@sonamu-kit/react-components 0.4.4 → 0.4.6
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/.storybook/main.d.ts +3 -0
- package/dist/.storybook/preview.d.ts +3 -0
- package/dist/_virtual/~icons/lucide/arrow-left.js +21 -0
- package/dist/_virtual/~icons/lucide/arrow-left.js.map +1 -0
- package/dist/_virtual/~icons/lucide/arrow-right.js +21 -0
- package/dist/_virtual/~icons/lucide/arrow-right.js.map +1 -0
- package/dist/_virtual/~icons/lucide/calendar.js +31 -0
- package/dist/_virtual/~icons/lucide/calendar.js.map +1 -0
- package/dist/_virtual/~icons/lucide/check.js +21 -0
- package/dist/_virtual/~icons/lucide/check.js.map +1 -0
- package/dist/_virtual/~icons/lucide/chevron-down.js +21 -0
- package/dist/_virtual/~icons/lucide/chevron-down.js.map +1 -0
- package/dist/_virtual/~icons/lucide/chevron-left.js +21 -0
- package/dist/_virtual/~icons/lucide/chevron-left.js.map +1 -0
- package/dist/_virtual/~icons/lucide/chevron-right.js +21 -0
- package/dist/_virtual/~icons/lucide/chevron-right.js.map +1 -0
- package/dist/_virtual/~icons/lucide/chevrons-up-down.js +21 -0
- package/dist/_virtual/~icons/lucide/chevrons-up-down.js.map +1 -0
- package/dist/_virtual/~icons/lucide/circle.js +23 -0
- package/dist/_virtual/~icons/lucide/circle.js.map +1 -0
- package/dist/_virtual/~icons/lucide/dot.js +23 -0
- package/dist/_virtual/~icons/lucide/dot.js.map +1 -0
- package/dist/_virtual/~icons/lucide/grip-vertical.js +52 -0
- package/dist/_virtual/~icons/lucide/grip-vertical.js.map +1 -0
- package/dist/_virtual/~icons/lucide/image.js +36 -0
- package/dist/_virtual/~icons/lucide/image.js.map +1 -0
- package/dist/_virtual/~icons/lucide/loader-2.js +21 -0
- package/dist/_virtual/~icons/lucide/loader-2.js.map +1 -0
- package/dist/_virtual/~icons/lucide/loader2.js +21 -0
- package/dist/_virtual/~icons/lucide/loader2.js.map +1 -0
- package/dist/_virtual/~icons/lucide/more-horizontal.js +37 -0
- package/dist/_virtual/~icons/lucide/more-horizontal.js.map +1 -0
- package/dist/_virtual/~icons/lucide/panel-left.js +27 -0
- package/dist/_virtual/~icons/lucide/panel-left.js.map +1 -0
- package/dist/_virtual/~icons/lucide/plus.js +21 -0
- package/dist/_virtual/~icons/lucide/plus.js.map +1 -0
- package/dist/_virtual/~icons/lucide/search.js +25 -0
- package/dist/_virtual/~icons/lucide/search.js.map +1 -0
- package/dist/_virtual/~icons/lucide/trash-2.js +21 -0
- package/dist/_virtual/~icons/lucide/trash-2.js.map +1 -0
- package/dist/_virtual/~icons/lucide/upload.js +21 -0
- package/dist/_virtual/~icons/lucide/upload.js.map +1 -0
- package/dist/_virtual/~icons/lucide/x-circle.js +25 -0
- package/dist/_virtual/~icons/lucide/x-circle.js.map +1 -0
- package/dist/_virtual/~icons/lucide/x.js +21 -0
- package/dist/_virtual/~icons/lucide/x.js.map +1 -0
- package/dist/components/index.js +61 -0
- package/dist/components/ui/accordion.js +37 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/alert-dialog.js +56 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/alert.js +33 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/aspect-ratio.js +7 -0
- package/dist/components/ui/aspect-ratio.js.map +1 -0
- package/dist/components/ui/avatar.js +27 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.js +24 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.js +63 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/button.js +59 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.js +49 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/card.js +56 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/carousel.js +119 -0
- package/dist/components/ui/carousel.js.map +1 -0
- package/dist/components/ui/checkbox.js +56 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.js +7 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/combobox.js +68 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/command.js +76 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/common-modal.js +64 -0
- package/dist/components/ui/common-modal.js.map +1 -0
- package/dist/components/ui/context-menu.js +75 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/date-input.js +15 -0
- package/dist/components/ui/date-input.js.map +1 -0
- package/dist/components/ui/date-picker.js +105 -0
- package/dist/components/ui/date-picker.js.map +1 -0
- package/dist/components/ui/dialog.js +52 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/drawer.js +50 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/dropdown-menu.js +77 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/file-input.js +268 -0
- package/dist/components/ui/file-input.js.map +1 -0
- package/dist/components/ui/form.js +81 -0
- package/dist/components/ui/form.js.map +1 -0
- package/dist/components/ui/hover-card.js +17 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/input-otp.js +43 -0
- package/dist/components/ui/input-otp.js.map +1 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.js +39 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/label.js +16 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/menubar.js +108 -0
- package/dist/components/ui/menubar.js.map +1 -0
- package/dist/components/ui/month-picker-multiple.js +236 -0
- package/dist/components/ui/month-picker-multiple.js.map +1 -0
- package/dist/components/ui/navigation-menu.js +60 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/pagination.js +55 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.js +36 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.js +20 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/radio-group.js +26 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/range-number-input.js +41 -0
- package/dist/components/ui/range-number-input.js.map +1 -0
- package/dist/components/ui/resizable.js +21 -0
- package/dist/components/ui/resizable.js.map +1 -0
- package/dist/components/ui/scroll-area.js +32 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select/enum-select.js +43 -0
- package/dist/components/ui/select/enum-select.js.map +1 -0
- package/dist/components/ui/select/id-async-select.js +160 -0
- package/dist/components/ui/select/id-async-select.js.map +1 -0
- package/dist/components/ui/select/select.js +337 -0
- package/dist/components/ui/select/select.js.map +1 -0
- package/dist/components/ui/separator.js +17 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/sheet.js +60 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.js +347 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.js +13 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/slider.js +37 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/sonamu-filter/constants.js +31 -0
- package/dist/components/ui/sonamu-filter/constants.js.map +1 -0
- package/dist/components/ui/sonamu-filter/rule-row-input.js +76 -0
- package/dist/components/ui/sonamu-filter/rule-row-input.js.map +1 -0
- package/dist/components/ui/sonamu-filter/sonamu-filter-modal.js +112 -0
- package/dist/components/ui/sonamu-filter/sonamu-filter-modal.js.map +1 -0
- package/dist/components/ui/sonamu-filter/sonamu-filter-popover.js +60 -0
- package/dist/components/ui/sonamu-filter/sonamu-filter-popover.js.map +1 -0
- package/dist/components/ui/sonamu-filter/utils.js +40 -0
- package/dist/components/ui/sonamu-filter/utils.js.map +1 -0
- package/dist/components/ui/sonamu-filter/value-input.js +101 -0
- package/dist/components/ui/sonamu-filter/value-input.js.map +1 -0
- package/dist/components/ui/switch.js +33 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.js +70 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.js +27 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/tag-input.js +57 -0
- package/dist/components/ui/tag-input.js.map +1 -0
- package/dist/components/ui/textarea.js +20 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toast.js +55 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toaster.js +22 -0
- package/dist/components/ui/toaster.js.map +1 -0
- package/dist/components/ui/toggle-group.js +39 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.js +42 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.js +16 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/contexts/index.js +2 -0
- package/dist/contexts/sonamu-context.js +28 -0
- package/dist/contexts/sonamu-context.js.map +1 -0
- package/dist/demo/App.d.ts +2 -0
- package/dist/demo/Layout.d.ts +2 -0
- package/dist/demo/components/FormDebugPanel.d.ts +11 -0
- package/dist/demo/main.d.ts +0 -0
- package/dist/demo/routeTree.gen.d.ts +102 -0
- package/dist/demo/routes/__root.d.ts +1 -0
- package/dist/demo/routes/data-display.d.ts +1 -0
- package/dist/demo/routes/dialogs-alerts.d.ts +1 -0
- package/dist/demo/routes/form.d.ts +1 -0
- package/dist/demo/routes/index.d.ts +1 -0
- package/dist/demo/routes/layout.d.ts +1 -0
- package/dist/demo/routes/navigation.d.ts +1 -0
- package/dist/demo/schemas/data-display-demo.schema.d.ts +20 -0
- package/dist/demo/schemas/dialogs-alerts-demo.schema.d.ts +32 -0
- package/dist/demo/schemas/form-demo.schema.d.ts +33 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/use-toast.js +112 -0
- package/dist/hooks/use-toast.js.map +1 -0
- package/dist/i18n/rc-keys.js +75 -0
- package/dist/i18n/rc-keys.js.map +1 -0
- package/dist/index.js +70 -0
- package/dist/lib/base-helpers.js +43 -0
- package/dist/lib/base-helpers.js.map +1 -0
- package/dist/lib/caster.js +27 -0
- package/dist/lib/caster.js.map +1 -0
- package/dist/lib/form-helpers.js +74 -0
- package/dist/lib/form-helpers.js.map +1 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/list-helpers.js +70 -0
- package/dist/lib/list-helpers.js.map +1 -0
- package/dist/lib/modal-helpers.js +30 -0
- package/dist/lib/modal-helpers.js.map +1 -0
- package/dist/lib/types.js +86 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/use-mobile.js +16 -0
- package/dist/lib/use-mobile.js.map +1 -0
- package/dist/lib/utils.js +23 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/router/index.js +1 -0
- package/dist/styles/globals.css +1 -1
- package/package.json +16 -12
- package/dist/react-components.es.js +0 -4500
- package/dist/react-components.es.js.map +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "./button.js";
|
|
4
|
+
import { Calendar as n } from "./calendar.js";
|
|
5
|
+
import { useSonamuBaseContext as r } from "../../contexts/sonamu-context.js";
|
|
6
|
+
import { Popover as i, PopoverContent as a, PopoverTrigger as o } from "./popover.js";
|
|
7
|
+
import s from "../../_virtual/~icons/lucide/calendar.js";
|
|
8
|
+
import * as c from "react";
|
|
9
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
|
+
import { format as d } from "date-fns";
|
|
11
|
+
//#region src/components/ui/date-picker.tsx
|
|
12
|
+
function f({ value: c, onValueChange: f, placeholder: p, disabled: m = !1, className: h }) {
|
|
13
|
+
let { SD: g } = r(), _ = p ?? g("rc.datePicker.pickDate");
|
|
14
|
+
return /* @__PURE__ */ u(i, { children: [/* @__PURE__ */ l(o, {
|
|
15
|
+
asChild: !0,
|
|
16
|
+
children: /* @__PURE__ */ u(t, {
|
|
17
|
+
variant: "outline",
|
|
18
|
+
disabled: m,
|
|
19
|
+
"data-empty": !c,
|
|
20
|
+
className: e("w-full justify-start text-left font-normal", "data-[empty=true]:text-muted-foreground", h),
|
|
21
|
+
children: [/* @__PURE__ */ l(s, {}), c ? d(c, "PPP") : /* @__PURE__ */ l("span", { children: _ })]
|
|
22
|
+
})
|
|
23
|
+
}), /* @__PURE__ */ l(a, {
|
|
24
|
+
className: "w-auto p-0",
|
|
25
|
+
align: "start",
|
|
26
|
+
children: /* @__PURE__ */ l(n, {
|
|
27
|
+
mode: "single",
|
|
28
|
+
selected: c,
|
|
29
|
+
onSelect: (e) => {
|
|
30
|
+
f?.(e);
|
|
31
|
+
},
|
|
32
|
+
initialFocus: !0
|
|
33
|
+
})
|
|
34
|
+
})] });
|
|
35
|
+
}
|
|
36
|
+
function p({ value: d, onValueChange: f, placeholder: p, disabled: m = !1, className: h }) {
|
|
37
|
+
let { SD: g } = r(), _ = p ?? g("rc.datePicker.selectDate"), [v, y] = c.useState(!1);
|
|
38
|
+
return /* @__PURE__ */ u(i, {
|
|
39
|
+
open: v,
|
|
40
|
+
onOpenChange: y,
|
|
41
|
+
children: [/* @__PURE__ */ l(o, {
|
|
42
|
+
asChild: !0,
|
|
43
|
+
children: /* @__PURE__ */ u(t, {
|
|
44
|
+
variant: "outline",
|
|
45
|
+
disabled: m,
|
|
46
|
+
className: e("w-full justify-between font-normal", !d && "text-muted-foreground", h),
|
|
47
|
+
children: [d ? d.toLocaleDateString() : _, /* @__PURE__ */ l(s, {})]
|
|
48
|
+
})
|
|
49
|
+
}), /* @__PURE__ */ l(a, {
|
|
50
|
+
className: "w-auto overflow-hidden p-0",
|
|
51
|
+
align: "start",
|
|
52
|
+
children: /* @__PURE__ */ l(n, {
|
|
53
|
+
mode: "single",
|
|
54
|
+
selected: d,
|
|
55
|
+
captionLayout: "dropdown",
|
|
56
|
+
onSelect: (e) => {
|
|
57
|
+
f?.(e), y(!1);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function m({ CalendarIcon: e, value: r, onValueChange: s, placeholder: f = "Pick a date", dateFormat: p = "yyyy/MM/dd", className: m = "", numberOfMonths: h = 2, maxDate: g, minDate: _ }) {
|
|
64
|
+
let [v, y] = c.useState(!1), b = c.useMemo(() => {
|
|
65
|
+
if (!r?.from && !r?.to) return f;
|
|
66
|
+
let e = r?.from ? d(r.from, p) : "", t = r?.to ? d(r.to, p) : "";
|
|
67
|
+
return e && t ? `${e} - ${t}` : t ? `- ${t}` : `${e} -`;
|
|
68
|
+
}, [
|
|
69
|
+
r,
|
|
70
|
+
p,
|
|
71
|
+
f
|
|
72
|
+
]), x = c.useMemo(() => {
|
|
73
|
+
if (!(!g && !_)) return (e) => !!(g && e > g || _ && e < _);
|
|
74
|
+
}, [g, _]);
|
|
75
|
+
return /* @__PURE__ */ u(i, {
|
|
76
|
+
open: v,
|
|
77
|
+
onOpenChange: y,
|
|
78
|
+
children: [/* @__PURE__ */ l(o, {
|
|
79
|
+
asChild: !0,
|
|
80
|
+
children: /* @__PURE__ */ u(t, {
|
|
81
|
+
variant: "outline",
|
|
82
|
+
className: `justify-start gap-2 h-8 px-3 text-xs font-normal ${m}`,
|
|
83
|
+
children: [/* @__PURE__ */ l(e, { className: "h-4 w-4 shrink-0" }), /* @__PURE__ */ l("span", {
|
|
84
|
+
className: "truncate",
|
|
85
|
+
children: b
|
|
86
|
+
})]
|
|
87
|
+
})
|
|
88
|
+
}), /* @__PURE__ */ l(a, {
|
|
89
|
+
className: "w-auto p-0",
|
|
90
|
+
align: "start",
|
|
91
|
+
children: /* @__PURE__ */ l(n, {
|
|
92
|
+
mode: "range",
|
|
93
|
+
defaultMonth: r?.from ?? (r?.to ? new Date(r.to.getFullYear(), r.to.getMonth() - 1, 1) : void 0),
|
|
94
|
+
selected: r,
|
|
95
|
+
onSelect: s,
|
|
96
|
+
numberOfMonths: h,
|
|
97
|
+
disabled: x
|
|
98
|
+
})
|
|
99
|
+
})]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { f as DatePicker, p as DatePickerWithDropdown, m as DatePickerWithRange };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=date-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker.js","names":[],"sources":["../../../src/components/ui/date-picker.tsx"],"sourcesContent":["\"use client\";\n\nimport { format } from \"date-fns\";\nimport * as React from \"react\";\nimport { type DateRange } from \"react-day-picker\";\nimport CalendarIcon from \"~icons/lucide/calendar\";\n\nimport { useSonamuBaseContext } from \"@/contexts\";\n\nimport { cn } from \"../../lib/utils\";\nimport { Button } from \"./button\";\nimport { Calendar } from \"./calendar\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\n\n// ============================================================================\n// DatePicker — 단일 날짜 선택\n// ============================================================================\n\ninterface DatePickerProps {\n value?: Date;\n onValueChange?: (date: Date | undefined) => void;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n}\n\nexport function DatePicker({\n value,\n onValueChange,\n placeholder,\n disabled = false,\n className,\n}: DatePickerProps) {\n const { SD } = useSonamuBaseContext();\n const finalPlaceholder = placeholder ?? SD(\"rc.datePicker.pickDate\");\n\n return (\n <Popover>\n <PopoverTrigger asChild>\n <Button\n variant=\"outline\"\n disabled={disabled}\n data-empty={!value}\n className={cn(\n \"w-full justify-start text-left font-normal\",\n \"data-[empty=true]:text-muted-foreground\",\n className,\n )}\n >\n <CalendarIcon />\n {value ? format(value, \"PPP\") : <span>{finalPlaceholder}</span>}\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n <Calendar\n mode=\"single\"\n selected={value}\n onSelect={(date) => {\n onValueChange?.(date);\n }}\n initialFocus\n />\n </PopoverContent>\n </Popover>\n );\n}\n\n// ============================================================================\n// DatePickerWithDropdown — 월/년 드롭다운 포함\n// ============================================================================\n\nexport function DatePickerWithDropdown({\n value,\n onValueChange,\n placeholder,\n disabled = false,\n className,\n}: DatePickerProps) {\n const { SD } = useSonamuBaseContext();\n const finalPlaceholder = placeholder ?? SD(\"rc.datePicker.selectDate\");\n const [open, setOpen] = React.useState(false);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n variant=\"outline\"\n disabled={disabled}\n className={cn(\n \"w-full justify-between font-normal\",\n !value && \"text-muted-foreground\",\n className,\n )}\n >\n {value ? value.toLocaleDateString() : finalPlaceholder}\n <CalendarIcon />\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-auto overflow-hidden p-0\" align=\"start\">\n <Calendar\n mode=\"single\"\n selected={value}\n captionLayout=\"dropdown\"\n onSelect={(selectedDate) => {\n onValueChange?.(selectedDate);\n setOpen(false);\n }}\n />\n </PopoverContent>\n </Popover>\n );\n}\n\n// ============================================================================\n// DatePickerWithRange — 날짜 범위 선택\n// ============================================================================\n\ninterface DatePickerWithRangeProps {\n CalendarIcon: React.ComponentType<{ className?: string }>;\n value?: DateRange;\n onValueChange?: (value: DateRange | undefined) => void;\n placeholder?: string;\n dateFormat?: string;\n className?: string;\n numberOfMonths?: number;\n maxDate?: Date;\n minDate?: Date;\n}\n\nexport function DatePickerWithRange({\n CalendarIcon: CalendarIconProp,\n value,\n onValueChange,\n placeholder = \"Pick a date\",\n dateFormat = \"yyyy/MM/dd\",\n className = \"\",\n numberOfMonths = 2,\n maxDate,\n minDate,\n}: DatePickerWithRangeProps) {\n const [isOpen, setIsOpen] = React.useState(false);\n\n const displayText = React.useMemo(() => {\n if (!value?.from && !value?.to) {\n return placeholder;\n }\n const fromStr = value?.from ? format(value.from, dateFormat) : \"\";\n const toStr = value?.to ? format(value.to, dateFormat) : \"\";\n if (fromStr && toStr) {\n return `${fromStr} - ${toStr}`;\n }\n if (toStr) {\n return `- ${toStr}`;\n }\n return `${fromStr} -`;\n }, [value, dateFormat, placeholder]);\n\n const disabledMatcher = React.useMemo(() => {\n if (!maxDate && !minDate) {\n return undefined;\n }\n return (date: Date): boolean => {\n if (maxDate && date > maxDate) {\n return true;\n }\n if (minDate && date < minDate) {\n return true;\n }\n return false;\n };\n }, [maxDate, minDate]);\n\n return (\n <Popover open={isOpen} onOpenChange={setIsOpen}>\n <PopoverTrigger asChild>\n <Button\n variant=\"outline\"\n className={`justify-start gap-2 h-8 px-3 text-xs font-normal ${className}`}\n >\n <CalendarIconProp className=\"h-4 w-4 shrink-0\" />\n <span className=\"truncate\">{displayText}</span>\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n <Calendar\n mode=\"range\"\n defaultMonth={\n value?.from ??\n (value?.to ? new Date(value.to.getFullYear(), value.to.getMonth() - 1, 1) : undefined)\n }\n selected={value}\n onSelect={onValueChange}\n numberOfMonths={numberOfMonths}\n disabled={disabledMatcher}\n />\n </PopoverContent>\n </Popover>\n );\n}\n\nexport type { DatePickerProps, DatePickerWithRangeProps, DateRange };\n"],"mappings":";;;;;;;;;;;AA0BA,SAAgB,EAAW,EACzB,UACA,kBACA,gBACA,cAAW,IACX,gBACkB;CAClB,IAAM,EAAE,UAAO,EAAqB,GAC9B,IAAmB,KAAe,EAAG,wBAAwB;CAEnE,OACE,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;EAAgB,SAAA;YACd,kBAAC,GAAD;GACE,SAAQ;GACE;GACV,cAAY,CAAC;GACb,WAAW,EACT,8CACA,2CACA,CACF;aARF,CAUE,kBAAC,GAAD,CAAe,CAAA,GACd,IAAQ,EAAO,GAAO,KAAK,IAAI,kBAAC,QAAD,EAAA,UAAO,EAAuB,CAAA,CACxD;;CACM,CAAA,GAChB,kBAAC,GAAD;EAAgB,WAAU;EAAa,OAAM;YAC3C,kBAAC,GAAD;GACE,MAAK;GACL,UAAU;GACV,WAAW,MAAS;IAClB,IAAgB,CAAI;GACtB;GACA,cAAA;EACD,CAAA;CACa,CAAA,CACT,EAAA,CAAA;AAEb;AAMA,SAAgB,EAAuB,EACrC,UACA,kBACA,gBACA,cAAW,IACX,gBACkB;CAClB,IAAM,EAAE,UAAO,EAAqB,GAC9B,IAAmB,KAAe,EAAG,0BAA0B,GAC/D,CAAC,GAAM,KAAW,EAAM,SAAS,EAAK;CAE5C,OACE,kBAAC,GAAD;EAAe;EAAM,cAAc;YAAnC,CACE,kBAAC,GAAD;GAAgB,SAAA;aACd,kBAAC,GAAD;IACE,SAAQ;IACE;IACV,WAAW,EACT,sCACA,CAAC,KAAS,yBACV,CACF;cAPF,CASG,IAAQ,EAAM,mBAAmB,IAAI,GACtC,kBAAC,GAAD,CAAe,CAAA,CACT;;EACM,CAAA,GAChB,kBAAC,GAAD;GAAgB,WAAU;GAA6B,OAAM;aAC3D,kBAAC,GAAD;IACE,MAAK;IACL,UAAU;IACV,eAAc;IACd,WAAW,MAAiB;KAE1B,AADA,IAAgB,CAAY,GAC5B,EAAQ,EAAK;IACf;GACD,CAAA;EACa,CAAA,CACT;;AAEb;AAkBA,SAAgB,EAAoB,EAClC,cAAc,GACd,UACA,kBACA,iBAAc,eACd,gBAAa,cACb,eAAY,IACZ,oBAAiB,GACjB,YACA,cAC2B;CAC3B,IAAM,CAAC,GAAQ,KAAa,EAAM,SAAS,EAAK,GAE1C,IAAc,EAAM,cAAc;EACtC,IAAI,CAAC,GAAO,QAAQ,CAAC,GAAO,IAC1B,OAAO;EAET,IAAM,IAAU,GAAO,OAAO,EAAO,EAAM,MAAM,CAAU,IAAI,IACzD,IAAQ,GAAO,KAAK,EAAO,EAAM,IAAI,CAAU,IAAI;EAOzD,OANI,KAAW,IACN,GAAG,EAAQ,KAAK,MAErB,IACK,KAAK,MAEP,GAAG,EAAQ;CACpB,GAAG;EAAC;EAAO;EAAY;CAAW,CAAC,GAE7B,IAAkB,EAAM,cAAc;EACtC,OAAC,KAAW,CAAC,IAGjB,QAAQ,MAIN,GAHI,KAAW,IAAO,KAGlB,KAAW,IAAO;CAK1B,GAAG,CAAC,GAAS,CAAO,CAAC;CAErB,OACE,kBAAC,GAAD;EAAS,MAAM;EAAQ,cAAc;YAArC,CACE,kBAAC,GAAD;GAAgB,SAAA;aACd,kBAAC,GAAD;IACE,SAAQ;IACR,WAAW,oDAAoD;cAFjE,CAIE,kBAAC,GAAD,EAAkB,WAAU,mBAAoB,CAAA,GAChD,kBAAC,QAAD;KAAM,WAAU;eAAY;IAAkB,CAAA,CACxC;;EACM,CAAA,GAChB,kBAAC,GAAD;GAAgB,WAAU;GAAa,OAAM;aAC3C,kBAAC,GAAD;IACE,MAAK;IACL,cACE,GAAO,SACN,GAAO,KAAK,IAAI,KAAK,EAAM,GAAG,YAAY,GAAG,EAAM,GAAG,SAAS,IAAI,GAAG,CAAC,IAAI,KAAA;IAE9E,UAAU;IACV,UAAU;IACM;IAChB,UAAU;GACX,CAAA;EACa,CAAA,CACT;;AAEb"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import t from "../../_virtual/~icons/lucide/x.js";
|
|
4
|
+
import * as n from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
import * as a from "@radix-ui/react-dialog";
|
|
7
|
+
//#region src/components/ui/dialog.tsx
|
|
8
|
+
var o = a.Root, s = a.Trigger, c = a.Portal, l = a.Close, u = n.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r(a.Overlay, {
|
|
9
|
+
ref: i,
|
|
10
|
+
className: e("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", t),
|
|
11
|
+
...n
|
|
12
|
+
}));
|
|
13
|
+
u.displayName = a.Overlay.displayName;
|
|
14
|
+
var d = n.forwardRef(({ className: n, children: o, ...s }, l) => /* @__PURE__ */ i(c, { children: [/* @__PURE__ */ r(u, {}), /* @__PURE__ */ i(a.Content, {
|
|
15
|
+
ref: l,
|
|
16
|
+
className: e("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg", n),
|
|
17
|
+
...s,
|
|
18
|
+
children: [o, /* @__PURE__ */ i(a.Close, {
|
|
19
|
+
className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
|
|
20
|
+
children: [/* @__PURE__ */ r(t, { className: "h-4 w-4" }), /* @__PURE__ */ r("span", {
|
|
21
|
+
className: "sr-only",
|
|
22
|
+
children: "Close"
|
|
23
|
+
})]
|
|
24
|
+
})]
|
|
25
|
+
})] }));
|
|
26
|
+
d.displayName = a.Content.displayName;
|
|
27
|
+
var f = ({ className: t, ...n }) => /* @__PURE__ */ r("div", {
|
|
28
|
+
className: e("flex flex-col space-y-1.5 text-center sm:text-left", t),
|
|
29
|
+
...n
|
|
30
|
+
});
|
|
31
|
+
f.displayName = "DialogHeader";
|
|
32
|
+
var p = ({ className: t, ...n }) => /* @__PURE__ */ r("div", {
|
|
33
|
+
className: e("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", t),
|
|
34
|
+
...n
|
|
35
|
+
});
|
|
36
|
+
p.displayName = "DialogFooter";
|
|
37
|
+
var m = n.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r(a.Title, {
|
|
38
|
+
ref: i,
|
|
39
|
+
className: e("text-lg font-semibold leading-none tracking-tight", t),
|
|
40
|
+
...n
|
|
41
|
+
}));
|
|
42
|
+
m.displayName = a.Title.displayName;
|
|
43
|
+
var h = n.forwardRef(({ className: t, ...n }, i) => /* @__PURE__ */ r(a.Description, {
|
|
44
|
+
ref: i,
|
|
45
|
+
className: e("text-sm text-muted-foreground", t),
|
|
46
|
+
...n
|
|
47
|
+
}));
|
|
48
|
+
h.displayName = a.Description.displayName;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { o as Dialog, l as DialogClose, d as DialogContent, h as DialogDescription, p as DialogFooter, f as DialogHeader, u as DialogOverlay, c as DialogPortal, m as DialogTitle, s as DialogTrigger };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","names":[],"sources":["../../../src/components/ui/dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport XIcon from \"~icons/lucide/x\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <XIcon className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"flex flex-col space-y-1.5 text-center sm:text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\", className)}\n {...props}\n />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"text-lg font-semibold leading-none tracking-tight\", className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"],"mappings":";;;;;;;AAQA,IAAM,IAAS,EAAgB,MAEzB,IAAgB,EAAgB,SAEhC,IAAe,EAAgB,QAE/B,IAAc,EAAgB,OAE9B,IAAgB,EAAM,YAGzB,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAgB,SAAjB;CACO;CACL,WAAW,EACT,0JACA,CACF;CACA,GAAI;AACL,CAAA,CACF;AACD,EAAc,cAAc,EAAgB,QAAQ;AAEpD,IAAM,IAAgB,EAAM,YAGzB,EAAE,cAAW,aAAU,GAAG,KAAS,MACpC,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD,CAAgB,CAAA,GAChB,kBAAC,EAAgB,SAAjB;CACO;CACL,WAAW,EACT,+fACA,CACF;CACA,GAAI;WANN,CAQG,GACD,kBAAC,EAAgB,OAAjB;EAAuB,WAAU;YAAjC,CACE,kBAAC,GAAD,EAAO,WAAU,UAAW,CAAA,GAC5B,kBAAC,QAAD;GAAM,WAAU;aAAU;EAAW,CAAA,CAChB;GACA;EACb,EAAA,CAAA,CACf;AACD,EAAc,cAAc,EAAgB,QAAQ;AAEpD,IAAM,KAAgB,EAAE,cAAW,GAAG,QACpC,kBAAC,OAAD;CAAK,WAAW,EAAG,sDAAsD,CAAS;CAAG,GAAI;AAAQ,CAAA;AAEnG,EAAa,cAAc;AAE3B,IAAM,KAAgB,EAAE,cAAW,GAAG,QACpC,kBAAC,OAAD;CACE,WAAW,EAAG,iEAAiE,CAAS;CACxF,GAAI;AACL,CAAA;AAEH,EAAa,cAAc;AAE3B,IAAM,IAAc,EAAM,YAGvB,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAgB,OAAjB;CACO;CACL,WAAW,EAAG,qDAAqD,CAAS;CAC5E,GAAI;AACL,CAAA,CACF;AACD,EAAY,cAAc,EAAgB,MAAM;AAEhD,IAAM,IAAoB,EAAM,YAG7B,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAgB,aAAjB;CACO;CACL,WAAW,EAAG,iCAAiC,CAAS;CACxD,GAAI;AACL,CAAA,CACF;AACD,EAAkB,cAAc,EAAgB,YAAY"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import * as t from "react";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
import { Drawer as i } from "vaul";
|
|
6
|
+
//#region src/components/ui/drawer.tsx
|
|
7
|
+
var a = ({ shouldScaleBackground: e = !0, ...t }) => /* @__PURE__ */ n(i.Root, {
|
|
8
|
+
shouldScaleBackground: e,
|
|
9
|
+
...t
|
|
10
|
+
});
|
|
11
|
+
a.displayName = "Drawer";
|
|
12
|
+
var o = i.Trigger, s = i.Portal, c = i.Close, l = t.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ n(i.Overlay, {
|
|
13
|
+
ref: a,
|
|
14
|
+
className: e("fixed inset-0 z-50 bg-black/80", t),
|
|
15
|
+
...r
|
|
16
|
+
}));
|
|
17
|
+
l.displayName = i.Overlay.displayName;
|
|
18
|
+
var u = t.forwardRef(({ className: t, children: a, ...o }, c) => /* @__PURE__ */ r(s, { children: [/* @__PURE__ */ n(l, {}), /* @__PURE__ */ r(i.Content, {
|
|
19
|
+
ref: c,
|
|
20
|
+
className: e("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background", t),
|
|
21
|
+
...o,
|
|
22
|
+
children: [/* @__PURE__ */ n("div", { className: "mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" }), a]
|
|
23
|
+
})] }));
|
|
24
|
+
u.displayName = "DrawerContent";
|
|
25
|
+
var d = ({ className: t, ...r }) => /* @__PURE__ */ n("div", {
|
|
26
|
+
className: e("grid gap-1.5 p-4 text-center sm:text-left", t),
|
|
27
|
+
...r
|
|
28
|
+
});
|
|
29
|
+
d.displayName = "DrawerHeader";
|
|
30
|
+
var f = ({ className: t, ...r }) => /* @__PURE__ */ n("div", {
|
|
31
|
+
className: e("mt-auto flex flex-col gap-2 p-4", t),
|
|
32
|
+
...r
|
|
33
|
+
});
|
|
34
|
+
f.displayName = "DrawerFooter";
|
|
35
|
+
var p = t.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ n(i.Title, {
|
|
36
|
+
ref: a,
|
|
37
|
+
className: e("text-lg font-semibold leading-none tracking-tight", t),
|
|
38
|
+
...r
|
|
39
|
+
}));
|
|
40
|
+
p.displayName = i.Title.displayName;
|
|
41
|
+
var m = t.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ n(i.Description, {
|
|
42
|
+
ref: a,
|
|
43
|
+
className: e("text-sm text-muted-foreground", t),
|
|
44
|
+
...r
|
|
45
|
+
}));
|
|
46
|
+
m.displayName = i.Description.displayName;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { a as Drawer, c as DrawerClose, u as DrawerContent, m as DrawerDescription, f as DrawerFooter, d as DrawerHeader, l as DrawerOverlay, s as DrawerPortal, p as DrawerTitle, o as DrawerTrigger };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer.js","names":[],"sources":["../../../src/components/ui/drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Drawer as DrawerPrimitive } from \"vaul\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Drawer = ({\n shouldScaleBackground = true,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (\n <DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />\n);\nDrawer.displayName = \"Drawer\";\n\nconst DrawerTrigger = DrawerPrimitive.Trigger;\n\nconst DrawerPortal = DrawerPrimitive.Portal;\n\nconst DrawerClose = DrawerPrimitive.Close;\n\nconst DrawerOverlay = React.forwardRef<\n React.ComponentRef<typeof DrawerPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DrawerPrimitive.Overlay\n ref={ref}\n className={cn(\"fixed inset-0 z-50 bg-black/80\", className)}\n {...props}\n />\n));\nDrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;\n\nconst DrawerContent = React.forwardRef<\n React.ComponentRef<typeof DrawerPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DrawerPortal>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background\",\n className,\n )}\n {...props}\n >\n <div className=\"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted\" />\n {children}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n));\nDrawerContent.displayName = \"DrawerContent\";\n\nconst DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"grid gap-1.5 p-4 text-center sm:text-left\", className)} {...props} />\n);\nDrawerHeader.displayName = \"DrawerHeader\";\n\nconst DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"mt-auto flex flex-col gap-2 p-4\", className)} {...props} />\n);\nDrawerFooter.displayName = \"DrawerFooter\";\n\nconst DrawerTitle = React.forwardRef<\n React.ComponentRef<typeof DrawerPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DrawerPrimitive.Title\n ref={ref}\n className={cn(\"text-lg font-semibold leading-none tracking-tight\", className)}\n {...props}\n />\n));\nDrawerTitle.displayName = DrawerPrimitive.Title.displayName;\n\nconst DrawerDescription = React.forwardRef<\n React.ComponentRef<typeof DrawerPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DrawerPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDrawerDescription.displayName = DrawerPrimitive.Description.displayName;\n\nexport {\n Drawer,\n DrawerPortal,\n DrawerOverlay,\n DrawerTrigger,\n DrawerClose,\n DrawerContent,\n DrawerHeader,\n DrawerFooter,\n DrawerTitle,\n DrawerDescription,\n};\n"],"mappings":";;;;;;AAOA,IAAM,KAAU,EACd,2BAAwB,IACxB,GAAG,QAEH,kBAAC,EAAgB,MAAjB;CAA6C;CAAuB,GAAI;AAAQ,CAAA;AAElF,EAAO,cAAc;AAErB,IAAM,IAAgB,EAAgB,SAEhC,IAAe,EAAgB,QAE/B,IAAc,EAAgB,OAE9B,IAAgB,EAAM,YAGzB,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAgB,SAAjB;CACO;CACL,WAAW,EAAG,kCAAkC,CAAS;CACzD,GAAI;AACL,CAAA,CACF;AACD,EAAc,cAAc,EAAgB,QAAQ;AAEpD,IAAM,IAAgB,EAAM,YAGzB,EAAE,cAAW,aAAU,GAAG,KAAS,MACpC,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD,CAAgB,CAAA,GAChB,kBAAC,EAAgB,SAAjB;CACO;CACL,WAAW,EACT,kGACA,CACF;CACA,GAAI;WANN,CAQE,kBAAC,OAAD,EAAK,WAAU,mDAAoD,CAAA,GAClE,CACsB;EACb,EAAA,CAAA,CACf;AACD,EAAc,cAAc;AAE5B,IAAM,KAAgB,EAAE,cAAW,GAAG,QACpC,kBAAC,OAAD;CAAK,WAAW,EAAG,6CAA6C,CAAS;CAAG,GAAI;AAAQ,CAAA;AAE1F,EAAa,cAAc;AAE3B,IAAM,KAAgB,EAAE,cAAW,GAAG,QACpC,kBAAC,OAAD;CAAK,WAAW,EAAG,mCAAmC,CAAS;CAAG,GAAI;AAAQ,CAAA;AAEhF,EAAa,cAAc;AAE3B,IAAM,IAAc,EAAM,YAGvB,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAgB,OAAjB;CACO;CACL,WAAW,EAAG,qDAAqD,CAAS;CAC5E,GAAI;AACL,CAAA,CACF;AACD,EAAY,cAAc,EAAgB,MAAM;AAEhD,IAAM,IAAoB,EAAM,YAG7B,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAgB,aAAjB;CACO;CACL,WAAW,EAAG,iCAAiC,CAAS;CACxD,GAAI;AACL,CAAA,CACF;AACD,EAAkB,cAAc,EAAgB,YAAY"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import t from "../../_virtual/~icons/lucide/chevron-right.js";
|
|
4
|
+
import n from "../../_virtual/~icons/lucide/check.js";
|
|
5
|
+
import r from "../../_virtual/~icons/lucide/circle.js";
|
|
6
|
+
import * as i from "react";
|
|
7
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
|
+
import * as s from "@radix-ui/react-dropdown-menu";
|
|
9
|
+
//#region src/components/ui/dropdown-menu.tsx
|
|
10
|
+
var c = s.Root, l = s.Trigger, u = s.Group, d = s.Portal, f = s.Sub, p = s.RadioGroup, m = i.forwardRef(({ className: n, inset: r, children: i, ...c }, l) => /* @__PURE__ */ o(s.SubTrigger, {
|
|
11
|
+
ref: l,
|
|
12
|
+
className: e("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", r && "pl-8", n),
|
|
13
|
+
...c,
|
|
14
|
+
children: [i, /* @__PURE__ */ a(t, { className: "ml-auto" })]
|
|
15
|
+
}));
|
|
16
|
+
m.displayName = s.SubTrigger.displayName;
|
|
17
|
+
var h = i.forwardRef(({ className: t, ...n }, r) => /* @__PURE__ */ a(s.SubContent, {
|
|
18
|
+
ref: r,
|
|
19
|
+
className: e("z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]", t),
|
|
20
|
+
...n
|
|
21
|
+
}));
|
|
22
|
+
h.displayName = s.SubContent.displayName;
|
|
23
|
+
var g = i.forwardRef(({ className: t, sideOffset: n = 4, ...r }, i) => /* @__PURE__ */ a(s.Portal, { children: /* @__PURE__ */ a(s.Content, {
|
|
24
|
+
ref: i,
|
|
25
|
+
sideOffset: n,
|
|
26
|
+
className: e("z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]", t),
|
|
27
|
+
...r
|
|
28
|
+
}) }));
|
|
29
|
+
g.displayName = s.Content.displayName;
|
|
30
|
+
var _ = i.forwardRef(({ className: t, inset: n, ...r }, i) => /* @__PURE__ */ a(s.Item, {
|
|
31
|
+
ref: i,
|
|
32
|
+
className: e("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", n && "pl-8", t),
|
|
33
|
+
...r
|
|
34
|
+
}));
|
|
35
|
+
_.displayName = s.Item.displayName;
|
|
36
|
+
var v = i.forwardRef(({ className: t, children: r, checked: i, ...c }, l) => /* @__PURE__ */ o(s.CheckboxItem, {
|
|
37
|
+
ref: l,
|
|
38
|
+
className: e("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50", t),
|
|
39
|
+
checked: i,
|
|
40
|
+
...c,
|
|
41
|
+
children: [/* @__PURE__ */ a("span", {
|
|
42
|
+
className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
43
|
+
children: /* @__PURE__ */ a(s.ItemIndicator, { children: /* @__PURE__ */ a(n, { className: "h-4 w-4" }) })
|
|
44
|
+
}), r]
|
|
45
|
+
}));
|
|
46
|
+
v.displayName = s.CheckboxItem.displayName;
|
|
47
|
+
var y = i.forwardRef(({ className: t, children: n, ...i }, c) => /* @__PURE__ */ o(s.RadioItem, {
|
|
48
|
+
ref: c,
|
|
49
|
+
className: e("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50", t),
|
|
50
|
+
...i,
|
|
51
|
+
children: [/* @__PURE__ */ a("span", {
|
|
52
|
+
className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
53
|
+
children: /* @__PURE__ */ a(s.ItemIndicator, { children: /* @__PURE__ */ a(r, { className: "h-2 w-2 fill-current" }) })
|
|
54
|
+
}), n]
|
|
55
|
+
}));
|
|
56
|
+
y.displayName = s.RadioItem.displayName;
|
|
57
|
+
var b = i.forwardRef(({ className: t, inset: n, ...r }, i) => /* @__PURE__ */ a(s.Label, {
|
|
58
|
+
ref: i,
|
|
59
|
+
className: e("px-2 py-1.5 text-sm font-semibold", n && "pl-8", t),
|
|
60
|
+
...r
|
|
61
|
+
}));
|
|
62
|
+
b.displayName = s.Label.displayName;
|
|
63
|
+
var x = i.forwardRef(({ className: t, ...n }, r) => /* @__PURE__ */ a(s.Separator, {
|
|
64
|
+
ref: r,
|
|
65
|
+
className: e("-mx-1 my-1 h-px bg-muted", t),
|
|
66
|
+
...n
|
|
67
|
+
}));
|
|
68
|
+
x.displayName = s.Separator.displayName;
|
|
69
|
+
var S = ({ className: t, ...n }) => /* @__PURE__ */ a("span", {
|
|
70
|
+
className: e("ml-auto text-xs tracking-widest opacity-60", t),
|
|
71
|
+
...n
|
|
72
|
+
});
|
|
73
|
+
S.displayName = "DropdownMenuShortcut";
|
|
74
|
+
//#endregion
|
|
75
|
+
export { c as DropdownMenu, v as DropdownMenuCheckboxItem, g as DropdownMenuContent, u as DropdownMenuGroup, _ as DropdownMenuItem, b as DropdownMenuLabel, d as DropdownMenuPortal, p as DropdownMenuRadioGroup, y as DropdownMenuRadioItem, x as DropdownMenuSeparator, S as DropdownMenuShortcut, f as DropdownMenuSub, h as DropdownMenuSubContent, m as DropdownMenuSubTrigger, l as DropdownMenuTrigger };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=dropdown-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","names":[],"sources":["../../../src/components/ui/dropdown-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport * as React from \"react\";\nimport CheckIcon from \"~icons/lucide/check\";\nimport ChevronRightIcon from \"~icons/lucide/chevron-right\";\nimport CircleIcon from \"~icons/lucide/circle\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst DropdownMenu = DropdownMenuPrimitive.Root;\n\nconst DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\n\nconst DropdownMenuGroup = DropdownMenuPrimitive.Group;\n\nconst DropdownMenuPortal = DropdownMenuPrimitive.Portal;\n\nconst DropdownMenuSub = DropdownMenuPrimitive.Sub;\n\nconst DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst DropdownMenuSubTrigger = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(({ className, inset, children, ...props }, ref) => (\n <DropdownMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n \"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n inset && \"pl-8\",\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"ml-auto\" />\n </DropdownMenuPrimitive.SubTrigger>\n));\nDropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;\n\nconst DropdownMenuSubContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n \"z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]\",\n className,\n )}\n {...props}\n />\n));\nDropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;\n\nconst DropdownMenuContent = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n>(({ className, sideOffset = 4, ...props }, ref) => (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]\",\n className,\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n));\nDropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;\n\nconst DropdownMenuItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n }\n>(({ className, inset, ...props }, ref) => (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n inset && \"pl-8\",\n className,\n )}\n {...props}\n />\n));\nDropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;\n\nconst DropdownMenuCheckboxItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(({ className, children, checked, ...props }, ref) => (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CheckIcon className=\"h-4 w-4\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n));\nDropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;\n\nconst DropdownMenuRadioItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(({ className, children, ...props }, ref) => (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n <span className=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CircleIcon className=\"h-2 w-2 fill-current\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n));\nDropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;\n\nconst DropdownMenuLabel = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(({ className, inset, ...props }, ref) => (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\"px-2 py-1.5 text-sm font-semibold\", inset && \"pl-8\", className)}\n {...props}\n />\n));\nDropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;\n\nconst DropdownMenuSeparator = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 my-1 h-px bg-muted\", className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;\n\nconst DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span className={cn(\"ml-auto text-xs tracking-widest opacity-60\", className)} {...props} />\n );\n};\nDropdownMenuShortcut.displayName = \"DropdownMenuShortcut\";\n\nexport {\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuRadioGroup,\n};\n"],"mappings":";;;;;;;;;AAUA,IAAM,IAAe,EAAsB,MAErC,IAAsB,EAAsB,SAE5C,IAAoB,EAAsB,OAE1C,IAAqB,EAAsB,QAE3C,IAAkB,EAAsB,KAExC,IAAyB,EAAsB,YAE/C,IAAyB,EAAM,YAKlC,EAAE,cAAW,UAAO,aAAU,GAAG,KAAS,MAC3C,kBAAC,EAAsB,YAAvB;CACO;CACL,WAAW,EACT,0MACA,KAAS,QACT,CACF;CACA,GAAI;WAPN,CASG,GACD,kBAAC,GAAD,EAAkB,WAAU,UAAW,CAAA,CACP;EACnC;AACD,EAAuB,cAAc,EAAsB,WAAW;AAEtE,IAAM,IAAyB,EAAM,YAGlC,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAsB,YAAvB;CACO;CACL,WAAW,EACT,6eACA,CACF;CACA,GAAI;AACL,CAAA,CACF;AACD,EAAuB,cAAc,EAAsB,WAAW;AAEtE,IAAM,IAAsB,EAAM,YAG/B,EAAE,cAAW,gBAAa,GAAG,GAAG,KAAS,MAC1C,kBAAC,EAAsB,QAAvB,EAAA,UACE,kBAAC,EAAsB,SAAvB;CACO;CACO;CACZ,WAAW,EACT,sjBACA,CACF;CACA,GAAI;AACL,CAAA,EAC2B,CAAA,CAC/B;AACD,EAAoB,cAAc,EAAsB,QAAQ;AAEhE,IAAM,IAAmB,EAAM,YAK5B,EAAE,cAAW,UAAO,GAAG,KAAS,MACjC,kBAAC,EAAsB,MAAvB;CACO;CACL,WAAW,EACT,iSACA,KAAS,QACT,CACF;CACA,GAAI;AACL,CAAA,CACF;AACD,EAAiB,cAAc,EAAsB,KAAK;AAE1D,IAAM,IAA2B,EAAM,YAGpC,EAAE,cAAW,aAAU,YAAS,GAAG,KAAS,MAC7C,kBAAC,EAAsB,cAAvB;CACO;CACL,WAAW,EACT,oOACA,CACF;CACS;CACT,GAAI;WAPN,CASE,kBAAC,QAAD;EAAM,WAAU;YACd,kBAAC,EAAsB,eAAvB,EAAA,UACE,kBAAC,GAAD,EAAW,WAAU,UAAW,CAAA,EACG,CAAA;CACjC,CAAA,GACL,CACiC;EACrC;AACD,EAAyB,cAAc,EAAsB,aAAa;AAE1E,IAAM,IAAwB,EAAM,YAGjC,EAAE,cAAW,aAAU,GAAG,KAAS,MACpC,kBAAC,EAAsB,WAAvB;CACO;CACL,WAAW,EACT,oOACA,CACF;CACA,GAAI;WANN,CAQE,kBAAC,QAAD;EAAM,WAAU;YACd,kBAAC,EAAsB,eAAvB,EAAA,UACE,kBAAC,GAAD,EAAY,WAAU,uBAAwB,CAAA,EACX,CAAA;CACjC,CAAA,GACL,CAC8B;EAClC;AACD,EAAsB,cAAc,EAAsB,UAAU;AAEpE,IAAM,IAAoB,EAAM,YAK7B,EAAE,cAAW,UAAO,GAAG,KAAS,MACjC,kBAAC,EAAsB,OAAvB;CACO;CACL,WAAW,EAAG,qCAAqC,KAAS,QAAQ,CAAS;CAC7E,GAAI;AACL,CAAA,CACF;AACD,EAAkB,cAAc,EAAsB,MAAM;AAE5D,IAAM,IAAwB,EAAM,YAGjC,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,EAAsB,WAAvB;CACO;CACL,WAAW,EAAG,4BAA4B,CAAS;CACnD,GAAI;AACL,CAAA,CACF;AACD,EAAsB,cAAc,EAAsB,UAAU;AAEpE,IAAM,KAAwB,EAAE,cAAW,GAAG,QAE1C,kBAAC,QAAD;CAAM,WAAW,EAAG,8CAA8C,CAAS;CAAG,GAAI;AAAQ,CAAA;AAG9F,EAAqB,cAAc"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { cn as e, useObjectUrls as t } from "../../lib/utils.js";
|
|
2
|
+
import { Button as n } from "./button.js";
|
|
3
|
+
import { useSonamuBaseContext as r } from "../../contexts/sonamu-context.js";
|
|
4
|
+
import i from "../../_virtual/~icons/lucide/x.js";
|
|
5
|
+
import a from "../../_virtual/~icons/lucide/image.js";
|
|
6
|
+
import o from "../../_virtual/~icons/lucide/loader2.js";
|
|
7
|
+
import s from "../../_virtual/~icons/lucide/upload.js";
|
|
8
|
+
import { useCallback as c, useRef as l, useState as u } from "react";
|
|
9
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
10
|
+
import { FileIcon as m, defaultStyles as h } from "react-file-icon";
|
|
11
|
+
//#region src/components/ui/file-input.tsx
|
|
12
|
+
function g(e) {
|
|
13
|
+
let t = e.split(".");
|
|
14
|
+
return t.length < 2 ? "" : t[t.length - 1].toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
var _ = {
|
|
17
|
+
sm: 14,
|
|
18
|
+
md: 18,
|
|
19
|
+
lg: 22,
|
|
20
|
+
xl: 26
|
|
21
|
+
};
|
|
22
|
+
function v({ filename: e, size: t = "md" }) {
|
|
23
|
+
let n = g(e), r = n && n in h ? h[n] : {};
|
|
24
|
+
return /* @__PURE__ */ f("div", {
|
|
25
|
+
className: "shrink-0 self-center",
|
|
26
|
+
style: {
|
|
27
|
+
width: _[t],
|
|
28
|
+
marginTop: -2
|
|
29
|
+
},
|
|
30
|
+
children: /* @__PURE__ */ f(m, {
|
|
31
|
+
extension: n || void 0,
|
|
32
|
+
...r
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
var y = {
|
|
37
|
+
sm: "w-20 h-20",
|
|
38
|
+
md: "w-32 h-32",
|
|
39
|
+
lg: "w-40 h-40",
|
|
40
|
+
xl: "w-48 h-48"
|
|
41
|
+
}, b = {
|
|
42
|
+
sm: "w-48 h-12",
|
|
43
|
+
md: "w-80 h-16",
|
|
44
|
+
lg: "w-96 h-20",
|
|
45
|
+
xl: "w-[28rem] h-24"
|
|
46
|
+
};
|
|
47
|
+
function x(m) {
|
|
48
|
+
let { placeholder: h, disabled: g = !1, className: _, previewSize: x = "md", uploadMode: S, viewMode: C, uploadParams: w, onBlur: T } = m, { uploader: E, SD: D } = r(), O = m.multiple ?? !1, k = C === "image", A = m.accept ?? (k ? "image/*" : "*/*"), j = l(null), [M, N] = u(!1), [P, F] = u(!1), I = h ?? `${D(k ? "rc.fileInput.imagePlaceholder" : "rc.fileInput.filePlaceholder")} URL${O ? "S" : ""}`, L = (() => {
|
|
49
|
+
if (!O) {
|
|
50
|
+
let e = m.value;
|
|
51
|
+
return e ? [e] : [];
|
|
52
|
+
}
|
|
53
|
+
return m.value || [];
|
|
54
|
+
})(), R = L.filter((e) => e instanceof File), z = t(R), B = L.map((e) => e instanceof File ? {
|
|
55
|
+
url: z[R.indexOf(e)],
|
|
56
|
+
name: e.name,
|
|
57
|
+
isPending: !0
|
|
58
|
+
} : {
|
|
59
|
+
url: e.url,
|
|
60
|
+
name: e.name,
|
|
61
|
+
isPending: !1
|
|
62
|
+
}), V = O ? m.maxFiles ?? 10 : 1, H = L.length, U = H < V, W = c(async (e) => {
|
|
63
|
+
if (e.length === 0 || g) return;
|
|
64
|
+
let t = V - H;
|
|
65
|
+
if (t <= 0) {
|
|
66
|
+
alert(D("rc.fileInput.maxFilesExceeded")(V));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let n = e.slice(0, t);
|
|
70
|
+
if (S === "eager") {
|
|
71
|
+
N(!0);
|
|
72
|
+
try {
|
|
73
|
+
let e = await E(n, w);
|
|
74
|
+
if (O) {
|
|
75
|
+
let t = [...L, ...e];
|
|
76
|
+
m.onValueChange?.(t);
|
|
77
|
+
} else m.onValueChange?.(e[0]);
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.error("Upload failed:", e), alert(D("rc.fileInput.uploadFailed"));
|
|
80
|
+
} finally {
|
|
81
|
+
N(!1);
|
|
82
|
+
}
|
|
83
|
+
} else if (O) {
|
|
84
|
+
let e = [...L, ...n];
|
|
85
|
+
m.onValueChange?.(e);
|
|
86
|
+
} else m.onValueChange?.(n[0]);
|
|
87
|
+
}, [
|
|
88
|
+
g,
|
|
89
|
+
H,
|
|
90
|
+
V,
|
|
91
|
+
O,
|
|
92
|
+
S,
|
|
93
|
+
w,
|
|
94
|
+
L,
|
|
95
|
+
m,
|
|
96
|
+
E
|
|
97
|
+
]), G = c((e) => {
|
|
98
|
+
W(Array.from(e.target.files || [])), j.current && (j.current.value = "");
|
|
99
|
+
}, [W]), K = c((e) => {
|
|
100
|
+
e.preventDefault(), F(!1), !(g || M) && W(Array.from(e.dataTransfer.files));
|
|
101
|
+
}, [
|
|
102
|
+
W,
|
|
103
|
+
g,
|
|
104
|
+
M
|
|
105
|
+
]), q = c((e) => (t) => {
|
|
106
|
+
if (t.stopPropagation(), !O) m.onValueChange?.(null);
|
|
107
|
+
else {
|
|
108
|
+
let t = L.filter((t, n) => n !== e);
|
|
109
|
+
m.onValueChange?.(t);
|
|
110
|
+
}
|
|
111
|
+
}, [
|
|
112
|
+
L,
|
|
113
|
+
O,
|
|
114
|
+
m.onValueChange
|
|
115
|
+
]), J = () => {
|
|
116
|
+
!g && !M && j.current?.click();
|
|
117
|
+
}, Y = k ? y : b;
|
|
118
|
+
if (!O && B.length > 0) {
|
|
119
|
+
let t = B[0];
|
|
120
|
+
return /* @__PURE__ */ p("div", {
|
|
121
|
+
className: e("relative inline-block", _),
|
|
122
|
+
children: [/* @__PURE__ */ f("input", {
|
|
123
|
+
ref: j,
|
|
124
|
+
type: "file",
|
|
125
|
+
accept: A,
|
|
126
|
+
onChange: G,
|
|
127
|
+
onBlur: T,
|
|
128
|
+
disabled: g || M,
|
|
129
|
+
className: "sr-only"
|
|
130
|
+
}), /* @__PURE__ */ f("div", {
|
|
131
|
+
onClick: J,
|
|
132
|
+
onDrop: K,
|
|
133
|
+
onDragOver: (e) => {
|
|
134
|
+
e.preventDefault(), !g && !M && F(!0);
|
|
135
|
+
},
|
|
136
|
+
onDragLeave: (e) => {
|
|
137
|
+
e.preventDefault(), F(!1);
|
|
138
|
+
},
|
|
139
|
+
className: e("relative flex items-center justify-center rounded-lg border-2 cursor-pointer transition-all", Y[x], k ? "border-transparent" : "border-dashed border-muted-foreground/25 hover:border-muted-foreground/50", P && "border-primary bg-primary/5", g && "opacity-50 cursor-not-allowed", M && "cursor-wait"),
|
|
140
|
+
children: M ? /* @__PURE__ */ p("div", {
|
|
141
|
+
className: "flex flex-col items-center gap-2 text-muted-foreground",
|
|
142
|
+
children: [/* @__PURE__ */ f(o, { className: "h-6 w-6 animate-spin" }), /* @__PURE__ */ f("span", {
|
|
143
|
+
className: "text-xs",
|
|
144
|
+
children: D("rc.fileInput.uploading")
|
|
145
|
+
})]
|
|
146
|
+
}) : /* @__PURE__ */ p(d, { children: [
|
|
147
|
+
k ? /* @__PURE__ */ f("img", {
|
|
148
|
+
src: t.url,
|
|
149
|
+
alt: "Preview",
|
|
150
|
+
className: "h-full w-full object-cover rounded-lg overflow-hidden"
|
|
151
|
+
}) : /* @__PURE__ */ p("div", {
|
|
152
|
+
className: "flex items-center gap-2 px-3 h-full w-full min-w-0 overflow-hidden",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ f(v, {
|
|
155
|
+
filename: t.name,
|
|
156
|
+
size: x
|
|
157
|
+
}),
|
|
158
|
+
/* @__PURE__ */ f("span", {
|
|
159
|
+
className: e("text-xs truncate min-w-0", t.isPending ? "w-[140px] shrink-0" : "flex-1"),
|
|
160
|
+
children: t.name
|
|
161
|
+
}),
|
|
162
|
+
t.isPending && /* @__PURE__ */ f("span", {
|
|
163
|
+
className: "px-2 py-0.5 bg-yellow-500/90 text-white text-xs rounded whitespace-nowrap shrink-0",
|
|
164
|
+
children: D("rc.fileInput.pending")
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
!g && /* @__PURE__ */ f(n, {
|
|
169
|
+
type: "button",
|
|
170
|
+
variant: "destructive",
|
|
171
|
+
size: "xs",
|
|
172
|
+
className: "absolute -top-2 -right-2 h-6 w-6 rounded-full p-0",
|
|
173
|
+
onClick: q(0),
|
|
174
|
+
icon: /* @__PURE__ */ f(i, {})
|
|
175
|
+
}),
|
|
176
|
+
k && t.isPending && /* @__PURE__ */ f("div", {
|
|
177
|
+
className: "absolute bottom-2 left-2 right-2 mx-auto max-w-[calc(100%-1rem)] px-2 py-1 bg-yellow-500/90 text-white text-xs rounded text-center truncate",
|
|
178
|
+
children: D("rc.fileInput.pending")
|
|
179
|
+
})
|
|
180
|
+
] })
|
|
181
|
+
})]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return /* @__PURE__ */ p("div", {
|
|
185
|
+
className: e("flex flex-wrap gap-3", _),
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ f("input", {
|
|
188
|
+
ref: j,
|
|
189
|
+
type: "file",
|
|
190
|
+
accept: A,
|
|
191
|
+
multiple: O,
|
|
192
|
+
onChange: G,
|
|
193
|
+
onBlur: T,
|
|
194
|
+
disabled: g || M,
|
|
195
|
+
className: "sr-only"
|
|
196
|
+
}),
|
|
197
|
+
B.map((t, r) => /* @__PURE__ */ p("div", {
|
|
198
|
+
className: e("relative", Y[x]),
|
|
199
|
+
children: [
|
|
200
|
+
k ? /* @__PURE__ */ f("div", {
|
|
201
|
+
className: "h-full w-full rounded-lg border overflow-hidden",
|
|
202
|
+
children: /* @__PURE__ */ f("img", {
|
|
203
|
+
src: t.url,
|
|
204
|
+
alt: `Uploaded ${r + 1}`,
|
|
205
|
+
className: "h-full w-full object-cover"
|
|
206
|
+
})
|
|
207
|
+
}) : /* @__PURE__ */ p("div", {
|
|
208
|
+
className: e("relative flex items-center gap-2 px-3 rounded-lg border-2 min-w-0 overflow-hidden", "border-dashed border-muted-foreground/25", "h-full w-full"),
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ f(v, {
|
|
211
|
+
filename: t.name,
|
|
212
|
+
size: x
|
|
213
|
+
}),
|
|
214
|
+
/* @__PURE__ */ f("span", {
|
|
215
|
+
className: e("text-xs truncate min-w-0", t.isPending ? "w-[140px] shrink-0" : "flex-1"),
|
|
216
|
+
children: t.name
|
|
217
|
+
}),
|
|
218
|
+
t.isPending && /* @__PURE__ */ f("span", {
|
|
219
|
+
className: "px-2 py-0.5 bg-yellow-500/90 text-white text-xs rounded whitespace-nowrap shrink-0",
|
|
220
|
+
children: D("rc.fileInput.pending")
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
}),
|
|
224
|
+
!g && /* @__PURE__ */ f(n, {
|
|
225
|
+
type: "button",
|
|
226
|
+
variant: "destructive",
|
|
227
|
+
size: "xs",
|
|
228
|
+
className: "absolute -top-2 -right-2 h-6 w-6 rounded-full p-0",
|
|
229
|
+
onClick: q(r),
|
|
230
|
+
icon: /* @__PURE__ */ f(i, {})
|
|
231
|
+
}),
|
|
232
|
+
k && t.isPending && /* @__PURE__ */ f("div", {
|
|
233
|
+
className: "absolute bottom-2 left-2 right-2 mx-auto max-w-[calc(100%-1rem)] px-2 py-1 bg-yellow-500/90 text-white text-xs rounded text-center truncate",
|
|
234
|
+
children: D("rc.fileInput.pending")
|
|
235
|
+
})
|
|
236
|
+
]
|
|
237
|
+
}, `${t.url}-${r}`)),
|
|
238
|
+
U && /* @__PURE__ */ f("div", {
|
|
239
|
+
onClick: J,
|
|
240
|
+
onDrop: K,
|
|
241
|
+
onDragOver: (e) => {
|
|
242
|
+
e.preventDefault(), !g && !M && F(!0);
|
|
243
|
+
},
|
|
244
|
+
onDragLeave: (e) => {
|
|
245
|
+
e.preventDefault(), F(!1);
|
|
246
|
+
},
|
|
247
|
+
className: e("flex items-center justify-center rounded-lg border-2 border-dashed cursor-pointer transition-all", Y[x], P ? "border-primary bg-primary/5" : "border-muted-foreground/25 hover:border-muted-foreground/50", g && "opacity-50 cursor-not-allowed", M && "cursor-wait"),
|
|
248
|
+
children: M ? /* @__PURE__ */ p("div", {
|
|
249
|
+
className: "flex flex-col items-center gap-2 text-muted-foreground",
|
|
250
|
+
children: [/* @__PURE__ */ f(o, { className: "h-6 w-6 animate-spin" }), /* @__PURE__ */ f("span", {
|
|
251
|
+
className: "text-xs",
|
|
252
|
+
children: D("rc.fileInput.uploading")
|
|
253
|
+
})]
|
|
254
|
+
}) : /* @__PURE__ */ p("div", {
|
|
255
|
+
className: "flex flex-col items-center gap-2 text-muted-foreground p-2",
|
|
256
|
+
children: [f(k ? a : s, { className: "h-6 w-6" }), /* @__PURE__ */ f("span", {
|
|
257
|
+
className: "text-xs text-center",
|
|
258
|
+
children: I
|
|
259
|
+
})]
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
export { x as FileInput };
|
|
267
|
+
|
|
268
|
+
//# sourceMappingURL=file-input.js.map
|