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.
- package/dist/components/ui/calendar.js +214 -199
- package/dist/components/ui/data-table/data-table-view-options.js +63 -42
- package/dist/components/ui/date-picker/date-picker.js +1 -1
- package/dist/components/ui/date-picker/date-range-picker.js +7 -7
- package/dist/components/ui/date-picker/month-picker.js +1 -1
- package/dist/components/ui/date-picker/month-range-picker.js +1 -1
- package/dist/components/ui/date-picker/multi-date-picker.js +26 -26
- package/dist/components/ui/date-picker/multi-month-picker.js +20 -20
- package/dist/components/ui/date-picker/multi-week-picker.js +11 -11
- package/dist/components/ui/date-picker/week-picker.js +1 -1
- package/dist/components/ui/date-picker/week-range-picker.js +7 -7
- package/dist/components/ui/prompt.js +4 -4
- package/dist/impact-nova.css +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
4
|
-
import { getDefaultClassNames as
|
|
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
|
|
6
|
+
import { Button as M } from "./button.js";
|
|
7
7
|
import "./button-variants.js";
|
|
8
|
-
import
|
|
9
|
-
import { FISCAL_PATTERNS as
|
|
10
|
-
const
|
|
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
|
-
],
|
|
24
|
-
function
|
|
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:
|
|
29
|
+
buttonVariant: L = "ghost",
|
|
30
30
|
formatters: G,
|
|
31
31
|
components: ve,
|
|
32
32
|
showFooter: h = !0,
|
|
33
33
|
onApply: K,
|
|
34
|
-
onCancel:
|
|
34
|
+
onCancel: ie,
|
|
35
35
|
onClear: ce,
|
|
36
|
-
mode:
|
|
36
|
+
mode: F = "single",
|
|
37
37
|
selected: x,
|
|
38
|
-
onSelect:
|
|
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:
|
|
47
|
-
fiscalMonthPattern:
|
|
46
|
+
selectionMode: ne = "week",
|
|
47
|
+
fiscalMonthPattern: re,
|
|
48
48
|
fiscalYearStartMonth: fe = 1,
|
|
49
|
-
weekStartsOn:
|
|
49
|
+
weekStartsOn: J = 1,
|
|
50
50
|
// Default Monday
|
|
51
51
|
// Month picker props
|
|
52
|
-
monthMode:
|
|
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:
|
|
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 (
|
|
65
|
-
if (Q === "advanced") return
|
|
64
|
+
if (re) return re;
|
|
65
|
+
if (Q === "advanced") return Re["4-4-5"];
|
|
66
66
|
}
|
|
67
|
-
}, [j, Q,
|
|
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 && (
|
|
81
|
+
R && (me(R), ge(R.getFullYear()));
|
|
82
82
|
}, [R]);
|
|
83
|
-
const [
|
|
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
|
|
88
|
-
|
|
89
|
-
},
|
|
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:
|
|
94
|
+
selectionMode: ne,
|
|
95
95
|
fiscalMonthPattern: X,
|
|
96
96
|
fiscalYearStartMonth: fe,
|
|
97
|
-
weekStartsOn:
|
|
97
|
+
weekStartsOn: J
|
|
98
98
|
});
|
|
99
|
-
}, [j, Q,
|
|
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
|
|
115
|
-
e.startDate < a.from.startDate && (
|
|
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((
|
|
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, _]),
|
|
135
|
-
const t = { year: e, month: n }, r = (a,
|
|
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
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
else if (
|
|
138
|
+
let o;
|
|
139
|
+
if (p === "single")
|
|
140
|
+
o = t;
|
|
141
|
+
else if (p === "multiple") {
|
|
142
142
|
const s = a || [];
|
|
143
|
-
|
|
144
|
-
} else if (
|
|
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
|
-
|
|
147
|
+
o = { from: t };
|
|
148
148
|
else {
|
|
149
|
-
const
|
|
150
|
-
new Date(t.year, t.month, 1) <
|
|
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?.(
|
|
153
|
+
return N?.(o), o;
|
|
154
154
|
});
|
|
155
|
-
else if (
|
|
155
|
+
else if (p === "single")
|
|
156
156
|
N?.(t);
|
|
157
|
-
else if (
|
|
158
|
-
const a = y || [], s = a.some((
|
|
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 (
|
|
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
|
|
166
|
-
new Date(t.year, t.month, 1) <
|
|
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
|
-
}, [
|
|
170
|
-
const e = z
|
|
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, $]),
|
|
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, $]),
|
|
180
|
+
}), [z, $]), W = d.useMemo(() => {
|
|
181
181
|
if (u !== "week") return;
|
|
182
|
-
const e = h ?
|
|
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
|
|
188
|
-
for (
|
|
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,
|
|
208
|
-
if (u !== "week" || !
|
|
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 = [...
|
|
211
|
-
if (
|
|
212
|
-
const
|
|
213
|
-
return s.getTime() -
|
|
214
|
-
},
|
|
215
|
-
return e.forEach((s,
|
|
216
|
-
const
|
|
217
|
-
!
|
|
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,
|
|
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 =
|
|
228
|
-
|
|
227
|
+
const t = ae(n);
|
|
228
|
+
se(t);
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
h && Z(e),
|
|
233
|
-
}, [h,
|
|
234
|
-
u === "week" ? (_?.(
|
|
235
|
-
}, [
|
|
236
|
-
u === "week" ? V(C) : u === "month" ? ee(y) : Z(x),
|
|
237
|
-
}, [x, C, y,
|
|
238
|
-
u === "week" ? (V(void 0), h || _?.(void 0)) : u === "month" ? (ee(void 0), h || N?.(void 0)) : (Z(void 0), h ||
|
|
239
|
-
}, [h,
|
|
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,
|
|
246
|
-
if (!
|
|
247
|
-
const
|
|
248
|
-
return s >=
|
|
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]),
|
|
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,
|
|
257
|
-
if (!
|
|
258
|
-
const
|
|
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 ===
|
|
261
|
-
isEnd: s ===
|
|
262
|
-
isMiddle: s >
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
276
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
(
|
|
297
|
-
|
|
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
|
-
|
|
304
|
-
|
|
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:
|
|
309
|
-
const a =
|
|
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
|
-
|
|
313
|
+
i && b && (l || o || s) && /* @__PURE__ */ c("div", { className: f(
|
|
312
314
|
"absolute inset-y-0 inset-x-0 bg-accent",
|
|
313
|
-
|
|
315
|
+
o && "rounded-l-full left-1/2 -ml-5",
|
|
314
316
|
s && "rounded-r-full right-1/2 -mr-5",
|
|
315
|
-
|
|
316
|
-
|
|
317
|
+
l && "inset-x-0",
|
|
318
|
+
o && s && "rounded-full inset-x-2"
|
|
317
319
|
) }),
|
|
318
320
|
/* @__PURE__ */ c(
|
|
319
|
-
|
|
321
|
+
M,
|
|
320
322
|
{
|
|
321
323
|
variant: "ghost",
|
|
322
|
-
onClick: () =>
|
|
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 && !
|
|
326
|
-
|
|
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
|
-
|
|
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
|
-
(
|
|
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
|
-
|
|
350
|
+
Ie,
|
|
349
351
|
{
|
|
350
|
-
mode: u === "week" ? "multiple" :
|
|
351
|
-
selected: u === "week" ?
|
|
352
|
-
onSelect:
|
|
353
|
-
month:
|
|
354
|
-
onMonthChange:
|
|
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:
|
|
357
|
-
modifiers: u === "week" ?
|
|
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:
|
|
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(
|
|
467
|
-
|
|
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
|
-
|
|
476
|
+
M,
|
|
475
477
|
{
|
|
476
|
-
variant:
|
|
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
|
-
|
|
486
|
+
M,
|
|
485
487
|
{
|
|
486
|
-
variant:
|
|
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
|
-
|
|
494
|
-
|
|
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
|
-
|
|
499
|
+
oe,
|
|
497
500
|
{
|
|
498
|
-
value:
|
|
499
|
-
onChange: (
|
|
500
|
-
if (
|
|
501
|
-
const l = parseInt(
|
|
502
|
-
|
|
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:
|
|
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
|
|
516
|
-
const t = he();
|
|
524
|
+
YearsDropdown: ({ value: e }) => {
|
|
525
|
+
const t = d.useContext(le) > 0, r = he();
|
|
517
526
|
return /* @__PURE__ */ c(
|
|
518
|
-
|
|
527
|
+
oe,
|
|
519
528
|
{
|
|
520
|
-
value:
|
|
521
|
-
onChange: (
|
|
522
|
-
if (
|
|
523
|
-
const
|
|
524
|
-
|
|
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:
|
|
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
|
-
|
|
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((
|
|
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(),
|
|
549
|
-
g.setDate(t.getDate() -
|
|
550
|
-
const
|
|
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":
|
|
556
|
-
"data-week-index":
|
|
557
|
-
"data-week-number":
|
|
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: (
|
|
565
|
-
|
|
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
|
-
|
|
584
|
+
Y
|
|
570
585
|
] })
|
|
571
586
|
}
|
|
572
587
|
) : /* @__PURE__ */ c(
|
|
573
588
|
"td",
|
|
574
589
|
{
|
|
575
590
|
...n,
|
|
576
|
-
"aria-label":
|
|
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
|
-
|
|
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" &&
|
|
597
|
-
|
|
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 =
|
|
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 =
|
|
626
|
+
const e = O;
|
|
612
627
|
if (!e) return "0 weeks";
|
|
613
|
-
const n = (
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
-
}, r = j === "fiscal" &&
|
|
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
|
|
620
|
-
return `${
|
|
634
|
+
const l = e.length;
|
|
635
|
+
return `${l} ${l !== 1 ? s : o}`;
|
|
621
636
|
} else {
|
|
622
|
-
let
|
|
623
|
-
return e.forEach((
|
|
624
|
-
const g = n(
|
|
625
|
-
|
|
626
|
-
}), t(
|
|
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:
|
|
644
|
+
const { from: l, to: i } = e;
|
|
630
645
|
if (r) {
|
|
631
|
-
if (!
|
|
632
|
-
const g = n(
|
|
633
|
-
return `${
|
|
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 (!
|
|
636
|
-
const g = n(
|
|
637
|
-
return `${
|
|
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 (!
|
|
640
|
-
const
|
|
641
|
-
return t(
|
|
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(
|
|
644
|
-
return t(
|
|
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 ${
|
|
662
|
+
return `1 ${o}`;
|
|
648
663
|
})() })
|
|
649
664
|
] }),
|
|
650
|
-
u === "month" && (
|
|
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
|
-
|
|
684
|
+
M,
|
|
670
685
|
{
|
|
671
686
|
variant: "link",
|
|
672
687
|
size: "sm",
|
|
673
|
-
onClick:
|
|
688
|
+
onClick: $e,
|
|
674
689
|
children: "Clear"
|
|
675
690
|
}
|
|
676
691
|
),
|
|
677
692
|
/* @__PURE__ */ c(
|
|
678
|
-
|
|
693
|
+
M,
|
|
679
694
|
{
|
|
680
695
|
variant: "outline",
|
|
681
696
|
size: "sm",
|
|
682
|
-
onClick:
|
|
697
|
+
onClick: ze,
|
|
683
698
|
children: "Cancel"
|
|
684
699
|
}
|
|
685
700
|
),
|
|
686
701
|
/* @__PURE__ */ c(
|
|
687
|
-
|
|
702
|
+
M,
|
|
688
703
|
{
|
|
689
704
|
variant: "default",
|
|
690
705
|
size: "sm",
|
|
691
|
-
onClick:
|
|
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
|
|
714
|
+
function Le({
|
|
700
715
|
className: te,
|
|
701
716
|
day: T,
|
|
702
717
|
modifiers: v,
|
|
703
718
|
pickerType: q,
|
|
704
|
-
...
|
|
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
|
-
|
|
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
|
-
...
|
|
734
|
-
disabled:
|
|
748
|
+
...L,
|
|
749
|
+
disabled: L.disabled || v.disabled
|
|
735
750
|
}
|
|
736
751
|
);
|
|
737
752
|
}
|
|
738
753
|
export {
|
|
739
|
-
|
|
740
|
-
|
|
754
|
+
Qe as Calendar,
|
|
755
|
+
Le as CalendarDayButton
|
|
741
756
|
};
|