impact-nova 1.2.0 → 1.2.1

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