{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combobox11",
  "title": "Combobox",
  "description": "Combobox built with shadcn/ui.",
  "files": [
    {
      "path": "contents/components/combobox/11/index.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Check, ChevronsUpDown, Clock } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Command,\n  CommandEmpty,\n  CommandGroup,\n  CommandInput,\n  CommandItem,\n  CommandList\n} from \"@/components/ui/command\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\n\nconst frameworks = [\n  {\n    value: \"next.js\",\n    label: \"Next.js\"\n  },\n  {\n    value: \"sveltekit\",\n    label: \"SvelteKit\"\n  },\n  {\n    value: \"nuxt.js\",\n    label: \"Nuxt.js\"\n  },\n  {\n    value: \"remix\",\n    label: \"Remix\"\n  },\n  {\n    value: \"astro\",\n    label: \"Astro\"\n  },\n  {\n    value: \"gatsby\",\n    label: \"Gatsby\"\n  },\n  {\n    value: \"solid\",\n    label: \"Solid.js\"\n  },\n  {\n    value: \"qwik\",\n    label: \"Qwik\"\n  }\n];\n\nexport default function Combobox() {\n  const [open, setOpen] = React.useState(false);\n  const [value, setValue] = React.useState(\"\");\n  const [recent, setRecent] = React.useState<string[]>([]);\n\n  const handleSelect = (currentValue: string) => {\n    const newValue = currentValue === value ? \"\" : currentValue;\n    setValue(newValue);\n    setOpen(false);\n\n    if (newValue) {\n      setRecent((prev) => {\n        const filtered = prev.filter((v) => v !== newValue);\n        return [newValue, ...filtered].slice(0, 3);\n      });\n    }\n  };\n\n  const recentFrameworks = recent\n    .map((val) => frameworks.find((f) => f.value === val))\n    .filter(Boolean) as typeof frameworks;\n\n  const otherFrameworks = frameworks.filter((f) => !recent.includes(f.value));\n\n  return (\n    <div className=\"w-full max-w-xs\">\n      <Popover open={open} onOpenChange={setOpen}>\n        <PopoverTrigger asChild>\n          <Button\n            variant=\"outline\"\n            role=\"combobox\"\n            aria-expanded={open}\n            className=\"w-full justify-between\">\n            {value\n              ? frameworks.find((framework) => framework.value === value)?.label\n              : \"Select framework...\"}\n            <ChevronsUpDown className=\"opacity-50\" />\n          </Button>\n        </PopoverTrigger>\n        <PopoverContent className=\"p-0\">\n          <Command>\n            <CommandInput placeholder=\"Search framework...\" className=\"h-9\" />\n            <CommandList>\n              <CommandEmpty>No framework found.</CommandEmpty>\n              {recentFrameworks.length > 0 && (\n                <CommandGroup heading=\"Recent\">\n                  {recentFrameworks.map((framework) => (\n                    <CommandItem\n                      key={framework.value}\n                      value={framework.value}\n                      onSelect={handleSelect}>\n                      <Clock className=\"mr-2 h-4 w-4 text-muted-foreground\" />\n                      {framework.label}\n                      <Check\n                        className={cn(\n                          \"ml-auto\",\n                          value === framework.value ? \"opacity-100\" : \"opacity-0\"\n                        )}\n                      />\n                    </CommandItem>\n                  ))}\n                </CommandGroup>\n              )}\n              <CommandGroup heading=\"All frameworks\">\n                {otherFrameworks.map((framework) => (\n                  <CommandItem\n                    key={framework.value}\n                    value={framework.value}\n                    onSelect={handleSelect}>\n                    {framework.label}\n                    <Check\n                      className={cn(\n                        \"ml-auto\",\n                        value === framework.value ? \"opacity-100\" : \"opacity-0\"\n                      )}\n                    />\n                  </CommandItem>\n                ))}\n              </CommandGroup>\n            </CommandList>\n          </Command>\n        </PopoverContent>\n      </Popover>\n    </div>\n  );\n}\n\n",
      "type": "registry:component",
      "target": "components/combobox11.tsx"
    }
  ],
  "type": "registry:component"
}