import type { CSSProperties, ReactNode } from 'react'; import type { SxProp } from '../Layout/sx.cjs'; export interface CommandPaletteItem { /** Stable identifier — used as React key. */ id: string; /** Visible label. */ label: string; /** When provided, selecting the item navigates to this href via `onItemSelect` (consumer wires the router). */ href?: string; /** Custom select handler — overrides default href navigation. */ onSelect?: () => void; /** Additional searchable terms beyond the label. */ keywords?: string[]; /** Right-aligned badge (e.g. "new"). */ badge?: ReactNode; /** Leading icon. Defaults to a section-derived icon if not provided. */ icon?: ReactNode; /** Right-aligned hint text (e.g. a path). Hidden on the active row. */ hint?: ReactNode; /** Keyboard shortcut hint (e.g. `⌘N`), rendered as a `` that stays visible on the active row. */ shortcut?: ReactNode; /** Disable selection. */ disabled?: boolean; } export interface CommandPaletteSection { /** Group heading rendered above items. */ title: string; /** Items in this group. */ items: CommandPaletteItem[]; /** Pin the group above the others. Group headings stick to the top while scrolling either way. */ pinned?: boolean; } export interface CommandPaletteProps { /** Controlled open state. */ open: boolean; /** Open-state setter. */ onOpenChange: (open: boolean) => void; /** Grouped item sections. */ sections: CommandPaletteSection[]; /** Search input placeholder. */ placeholder?: string; /** Title for assistive tech (visually hidden). */ title?: string; /** Description for assistive tech (visually hidden). */ description?: string; /** Empty-state content. */ emptyText?: ReactNode; /** Footer content. Defaults to keyboard hints. Pass `false` to hide. */ footer?: ReactNode | false; /** * Fires when the user selects an item. Use this to navigate via your router. * If the item has its own `onSelect`, that runs first. */ onItemSelect?: (item: CommandPaletteItem) => void; /** Extra className on the dialog content. */ contentClassName?: string; /** * Item ids to show under a "Recent" group while the search is empty. * Controlled; pair with `onRecentChange`. Omit to let the palette track them itself. */ recent?: string[]; /** Fires with the updated recent ids (most recent first) after a selection. */ onRecentChange?: (ids: string[]) => void; /** localStorage key to persist self-tracked recents across sessions. Ignored when `recent` is controlled. */ persistRecentKey?: string; /** Max recent items shown/kept. Default: 5. */ recentLimit?: number; /** Heading of the recent group. Default: `Recent`. */ recentTitle?: string; /** * Fires with the typed text on every change, and with `''` when the palette closes. * Use it to load items from a server (e.g. search results) into `sections`. */ onSearchChange?: (search: string) => void; } export interface CommandPaletteTriggerProps { /** Click handler — usually `() => setOpen(true)`. */ onClick: () => void; /** Visible label. */ label?: string; /** Keyboard shortcut hint. Defaults to "⌘K". */ shortcut?: string; /** Extra className. */ className?: string; /** Inline style for the trigger button. */ style?: CSSProperties; /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */ sx?: SxProp; } export interface UseCommandPaletteOptions { /** Bind the ⌘K / Ctrl+K hotkey. Default: true. */ hotkey?: boolean; } export interface UseCommandPaletteReturn { open: boolean; setOpen: (open: boolean) => void; toggle: () => void; }