{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "expandable-search",
  "title": "Expandable Search",
  "description": "Search icon that expands into a text input and stays open while filled.",
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "@ikas/motion",
    "@ikas/utils"
  ],
  "files": [
    {
      "path": "registry/ikas/expandable-search.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion } from \"motion/react\"\nimport { SearchIcon, XIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { springOrInstant } from \"@/lib/motion\"\n\ntype ExpandableSearchProps = {\n  value: string\n  onValueChange: (value: string) => void\n  placeholder?: string\n  className?: string\n  /** Accessible name of the input. Defaults to the placeholder. */\n  label?: string\n}\n\n/** A search icon that opens into an input. Stays open while it has a value. */\nfunction ExpandableSearch({ value, onValueChange, placeholder = \"Ara\", className, label }: ExpandableSearchProps) {\n  const [open, setOpen] = React.useState(false)\n  const [mobile, setMobile] = React.useState(false)\n  const inputRef = React.useRef<HTMLInputElement>(null)\n  const reduce = useReducedMotion()\n  const expanded = open || value !== \"\"\n\n  React.useEffect(() => {\n    const query = window.matchMedia(\"(max-width: 639px)\")\n    const update = () => setMobile(query.matches)\n    update()\n    query.addEventListener(\"change\", update)\n    return () => query.removeEventListener(\"change\", update)\n  }, [])\n\n  function expand() {\n    setOpen(true)\n    requestAnimationFrame(() => inputRef.current?.focus())\n  }\n\n  function close() {\n    onValueChange(\"\")\n    setOpen(false)\n  }\n\n  return (\n    <div\n      data-slot=\"expandable-search\"\n      data-expanded={expanded || undefined}\n      className={cn(\n        \"flex h-8 items-center rounded-lg transition-[background-color,box-shadow] duration-150 ease-out\",\n        expanded ? \"bg-card shadow-raised focus-within:ring-3 focus-within:ring-ring/25\" : \"hover:bg-foreground/[0.04]\",\n        className\n      )}\n    >\n      <button\n        type=\"button\"\n        aria-label={expanded ? undefined : (label ?? placeholder)}\n        aria-hidden={expanded || undefined}\n        tabIndex={expanded ? -1 : 0}\n        onClick={expand}\n        className=\"flex size-8 shrink-0 items-center justify-center rounded-lg text-icon outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30\"\n      >\n        <SearchIcon className=\"size-4\" data-anim=\"pop\" />\n      </button>\n      <motion.div\n        initial={false}\n        animate={{ width: expanded ? (mobile ? 160 : 220) : 0, opacity: expanded ? 1 : 0 }}\n        transition={springOrInstant(reduce)}\n        className=\"flex items-center overflow-hidden\"\n      >\n        <input\n          ref={inputRef}\n          value={value}\n          tabIndex={expanded ? 0 : -1}\n          aria-label={label ?? placeholder}\n          placeholder={placeholder}\n          onChange={(event) => onValueChange(event.target.value)}\n          onKeyDown={(event) => {\n            if (event.key === \"Escape\") {\n              event.preventDefault()\n              close()\n              inputRef.current?.blur()\n            }\n          }}\n          onBlur={() => {\n            if (value === \"\") setOpen(false)\n          }}\n          className=\"h-8 min-w-0 flex-1 bg-transparent pr-1 text-base outline-none placeholder:text-muted-foreground sm:text-sm\"\n        />\n        {value !== \"\" && (\n          <button\n            type=\"button\"\n            aria-label=\"Aramayı temizle\"\n            onMouseDown={(event) => event.preventDefault()}\n            onClick={() => {\n              onValueChange(\"\")\n              inputRef.current?.focus()\n            }}\n            className=\"mr-1.5 flex size-5 shrink-0 items-center justify-center rounded-md text-icon outline-none transition-[color,scale] duration-150 hover:bg-foreground/[0.06] hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30 active:scale-90\"\n          >\n            <XIcon className=\"size-3\" />\n          </button>\n        )}\n      </motion.div>\n    </div>\n  )\n}\n\nexport { ExpandableSearch, type ExpandableSearchProps }\n",
      "type": "registry:component",
      "target": "@components/ikas/expandable-search.tsx"
    }
  ],
  "docs": "https://builders.ikas.com/tr/docs/app-development/ui-kit/components/expandable-search",
  "categories": [
    "forms",
    "navigation"
  ],
  "type": "registry:component"
}