import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command" import { INPUT_WIDGETS, WIDGET_DESCRIPTIONS, WIDGET_LABELS, type WidgetKind, } from "./widgets" const KINDS = Object.keys(WIDGET_LABELS) as WidgetKind[] const GROUPS = [ ["Show a value", KINDS.filter((kind) => !INPUT_WIDGETS.has(kind))], ["Control something", KINDS.filter((kind) => INPUT_WIDGETS.has(kind))], ] as const /** ⌘P on a dashboard being edited: the flow canvas's add-a-node palette, for widgets. */ export function WidgetPalette({ open, onOpenChange, onAdd, }: { open: boolean onOpenChange: (open: boolean) => void onAdd: (kind: WidgetKind) => void }) { // Unmounted rather than faded, for the reason the flow palette gives. if (!open) return null return ( Nothing matches that. {GROUPS.map(([heading, kinds]) => ( {kinds.map((kind) => ( { onOpenChange(false) onAdd(kind) }} > {WIDGET_LABELS[kind]} {WIDGET_DESCRIPTIONS[kind]} ))} ))} ) }