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