impact-nova 0.1.13 → 1.1.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 (120) 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/date-display-renderer.js +32 -21
  5. package/dist/components/ui/ag-grid-react/cell-renderers/editors/date-cell-editor.d.ts +3 -5
  6. package/dist/components/ui/ag-grid-react/cell-renderers/editors/date-cell-editor.js +57 -55
  7. package/dist/components/ui/ag-grid-react/cell-renderers/editors/split-cell-editor.d.ts +5 -0
  8. package/dist/components/ui/ag-grid-react/cell-renderers/editors/split-cell-editor.js +50 -52
  9. package/dist/components/ui/ag-grid-react/cell-renderers/input-display-renderer.d.ts +1 -1
  10. package/dist/components/ui/ag-grid-react/cell-renderers/split-cell-renderer.js +34 -34
  11. package/dist/components/ui/ag-grid-react/headers/advanced-filter/column-filter-section.js +8 -11
  12. package/dist/components/ui/ag-grid-react/headers/column-menu/column-settings-menu.js +17 -17
  13. package/dist/components/ui/ag-grid-react/headers/header-search-input.js +3 -3
  14. package/dist/components/ui/alert-dialog.js +45 -40
  15. package/dist/components/ui/alert.d.ts +21 -4
  16. package/dist/components/ui/alert.js +45 -25
  17. package/dist/components/ui/avatar.js +19 -16
  18. package/dist/components/ui/badge.js +8 -1
  19. package/dist/components/ui/breadcrumb.js +1 -0
  20. package/dist/components/ui/button-group.d.ts +1 -1
  21. package/dist/components/ui/button-group.js +27 -32
  22. package/dist/components/ui/button-variants.d.ts +1 -1
  23. package/dist/components/ui/button.d.ts +11 -0
  24. package/dist/components/ui/button.js +11 -9
  25. package/dist/components/ui/calendar.d.ts +14 -2
  26. package/dist/components/ui/calendar.js +443 -376
  27. package/dist/components/ui/card.js +7 -6
  28. package/dist/components/ui/checkbox.js +64 -48
  29. package/dist/components/ui/chips.d.ts +1 -0
  30. package/dist/components/ui/chips.js +27 -19
  31. package/dist/components/ui/data-table/data-table-column-list.d.ts +4 -1
  32. package/dist/components/ui/data-table/data-table-column-list.js +58 -54
  33. package/dist/components/ui/data-table/data-table-sheet.d.ts +1 -1
  34. package/dist/components/ui/data-table/data-table-sheet.js +43 -40
  35. package/dist/components/ui/data-table/data-table-view-options.js +17 -17
  36. package/dist/components/ui/data-table/data-table.js +21 -20
  37. package/dist/components/ui/date-picker/date-picker.js +93 -93
  38. package/dist/components/ui/date-picker/date-range-picker.js +142 -133
  39. package/dist/components/ui/date-picker/month-picker.js +96 -93
  40. package/dist/components/ui/date-picker/month-range-picker.js +144 -134
  41. package/dist/components/ui/date-picker/multi-date-picker.js +43 -45
  42. package/dist/components/ui/date-picker/multi-month-picker.js +37 -39
  43. package/dist/components/ui/date-picker/multi-week-picker.js +56 -46
  44. package/dist/components/ui/date-picker/week-picker.js +119 -109
  45. package/dist/components/ui/date-picker/week-range-picker.js +170 -147
  46. package/dist/components/ui/dialog.js +15 -6
  47. package/dist/components/ui/drawer.js +16 -13
  48. package/dist/components/ui/dropdown-menu.js +4 -2
  49. package/dist/components/ui/dynamic-layout.d.ts +2 -2
  50. package/dist/components/ui/dynamic-layout.js +18 -15
  51. package/dist/components/ui/empty-container.js +69 -64
  52. package/dist/components/ui/file-upload.js +113 -106
  53. package/dist/components/ui/filter-panel/filter-panel.js +49 -46
  54. package/dist/components/ui/filter-strip/filter-strip.js +41 -37
  55. package/dist/components/ui/header.js +26 -25
  56. package/dist/components/ui/horizontal-scroller/horizontal-scroller.js +43 -40
  57. package/dist/components/ui/hover-card.js +6 -5
  58. package/dist/components/ui/input.d.ts +1 -1
  59. package/dist/components/ui/input.js +79 -68
  60. package/dist/components/ui/loader.d.ts +1 -0
  61. package/dist/components/ui/loader.js +23 -13
  62. package/dist/components/ui/nested-list/components/NestedListContent.d.ts +1 -3
  63. package/dist/components/ui/nested-list/components/NestedListContent.js +16 -15
  64. package/dist/components/ui/nested-list/components/SortableItem.js +116 -80
  65. package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.d.ts +13 -1
  66. package/dist/components/ui/nested-list/hooks/useNestedListDragDrop.js +162 -112
  67. package/dist/components/ui/nested-list/nested-list.js +182 -189
  68. package/dist/components/ui/notification-panel/notification-item.js +19 -17
  69. package/dist/components/ui/notification-panel/notification-list.js +21 -21
  70. package/dist/components/ui/notification-panel/notification-panel.js +25 -25
  71. package/dist/components/ui/popover.js +37 -34
  72. package/dist/components/ui/progress.js +12 -10
  73. package/dist/components/ui/prompt.js +29 -27
  74. package/dist/components/ui/radio-group.js +55 -46
  75. package/dist/components/ui/select/components/Submenu.d.ts +1 -2
  76. package/dist/components/ui/select/components/Submenu.js +52 -48
  77. package/dist/components/ui/select/select.js +321 -324
  78. package/dist/components/ui/sheet.js +18 -15
  79. package/dist/components/ui/sidebar.d.ts +2 -2
  80. package/dist/components/ui/sidebar.js +3 -3
  81. package/dist/components/ui/skeleton.d.ts +2 -1
  82. package/dist/components/ui/skeleton.js +12 -11
  83. package/dist/components/ui/slider.js +39 -12
  84. package/dist/components/ui/smart-input.js +44 -39
  85. package/dist/components/ui/stepper.js +33 -29
  86. package/dist/components/ui/switch.js +6 -4
  87. package/dist/components/ui/tabs.js +50 -45
  88. package/dist/components/ui/tag-group.d.ts +2 -1
  89. package/dist/components/ui/tag-group.js +29 -25
  90. package/dist/components/ui/tag.d.ts +1 -0
  91. package/dist/components/ui/tag.js +26 -20
  92. package/dist/components/ui/textarea.js +18 -17
  93. package/dist/components/ui/toast.d.ts +1 -1
  94. package/dist/components/ui/toast.js +47 -41
  95. package/dist/components/ui/toaster.js +42 -42
  96. package/dist/components/ui/tooltip.js +18 -16
  97. package/dist/components/ui/types/date-picker.types.d.ts +33 -0
  98. package/dist/components/ui/types/empty-container.types.d.ts +5 -0
  99. package/dist/components/ui/types/nested-list.types.d.ts +1 -0
  100. package/dist/components/ui/types/select.types.d.ts +0 -1
  101. package/dist/icons/assets/bookmark.svg.js +4 -0
  102. package/dist/icons/assets/bookmark.svg2.js +5 -0
  103. package/dist/icons/assets/bookmarkFilled.svg.js +4 -0
  104. package/dist/icons/assets/bookmarkFilled.svg2.js +5 -0
  105. package/dist/icons/assets/download.svg.js +4 -0
  106. package/dist/icons/assets/download.svg2.js +5 -0
  107. package/dist/icons/index.d.ts +20 -6
  108. package/dist/icons/index.js +398 -370
  109. package/dist/impact-nova.css +1 -1
  110. package/dist/index.d.ts +1 -0
  111. package/dist/index.js +318 -314
  112. package/dist/lib/fiscal-calendar.d.ts +62 -0
  113. package/dist/lib/fiscal-calendar.js +99 -0
  114. package/dist/lib/utils.d.ts +2 -1
  115. package/dist/lib/utils.js +29 -13
  116. package/package.json +5 -5
  117. package/dist/components/ui/select/hooks/useClickOutside.d.ts +0 -15
  118. package/dist/components/ui/select/hooks/useClickOutside.js +0 -43
  119. package/dist/components/ui/select/hooks/useMenuPosition.d.ts +0 -2
  120. package/dist/components/ui/select/hooks/useMenuPosition.js +0 -89
