impact-nova 1.6.1 → 1.6.3

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.
@@ -1,73 +1,73 @@
1
1
  import { jsxs as Y, jsx as c } from "react/jsx-runtime";
2
2
  import * as d from "react";
3
- import { ChevronLeftIcon as we, ChevronRightIcon as ye } from "lucide-react";
4
- import { getDefaultClassNames as He, DayPicker as Be } from "react-day-picker";
3
+ import { ChevronLeftIcon as ye, ChevronRightIcon as Ne } from "lucide-react";
4
+ import { getDefaultClassNames as Be, DayPicker as Fe } from "react-day-picker";
5
5
  import { cn as f } from "../../lib/utils.js";
6
- import { Button as R } from "./button.js";
6
+ import { Button as P } from "./button.js";
7
7
  import "./button-variants.js";
8
- import ce from "./select/select.js";
9
- import { FISCAL_PATTERNS as Fe, resolveWeekSelection as Te } from "../../lib/fiscal-calendar.js";
10
- import { getIntlLocale as Ke, getDateFnsLocale as We } from "../../i18n/getDateFnsLocale.js";
11
- import { useImpactNovaI18n as qe } from "../../i18n/ImpactNovaI18nContext.js";
12
- const ue = d.createContext(0);
13
- function st({
14
- className: ae,
15
- classNames: G,
8
+ import ue from "./select/select.js";
9
+ import { FISCAL_PATTERNS as Te, resolveWeekSelection as Ke } from "../../lib/fiscal-calendar.js";
10
+ import { getIntlLocale as We, getDateFnsLocale as qe } from "../../i18n/getDateFnsLocale.js";
11
+ import { useImpactNovaI18n as Ge } from "../../i18n/ImpactNovaI18nContext.js";
12
+ const fe = d.createContext(0);
13
+ function ot({
14
+ className: se,
15
+ classNames: J,
16
16
  showOutsideDays: y = !1,
17
- captionLayout: J = "dropdown",
18
- buttonVariant: B = "ghost",
19
- formatters: Q,
20
- components: Ne,
17
+ captionLayout: Q = "dropdown",
18
+ buttonVariant: F = "ghost",
19
+ formatters: X,
20
+ components: Ce,
21
21
  showFooter: x = !0,
22
- onApply: X,
23
- onCancel: fe,
24
- onClear: de,
25
- mode: F = "single",
22
+ onApply: Z,
23
+ onCancel: de,
24
+ onClear: me,
25
+ mode: T = "single",
26
26
  selected: D,
27
27
  onSelect: U,
28
28
  // Week picker props
29
29
  pickerType: m = "date",
30
- weekMode: v = "single",
30
+ weekMode: p = "single",
31
31
  selectedWeeks: C,
32
- onWeekSelect: A,
33
- calendarType: L = "calendar",
34
- fiscalMode: Z = "basic",
35
- selectionMode: se = "week",
32
+ onWeekSelect: k,
33
+ calendarType: R = "calendar",
34
+ fiscalMode: V = "basic",
35
+ selectionMode: oe = "week",
36
36
  fiscalMonthPattern: le,
37
- fiscalYearStartMonth: me = 1,
38
- weekStartsOn: T = 1,
37
+ fiscalYearStartMonth: ge = 1,
38
+ weekStartsOn: K = 1,
39
39
  // Default Monday
40
40
  // Month picker props
41
41
  monthMode: w = "single",
42
42
  selectedMonths: N,
43
43
  onMonthSelect: _,
44
- month: H,
45
- defaultMonth: ge,
46
- onMonthChange: Ce,
47
- startMonth: Se,
48
- endMonth: _e,
49
- ...he
44
+ month: B,
45
+ defaultMonth: he,
46
+ onMonthChange: Se,
47
+ startMonth: _e,
48
+ endMonth: Ye,
49
+ ...xe
50
50
  }) {
51
- const { locale: V, t: h } = qe(), K = d.useMemo(() => Ke(V), [V]), Ye = d.useMemo(() => We(V), [V]), xe = d.useMemo(
51
+ const { locale: ee, t: h } = Ge(), W = d.useMemo(() => We(ee), [ee]), ke = d.useMemo(() => qe(ee), [ee]), be = d.useMemo(
52
52
  () => Array.from(
53
53
  { length: 12 },
54
- (e, n) => new Date(2024, n, 1).toLocaleString(K, { month: "long" })
54
+ (e, n) => new Date(2024, n, 1).toLocaleString(W, { month: "long" })
55
55
  ),
56
- [K]
56
+ [W]
57
57
  ), Ae = d.useMemo(
58
58
  () => Array.from(
59
59
  { length: 12 },
60
- (e, n) => new Date(2024, n, 1).toLocaleString(K, { month: "short" })
60
+ (e, n) => new Date(2024, n, 1).toLocaleString(W, { month: "short" })
61
61
  ),
62
- [K]
63
- ), ee = d.useMemo(() => {
64
- if (L === "fiscal") {
62
+ [W]
63
+ ), te = d.useMemo(() => {
64
+ if (R === "fiscal") {
65
65
  if (le) return le;
66
- if (Z === "advanced") return Fe["4-4-5"];
66
+ if (V === "advanced") return Te["4-4-5"];
67
67
  }
68
- }, [L, Z, le]), b = He(), je = d.useMemo(() => new Date(1900, 0, 1), []), Me = d.useMemo(() => new Date(2100, 11, 31), []), E = Se || je, P = _e || Me, [W, te] = d.useState(D), [j, be] = d.useState(() => {
69
- if (H) return H;
70
- if (ge) return ge;
68
+ }, [R, V, le]), b = Be(), je = d.useMemo(() => new Date(1900, 0, 1), []), Me = d.useMemo(() => new Date(2100, 11, 31), []), E = _e || je, L = Ye || Me, [q, ne] = d.useState(D), [A, pe] = d.useState(() => {
69
+ if (B) return B;
70
+ if (he) return he;
71
71
  if (D) {
72
72
  if (Array.isArray(D))
73
73
  return D[0] || /* @__PURE__ */ new Date();
@@ -79,35 +79,35 @@ function st({
79
79
  return /* @__PURE__ */ new Date();
80
80
  });
81
81
  d.useEffect(() => {
82
- H && (be(H), ve(H.getFullYear()));
83
- }, [H]);
84
- const [$, ne] = d.useState(C), [M, re] = d.useState(N), [ke, ve] = d.useState(j.getFullYear());
82
+ B && (pe(B), ve(B.getFullYear()));
83
+ }, [B]);
84
+ const [$, re] = d.useState(C), [j, ae] = d.useState(N), [ze, ve] = d.useState(A.getFullYear());
85
85
  d.useEffect(() => {
86
- te(D), ne(C), re(N);
86
+ ne(D), re(C), ae(N);
87
87
  }, [D, C, N]);
88
88
  const O = (e) => {
89
- be(e), ve(e.getFullYear()), Ce?.(e);
90
- }, oe = d.useCallback((e) => {
89
+ pe(e), ve(e.getFullYear()), Se?.(e);
90
+ }, ie = d.useCallback((e) => {
91
91
  let n;
92
- return e instanceof Date ? n = e : n = e.days.find((t) => !t.outside)?.date || e.days[0]?.date || /* @__PURE__ */ new Date(), Te(n, {
93
- calendarType: L,
94
- fiscalMode: Z,
95
- selectionMode: se,
96
- fiscalMonthPattern: ee,
97
- fiscalYearStartMonth: me,
98
- weekStartsOn: T
92
+ return e instanceof Date ? n = e : n = e.days.find((t) => !t.outside)?.date || e.days[0]?.date || /* @__PURE__ */ new Date(), Ke(n, {
93
+ calendarType: R,
94
+ fiscalMode: V,
95
+ selectionMode: oe,
96
+ fiscalMonthPattern: te,
97
+ fiscalYearStartMonth: ge,
98
+ weekStartsOn: K
99
99
  });
100
- }, [L, Z, se, ee, me, T]), ie = d.useCallback((e) => {
100
+ }, [R, V, oe, te, ge, K]), ce = d.useCallback((e) => {
101
101
  const n = (t, r) => t.year === r.year && t.month === r.month && t.weekOfMonth === r.weekOfMonth;
102
102
  if (x)
103
- ne((t) => {
103
+ re((t) => {
104
104
  let r;
105
- if (v === "single")
105
+ if (p === "single")
106
106
  r = e;
107
- else if (v === "multiple") {
107
+ else if (p === "multiple") {
108
108
  const a = t || [];
109
- r = a.some((l) => n(l, e)) ? a.filter((l) => !n(l, e)) : [...a, e];
110
- } else if (v === "range") {
109
+ r = a.some((o) => n(o, e)) ? a.filter((o) => !n(o, e)) : [...a, e];
110
+ } else if (p === "range") {
111
111
  const a = t;
112
112
  if (!a?.from || a.to)
113
113
  r = { from: e };
@@ -116,39 +116,39 @@ function st({
116
116
  e.startDate < a.from.startDate && (s.from = e, s.to = a.from), r = s;
117
117
  }
118
118
  }
119
- return A?.(r), r;
119
+ return k?.(r), r;
120
120
  });
121
- else if (v === "single")
122
- A?.(e);
123
- else if (v === "multiple") {
121
+ else if (p === "single")
122
+ k?.(e);
123
+ else if (p === "multiple") {
124
124
  const t = C || [], a = t.some((s) => n(s, e)) ? t.filter((s) => !n(s, e)) : [...t, e];
125
- A?.(a.length > 0 ? a : void 0);
126
- } else if (v === "range") {
125
+ k?.(a.length > 0 ? a : void 0);
126
+ } else if (p === "range") {
127
127
  const t = C;
128
128
  if (!t?.from || t.to)
129
- A?.({ from: e });
129
+ k?.({ from: e });
130
130
  else {
131
131
  const r = { from: t.from, to: e };
132
- e.startDate < t.from.startDate && (r.from = e, r.to = t.from), A?.(r);
132
+ e.startDate < t.from.startDate && (r.from = e, r.to = t.from), k?.(r);
133
133
  }
134
134
  }
135
- }, [v, x, C, A]), ze = d.useCallback((e, n) => {
135
+ }, [p, x, C, k]), Ie = d.useCallback((e, n) => {
136
136
  const t = { year: e, month: n }, r = (a, s) => a.year === s.year && a.month === s.month;
137
137
  if (x)
138
- re((a) => {
138
+ ae((a) => {
139
139
  let s;
140
140
  if (w === "single")
141
141
  s = t;
142
142
  else if (w === "multiple") {
143
- const l = a || [];
144
- s = l.some((u) => r(u, t)) ? l.filter((u) => !r(u, t)) : [...l, t];
143
+ const o = a || [];
144
+ s = o.some((u) => r(u, t)) ? o.filter((u) => !r(u, t)) : [...o, t];
145
145
  } else if (w === "range") {
146
- const l = a;
147
- if (!l?.from || l.to)
146
+ const o = a;
147
+ if (!o?.from || o.to)
148
148
  s = { from: t };
149
149
  else {
150
- const o = new Date(l.from.year, l.from.month, 1);
151
- new Date(t.year, t.month, 1) < o ? s = { from: t, to: l.from } : s = { from: l.from, to: t };
150
+ const l = new Date(o.from.year, o.from.month, 1);
151
+ new Date(t.year, t.month, 1) < l ? s = { from: t, to: o.from } : s = { from: o.from, to: t };
152
152
  }
153
153
  }
154
154
  return _?.(s), s;
@@ -156,8 +156,8 @@ function st({
156
156
  else if (w === "single")
157
157
  _?.(t);
158
158
  else if (w === "multiple") {
159
- const a = N || [], l = a.some((o) => r(o, t)) ? a.filter((o) => !r(o, t)) : [...a, t];
160
- _?.(l.length > 0 ? l : void 0);
159
+ const a = N || [], o = a.some((l) => r(l, t)) ? a.filter((l) => !r(l, t)) : [...a, t];
160
+ _?.(o.length > 0 ? o : void 0);
161
161
  } else if (w === "range") {
162
162
  const a = N;
163
163
  if (!a?.from || a.to)
@@ -167,18 +167,18 @@ function st({
167
167
  new Date(t.year, t.month, 1) < s ? _?.({ from: t, to: a.from }) : _?.({ from: a.from, to: t });
168
168
  }
169
169
  }
170
- }, [w, x, N, _]), pe = d.useCallback(() => {
171
- const e = E.getFullYear(), n = P.getFullYear(), t = [];
170
+ }, [w, x, N, _]), De = d.useCallback(() => {
171
+ const e = E.getFullYear(), n = L.getFullYear(), t = [];
172
172
  for (let r = e; r <= n; r++)
173
173
  t.push({ label: r.toString(), value: r.toString() });
174
174
  return t;
175
- }, [E, P]), Ie = d.useCallback((e) => xe.map((t, r) => ({
175
+ }, [E, L]), Pe = d.useCallback((e) => be.map((t, r) => ({
176
176
  label: t,
177
177
  value: r.toString()
178
178
  })).filter((t, r) => {
179
179
  const a = new Date(e, r, 1);
180
- return !(E && a < new Date(E.getFullYear(), E.getMonth(), 1) || P && a > new Date(P.getFullYear(), P.getMonth(), 1));
181
- }), [E, P, xe]), q = d.useMemo(() => {
180
+ return !(E && a < new Date(E.getFullYear(), E.getMonth(), 1) || L && a > new Date(L.getFullYear(), L.getMonth(), 1));
181
+ }), [E, L, be]), G = d.useMemo(() => {
182
182
  if (m !== "week") return;
183
183
  const e = x ? $ : C;
184
184
  if (!e) return;
@@ -206,73 +206,73 @@ function st({
206
206
  t(e);
207
207
  return n;
208
208
  }, [m, x, $, C]), Re = d.useMemo(() => {
209
- if (m !== "week" || !q || q.length === 0)
209
+ if (m !== "week" || !G || G.length === 0)
210
210
  return { range_start: [], range_middle: [], range_end: [] };
211
- const e = [...q].sort((i, g) => i.getTime() - g.getTime()), n = [], t = [], r = [], a = x ? $ : C, s = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
212
- v === "multiple" && Array.isArray(a) && a.forEach((i) => {
213
- const g = i.startDate.toISOString().split("T")[0], p = i.endDate.toISOString().split("T")[0];
214
- s.add(g), l.add(p);
211
+ const e = [...G].sort((i, g) => i.getTime() - g.getTime()), n = [], t = [], r = [], a = x ? $ : C, s = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
212
+ p === "multiple" && Array.isArray(a) && a.forEach((i) => {
213
+ const g = i.startDate.toISOString().split("T")[0], v = i.endDate.toISOString().split("T")[0];
214
+ s.add(g), o.add(v);
215
215
  });
216
- const o = (i, g) => {
216
+ const l = (i, g) => {
217
217
  if (g === 0) return !1;
218
- const p = e[g - 1];
219
- return i.getTime() - p.getTime() <= 1440 * 60 * 1e3;
218
+ const v = e[g - 1];
219
+ return i.getTime() - v.getTime() <= 1440 * 60 * 1e3;
220
220
  }, u = (i, g) => g === e.length - 1 ? !1 : e[g + 1].getTime() - i.getTime() <= 1440 * 60 * 1e3;
221
221
  return e.forEach((i, g) => {
222
- const p = i.toISOString().split("T")[0], k = s.has(p), S = l.has(p), z = o(i, g), I = u(i, g);
223
- v === "multiple" ? k ? n.push(i) : S ? r.push(i) : t.push(i) : !z && !I ? (n.push(i), r.push(i)) : z ? I ? t.push(i) : r.push(i) : n.push(i);
222
+ const v = i.toISOString().split("T")[0], M = s.has(v), S = o.has(v), z = l(i, g), I = u(i, g);
223
+ p === "multiple" ? M ? n.push(i) : S ? r.push(i) : t.push(i) : !z && !I ? (n.push(i), r.push(i)) : z ? I ? t.push(i) : r.push(i) : n.push(i);
224
224
  }), {
225
225
  range_start: n,
226
226
  range_middle: t,
227
227
  range_end: r
228
228
  };
229
- }, [m, q, v, x, $, C]), Le = d.useCallback((e) => {
229
+ }, [m, G, p, x, $, C]), Ee = d.useCallback((e) => {
230
230
  if (m === "week" && e) {
231
231
  const n = Array.isArray(e) ? e[e.length - 1] : e instanceof Date ? e : void 0;
232
232
  if (n) {
233
- const t = oe(n);
234
- ie(t);
233
+ const t = ie(n);
234
+ ce(t);
235
235
  return;
236
236
  }
237
237
  }
238
- x && te(e), U?.(e);
239
- }, [x, U, m, oe, ie]), Ee = d.useCallback(() => {
240
- m === "week" ? (A?.($), X?.($)) : m === "month" ? (_?.(M), X?.(M)) : (U?.(W), X?.(W));
241
- }, [W, $, M, U, A, _, X, m]), Pe = d.useCallback(() => {
242
- m === "week" ? ne(C) : m === "month" ? re(N) : te(D), fe?.();
243
- }, [D, C, N, fe, m]), $e = d.useCallback(() => {
244
- m === "week" ? (ne(void 0), x || A?.(void 0)) : m === "month" ? (re(void 0), x || _?.(void 0)) : (te(void 0), x || U?.(void 0)), de?.();
245
- }, [x, U, A, _, de, m]), Oe = d.useCallback((e, n) => {
246
- const t = x ? M : N;
238
+ x && ne(e), U?.(e);
239
+ }, [x, U, m, ie, ce]), Le = d.useCallback(() => {
240
+ m === "week" ? (k?.($), Z?.($)) : m === "month" ? (_?.(j), Z?.(j)) : (U?.(q), Z?.(q));
241
+ }, [q, $, j, U, k, _, Z, m]), $e = d.useCallback(() => {
242
+ m === "week" ? re(C) : m === "month" ? ae(N) : ne(D), de?.();
243
+ }, [D, C, N, de, m]), Oe = d.useCallback(() => {
244
+ m === "week" ? (re(void 0), x || k?.(void 0)) : m === "month" ? (ae(void 0), x || _?.(void 0)) : (ne(void 0), x || U?.(void 0)), me?.();
245
+ }, [x, U, k, _, me, m]), Ue = d.useCallback((e, n) => {
246
+ const t = x ? j : N;
247
247
  if (!t) return !1;
248
248
  if (Array.isArray(t))
249
249
  return t.some((r) => r.year === e && r.month === n);
250
250
  if ("from" in t) {
251
- const r = t, a = r.from, s = r.to, l = new Date(e, n, 1).getTime(), o = new Date(a.year, a.month, 1).getTime();
252
- if (!s) return l === o;
251
+ const r = t, a = r.from, s = r.to, o = new Date(e, n, 1).getTime(), l = new Date(a.year, a.month, 1).getTime();
252
+ if (!s) return o === l;
253
253
  const u = new Date(s.year, s.month, 1).getTime();
254
- return l >= o && l <= u;
254
+ return o >= l && o <= u;
255
255
  } else {
256
256
  const r = t;
257
257
  return r.year === e && r.month === n;
258
258
  }
259
- }, [x, M, N]), Ue = d.useCallback((e, n) => {
260
- const t = x ? M : N;
259
+ }, [x, j, N]), He = d.useCallback((e, n) => {
260
+ const t = x ? j : N;
261
261
  if (!t || !("from" in t)) return { isStart: !1, isEnd: !1, isMiddle: !1 };
262
- const r = t, a = r.from, s = r.to, l = new Date(e, n, 1).getTime(), o = new Date(a.year, a.month, 1).getTime();
263
- if (!s) return { isStart: l === o, isEnd: !1, isMiddle: !1 };
262
+ const r = t, a = r.from, s = r.to, o = new Date(e, n, 1).getTime(), l = new Date(a.year, a.month, 1).getTime();
263
+ if (!s) return { isStart: o === l, isEnd: !1, isMiddle: !1 };
264
264
  const u = new Date(s.year, s.month, 1).getTime();
265
265
  return {
266
- isStart: l === o,
267
- isEnd: l === u,
268
- isMiddle: l > o && l < u
266
+ isStart: o === l,
267
+ isEnd: o === u,
268
+ isMiddle: o > l && o < u
269
269
  };
270
- }, [x, M, N]), De = ({ yearOffset: e = 0 }) => {
271
- const n = ke + e;
270
+ }, [x, j, N]), we = ({ yearOffset: e = 0 }) => {
271
+ const n = ze + e;
272
272
  return /* @__PURE__ */ Y("div", { className: "flex flex-col gap-4 p-3 min-w-[280px]", children: [
273
273
  /* @__PURE__ */ Y("div", { className: "flex items-center justify-between", children: [
274
274
  e === 0 && /* @__PURE__ */ c(
275
- R,
275
+ P,
276
276
  {
277
277
  variant: "ghost",
278
278
  size: "icon",
@@ -280,62 +280,62 @@ function st({
280
280
  "aria-label": h("calendar.previousYear"),
281
281
  title: h("calendar.previousYear"),
282
282
  disabled: n <= E.getFullYear(),
283
- onClick: () => O(new Date(n - 1, j.getMonth(), 1)),
284
- children: /* @__PURE__ */ c(we, { className: "h-4 w-4" })
283
+ onClick: () => O(new Date(n - 1, A.getMonth(), 1)),
284
+ children: /* @__PURE__ */ c(ye, { className: "h-4 w-4" })
285
285
  }
286
286
  ),
287
287
  /* @__PURE__ */ c("div", { className: "flex-1 flex justify-center items-center", children: /* @__PURE__ */ c(
288
- ce,
288
+ ue,
289
289
  {
290
290
  value: { label: n.toString(), value: n.toString() },
291
291
  onChange: (t) => {
292
292
  if (t && "value" in t) {
293
293
  const r = parseInt(t.value) - e;
294
- O(new Date(r, j.getMonth(), 1));
294
+ O(new Date(r, A.getMonth(), 1));
295
295
  }
296
296
  },
297
297
  scrollToSelectedOnOpen: !0,
298
- options: pe(),
298
+ options: De(),
299
299
  parentClassName: "flex justify-center items-center",
300
300
  className: "w-[200px]",
301
301
  menuWidth: "140px"
302
302
  }
303
303
  ) }),
304
304
  (w === "single" || e === 1) && /* @__PURE__ */ c(
305
- R,
305
+ P,
306
306
  {
307
307
  variant: "ghost",
308
308
  size: "icon",
309
309
  className: "h-7 w-7",
310
310
  "aria-label": h("calendar.nextYear"),
311
311
  title: h("calendar.nextYear"),
312
- disabled: n >= P.getFullYear(),
313
- onClick: () => O(new Date(n + 1, j.getMonth(), 1)),
314
- children: /* @__PURE__ */ c(ye, { className: "h-4 w-4" })
312
+ disabled: n >= L.getFullYear(),
313
+ onClick: () => O(new Date(n + 1, A.getMonth(), 1)),
314
+ children: /* @__PURE__ */ c(Ne, { className: "h-4 w-4" })
315
315
  }
316
316
  )
317
317
  ] }),
318
318
  /* @__PURE__ */ c("div", { className: "grid grid-cols-4 gap-y-4 gap-x-0", children: Ae.map((t, r) => {
319
- const a = Oe(n, r), { isStart: s, isEnd: l, isMiddle: o } = Ue(n, r), u = w === "range", i = x ? M : N, g = i && "to" in i && !!i.to;
319
+ const a = Ue(n, r), { isStart: s, isEnd: o, isMiddle: l } = He(n, r), u = w === "range", i = x ? j : N, g = i && "to" in i && !!i.to;
320
320
  return /* @__PURE__ */ Y("div", { className: "relative flex items-center justify-center h-10 w-full group", children: [
321
- u && g && (o || s || l) && /* @__PURE__ */ c("div", { className: f(
321
+ u && g && (l || s || o) && /* @__PURE__ */ c("div", { className: f(
322
322
  "absolute inset-y-0 inset-x-0 bg-accent",
323
323
  s && "rounded-l-full left-1/2 -ml-5",
324
- l && "rounded-r-full right-1/2 -mr-5",
325
- o && "inset-x-0",
326
- s && l && "rounded-full inset-x-2"
324
+ o && "rounded-r-full right-1/2 -mr-5",
325
+ l && "inset-x-0",
326
+ s && o && "rounded-full inset-x-2"
327
327
  ) }),
328
328
  /* @__PURE__ */ c(
329
- R,
329
+ P,
330
330
  {
331
331
  variant: "ghost",
332
- onClick: () => ze(n, r),
332
+ onClick: () => Ie(n, r),
333
333
  className: f(
334
334
  "relative z-10 w-10 h-10 p-0 text-sm font-normal rounded-lg transition-all",
335
335
  a && !u && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground",
336
- u && (s || l) && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground rounded-lg",
336
+ u && (s || o) && "bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground rounded-lg",
337
337
  !a && "hover:bg-accent hover:text-accent-foreground border border-transparent hover:border-brand",
338
- o && "text-accent-foreground"
338
+ l && "text-accent-foreground"
339
339
  ),
340
340
  children: t
341
341
  }
@@ -346,42 +346,42 @@ function st({
346
346
  };
347
347
  return /* @__PURE__ */ Y("div", { className: "flex flex-col ", "data-component": "calendar", children: [
348
348
  m === "month" ? /* @__PURE__ */ Y("div", { className: "flex flex-col md:flex-row", children: [
349
- /* @__PURE__ */ c(De, { yearOffset: 0 }),
349
+ /* @__PURE__ */ c(we, { yearOffset: 0 }),
350
350
  (w === "range" || w === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row gap-0", children: [
351
351
  /* @__PURE__ */ c("div", { className: "w-[1px] bg-stroke-hairline my-4" }),
352
- /* @__PURE__ */ c(De, { yearOffset: 1 })
352
+ /* @__PURE__ */ c(we, { yearOffset: 1 })
353
353
  ] })
354
354
  ] }) : (
355
355
  // @ts-ignore: TS mismatch due to dynamic union types.
356
356
  // FIX: Split rendering into separate `DayPicker` calls for 'single' | 'multiple' | 'range' to strictly match discriminated unions.
357
357
  /* @__PURE__ */ c(
358
- Be,
358
+ Fe,
359
359
  {
360
- mode: m === "week" ? "multiple" : F,
361
- selected: m === "week" ? q : x ? W : D,
362
- onSelect: Le,
363
- month: j,
360
+ mode: m === "week" ? "multiple" : T,
361
+ selected: m === "week" ? G : x ? q : D,
362
+ onSelect: Ee,
363
+ month: A,
364
364
  onMonthChange: O,
365
- showOutsideDays: L === "fiscal" ? !0 : y,
366
- weekStartsOn: T,
365
+ showOutsideDays: R === "fiscal" ? !0 : y,
366
+ weekStartsOn: K,
367
367
  modifiers: m === "week" ? Re : void 0,
368
- locale: Ye,
368
+ locale: ke,
369
369
  className: f(
370
370
  "bg-canvas group/calendar p-2 [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
371
371
  String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
372
372
  String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
373
- ae
373
+ se
374
374
  ),
375
- captionLayout: J,
375
+ captionLayout: Q,
376
376
  startMonth: E,
377
- endMonth: P,
378
- disabled: he.disabled,
379
- numberOfMonths: F === "range" || F === "multiple" || v === "range" || v === "multiple" ? 2 : 1,
377
+ endMonth: L,
378
+ disabled: xe.disabled,
379
+ numberOfMonths: T === "range" || T === "multiple" || p === "range" || p === "multiple" ? 2 : 1,
380
380
  showWeekNumber: !0,
381
381
  formatters: {
382
- formatMonthDropdown: (e) => e.toLocaleString(K, { month: "short" }),
382
+ formatMonthDropdown: (e) => e.toLocaleString(W, { month: "short" }),
383
383
  formatWeekNumber: (e) => h("calendar.weekNumber", { number: e }),
384
- ...Q
384
+ ...X
385
385
  },
386
386
  classNames: {
387
387
  root: f("w-fit", b.root),
@@ -441,7 +441,7 @@ function st({
441
441
  "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",
442
442
  m === "week" && "group-hover/week:bg-accent [&:nth-child(2)]:group-hover/week:rounded-l-full [&:nth-child(8)]:group-hover/week:rounded-r-full",
443
443
  m === "week" && "[&.rdp-selected:nth-child(2)]:rounded-l-full [&.rdp-selected:nth-child(8)]:rounded-r-full",
444
- G?.day
444
+ J?.day
445
445
  ),
446
446
  range_start: f(
447
447
  "bg-accent rounded-l-full",
@@ -454,7 +454,7 @@ function st({
454
454
  b.today
455
455
  ),
456
456
  outside: f(
457
- L === "fiscal" || y ? "text-content-muted opacity-50" : "invisible",
457
+ R === "fiscal" || y ? "text-content-muted opacity-50" : "invisible",
458
458
  b.outside
459
459
  ),
460
460
  disabled: f(
@@ -462,7 +462,7 @@ function st({
462
462
  b.disabled
463
463
  ),
464
464
  hidden: f("invisible", b.hidden),
465
- ...G
465
+ ...J
466
466
  },
467
467
  components: {
468
468
  Root: ({ className: e, rootRef: n, ...t }) => /* @__PURE__ */ c(
@@ -474,17 +474,17 @@ function st({
474
474
  ...t
475
475
  }
476
476
  ),
477
- Chevron: ({ className: e, orientation: n, ...t }) => n === "left" ? /* @__PURE__ */ c(we, { className: f("size-4 text-content", e), ...t }) : n === "right" ? /* @__PURE__ */ c(
478
- ye,
477
+ Chevron: ({ className: e, orientation: n, ...t }) => n === "left" ? /* @__PURE__ */ c(ye, { className: f("size-4 text-content", e), ...t }) : n === "right" ? /* @__PURE__ */ c(
478
+ Ne,
479
479
  {
480
480
  className: f("size-4 text-content", e),
481
481
  ...t
482
482
  }
483
483
  ) : /* @__PURE__ */ c("span", {}),
484
484
  PreviousMonthButton: (e) => /* @__PURE__ */ c(
485
- R,
485
+ P,
486
486
  {
487
- variant: B,
487
+ variant: F,
488
488
  size: "icon",
489
489
  className: "h-7 w-7",
490
490
  "aria-label": h("calendar.previousMonth"),
@@ -493,9 +493,9 @@ function st({
493
493
  }
494
494
  ),
495
495
  NextMonthButton: (e) => /* @__PURE__ */ c(
496
- R,
496
+ P,
497
497
  {
498
- variant: B,
498
+ variant: F,
499
499
  size: "icon",
500
500
  className: "h-7 w-7",
501
501
  "aria-label": h("calendar.nextMonth"),
@@ -503,21 +503,21 @@ function st({
503
503
  ...e
504
504
  }
505
505
  ),
506
- MonthCaption: ({ displayIndex: e, ...n }) => /* @__PURE__ */ c(ue.Provider, { value: e, children: /* @__PURE__ */ c("div", { ...n }) }),
506
+ MonthCaption: ({ displayIndex: e, ...n }) => /* @__PURE__ */ c(fe.Provider, { value: e, children: /* @__PURE__ */ c("div", { ...n }) }),
507
507
  MonthsDropdown: ({ value: e }) => {
508
- const n = d.useContext(ue), t = n > 0, a = new Date(j.getFullYear(), j.getMonth() + n, 1).getFullYear(), s = Ie(a);
508
+ const n = d.useContext(fe), t = n > 0, a = new Date(A.getFullYear(), A.getMonth() + n, 1).getFullYear(), s = Pe(a);
509
509
  return /* @__PURE__ */ c(
510
- ce,
510
+ ue,
511
511
  {
512
- value: s.find((l) => l.value === e?.toString()),
513
- onChange: (l) => {
514
- if (l && "value" in l) {
515
- const o = parseInt(l.value);
512
+ value: s.find((o) => o.value === e?.toString()),
513
+ onChange: (o) => {
514
+ if (o && "value" in o) {
515
+ const l = parseInt(o.value);
516
516
  if (t) {
517
- const u = new Date(a, o - 1, 1);
517
+ const u = new Date(a, l - 1, 1);
518
518
  O(u);
519
519
  } else {
520
- const u = new Date(a, o, 1);
520
+ const u = new Date(a, l, 1);
521
521
  O(u);
522
522
  }
523
523
  }
@@ -533,20 +533,20 @@ function st({
533
533
  );
534
534
  },
535
535
  YearsDropdown: ({ value: e }) => {
536
- const t = d.useContext(ue) > 0, r = pe();
536
+ const t = d.useContext(fe) > 0, r = De();
537
537
  return /* @__PURE__ */ c(
538
- ce,
538
+ ue,
539
539
  {
540
540
  value: r.find((a) => a.value === e?.toString()),
541
541
  onChange: (a) => {
542
542
  if (a && "value" in a) {
543
543
  const s = parseInt(a.value);
544
544
  if (t) {
545
- const l = new Date(j.getFullYear(), j.getMonth() + 1, 1).getMonth(), o = new Date(s, l - 1, 1);
546
- O(o);
547
- } else {
548
- const l = new Date(s, j.getMonth(), 1);
545
+ const o = new Date(A.getFullYear(), A.getMonth() + 1, 1).getMonth(), l = new Date(s, o - 1, 1);
549
546
  O(l);
547
+ } else {
548
+ const o = new Date(s, A.getMonth(), 1);
549
+ O(o);
550
550
  }
551
551
  }
552
552
  },
@@ -561,7 +561,7 @@ function st({
561
561
  );
562
562
  },
563
563
  DayButton: (e) => /* @__PURE__ */ c(
564
- Ge,
564
+ Je,
565
565
  {
566
566
  ...e,
567
567
  pickerType: m
@@ -571,28 +571,35 @@ function st({
571
571
  const t = e.days.find((I) => !I.outside)?.date;
572
572
  if (!t)
573
573
  return /* @__PURE__ */ c("td", { ...n, className: f("select-none flex items-center justify-center h-8 text-[11px] text-content-muted 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" }) });
574
- const r = t.getFullYear(), a = t.getMonth(), o = (new Date(r, a, 1).getDay() + 7 - T) % 7, u = new Date(r, a, 1 - o), i = new Date(t), p = (t.getDay() + 7 - T) % 7;
575
- i.setDate(t.getDate() - p);
574
+ const r = t.getFullYear(), a = t.getMonth(), l = (new Date(r, a, 1).getDay() + 7 - K) % 7, u = new Date(r, a, 1 - l), i = new Date(t), v = (t.getDay() + 7 - K) % 7;
575
+ i.setDate(t.getDate() - v);
576
576
  const S = Math.round((i.getTime() - u.getTime()) / (10080 * 60 * 1e3)) + 1, z = h("calendar.weekLabel", { number: S });
577
- return m === "week" ? /* @__PURE__ */ c(
578
- "td",
579
- {
580
- ...n,
581
- "aria-label": z,
582
- "data-week-index": S,
583
- "data-week-number": S,
584
- className: f(
585
- "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",
586
- n.className
587
- ),
588
- scope: "row",
589
- role: "rowheader",
590
- onClick: (I) => {
591
- I.preventDefault(), I.stopPropagation(), ie(oe(e));
592
- },
593
- children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-content-muted", children: h("calendar.weekNumber", { number: S }) })
594
- }
595
- ) : /* @__PURE__ */ c(
577
+ if (m === "week") {
578
+ const I = () => {
579
+ t && ce(ie(t));
580
+ };
581
+ return /* @__PURE__ */ c(
582
+ "td",
583
+ {
584
+ "aria-label": z,
585
+ "data-week-index": S,
586
+ "data-week-number": S,
587
+ tabIndex: 0,
588
+ role: "button",
589
+ className: f(
590
+ "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"
591
+ ),
592
+ onClick: (H) => {
593
+ H.preventDefault(), H.stopPropagation(), I();
594
+ },
595
+ onKeyDown: (H) => {
596
+ (H.key === "Enter" || H.key === " ") && (H.preventDefault(), H.stopPropagation(), I());
597
+ },
598
+ children: /* @__PURE__ */ c("div", { className: "flex h-8 w-full items-center justify-center text-center text-[11px] text-content-muted", children: h("calendar.weekNumber", { number: S }) })
599
+ }
600
+ );
601
+ }
602
+ return /* @__PURE__ */ c(
596
603
  "td",
597
604
  {
598
605
  ...n,
@@ -607,17 +614,17 @@ function st({
607
614
  }
608
615
  );
609
616
  },
610
- ...Ne
617
+ ...Ce
611
618
  },
612
- ...he
619
+ ...xe
613
620
  }
614
621
  )
615
622
  ),
616
- x && /* @__PURE__ */ Y("div", { className: f("flex items-center gap-2 border-t pt-3 p-3", m === "month" && w !== "single" || F === "range" || v === "range" || v === "multiple" ? "justify-between" : "justify-end"), children: [
617
- F === "range" && m === "date" && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
623
+ x && /* @__PURE__ */ Y("div", { className: f("flex items-center gap-2 border-t pt-3 p-3", m === "month" && w !== "single" || T === "range" || p === "range" || p === "multiple" ? "justify-between" : "justify-end"), children: [
624
+ T === "range" && m === "date" && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
618
625
  "Selected:",
619
626
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
620
- const e = W;
627
+ const e = q;
621
628
  if (e?.from && e?.to) {
622
629
  const n = Math.abs(e.to.getTime() - e.from.getTime()), t = Math.ceil(n / (1e3 * 60 * 60 * 24)) + 1;
623
630
  return `${t} day${t !== 1 ? "s" : ""}`;
@@ -625,43 +632,43 @@ function st({
625
632
  return "0 days";
626
633
  })() })
627
634
  ] }),
628
- m === "week" && (v === "range" || v === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
635
+ m === "week" && (p === "range" || p === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
629
636
  "Selected:",
630
637
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
631
638
  const e = $;
632
639
  if (!e) return "0 weeks";
633
- const n = (o) => Date.UTC(o.getFullYear(), o.getMonth(), o.getDate()), t = (o) => {
634
- const u = Math.floor(o / 7), i = o % 7, g = [];
640
+ const n = (l) => Date.UTC(l.getFullYear(), l.getMonth(), l.getDate()), t = (l) => {
641
+ const u = Math.floor(l / 7), i = l % 7, g = [];
635
642
  return u > 0 && g.push(`${u} week${u !== 1 ? "s" : ""}`), (i > 0 || u === 0) && g.push(`${i} day${i !== 1 ? "s" : ""}`), g.join(" ");
636
- }, r = L === "fiscal" && se === "fiscalMonth", a = L === "fiscal", s = r ? "fiscal month" : a ? "fiscal week" : "week", l = r ? "fiscal months" : a ? "fiscal weeks" : "weeks";
643
+ }, r = R === "fiscal" && oe === "fiscalMonth", a = R === "fiscal", s = r ? "fiscal month" : a ? "fiscal week" : "week", o = r ? "fiscal months" : a ? "fiscal weeks" : "weeks";
637
644
  if (Array.isArray(e))
638
645
  if (a || r) {
639
- const o = e.length;
640
- return `${o} ${o !== 1 ? l : s}`;
646
+ const l = e.length;
647
+ return `${l} ${l !== 1 ? o : s}`;
641
648
  } else {
642
- let o = 0;
649
+ let l = 0;
643
650
  return e.forEach((u) => {
644
651
  const i = n(u.startDate), g = n(u.endDate);
645
- o += Math.round((g - i) / (1e3 * 60 * 60 * 24)) + 1;
646
- }), t(o);
652
+ l += Math.round((g - i) / (1e3 * 60 * 60 * 24)) + 1;
653
+ }), t(l);
647
654
  }
648
655
  else if ("from" in e) {
649
- const { from: o, to: u } = e;
656
+ const { from: l, to: u } = e;
650
657
  if (r) {
651
658
  if (!u) return `1 ${s}`;
652
- const i = n(o.startDate), g = n(u.endDate), p = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1, k = ee ? ee.reduce((z, I) => z + I, 0) / 12 : 4.33, S = Math.max(1, Math.round(p / (k * 7)));
653
- return `${S} ${S !== 1 ? l : s}`;
659
+ const i = n(l.startDate), g = n(u.endDate), v = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1, M = te ? te.reduce((z, I) => z + I, 0) / 12 : 4.33, S = Math.max(1, Math.round(v / (M * 7)));
660
+ return `${S} ${S !== 1 ? o : s}`;
654
661
  } else if (a) {
655
662
  if (!u) return `1 ${s}`;
656
- const i = n(o.startDate), g = n(u.endDate), p = Math.round((g - i) / (10080 * 60 * 1e3)), k = p > 0 ? p : 1;
657
- return `${k} ${k !== 1 ? l : s}`;
663
+ const i = n(l.startDate), g = n(u.endDate), v = Math.round((g - i) / (10080 * 60 * 1e3)), M = v > 0 ? v : 1;
664
+ return `${M} ${M !== 1 ? o : s}`;
658
665
  } else {
659
666
  if (!u) {
660
- const k = n(o.startDate), S = n(o.endDate), z = Math.round((S - k) / (1e3 * 60 * 60 * 24)) + 1;
667
+ const M = n(l.startDate), S = n(l.endDate), z = Math.round((S - M) / (1e3 * 60 * 60 * 24)) + 1;
661
668
  return t(z);
662
669
  }
663
- const i = n(o.startDate), g = n(u.endDate), p = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1;
664
- return t(p);
670
+ const i = n(l.startDate), g = n(u.endDate), v = Math.round(Math.abs(g - i) / (1e3 * 60 * 60 * 24)) + 1;
671
+ return t(v);
665
672
  }
666
673
  } else
667
674
  return `1 ${s}`;
@@ -670,7 +677,7 @@ function st({
670
677
  m === "month" && (w === "range" || w === "multiple") && /* @__PURE__ */ Y("div", { className: "flex flex-row items-center gap-1 text-content-tertiary text-xs leading-[18px] font-medium", children: [
671
678
  "Selected:",
672
679
  /* @__PURE__ */ c("span", { className: "text-content font-semibold", children: (() => {
673
- const e = M;
680
+ const e = j;
674
681
  if (!e) return "0 months";
675
682
  if (Array.isArray(e)) {
676
683
  const n = e.length;
@@ -686,29 +693,29 @@ function st({
686
693
  ] }),
687
694
  /* @__PURE__ */ Y("div", { className: "flex items-center gap-2", children: [
688
695
  /* @__PURE__ */ c(
689
- R,
696
+ P,
690
697
  {
691
698
  variant: "link",
692
699
  size: "sm",
693
- onClick: $e,
700
+ onClick: Oe,
694
701
  children: h("calendar.clear")
695
702
  }
696
703
  ),
697
704
  /* @__PURE__ */ c(
698
- R,
705
+ P,
699
706
  {
700
707
  variant: "outline",
701
708
  size: "sm",
702
- onClick: Pe,
709
+ onClick: $e,
703
710
  children: h("calendar.cancel")
704
711
  }
705
712
  ),
706
713
  /* @__PURE__ */ c(
707
- R,
714
+ P,
708
715
  {
709
716
  variant: "default",
710
717
  size: "sm",
711
- onClick: Ee,
718
+ onClick: Le,
712
719
  children: h("calendar.apply")
713
720
  }
714
721
  )
@@ -716,23 +723,23 @@ function st({
716
723
  ] })
717
724
  ] });
718
725
  }
719
- function Ge({
720
- className: ae,
721
- day: G,
726
+ function Je({
727
+ className: se,
728
+ day: J,
722
729
  modifiers: y,
723
- pickerType: J,
724
- ...B
730
+ pickerType: Q,
731
+ ...F
725
732
  }) {
726
- const Q = d.useRef(null);
733
+ const X = d.useRef(null);
727
734
  return d.useEffect(() => {
728
- y.focused && Q.current?.focus();
735
+ y.focused && X.current?.focus();
729
736
  }, [y.focused]), /* @__PURE__ */ c(
730
- R,
737
+ P,
731
738
  {
732
- ref: Q,
739
+ ref: X,
733
740
  variant: "ghost",
734
741
  size: "sm",
735
- "data-day": G.date.toLocaleDateString(),
742
+ "data-day": J.date.toLocaleDateString(),
736
743
  "data-selected-single": y.selected && !y.range_start && !y.range_end && !y.range_middle,
737
744
  "data-range-start": y.range_start,
738
745
  "data-range-end": y.range_end,
@@ -740,22 +747,22 @@ function Ge({
740
747
  className: f(
741
748
  "gap-2 whitespace-nowrap focus-visible:ring-1 focus-visible:ring-focus-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",
742
749
  // Hover styling
743
- J !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-brand",
744
- J === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
750
+ Q !== "week" && "hover:bg-accent hover:text-accent-foreground hover:border-brand",
751
+ Q === "week" && "hover:bg-transparent hover:text-inherit hover:border-transparent",
745
752
  // Selection state
746
753
  "data-[selected-single=true]:bg-brand data-[selected-single=true]:text-brand-foreground data-[selected-single=true]:rounded-lg data-[selected-single=true]:border-transparent",
747
754
  "data-[range-start=true]:bg-brand data-[range-start=true]:text-brand-foreground data-[range-start=true]:rounded-lg data-[range-start=true]:border-transparent",
748
755
  "data-[range-end=true]:bg-brand data-[range-end=true]:text-brand-foreground data-[range-end=true]:rounded-lg data-[range-end=true]:border-transparent",
749
756
  "data-[range-middle=true]:text-accent-foreground data-[range-middle=true]:rounded-none",
750
- ae
757
+ se
751
758
  ),
752
759
  "data-component": "calendar-day",
753
- ...B,
754
- disabled: B.disabled || y.disabled
760
+ ...F,
761
+ disabled: F.disabled || y.disabled
755
762
  }
756
763
  );
757
764
  }
758
765
  export {
759
- st as Calendar,
760
- Ge as CalendarDayButton
766
+ ot as Calendar,
767
+ Je as CalendarDayButton
761
768
  };