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