ivt
Version:
Ivt Components Library
1 lines • 5.88 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js","../../src/components/ui/combobox/combobox.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.479.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"m7 15 5 5 5-5\", key: \"1hf1tw\" }],\n [\"path\", { d: \"m7 9 5-5 5 5\", key: \"sgt6xg\" }]\n];\nconst ChevronsUpDown = createLucideIcon(\"ChevronsUpDown\", __iconNode);\n\nexport { __iconNode, ChevronsUpDown as default };\n//# sourceMappingURL=chevrons-up-down.js.map\n","import { Check, ChevronsUpDown } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n\tCommand,\n\tCommandEmpty,\n\tCommandGroup,\n\tCommandInput,\n\tCommandItem,\n\tCommandList,\n} from \"@/components/ui/command\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport { cn } from \"@/lib/utils\";\n\ninterface ComboboxItem {\n\tvalue: string;\n\tlabel: string;\n\t// Você pode adicionar outras propriedades se precisar, ex: icon, disabled\n\t// icon?: React.ReactNode;\n\t// disabled?: boolean;\n}\n\ninterface ComboboxProps {\n\t/**\n\t * A lista de itens a serem exibidos no combobox.\n\t * Cada item deve ter 'value' e 'label'.\n\t */\n\titems: ComboboxItem[];\n\t/**\n\t * O valor atualmente selecionado no combobox.\n\t */\n\tvalue: string;\n\t/**\n\t * Função de callback para quando um item é selecionado.\n\t * Recebe o novo valor selecionado.\n\t */\n\tonValueChange: (newValue: string) => void;\n\t/**\n\t * Placeholder para o botão do combobox quando nenhum item está selecionado.\n\t * @default \"Select item...\"\n\t */\n\tplaceholder?: string;\n\t/**\n\t * Placeholder para o campo de busca dentro do combobox.\n\t * @default \"Search item...\"\n\t */\n\tsearchPlaceholder?: string;\n\t/**\n\t * Mensagem exibida quando nenhum item é encontrado na busca.\n\t * @default \"No item found.\"\n\t */\n\temptyMessage?: string;\n\t/**\n\t * Largura do combobox (e do popover).\n\t * @default \"w-[200px]\"\n\t */\n\twidthClassName?: string;\n\t/**\n\t * Classes CSS adicionais para o combobox principal.\n\t */\n\tclassName?: string;\n\t/**\n\t * Título do grupo de comandos.\n\t */\n\tgroupHeading?: string;\n}\n\nexport function Combobox({\n\titems,\n\tvalue,\n\tonValueChange,\n\tplaceholder = \"Select item...\",\n\tsearchPlaceholder = \"Search item...\",\n\temptyMessage = \"No item found.\",\n\twidthClassName = \"w-fit\",\n\tclassName,\n\tgroupHeading,\n}: ComboboxProps) {\n\tconst [open, setOpen] = React.useState(false);\n\n\tconst handleSelect = (currentValue: string) => {\n\t\tonValueChange(currentValue === value ? \"\" : currentValue);\n\t\tsetOpen(false);\n\t};\n\n\treturn (\n\t\t<Popover open={open} onOpenChange={setOpen}>\n\t\t\t<PopoverTrigger asChild>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\taria-expanded={open}\n\t\t\t\t\tclassName={cn(widthClassName, \"justify-between\", className)}\n\t\t\t\t>\n\t\t\t\t\t{value ? items.find((item) => item.value === value)?.label : placeholder}\n\t\t\t\t\t<ChevronsUpDown className=\"ml-2 h-4 w-4 shrink-0 opacity-50\" />\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\t\t\t<PopoverContent className={cn(widthClassName, \"p-0\")}>\n\t\t\t\t<Command>\n\t\t\t\t\t<CommandInput placeholder={searchPlaceholder} className=\"h-9\" />\n\t\t\t\t\t<CommandList>\n\t\t\t\t\t\t<CommandEmpty>{emptyMessage}</CommandEmpty>\n\t\t\t\t\t\t<CommandGroup heading={groupHeading}>\n\t\t\t\t\t\t\t{items.map((item) => (\n\t\t\t\t\t\t\t\t<CommandItem key={item.value} value={item.value} onSelect={handleSelect}>\n\t\t\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t\t\t\t<Check\n\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t\"ml-auto h-4 w-4\",\n\t\t\t\t\t\t\t\t\t\t\tvalue === item.value ? \"opacity-100\" : \"opacity-0\",\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</CommandItem>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</CommandGroup>\n\t\t\t\t\t</CommandList>\n\t\t\t\t</Command>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n"],"names":["ChevronsUpDown","createLucideIcon","d","key","Combobox","items","value","onValueChange","placeholder","searchPlaceholder","emptyMessage","widthClassName","className","groupHeading","open","setOpen","React","useState","handleSelect","currentValue","createElement","Popover","onOpenChange","PopoverTrigger","asChild","Button","variant","aria-expanded","cn","find","item","label","PopoverContent","Command","CommandInput","CommandList","CommandEmpty","CommandGroup","heading","map","CommandItem","onSelect","Check"],"mappings":"yoCAGO,MAgBDA,EAAiBC,EAAiB,iBAhBJ,CAClC,CAAC,OAAQ,CAAEC,EAAG,gBAAiBC,IAAK,WACpC,CAAC,OAAQ,CAAED,EAAG,eAAgBC,IAAK,aC+D9B,SAASC,GAASC,MACxBA,EAAKC,MACLA,EAAKC,cACLA,EAAaC,YACbA,EAAc,iBAAgBC,kBAC9BA,EAAoB,iBAAgBC,aACpCA,EAAe,iBAAgBC,eAC/BA,EAAiB,QAAOC,UACxBA,EAASC,aACTA,IAEA,MAAOC,EAAMC,GAAWC,EAAMC,UAAS,GAEjCC,EAAgBC,IACrBZ,EAAcY,IAAiBb,EAAQ,GAAKa,GAC5CJ,GAAQ,IAGT,OACCC,EAAAI,cAACC,EAAAA,CAAQP,KAAMA,EAAMQ,aAAcP,GAClCC,EAAAI,cAACG,EAAAA,CAAeC,SAAAA,GACfR,EAAAI,cAACK,EAAAA,CACAC,QAA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