ivt 0.4.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/combobox/index.mjs
CHANGED
|
@@ -30,11 +30,17 @@ import '../chunks/index-C45e7-3X.mjs';
|
|
|
30
30
|
import '../chunks/dialog-D-h9t9_b.mjs';
|
|
31
31
|
import '../chunks/x-BZdVnIMx.mjs';
|
|
32
32
|
|
|
33
|
-
function Combobox({ items, value, onValueChange, placeholder = "
|
|
33
|
+
function Combobox({ items, value, onValueChange, placeholder = "Selecione um item...", searchPlaceholder = "Busque um item...", emptyMessage = "Nenhum item encontrado.", widthClassName = "w-fit", className, groupHeading }) {
|
|
34
34
|
const [open, setOpen] = React.useState(false);
|
|
35
|
+
const [search, setSearch] = React.useState("");
|
|
36
|
+
const filteredItems = items.filter((item)=>{
|
|
37
|
+
const match = item.label.toLowerCase().includes(search.toLowerCase());
|
|
38
|
+
return match;
|
|
39
|
+
});
|
|
35
40
|
const handleSelect = (currentValue)=>{
|
|
36
41
|
onValueChange(currentValue === value ? "" : currentValue);
|
|
37
42
|
setOpen(false);
|
|
43
|
+
setSearch("");
|
|
38
44
|
};
|
|
39
45
|
return /*#__PURE__*/ React.createElement(Popover, {
|
|
40
46
|
open: open,
|
|
@@ -45,19 +51,24 @@ function Combobox({ items, value, onValueChange, placeholder = "Select item...",
|
|
|
45
51
|
variant: "outline",
|
|
46
52
|
"aria-expanded": open,
|
|
47
53
|
className: cn(widthClassName, "justify-between", className)
|
|
48
|
-
}, value ? items.find((item)=>item.value === value)?.label : placeholder, /*#__PURE__*/ React.createElement(ChevronsUpDown, {
|
|
54
|
+
}, value ? items.find((item)=>item.value === value)?.label ?? emptyMessage : placeholder, /*#__PURE__*/ React.createElement(ChevronsUpDown, {
|
|
49
55
|
className: "ml-2 h-4 w-4 shrink-0 opacity-50"
|
|
50
56
|
}))), /*#__PURE__*/ React.createElement(PopoverContent, {
|
|
57
|
+
align: "start",
|
|
51
58
|
className: cn(widthClassName, "p-0")
|
|
52
59
|
}, /*#__PURE__*/ React.createElement(Command, null, /*#__PURE__*/ React.createElement(CommandInput, {
|
|
53
60
|
placeholder: searchPlaceholder,
|
|
54
|
-
className: "h-9"
|
|
61
|
+
className: "h-9",
|
|
62
|
+
value: search,
|
|
63
|
+
onInput: (e)=>{
|
|
64
|
+
setSearch(e.currentTarget.value);
|
|
65
|
+
}
|
|
55
66
|
}), /*#__PURE__*/ React.createElement(CommandList, null, /*#__PURE__*/ React.createElement(CommandEmpty, null, emptyMessage), /*#__PURE__*/ React.createElement(CommandGroup, {
|
|
56
67
|
heading: groupHeading
|
|
57
|
-
},
|
|
68
|
+
}, filteredItems.map((item)=>/*#__PURE__*/ React.createElement(CommandItem, {
|
|
58
69
|
key: item.value,
|
|
59
|
-
value: item.
|
|
60
|
-
onSelect: handleSelect
|
|
70
|
+
value: item.label,
|
|
71
|
+
onSelect: ()=>handleSelect(item.value)
|
|
61
72
|
}, item.label, /*#__PURE__*/ React.createElement(Check, {
|
|
62
73
|
className: cn("ml-auto h-4 w-4", value === item.value ? "opacity-100" : "opacity-0")
|
|
63
74
|
}))))))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/components/ui/combobox/combobox.tsx"],"sourcesContent":["\"use client\";\n\nimport { 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
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/components/ui/combobox/combobox.tsx"],"sourcesContent":["\"use client\";\n\nimport { 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}\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 = \"Selecione um item...\",\n\tsearchPlaceholder = \"Busque um item...\",\n\temptyMessage = \"Nenhum item encontrado.\",\n\twidthClassName = \"w-fit\",\n\tclassName,\n\tgroupHeading,\n}: ComboboxProps) {\n\tconst [open, setOpen] = React.useState(false);\n\tconst [search, setSearch] = React.useState(\"\");\n\n\tconst filteredItems = items.filter((item) => {\n\t\tconst match = item.label.toLowerCase().includes(search.toLowerCase());\n\t\treturn match;\n\t});\n\n\tconst handleSelect = (currentValue: string) => {\n\t\tonValueChange(currentValue === value ? \"\" : currentValue);\n\t\tsetOpen(false);\n\t\tsetSearch(\"\");\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\n\t\t\t\t\t\t? (items.find((item) => item.value === value)?.label ?? emptyMessage)\n\t\t\t\t\t\t: 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 align=\"start\" className={cn(widthClassName, \"p-0\")}>\n\t\t\t\t<Command>\n\t\t\t\t\t<CommandInput\n\t\t\t\t\t\tplaceholder={searchPlaceholder}\n\t\t\t\t\t\tclassName=\"h-9\"\n\t\t\t\t\t\tvalue={search}\n\t\t\t\t\t\tonInput={(e) => {\n\t\t\t\t\t\t\tsetSearch(e.currentTarget.value);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\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{filteredItems.map((item) => (\n\t\t\t\t\t\t\t\t<CommandItem\n\t\t\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\t\t\tvalue={item.label}\n\t\t\t\t\t\t\t\t\tonSelect={() => handleSelect(item.value)}\n\t\t\t\t\t\t\t\t>\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":["Combobox","items","value","onValueChange","placeholder","searchPlaceholder","emptyMessage","widthClassName","className","groupHeading","open","setOpen","React","useState","search","setSearch","filteredItems","filter","item","match","label","toLowerCase","includes","handleSelect","currentValue","Popover","onOpenChange","PopoverTrigger","asChild","Button","variant","aria-expanded","cn","find","ChevronsUpDown","PopoverContent","align","Command","CommandInput","onInput","e","currentTarget","CommandList","CommandEmpty","CommandGroup","heading","map","CommandItem","key","onSelect","Check"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEO,SAASA,QAAAA,CAAS,EACxBC,KAAK,EACLC,KAAK,EACLC,aAAa,EACbC,WAAAA,GAAc,sBAAsB,EACpCC,oBAAoB,mBAAmB,EACvCC,YAAAA,GAAe,yBAAyB,EACxCC,cAAAA,GAAiB,OAAO,EACxBC,SAAS,EACTC,YAAY,EACG,EAAA;AACf,IAAA,MAAM,CAACC,IAAAA,EAAMC,OAAAA,CAAQ,GAAGC,KAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;AACvC,IAAA,MAAM,CAACC,MAAAA,EAAQC,SAAAA,CAAU,GAAGH,KAAAA,CAAMC,QAAQ,CAAC,EAAA,CAAA;AAE3C,IAAA,MAAMG,aAAAA,GAAgBf,KAAAA,CAAMgB,MAAM,CAAC,CAACC,IAAAA,GAAAA;QACnC,MAAMC,KAAAA,GAAQD,KAAKE,KAAK,CAACC,WAAW,EAAA,CAAGC,QAAQ,CAACR,MAAAA,CAAOO,WAAW,EAAA,CAAA;QAClE,OAAOF,K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K,CAAA;AAChC,QAAA;AAED,KAAA,CAAA,gBAAA,KAAA,CAAA,aAAA,CAACwC,WAAAA,EAAAA,IAAAA,gBACA,KAAA,CAAA,aAAA,CAACC,YAAAA,EAAAA,IAAAA,EAAcrC,YAAAA,CAAAA,gBACf,KAAA,CAAA,aAAA,CAACsC,YAAAA,EAAAA;QAAaC,OAAAA,EAASpC;AACrBO,KAAAA,EAAAA,aAAAA,CAAc8B,GAAG,CAAC,CAAC5B,IAAAA,iBACnB,KAAA,CAAA,aAAA,CAAC6B,WAAAA,EAAAA;AACAC,YAAAA,GAAAA,EAAK9B,KAAKhB,KAAK;AACfA,YAAAA,KAAAA,EAAOgB,KAAKE,KAAK;YACjB6B,QAAAA,EAAU,IAAM1B,YAAAA,CAAaL,IAAAA,CAAKhB,KAAK;WAEtCgB,IAAAA,CAAKE,KAAK,gBACX,KAAA,CAAA,aAAA,CAAC8B,KAAAA,EAAAA;AACA1C,YAAAA,SAAAA,EAAWwB,GACV,iBAAA,EACA9B,KAAAA,KAAUgB,IAAAA,CAAKhB,KAAK,GAAG,aAAA,GAAgB,WAAA;;AAWlD;;;;"}
|
|
@@ -30,8 +30,13 @@ interface DatePickerProps extends Omit<React__default.ComponentProps<typeof Cale
|
|
|
30
30
|
* Pode ser um boolean, ou uma função que recebe a data e retorna boolean
|
|
31
31
|
*/
|
|
32
32
|
disabled?: boolean | ((date: Date) => boolean);
|
|
33
|
+
/**
|
|
34
|
+
* Mês padrão a ser mostrado (caso nenhuma data esteja selecionada)
|
|
35
|
+
* Por padrão, será o mês atual.
|
|
36
|
+
*/
|
|
37
|
+
defaultMonth?: Date;
|
|
33
38
|
}
|
|
34
|
-
declare function DatePicker({ date, setDate, placeholder, id, buttonProps, popoverProps, popoverContentClassName, className, disabled, ...props }: DatePickerProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare function DatePicker({ date, setDate, placeholder, id, buttonProps, popoverProps, popoverContentClassName, className, disabled, defaultMonth, ...props }: DatePickerProps): react_jsx_runtime.JSX.Element;
|
|
35
40
|
|
|
36
41
|
export { DatePicker };
|
|
37
42
|
export type { DatePickerProps };
|
|
@@ -29,7 +29,7 @@ import '../chunks/chevron-left-wvVA3SWH.mjs';
|
|
|
29
29
|
import '../chunks/chevron-right-aTufSnLl.mjs';
|
|
30
30
|
import '../chunks/chevron-down-BgIYlWhk.mjs';
|
|
31
31
|
|
|
32
|
-
function DatePicker({ date, setDate, placeholder = "Selecione uma data", id = "date-picker", buttonProps, popoverProps, popoverContentClassName, className, disabled, ...props }) {
|
|
32
|
+
function DatePicker({ date, setDate, placeholder = "Selecione uma data", id = "date-picker", buttonProps, popoverProps, popoverContentClassName, className, disabled, defaultMonth, ...props }) {
|
|
33
33
|
const validDate = tryParseDate(date);
|
|
34
34
|
return /*#__PURE__*/ React__default.createElement(Popover, popoverProps, /*#__PURE__*/ React__default.createElement(PopoverTrigger, {
|
|
35
35
|
asChild: true
|
|
@@ -56,6 +56,7 @@ function DatePicker({ date, setDate, placeholder = "Selecione uma data", id = "d
|
|
|
56
56
|
fromYear: 2010,
|
|
57
57
|
toYear: 2040,
|
|
58
58
|
disabled: disabled,
|
|
59
|
+
defaultMonth: validDate ?? defaultMonth ?? new Date(),
|
|
59
60
|
...props,
|
|
60
61
|
mode: "single"
|
|
61
62
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/components/ui/date-picker/date-picker.tsx"],"sourcesContent":["\"use client\";\n\nimport { Button, type ButtonProps } from \"@/components/ui/button\";\nimport { Calendar } from \"@/components/ui/calendar\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport { cn } from \"@/lib/utils\";\nimport { tryParseDate } from \"@/utils/date\";\nimport { format } from \"date-fns\";\nimport { ptBR } from \"date-fns/locale\";\nimport { CalendarDaysIcon } from \"lucide-react\";\nimport React from \"react\";\n\nexport interface DatePickerProps\n\textends Omit<React.ComponentProps<typeof Calendar>, \"mode\" | \"selected\" | \"onSelect\"> {\n\t/** Data selecionada (pode ser Date ou string parseável) */\n\tdate: Date | string | undefined;\n\n\t/** Função chamada ao selecionar uma data */\n\tsetDate: (date: Date | undefined) => void;\n\n\t/** Texto exibido quando não há data selecionada */\n\tplaceholder?: string;\n\n\t/** ID opcional do botão */\n\tid?: string;\n\n\t/** Props extras para o botão */\n\tbuttonProps?: ButtonProps;\n\n\t/** Props extras para o popover */\n\tpopoverProps?: React.ComponentProps<typeof Popover>;\n\n\t/** Classe extra para o conteúdo do popover */\n\tpopoverContentClassName?: string;\n\n\t/** Classe extra para o botão */\n\tclassName?: string;\n\n\t/**\n\t * Permite desabilitar datas específicas (igual ao Calendar do shadcn)\n\t * Pode ser um boolean, ou uma função que recebe a data e retorna boolean\n\t */\n\tdisabled?: boolean | ((date: Date) => boolean);\n}\n\nexport function DatePicker({\n\tdate,\n\tsetDate,\n\tplaceholder = \"Selecione uma data\",\n\tid = \"date-picker\",\n\tbuttonProps,\n\tpopoverProps,\n\tpopoverContentClassName,\n\tclassName,\n\tdisabled,\n\t...props\n}: DatePickerProps) {\n\tconst validDate = tryParseDate(date);\n\n\treturn (\n\t\t<Popover {...popoverProps}>\n\t\t\t<PopoverTrigger asChild>\n\t\t\t\t<Button\n\t\t\t\t\tid={id}\n\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\"hover:text-foreground justify-start text-left font-normal\",\n\t\t\t\t\t\t!validDate && \"text-muted-foreground hover:text-muted-foreground\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\tdisabled={typeof disabled === \"boolean\" ? disabled : undefined}\n\t\t\t\t\t{...buttonProps}\n\t\t\t\t>\n\t\t\t\t\t<CalendarDaysIcon className=\"size-4\" />\n\t\t\t\t\t{validDate ? format(validDate, \"P\", { locale: ptBR }) : <span>{placeholder}</span>}\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\n\t\t\t<PopoverContent className={cn(\"w-auto p-0\", popoverContentClassName)} align=\"start\">\n\t\t\t\t<Calendar\n\t\t\t\t\tautoFocus\n\t\t\t\t\tcaptionLayout=\"dropdown\"\n\t\t\t\t\tselected={validDate}\n\t\t\t\t\tonSelect={setDate}\n\t\t\t\t\tlocale={ptBR}\n\t\t\t\t\tnumberOfMonths={1}\n\t\t\t\t\tfromYear={2010}\n\t\t\t\t\ttoYear={2040}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t{...props}\n\t\t\t\t\tmode=\"single\"\n\t\t\t\t/>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n"],"names":["DatePicker","date","setDate","placeholder","id","buttonProps","popoverProps","popoverContentClassName","className","disabled","props","validDate","tryParseDate","React","Popover","PopoverTrigger","asChild","Button","variant","cn","undefined","CalendarDaysIcon","format","locale","ptBR","span","PopoverContent","align","Calendar","autoFocus","captionLayout","selected","onSelect","numberOfMonths","fromYear","toYear","mode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/components/ui/date-picker/date-picker.tsx"],"sourcesContent":["\"use client\";\n\nimport { Button, type ButtonProps } from \"@/components/ui/button\";\nimport { Calendar } from \"@/components/ui/calendar\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport { cn } from \"@/lib/utils\";\nimport { tryParseDate } from \"@/utils/date\";\nimport { format } from \"date-fns\";\nimport { ptBR } from \"date-fns/locale\";\nimport { CalendarDaysIcon } from \"lucide-react\";\nimport React from \"react\";\n\nexport interface DatePickerProps\n\textends Omit<React.ComponentProps<typeof Calendar>, \"mode\" | \"selected\" | \"onSelect\"> {\n\t/** Data selecionada (pode ser Date ou string parseável) */\n\tdate: Date | string | undefined;\n\n\t/** Função chamada ao selecionar uma data */\n\tsetDate: (date: Date | undefined) => void;\n\n\t/** Texto exibido quando não há data selecionada */\n\tplaceholder?: string;\n\n\t/** ID opcional do botão */\n\tid?: string;\n\n\t/** Props extras para o botão */\n\tbuttonProps?: ButtonProps;\n\n\t/** Props extras para o popover */\n\tpopoverProps?: React.ComponentProps<typeof Popover>;\n\n\t/** Classe extra para o conteúdo do popover */\n\tpopoverContentClassName?: string;\n\n\t/** Classe extra para o botão */\n\tclassName?: string;\n\n\t/**\n\t * Permite desabilitar datas específicas (igual ao Calendar do shadcn)\n\t * Pode ser um boolean, ou uma função que recebe a data e retorna boolean\n\t */\n\tdisabled?: boolean | ((date: Date) => boolean);\n\n\t/**\n\t * Mês padrão a ser mostrado (caso nenhuma data esteja selecionada)\n\t * Por padrão, será o mês atual.\n\t */\n\tdefaultMonth?: Date;\n}\n\nexport function DatePicker({\n\tdate,\n\tsetDate,\n\tplaceholder = \"Selecione uma data\",\n\tid = \"date-picker\",\n\tbuttonProps,\n\tpopoverProps,\n\tpopoverContentClassName,\n\tclassName,\n\tdisabled,\n\tdefaultMonth,\n\t...props\n}: DatePickerProps) {\n\tconst validDate = tryParseDate(date);\n\n\treturn (\n\t\t<Popover {...popoverProps}>\n\t\t\t<PopoverTrigger asChild>\n\t\t\t\t<Button\n\t\t\t\t\tid={id}\n\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\"hover:text-foreground justify-start text-left font-normal\",\n\t\t\t\t\t\t!validDate && \"text-muted-foreground hover:text-muted-foreground\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\tdisabled={typeof disabled === \"boolean\" ? disabled : undefined}\n\t\t\t\t\t{...buttonProps}\n\t\t\t\t>\n\t\t\t\t\t<CalendarDaysIcon className=\"size-4\" />\n\t\t\t\t\t{validDate ? format(validDate, \"P\", { locale: ptBR }) : <span>{placeholder}</span>}\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\n\t\t\t<PopoverContent className={cn(\"w-auto p-0\", popoverContentClassName)} align=\"start\">\n\t\t\t\t<Calendar\n\t\t\t\t\tautoFocus\n\t\t\t\t\tcaptionLayout=\"dropdown\"\n\t\t\t\t\tselected={validDate}\n\t\t\t\t\tonSelect={setDate}\n\t\t\t\t\tlocale={ptBR}\n\t\t\t\t\tnumberOfMonths={1}\n\t\t\t\t\tfromYear={2010}\n\t\t\t\t\ttoYear={2040}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tdefaultMonth={validDate ?? defaultMonth ?? new Date()}\n\t\t\t\t\t{...props}\n\t\t\t\t\tmode=\"single\"\n\t\t\t\t/>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n"],"names":["DatePicker","date","setDate","placeholder","id","buttonProps","popoverProps","popoverContentClassName","className","disabled","defaultMonth","props","validDate","tryParseDate","React","Popover","PopoverTrigger","asChild","Button","variant","cn","undefined","CalendarDaysIcon","format","locale","ptBR","span","PopoverContent","align","Calendar","autoFocus","captionLayout","selected","onSelect","numberOfMonths","fromYear","toYear","Date","mode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,SAASA,UAAAA,CAAW,EAC1BC,IAAI,EACJC,OAAO,EACPC,WAAAA,GAAc,oBAAoB,EAClCC,EAAAA,GAAK,aAAa,EAClBC,WAAW,EACXC,YAAY,EACZC,uBAAuB,EACvBC,SAAS,EACTC,QAAQ,EACRC,YAAY,EACZ,GAAGC,KAAAA,EACc,EAAA;AACjB,IAAA,MAAMC,YAAYC,YAAAA,CAAaZ,IAAAA,CAAAA;IAE/B,qBACCa,cAAA,CAAA,aAAA,CAACC,OAAAA,EAAYT,YAAAA,gBACZQ,cAAA,CAAA,aAAA,CAACE,cAAAA,EAAAA;QAAeC,OAAAA,EAAAA;qBACfH,cAAA,CAAA,aAAA,CAACI,MAAAA,EAAAA;QACAd,EAAAA,EAAIA,EAAAA;QACJe,OAAAA,EAAQ,SAAA;AACRX,QAAAA,SAAAA,EAAWY,EAAAA,CACV,2DAAA,EACA,CAACR,SAAAA,IAAa,mDAAA,EACdJ,SAAAA,CAAAA;QAEDC,QAAAA,EAA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