{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-header-search",
  "title": "Header Search",
  "description": "An expandable search button for use in page headers with smooth transition animations.",
  "dependencies": [
    "lucide-react",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "@lema-ds/button",
    "@lema-ds/input",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider"
  ],
  "files": [
    {
      "path": "components/ds/ds-header-search.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Search, X } from \"lucide-react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { HTMLAttributes } from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useUILocale } from \"@/components/ui/ds-locale-provider\"\nimport { Button } from \"@/components/ui/button\"\nimport { Input } from \"@/components/ui/input\"\n\n// ── Types ──────────────────────────────────────────────────────────────────\n\nexport interface HeaderSearchProps\n  extends\n    Omit<HTMLAttributes<HTMLDivElement>, \"onChange\">,\n    VariantProps<typeof headerSearchVariants> {\n  value?: string\n  onChange?: (value: string) => void\n  onSearch?: (value: string) => void\n  placeholder?: string\n  autoFocus?: boolean\n  rounded?: \"full\" | \"md\" | \"none\"\n  locale?: UILocale\n}\n\nexport type HeaderSearchVariants = VariantProps<typeof headerSearchVariants>\n\n// ── Variants ───────────────────────────────────────────────────────────────\n\nexport const headerSearchVariants = cva(\n  \"relative flex items-center transition-all duration-300 ease-in-out\",\n  {\n    variants: {\n      isExpanded: {\n        true: \"w-full md:w-[300px] lg:w-[400px]\",\n        false: \"w-10\",\n      },\n      rounded: {\n        full: \"\",\n        md: \"\",\n        none: \"\",\n      },\n    },\n    defaultVariants: {\n      isExpanded: false,\n      rounded: \"full\",\n    },\n  }\n)\n\nexport const headerSearchButtonVariants = cva(\n  \"flex shrink-0 items-center justify-center transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none\",\n  {\n    variants: {\n      size: {\n        sm: \"size-8\",\n        md: \"size-10\",\n        lg: \"size-12\",\n      },\n      rounded: {\n        full: \"rounded-full\",\n        md: \"rounded-md\",\n        none: \"rounded-none\",\n      },\n    },\n    defaultVariants: { size: \"md\", rounded: \"full\" },\n  }\n)\n\n// ── HeaderSearch ───────────────────────────────────────────────────────────\n\nexport const HeaderSearch = React.forwardRef<HTMLDivElement, HeaderSearchProps>(\n  (\n    {\n      value,\n      onChange,\n      onSearch,\n      placeholder = \"Search...\",\n      isExpanded: isExpandedProp,\n      rounded = \"full\",\n      locale: localeProp,\n      className,\n      autoFocus = true,\n      ...props\n    },\n    ref\n  ) => {\n    const locale = useUILocale(localeProp)\n    const [isExpanded, setIsExpanded] = React.useState(isExpandedProp || false)\n    const [searchValue, setSearchValue] = React.useState(value || \"\")\n    const inputRef = React.useRef<HTMLInputElement>(null)\n\n    React.useEffect(() => {\n      if (isExpanded && autoFocus) {\n        inputRef.current?.focus()\n      }\n    }, [isExpanded, autoFocus])\n\n    const handleToggle = () => {\n      setIsExpanded(!isExpanded)\n      if (isExpanded) {\n        setSearchValue(\"\")\n        onChange?.(\"\")\n      }\n    }\n\n    const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n      const newValue = e.target.value\n      setSearchValue(newValue)\n      onChange?.(newValue)\n    }\n\n    const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n      if (e.key === \"Enter\") onSearch?.(searchValue)\n      if (e.key === \"Escape\") handleToggle()\n    }\n\n    const roundedClasses = {\n      full: \"rounded-full\",\n      md: \"rounded-md\",\n      none: \"rounded-none\",\n    }\n\n    return (\n      <div\n        ref={ref}\n        data-slot=\"header-search\"\n        className={cn(headerSearchVariants({ isExpanded, rounded }), className)}\n        {...props}\n      >\n        <div className=\"flex w-full items-center\">\n          {!isExpanded ? (\n            <Button\n              data-slot=\"header-search-toggle\"\n              variant=\"ghost\"\n              size=\"icon\"\n              className={cn(headerSearchButtonVariants({ rounded }))}\n              onClick={handleToggle}\n              aria-label={UI_I18N[locale].headerSearch.open}\n            >\n              <Search className=\"size-5\" />\n            </Button>\n          ) : (\n            <div\n              data-slot=\"header-search-input-wrapper\"\n              className=\"relative flex w-full animate-in items-center duration-200 zoom-in-95 fade-in\"\n            >\n              <Search className=\"absolute left-3 size-4 text-muted-foreground\" />\n              <Input\n                data-slot=\"header-search-input\"\n                ref={inputRef}\n                value={searchValue}\n                onChange={handleInputChange}\n                onKeyDown={handleKeyDown}\n                placeholder={placeholder}\n                className={cn(\n                  \"h-10 w-full pr-10 pl-9 ring-offset-background focus-visible:ring-1\",\n                  roundedClasses[rounded || \"full\"]\n                )}\n              />\n              <Button\n                data-slot=\"header-search-close\"\n                variant=\"ghost\"\n                size=\"icon\"\n                className={cn(\n                  \"absolute right-1 size-8 hover:bg-transparent\",\n                  roundedClasses[rounded || \"full\"]\n                )}\n                onClick={handleToggle}\n                aria-label={UI_I18N[locale].headerSearch.close}\n              >\n                <X className=\"size-4 text-muted-foreground transition-colors hover:text-foreground\" />\n              </Button>\n            </div>\n          )}\n        </div>\n      </div>\n    )\n  }\n)\n\nHeaderSearch.displayName = \"HeaderSearch\"\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
