@sonamu-kit/react-components 0.4.7 → 0.4.9

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.
Files changed (63) hide show
  1. package/dist/components/ui/calendar.js +12 -6
  2. package/dist/components/ui/calendar.js.map +1 -1
  3. package/dist/components/ui/carousel.js +12 -16
  4. package/dist/components/ui/carousel.js.map +1 -1
  5. package/dist/components/ui/common-modal.d.ts +6 -6
  6. package/dist/components/ui/common-modal.js.map +1 -1
  7. package/dist/components/ui/date-input.js +6 -5
  8. package/dist/components/ui/date-input.js.map +1 -1
  9. package/dist/components/ui/file-input.js +131 -130
  10. package/dist/components/ui/file-input.js.map +1 -1
  11. package/dist/components/ui/input.js +21 -20
  12. package/dist/components/ui/input.js.map +1 -1
  13. package/dist/components/ui/month-picker-multiple.js +31 -19
  14. package/dist/components/ui/month-picker-multiple.js.map +1 -1
  15. package/dist/components/ui/pagination.js +18 -17
  16. package/dist/components/ui/pagination.js.map +1 -1
  17. package/dist/components/ui/select/enum-select.js +4 -2
  18. package/dist/components/ui/select/enum-select.js.map +1 -1
  19. package/dist/components/ui/select/id-async-select.d.ts +32 -14
  20. package/dist/components/ui/select/id-async-select.js +185 -144
  21. package/dist/components/ui/select/id-async-select.js.map +1 -1
  22. package/dist/components/ui/select/select.js +199 -158
  23. package/dist/components/ui/select/select.js.map +1 -1
  24. package/dist/components/ui/sidebar.d.ts +2 -1
  25. package/dist/components/ui/sidebar.js +54 -45
  26. package/dist/components/ui/sidebar.js.map +1 -1
  27. package/dist/components/ui/sonamu-filter/constants.d.ts +27 -3
  28. package/dist/components/ui/sonamu-filter/constants.js.map +1 -1
  29. package/dist/components/ui/sonamu-filter/rule-row-input.js +18 -15
  30. package/dist/components/ui/sonamu-filter/rule-row-input.js.map +1 -1
  31. package/dist/components/ui/sonamu-filter/sonamu-filter-modal.js +34 -37
  32. package/dist/components/ui/sonamu-filter/sonamu-filter-modal.js.map +1 -1
  33. package/dist/components/ui/sonamu-filter/sonamu-filter-popover.js +17 -12
  34. package/dist/components/ui/sonamu-filter/sonamu-filter-popover.js.map +1 -1
  35. package/dist/components/ui/sonamu-filter/types.d.ts +14 -9
  36. package/dist/components/ui/sonamu-filter/utils.d.ts +9 -7
  37. package/dist/components/ui/sonamu-filter/utils.js +39 -20
  38. package/dist/components/ui/sonamu-filter/utils.js.map +1 -1
  39. package/dist/components/ui/sonamu-filter/value-input.js +65 -50
  40. package/dist/components/ui/sonamu-filter/value-input.js.map +1 -1
  41. package/dist/contexts/sonamu-context.js +34 -10
  42. package/dist/contexts/sonamu-context.js.map +1 -1
  43. package/dist/demo/components/FormDebugPanel.d.ts +1 -1
  44. package/dist/hooks/use-toast.d.ts +1 -1
  45. package/dist/hooks/use-toast.js.map +1 -1
  46. package/dist/lib/base-helpers.d.ts +1 -1
  47. package/dist/lib/base-helpers.js +7 -7
  48. package/dist/lib/base-helpers.js.map +1 -1
  49. package/dist/lib/caster.d.ts +3 -2
  50. package/dist/lib/caster.js +37 -19
  51. package/dist/lib/caster.js.map +1 -1
  52. package/dist/lib/form-helpers.js +38 -35
  53. package/dist/lib/form-helpers.js.map +1 -1
  54. package/dist/lib/list-helpers.d.ts +2 -2
  55. package/dist/lib/list-helpers.js +33 -36
  56. package/dist/lib/list-helpers.js.map +1 -1
  57. package/dist/lib/use-mobile.js +5 -7
  58. package/dist/lib/use-mobile.js.map +1 -1
  59. package/dist/lib/utils.d.ts +0 -14
  60. package/dist/lib/utils.js +24 -14
  61. package/dist/lib/utils.js.map +1 -1
  62. package/dist/styles/globals.css +38 -106
  63. package/package.json +5 -3
