/** * createCommand - the HEADLESS core behind (the ⌘K palette): the * fuzzy-filtered result list, roving active index, run/close, the global toggle * hotkey, and the WAI-ARIA combobox wiring (activedescendant) - as prop-getters * you spread onto your own input/list/option markup. The overlay lifecycle * (focus-trap + scroll-lock + dismissal) is a separate concern; pair this with * `createOverlay`. Runes-based, like `createListbox`. */ import type { CommandItem } from './ui-app.types'; export type CommandConfig = { commands: () => ReadonlyArray; /** Whether the palette is open (used to reset query/active on open). */ open: () => boolean; onRun?: (cmd: CommandItem) => void; /** Close the palette (a command ran, or requested by the input). */ onClose?: () => void; /** Toggle open/closed - fired by the global hotkey. */ onToggleOpen?: () => void; /** Global toggle hotkey (Cmd/Ctrl + key). `false` disables it. Default 'mod+k'. */ hotkey?: () => 'mod+k' | 'mod+p' | false; /** DOM hook to scroll the newly-active option into view. */ scrollActiveIntoView?: (index: number) => void; }; export declare function createCommand(config: CommandConfig): { query: string; readonly active: number; readonly results: CommandItem[]; isActive: (i: number) => boolean; move: (delta: number) => void; run: (cmd: CommandItem | undefined) => void; /** Arrow/Enter handler - attach to the panel (catches events bubbled from the * input) so keys work whether dispatched on the input or the dialog. */ onKeydown: (e: KeyboardEvent) => void; /** Id of the list element (for aria-controls). */ listId: string; /** Id of the option at `i` (for aria-activedescendant + item id). */ optionId: (i: number) => string; /** Spread onto the search ``. */ inputProps: () => { role: "combobox"; 'aria-expanded': true; 'aria-controls': string; 'aria-activedescendant': string | undefined; value: string; oninput: (e: Event) => void; }; /** Spread onto the `