@sonamu-kit/react-components 0.4.7 → 0.4.8
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/components/ui/calendar.js +12 -6
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/carousel.js +12 -16
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/common-modal.d.ts +6 -6
- package/dist/components/ui/common-modal.js.map +1 -1
- package/dist/components/ui/file-input.js +131 -130
- package/dist/components/ui/file-input.js.map +1 -1
- package/dist/components/ui/input.js +21 -20
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/month-picker-multiple.js +31 -19
- package/dist/components/ui/month-picker-multiple.js.map +1 -1
- package/dist/components/ui/pagination.js +18 -17
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/select/enum-select.js +4 -2
- package/dist/components/ui/select/enum-select.js.map +1 -1
- package/dist/components/ui/select/id-async-select.d.ts +32 -14
- package/dist/components/ui/select/id-async-select.js +185 -144
- package/dist/components/ui/select/id-async-select.js.map +1 -1
- package/dist/components/ui/select/select.js +199 -158
- package/dist/components/ui/select/select.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +2 -1
- package/dist/components/ui/sidebar.js +54 -45
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/sonamu-filter/constants.d.ts +27 -3
- package/dist/components/ui/sonamu-filter/constants.js.map +1 -1
- package/dist/components/ui/sonamu-filter/rule-row-input.js +18 -15
- package/dist/components/ui/sonamu-filter/rule-row-input.js.map +1 -1
- package/dist/components/ui/sonamu-filter/sonamu-filter-modal.js +34 -37
- package/dist/components/ui/sonamu-filter/sonamu-filter-modal.js.map +1 -1
- package/dist/components/ui/sonamu-filter/sonamu-filter-popover.js +17 -12
- package/dist/components/ui/sonamu-filter/sonamu-filter-popover.js.map +1 -1
- package/dist/components/ui/sonamu-filter/types.d.ts +14 -9
- package/dist/components/ui/sonamu-filter/utils.d.ts +9 -7
- package/dist/components/ui/sonamu-filter/utils.js +39 -20
- package/dist/components/ui/sonamu-filter/utils.js.map +1 -1
- package/dist/components/ui/sonamu-filter/value-input.js +65 -50
- package/dist/components/ui/sonamu-filter/value-input.js.map +1 -1
- package/dist/contexts/sonamu-context.js +34 -10
- package/dist/contexts/sonamu-context.js.map +1 -1
- package/dist/demo/components/FormDebugPanel.d.ts +1 -1
- package/dist/hooks/use-toast.d.ts +1 -1
- package/dist/hooks/use-toast.js.map +1 -1
- package/dist/lib/base-helpers.d.ts +1 -1
- package/dist/lib/base-helpers.js +10 -10
- package/dist/lib/base-helpers.js.map +1 -1
- package/dist/lib/caster.d.ts +3 -2
- package/dist/lib/caster.js +37 -19
- package/dist/lib/caster.js.map +1 -1
- package/dist/lib/form-helpers.js +38 -35
- package/dist/lib/form-helpers.js.map +1 -1
- package/dist/lib/list-helpers.d.ts +2 -2
- package/dist/lib/list-helpers.js +33 -36
- package/dist/lib/list-helpers.js.map +1 -1
- package/dist/lib/use-mobile.js +5 -7
- package/dist/lib/use-mobile.js.map +1 -1
- package/dist/lib/utils.d.ts +0 -14
- package/dist/lib/utils.js +24 -14
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles/globals.css +38 -106
- package/package.json +2 -2
|
@@ -7,10 +7,16 @@ import "react";
|
|
|
7
7
|
import { jsx as i } from "react/jsx-runtime";
|
|
8
8
|
import { DayPicker as a } from "react-day-picker";
|
|
9
9
|
//#region src/components/ui/calendar.tsx
|
|
10
|
-
function o(
|
|
10
|
+
function o() {
|
|
11
|
+
return /* @__PURE__ */ i(r, { className: "h-4 w-4" });
|
|
12
|
+
}
|
|
13
|
+
function s() {
|
|
14
|
+
return /* @__PURE__ */ i(n, { className: "h-4 w-4" });
|
|
15
|
+
}
|
|
16
|
+
function c({ className: n, classNames: r, showOutsideDays: c = !0, ...l }) {
|
|
11
17
|
return /* @__PURE__ */ i(a, {
|
|
12
18
|
showOutsideDays: c,
|
|
13
|
-
className: e("p-3",
|
|
19
|
+
className: e("p-3", n),
|
|
14
20
|
classNames: {
|
|
15
21
|
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
|
16
22
|
month: "space-y-4",
|
|
@@ -34,16 +40,16 @@ function o({ className: o, classNames: s, showOutsideDays: c = !0, ...l }) {
|
|
|
34
40
|
day_disabled: "text-muted-foreground opacity-50",
|
|
35
41
|
day_range_middle: "aria-selected:bg-transparent aria-selected:text-foreground",
|
|
36
42
|
day_hidden: "invisible",
|
|
37
|
-
...
|
|
43
|
+
...r
|
|
38
44
|
},
|
|
39
45
|
components: {
|
|
40
|
-
IconLeft:
|
|
41
|
-
IconRight:
|
|
46
|
+
IconLeft: o,
|
|
47
|
+
IconRight: s
|
|
42
48
|
},
|
|
43
49
|
...l
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
//#endregion
|
|
47
|
-
export {
|
|
53
|
+
export { c as Calendar };
|
|
48
54
|
|
|
49
55
|
//# sourceMappingURL=calendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","names":[],"sources":["../../../src/components/ui/calendar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { DayPicker } from \"react-day-picker\";\nimport { type DateRange } from \"react-day-picker\";\nimport ChevronLeftIcon from \"~icons/lucide/chevron-left\";\nimport ChevronRightIcon from \"~icons/lucide/chevron-right\";\n\nimport { cn } from \"../../lib/utils\";\nimport { buttonVariants } from \"./button\";\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n ...props\n}: React.ComponentProps<typeof DayPicker>) {\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn(\"p-3\", className)}\n classNames={{\n months: \"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0\",\n month: \"space-y-4\",\n caption: \"flex justify-center pt-1 relative items-center w-full\",\n caption_label: \"text-sm font-medium\",\n nav: \"space-x-1 flex items-center\",\n nav_button: cn(\n buttonVariants({ variant: \"outline\" }),\n \"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100\",\n ),\n nav_button_previous: \"absolute left-1\",\n nav_button_next: \"absolute right-1\",\n table: \"w-full border-collapse space-y-1\",\n head_row: \"flex\",\n head_cell: \"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]\",\n row: \"flex w-full mt-2\",\n cell: cn(\n \"h-9 w-9 text-center text-sm p-0 relative focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent/10\",\n props.mode === \"range\"\n ? \"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md\"\n : \"[&:has([aria-selected])]:rounded-md\",\n ),\n day: cn(\n buttonVariants({ variant: \"ghost\" }),\n \"h-9 w-9 p-0 font-normal aria-selected:opacity-100\",\n ),\n day_range_start: \"day-range-start\",\n day_range_end: \"day-range-end\",\n day_selected:\n \"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground\",\n day_today: \"bg-accent/10 text-foreground\",\n day_outside:\n \"day-outside text-muted-foreground opacity-50 aria-selected:bg-transparent aria-selected:opacity-100 aria-selected:text-foreground\",\n day_disabled: \"text-muted-foreground opacity-50\",\n day_range_middle: \"aria-selected:bg-transparent aria-selected:text-foreground\",\n day_hidden: \"invisible\",\n ...classNames,\n }}\n components={{\n IconLeft:
|
|
1
|
+
{"version":3,"file":"calendar.js","names":[],"sources":["../../../src/components/ui/calendar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { DayPicker } from \"react-day-picker\";\nimport { type DateRange } from \"react-day-picker\";\nimport ChevronLeftIcon from \"~icons/lucide/chevron-left\";\nimport ChevronRightIcon from \"~icons/lucide/chevron-right\";\n\nimport { cn } from \"../../lib/utils\";\n\nfunction CalendarPreviousIcon() {\n return <ChevronLeftIcon className=\"h-4 w-4\" />;\n}\n\nfunction CalendarNextIcon() {\n return <ChevronRightIcon className=\"h-4 w-4\" />;\n}\nimport { buttonVariants } from \"./button\";\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n ...props\n}: React.ComponentProps<typeof DayPicker>) {\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn(\"p-3\", className)}\n classNames={{\n months: \"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0\",\n month: \"space-y-4\",\n caption: \"flex justify-center pt-1 relative items-center w-full\",\n caption_label: \"text-sm font-medium\",\n nav: \"space-x-1 flex items-center\",\n nav_button: cn(\n buttonVariants({ variant: \"outline\" }),\n \"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100\",\n ),\n nav_button_previous: \"absolute left-1\",\n nav_button_next: \"absolute right-1\",\n table: \"w-full border-collapse space-y-1\",\n head_row: \"flex\",\n head_cell: \"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]\",\n row: \"flex w-full mt-2\",\n cell: cn(\n \"h-9 w-9 text-center text-sm p-0 relative focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent/10\",\n props.mode === \"range\"\n ? \"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md\"\n : \"[&:has([aria-selected])]:rounded-md\",\n ),\n day: cn(\n buttonVariants({ variant: \"ghost\" }),\n \"h-9 w-9 p-0 font-normal aria-selected:opacity-100\",\n ),\n day_range_start: \"day-range-start\",\n day_range_end: \"day-range-end\",\n day_selected:\n \"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground\",\n day_today: \"bg-accent/10 text-foreground\",\n day_outside:\n \"day-outside text-muted-foreground opacity-50 aria-selected:bg-transparent aria-selected:opacity-100 aria-selected:text-foreground\",\n day_disabled: \"text-muted-foreground opacity-50\",\n day_range_middle: \"aria-selected:bg-transparent aria-selected:text-foreground\",\n day_hidden: \"invisible\",\n ...classNames,\n }}\n components={{\n IconLeft: CalendarPreviousIcon,\n IconRight: CalendarNextIcon,\n }}\n {...props}\n />\n );\n}\n\nexport { Calendar };\nexport type { DateRange };\n"],"mappings":";;;;;;;;;AAUA,SAAS,IAAuB;CAC9B,OAAO,kBAAC,GAAD,EAAiB,WAAU,UAAW,CAAA;AAC/C;AAEA,SAAS,IAAmB;CAC1B,OAAO,kBAAC,GAAD,EAAkB,WAAU,UAAW,CAAA;AAChD;AAGA,SAAS,EAAS,EAChB,cACA,eACA,qBAAkB,IAClB,GAAG,KACsC;CACzC,OACE,kBAAC,GAAD;EACmB;EACjB,WAAW,EAAG,OAAO,CAAS;EAC9B,YAAY;GACV,QAAQ;GACR,OAAO;GACP,SAAS;GACT,eAAe;GACf,KAAK;GACL,YAAY,EACV,EAAe,EAAE,SAAS,UAAU,CAAC,GACrC,yDACF;GACA,qBAAqB;GACrB,iBAAiB;GACjB,OAAO;GACP,UAAU;GACV,WAAW;GACX,KAAK;GACL,MAAM,EACJ,0HACA,EAAM,SAAS,UACX,yKACA,qCACN;GACA,KAAK,EACH,EAAe,EAAE,SAAS,QAAQ,CAAC,GACnC,mDACF;GACA,iBAAiB;GACjB,eAAe;GACf,cACE;GACF,WAAW;GACX,aACE;GACF,cAAc;GACd,kBAAkB;GAClB,YAAY;GACZ,GAAG;EACL;EACA,YAAY;GACV,UAAU;GACV,WAAW;EACb;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -17,35 +17,31 @@ var u = i.forwardRef(({ orientation: t = "horizontal", opts: n, setApi: r, plugi
|
|
|
17
17
|
let [p, m] = s({
|
|
18
18
|
...n,
|
|
19
19
|
axis: t === "horizontal" ? "x" : "y"
|
|
20
|
-
}, o),
|
|
21
|
-
e
|
|
22
|
-
}, []),
|
|
20
|
+
}, o), h = i.useCallback((e) => m ? (m.on("reInit", e), m.on("select", e), () => {
|
|
21
|
+
m.off("reInit", e), m.off("select", e);
|
|
22
|
+
}) : () => void 0, [m]), g = i.useSyncExternalStore(h, () => m?.canScrollPrev() ?? !1, () => !1), _ = i.useSyncExternalStore(h, () => m?.canScrollNext() ?? !1, () => !1), v = i.useCallback(() => {
|
|
23
23
|
m?.scrollPrev();
|
|
24
|
-
}, [m]),
|
|
24
|
+
}, [m]), y = i.useCallback(() => {
|
|
25
25
|
m?.scrollNext();
|
|
26
|
-
}, [m]),
|
|
27
|
-
e.key === "ArrowLeft" ? (e.preventDefault(),
|
|
28
|
-
}, [
|
|
26
|
+
}, [m]), b = i.useCallback((e) => {
|
|
27
|
+
e.key === "ArrowLeft" ? (e.preventDefault(), v()) : e.key === "ArrowRight" && (e.preventDefault(), y());
|
|
28
|
+
}, [v, y]);
|
|
29
29
|
return i.useEffect(() => {
|
|
30
30
|
!m || !r || r(m);
|
|
31
|
-
}, [m, r]),
|
|
32
|
-
if (m) return y(m), m.on("reInit", y), m.on("select", y), () => {
|
|
33
|
-
m?.off("reInit", y), m?.off("select", y);
|
|
34
|
-
};
|
|
35
|
-
}, [m, y]), /* @__PURE__ */ a(c.Provider, {
|
|
31
|
+
}, [m, r]), /* @__PURE__ */ a(c.Provider, {
|
|
36
32
|
value: {
|
|
37
33
|
carouselRef: p,
|
|
38
34
|
api: m,
|
|
39
35
|
opts: n,
|
|
40
36
|
orientation: t || (n?.axis === "y" ? "vertical" : "horizontal"),
|
|
41
|
-
scrollPrev:
|
|
42
|
-
scrollNext:
|
|
43
|
-
canScrollPrev:
|
|
37
|
+
scrollPrev: v,
|
|
38
|
+
scrollNext: y,
|
|
39
|
+
canScrollPrev: g,
|
|
44
40
|
canScrollNext: _
|
|
45
41
|
},
|
|
46
42
|
children: /* @__PURE__ */ a("div", {
|
|
47
43
|
ref: f,
|
|
48
|
-
onKeyDownCapture:
|
|
44
|
+
onKeyDownCapture: b,
|
|
49
45
|
className: e("relative", l),
|
|
50
46
|
role: "region",
|
|
51
47
|
"aria-roledescription": "carousel",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","names":[],"sources":["../../../src/components/ui/carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport useEmblaCarousel from \"embla-carousel-react\";\nimport { type UseEmblaCarouselType } from \"embla-carousel-react\";\nimport * as React from \"react\";\nimport ArrowLeftIcon from \"~icons/lucide/arrow-left\";\nimport ArrowRightIcon from \"~icons/lucide/arrow-right\";\n\nimport { cn } from \"../../lib/utils\";\nimport { Button } from \"./button\";\n\ntype CarouselApi = UseEmblaCarouselType[1];\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>;\ntype CarouselOptions = UseCarouselParameters[0];\ntype CarouselPlugin = UseCarouselParameters[1];\n\ntype CarouselProps = {\n opts?: CarouselOptions;\n plugins?: CarouselPlugin;\n orientation?: \"horizontal\" | \"vertical\";\n setApi?: (api: CarouselApi) => void;\n};\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0];\n api: ReturnType<typeof useEmblaCarousel>[1];\n scrollPrev: () => void;\n scrollNext: () => void;\n canScrollPrev: boolean;\n canScrollNext: boolean;\n} & CarouselProps;\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null);\n\nfunction useCarousel() {\n const context = React.useContext(CarouselContext);\n\n if (!context) {\n throw new Error(\"useCarousel must be used within a <Carousel />\");\n }\n\n return context;\n}\n\nconst Carousel = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & CarouselProps\n>(({ orientation = \"horizontal\", opts, setApi, plugins, className, children, ...props }, ref) => {\n const [carouselRef, api] = useEmblaCarousel(\n {\n ...opts,\n axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n },\n plugins,\n );\n const
|
|
1
|
+
{"version":3,"file":"carousel.js","names":[],"sources":["../../../src/components/ui/carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport useEmblaCarousel from \"embla-carousel-react\";\nimport { type UseEmblaCarouselType } from \"embla-carousel-react\";\nimport * as React from \"react\";\nimport ArrowLeftIcon from \"~icons/lucide/arrow-left\";\nimport ArrowRightIcon from \"~icons/lucide/arrow-right\";\n\nimport { cn } from \"../../lib/utils\";\nimport { Button } from \"./button\";\n\ntype CarouselApi = UseEmblaCarouselType[1];\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>;\ntype CarouselOptions = UseCarouselParameters[0];\ntype CarouselPlugin = UseCarouselParameters[1];\n\ntype CarouselProps = {\n opts?: CarouselOptions;\n plugins?: CarouselPlugin;\n orientation?: \"horizontal\" | \"vertical\";\n setApi?: (api: CarouselApi) => void;\n};\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0];\n api: ReturnType<typeof useEmblaCarousel>[1];\n scrollPrev: () => void;\n scrollNext: () => void;\n canScrollPrev: boolean;\n canScrollNext: boolean;\n} & CarouselProps;\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null);\n\nfunction useCarousel() {\n const context = React.useContext(CarouselContext);\n\n if (!context) {\n throw new Error(\"useCarousel must be used within a <Carousel />\");\n }\n\n return context;\n}\n\nconst Carousel = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & CarouselProps\n>(({ orientation = \"horizontal\", opts, setApi, plugins, className, children, ...props }, ref) => {\n const [carouselRef, api] = useEmblaCarousel(\n {\n ...opts,\n axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n },\n plugins,\n );\n const subscribe = React.useCallback(\n (onStoreChange: () => void) => {\n if (!api) return () => undefined;\n\n api.on(\"reInit\", onStoreChange);\n api.on(\"select\", onStoreChange);\n return () => {\n api.off(\"reInit\", onStoreChange);\n api.off(\"select\", onStoreChange);\n };\n },\n [api],\n );\n const canScrollPrev = React.useSyncExternalStore(\n subscribe,\n () => api?.canScrollPrev() ?? false,\n () => false,\n );\n const canScrollNext = React.useSyncExternalStore(\n subscribe,\n () => api?.canScrollNext() ?? false,\n () => false,\n );\n\n const scrollPrev = React.useCallback(() => {\n api?.scrollPrev();\n }, [api]);\n\n const scrollNext = React.useCallback(() => {\n api?.scrollNext();\n }, [api]);\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n scrollPrev();\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n scrollNext();\n }\n },\n [scrollPrev, scrollNext],\n );\n\n React.useEffect(() => {\n if (!api || !setApi) {\n return;\n }\n\n setApi(api);\n }, [api, setApi]);\n\n return (\n <CarouselContext.Provider\n value={{\n carouselRef,\n api: api,\n opts,\n orientation: orientation || (opts?.axis === \"y\" ? \"vertical\" : \"horizontal\"),\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n }}\n >\n <div\n ref={ref}\n onKeyDownCapture={handleKeyDown}\n className={cn(\"relative\", className)}\n role=\"region\"\n aria-roledescription=\"carousel\"\n {...props}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n );\n});\nCarousel.displayName = \"Carousel\";\n\nconst CarouselContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const { carouselRef, orientation } = useCarousel();\n\n return (\n <div ref={carouselRef} className=\"overflow-hidden\">\n <div\n ref={ref}\n className={cn(\n \"flex\",\n orientation === \"horizontal\" ? \"-ml-4\" : \"-mt-4 flex-col\",\n className,\n )}\n {...props}\n />\n </div>\n );\n },\n);\nCarouselContent.displayName = \"CarouselContent\";\n\nconst CarouselItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const { orientation } = useCarousel();\n\n return (\n <div\n ref={ref}\n role=\"group\"\n aria-roledescription=\"slide\"\n className={cn(\n \"min-w-0 shrink-0 grow-0 basis-full\",\n orientation === \"horizontal\" ? \"pl-4\" : \"pt-4\",\n className,\n )}\n {...props}\n />\n );\n },\n);\nCarouselItem.displayName = \"CarouselItem\";\n\nconst CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(\n ({ className, variant = \"outline\", size = \"default\", ...props }, ref) => {\n const { orientation, scrollPrev, canScrollPrev } = useCarousel();\n\n return (\n <Button\n ref={ref}\n variant={variant}\n size={size}\n className={cn(\n \"absolute h-8 w-8 rounded-full\",\n orientation === \"horizontal\"\n ? \"-left-12 top-1/2 -translate-y-1/2\"\n : \"-top-12 left-1/2 -translate-x-1/2 rotate-90\",\n className,\n )}\n disabled={!canScrollPrev}\n onClick={scrollPrev}\n {...props}\n >\n <ArrowLeftIcon className=\"h-4 w-4\" />\n <span className=\"sr-only\">Previous slide</span>\n </Button>\n );\n },\n);\nCarouselPrevious.displayName = \"CarouselPrevious\";\n\nconst CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(\n ({ className, variant = \"outline\", size = \"default\", ...props }, ref) => {\n const { orientation, scrollNext, canScrollNext } = useCarousel();\n\n return (\n <Button\n ref={ref}\n variant={variant}\n size={size}\n className={cn(\n \"absolute h-8 w-8 rounded-full\",\n orientation === \"horizontal\"\n ? \"-right-12 top-1/2 -translate-y-1/2\"\n : \"-bottom-12 left-1/2 -translate-x-1/2 rotate-90\",\n className,\n )}\n disabled={!canScrollNext}\n onClick={scrollNext}\n {...props}\n >\n <ArrowRightIcon className=\"h-4 w-4\" />\n <span className=\"sr-only\">Next slide</span>\n </Button>\n );\n },\n);\nCarouselNext.displayName = \"CarouselNext\";\n\nexport {\n type CarouselApi,\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselPrevious,\n CarouselNext,\n};\n"],"mappings":";;;;;;;;;AAgCA,IAAM,IAAkB,EAAM,cAA2C,IAAI;AAE7E,SAAS,IAAc;CACrB,IAAM,IAAU,EAAM,WAAW,CAAe;CAEhD,IAAI,CAAC,GACH,MAAU,MAAM,gDAAgD;CAGlE,OAAO;AACT;AAEA,IAAM,IAAW,EAAM,YAGpB,EAAE,iBAAc,cAAc,SAAM,WAAQ,YAAS,cAAW,aAAU,GAAG,KAAS,MAAQ;CAC/F,IAAM,CAAC,GAAa,KAAO,EACzB;EACE,GAAG;EACH,MAAM,MAAgB,eAAe,MAAM;CAC7C,GACA,CACF,GACM,IAAY,EAAM,aACrB,MACM,KAEL,EAAI,GAAG,UAAU,CAAa,GAC9B,EAAI,GAAG,UAAU,CAAa,SACjB;EAEX,AADA,EAAI,IAAI,UAAU,CAAa,GAC/B,EAAI,IAAI,UAAU,CAAa;CACjC,WAPuB,KAAA,GASzB,CAAC,CAAG,CACN,GACM,IAAgB,EAAM,qBAC1B,SACM,GAAK,cAAc,KAAK,UACxB,EACR,GACM,IAAgB,EAAM,qBAC1B,SACM,GAAK,cAAc,KAAK,UACxB,EACR,GAEM,IAAa,EAAM,kBAAkB;EACzC,GAAK,WAAW;CAClB,GAAG,CAAC,CAAG,CAAC,GAEF,IAAa,EAAM,kBAAkB;EACzC,GAAK,WAAW;CAClB,GAAG,CAAC,CAAG,CAAC,GAEF,IAAgB,EAAM,aACzB,MAA+C;EAC9C,AAAI,EAAM,QAAQ,eAChB,EAAM,eAAe,GACrB,EAAW,KACF,EAAM,QAAQ,iBACvB,EAAM,eAAe,GACrB,EAAW;CAEf,GACA,CAAC,GAAY,CAAU,CACzB;CAUA,OARA,EAAM,gBAAgB;EAChB,CAAC,KAAO,CAAC,KAIb,EAAO,CAAG;CACZ,GAAG,CAAC,GAAK,CAAM,CAAC,GAGd,kBAAC,EAAgB,UAAjB;EACE,OAAO;GACL;GACK;GACL;GACA,aAAa,MAAgB,GAAM,SAAS,MAAM,aAAa;GAC/D;GACA;GACA;GACA;EACF;YAEA,kBAAC,OAAD;GACO;GACL,kBAAkB;GAClB,WAAW,EAAG,YAAY,CAAS;GACnC,MAAK;GACL,wBAAqB;GACrB,GAAI;GAEH;EACE,CAAA;CACmB,CAAA;AAE9B,CAAC;AACD,EAAS,cAAc;AAEvB,IAAM,IAAkB,EAAM,YAC3B,EAAE,cAAW,GAAG,KAAS,MAAQ;CAChC,IAAM,EAAE,gBAAa,mBAAgB,EAAY;CAEjD,OACE,kBAAC,OAAD;EAAK,KAAK;EAAa,WAAU;YAC/B,kBAAC,OAAD;GACO;GACL,WAAW,EACT,QACA,MAAgB,eAAe,UAAU,kBACzC,CACF;GACA,GAAI;EACL,CAAA;CACE,CAAA;AAET,CACF;AACA,EAAgB,cAAc;AAE9B,IAAM,IAAe,EAAM,YACxB,EAAE,cAAW,GAAG,KAAS,MAAQ;CAChC,IAAM,EAAE,mBAAgB,EAAY;CAEpC,OACE,kBAAC,OAAD;EACO;EACL,MAAK;EACL,wBAAqB;EACrB,WAAW,EACT,sCACA,MAAgB,eAAe,SAAS,QACxC,CACF;EACA,GAAI;CACL,CAAA;AAEL,CACF;AACA,EAAa,cAAc;AAE3B,IAAM,IAAmB,EAAM,YAC5B,EAAE,cAAW,aAAU,WAAW,UAAO,WAAW,GAAG,KAAS,MAAQ;CACvE,IAAM,EAAE,gBAAa,eAAY,qBAAkB,EAAY;CAE/D,OACE,kBAAC,GAAD;EACO;EACI;EACH;EACN,WAAW,EACT,kCACA,MAAgB,eACZ,sCACA,+CACJ,CACF;EACA,UAAU,CAAC;EACX,SAAS;EACT,GAAI;YAbN,CAeE,kBAAC,GAAD,EAAe,WAAU,UAAW,CAAA,GACpC,kBAAC,QAAD;GAAM,WAAU;aAAU;EAAoB,CAAA,CACxC;;AAEZ,CACF;AACA,EAAiB,cAAc;AAE/B,IAAM,IAAe,EAAM,YACxB,EAAE,cAAW,aAAU,WAAW,UAAO,WAAW,GAAG,KAAS,MAAQ;CACvE,IAAM,EAAE,gBAAa,eAAY,qBAAkB,EAAY;CAE/D,OACE,kBAAC,GAAD;EACO;EACI;EACH;EACN,WAAW,EACT,iCACA,MAAgB,eACZ,uCACA,kDACJ,CACF;EACA,UAAU,CAAC;EACX,SAAS;EACT,GAAI;YAbN,CAeE,kBAAC,GAAD,EAAgB,WAAU,UAAW,CAAA,GACrC,kBAAC,QAAD;GAAM,WAAU;aAAU;EAAgB,CAAA,CACpC;;AAEZ,CACF;AACA,EAAa,cAAc"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
|
-
type ExtendedModalProps = {
|
|
2
|
+
type ExtendedModalProps<CompletionData = unknown> = {
|
|
3
3
|
title?: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
className?: string;
|
|
6
|
-
onCompleted?: (data?:
|
|
6
|
+
onCompleted?: (data?: CompletionData) => void;
|
|
7
7
|
onControlledOpen?: () => void;
|
|
8
8
|
onControlledClose?: () => void;
|
|
9
9
|
};
|
|
10
10
|
export declare const commonModalAtom: import('jotai').PrimitiveAtom<{
|
|
11
11
|
open: boolean;
|
|
12
12
|
reactNode: React.ReactNode | null;
|
|
13
|
-
} & ExtendedModalProps
|
|
13
|
+
} & ExtendedModalProps<unknown>> & {
|
|
14
14
|
init: {
|
|
15
15
|
open: boolean;
|
|
16
16
|
reactNode: React.ReactNode | null;
|
|
17
|
-
} & ExtendedModalProps
|
|
17
|
+
} & ExtendedModalProps<unknown>;
|
|
18
18
|
};
|
|
19
19
|
type CommonModalProps = {
|
|
20
20
|
className?: string;
|
|
@@ -23,8 +23,8 @@ export declare function CommonModal({ className }: CommonModalProps): import("re
|
|
|
23
23
|
export declare function useCommonModal(): {
|
|
24
24
|
open: boolean;
|
|
25
25
|
reactNode: React.ReactNode;
|
|
26
|
-
openModal: (
|
|
26
|
+
openModal: (content: React.ReactNode, props?: ExtendedModalProps) => void;
|
|
27
27
|
closeModal: () => void;
|
|
28
|
-
doneModal: (data?:
|
|
28
|
+
doneModal: <CompletionData>(data?: CompletionData) => void;
|
|
29
29
|
};
|
|
30
30
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-modal.js","names":[],"sources":["../../../src/components/ui/common-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { atom, useAtom } from \"jotai\";\nimport type * as React from \"react\";\nimport { useEffect } from \"react\";\n\nimport { cn } from \"../../lib/utils\";\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from \"./dialog\";\n\ntype ExtendedModalProps = {\n title?: string;\n description?: string;\n className?: string;\n onCompleted?: (data?:
|
|
1
|
+
{"version":3,"file":"common-modal.js","names":[],"sources":["../../../src/components/ui/common-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { atom, useAtom } from \"jotai\";\nimport type * as React from \"react\";\nimport { useEffect } from \"react\";\n\nimport { cn } from \"../../lib/utils\";\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from \"./dialog\";\n\ntype ExtendedModalProps<CompletionData = unknown> = {\n title?: string;\n description?: string;\n className?: string;\n onCompleted?: (data?: CompletionData) => void;\n onControlledOpen?: () => void;\n onControlledClose?: () => void;\n};\n\nexport const commonModalAtom = atom<\n {\n open: boolean;\n reactNode: React.ReactNode | null;\n } & ExtendedModalProps\n>({\n open: false,\n reactNode: null,\n});\n\ntype CommonModalProps = {\n className?: string;\n};\n\nexport function CommonModal({ className }: CommonModalProps) {\n const [atomValue, setAtomValue] = useAtom(commonModalAtom);\n const {\n open,\n reactNode,\n title,\n description,\n className: modalClassName,\n onControlledOpen,\n onControlledClose,\n } = atomValue;\n\n const closeAndClear = () => {\n if (onControlledClose) {\n onControlledClose();\n }\n setAtomValue({\n open: false,\n reactNode: null,\n });\n };\n\n useEffect(() => {\n if (open && onControlledOpen) {\n onControlledOpen();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return (\n <Dialog\n open={open}\n onOpenChange={(isOpen) => {\n if (!isOpen) {\n closeAndClear();\n }\n }}\n >\n <DialogContent className={cn(\"max-w-4xl\", modalClassName, className)}>\n <DialogHeader>\n <DialogTitle className={!title ? \"sr-only\" : undefined}>{title || \"Modal\"}</DialogTitle>\n <DialogDescription className={!description ? \"sr-only\" : undefined}>\n {description || \"Modal content\"}\n </DialogDescription>\n </DialogHeader>\n {reactNode}\n </DialogContent>\n </Dialog>\n );\n}\n\nexport function useCommonModal() {\n const [atomValue, setAtomValue] = useAtom(commonModalAtom);\n const { open, reactNode, onCompleted } = atomValue;\n\n const openModal = (content: React.ReactNode, props?: ExtendedModalProps) => {\n setAtomValue({\n open: true,\n reactNode: content,\n ...props,\n });\n };\n\n const closeModal = () => {\n setAtomValue({\n open: false,\n reactNode: null,\n });\n };\n\n const doneModal = <CompletionData,>(data?: CompletionData) => {\n closeModal();\n if (onCompleted) {\n onCompleted(data);\n }\n };\n\n return {\n open,\n reactNode,\n openModal,\n closeModal,\n doneModal,\n };\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,IAAkB,EAK7B;CACA,MAAM;CACN,WAAW;AACb,CAAC;AAMD,SAAgB,EAAY,EAAE,gBAA+B;CAC3D,IAAM,CAAC,GAAW,KAAgB,EAAQ,CAAe,GACnD,EACJ,SACA,cACA,UACA,gBACA,WAAW,GACX,qBACA,yBACE,GAEE,UAAsB;EAI1B,AAHI,KACF,EAAkB,GAEpB,EAAa;GACX,MAAM;GACN,WAAW;EACb,CAAC;CACH;CASA,OAPA,QAAgB;EACd,AAAI,KAAQ,KACV,EAAiB;CAGrB,GAAG,CAAC,CAAI,CAAC,GAGP,kBAAC,GAAD;EACQ;EACN,eAAe,MAAW;GACxB,AAAK,KACH,EAAc;EAElB;YAEA,kBAAC,GAAD;GAAe,WAAW,EAAG,aAAa,GAAgB,CAAS;aAAnE,CACE,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;IAAa,WAAY,IAAoB,KAAA,IAAZ;cAAwB,KAAS;GAAqB,CAAA,GACvF,kBAAC,GAAD;IAAmB,WAAY,IAA0B,KAAA,IAAZ;cAC1C,KAAe;GACC,CAAA,CACP,EAAA,CAAA,GACb,CACY;;CACT,CAAA;AAEZ;AAEA,SAAgB,IAAiB;CAC/B,IAAM,CAAC,GAAW,KAAgB,EAAQ,CAAe,GACnD,EAAE,SAAM,cAAW,mBAAgB,GAEnC,KAAa,GAA0B,MAA+B;EAC1E,EAAa;GACX,MAAM;GACN,WAAW;GACX,GAAG;EACL,CAAC;CACH,GAEM,UAAmB;EACvB,EAAa;GACX,MAAM;GACN,WAAW;EACb,CAAC;CACH;CASA,OAAO;EACL;EACA;EACA;EACA;EACA,YAZkC,MAA0B;GAE5D,AADA,EAAW,GACP,KACF,EAAY,CAAI;EAEpB;CAQA;AACF"}
|
|
@@ -5,257 +5,258 @@ import i from "../../_virtual/~icons/lucide/x.js";
|
|
|
5
5
|
import a from "../../_virtual/~icons/lucide/image.js";
|
|
6
6
|
import o from "../../_virtual/~icons/lucide/loader2.js";
|
|
7
7
|
import s from "../../_virtual/~icons/lucide/upload.js";
|
|
8
|
-
import { useCallback as c,
|
|
9
|
-
import { Fragment as
|
|
10
|
-
import {
|
|
8
|
+
import { useCallback as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
9
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
10
|
+
import { isFunction as h } from "radashi";
|
|
11
|
+
import { FileIcon as g, defaultStyles as _ } from "react-file-icon";
|
|
11
12
|
//#region src/components/ui/file-input.tsx
|
|
12
|
-
function
|
|
13
|
+
function v(e) {
|
|
14
|
+
return Object.prototype.toString.call(e) === "[object File]";
|
|
15
|
+
}
|
|
16
|
+
function y(e) {
|
|
13
17
|
let t = e.split(".");
|
|
14
18
|
return t.length < 2 ? "" : t[t.length - 1].toLowerCase();
|
|
15
19
|
}
|
|
16
|
-
var
|
|
20
|
+
var b = {
|
|
17
21
|
sm: 14,
|
|
18
22
|
md: 18,
|
|
19
23
|
lg: 22,
|
|
20
24
|
xl: 26
|
|
21
|
-
};
|
|
22
|
-
function
|
|
23
|
-
let n =
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
+
}, x = new Map(Object.entries(_));
|
|
26
|
+
function S({ filename: e, size: t = "md" }) {
|
|
27
|
+
let n = y(e), r = x.get(n) ?? {};
|
|
28
|
+
return /* @__PURE__ */ p("div", {
|
|
25
29
|
className: "shrink-0 self-center",
|
|
26
30
|
style: {
|
|
27
|
-
width:
|
|
31
|
+
width: b[t],
|
|
28
32
|
marginTop: -2
|
|
29
33
|
},
|
|
30
|
-
children: /* @__PURE__ */
|
|
34
|
+
children: /* @__PURE__ */ p(g, {
|
|
31
35
|
extension: n || void 0,
|
|
32
36
|
...r
|
|
33
37
|
})
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
|
-
var
|
|
40
|
+
var C = {
|
|
37
41
|
sm: "w-20 h-20",
|
|
38
42
|
md: "w-32 h-32",
|
|
39
43
|
lg: "w-40 h-40",
|
|
40
44
|
xl: "w-48 h-48"
|
|
41
|
-
},
|
|
45
|
+
}, w = {
|
|
42
46
|
sm: "w-48 h-12",
|
|
43
47
|
md: "w-80 h-16",
|
|
44
48
|
lg: "w-96 h-20",
|
|
45
49
|
xl: "w-[28rem] h-24"
|
|
46
50
|
};
|
|
47
|
-
function
|
|
48
|
-
let { placeholder:
|
|
49
|
-
if (!
|
|
50
|
-
let e =
|
|
51
|
+
function T(g) {
|
|
52
|
+
let { placeholder: _, disabled: y = !1, className: b, previewSize: x = "md", uploadMode: T, viewMode: E, uploadParams: D, onBlur: O } = g, { uploader: k, SD: A } = r(), j = g.multiple ?? !1, M = E === "image", N = g.accept ?? (M ? "image/*" : "*/*"), P = u(null), [F, I] = d(!1), [L, R] = d(!1), z = _ ?? `${A(M ? "rc.fileInput.imagePlaceholder" : "rc.fileInput.filePlaceholder")} URL${j ? "S" : ""}`, B = l(() => {
|
|
53
|
+
if (g.multiple !== !0) {
|
|
54
|
+
let e = g.value;
|
|
51
55
|
return e ? [e] : [];
|
|
52
56
|
}
|
|
53
|
-
return
|
|
54
|
-
})
|
|
55
|
-
url:
|
|
57
|
+
return g.value ?? [];
|
|
58
|
+
}, [g.multiple, g.value]), V = l(() => B.filter(v), [B]), H = t(V), U = B.map((e) => v(e) ? {
|
|
59
|
+
url: H[V.indexOf(e)],
|
|
56
60
|
name: e.name,
|
|
57
61
|
isPending: !0
|
|
58
62
|
} : {
|
|
59
63
|
url: e.url,
|
|
60
64
|
name: e.name,
|
|
61
65
|
isPending: !1
|
|
62
|
-
}),
|
|
63
|
-
if (e.length === 0 ||
|
|
64
|
-
let t =
|
|
66
|
+
}), W = g.multiple === !0 ? g.maxFiles ?? 10 : 1, G = B.length, K = G < W, q = c(async (e) => {
|
|
67
|
+
if (e.length === 0 || y) return;
|
|
68
|
+
let t = W - G;
|
|
65
69
|
if (t <= 0) {
|
|
66
|
-
|
|
70
|
+
let e = A("rc.fileInput.maxFilesExceeded");
|
|
71
|
+
alert(h(e) ? e(W) : e);
|
|
67
72
|
return;
|
|
68
73
|
}
|
|
69
74
|
let n = e.slice(0, t);
|
|
70
|
-
if (
|
|
71
|
-
|
|
75
|
+
if (T === "eager") {
|
|
76
|
+
I(!0);
|
|
72
77
|
try {
|
|
73
|
-
let e = await
|
|
74
|
-
if (
|
|
75
|
-
let t = [...
|
|
76
|
-
|
|
77
|
-
} else
|
|
78
|
+
let e = await k(n, D);
|
|
79
|
+
if (g.multiple === !0) {
|
|
80
|
+
let t = [...B, ...e];
|
|
81
|
+
g.onValueChange?.(t);
|
|
82
|
+
} else g.onValueChange?.(e[0] ?? null);
|
|
78
83
|
} catch (e) {
|
|
79
|
-
console.error("Upload failed:", e), alert(
|
|
84
|
+
console.error("Upload failed:", e), alert(A("rc.fileInput.uploadFailed"));
|
|
80
85
|
} finally {
|
|
81
|
-
|
|
86
|
+
I(!1);
|
|
82
87
|
}
|
|
83
|
-
} else if (
|
|
84
|
-
let e = [...
|
|
85
|
-
|
|
86
|
-
} else
|
|
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));
|
|
88
|
+
} else if (g.multiple === !0) {
|
|
89
|
+
let e = [...B, ...n];
|
|
90
|
+
g.onValueChange?.(e);
|
|
91
|
+
} else g.onValueChange?.(n[0] ?? null);
|
|
101
92
|
}, [
|
|
93
|
+
y,
|
|
94
|
+
G,
|
|
102
95
|
W,
|
|
96
|
+
T,
|
|
97
|
+
D,
|
|
98
|
+
B,
|
|
103
99
|
g,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
k,
|
|
101
|
+
A
|
|
102
|
+
]), J = c((e) => {
|
|
103
|
+
q(Array.from(e.target.files || [])), P.current && (P.current.value = "");
|
|
104
|
+
}, [q]), Y = c((e) => {
|
|
105
|
+
e.preventDefault(), R(!1), !(y || F) && q(Array.from(e.dataTransfer.files));
|
|
106
|
+
}, [
|
|
107
|
+
q,
|
|
108
|
+
y,
|
|
109
|
+
F
|
|
110
|
+
]), X = c((e) => (t) => {
|
|
111
|
+
if (t.stopPropagation(), g.multiple !== !0) g.onValueChange?.(null);
|
|
107
112
|
else {
|
|
108
|
-
let t =
|
|
109
|
-
|
|
113
|
+
let t = B.filter((t, n) => n !== e);
|
|
114
|
+
g.onValueChange?.(t);
|
|
110
115
|
}
|
|
111
|
-
}, [
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return /* @__PURE__ */ p("div", {
|
|
121
|
-
className: e("relative inline-block", _),
|
|
122
|
-
children: [/* @__PURE__ */ f("input", {
|
|
123
|
-
ref: j,
|
|
116
|
+
}, [B, g]), Z = () => {
|
|
117
|
+
!y && !F && P.current?.click();
|
|
118
|
+
}, Q = M ? C : w;
|
|
119
|
+
if (!j && U.length > 0) {
|
|
120
|
+
let t = U[0];
|
|
121
|
+
return /* @__PURE__ */ m("div", {
|
|
122
|
+
className: e("relative inline-block", b),
|
|
123
|
+
children: [/* @__PURE__ */ p("input", {
|
|
124
|
+
ref: P,
|
|
124
125
|
type: "file",
|
|
125
|
-
accept:
|
|
126
|
-
onChange:
|
|
127
|
-
onBlur:
|
|
128
|
-
disabled:
|
|
126
|
+
accept: N,
|
|
127
|
+
onChange: J,
|
|
128
|
+
onBlur: O,
|
|
129
|
+
disabled: y || F,
|
|
129
130
|
className: "sr-only"
|
|
130
|
-
}), /* @__PURE__ */
|
|
131
|
-
onClick:
|
|
132
|
-
onDrop:
|
|
131
|
+
}), /* @__PURE__ */ p("div", {
|
|
132
|
+
onClick: Z,
|
|
133
|
+
onDrop: Y,
|
|
133
134
|
onDragOver: (e) => {
|
|
134
|
-
e.preventDefault(), !
|
|
135
|
+
e.preventDefault(), !y && !F && R(!0);
|
|
135
136
|
},
|
|
136
137
|
onDragLeave: (e) => {
|
|
137
|
-
e.preventDefault(),
|
|
138
|
+
e.preventDefault(), R(!1);
|
|
138
139
|
},
|
|
139
|
-
className: e("relative flex items-center justify-center rounded-lg border-2 cursor-pointer transition-all",
|
|
140
|
-
children:
|
|
140
|
+
className: e("relative flex items-center justify-center rounded-lg border-2 cursor-pointer transition-all", Q[x], M ? "border-transparent" : "border-dashed border-muted-foreground/25 hover:border-muted-foreground/50", L && "border-primary bg-primary/5", y && "opacity-50 cursor-not-allowed", F && "cursor-wait"),
|
|
141
|
+
children: F ? /* @__PURE__ */ m("div", {
|
|
141
142
|
className: "flex flex-col items-center gap-2 text-muted-foreground",
|
|
142
|
-
children: [/* @__PURE__ */
|
|
143
|
+
children: [/* @__PURE__ */ p(o, { className: "h-6 w-6 animate-spin" }), /* @__PURE__ */ p("span", {
|
|
143
144
|
className: "text-xs",
|
|
144
|
-
children:
|
|
145
|
+
children: A("rc.fileInput.uploading")
|
|
145
146
|
})]
|
|
146
|
-
}) : /* @__PURE__ */
|
|
147
|
-
|
|
147
|
+
}) : /* @__PURE__ */ m(f, { children: [
|
|
148
|
+
M ? /* @__PURE__ */ p("img", {
|
|
148
149
|
src: t.url,
|
|
149
150
|
alt: "Preview",
|
|
150
151
|
className: "h-full w-full object-cover rounded-lg overflow-hidden"
|
|
151
|
-
}) : /* @__PURE__ */
|
|
152
|
+
}) : /* @__PURE__ */ m("div", {
|
|
152
153
|
className: "flex items-center gap-2 px-3 h-full w-full min-w-0 overflow-hidden",
|
|
153
154
|
children: [
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ p(S, {
|
|
155
156
|
filename: t.name,
|
|
156
157
|
size: x
|
|
157
158
|
}),
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
+
/* @__PURE__ */ p("span", {
|
|
159
160
|
className: e("text-xs truncate min-w-0", t.isPending ? "w-[140px] shrink-0" : "flex-1"),
|
|
160
161
|
children: t.name
|
|
161
162
|
}),
|
|
162
|
-
t.isPending && /* @__PURE__ */
|
|
163
|
+
t.isPending && /* @__PURE__ */ p("span", {
|
|
163
164
|
className: "px-2 py-0.5 bg-yellow-500/90 text-white text-xs rounded whitespace-nowrap shrink-0",
|
|
164
|
-
children:
|
|
165
|
+
children: A("rc.fileInput.pending")
|
|
165
166
|
})
|
|
166
167
|
]
|
|
167
168
|
}),
|
|
168
|
-
!
|
|
169
|
+
!y && /* @__PURE__ */ p(n, {
|
|
169
170
|
type: "button",
|
|
170
171
|
variant: "destructive",
|
|
171
172
|
size: "xs",
|
|
172
173
|
className: "absolute -top-2 -right-2 h-6 w-6 rounded-full p-0",
|
|
173
|
-
onClick:
|
|
174
|
-
icon: /* @__PURE__ */
|
|
174
|
+
onClick: X(0),
|
|
175
|
+
icon: /* @__PURE__ */ p(i, {})
|
|
175
176
|
}),
|
|
176
|
-
|
|
177
|
+
M && t.isPending && /* @__PURE__ */ p("div", {
|
|
177
178
|
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:
|
|
179
|
+
children: A("rc.fileInput.pending")
|
|
179
180
|
})
|
|
180
181
|
] })
|
|
181
182
|
})]
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
|
-
return /* @__PURE__ */
|
|
185
|
-
className: e("flex flex-wrap gap-3",
|
|
185
|
+
return /* @__PURE__ */ m("div", {
|
|
186
|
+
className: e("flex flex-wrap gap-3", b),
|
|
186
187
|
children: [
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
ref:
|
|
188
|
+
/* @__PURE__ */ p("input", {
|
|
189
|
+
ref: P,
|
|
189
190
|
type: "file",
|
|
190
|
-
accept:
|
|
191
|
-
multiple:
|
|
192
|
-
onChange:
|
|
193
|
-
onBlur:
|
|
194
|
-
disabled:
|
|
191
|
+
accept: N,
|
|
192
|
+
multiple: j,
|
|
193
|
+
onChange: J,
|
|
194
|
+
onBlur: O,
|
|
195
|
+
disabled: y || F,
|
|
195
196
|
className: "sr-only"
|
|
196
197
|
}),
|
|
197
|
-
|
|
198
|
-
className: e("relative",
|
|
198
|
+
U.map((t, r) => /* @__PURE__ */ m("div", {
|
|
199
|
+
className: e("relative", Q[x]),
|
|
199
200
|
children: [
|
|
200
|
-
|
|
201
|
+
M ? /* @__PURE__ */ p("div", {
|
|
201
202
|
className: "h-full w-full rounded-lg border overflow-hidden",
|
|
202
|
-
children: /* @__PURE__ */
|
|
203
|
+
children: /* @__PURE__ */ p("img", {
|
|
203
204
|
src: t.url,
|
|
204
205
|
alt: `Uploaded ${r + 1}`,
|
|
205
206
|
className: "h-full w-full object-cover"
|
|
206
207
|
})
|
|
207
|
-
}) : /* @__PURE__ */
|
|
208
|
+
}) : /* @__PURE__ */ m("div", {
|
|
208
209
|
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
210
|
children: [
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
+
/* @__PURE__ */ p(S, {
|
|
211
212
|
filename: t.name,
|
|
212
213
|
size: x
|
|
213
214
|
}),
|
|
214
|
-
/* @__PURE__ */
|
|
215
|
+
/* @__PURE__ */ p("span", {
|
|
215
216
|
className: e("text-xs truncate min-w-0", t.isPending ? "w-[140px] shrink-0" : "flex-1"),
|
|
216
217
|
children: t.name
|
|
217
218
|
}),
|
|
218
|
-
t.isPending && /* @__PURE__ */
|
|
219
|
+
t.isPending && /* @__PURE__ */ p("span", {
|
|
219
220
|
className: "px-2 py-0.5 bg-yellow-500/90 text-white text-xs rounded whitespace-nowrap shrink-0",
|
|
220
|
-
children:
|
|
221
|
+
children: A("rc.fileInput.pending")
|
|
221
222
|
})
|
|
222
223
|
]
|
|
223
224
|
}),
|
|
224
|
-
!
|
|
225
|
+
!y && /* @__PURE__ */ p(n, {
|
|
225
226
|
type: "button",
|
|
226
227
|
variant: "destructive",
|
|
227
228
|
size: "xs",
|
|
228
229
|
className: "absolute -top-2 -right-2 h-6 w-6 rounded-full p-0",
|
|
229
|
-
onClick:
|
|
230
|
-
icon: /* @__PURE__ */
|
|
230
|
+
onClick: X(r),
|
|
231
|
+
icon: /* @__PURE__ */ p(i, {})
|
|
231
232
|
}),
|
|
232
|
-
|
|
233
|
+
M && t.isPending && /* @__PURE__ */ p("div", {
|
|
233
234
|
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:
|
|
235
|
+
children: A("rc.fileInput.pending")
|
|
235
236
|
})
|
|
236
237
|
]
|
|
237
238
|
}, `${t.url}-${r}`)),
|
|
238
|
-
|
|
239
|
-
onClick:
|
|
240
|
-
onDrop:
|
|
239
|
+
K && /* @__PURE__ */ p("div", {
|
|
240
|
+
onClick: Z,
|
|
241
|
+
onDrop: Y,
|
|
241
242
|
onDragOver: (e) => {
|
|
242
|
-
e.preventDefault(), !
|
|
243
|
+
e.preventDefault(), !y && !F && R(!0);
|
|
243
244
|
},
|
|
244
245
|
onDragLeave: (e) => {
|
|
245
|
-
e.preventDefault(),
|
|
246
|
+
e.preventDefault(), R(!1);
|
|
246
247
|
},
|
|
247
|
-
className: e("flex items-center justify-center rounded-lg border-2 border-dashed cursor-pointer transition-all",
|
|
248
|
-
children:
|
|
248
|
+
className: e("flex items-center justify-center rounded-lg border-2 border-dashed cursor-pointer transition-all", Q[x], L ? "border-primary bg-primary/5" : "border-muted-foreground/25 hover:border-muted-foreground/50", y && "opacity-50 cursor-not-allowed", F && "cursor-wait"),
|
|
249
|
+
children: F ? /* @__PURE__ */ m("div", {
|
|
249
250
|
className: "flex flex-col items-center gap-2 text-muted-foreground",
|
|
250
|
-
children: [/* @__PURE__ */
|
|
251
|
+
children: [/* @__PURE__ */ p(o, { className: "h-6 w-6 animate-spin" }), /* @__PURE__ */ p("span", {
|
|
251
252
|
className: "text-xs",
|
|
252
|
-
children:
|
|
253
|
+
children: A("rc.fileInput.uploading")
|
|
253
254
|
})]
|
|
254
|
-
}) : /* @__PURE__ */
|
|
255
|
+
}) : /* @__PURE__ */ m("div", {
|
|
255
256
|
className: "flex flex-col items-center gap-2 text-muted-foreground p-2",
|
|
256
|
-
children: [
|
|
257
|
+
children: [p(M ? a : s, { className: "h-6 w-6" }), /* @__PURE__ */ p("span", {
|
|
257
258
|
className: "text-xs text-center",
|
|
258
|
-
children:
|
|
259
|
+
children: z
|
|
259
260
|
})]
|
|
260
261
|
})
|
|
261
262
|
})
|
|
@@ -263,6 +264,6 @@ function x(m) {
|
|
|
263
264
|
});
|
|
264
265
|
}
|
|
265
266
|
//#endregion
|
|
266
|
-
export {
|
|
267
|
+
export { T as FileInput };
|
|
267
268
|
|
|
268
269
|
//# sourceMappingURL=file-input.js.map
|