@@ -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({ className: o, classNames: s, showOutsideDays: c = !0, ...l }) {
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", o),
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
- ...s
43
+ ...r
38
44
  },
39
45
  components: {
40
- IconLeft: () => /* @__PURE__ */ i(r, { className: "h-4 w-4" }),
41
- IconRight: () => /* @__PURE__ */ i(n, { className: "h-4 w-4" })
46
+ IconLeft: o,
47
+ IconRight: s
42
48
  },
43
49
  ...l
44
50
  });
45
51
  }
46
52
  //#endregion
47
- export { o as Calendar };
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: () => <ChevronLeftIcon className=\"h-4 w-4\" />,\n IconRight: () => <ChevronRightIcon className=\"h-4 w-4\" />,\n }}\n {...props}\n />\n );\n}\n\nexport { Calendar };\nexport type { DateRange };\n"],"mappings":";;;;;;;;;AAWA,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,gBAAgB,kBAAC,GAAD,EAAiB,WAAU,UAAW,CAAA;GACtD,iBAAiB,kBAAC,GAAD,EAAkB,WAAU,UAAW,CAAA;EAC1D;EACA,GAAI;CACL,CAAA;AAEL"}
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), [h, g] = i.useState(!1), [_, v] = i.useState(!1), y = i.useCallback((e) => {
21
- e && (g(e.canScrollPrev()), v(e.canScrollNext()));
22
- }, []), b = i.useCallback(() => {
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]), x = i.useCallback(() => {
24
+ }, [m]), y = i.useCallback(() => {
25
25
  m?.scrollNext();
26
- }, [m]), S = i.useCallback((e) => {
27
- e.key === "ArrowLeft" ? (e.preventDefault(), b()) : e.key === "ArrowRight" && (e.preventDefault(), x());
28
- }, [b, x]);
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]), i.useEffect(() => {
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: b,
42
- scrollNext: x,
43
- canScrollPrev: h,
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: S,
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 [canScrollPrev, setCanScrollPrev] = React.useState(false);\n const [canScrollNext, setCanScrollNext] = React.useState(false);\n\n const onSelect = React.useCallback((api: CarouselApi) => {\n if (!api) {\n return;\n }\n\n setCanScrollPrev(api.canScrollPrev());\n setCanScrollNext(api.canScrollNext());\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 React.useEffect(() => {\n if (!api) {\n return;\n }\n\n onSelect(api);\n api.on(\"reInit\", onSelect);\n api.on(\"select\", onSelect);\n\n return () => {\n api?.off(\"reInit\", onSelect);\n api?.off(\"select\", onSelect);\n };\n }, [api, onSelect]);\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,CAAC,GAAe,KAAoB,EAAM,SAAS,EAAK,GACxD,CAAC,GAAe,KAAoB,EAAM,SAAS,EAAK,GAExD,IAAW,EAAM,aAAa,MAAqB;EAClD,MAIL,EAAiB,EAAI,cAAc,CAAC,GACpC,EAAiB,EAAI,cAAc,CAAC;CACtC,GAAG,CAAC,CAAC,GAEC,IA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AE9B,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
+ {"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;CA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Aa,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?: unknown) => void;
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: (reactNode: React.ReactNode, props?: ExtendedModalProps) => void;
26
+ openModal: (content: React.ReactNode, props?: ExtendedModalProps) => void;
27
27
  closeModal: () => void;
28
- doneModal: (data?: unknown) => void;
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?: unknown) => 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 = (reactNode: React.ReactNode, props?: ExtendedModalProps) => {\n setAtomValue({\n open: true,\n reactNode,\n ...props,\n });\n };\n\n const closeModal = () => {\n setAtomValue({\n open: false,\n reactNode: null,\n });\n };\n\n const doneModal = (data?: unknown) => {\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,GAA4B,MAA+B;EAC5E,EAAa;GACX,MAAM;GACN;GACA,GAAG;EACL,CAAC;CACH,GAEM,UAAmB;EACvB,EAAa;GACX,MAAM;GACN,WAAW;EACb,CAAC;CACH;CASA,OAAO;EACL;EACA;EACA;EACA;EACA,YAZiB,MAAmB;GAEpC,AADA,EAAW,GACP,KACF,EAAY,CAAI;EAEpB;CAQA;AACF"}
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"}
@@ -1,15 +1,16 @@
1
1
  import { Input as e } from "./input.js";
2
2
  import { jsx as t } from "react/jsx-runtime";
3
+ import { format as n } from "date-fns";
3
4
  //#region src/components/ui/date-input.tsx
4
- function n({ value: n, onValueChange: r, ...i }) {
5
+ function r({ value: r, onValueChange: i, ...a }) {
5
6
  return /* @__PURE__ */ t(e, {
6
7
  type: "datetime-local",
7
- value: n ? n instanceof Date ? n.toISOString().slice(0, 16) : new Date(n).toISOString().slice(0, 16) : "",
8
- onChange: (e) => r(e.target.value ? new Date(e.target.value) : null),
9
- ...i
8
+ value: r ? n(r instanceof Date ? r : new Date(r), "yyyy-MM-dd'T'HH:mm") : "",
9
+ onChange: (e) => i(e.target.value ? new Date(e.target.value) : null),
10
+ ...a
10
11
  });
11
12
  }
12
13
  //#endregion
13
- export { n as DateInput };
14
+ export { r as DateInput };
14
15
 
15
16
  //# sourceMappingURL=date-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-input.js","names":[],"sources":["../../../src/components/ui/date-input.tsx"],"sourcesContent":["import { type Override } from \"../../lib/types\";\nimport { Input } from \"./input\";\n\ntype DateInputProps = Override<\n React.ComponentProps<\"input\">,\n {\n value: Date | null;\n onValueChange: (value: Date | null) => void;\n }\n>;\nfunction DateInput({ value, onValueChange, ...props }: DateInputProps) {\n // value가 문자열이거나 빈 문자열인 경우 처리\n const dateValue = !value\n ? \"\"\n : value instanceof Date\n ? value.toISOString().slice(0, 16)\n : new Date(value).toISOString().slice(0, 16);\n\n return (\n <Input\n type=\"datetime-local\"\n value={dateValue}\n onChange={(e) => onValueChange(e.target.value ? new Date(e.target.value) : null)}\n {...props}\n />\n );\n}\n\nexport { DateInput, type DateInputProps };\n"],"mappings":";;;AAUA,SAAS,EAAU,EAAE,UAAO,kBAAe,GAAG,KAAyB;CAQrE,OACE,kBAAC,GAAD;EACE,MAAK;EACL,OATe,IAEf,aAAiB,OACf,EAAM,YAAY,EAAE,MAAM,GAAG,EAAE,IAC/B,IAAI,KAAK,CAAK,EAAE,YAAY,EAAE,MAAM,GAAG,EAAE,IAH3C;EASA,WAAW,MAAM,EAAc,EAAE,OAAO,QAAQ,IAAI,KAAK,EAAE,OAAO,KAAK,IAAI,IAAI;EAC/E,GAAI;CACL,CAAA;AAEL"}
1
+ {"version":3,"file":"date-input.js","names":[],"sources":["../../../src/components/ui/date-input.tsx"],"sourcesContent":["import { format } from \"date-fns\";\n\nimport { type Override } from \"../../lib/types\";\nimport { Input } from \"./input\";\n\ntype DateInputProps = Override<\n React.ComponentProps<\"input\">,\n {\n value: Date | null;\n onValueChange: (value: Date | null) => void;\n }\n>;\nfunction DateInput({ value, onValueChange, ...props }: DateInputProps) {\n // 입력과 같은 현지 시각 기준으로 표시해 수정 시 시차가 생기지 않게 합니다.\n const dateValue = !value\n ? \"\"\n : format(value instanceof Date ? value : new Date(value), \"yyyy-MM-dd'T'HH:mm\");\n\n return (\n <Input\n type=\"datetime-local\"\n value={dateValue}\n onChange={(e) => onValueChange(e.target.value ? new Date(e.target.value) : null)}\n {...props}\n />\n );\n}\n\nexport { DateInput, type DateInputProps };\n"],"mappings":";;;;AAYA,SAAS,EAAU,EAAE,UAAO,kBAAe,GAAG,KAAyB;CAMrE,OACE,kBAAC,GAAD;EACE,MAAK;EACL,OAPe,IAEf,EAAO,aAAiB,OAAO,IAAQ,IAAI,KAAK,CAAK,GAAG,oBAAoB,IAD5E;EAOA,WAAW,MAAM,EAAc,EAAE,OAAO,QAAQ,IAAI,KAAK,EAAE,OAAO,KAAK,IAAI,IAAI;EAC/E,GAAI;CACL,CAAA;AAEL"}