impact-nova 0.1.13 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/components/layout/dashboard-layout.d.ts +21 -6
  2. package/dist/components/ui/accordion-nested-list/accordion-nested-list.js +32 -33
  3. package/dist/components/ui/accordion.js +25 -23
  4. package/dist/components/ui/ag-grid-react/cell-renderers/editors/split-cell-editor.d.ts +5 -0
  5. package/dist/components/ui/ag-grid-react/cell-renderers/editors/split-cell-editor.js +50 -52
  6. package/dist/components/ui/ag-grid-react/cell-renderers/input-display-renderer.d.ts +1 -1
  7. package/dist/components/ui/ag-grid-react/cell-renderers/split-cell-renderer.js +34 -34
  8. package/dist/components/ui/ag-grid-react/headers/advanced-filter/column-filter-section.js +8 -11
  9. package/dist/components/ui/ag-grid-react/headers/column-menu/column-settings-menu.js +17 -17
  10. package/dist/components/ui/ag-grid-react/headers/header-search-input.js +3 -3
  11. package/dist/components/ui/alert-dialog.js +45 -40
  12. package/dist/components/ui/alert.d.ts +21 -4
  13. package/dist/components/ui/alert.js +45 -25
  14. package/dist/components/ui/avatar.js +19 -16
  15. package/dist/components/ui/badge.js +8 -1
  16. package/dist/components/ui/breadcrumb.js +1 -0
  17. package/dist/components/ui/button-group.d.ts +1 -1
  18. package/dist/components/ui/button-group.js +27 -32
  19. package/dist/components/ui/button-variants.d.ts +1 -1
  20. package/dist/components/ui/button.d.ts +11 -0
  21. package/dist/components/ui/button.js +11 -9
  22. package/dist/components/ui/calendar.d.ts +14 -2
  23. package/dist/components/ui/calendar.js +443 -376
  24. package/dist/components/ui/card.js +7 -6
  25. package/dist/components/ui/checkbox.js +64 -48
  26. package/dist/components/ui/chips.d.ts +1 -0
  27. package/dist/components/ui/chips.js +27 -19
  28. package/dist/components/ui/data-table/data-table-column-list.d.ts +4 -1
  29. package/dist/components/ui/data-table/data-table-column-list.js +58 -54
  30. package/dist/components/ui/data-table/data-table-sheet.d.ts +1 -1
  31. package/dist/components/ui/data-table/data-table-sheet.js +43 -40
  32. package/dist/components/ui/data-table/data-table-view-options.js +17 -17
  33. package/dist/components/ui/data-table/data-table.js +21 -20
  34. package/dist/components/ui/date-picker/date-picker.js +83 -87
  35. package/dist/components/ui/date-picker/date-range-picker.js +129 -125
  36. package/dist/components/ui/date-picker/month-picker.js +90 -93
  37. package/dist/components/ui/date-picker/month-range-picker.js +132 -129
  38. package/dist/components/ui/date-picker/multi-date-picker.js +37 -38
  39. package/dist/components/ui/date-picker/multi-month-picker.js +29 -30
  40. package/dist/components/ui/date-picker/multi-week-picker.js +49 -38
  41. package/dist/components/ui/date-picker/week-picker.js +116 -112
  42. package/dist/components/ui/date-picker/week-range-picker.js +153 -142
  43. package/dist/components/ui/dialog.js +15 -6
  44. package/dist/components/ui/drawer.js +16 -13
  45. package/dist/components/ui/dropdown-menu.js +4 -2
  46. package/dist/components/ui/dynamic-layout.d.ts +2 -2
  47. package/dist/components/ui/dynamic-layout.js +18 -15
  48. package/dist/components/ui/empty-container.js +69 -64
  49. package/dist/components/ui/file-upload.js +113 -106
  50. package/dist/components/ui/filter-panel/filter-panel.js +49 -46
  51. package/dist/components/ui/filter-strip/filter-strip.js +41 -37
  52. package/dist/components/ui/header.js +26 -25
  53. package/dist/components/ui/horizontal-scroller/horizontal-scroller.js +43 -40
  54. package/dist/components/ui/hover-card.js +6 -5
  55. package/dist/components/ui/input.d.ts +1 -1
  56. package/dist/components/ui/input.js +79 -68
  57. package/dist/components/ui/loader.d.ts +1 -0
  58. package/dist/components/ui/loader.js +23 -13
  59. package/dist/components/ui/nested-list/components/NestedListContent.d.ts +1 -3
  60. package/dist/components/ui/nested-list/components/NestedListContent.js +16 -15
  61. package/dist/components/ui/nested-list/components/SortableItem.js +116 -80
  62. package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.d.ts +13 -1
  63. package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.js +162 -112
  64. package/dist/components/ui/nested-list/nested-list.js +182 -189
  65. package/dist/components/ui/notification-panel/notification-item.js +19 -17
  66. package/dist/components/ui/notification-panel/notification-list.js +21 -21
  67. package/dist/components/ui/notification-panel/notification-panel.js +25 -25
  68. package/dist/components/ui/popover.js +37 -34
  69. package/dist/components/ui/progress.js +12 -10
  70. package/dist/components/ui/prompt.js +29 -27
  71. package/dist/components/ui/radio-group.js +55 -46
  72. package/dist/components/ui/select/components/Submenu.d.ts +1 -2
  73. package/dist/components/ui/select/components/Submenu.js +52 -48
  74. package/dist/components/ui/select/select.js +321 -324
  75. package/dist/components/ui/sheet.js +18 -15
  76. package/dist/components/ui/sidebar.d.ts +2 -2
  77. package/dist/components/ui/sidebar.js +3 -3
  78. package/dist/components/ui/skeleton.d.ts +2 -1
  79. package/dist/components/ui/skeleton.js +12 -11
  80. package/dist/components/ui/slider.js +39 -12
  81. package/dist/components/ui/smart-input.js +44 -39
  82. package/dist/components/ui/stepper.js +33 -29
  83. package/dist/components/ui/switch.js +6 -4
  84. package/dist/components/ui/tabs.js +50 -45
  85. package/dist/components/ui/tag-group.d.ts +2 -1
  86. package/dist/components/ui/tag-group.js +29 -25
  87. package/dist/components/ui/tag.d.ts +1 -0
  88. package/dist/components/ui/tag.js +26 -20
  89. package/dist/components/ui/textarea.js +18 -17
  90. package/dist/components/ui/toast.d.ts +1 -1
  91. package/dist/components/ui/toast.js +47 -41
  92. package/dist/components/ui/toaster.js +42 -42
  93. package/dist/components/ui/tooltip.js +18 -16
  94. package/dist/components/ui/types/date-picker.types.d.ts +33 -0
  95. package/dist/components/ui/types/empty-container.types.d.ts +5 -0
  96. package/dist/components/ui/types/nested-list.types.d.ts +1 -0
  97. package/dist/components/ui/types/select.types.d.ts +0 -1
  98. package/dist/icons/assets/bookmark.svg.js +4 -0
  99. package/dist/icons/assets/bookmark.svg2.js +5 -0
  100. package/dist/icons/assets/bookmarkFilled.svg.js +4 -0
  101. package/dist/icons/assets/bookmarkFilled.svg2.js +5 -0
  102. package/dist/icons/assets/download.svg.js +4 -0
  103. package/dist/icons/assets/download.svg2.js +5 -0
  104. package/dist/icons/index.d.ts +20 -6
  105. package/dist/icons/index.js +398 -370
  106. package/dist/impact-nova.css +1 -1
  107. package/dist/index.d.ts +1 -0
  108. package/dist/index.js +318 -314
  109. package/dist/lib/fiscal-calendar.d.ts +62 -0
  110. package/dist/lib/fiscal-calendar.js +99 -0
  111. package/package.json +5 -5
  112. package/dist/components/ui/select/hooks/useClickOutside.d.ts +0 -15
  113. package/dist/components/ui/select/hooks/useClickOutside.js +0 -43
  114. package/dist/components/ui/select/hooks/useMenuPosition.d.ts +0 -2
  115. package/dist/components/ui/select/hooks/useMenuPosition.js +0 -89
