{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "search-field",
  "type": "registry:ui",
  "title": "Search Field",
  "description": "A search input with a magnifier and a clear button.",
  "categories": [
    "forms"
  ],
  "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/input-group.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/search-field.tsx",
      "type": "registry:ui",
      "target": "components/ui/search-field.tsx",
      "content": "'use client';\n\nimport { useRef, type KeyboardEvent } from 'react';\nimport { CloseIcon } from '@/lib/sprout/icons/close-icon';\nimport { SearchIcon } from '@/lib/sprout/icons/search-icon';\nimport { cn } from '@/lib/sprout/classes';\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/components/ui/input-group';\n\nexport interface SearchFieldProps {\n  label: string;\n  value: string;\n  onChange: (value: string) => void;\n  placeholder?: string | undefined;\n  maxLength?: number | undefined;\n  id?: string | undefined;\n  className?: string | undefined;\n}\n\nexport function SearchField({ label, value, onChange, placeholder, maxLength, id, className }: SearchFieldProps) {\n  const input = useRef<HTMLInputElement>(null);\n  const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n    if (event.key !== 'Escape' || !value) return;\n    event.preventDefault();\n    event.stopPropagation();\n    onChange('');\n  };\n  return (\n    <InputGroup data-slot=\"search-field\" className={cn('sprout-search-field', className)}>\n      <InputGroupAddon>\n        <SearchIcon size=\"md\" aria-hidden=\"true\" />\n      </InputGroupAddon>\n      <InputGroupInput\n        ref={input}\n        id={id}\n        type=\"search\"\n        aria-label={label}\n        maxLength={maxLength}\n        value={value}\n        placeholder={placeholder ?? label}\n        autoComplete=\"off\"\n        spellCheck={false}\n        onChange={event => onChange(event.currentTarget.value)}\n        onKeyDown={onKeyDown}\n      />\n      {value && (\n        <InputGroupAddon align=\"inline-end\">\n          <InputGroupButton\n            data-slot=\"search-field-clear\"\n            size=\"icon\"\n            aria-label=\"Clear search\"\n            className=\"sprout-search-field-clear\"\n            onClick={() => {\n              onChange('');\n              input.current?.focus();\n            }}\n          >\n            <CloseIcon size=\"sm\" aria-hidden=\"true\" />\n          </InputGroupButton>\n        </InputGroupAddon>\n      )}\n    </InputGroup>\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"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/search-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/search-icon.tsx",
      "content": "import { Search01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const SearchIcon = /* @__PURE__ */ createIcon(glyph, 'SearchIcon');\n"
    }
  ],
  "css": {
    "@layer components": {
      ".sprout-search-field": {
        "max-width": "24rem"
      },
      "@media (prefers-reduced-motion: no-preference)": {
        ".sprout-search-field-clear": {
          "animation": "sprout-search-field-clear-in var(--sprout-motion-fast, .12s) var(--sprout-motion-ease, ease-out)"
        }
      },
      "@keyframes sprout-search-field-clear-in": {
        "from": {
          "opacity": "0",
          "transform": "scale(.8)"
        }
      }
    }
  },
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/search-field/",
  "meta": {
    "source": "packages/sprout/src/components/search-field.tsx"
  }
}
