import React from "react"; import type { ActionImpl, ActionId } from "kbar"; interface IResultITemProps { action: ActionImpl; active: boolean; currentRootActionId: ActionId; } export const ResultItem = React.forwardRef( ({ action, active, currentRootActionId }, ref) => { const ancestors = React.useMemo(() => { if (!currentRootActionId) return action.ancestors; const index = action.ancestors.findIndex( (ancestor) => ancestor.id === currentRootActionId, ); return action.ancestors.slice(index + 1); }, [action.ancestors, currentRootActionId]); return (
{action.icon && action.icon}
{ancestors.length > 0 && ancestors.map((ancestor) => ( {ancestor.name} ))} {action.name}
{action.subtitle && ( {action.subtitle} )}
{action.shortcut?.length ? (
{action.shortcut.map((sc) => ( {sc} ))}
) : null}
); }, ); ResultItem.displayName = "ResultItem";