import { ArrowDownIcon, ArrowUpIcon } from "lucide-react"; import { type ComponentProps, type ReactNode, useLayoutEffect, useRef } from "react"; import { Command, CommandFooter, CommandInput, CommandPanel } from "./ui/command"; import { Kbd, KbdGroup } from "./ui/kbd"; type CommandPaletteContentProps = Omit, "children"> & { readonly children: ReactNode; readonly escapeLabel?: ReactNode; readonly footerActionLabel?: ReactNode; readonly footerTrailing?: ReactNode; readonly inputAccessory?: ReactNode; readonly inputProps: ComponentProps; readonly panelClassName?: string; readonly showBackHint?: boolean; readonly testId?: string; }; /** * Shared command palette chrome. Palette modes provide their query behavior, * results, and optional input accessory while retaining one input, panel, and * keyboard-hint gutter. */ export function CommandPaletteContent({ children, escapeLabel = "Close", footerActionLabel, footerTrailing, inputAccessory, inputProps, panelClassName, showBackHint, testId, ...commandProps }: CommandPaletteContentProps) { const inputRef = useRef(null); // Direct-open flows replace the initial palette view after the dialog has // already moved focus. Reclaim it when the replacement input mounts so // typing cannot continue in the composer behind the modal. useLayoutEffect(() => { inputRef.current?.focus(); }, []); return (
{inputAccessory}
{children}
Navigate {footerActionLabel !== undefined ? ( Enter {footerActionLabel} ) : null} {showBackHint ? ( Backspace Back ) : null} Esc {escapeLabel}
{footerTrailing}
); }