{"version":3,"file":"Command.context.cjs","sources":["../../../../../src/components/overlay/command/context/Command.context.ts"],"sourcesContent":["import { createContext, type Dispatch, type RefObject, type SetStateAction, useContext } from 'react'\r\n\r\n/** Internal state shared by all Command compound slots. */\r\nexport type CommandContextValue = {\r\n    /** Current search string entered in `Command.Input`. */\r\n    search: string\r\n    setSearch: Dispatch<SetStateAction<string>>\r\n    /** ID of the currently highlighted `Command.Item` (`aria-activedescendant`). */\r\n    activeId: string | undefined\r\n    setActiveId: Dispatch<SetStateAction<string | undefined>>\r\n    /** Stable ID for `Command.List` — referenced by `Command.Input` as `aria-controls`. */\r\n    listId: string\r\n    /** Ref attached to the `Command.List` DOM node for keyboard navigation DOM queries. */\r\n    listRef: RefObject<HTMLDivElement | null>\r\n}\r\n\r\nexport const CommandContext = createContext<CommandContextValue | null>(null)\r\n\r\n/** Consume the Command context. Throws when used outside `Command.Content`. */\r\nexport const useCommandContext = (): CommandContextValue => {\r\n    const ctx = useContext(CommandContext)\r\n    if (!ctx) {\r\n        throw new Error(\r\n            'Command compound components must be rendered inside <Command.Content>.',\r\n        )\r\n    }\r\n    return ctx\r\n}\r\n"],"names":["CommandContext","createContext","useCommandContext","ctx","useContext"],"mappings":"yGAgBaA,EAAiBC,EAAAA,cAA0C,IAAI,EAG/DC,EAAoB,IAA2B,CACxD,MAAMC,EAAMC,EAAAA,WAAWJ,CAAc,EACrC,GAAI,CAACG,EACD,MAAM,IAAI,MACN,wEAAA,EAGR,OAAOA,CACX"}