@@ -1,12 +1,13 @@
1
- import { jsxs as p, jsx as c } from "react/jsx-runtime";
2
- import * as m from "react";
3
- import { ChevronLeftIcon as de, ChevronRightIcon as me } from "lucide-react";
4
- import { getDefaultClassNames as Ye, DayPicker as je } from "react-day-picker";
5
- import { cn as o } from "../../lib/utils.js";
6
- import { Button as M } from "./button.js";
7
- import { buttonVariants as ge } from "./button-variants.js";
8
- import ne from "./select/select.js";
9
- const ze = [
1
+ import { jsxs as D, jsx as f } from "react/jsx-runtime";
2
+ import * as d from "react";
3
+ import { ChevronLeftIcon as we, ChevronRightIcon as De } from "lucide-react";
4
+ import { getDefaultClassNames as Re, DayPicker as Ie } from "react-day-picker";
5
+ import { cn as c } from "../../lib/utils.js";
6
+ import { Button as E } from "./button.js";
7
+ import { buttonVariants as Ne } from "./button-variants.js";
8
+ import de from "./select/select.js";
9
+ import { FISCAL_PATTERNS as Ue, resolveWeekSelection as He } from "../../lib/fiscal-calendar.js";
10
+ const Pe = [
10
11
  "January",
11
12
  "February",
12
13
  "March",
@@ -19,150 +20,179 @@ const ze = [
19
20
  "October",
20
21
  "November",
21
22
  "December"
22
- ], Ae = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
23
- function We({
24
- className: X,
25
- classNames: T,
26
- showOutsideDays: w = !1,
27
- captionLayout: B = "dropdown",
28
- buttonVariant: Z = "ghost",
29
- formatters: U,
30
- components: he,
31
- showFooter: f = !0,
32
- onApply: q,
33
- onCancel: re,
34
- onClear: ae,
35
- onPendingChange: b,
36
- fromYear: V = 1900,
37
- toYear: F = 2100,
38
- mode: E = "single",
39
- selected: h,
40
- onSelect: $,
41
- fromDate: Y,
42
- toDate: j,
43
- fromMonth: R,
44
- toMonth: H,
23
+ ], Je = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
24
+ function Qe({
25
+ className: ae,
26
+ classNames: G,
27
+ showOutsideDays: p = !1,
28
+ captionLayout: K = "dropdown",
29
+ buttonVariant: P = "ghost",
30
+ formatters: Q,
31
+ components: Ce,
32
+ showFooter: h = !0,
33
+ onApply: X,
34
+ onCancel: me,
35
+ onClear: ge,
36
+ fromYear: se = 1900,
37
+ toYear: le = 2100,
38
+ mode: J = "single",
39
+ selected: x,
40
+ onSelect: k,
41
+ fromDate: C,
42
+ toDate: _,
43
+ fromMonth: L,
44
+ toMonth: W,
45
45
  // Week picker props
46
46
  pickerType: u = "date",
47
- weekMode: N = "single",
47
+ weekMode: y = "single",
48
48
  selectedWeeks: S,
49
- onWeekSelect: _,
49
+ onWeekSelect: A,
50
+ calendarType: Y = "calendar",
51
+ fiscalMode: Z = "basic",
52
+ selectionMode: ie = "week",
53
+ fiscalMonthPattern: oe,
54
+ fiscalYearStartMonth: he = 1,
55
+ weekStartsOn: B = 1,
56
+ // Default Monday
50
57
  // Month picker props
51
- monthMode: D = "single",
52
- selectedMonths: x,
53
- onMonthSelect: C,
54
- month: I,
55
- onMonthChange: xe,
56
- ...pe
58
+ monthMode: b = "single",
59
+ selectedMonths: w,
60
+ onMonthSelect: N,
61
+ month: R,
62
+ defaultMonth: xe,
63
+ onMonthChange: _e,
64
+ ...F
57
65
  }) {
58
- const g = Ye(), [J, G] = m.useState(h), [K, P] = m.useState(() => {
59
- if (I) return I;
60
- if (h) {
61
- if (Array.isArray(h))
62
- return h[0] || /* @__PURE__ */ new Date();
63
- if (h instanceof Date)
64
- return h;
65
- if ("from" in h && h.from)
66
- return h.from;
66
+ const V = d.useMemo(() => {
67
+ if (Y === "fiscal") {
68
+ if (oe) return oe;
69
+ if (Z === "advanced") return Ue["4-4-5"];
70
+ }
71
+ }, [Y, Z, oe]), m = Re(), [T, ee] = d.useState(x), [te, ce] = d.useState(() => {
72
+ if (R) return R;
73
+ if (xe) return xe;
74
+ if (x) {
75
+ if (Array.isArray(x))
76
+ return x[0] || /* @__PURE__ */ new Date();
77
+ if (x instanceof Date)
78
+ return x;
79
+ if ("from" in x && x.from)
80
+ return x.from;
67
81
  }
68
82
  return /* @__PURE__ */ new Date();
69
83
  });
70
- m.useEffect(() => {
71
- I && (P(I), le(I.getFullYear()));
72
- }, [I]);
73
- const [k, z] = m.useState(S), [v, A] = m.useState(x), [se, le] = m.useState(K.getFullYear());
74
- m.useEffect(() => {
75
- G(h), z(S), A(x);
76
- }, [h, S, x]);
77
- const W = (e) => {
78
- P(e), le(e.getFullYear()), xe?.(e);
79
- }, ie = m.useCallback((e) => {
80
- let n, t;
81
- if (e instanceof Date) {
82
- n = new Date(e);
83
- const l = e.getDay(), d = l === 0 ? -6 : 1 - l;
84
- n.setDate(e.getDate() + d), t = new Date(n), t.setDate(n.getDate() + 6);
85
- } else
86
- n = e.days[0]?.date, t = e.days[e.days.length - 1]?.date;
87
- if (!n) {
88
- const l = /* @__PURE__ */ new Date();
89
- return {
90
- year: l.getFullYear(),
91
- month: l.getMonth(),
92
- weekOfMonth: 1,
93
- startDate: l,
94
- endDate: l
95
- };
96
- }
97
- const s = new Date(n.getFullYear(), n.getMonth(), 1).getDay(), i = n.getDate(), a = Math.ceil((i + s) / 7);
98
- return {
99
- year: n.getFullYear(),
100
- month: n.getMonth(),
101
- weekOfMonth: a,
102
- startDate: n,
103
- endDate: t || n
104
- };
105
- }, []), oe = m.useCallback((e) => {
106
- if (N === "single") {
107
- const n = e;
108
- f ? (z(n), b?.(n)) : _?.(n);
109
- } else if (N === "multiple") {
110
- const t = (f ? k : S) || [], r = (a, l) => a.year === l.year && a.month === l.month && a.weekOfMonth === l.weekOfMonth, i = t.some((a) => r(a, e)) ? t.filter((a) => !r(a, e)) : [...t, e];
111
- f ? (z(i), b?.(i.length > 0 ? i : void 0)) : _?.(i.length > 0 ? i : void 0);
112
- } else if (N === "range") {
113
- const n = f ? k : S;
114
- if (!n?.from || n.to) {
115
- const t = { from: e };
116
- f ? (z(t), b?.(t)) : _?.(t);
117
- } else {
118
- const t = {
119
- from: n.from,
120
- to: e
121
- };
122
- e.startDate < n.from.startDate && (t.from = e, t.to = n.from), f ? (z(t), b?.(t)) : _?.(t);
84
+ d.useEffect(() => {
85
+ R && (ce(R), ve(R.getFullYear()));
86
+ }, [R]);
87
+ const [I, re] = d.useState(S), [z, ne] = d.useState(w), [be, ve] = d.useState(te.getFullYear());
88
+ d.useEffect(() => {
89
+ ee(x), re(S), ne(w);
90
+ }, [x, S, w]);
91
+ const M = (e) => {
92
+ ce(e), ve(e.getFullYear()), _e?.(e);
93
+ }, fe = d.useCallback((e) => {
94
+ let n;
95
+ return e instanceof Date ? n = e : n = e.days.find((t) => !t.outside)?.date || e.days[0]?.date || /* @__PURE__ */ new Date(), He(n, {
96
+ calendarType: Y,
97
+ fiscalMode: Z,
98
+ selectionMode: ie,
99
+ fiscalMonthPattern: V,
100
+ fiscalYearStartMonth: he,
101
+ weekStartsOn: B
102
+ });
103
+ }, [Y, Z, ie, V, he, B]), ue = d.useCallback((e) => {
104
+ const n = (t, r) => t.year === r.year && t.month === r.month && t.weekOfMonth === r.weekOfMonth;
105
+ if (h)
106
+ re((t) => {
107
+ let r;
108
+ if (y === "single")
109
+ r = e;
110
+ else if (y === "multiple") {
111
+ const a = t || [];
112
+ r = a.some((s) => n(s, e)) ? a.filter((s) => !n(s, e)) : [...a, e];
113
+ } else if (y === "range") {
114
+ const a = t;
115
+ if (!a?.from || a.to)
116
+ r = { from: e };
117
+ else {
118
+ const l = { from: a.from, to: e };
119
+ e.startDate < a.from.startDate && (l.from = e, l.to = a.from), r = l;
120
+ }
121
+ }
122
+ return A?.(r), r;
123
+ });
124
+ else if (y === "single")
125
+ A?.(e);
126
+ else if (y === "multiple") {
127
+ const t = S || [], a = t.some((l) => n(l, e)) ? t.filter((l) => !n(l, e)) : [...t, e];
128
+ A?.(a.length > 0 ? a : void 0);
129
+ } else if (y === "range") {
130
+ const t = S;
131
+ if (!t?.from || t.to)
132
+ A?.({ from: e });
133
+ else {
134
+ const r = { from: t.from, to: e };
135
+ e.startDate < t.from.startDate && (r.from = e, r.to = t.from), A?.(r);
123
136
  }
124
137
  }
125
- }, [N, f, k, S, _, b]), be = m.useCallback((e, n) => {
126
- const t = { year: e, month: n };
127
- if (D === "single")
128
- f ? (A(t), b?.(t)) : C?.(t);
129
- else if (D === "multiple") {
130
- const s = (f ? v : x) || [], i = (d, y) => d.year === y.year && d.month === y.month, l = s.some((d) => i(d, t)) ? s.filter((d) => !i(d, t)) : [...s, t];
131
- f ? (A(l), b?.(l.length > 0 ? l : void 0)) : C?.(l.length > 0 ? l : void 0);
132
- } else if (D === "range") {
133
- const r = f ? v : x;
134
- if (!r?.from || r.to) {
135
- const s = { from: t };
136
- f ? (A(s), b?.(s)) : C?.(s);
137
- } else {
138
- const s = new Date(r.from.year, r.from.month, 1), i = new Date(t.year, t.month, 1);
139
- let a;
140
- i < s ? a = { from: t, to: r.from } : a = { from: r.from, to: t }, f ? (A(a), b?.(a)) : C?.(a);
138
+ }, [y, h, S, A]), Se = d.useCallback((e, n) => {
139
+ const t = { year: e, month: n }, r = (a, l) => a.year === l.year && a.month === l.month;
140
+ if (h)
141
+ ne((a) => {
142
+ let l;
143
+ if (b === "single")
144
+ l = t;
145
+ else if (b === "multiple") {
146
+ const s = a || [];
147
+ l = s.some((o) => r(o, t)) ? s.filter((o) => !r(o, t)) : [...s, t];
148
+ } else if (b === "range") {
149
+ const s = a;
150
+ if (!s?.from || s.to)
151
+ l = { from: t };
152
+ else {
153
+ const i = new Date(s.from.year, s.from.month, 1);
154
+ new Date(t.year, t.month, 1) < i ? l = { from: t, to: s.from } : l = { from: s.from, to: t };
155
+ }
156
+ }
157
+ return N?.(l), l;
158
+ });
159
+ else if (b === "single")
160
+ N?.(t);
161
+ else if (b === "multiple") {
162
+ const a = w || [], s = a.some((i) => r(i, t)) ? a.filter((i) => !r(i, t)) : [...a, t];
163
+ N?.(s.length > 0 ? s : void 0);
164
+ } else if (b === "range") {
165
+ const a = w;
166
+ if (!a?.from || a.to)
167
+ N?.({ from: t });
168
+ else {
169
+ const l = new Date(a.from.year, a.from.month, 1);
170
+ new Date(t.year, t.month, 1) < l ? N?.({ from: t, to: a.from }) : N?.({ from: a.from, to: t });
141
171
  }
142
172
  }
143
- }, [D, f, v, x, C, b]), ce = m.useCallback(() => {
144
- let e = V, n = F;
145
- Y && (e = Math.max(e, Y.getFullYear())), j && (n = Math.min(n, j.getFullYear()));
173
+ }, [b, h, w, N]), pe = d.useCallback(() => {
174
+ let e = se, n = le;
175
+ C && (e = Math.max(e, C.getFullYear())), _ && (n = Math.min(n, _.getFullYear()));
146
176
  const t = [];
147
177
  for (let r = e; r <= n; r++)
148
178
  t.push({ label: r.toString(), value: r.toString() });
149
179
  return t;
150
- }, [V, F, Y, j]), ve = m.useCallback((e) => ze.map((t, r) => ({
180
+ }, [se, le, C, _]), Ae = d.useCallback((e) => Pe.map((t, r) => ({
151
181
  label: t,
152
182
  value: r.toString()
153
183
  })).filter((t, r) => {
154
- const s = new Date(e, r, 15);
155
- return !(Y && s < new Date(Y.getFullYear(), Y.getMonth(), 1) || j && s > new Date(j.getFullYear(), j.getMonth(), 1) || R && s < new Date(R.getFullYear(), R.getMonth(), 1) || H && s > new Date(H.getFullYear(), H.getMonth(), 1));
156
- }), [Y, j, R, H]), L = m.useMemo(() => {
184
+ const a = new Date(e, r, 1);
185
+ return !(C && a < new Date(C.getFullYear(), C.getMonth(), 1) || _ && a > new Date(_.getFullYear(), _.getMonth(), 1) || L && a < new Date(L.getFullYear(), L.getMonth(), 1) || W && a > new Date(W.getFullYear(), W.getMonth(), 1));
186
+ }), [C, _, L, W]), q = d.useMemo(() => {
157
187
  if (u !== "week") return;
158
- const e = f ? k : S;
188
+ const e = h ? I : S;
159
189
  if (!e) return;
160
190
  const n = [], t = (r) => {
161
- let s = new Date(r.startDate);
162
- s.setHours(0, 0, 0, 0);
163
- const i = new Date(r.endDate);
164
- for (i.setHours(0, 0, 0, 0); s <= i; )
165
- n.push(new Date(s)), s.setDate(s.getDate() + 1);
191
+ let a = new Date(r.startDate);
192
+ a.setHours(0, 0, 0, 0);
193
+ const l = new Date(r.endDate);
194
+ for (l.setHours(0, 0, 0, 0); a <= l; )
195
+ n.push(new Date(a)), a.setDate(a.getDate() + 1);
166
196
  };
167
197
  if (Array.isArray(e))
168
198
  e.forEach(t);
@@ -173,136 +203,133 @@ function We({
173
203
  else {
174
204
  let r = new Date(e.from.startDate);
175
205
  r.setHours(0, 0, 0, 0);
176
- const s = new Date(e.to.endDate);
177
- for (s.setHours(0, 0, 0, 0); r <= s; )
206
+ const a = new Date(e.to.endDate);
207
+ for (a.setHours(0, 0, 0, 0); r <= a; )
178
208
  n.push(new Date(r)), r.setDate(r.getDate() + 1);
179
209
  }
180
210
  } else
181
211
  t(e);
182
212
  return n;
183
- }, [u, f, k, S]), ye = m.useMemo(() => {
184
- if (u !== "week" || !L || L.length === 0)
213
+ }, [u, h, I, S]), je = d.useMemo(() => {
214
+ if (u !== "week" || !q || q.length === 0)
185
215
  return { range_start: [], range_middle: [], range_end: [] };
186
- const e = [...L].sort((a, l) => a.getTime() - l.getTime()), n = [], t = [], r = [], s = (a, l) => {
187
- if (l === 0) return !1;
188
- const d = e[l - 1];
189
- return a.getTime() - d.getTime() <= 1440 * 60 * 1e3;
190
- }, i = (a, l) => l === e.length - 1 ? !1 : e[l + 1].getTime() - a.getTime() <= 1440 * 60 * 1e3;
191
- return e.forEach((a, l) => {
192
- const d = s(a, l), y = i(a, l), O = a.getDate() === 1, Q = new Date(a);
193
- Q.setDate(a.getDate() + 1);
194
- const ee = Q.getDate() === 1;
195
- (!d || O) && (!y || ee) ? (n.push(a), r.push(a)) : !d || O ? n.push(a) : !y || ee ? r.push(a) : t.push(a);
216
+ const e = [...q].sort((s, i) => s.getTime() - i.getTime()), n = [], t = [], r = [], a = (s, i) => {
217
+ if (i === 0) return !1;
218
+ const o = e[i - 1];
219
+ return s.getTime() - o.getTime() <= 1440 * 60 * 1e3;
220
+ }, l = (s, i) => i === e.length - 1 ? !1 : e[i + 1].getTime() - s.getTime() <= 1440 * 60 * 1e3;
221
+ return e.forEach((s, i) => {
222
+ const o = a(s, i), g = l(s, i);
223
+ !o && !g ? (n.push(s), r.push(s)) : o ? g ? t.push(s) : r.push(s) : n.push(s);
196
224
  }), {
197
225
  range_start: n,
198
226
  range_middle: t,
199
227
  range_end: r
200
228
  };
201
- }, [u, L]), we = m.useCallback((e) => {
229
+ }, [u, q]), ze = d.useCallback((e) => {
202
230
  if (u === "week" && e) {
203
231
  const n = Array.isArray(e) ? e[e.length - 1] : e instanceof Date ? e : void 0;
204
232
  if (n) {
205
- const t = ie(n);
206
- oe(t);
233
+ const t = fe(n);
234
+ ue(t);
207
235
  return;
208
236
  }
209
237
  }
210
- f ? (G(e), b?.(e)) : $?.(e);
211
- }, [f, $, b, u, ie, oe]), De = m.useCallback(() => {
212
- u === "week" ? (_?.(k), q?.(k)) : u === "month" ? (C?.(v), q?.(v)) : ($?.(J), q?.(J));
213
- }, [J, k, v, $, _, C, q, u]), Ne = m.useCallback(() => {
214
- u === "week" ? z(S) : u === "month" ? A(x) : G(h), re?.();
215
- }, [h, S, x, re, u]), Se = m.useCallback(() => {
216
- u === "week" ? (z(void 0), f || _?.(void 0)) : u === "month" ? (A(void 0), f || C?.(void 0)) : (G(void 0), f || $?.(void 0)), ae?.();
217
- }, [f, $, _, C, ae, u]), _e = m.useCallback((e, n) => {
218
- const t = f ? v : x;
238
+ h && ee(e), k?.(e);
239
+ }, [h, k, u, fe, ue]), Ye = d.useCallback(() => {
240
+ u === "week" ? (A?.(I), X?.(I)) : u === "month" ? (N?.(z), X?.(z)) : (k?.(T), X?.(T));
241
+ }, [T, I, z, k, A, N, X, u]), $e = d.useCallback(() => {
242
+ u === "week" ? re(S) : u === "month" ? ne(w) : ee(x), me?.();
243
+ }, [x, S, w, me, u]), ke = d.useCallback(() => {
244
+ u === "week" ? (re(void 0), h || A?.(void 0)) : u === "month" ? (ne(void 0), h || N?.(void 0)) : (ee(void 0), h || k?.(void 0)), ge?.();
245
+ }, [h, k, A, N, ge, u]), Oe = d.useCallback((e, n) => {
246
+ const t = h ? z : w;
219
247
  if (!t) return !1;
220
248
  if (Array.isArray(t))
221
249
  return t.some((r) => r.year === e && r.month === n);
222
250
  if ("from" in t) {
223
- const r = t, s = r.from, i = r.to, a = new Date(e, n, 1).getTime(), l = new Date(s.year, s.month, 1).getTime();
224
- if (!i) return a === l;
225
- const d = new Date(i.year, i.month, 1).getTime();
226
- return a >= l && a <= d;
251
+ const r = t, a = r.from, l = r.to, s = new Date(e, n, 1).getTime(), i = new Date(a.year, a.month, 1).getTime();
252
+ if (!l) return s === i;
253
+ const o = new Date(l.year, l.month, 1).getTime();
254
+ return s >= i && s <= o;
227
255
  } else {
228
256
  const r = t;
229
257
  return r.year === e && r.month === n;
230
258
  }
231
- }, [f, v, x]), Ce = m.useCallback((e, n) => {
232
- const t = f ? v : x;
259
+ }, [h, z, w]), Ee = d.useCallback((e, n) => {
260
+ const t = h ? z : w;
233
261
  if (!t || !("from" in t)) return { isStart: !1, isEnd: !1, isMiddle: !1 };
234
- const r = t, s = r.from, i = r.to, a = new Date(e, n, 1).getTime(), l = new Date(s.year, s.month, 1).getTime();
235
- if (!i) return { isStart: a === l, isEnd: !1, isMiddle: !1 };
236
- const d = new Date(i.year, i.month, 1).getTime();
262
+ const r = t, a = r.from, l = r.to, s = new Date(e, n, 1).getTime(), i = new Date(a.year, a.month, 1).getTime();
263
+ if (!l) return { isStart: s === i, isEnd: !1, isMiddle: !1 };
264
+ const o = new Date(l.year, l.month, 1).getTime();
237
265
  return {
238
- isStart: a === l,
239
- isEnd: a === d,
240
- isMiddle: a > l && a < d
266
+ isStart: s === i,
267
+ isEnd: s === o,
268
+ isMiddle: s > i && s < o
241
269
  };
242
- }, [f, v, x]), fe = ({ yearOffset: e = 0 }) => {
243
- const n = se + e;
244
- return /* @__PURE__ */ p("div", { className: "flex flex-col gap-4 p-3 min-w-[280px]", children: [
245
- /* @__PURE__ */ p("div", { className: "flex items-center justify-between", children: [
246
- e === 0 && /* @__PURE__ */ c(
247
- M,
270
+ }, [h, z, w]), ye = ({ yearOffset: e = 0 }) => {
271
+ const n = be + e;
272
+ return /* @__PURE__ */ D("div", { className: "flex flex-col gap-4 p-3 min-w-[280px]", children: [
273
+ /* @__PURE__ */ D("div", { className: "flex items-center justify-between", children: [
274
+ e === 0 && /* @__PURE__ */ f(
275
+ E,
248
276
  {
249
277
  variant: "ghost",
250
278
  size: "sm",
251
279
  className: "h-7 w-7 p-0",
252
- onClick: () => W(new Date(n - 1, se % 12, 1)),
253
- children: /* @__PURE__ */ c(de, { className: "h-4 w-4" })
280
+ onClick: () => M(new Date(n - 1, be % 12, 1)),
281
+ children: /* @__PURE__ */ f(we, { className: "h-4 w-4" })
254
282
  }
255
283
  ),
256
- /* @__PURE__ */ c("div", { className: "flex-1 flex justify-center items-center", children: /* @__PURE__ */ c(
257
- ne,
284
+ /* @__PURE__ */ f("div", { className: "flex-1 flex justify-center items-center", children: /* @__PURE__ */ f(
285
+ de,
258
286
  {
259
287
  value: { label: n.toString(), value: n.toString() },
260
288
  onChange: (t) => {
261
289
  if (t && "value" in t) {
262
290
  const r = parseInt(t.value) - e;
263
- W(new Date(r, 0, 1));
291
+ M(new Date(r, 0, 1));
264
292
  }
265
293
  },
266
- dropdownZIndex: 50,
267
294
  scrollToSelectedOnOpen: !0,
268
- options: ce(),
295
+ options: pe(),
269
296
  parentClassName: "flex justify-center items-center",
270
297
  className: "w-[200px]",
271
298
  menuWidth: "140px"
272
299
  }
273
300
  ) }),
274
- (D !== "range" || e === 1) && /* @__PURE__ */ c(
275
- M,
301
+ (b !== "range" || e === 1) && /* @__PURE__ */ f(
302
+ E,
276
303
  {
277
304
  variant: "ghost",
278
305
  size: "sm",
279
306
  className: "h-7 w-7 p-0",
280
- onClick: () => W(new Date(n + 1, 0, 1)),
281
- children: /* @__PURE__ */ c(me, { className: "h-4 w-4" })
307
+ onClick: () => M(new Date(n + 1, 0, 1)),
308
+ children: /* @__PURE__ */ f(De, { className: "h-4 w-4" })
282
309
  }
283
310
  )
284
311
  ] }),
285
- /* @__PURE__ */ c("div", { className: "grid grid-cols-4 gap-y-4 gap-x-0", children: Ae.map((t, r) => {
286
- const s = _e(n, r), { isStart: i, isEnd: a, isMiddle: l } = Ce(n, r), d = D === "range", y = f ? v : x, O = y && "to" in y && !!y.to;
287
- return /* @__PURE__ */ p("div", { className: "relative flex items-center justify-center h-10 w-full group", children: [
288
- d && O && (l || i || a) && /* @__PURE__ */ c("div", { className: o(
312
+ /* @__PURE__ */ f("div", { className: "grid grid-cols-4 gap-y-4 gap-x-0", children: Je.map((t, r) => {
313
+ const a = Oe(n, r), { isStart: l, isEnd: s, isMiddle: i } = Ee(n, r), o = b === "range", g = h ? z : w, v = g && "to" in g && !!g.to;
314
+ return /* @__PURE__ */ D("div", { className: "relative flex items-center justify-center h-10 w-full group", children: [
315
+ o && v && (i || l || s) && /* @__PURE__ */ f("div", { className: c(
289
316
  "absolute inset-y-0 inset-x-0 bg-accent",
290
- i && "rounded-l-full left-1/2 -ml-5",
291
- a && "rounded-r-full right-1/2 -mr-5",
292
- l && "inset-x-0",
293
- i && a && "rounded-full inset-x-2"
317
+ l && "rounded-l-full left-1/2 -ml-5",
318
+ s && "rounded-r-full right-1/2 -mr-5",
319
+ i && "inset-x-0",
320
+ l && s && "rounded-full inset-x-2"
294
321
  ) }),
295
- /* @__PURE__ */ c(
296
- M,
322
+ /* @__PURE__ */ f(
323
+ E,
297
324
  {
298
325
  variant: "ghost",
299
- onClick: () => be(n, r),
300
- className: o(
326
+ onClick: () => Se(n, r),
327
+ className: c(
301
328
  "relative z-10 w-10 h-10 p-0 text-sm font-normal rounded-lg transition-all",
302
- s && !d && "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",
303
- d && (i || a) && "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground rounded-lg",
304
- !s && "hover:bg-accent hover:text-accent-foreground border border-transparent hover:border-primary",
305
- l && "text-accent-foreground"
329
+ a && !o && "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",
330
+ o && (l || s) && "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground rounded-lg",
331
+ !a && "hover:bg-accent hover:text-accent-foreground border border-transparent hover:border-primary",
332
+ i && "text-accent-foreground"
306
333
  ),
307
334
  children: t
308
335
  }
@@ -311,158 +338,164 @@ function We({
311
338
  }) })
312
339
  ] });
313
340
  };
314
- return /* @__PURE__ */ p("div", { className: "flex flex-col ", children: [
315
- u === "month" ? /* @__PURE__ */ p("div", { className: "flex flex-col md:flex-row", children: [
316
- /* @__PURE__ */ c(fe, { yearOffset: 0 }),
317
- (D === "range" || D === "multiple") && /* @__PURE__ */ p("div", { className: "flex flex-row gap-0", children: [
318
- /* @__PURE__ */ c("div", { className: "w-[1px] bg-gray-200 my-4" }),
319
- /* @__PURE__ */ c(fe, { yearOffset: 1 })
341
+ return /* @__PURE__ */ D("div", { className: "flex flex-col ", "data-component": "calendar", children: [
342
+ u === "month" ? /* @__PURE__ */ D("div", { className: "flex flex-col md:flex-row", children: [
343
+ /* @__PURE__ */ f(ye, { yearOffset: 0 }),
344
+ (b === "range" || b === "multiple") && /* @__PURE__ */ D("div", { className: "flex flex-row gap-0", children: [
345
+ /* @__PURE__ */ f("div", { className: "w-[1px] bg-gray-200 my-4" }),
346
+ /* @__PURE__ */ f(ye, { yearOffset: 1 })
320
347
  ] })
321
348
  ] }) : (
322
349
  // @ts-ignore: TS mismatch due to dynamic union types.
323
350
  // FIX: Split rendering into separate `DayPicker` calls for 'single' | 'multiple' | 'range' to strictly match discriminated unions.
324
- /* @__PURE__ */ c(
325
- je,
351
+ /* @__PURE__ */ f(
352
+ Ie,
326
353
  {
327
- mode: u === "week" ? "multiple" : E,
328
- selected: u === "week" ? L : f ? J : h,
329
- onSelect: we,
330
- month: K,
331
- onMonthChange: W,
332
- showOutsideDays: w,
333
- modifiers: u === "week" ? ye : void 0,
334
- className: o(
335
- "bg-background group/calendar p-3 [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
354
+ mode: u === "week" ? "multiple" : J,
355
+ selected: u === "week" ? q : h ? T : x,
356
+ onSelect: ze,
357
+ month: te,
358
+ onMonthChange: M,
359
+ showOutsideDays: Y === "fiscal" ? !0 : p,
360
+ weekStartsOn: B,
361
+ modifiers: u === "week" ? je : void 0,
362
+ className: c(
363
+ "bg-background group/calendar p-2 [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
336
364
  String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
337
365
  String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
338
- X
366
+ ae
339
367
  ),
340
- captionLayout: B,
341
- fromDate: Y,
342
- toDate: j,
343
- fromMonth: R,
344
- toMonth: H,
345
- fromYear: V,
346
- toYear: F,
347
- numberOfMonths: E === "range" || E === "multiple" || N === "range" || N === "multiple" ? 2 : 1,
348
- weekStartsOn: 1,
368
+ captionLayout: K,
369
+ fromDate: C,
370
+ toDate: _,
371
+ disabled: [
372
+ ...F.disabled ? Array.isArray(F.disabled) ? F.disabled : [F.disabled] : [],
373
+ C ? { before: C } : void 0,
374
+ _ ? { after: _ } : void 0
375
+ ].filter(Boolean),
376
+ fromMonth: L,
377
+ toMonth: W,
378
+ fromYear: se,
379
+ toYear: le,
380
+ numberOfMonths: J === "range" || J === "multiple" || y === "range" || y === "multiple" ? 2 : 1,
349
381
  showWeekNumber: !0,
350
382
  formatters: {
351
383
  formatMonthDropdown: (e) => e.toLocaleString("default", { month: "short" }),
352
384
  formatWeekNumber: (e) => `W${e}`,
353
- ...U
385
+ ...Q
354
386
  },
355
387
  classNames: {
356
- root: o("w-fit", g.root),
357
- months: o(
358
- "relative flex flex-col gap-4 md:flex-row",
359
- g.months
388
+ root: c("w-fit", m.root),
389
+ months: c(
390
+ "relative flex flex-col gap-2 md:flex-row",
391
+ m.months
360
392
  ),
361
- month: o(
362
- "flex w-full flex-col gap-4 relative after:absolute after:top-[5.5rem] after:bottom-0 after:left-8 after:w-[1px] after:bg-gray-200",
363
- g.month
393
+ month: c(
394
+ "flex flex-1 min-w-[252px] flex-col gap-2 relative after:absolute after:top-[5.5rem] after:bottom-0 after:left-[30px] after:w-[1px] after:bg-gray-200",
395
+ m.month
364
396
  ),
365
- nav: o(
397
+ nav: c(
366
398
  "absolute inset-x-0 top-2 flex w-full items-center justify-between gap-1",
367
- g.nav
399
+ m.nav
368
400
  ),
369
- button_previous: o(
370
- ge({ variant: Z }),
401
+ button_previous: c(
402
+ Ne({ variant: P }),
371
403
  "h-[--cell-size] w-[--cell-size] select-none p-0.2 z-10 aria-disabled:opacity-50 flex items-center justify-center relative",
372
- g.button_previous
404
+ m.button_previous
373
405
  ),
374
- button_next: o(
375
- ge({ variant: Z }),
406
+ button_next: c(
407
+ Ne({ variant: P }),
376
408
  "h-[--cell-size] w-[--cell-size] select-none p-0.2 z-10 aria-disabled:opacity-50 flex items-center justify-center relative",
377
- g.button_next
409
+ m.button_next
378
410
  ),
379
- month_caption: o(
411
+ month_caption: c(
380
412
  "flex h-[--cell-size] w-full items-center justify-center px-[--cell-size] relative ",
381
- g.month_caption
413
+ m.month_caption
382
414
  ),
383
- dropdowns: o(
415
+ dropdowns: c(
384
416
  "flex h-[--cell-size] gap-1 items-center justify-center text-sm font-medium relative ",
385
- g.dropdowns
417
+ m.dropdowns
386
418
  ),
387
- caption_label: o(
419
+ caption_label: c(
388
420
  "select-none font-medium text-sm",
389
- g.caption_label
421
+ m.caption_label
390
422
  ),
391
- table: "w-full border-collapse table-fixed",
392
- weekdays: o("flex w-full relative after:absolute after:bottom-0 after:right-0 after:h-[1px] after:bg-gray-200 after:left-8", g.weekdays),
393
- weekday: o(
423
+ table: "w-full border-collapse",
424
+ weekdays: c("flex w-full relative after:absolute after:bottom-0 after:right-0 after:h-[1px] after:bg-gray-200 after:left-[30px]", m.weekdays),
425
+ weekday: c(
394
426
  "flex-1 select-none rounded-md font-normal text-center",
395
427
  "text-[11px] text-[#757575] pb-2",
396
- g.weekday
428
+ "[&:nth-child(2)]:pl-2",
429
+ m.weekday
397
430
  ),
398
- week: o("mt-2 flex w-full items-stretch group/week", g.week),
399
- week_number_header: o(
400
- "select-none font-normal text-center h-8 flex items-center justify-center",
401
- "text-[11px] text-[#757575] w-8 flex-shrink-0",
402
- g.week_number_header
431
+ week: c("mt-1 flex w-full items-stretch group/week", m.week),
432
+ week_number_header: c(
433
+ "select-none font-normal text-center h-[30px] flex items-center justify-center",
434
+ "text-[11px] text-[#757575] w-[30px] flex-shrink-0",
435
+ m.week_number_header
403
436
  ),
404
- week_number: o(
405
- "select-none flex items-center justify-center h-8",
406
- "text-[11px] text-[#757575] w-8 flex-shrink-0",
407
- g.week_number
437
+ week_number: c(
438
+ "select-none flex items-center justify-center h-[30px]",
439
+ "text-[11px] text-[#757575] w-[30px] flex-shrink-0 transition-colors",
440
+ u === "week" && "group-hover/week:bg-accent group-hover/week:rounded-l-lg",
441
+ m.week_number
408
442
  ),
409
- day: o(
410
- "group/day relative select-none p-0 text-center flex-1 h-8 flex items-center justify-center [&:nth-child(2)]:pl-2 rdp-day",
443
+ day: c(
444
+ "group/day relative select-none p-0 text-center flex-1 h-[30px] flex items-center justify-center [&:nth-child(2)]:pl-2 rdp-day",
411
445
  u === "week" && "group-hover/week:bg-accent [&:nth-child(2)]:group-hover/week:rounded-l-full [&:nth-child(8)]:group-hover/week:rounded-r-full",
412
446
  u === "week" && "[&.rdp-selected:nth-child(2)]:rounded-l-full [&.rdp-selected:nth-child(8)]:rounded-r-full",
413
- T?.day
447
+ G?.day
414
448
  ),
415
- range_start: o(
449
+ range_start: c(
416
450
  "bg-accent rounded-l-full",
417
- g.range_start
451
+ m.range_start
418
452
  ),
419
- range_middle: o("bg-accent rounded-none", g.range_middle),
420
- range_end: o("bg-accent rounded-r-full", g.range_end),
421
- today: o(
453
+ range_middle: c("bg-accent rounded-none", m.range_middle),
454
+ range_end: c("bg-accent rounded-r-full", m.range_end),
455
+ today: c(
422
456
  "text-primary",
423
- g.today
457
+ m.today
424
458
  ),
425
- outside: o(
426
- "invisible",
427
- g.outside
459
+ outside: c(
460
+ Y === "fiscal" || p ? "text-muted-foreground opacity-50" : "invisible",
461
+ m.outside
428
462
  ),
429
- disabled: o(
463
+ disabled: c(
430
464
  "text-muted-foreground opacity-50",
431
- g.disabled
465
+ m.disabled
432
466
  ),
433
- hidden: o("invisible", g.hidden),
434
- ...T
467
+ hidden: c("invisible", m.hidden),
468
+ ...G
435
469
  },
436
470
  components: {
437
- Root: ({ className: e, rootRef: n, ...t }) => /* @__PURE__ */ c(
471
+ Root: ({ className: e, rootRef: n, ...t }) => /* @__PURE__ */ f(
438
472
  "div",
439
473
  {
440
474
  "data-slot": "calendar",
441
475
  ref: n,
442
- className: o(e),
476
+ className: c(e),
443
477
  ...t
444
478
  }
445
479
  ),
446
- Chevron: ({ className: e, orientation: n, ...t }) => n === "left" ? /* @__PURE__ */ c(de, { className: o("size-4 text-foreground", e), ...t }) : n === "right" ? /* @__PURE__ */ c(
447
- me,
480
+ Chevron: ({ className: e, orientation: n, ...t }) => n === "left" ? /* @__PURE__ */ f(we, { className: c("size-4 text-foreground", e), ...t }) : n === "right" ? /* @__PURE__ */ f(
481
+ De,
448
482
  {
449
- className: o("size-4 text-foreground", e),
483
+ className: c("size-4 text-foreground", e),
450
484
  ...t
451
485
  }
452
- ) : /* @__PURE__ */ c("span", {}),
486
+ ) : /* @__PURE__ */ f("span", {}),
453
487
  MonthsDropdown: ({ value: e, onChange: n }) => {
454
- const t = K.getFullYear(), r = ve(t);
455
- return /* @__PURE__ */ c(
456
- ne,
488
+ const t = te.getFullYear(), r = Ae(t);
489
+ return /* @__PURE__ */ f(
490
+ de,
457
491
  {
458
- value: r.find((s) => s.value === e?.toString()),
459
- onChange: (s) => {
460
- if (s && "value" in s) {
461
- const i = parseInt(s.value), a = new Date(t, i, 1);
462
- W(a), n?.(i);
492
+ value: r.find((a) => a.value === e?.toString()),
493
+ onChange: (a) => {
494
+ if (a && "value" in a) {
495
+ const l = parseInt(a.value), s = new Date(t, l, 1);
496
+ M(s), n?.(l);
463
497
  }
464
498
  },
465
- dropdownZIndex: 250,
466
499
  scrollToSelectedOnOpen: !0,
467
500
  options: r,
468
501
  className: "w-[95px]",
@@ -474,18 +507,17 @@ function We({
474
507
  );
475
508
  },
476
509
  YearsDropdown: ({ value: e, onChange: n }) => {
477
- const t = ce();
478
- return /* @__PURE__ */ c(
479
- ne,
510
+ const t = pe();
511
+ return /* @__PURE__ */ f(
512
+ de,
480
513
  {
481
514
  value: t.find((r) => r.value === e?.toString()),
482
515
  onChange: (r) => {
483
516
  if (r && "value" in r) {
484
- const s = parseInt(r.value), i = new Date(s, K.getMonth(), 1);
485
- P(i), n?.(s);
517
+ const a = parseInt(r.value), l = new Date(a, te.getMonth(), 1);
518
+ ce(l), n?.(a);
486
519
  }
487
520
  },
488
- dropdownZIndex: 250,
489
521
  scrollToSelectedOnOpen: !0,
490
522
  options: t,
491
523
  className: "w-[76px]",
@@ -496,62 +528,70 @@ function We({
496
528
  }
497
529
  );
498
530
  },
499
- DayButton: (e) => /* @__PURE__ */ c(
500
- Oe,
531
+ DayButton: (e) => /* @__PURE__ */ f(
532
+ Le,
501
533
  {
502
534
  ...e,
503
535
  pickerType: u
504
536
  }
505
537
  ),
506
538
  WeekNumber: ({ week: e, ...n }) => {
507
- const t = e.days.find((ke) => !ke.outside)?.date;
539
+ const t = e.days.find((H) => !H.outside)?.date;
508
540
  if (!t)
509
- return /* @__PURE__ */ c("td", { ...n, className: o("select-none flex items-center justify-center h-8 text-[11px] text-[#757575] w-8 flex-shrink-0 rdp-week_number", n.className), children: /* @__PURE__ */ c("div", { className: "flex size-[--cell-size] items-center justify-center text-center" }) });
510
- const r = t.getFullYear(), s = t.getMonth(), a = new Date(r, s, 1).getDay(), l = a === 0 ? -6 : 1 - a, d = new Date(r, s, 1 + l), y = new Date(t), O = t.getDay(), Q = O === 0 ? -6 : 1 - O;
511
- y.setDate(t.getDate() + Q);
512
- const te = Math.floor((y.getTime() - d.getTime()) / (10080 * 60 * 1e3)) + 1, ue = `Week ${te}`;
513
- return u === "week" ? /* @__PURE__ */ c(
541
+ return /* @__PURE__ */ f("td", { ...n, className: c("select-none flex items-center justify-center h-8 text-[11px] text-[#757575] w-8 flex-shrink-0 rdp-week_number", n.className), children: /* @__PURE__ */ f("div", { className: "flex size-[--cell-size] items-center justify-center text-center" }) });
542
+ const r = t.getFullYear(), a = t.getMonth(), i = (new Date(r, a, 1).getDay() + 7 - B) % 7, o = new Date(r, a, 1 - i), g = new Date(t), $ = (t.getDay() + 7 - B) % 7;
543
+ g.setDate(t.getDate() - $);
544
+ const j = Math.round((g.getTime() - o.getTime()) / (10080 * 60 * 1e3)) + 1, U = `Week ${j}`;
545
+ return u === "week" ? /* @__PURE__ */ f(
514
546
  "td",
515
547
  {
516
548
  ...n,
517
- "aria-label": ue,
518
- className: o(
519
- "select-none flex items-center justify-center h-8 w-8 flex-shrink-0 rdp-week_number",
549
+ "aria-label": U,
550
+ "data-week-index": j,
551
+ "data-week-number": j,
552
+ className: c(
553
+ "select-none flex items-center justify-center h-[30px] w-[30px] flex-shrink-0 rdp-week_number cursor-pointer hover:bg-accent hover:text-accent-foreground group-hover/week:bg-accent group-hover/week:rounded-l-lg rounded-lg transition-colors",
520
554
  n.className
521
555
  ),
522
556
  scope: "row",
523
557
  role: "rowheader",
524
- children: /* @__PURE__ */ p("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-[#757575]", children: [
558
+ onClick: (H) => {
559
+ H.preventDefault(), H.stopPropagation(), ue(fe(e));
560
+ },
561
+ children: /* @__PURE__ */ D("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-[#757575]", children: [
525
562
  "W",
526
- te
563
+ j
527
564
  ] })
528
565
  }
529
- ) : /* @__PURE__ */ c(
566
+ ) : /* @__PURE__ */ f(
530
567
  "td",
531
568
  {
532
569
  ...n,
533
- "aria-label": ue,
534
- className: o("select-none flex items-center justify-center h-8 text-[11px] text-[#757575] w-8 flex-shrink-0 rdp-week_number", n.className),
570
+ "aria-label": U,
571
+ className: c(
572
+ "select-none flex items-center justify-center h-[30px] text-[11px] text-[#757575] w-[30px] flex-shrink-0 rdp-week_number",
573
+ n.className
574
+ ),
535
575
  scope: "row",
536
576
  role: "rowheader",
537
- children: /* @__PURE__ */ p("div", { className: "flex h-8 w-full items-center justify-center text-center", children: [
577
+ children: /* @__PURE__ */ D("div", { className: "flex h-8 w-full items-center justify-center text-center", children: [
538
578
  "W",
539
- te
579
+ j
540
580
  ] })
541
581
  }
542
582
  );
543
583
  },
544
- ...he
584
+ ...Ce
545
585
  },
546
- ...pe
586
+ ...F
547
587
  }
548
588
  )
549
589
  ),
550
- f && /* @__PURE__ */ p("div", { className: o("flex items-center gap-2 border-t pt-3 p-3", u === "month" && D !== "single" || E === "range" || N === "range" || N === "multiple" ? "justify-between" : "justify-end"), children: [
551
- E === "range" && u === "date" && /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-1 text-[#60697d] text-xs leading-[18px] font-medium", children: [
590
+ h && /* @__PURE__ */ D("div", { className: c("flex items-center gap-2 border-t pt-3 p-3", u === "month" && b !== "single" || J === "range" || y === "range" || y === "multiple" ? "justify-between" : "justify-end"), children: [
591
+ J === "range" && u === "date" && /* @__PURE__ */ D("div", { className: "flex flex-row items-center gap-1 text-[#60697d] text-xs leading-[18px] font-medium", children: [
552
592
  "Selected:",
553
- /* @__PURE__ */ c("span", { className: "text-[#0d152c] font-semibold", children: (() => {
554
- const e = J;
593
+ /* @__PURE__ */ f("span", { className: "text-[#0d152c] font-semibold", children: (() => {
594
+ const e = T;
555
595
  if (e?.from && e?.to) {
556
596
  const n = Math.abs(e.to.getTime() - e.from.getTime()), t = Math.ceil(n / (1e3 * 60 * 60 * 24)) + 1;
557
597
  return `${t} day${t !== 1 ? "s" : ""}`;
@@ -559,27 +599,52 @@ function We({
559
599
  return "0 days";
560
600
  })() })
561
601
  ] }),
562
- u === "week" && (N === "range" || N === "multiple") && /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-1 text-[#60697d] text-xs leading-[18px] font-medium", children: [
602
+ u === "week" && (y === "range" || y === "multiple") && /* @__PURE__ */ D("div", { className: "flex flex-row items-center gap-1 text-[#60697d] text-xs leading-[18px] font-medium", children: [
563
603
  "Selected:",
564
- /* @__PURE__ */ c("span", { className: "text-[#0d152c] font-semibold", children: (() => {
565
- const e = k;
604
+ /* @__PURE__ */ f("span", { className: "text-[#0d152c] font-semibold", children: (() => {
605
+ const e = I;
566
606
  if (!e) return "0 weeks";
567
- if (Array.isArray(e)) {
568
- const n = e.length;
569
- return `${n} week${n !== 1 ? "s" : ""}`;
570
- } else if ("from" in e) {
571
- const { from: n, to: t } = e;
572
- if (!t) return "1 week";
573
- const r = n.startDate.getTime(), s = t.endDate.getTime(), a = Math.ceil((s - r) / (10080 * 60 * 1e3)) + 1;
574
- return `${a} week${a !== 1 ? "s" : ""}`;
607
+ const n = (i) => Date.UTC(i.getFullYear(), i.getMonth(), i.getDate()), t = (i) => {
608
+ const o = Math.floor(i / 7), g = i % 7, v = [];
609
+ return o > 0 && v.push(`${o} week${o !== 1 ? "s" : ""}`), (g > 0 || o === 0) && v.push(`${g} day${g !== 1 ? "s" : ""}`), v.join(" ");
610
+ }, r = Y === "fiscal" && ie === "fiscalMonth", a = Y === "fiscal", l = r ? "fiscal month" : a ? "fiscal week" : "week", s = r ? "fiscal months" : a ? "fiscal weeks" : "weeks";
611
+ if (Array.isArray(e))
612
+ if (a || r) {
613
+ const i = e.length;
614
+ return `${i} ${i !== 1 ? s : l}`;
615
+ } else {
616
+ let i = 0;
617
+ return e.forEach((o) => {
618
+ const g = n(o.startDate), v = n(o.endDate);
619
+ i += Math.round((v - g) / (1e3 * 60 * 60 * 24)) + 1;
620
+ }), t(i);
621
+ }
622
+ else if ("from" in e) {
623
+ const { from: i, to: o } = e;
624
+ if (r) {
625
+ if (!o) return `1 ${l}`;
626
+ const g = n(i.startDate), v = n(o.endDate), $ = Math.round(Math.abs(v - g) / (1e3 * 60 * 60 * 24)) + 1, O = V ? V.reduce((U, H) => U + H, 0) / 12 : 4.33, j = Math.max(1, Math.round($ / (O * 7)));
627
+ return `${j} ${j !== 1 ? s : l}`;
628
+ } else if (a) {
629
+ if (!o) return `1 ${l}`;
630
+ const g = n(i.startDate), v = n(o.endDate), $ = Math.round((v - g) / (10080 * 60 * 1e3)), O = $ > 0 ? $ : 1;
631
+ return `${O} ${O !== 1 ? s : l}`;
632
+ } else {
633
+ if (!o) {
634
+ const O = n(i.startDate), j = n(i.endDate), U = Math.round((j - O) / (1e3 * 60 * 60 * 24)) + 1;
635
+ return t(U);
636
+ }
637
+ const g = n(i.startDate), v = n(o.endDate), $ = Math.round(Math.abs(v - g) / (1e3 * 60 * 60 * 24)) + 1;
638
+ return t($);
639
+ }
575
640
  } else
576
- return "1 week";
641
+ return `1 ${l}`;
577
642
  })() })
578
643
  ] }),
579
- u === "month" && (D === "range" || D === "multiple") && /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-1 text-[#60697d] text-xs leading-[18px] font-medium", children: [
644
+ u === "month" && (b === "range" || b === "multiple") && /* @__PURE__ */ D("div", { className: "flex flex-row items-center gap-1 text-[#60697d] text-xs leading-[18px] font-medium", children: [
580
645
  "Selected:",
581
- /* @__PURE__ */ c("span", { className: "text-[#0d152c] font-semibold", children: (() => {
582
- const e = v;
646
+ /* @__PURE__ */ f("span", { className: "text-[#0d152c] font-semibold", children: (() => {
647
+ const e = z;
583
648
  if (!e) return "0 months";
584
649
  if (Array.isArray(e)) {
585
650
  const n = e.length;
@@ -587,37 +652,37 @@ function We({
587
652
  } else if ("from" in e) {
588
653
  const n = e;
589
654
  if (!n.to) return "1 month";
590
- const t = new Date(n.from.year, n.from.month, 1), r = new Date(n.to.year, n.to.month, 1), s = (r.getFullYear() - t.getFullYear()) * 12 + (r.getMonth() - t.getMonth()) + 1;
591
- return `${s} month${s !== 1 ? "s" : ""}`;
655
+ const t = new Date(n.from.year, n.from.month, 1), r = new Date(n.to.year, n.to.month, 1), a = (r.getFullYear() - t.getFullYear()) * 12 + (r.getMonth() - t.getMonth()) + 1;
656
+ return `${a} month${a !== 1 ? "s" : ""}`;
592
657
  } else
593
658
  return "1 month";
594
659
  })() })
595
660
  ] }),
596
- /* @__PURE__ */ p("div", { className: "flex items-center gap-2", children: [
597
- /* @__PURE__ */ c(
598
- M,
661
+ /* @__PURE__ */ D("div", { className: "flex items-center gap-2", children: [
662
+ /* @__PURE__ */ f(
663
+ E,
599
664
  {
600
665
  variant: "link",
601
666
  size: "sm",
602
- onClick: Se,
667
+ onClick: ke,
603
668
  children: "Clear"
604
669
  }
605
670
  ),
606
- /* @__PURE__ */ c(
607
- M,
671
+ /* @__PURE__ */ f(
672
+ E,
608
673
  {
609
674
  variant: "outline",
610
675
  size: "sm",
611
- onClick: Ne,
676
+ onClick: $e,
612
677
  children: "Cancel"
613
678
  }
614
679
  ),
615
- /* @__PURE__ */ c(
616
- M,
680
+ /* @__PURE__ */ f(
681
+ E,
617
682
  {
618
683
  variant: "default",
619
684
  size: "sm",
620
- onClick: De,
685
+ onClick: Ye,
621
686
  children: "Apply"
622
687
  }
623
688
  )
@@ -625,44 +690,46 @@ function We({
625
690
  ] })
626
691
  ] });
627
692
  }
628
- function Oe({
629
- className: X,
630
- day: T,
631
- modifiers: w,
632
- pickerType: B,
633
- ...Z
693
+ function Le({
694
+ className: ae,
695
+ day: G,
696
+ modifiers: p,
697
+ pickerType: K,
698
+ ...P
634
699
  }) {
635
- const U = m.useRef(null);
636
- return m.useEffect(() => {
637
- w.focused && U.current?.focus();
638
- }, [w.focused]), /* @__PURE__ */ c(
639
- M,
700
+ const Q = d.useRef(null);
701
+ return d.useEffect(() => {
702
+ p.focused && Q.current?.focus();
703
+ }, [p.focused]), /* @__PURE__ */ f(
704
+ E,
640
705
  {
641
- ref: U,
706
+ ref: Q,
642
707
  variant: "ghost",
643
708
  size: "sm",
644
- "data-day": T.date.toLocaleDateString(),
645
- "data-selected-single": w.selected && !w.range_start && !w.range_end && !w.range_middle,
646
- "data-range-start": w.range_start,
647
- "data-range-end": w.range_end,
648
- "data-range-middle": w.range_middle,
649
- className: o(
709
+ "data-day": G.date.toLocaleDateString(),
710
+ "data-selected-single": p.selected && !p.range_start && !p.range_end && !p.range_middle,
711
+ "data-range-start": p.range_start,
712
+ "data-range-end": p.range_end,
713
+ "data-range-middle": p.range_middle,
714
+ className: c(
650
715
  "gap-2 whitespace-nowrap focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 px-3 rounded-lg flex items-center justify-center font-normal transition-colors w-5 h-5 border border-transparent focus-visible:outline-none text-sm rdp-day rdp-day_button",
651
716
  // Hover styling
652
- B !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-primary",
653
- B === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
717
+ K !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-primary",
718
+ K === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
654
719
  // Selection state
655
720
  "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[selected-single=true]:rounded-lg data-[selected-single=true]:border-transparent",
656
721
  "data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-start=true]:rounded-lg data-[range-start=true]:border-transparent",
657
722
  "data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-end=true]:rounded-lg data-[range-end=true]:border-transparent",
658
723
  "data-[range-middle=true]:text-accent-foreground data-[range-middle=true]:rounded-none",
659
- X
724
+ ae
660
725
  ),
661
- ...Z
726
+ "data-component": "calendar-day",
727
+ ...P,
728
+ disabled: P.disabled || p.disabled
662
729
  }
663
730
  );
664
731
  }
665
732
  export {
666
- We as Calendar,
667
- Oe as CalendarDayButton
733
+ Qe as Calendar,
734
+ Le as CalendarDayButton
668
735
  };