import { useUniqueId } from "@charcuterie/logic" import type { ControlSize } from "@charcuterie/tokens" import type { KeyboardEvent as ReactKeyboardEvent, ReactNode, RefObject, } from "react" import { useEffect, useMemo, useRef, useState } from "react" import { usePanelItemSize } from "../Overlay/usePanelItemSize.ts" import { SearchInput } from "../SearchInput/SearchInput.tsx" import { toClassName } from "../toClassName.ts" import { CommandPaletteFooter } from "./CommandPaletteFooter.tsx" import { CommandPaletteOption } from "./CommandPaletteOption.tsx" import { buildCommandPaletteSections, type CommandPaletteGroup, type CommandPaletteItem, type CommandPalettePrefix, type CommandPaletteRow, } from "./commandPaletteSections.ts" export type CommandPalettePanelProps = { /** The glyph inside the clear button. Without one, there is no clear button — Escape closes. */ clearIcon?: ReactNode /** The query the palette opens with, when the caller does not own `query`. Read once per open. */ defaultQuery?: string /** Shown when a query matches nothing and there is no fallback row. Default "No matches". */ emptyLabel?: string /** * The strip under the list. Default: the keys, and each prefix * with its target. `null` draws none. */ footer?: ReactNode /** The title of a prefix command's row. Default `Search