{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "search-dialog",
  "type": "registry:ui",
  "title": "Search Dialog",
  "description": "A wide search palette with grouped results.",
  "categories": [
    "overlays"
  ],
  "dependencies": [
    "@hugeicons/core-free-icons@4.4.0",
    "@hugeicons/react@1.1.10"
  ],
  "registryDependencies": [
    "https://sprout.tulipfarm.ai/r/sprout-base.json",
    "https://sprout.tulipfarm.ai/r/button.json",
    "https://sprout.tulipfarm.ai/r/command.json",
    "https://sprout.tulipfarm.ai/r/dialog.json",
    "https://sprout.tulipfarm.ai/r/kbd.json",
    "https://sprout.tulipfarm.ai/r/toggle.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/search-dialog.tsx",
      "type": "registry:ui",
      "target": "components/ui/search-dialog.tsx",
      "content": "'use client';\n\nimport { Children, Fragment, isValidElement, type ReactElement, type ReactNode, type Ref } from 'react';\nimport { CloseIcon } from '@/lib/sprout/icons/close-icon';\nimport { cn } from '@/lib/sprout/classes';\nimport { Button } from '@/components/ui/button';\nimport { Kbd } from '@/components/ui/kbd';\nimport { Toggle } from '@/components/ui/toggle';\nimport { Command, CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/ui/command';\nimport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogTitle,\n  type DialogContentProps,\n} from '@/components/ui/dialog';\n\nexport interface SearchDialogProps {\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  title: string;\n  description: string;\n  className?: string;\n  container?: DialogContentProps['container'];\n  children: ReactNode;\n}\n\nexport function SearchDialog({\n  open,\n  onOpenChange,\n  title,\n  description,\n  className,\n  container,\n  children,\n}: SearchDialogProps) {\n  return (\n    <Dialog open={open} onOpenChange={next => onOpenChange(next)}>\n      <DialogContent\n        data-slot=\"search-dialog\"\n        placement=\"top\"\n        showCloseButton={false}\n        container={container}\n        className={cn('sprout-search-dialog', className)}\n      >\n        <DialogTitle className=\"sprout-command-sr-only\">{title}</DialogTitle>\n        <DialogDescription className=\"sprout-command-sr-only\">{description}</DialogDescription>\n        <Command shouldFilter={false} loop label={title} className=\"sprout-search-command\">\n          {children}\n        </Command>\n      </DialogContent>\n    </Dialog>\n  );\n}\n\nexport interface SearchInputProps {\n  ref?: Ref<HTMLInputElement>;\n  value: string;\n  onValueChange: (value: string) => void;\n  placeholder: string;\n  label: string;\n  closeLabel?: string;\n}\n\nexport function SearchInput({\n  ref,\n  value,\n  onValueChange,\n  placeholder,\n  label,\n  closeLabel = 'Close search',\n}: SearchInputProps) {\n  return (\n    <div data-slot=\"search-input\" className=\"sprout-search-input\">\n      <CommandInput\n        ref={ref}\n        value={value}\n        onValueChange={onValueChange}\n        placeholder={placeholder}\n        aria-label={label}\n      />\n      <DialogClose render={<Button variant=\"ghost\" size=\"icon-sm\" aria-label={closeLabel} />}>\n        <CloseIcon size=\"md\" aria-hidden=\"true\" />\n      </DialogClose>\n    </div>\n  );\n}\n\nexport interface SearchFiltersProps {\n  label: string;\n  children: ReactNode;\n}\n\nexport function SearchFilters({ label, children }: SearchFiltersProps) {\n  return (\n    <div data-slot=\"search-filters\" role=\"group\" aria-label={label} className=\"sprout-search-filters\">\n      {children}\n    </div>\n  );\n}\n\nexport interface SearchFilterProps {\n  pressed: boolean;\n  onPressedChange: (pressed: boolean) => void;\n  icon?: ReactNode;\n  children: ReactNode;\n}\n\nexport function SearchFilter({ pressed, onPressedChange, icon, children }: SearchFilterProps) {\n  return (\n    <Toggle\n      data-slot=\"search-filter\"\n      variant=\"outline\"\n      size=\"sm\"\n      pressed={pressed}\n      onPressedChange={next => onPressedChange(next)}\n    >\n      {icon}\n      {children}\n    </Toggle>\n  );\n}\n\nexport interface SearchListProps {\n  label: string;\n  children: ReactNode;\n}\n\nexport function SearchList({ label, children }: SearchListProps) {\n  return (\n    <CommandList aria-label={label} className=\"sprout-search-list\">\n      {children}\n    </CommandList>\n  );\n}\n\nexport interface SearchGroupProps {\n  heading: string;\n  count: number;\n  children: ReactNode;\n}\n\nexport function SearchGroup({ heading, count, children }: SearchGroupProps) {\n  if (count === 0) return null;\n  return (\n    <CommandGroup\n      className=\"sprout-search-group\"\n      heading={\n        <span className=\"sprout-search-group-heading\">\n          {heading}{' '}\n          <span data-slot=\"search-group-count\" className=\"sprout-search-group-count\">\n            {count}\n          </span>\n        </span>\n      }\n    >\n      {children}\n    </CommandGroup>\n  );\n}\n\nexport interface SearchItemIconProps {\n  children: ReactNode;\n}\n\nexport function SearchItemIcon({ children }: SearchItemIconProps) {\n  return (\n    <span data-slot=\"search-item-icon\" className=\"sprout-search-item-icon\">\n      {children}\n    </span>\n  );\n}\n\nexport interface SearchItemProps {\n  value: string;\n  onSelect: () => void;\n  media: ReactNode;\n  title: string;\n  meta?: string | undefined;\n  detail?: string | undefined;\n  trailing?: ReactNode;\n}\n\nexport function SearchItem({ value, onSelect, media, title, meta, detail, trailing }: SearchItemProps) {\n  return (\n    <CommandItem value={value} onSelect={() => onSelect()} className=\"sprout-search-item\">\n      <span data-slot=\"search-item-media\" className=\"sprout-search-item-media\">\n        {media}\n      </span>\n      <span className=\"sprout-search-item-text\">\n        <span className=\"sprout-search-item-line\">\n          <span data-slot=\"search-item-title\" className=\"sprout-search-item-title\">\n            {title}\n          </span>\n          {meta && (\n            <>\n              <span aria-hidden=\"true\" className=\"sprout-search-item-dot\">\n                ·\n              </span>\n              <span data-slot=\"search-item-meta\" className=\"sprout-search-item-meta\">\n                {meta}\n              </span>\n            </>\n          )}\n        </span>\n        {detail && (\n          <span data-slot=\"search-item-detail\" className=\"sprout-search-item-detail\">\n            {detail}\n          </span>\n        )}\n      </span>\n      {trailing && (\n        <span data-slot=\"search-item-trailing\" className=\"sprout-search-item-trailing\">\n          {trailing}\n        </span>\n      )}\n      <Kbd variant=\"outline\" aria-hidden=\"true\" className=\"sprout-search-item-enter\">\n        ↵\n      </Kbd>\n    </CommandItem>\n  );\n}\n\nfunction tiles(media: ReactNode) {\n  const nodes =\n    isValidElement(media) && media.type === Fragment\n      ? (media as ReactElement<{ children?: ReactNode }>).props.children\n      : media;\n  return Children.toArray(nodes).map((node, index) => (\n    <span key={index} data-slot=\"search-empty-tile\" className=\"sprout-search-empty-tile\">\n      {node}\n    </span>\n  ));\n}\n\nexport interface SearchEmptyProps {\n  media?: ReactNode;\n  title: string;\n  description: string;\n  action?: ReactNode;\n}\n\nexport function SearchEmpty({ media, title, description, action }: SearchEmptyProps) {\n  return (\n    <div data-slot=\"search-empty\" role=\"status\" className=\"sprout-search-empty\">\n      {media && (\n        <div aria-hidden=\"true\" className=\"sprout-search-empty-media\">\n          <span className=\"sprout-search-empty-tiles\">{tiles(media)}</span>\n        </div>\n      )}\n      <div className=\"sprout-search-empty-text\">\n        <p className=\"sprout-search-empty-title\">{title}</p>\n        <p className=\"sprout-search-empty-description\">{description}</p>\n      </div>\n      {action}\n    </div>\n  );\n}\n\nexport interface SearchFooterProps {\n  children: ReactNode;\n}\n\nexport function SearchFooter({ children }: SearchFooterProps) {\n  return (\n    <footer data-slot=\"search-footer\" className=\"sprout-search-footer\">\n      {children}\n    </footer>\n  );\n}\n\nexport interface SearchHintProps {\n  keys: string;\n  children: ReactNode;\n}\n\nexport function SearchHint({ keys, children }: SearchHintProps) {\n  return (\n    <span data-slot=\"search-hint\" className=\"sprout-search-hint\">\n      <Kbd variant=\"outline\">{keys}</Kbd>\n      {children}\n    </span>\n  );\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/close-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/close-icon.tsx",
      "content": "import { Cancel01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const CloseIcon = /* @__PURE__ */ createIcon(glyph, 'CloseIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/create-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/create-icon.tsx",
      "content": "import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react';\nimport type { ReactElement, Ref, SVGProps } from 'react';\n\nexport const iconSizes = {\n  xs: 12,\n  sm: 14,\n  md: 16,\n  lg: 18,\n  xl: 20,\n  '2xl': 24,\n} as const;\n\nexport type IconSize = keyof typeof iconSizes;\n\nexport const iconStrokeWidth = 1.5;\n\nexport type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {\n  size?: IconSize | number;\n  ref?: Ref<SVGSVGElement>;\n};\n\nexport type IconComponent = (props: IconProps) => ReactElement;\n\nexport function createIcon(glyph: IconSvgElement, name: string): IconComponent {\n  const Icon = ({ size = '2xl', strokeWidth = iconStrokeWidth, ...props }: IconProps) => (\n    <HugeiconsIcon\n      icon={glyph}\n      size={typeof size === 'number' ? size : iconSizes[size]}\n      strokeWidth={Number(strokeWidth)}\n      {...props}\n    />\n  );\n  Icon.displayName = name;\n  return Icon;\n}\n"
    }
  ],
  "css": {
    "@layer components": {
      ".sprout-dialog-content.sprout-search-dialog": {
        "--sprout-dialog-padding": "0px",
        "flex-direction": "column",
        "gap": "0",
        "padding": "0",
        "display": "flex",
        "overflow": "hidden"
      },
      ".sprout-search-command.sprout-command": {
        "border-radius": "inherit",
        "background": "none",
        "flex": "1",
        "min-height": "0",
        "padding": "0"
      },
      ".sprout-search-input": {
        "border-bottom": "1px solid var(--sprout-line)",
        "flex-shrink": "0",
        "align-items": "center",
        "gap": "4px",
        "height": "48px",
        "padding-inline": "4px 8px",
        "display": "flex"
      },
      ".sprout-search-input > .sprout-command-input-wrapper": {
        "flex": "1",
        "min-width": "0",
        "height": "100%",
        "padding": "0"
      },
      ".sprout-search-input .sprout-command-input-group": {
        "background": "none",
        "border": "0",
        "border-radius": "0",
        "gap": "10px",
        "height": "100%",
        "padding-inline": "12px 4px"
      },
      ".sprout-search-input .sprout-command-input": {
        "font-size": "var(--sprout-text-base)"
      },
      ".sprout-search-filters": {
        "border-bottom": "1px solid var(--sprout-line)",
        "scrollbar-width": "none",
        "flex-shrink": "0",
        "gap": "6px",
        "padding": "8px 12px",
        "display": "flex",
        "overflow-x": "auto"
      },
      ".sprout-search-filters::-webkit-scrollbar": {
        "display": "none"
      },
      ".sprout-search-dialog .sprout-search-list": {
        "height": "min(28rem, 60dvh)",
        "max-height": "none",
        "padding": "0 8px 8px",
        "scroll-padding-block": "8px"
      },
      ".sprout-search-list > .sprout-command-list-sizer": {
        "min-height": "100%"
      },
      ".sprout-search-group.sprout-command-group": {
        "padding": "4px 0 0",
        "overflow": "visible"
      },
      ".sprout-search-group + .sprout-search-group": {
        "border-top": "1px dashed var(--sprout-line)",
        "margin-top": "4px"
      },
      ".sprout-search-group > .sprout-command-group-heading": {
        "padding": "10px 8px 4px"
      },
      ".sprout-search-group-heading": {
        "align-items": "center",
        "gap": "6px",
        "display": "flex"
      },
      ".sprout-search-group-count": {
        "background": "var(--sprout-hover)",
        "font-variant-numeric": "tabular-nums",
        "text-align": "center",
        "border-radius": "4px",
        "min-width": "8px",
        "padding-inline": "4px"
      },
      ".sprout-search-item.sprout-command-item": {
        "border-radius": "calc(var(--sprout-radius-panel) - 4px)",
        "overflow-wrap": "normal",
        "gap": "10px",
        "min-height": "34px",
        "padding": "6px 12px",
        "font-size": ".875rem"
      },
      ".sprout-search-item > .sprout-command-item-check": {
        "display": "none"
      },
      ".sprout-search-item-media, .sprout-search-item-icon": {
        "flex-shrink": "0",
        "justify-content": "center",
        "align-items": "center",
        "width": "20px",
        "height": "20px",
        "display": "flex"
      },
      ".sprout-search-item-icon": {
        "color": "var(--sprout-muted)",
        "width": "18px",
        "height": "20px"
      },
      ".sprout-search-item-icon svg": {
        "width": "18px",
        "height": "18px"
      },
      ".sprout-search-item-media svg": {
        "flex-shrink": "0"
      },
      ".sprout-search-item-text": {
        "flex-direction": "column",
        "flex": "1",
        "min-width": "0",
        "display": "flex"
      },
      ".sprout-search-item-line": {
        "align-items": "baseline",
        "gap": "6px",
        "min-width": "0",
        "display": "flex"
      },
      ".sprout-search-item-title, .sprout-search-item-meta, .sprout-search-item-detail": {
        "text-overflow": "ellipsis",
        "white-space": "nowrap",
        "min-width": "0",
        "overflow": "hidden"
      },
      ".sprout-search-item-title": {
        "flex-shrink": "1",
        "font-weight": "500"
      },
      ".sprout-search-item-dot, .sprout-search-item-meta, .sprout-search-item-detail, .sprout-search-item-trailing": {
        "color": "var(--sprout-muted)"
      },
      ".sprout-search-item-dot": {
        "flex-shrink": "0"
      },
      ".sprout-search-item-meta": {
        "flex-shrink": "0",
        "max-width": "40%"
      },
      ".sprout-search-item-detail": {
        "font-size": "var(--sprout-text-xs)",
        "line-height": "1rem"
      },
      ".sprout-search-item-trailing": {
        "font-size": "var(--sprout-text-xs)",
        "white-space": "nowrap",
        "flex-shrink": "0"
      },
      ".sprout-search-item-enter, .sprout-search-item[data-selected] > .sprout-search-item-trailing": {
        "display": "none"
      },
      ".sprout-search-item[data-selected] > .sprout-search-item-enter": {
        "display": "inline-flex"
      },
      ".sprout-search-empty": {
        "box-sizing": "border-box",
        "text-align": "center",
        "flex-direction": "column",
        "flex": "1",
        "justify-content": "center",
        "align-items": "center",
        "gap": "12px",
        "min-height": "100%",
        "padding": "16px 24px",
        "display": "flex"
      },
      ".sprout-search-empty-media": {
        "background-image": "linear-gradient(var(--sprout-line) 1px, transparent 1px),\n      linear-gradient(90deg, var(--sprout-line) 1px, transparent 1px)",
        "background-size": "16px 16px",
        "justify-content": "center",
        "align-items": "center",
        "width": "224px",
        "height": "112px",
        "display": "flex",
        "mask-image": "radial-gradient(closest-side, oklch(0% 0 0) 30%, #0000 100%)"
      },
      ".sprout-search-empty-tiles": {
        "align-items": "center",
        "display": "flex"
      },
      ".sprout-search-empty-tile": {
        "border": "1px solid var(--sprout-line)",
        "border-radius": "var(--sprout-radius-panel)",
        "background": "var(--sprout-surface)",
        "width": "44px",
        "height": "44px",
        "box-shadow": "var(--sprout-shadow-panel)",
        "color": "var(--sprout-muted)",
        "justify-content": "center",
        "align-items": "center",
        "margin-inline": "-4px",
        "display": "flex"
      },
      ".sprout-search-empty-tile:first-child:not(:only-child)": {
        "rotate": "-8deg"
      },
      ".sprout-search-empty-tile:last-child:not(:only-child)": {
        "rotate": "8deg"
      },
      ".sprout-search-empty-tile > svg": {
        "width": "20px",
        "height": "20px"
      },
      ".sprout-search-empty-text": {
        "flex-direction": "column",
        "gap": "4px",
        "max-width": "24rem",
        "display": "flex"
      },
      ".sprout-search-empty-title": {
        "font-weight": "600"
      },
      ".sprout-search-empty-description": {
        "color": "var(--sprout-muted)",
        "text-wrap": "pretty"
      },
      ".sprout-search-empty-title, .sprout-search-empty-description": {
        "margin": "0"
      },
      ".sprout-search-footer": {
        "border-top": "1px solid var(--sprout-line)",
        "background": "color-mix(in oklab, var(--sprout-canvas) 70%, var(--sprout-surface))",
        "height": "44px",
        "color": "var(--sprout-muted)",
        "font-size": "var(--sprout-text-xs)",
        "flex-shrink": "0",
        "align-items": "center",
        "gap": "16px",
        "padding-inline": "16px",
        "line-height": "1rem",
        "display": "none"
      },
      ".sprout-search-hint": {
        "white-space": "nowrap",
        "align-items": "center",
        "gap": "6px",
        "display": "inline-flex"
      },
      "@media (width >= 40rem)": {
        ".sprout-dialog-content.sprout-search-dialog": {
          "max-width": "42rem"
        },
        ".sprout-search-footer": {
          "display": "flex"
        }
      }
    }
  },
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/search-dialog/",
  "meta": {
    "source": "packages/sprout/src/components/search-dialog.tsx"
  }
}