@@ -1,79 +1,78 @@
1
- import { jsxs as f, jsx as o } from "react/jsx-runtime";
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
2
  import * as a from "react";
3
- import { X as S } from "lucide-react";
3
+ import { X as O } from "lucide-react";
4
4
  import { CalendarMonth as k } from "../../../icons/index.js";
5
- import { format as v } from "date-fns";
6
- import { cn as w } from "../../../lib/utils.js";
7
- import { Input as T } from "../input.js";
8
- import { Popover as j, PopoverTrigger as I, PopoverContent as R } from "../popover.js";
9
- import { Calendar as E } from "../calendar.js";
5
+ import { format as w } from "date-fns";
6
+ import { cn as T } from "../../../lib/utils.js";
7
+ import { Input as j } from "../input.js";
8
+ import { Popover as v, PopoverTrigger as R, PopoverContent as E } from "../popover.js";
9
+ import { Calendar as I } from "../calendar.js";
10
10
  const L = a.forwardRef(
11
11
  ({
12
- value: t,
12
+ value: e,
13
13
  onChange: s,
14
- format: m = "MM/dd/yyyy",
15
- placeholder: u = "Select Dates",
16
- minDate: h,
14
+ format: f = "MM/dd/yyyy",
15
+ placeholder: h = "Select Dates",
16
+ minDate: u,
17
17
  maxDate: y,
18
18
  fromYear: g,
19
19
  toYear: C,
20
20
  showFooter: l = !0,
21
21
  disabled: c,
22
- className: D,
23
- ...x
22
+ className: x,
23
+ ...D
24
24
  }, P) => {
25
- const [i, r] = a.useState(!1), [p, n] = a.useState(t);
25
+ const [i, r] = a.useState(!1), [p, n] = a.useState(e);
26
26
  a.useEffect(() => {
27
- i && n(t);
27
+ i && n(e);
28
28
  }, [i]);
29
- const N = (e) => {
30
- n(e), l || s?.(e);
31
- }, A = (e) => {
32
- s?.(e !== void 0 ? e : p), r(!1);
29
+ const N = (t) => {
30
+ n(t), l || s?.(t);
31
+ }, A = (t) => {
32
+ s?.(t !== void 0 ? t : p), r(!1);
33
33
  }, M = () => {
34
- n(t), r(!1);
34
+ n(e), r(!1);
35
35
  }, d = () => {
36
36
  n(void 0), s?.(void 0), l || r(!1);
37
- }, O = t && t.length > 0 ? t.length === 1 ? v(t[0], m) : `${t.length} dates selected` : "";
38
- return /* @__PURE__ */ f(j, { open: i, onOpenChange: r, children: [
39
- /* @__PURE__ */ o(I, { asChild: !0, children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(
40
- T,
37
+ }, S = e && e.length > 0 ? e.length === 1 ? w(e[0], f) : `${e.length} dates selected` : "";
38
+ return /* @__PURE__ */ m(v, { open: i, onOpenChange: r, children: [
39
+ /* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(
40
+ j,
41
41
  {
42
42
  ref: P,
43
- value: O,
44
- placeholder: u,
43
+ value: S,
44
+ placeholder: h,
45
45
  readOnly: !0,
46
46
  disabled: c,
47
- className: w("cursor-pointer", D),
48
- suffix: /* @__PURE__ */ f("div", { className: "flex items-center gap-1", children: [
49
- t && t.length > 0 && !c && /* @__PURE__ */ o(
50
- S,
47
+ className: T("cursor-pointer", x),
48
+ suffix: /* @__PURE__ */ m("div", { className: "flex items-center gap-1", children: [
49
+ e && e.length > 0 && !c && /* @__PURE__ */ o(
50
+ O,
51
51
  {
52
52
  className: "h-4 w-4 cursor-pointer hover:text-foreground",
53
- onClick: (e) => {
54
- e.stopPropagation(), d();
53
+ onClick: (t) => {
54
+ t.stopPropagation(), d();
55
55
  }
56
56
  }
57
57
  ),
58
58
  /* @__PURE__ */ o(k, { className: "h-4 w-4 text-secondary-foreground" })
59
59
  ] }),
60
- ...x
60
+ ...D
61
61
  }
62
62
  ) }) }),
63
63
  /* @__PURE__ */ o(
64
- R,
64
+ E,
65
65
  {
66
66
  className: "w-auto p-0",
67
67
  align: "start",
68
- onOpenAutoFocus: (e) => e.preventDefault(),
69
- onInteractOutside: (e) => e.preventDefault(),
68
+ onOpenAutoFocus: (t) => t.preventDefault(),
70
69
  children: /* @__PURE__ */ o(
71
- E,
70
+ I,
72
71
  {
73
72
  mode: "multiple",
74
73
  selected: p,
75
74
  onSelect: N,
76
- fromDate: h,
75
+ fromDate: u,
77
76
  toDate: y,
78
77
  fromYear: g,
79
78
  toYear: C,
@@ -1,51 +1,51 @@
1
1
  import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
2
  import * as s from "react";
3
- import { X as S } from "lucide-react";
4
- import { CalendarMonth as k } from "../../../icons/index.js";
5
- import { cn as D } from "../../../lib/utils.js";
6
- import { Input as T } from "../input.js";
7
- import { Popover as w, PopoverTrigger as $, PopoverContent as j } from "../popover.js";
8
- import { Calendar as v } from "../calendar.js";
9
- const I = s.forwardRef(
3
+ import { X as k } from "lucide-react";
4
+ import { CalendarMonth as O } from "../../../icons/index.js";
5
+ import { cn as T } from "../../../lib/utils.js";
6
+ import { Input as w } from "../input.js";
7
+ import { Popover as D, PopoverTrigger as $, PopoverContent as j } from "../popover.js";
8
+ import { Calendar as R } from "../calendar.js";
9
+ const v = s.forwardRef(
10
10
  ({
11
11
  value: e,
12
- onChange: a,
12
+ onChange: c,
13
13
  placeholder: f = "Select Months",
14
14
  minDate: h,
15
15
  maxDate: u,
16
16
  fromYear: g,
17
17
  toYear: y,
18
- showFooter: c = !0,
19
- disabled: l,
18
+ showFooter: i = !0,
19
+ disabled: a,
20
20
  className: M,
21
21
  ...C
22
22
  }, x) => {
23
- const [i, n] = s.useState(!1), [p, r] = s.useState(e);
23
+ const [l, n] = s.useState(!1), [p, r] = s.useState(e);
24
24
  s.useEffect(() => {
25
- i && r(e);
26
- }, [i]);
25
+ l && r(e);
26
+ }, [l]);
27
27
  const P = (t) => {
28
- r(t), c || a?.(t);
28
+ r(t), i || c?.(t);
29
29
  }, N = (t) => {
30
- a?.(t !== void 0 ? t : p), n(!1);
30
+ c?.(t !== void 0 ? t : p), n(!1);
31
31
  }, A = () => {
32
32
  r(e), n(!1);
33
33
  }, m = () => {
34
- r(void 0), a?.(void 0), c || n(!1);
35
- }, O = e && e.length > 0 ? e.length === 1 ? `${e[0].month + 1}/${e[0].year}` : `${e.length} months selected` : "";
36
- return /* @__PURE__ */ d(w, { open: i, onOpenChange: n, children: [
34
+ r(void 0), c?.(void 0), i || n(!1);
35
+ }, S = e && e.length > 0 ? e.length === 1 ? `${e[0].month + 1}/${e[0].year}` : `${e.length} months selected` : "";
36
+ return /* @__PURE__ */ d(D, { open: l, onOpenChange: n, children: [
37
37
  /* @__PURE__ */ o($, { asChild: !0, children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(
38
- T,
38
+ w,
39
39
  {
40
40
  ref: x,
41
- value: O,
41
+ value: S,
42
42
  placeholder: f,
43
43
  readOnly: !0,
44
- disabled: l,
45
- className: D("cursor-pointer", M),
44
+ disabled: a,
45
+ className: T("cursor-pointer", M),
46
46
  suffix: /* @__PURE__ */ d("div", { className: "flex items-center gap-1", children: [
47
- e && e.length > 0 && !l && /* @__PURE__ */ o(
48
- S,
47
+ e && e.length > 0 && !a && /* @__PURE__ */ o(
48
+ k,
49
49
  {
50
50
  className: "h-4 w-4 cursor-pointer hover:text-foreground",
51
51
  onClick: (t) => {
@@ -53,7 +53,7 @@ const I = s.forwardRef(
53
53
  }
54
54
  }
55
55
  ),
56
- /* @__PURE__ */ o(k, { className: "h-4 w-4 text-secondary-foreground" })
56
+ /* @__PURE__ */ o(O, { className: "h-4 w-4 text-secondary-foreground" })
57
57
  ] }),
58
58
  ...C
59
59
  }
@@ -64,9 +64,8 @@ const I = s.forwardRef(
64
64
  className: "w-auto p-0",
65
65
  align: "start",
66
66
  onOpenAutoFocus: (t) => t.preventDefault(),
67
- onInteractOutside: (t) => t.preventDefault(),
68
67
  children: /* @__PURE__ */ o(
69
- v,
68
+ R,
70
69
  {
71
70
  pickerType: "month",
72
71
  monthMode: "multiple",
@@ -76,7 +75,7 @@ const I = s.forwardRef(
76
75
  toDate: u,
77
76
  fromYear: g,
78
77
  toYear: y,
79
- showFooter: c,
78
+ showFooter: i,
80
79
  onApply: N,
81
80
  onCancel: A,
82
81
  onClear: m,
@@ -88,7 +87,7 @@ const I = s.forwardRef(
88
87
  ] });
89
88
  }
90
89
  );
91
- I.displayName = "MultiMonthPicker";
90
+ v.displayName = "MultiMonthPicker";
92
91
  export {
93
- I as MultiMonthPicker
92
+ v as MultiMonthPicker
94
93
  };
@@ -1,56 +1,62 @@
1
1
  import { jsxs as y, jsx as o } from "react/jsx-runtime";
2
2
  import * as a from "react";
3
- import { X as N } from "lucide-react";
4
- import { CalendarMonth as A } from "../../../icons/index.js";
5
- import { format as u } from "date-fns";
6
- import { cn as O } from "../../../lib/utils.js";
7
- import { Input as T } from "../input.js";
8
- import { Popover as v, PopoverTrigger as $, PopoverContent as j } from "../popover.js";
9
- import { Calendar as I } from "../calendar.js";
10
- const R = (e, r = "MM/dd/yyyy") => {
11
- const c = u(e.startDate, r), i = u(e.endDate, r);
3
+ import { X as v } from "lucide-react";
4
+ import { CalendarMonth as R } from "../../../icons/index.js";
5
+ import { format as h } from "date-fns";
6
+ import { cn as E } from "../../../lib/utils.js";
7
+ import { Input as I } from "../input.js";
8
+ import { Popover as L, PopoverTrigger as V, PopoverContent as X } from "../popover.js";
9
+ import { Calendar as b } from "../calendar.js";
10
+ const q = (e, r = "MM/dd/yyyy") => {
11
+ const c = h(e.startDate, r), i = h(e.endDate, r);
12
12
  return `${c} - ${i}`;
13
- }, E = a.forwardRef(
13
+ }, z = a.forwardRef(
14
14
  ({
15
15
  value: e,
16
16
  onChange: r,
17
17
  format: c = "MM/dd/yyyy",
18
18
  placeholder: i = "Select Weeks",
19
- minDate: h,
20
- maxDate: k,
19
+ minDate: k,
20
+ maxDate: u,
21
21
  fromYear: g,
22
22
  toYear: C,
23
23
  showFooter: l = !0,
24
+ calendarType: M = "calendar",
25
+ fiscalMode: w = "basic",
26
+ selectionMode: x = "week",
27
+ fiscalMonthPattern: P,
28
+ fiscalYearStartMonth: S = 1,
29
+ weekStartsOn: W = 1,
24
30
  disabled: d,
25
- className: M,
26
- ...x
27
- }, P) => {
31
+ className: N,
32
+ ...A
33
+ }, D) => {
28
34
  const [p, n] = a.useState(!1), [f, s] = a.useState(e);
29
35
  a.useEffect(() => {
30
36
  p && s(e);
31
37
  }, [p]);
32
- const S = (t) => {
38
+ const O = (t) => {
33
39
  s(t), l || r?.(t);
34
- }, W = (t) => {
40
+ }, T = (t) => {
35
41
  r?.(t !== void 0 ? t : f), n(!1);
36
- }, w = () => {
42
+ }, $ = () => {
37
43
  s(e), n(!1);
38
44
  }, m = () => {
39
45
  s(void 0), r?.(void 0), l || n(!1);
40
- }, D = e && e.length > 0 ? e.length === 1 ? R(e[0], c) : `${e.length} weeks selected` : "";
41
- return /* @__PURE__ */ y(v, { open: p, onOpenChange: n, children: [
42
- /* @__PURE__ */ o($, { asChild: !0, children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(
43
- T,
46
+ }, j = e && e.length > 0 ? e.length === 1 ? q(e[0], c) : `${e.length} weeks selected` : "";
47
+ return /* @__PURE__ */ y(L, { open: p, onOpenChange: n, children: [
48
+ /* @__PURE__ */ o(V, { asChild: !0, children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(
49
+ I,
44
50
  {
45
- ref: P,
46
- value: D,
51
+ ref: D,
52
+ value: j,
47
53
  placeholder: i,
48
54
  readOnly: !0,
49
55
  disabled: d,
50
- className: O("cursor-pointer", M),
56
+ className: E("cursor-pointer", N),
51
57
  suffix: /* @__PURE__ */ y("div", { className: "flex items-center gap-1", children: [
52
58
  e && e.length > 0 && !d && /* @__PURE__ */ o(
53
- N,
59
+ v,
54
60
  {
55
61
  className: "h-4 w-4 cursor-pointer hover:text-foreground",
56
62
  onClick: (t) => {
@@ -58,32 +64,37 @@ const R = (e, r = "MM/dd/yyyy") => {
58
64
  }
59
65
  }
60
66
  ),
61
- /* @__PURE__ */ o(A, { className: "h-4 w-4 text-secondary-foreground" })
67
+ /* @__PURE__ */ o(R, { className: "h-4 w-4 text-secondary-foreground" })
62
68
  ] }),
63
- ...x
69
+ ...A
64
70
  }
65
71
  ) }) }),
66
72
  /* @__PURE__ */ o(
67
- j,
73
+ X,
68
74
  {
69
75
  className: "w-auto p-0",
70
76
  align: "start",
71
77
  onOpenAutoFocus: (t) => t.preventDefault(),
72
- onInteractOutside: (t) => t.preventDefault(),
73
78
  children: /* @__PURE__ */ o(
74
- I,
79
+ b,
75
80
  {
76
81
  pickerType: "week",
77
82
  weekMode: "multiple",
78
83
  selectedWeeks: f,
79
- onWeekSelect: S,
80
- fromDate: h,
81
- toDate: k,
84
+ onWeekSelect: O,
85
+ fromDate: k,
86
+ toDate: u,
82
87
  fromYear: g,
83
88
  toYear: C,
84
89
  showFooter: l,
85
- onApply: W,
86
- onCancel: w,
90
+ calendarType: M,
91
+ fiscalMode: w,
92
+ selectionMode: x,
93
+ fiscalMonthPattern: P,
94
+ fiscalYearStartMonth: S,
95
+ weekStartsOn: W,
96
+ onApply: T,
97
+ onCancel: $,
87
98
  onClear: m,
88
99
  captionLayout: "dropdown"
89
100
  }
@@ -93,7 +104,7 @@ const R = (e, r = "MM/dd/yyyy") => {
93
104
  ] });
94
105
  }
95
106
  );
96
- E.displayName = "MultiWeekPicker";
107
+ z.displayName = "MultiWeekPicker";
97
108
  export {
98
- E as MultiWeekPicker
109
+ z as MultiWeekPicker
99
110
  };
@@ -1,131 +1,135 @@
1
- import { jsxs as M, jsx as r } from "react/jsx-runtime";
2
- import * as s from "react";
3
- import { X as R } from "lucide-react";
4
- import { CalendarMonth as Y } from "../../../icons/index.js";
5
- import { format as P, parse as X, isValid as q } from "date-fns";
6
- import { cn as z, maskDate as G } from "../../../lib/utils.js";
7
- import { Input as H } from "../input.js";
8
- import { Popover as J, PopoverTrigger as K, PopoverContent as Q } from "../popover.js";
9
- import { Calendar as U } from "../calendar.js";
10
- const h = (n, a = "MM/dd/yyyy") => {
11
- const o = P(n.startDate, a), k = P(n.endDate, a);
12
- return `${o} - ${k}`;
13
- }, Z = s.forwardRef(
1
+ import { jsxs as A, jsx as i } from "react/jsx-runtime";
2
+ import * as a from "react";
3
+ import { X as H } from "lucide-react";
4
+ import { CalendarMonth as J } from "../../../icons/index.js";
5
+ import { format as M, parse as K, isValid as Q } from "date-fns";
6
+ import { cn as U, maskDate as Z } from "../../../lib/utils.js";
7
+ import { Input as _ } from "../input.js";
8
+ import { Popover as Y, PopoverTrigger as F, PopoverContent as ee } from "../popover.js";
9
+ import { Calendar as te } from "../calendar.js";
10
+ import { resolveWeekSelection as ne } from "../../../lib/fiscal-calendar.js";
11
+ const f = (t, r = "MM/dd/yyyy") => {
12
+ const n = M(t.startDate, r), m = M(t.endDate, r);
13
+ return `${n} - ${m}`;
14
+ }, oe = a.forwardRef(
14
15
  ({
15
- value: n,
16
- onChange: a,
17
- format: o = "MM/dd/yyyy",
18
- placeholder: k = "Select Week",
19
- minDate: C,
20
- maxDate: w,
21
- fromYear: S,
22
- toYear: O,
23
- showFooter: f = !0,
24
- disabled: m,
25
- className: v,
26
- ...x
27
- }, I) => {
28
- const [c, d] = s.useState(!1), [l, i] = s.useState(n), [W, g] = s.useState(n ? h(n, o) : ""), [N, u] = s.useState(n?.startDate || /* @__PURE__ */ new Date());
29
- s.useEffect(() => {
30
- g(n ? h(n, o) : "");
31
- }, [n, o]), s.useEffect(() => {
32
- console.log("[WeekPicker] useEffect - open:", c, "value:", n, "pendingWeek:", l), c && (i(n), u(n?.startDate || /* @__PURE__ */ new Date()));
33
- }, [c]);
34
- const A = (e) => {
35
- console.log("[WeekPicker] handleSelect called:", e), i(e), f || (console.log("[WeekPicker] No footer - applying immediately"), a?.(e), d(!1));
36
- }, V = (e) => {
37
- const t = e;
38
- g(t ? h(t, o) : "");
39
- }, $ = (e) => {
40
- const t = e !== void 0 ? e : l;
41
- console.log("[WeekPicker] handleApply called, appliedWeek:", e, "pendingWeek:", l, "using:", t), a?.(t), d(!1);
42
- }, B = () => {
43
- console.log("[WeekPicker] handleCancel called"), i(n), d(!1);
44
- }, D = () => {
45
- console.log("[WeekPicker] handleClear called"), i(void 0), g(""), a?.(void 0), f || d(!1);
46
- }, E = (e) => {
47
- const t = new Date(e);
48
- t.setDate(e.getDate() - e.getDay());
49
- const p = new Date(t);
50
- p.setDate(t.getDate() + 6);
51
- const T = new Date(t.getFullYear(), t.getMonth(), 1).getDay(), j = t.getDate(), L = Math.ceil((j + T) / 7);
52
- return {
53
- year: t.getFullYear(),
54
- month: t.getMonth(),
55
- weekOfMonth: L,
56
- startDate: t,
57
- endDate: p
58
- };
59
- };
60
- return /* @__PURE__ */ M(J, { open: c, onOpenChange: d, children: [
61
- /* @__PURE__ */ r(K, { asChild: !0, children: /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
62
- H,
16
+ value: t,
17
+ onChange: r,
18
+ format: n = "MM/dd/yyyy",
19
+ placeholder: m = "Select Week",
20
+ minDate: V,
21
+ maxDate: I,
22
+ fromYear: $,
23
+ toYear: T,
24
+ showFooter: c = !0,
25
+ calendarType: D = "calendar",
26
+ fiscalMode: C = "basic",
27
+ selectionMode: W = "week",
28
+ fiscalMonthPattern: S,
29
+ fiscalYearStartMonth: v = 1,
30
+ weekStartsOn: w = 1,
31
+ disabled: x,
32
+ className: j,
33
+ ...B
34
+ }, E) => {
35
+ const [o, l] = a.useState(!1), [s, p] = a.useState(t), [k, d] = a.useState(t ? f(t, n) : ""), [L, y] = a.useState(t?.startDate || /* @__PURE__ */ new Date());
36
+ a.useEffect(() => {
37
+ d(t ? f(t, n) : "");
38
+ }, [t, n]), a.useEffect(() => {
39
+ o && (p(t), y(t?.startDate || /* @__PURE__ */ new Date()));
40
+ }, [o]);
41
+ const O = (e) => {
42
+ p(e), c || (r?.(e), l(!1));
43
+ }, R = (e) => {
44
+ r?.(e !== void 0 ? e : s), l(!1);
45
+ }, X = () => {
46
+ p(t), l(!1);
47
+ }, g = () => {
48
+ p(void 0), d(""), r?.(void 0), c || l(!1);
49
+ }, b = (e) => ne(e, {
50
+ calendarType: D,
51
+ fiscalMode: C,
52
+ selectionMode: W,
53
+ fiscalMonthPattern: S,
54
+ fiscalYearStartMonth: v,
55
+ weekStartsOn: w
56
+ }), q = (e) => {
57
+ const u = Z(e.target.value, n);
58
+ if (d(u), u === "") {
59
+ p(void 0), c || r?.(void 0);
60
+ return;
61
+ }
62
+ const h = K(u, n, /* @__PURE__ */ new Date());
63
+ if (Q(h)) {
64
+ const N = b(h);
65
+ p(N), y(h), c || r?.(N);
66
+ }
67
+ }, z = () => {
68
+ if (!o) {
69
+ if (k === "") {
70
+ g();
71
+ return;
72
+ }
73
+ d(s ? f(s, n) : "");
74
+ }
75
+ }, P = c && o && (s ? f(s, n) : "") !== k, G = c && o ? s ? f(s, n) : "" : k;
76
+ return /* @__PURE__ */ A(Y, { open: o, onOpenChange: l, children: [
77
+ /* @__PURE__ */ i(F, { asChild: !0, children: /* @__PURE__ */ i("div", { "data-component": "week-picker", "data-state": o ? "open" : "closed", "data-pending": P || void 0, children: /* @__PURE__ */ i(
78
+ _,
63
79
  {
64
- ref: I,
65
- value: W,
66
- onChange: (e) => {
67
- const t = G(e.target.value, o);
68
- if (g(t), t === "") {
69
- i(void 0), f || a?.(void 0);
70
- return;
71
- }
72
- const p = X(t, o, /* @__PURE__ */ new Date());
73
- if (q(p)) {
74
- const y = E(p);
75
- i(y), u(p), f || a?.(y);
76
- }
77
- },
78
- onBlur: () => {
79
- if (W === "") {
80
- D();
81
- return;
82
- }
83
- g(l ? h(l, o) : "");
84
- },
85
- onClick: (e) => c && e.stopPropagation(),
86
- placeholder: c ? `${o} - ${o}` : k,
87
- disabled: m,
88
- className: z("cursor-pointer", v),
89
- suffix: /* @__PURE__ */ M("div", { className: "flex items-center gap-1", children: [
90
- n && !m && /* @__PURE__ */ r(
91
- R,
80
+ ref: E,
81
+ value: G,
82
+ onChange: q,
83
+ onBlur: z,
84
+ onClick: (e) => o && e.stopPropagation(),
85
+ placeholder: o ? `${n} - ${n}` : m,
86
+ disabled: x,
87
+ "data-form-control": "input",
88
+ className: U("cursor-pointer", P && "text-muted-foreground", j),
89
+ suffix: /* @__PURE__ */ A("div", { className: "flex items-center gap-1", children: [
90
+ t && !x && /* @__PURE__ */ i(
91
+ H,
92
92
  {
93
93
  className: "h-4 w-4 cursor-pointer hover:text-foreground",
94
94
  onClick: (e) => {
95
- e.stopPropagation(), D();
95
+ e.stopPropagation(), g();
96
96
  }
97
97
  }
98
98
  ),
99
- /* @__PURE__ */ r(Y, { className: "h-4 w-4 text-secondary-foreground" })
99
+ /* @__PURE__ */ i(J, { className: "h-4 w-4 text-secondary-foreground" })
100
100
  ] }),
101
- ...x
101
+ ...B
102
102
  }
103
103
  ) }) }),
104
- /* @__PURE__ */ r(
105
- Q,
104
+ /* @__PURE__ */ i(
105
+ ee,
106
106
  {
107
107
  className: "w-auto p-0",
108
108
  align: "start",
109
109
  onOpenAutoFocus: (e) => e.preventDefault(),
110
- onInteractOutside: (e) => e.preventDefault(),
111
- children: /* @__PURE__ */ r(
112
- U,
110
+ children: /* @__PURE__ */ i(
111
+ te,
113
112
  {
114
113
  pickerType: "week",
115
114
  weekMode: "single",
116
- selectedWeeks: l,
117
- onWeekSelect: A,
118
- onPendingChange: V,
119
- month: N,
120
- onMonthChange: u,
121
- fromDate: C,
122
- toDate: w,
123
- fromYear: S,
124
- toYear: O,
125
- showFooter: f,
126
- onApply: $,
127
- onCancel: B,
128
- onClear: D,
115
+ selectedWeeks: s,
116
+ onWeekSelect: O,
117
+ month: L,
118
+ onMonthChange: y,
119
+ fromDate: V,
120
+ toDate: I,
121
+ fromYear: $,
122
+ toYear: T,
123
+ showFooter: c,
124
+ calendarType: D,
125
+ fiscalMode: C,
126
+ selectionMode: W,
127
+ fiscalMonthPattern: S,
128
+ fiscalYearStartMonth: v,
129
+ weekStartsOn: w,
130
+ onApply: R,
131
+ onCancel: X,
132
+ onClear: g,
129
133
  captionLayout: "dropdown"
130
134
  }
131
135
  )
@@ -134,7 +138,7 @@ const h = (n, a = "MM/dd/yyyy") => {
134
138
  ] });
135
139
  }
136
140
  );
137
- Z.displayName = "WeekPicker";
141
+ oe.displayName = "WeekPicker";
138
142
  export {
139
- Z as WeekPicker
143
+ oe as WeekPicker
140
144
  };