{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command",
  "type": "registry:ui",
  "title": "Command",
  "description": "⌘K command palette with fuzzy search, groups, and keyboard navigation (cmdk).",
  "dependencies": [
    "@saasflare/ui",
    "cmdk"
  ],
  "files": [
    {
      "path": "components/ui/command.tsx",
      "type": "registry:ui",
      "content": "// @toreview\n\"use client\"\n\n/**\n * @fileoverview Command primitive — searchable command palette with keyboard navigation and grouping.\n * Built on cmdk. Includes a dialog variant for modal command menus.\n * Part of the Saasflare base component layer.\n * @module packages/ui/components/ui/command\n * @layer core\n *\n * @component\n * @example\n * import { Command, CommandInput, CommandList, CommandItem, CommandGroup } from '@saasflare/ui';\n * <Command>\n *   <CommandInput placeholder=\"Search...\" />\n *   <CommandList>\n *     <CommandGroup heading=\"Actions\">\n *       <CommandItem>New File</CommandItem>\n *     </CommandGroup>\n *   </CommandList>\n * </Command>\n */\n\nimport * as React from \"react\"\nimport { Command as CommandPrimitive } from \"cmdk\"\nimport { MagnifyingGlassIcon } from \"@saasflare/ui\"\n\nimport { cn } from \"@saasflare/ui\"\nimport { useSaasflareProps, type SaasflareComponentProps } from \"@saasflare/ui\"\nimport {\n  Dialog,\n  DialogContent,\n  DialogDescription,\n  DialogHeader,\n  DialogTitle,\n} from \"@saasflare/ui\"\n\n/**\n * Props for {@link Command}.\n *\n * Extends the cmdk root props with {@link SaasflareComponentProps} so the\n * design-system axes (surface/radius/animated/iconWeight) can be supplied\n * per-instance or inherited from the provider.\n */\ninterface CommandProps\n  extends Omit<React.ComponentProps<typeof CommandPrimitive>, keyof SaasflareComponentProps>,\n    SaasflareComponentProps {}\n\n/**\n * Command palette root — a searchable, keyboard-navigable command menu built on cmdk.\n *\n * Filters {@link CommandItem} children as the user types into {@link CommandInput}.\n * Resolves the design-system axes and emits them as data attributes. For a modal\n * ⌘K-style palette use {@link CommandDialog}.\n *\n * @component\n * @layer core\n */\nfunction Command({\n  className,\n  surface,\n  radius,\n  animated,\n  iconWeight,\n  ...props\n}: CommandProps) {\n  const sf = useSaasflareProps({ surface, radius, animated, iconWeight })\n\n  return (\n    <CommandPrimitive\n      {...props}\n      data-slot=\"command\"\n      data-surface={sf.surface}\n      data-radius={sf.radius}\n      data-animated={String(sf.animated)}\n      className={cn(\n        \"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground\",\n        className\n      )}\n    />\n  )\n}\n\n/**\n * Command palette inside a modal {@link Dialog} — the classic ⌘K menu.\n *\n * `title` and `description` feed a visually hidden header for screen readers;\n * the design-system axes are forwarded to both the dialog surface and the\n * inner {@link Command}.\n *\n * @component\n * @layer core\n */\nfunction CommandDialog({\n  title = \"Command Palette\",\n  description = \"Search for a command to run...\",\n  children,\n  className,\n  surface,\n  radius,\n  animated,\n  iconWeight,\n  ...props\n}: React.ComponentProps<typeof Dialog> &\n  SaasflareComponentProps & {\n    title?: string\n    description?: string\n    className?: string\n  }) {\n  return (\n    <Dialog {...props}>\n      <DialogContent\n        surface={surface}\n        radius={radius}\n        animated={animated}\n        iconWeight={iconWeight}\n        className={cn(\"overflow-hidden p-0\", className)}\n      >\n        <DialogHeader className=\"sr-only\">\n          <DialogTitle>{title}</DialogTitle>\n          <DialogDescription>{description}</DialogDescription>\n        </DialogHeader>\n        <Command\n          surface={surface}\n          radius={radius}\n          animated={animated}\n          iconWeight={iconWeight}\n          className=\"**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\"\n        >\n          {children}\n        </Command>\n      </DialogContent>\n    </Dialog>\n  )\n}\n\n/**\n * Search input that filters the command list as the user types, with a leading\n * magnifying-glass icon that follows the resolved `iconWeight` axis.\n *\n * @component\n * @layer core\n */\nfunction CommandInput({\n  className,\n  iconWeight,\n  ...props\n}: Omit<\n  React.ComponentProps<typeof CommandPrimitive.Input>,\n  keyof Pick<SaasflareComponentProps, \"iconWeight\">\n> &\n  Pick<SaasflareComponentProps, \"iconWeight\">) {\n  const sf = useSaasflareProps({ iconWeight })\n  return (\n    <div\n      data-slot=\"command-input-wrapper\"\n      className=\"flex h-9 items-center gap-2 border-b px-3\"\n    >\n      <MagnifyingGlassIcon weight={sf.iconWeight} className=\"size-4 shrink-0 opacity-50\" />\n      <CommandPrimitive.Input\n        data-slot=\"command-input\"\n        className={cn(\n          \"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n          className\n        )}\n        {...props}\n      />\n    </div>\n  )\n}\n\n/**\n * Scrollable container for the command groups and items.\n *\n * @component\n * @layer core\n */\nfunction CommandList({\n  className,\n  ...props\n}: React.ComponentProps<typeof CommandPrimitive.List>) {\n  return (\n    <CommandPrimitive.List\n      data-slot=\"command-list\"\n      className={cn(\n        \"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * Empty state shown when the current search matches no items.\n *\n * @component\n * @layer core\n */\nfunction CommandEmpty({\n  ...props\n}: React.ComponentProps<typeof CommandPrimitive.Empty>) {\n  return (\n    <CommandPrimitive.Empty\n      data-slot=\"command-empty\"\n      className=\"py-6 text-center text-sm\"\n      {...props}\n    />\n  )\n}\n\n/**\n * Labeled group of related command items — pass `heading` for the group label.\n *\n * @component\n * @layer core\n */\nfunction CommandGroup({\n  className,\n  ...props\n}: React.ComponentProps<typeof CommandPrimitive.Group>) {\n  return (\n    <CommandPrimitive.Group\n      data-slot=\"command-group\"\n      className={cn(\n        \"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * Visual divider between command groups.\n *\n * @component\n * @layer core\n */\nfunction CommandSeparator({\n  className,\n  ...props\n}: React.ComponentProps<typeof CommandPrimitive.Separator>) {\n  return (\n    <CommandPrimitive.Separator\n      data-slot=\"command-separator\"\n      className={cn(\"-mx-1 h-px bg-border\", className)}\n      {...props}\n    />\n  )\n}\n\n/**\n * Selectable command entry — highlighted on keyboard navigation and pointer hover.\n *\n * @component\n * @layer core\n */\nfunction CommandItem({\n  className,\n  ...props\n}: React.ComponentProps<typeof CommandPrimitive.Item>) {\n  return (\n    <CommandPrimitive.Item\n      data-slot=\"command-item\"\n      className={cn(\n        \"relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * Right-aligned keyboard-shortcut hint inside a {@link CommandItem}.\n *\n * @component\n * @layer core\n */\nfunction CommandShortcut({\n  className,\n  ...props\n}: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      data-slot=\"command-shortcut\"\n      className={cn(\n        \"ml-auto text-xs tracking-widest text-muted-foreground\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Command,\n  CommandDialog,\n  CommandInput,\n  CommandList,\n  CommandEmpty,\n  CommandGroup,\n  CommandItem,\n  CommandShortcut,\n  CommandSeparator,\n  type CommandProps,\n}\n",
      "target": "components/ui/command.tsx"
    }
  ],
  "$meta": {
    "source": "https://ui.saasflare.io/r/command.json"
  }
}
