impact-nova 2.5.10 → 2.5.11
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/data/expandable-list-item/expandable-list-item-attributes.js +3 -2
- package/dist/components/data/expandable-list-item/expandable-list-item-metrics.js +3 -2
- package/dist/components/data-display/calendar/calendar-apply-validation.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-apply-validation.js +64 -67
- package/dist/components/data-display/calendar/calendar-available-view.d.ts +27 -0
- package/dist/components/data-display/calendar/calendar-available-view.js +85 -0
- package/dist/components/data-display/calendar/calendar-day-picker-components.d.ts +4 -2
- package/dist/components/data-display/calendar/calendar-day-picker-components.js +163 -152
- package/dist/components/data-display/calendar/calendar-day-picker-view.js +77 -76
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.d.ts +6 -0
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.js +34 -18
- package/dist/components/data-display/calendar/calendar-month-utils.d.ts +5 -0
- package/dist/components/data-display/calendar/calendar-month-utils.js +85 -64
- package/dist/components/data-display/calendar/calendar-selection-appearance.d.ts +1 -0
- package/dist/components/data-display/calendar/calendar-selection-appearance.js +31 -30
- package/dist/components/data-display/calendar/calendar-week-number-cell.d.ts +2 -1
- package/dist/components/data-display/calendar/calendar-week-number-cell.js +55 -41
- package/dist/components/data-display/calendar/calendar-year-panes.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-year-panes.js +3 -1
- package/dist/components/data-display/calendar/calendar.js +146 -143
- package/dist/components/data-display/calendar/calendar.types.d.ts +5 -0
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.d.ts +2 -1
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.js +79 -74
- package/dist/components/data-display/calendar/use-calendar-state.d.ts +3 -1
- package/dist/components/data-display/calendar/use-calendar-state.js +403 -325
- package/dist/components/feedback/tooltip/tab-tooltip-render.js +3 -2
- package/dist/components/flows/command-palette/shortcut-settings.js +10 -10
- package/dist/components/flows/filter-panel/filter-panel.js +4 -4
- package/dist/components/forms/date-picker/date-picker.js +60 -58
- package/dist/components/forms/date-picker/date-picker.types.d.ts +5 -0
- package/dist/components/forms/date-picker/date-range-picker.js +66 -64
- package/dist/components/forms/date-picker/fiscal-pass-through.d.ts +1 -0
- package/dist/components/forms/date-picker/fiscal-pass-through.js +3 -2
- package/dist/components/forms/date-picker/month-picker.js +61 -59
- package/dist/components/forms/date-picker/month-range-picker.js +63 -61
- package/dist/components/forms/date-picker/multi-date-picker.js +51 -49
- package/dist/components/forms/date-picker/multi-month-picker.js +49 -47
- package/dist/components/forms/date-picker/multi-quarter-picker.js +46 -44
- package/dist/components/forms/date-picker/multi-week-picker.js +53 -51
- package/dist/components/forms/date-picker/multi-year-picker.js +48 -46
- package/dist/components/forms/date-picker/quarter-picker.js +46 -44
- package/dist/components/forms/date-picker/quarter-range-picker.js +45 -43
- package/dist/components/forms/date-picker/week-picker.js +68 -66
- package/dist/components/forms/date-picker/week-range-picker.js +82 -80
- package/dist/components/forms/date-picker/year-picker.js +47 -45
- package/dist/components/forms/date-picker/year-range-picker.js +47 -45
- package/dist/components/forms/select/components/SelectTriggerValue.js +3 -2
- package/dist/components/forms/select/components/Submenu.js +3 -2
- package/dist/form-react/Fields/DateInputField.js +51 -50
- package/dist/form-react/Fields/DateRangeField.js +14 -13
- package/dist/form-react/Fields/MonthRangeField.js +29 -28
- package/dist/form-react/Fields/MultiMonthPickerField.js +13 -12
- package/dist/form-react/Fields/MultiWeekPickerField.js +18 -17
- package/dist/form-react/Fields/WeekRangePicker.js +22 -21
- package/dist/form-react/types/fields.types.d.ts +12 -0
- package/dist/impact-nova.css +1 -1
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsxs as W, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import { Cross as
|
|
3
|
+
import { Cross as Te, CalendarMonth as Ee } from "impact-nova-icons";
|
|
4
4
|
import { format as j } from "date-fns";
|
|
5
|
-
import { cn as
|
|
6
|
-
import { usePickerDismissActionsRef as
|
|
7
|
-
import { Input as
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { Calendar as
|
|
5
|
+
import { cn as Se } from "../../../lib/utils.js";
|
|
6
|
+
import { usePickerDismissActionsRef as Ae, usePickerFooterDismissNudge as Ne, isDateInputInvalid as we, resolveSingleValueDismissFlash as Ve, handlePickerEscapeKeyDown as Le, handlePickerSurfacePointerDown as Oe, resolveDateInputOnBlur as Me, maskDateInput as je, parseDateInput as Be, resolveDateInputOnEnter as ze } from "./date-input-behavior.js";
|
|
7
|
+
import { Input as He } from "../input/input.js";
|
|
8
|
+
import { Popover as Ke, PopoverAnchor as $e, PopoverContent as qe } from "../../feedback/popover/popover.js";
|
|
9
|
+
import { Calendar as Ge } from "../../data-display/calendar/calendar.js";
|
|
10
10
|
import { Tooltip as Z, TooltipTrigger as _, TooltipContent as Y } from "../../feedback/tooltip/tooltip.js";
|
|
11
|
-
import { resolveWeekSelection as
|
|
12
|
-
import { useImpactNovaI18n as
|
|
13
|
-
import { getDateFnsLocale as
|
|
14
|
-
import { coerceSingleWeekApply as
|
|
15
|
-
import { buildDateBoundsMatcher as
|
|
16
|
-
import { fiscalCalendarPassThrough as
|
|
11
|
+
import { resolveWeekSelection as Je } from "../../../lib/fiscal-calendar/week-selection.js";
|
|
12
|
+
import { useImpactNovaI18n as Qe } from "../../../i18n/use-impact-nova-i18n.js";
|
|
13
|
+
import { getDateFnsLocale as Ue } from "../../../i18n/getDateFnsLocale.js";
|
|
14
|
+
import { coerceSingleWeekApply as Xe, coerceSingleWeek as Ze } from "./calendar-selection-adapters.js";
|
|
15
|
+
import { buildDateBoundsMatcher as _e } from "../../../lib/date-bounds-matcher.js";
|
|
16
|
+
import { fiscalCalendarPassThrough as Ye } from "./fiscal-pass-through.js";
|
|
17
17
|
const F = (n, c = "MM/dd/yyyy", t) => {
|
|
18
18
|
const R = j(n.startDate, c, t ? { locale: t } : {}), b = j(n.endDate, c, t ? { locale: t } : {});
|
|
19
19
|
return `${R} - ${b}`;
|
|
20
|
-
}, g = (n, c, t) => n ? j(n.startDate, c, t ? { locale: t } : {}) : "",
|
|
20
|
+
}, g = (n, c, t) => n ? j(n.startDate, c, t ? { locale: t } : {}) : "", Fe = s.forwardRef(
|
|
21
21
|
({
|
|
22
22
|
value: n,
|
|
23
23
|
onChange: c,
|
|
@@ -37,15 +37,16 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
37
37
|
weekStartsOn: A = 1,
|
|
38
38
|
showPresets: se,
|
|
39
39
|
showPeriodBoundaries: oe,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
autoNavigateToAvailable: ie,
|
|
41
|
+
comparison: ce,
|
|
42
|
+
onComparisonChange: ae,
|
|
42
43
|
disabled: p,
|
|
43
|
-
className:
|
|
44
|
-
...
|
|
45
|
-
},
|
|
46
|
-
const { locale: B, t: D } =
|
|
47
|
-
s.useImperativeHandle(
|
|
48
|
-
const [o, H] = s.useState(!1), K =
|
|
44
|
+
className: le,
|
|
45
|
+
...pe
|
|
46
|
+
}, ue) => {
|
|
47
|
+
const { locale: B, t: D } = Qe(), i = s.useMemo(() => Ue(B), [B]), fe = R ?? D("datePicker.selectWeek"), C = I === "fiscal", N = s.useRef(null), z = s.useRef(null), v = s.useRef(!1);
|
|
48
|
+
s.useImperativeHandle(ue, () => N.current);
|
|
49
|
+
const [o, H] = s.useState(!1), K = Ae(), { footerFlashKey: de, footerFlashTarget: me, popoverHandlers: ke } = Ne(l, o, K, z), [De, w] = s.useState(!1), [u, f] = s.useState(n), [y, m] = s.useState(""), [ye, h] = s.useState(n?.startDate || /* @__PURE__ */ new Date()), he = n ? F(n, t, i) : "", $ = u ? F(u, t, i) : "", V = o || De, ge = V ? y : $, q = s.useCallback(() => {
|
|
49
50
|
f(n), m(g(n, t, i)), C || h(n?.startDate || /* @__PURE__ */ new Date());
|
|
50
51
|
}, [n, t, i, C]), P = s.useCallback(() => {
|
|
51
52
|
m(g(u ?? n, t, i)), C || h((u ?? n)?.startDate || /* @__PURE__ */ new Date());
|
|
@@ -68,7 +69,7 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
68
69
|
l || d();
|
|
69
70
|
}
|
|
70
71
|
}, L = s.useCallback(
|
|
71
|
-
(e) =>
|
|
72
|
+
(e) => Je(e, {
|
|
72
73
|
calendarKind: I,
|
|
73
74
|
fiscalMode: x,
|
|
74
75
|
granularity: T,
|
|
@@ -84,33 +85,33 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
84
85
|
S,
|
|
85
86
|
A
|
|
86
87
|
]
|
|
87
|
-
),
|
|
88
|
-
const r =
|
|
88
|
+
), Ce = (e) => {
|
|
89
|
+
const r = Ze(e);
|
|
89
90
|
f(r), r && (m(g(r, t, i)), C || h(r.startDate)), l || (c?.(r), d());
|
|
90
91
|
}, J = (e) => {
|
|
91
|
-
const r =
|
|
92
|
+
const r = Xe(e, u);
|
|
92
93
|
c?.(r), d();
|
|
93
94
|
}, O = () => {
|
|
94
95
|
q(), d();
|
|
95
96
|
}, Q = () => {
|
|
96
97
|
f(void 0), m(""), c?.(void 0), l || d();
|
|
97
|
-
},
|
|
98
|
+
}, ve = (e) => {
|
|
98
99
|
const r = L(e);
|
|
99
100
|
f(r), m(g(r, t, i)), h(e), c?.(r), d();
|
|
100
|
-
},
|
|
101
|
-
const r =
|
|
101
|
+
}, Ie = (e) => {
|
|
102
|
+
const r = je(e.target.value, t, y);
|
|
102
103
|
if (m(r), r === "") {
|
|
103
104
|
f(void 0), l || c?.(void 0);
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
|
-
const { parsed: M, isValid:
|
|
107
|
-
if (
|
|
107
|
+
const { parsed: M, isValid: xe } = Be(r, t, i);
|
|
108
|
+
if (xe && M) {
|
|
108
109
|
const X = L(M);
|
|
109
110
|
f(X), h(M), l || c?.(X);
|
|
110
111
|
}
|
|
111
|
-
},
|
|
112
|
+
}, Pe = () => {
|
|
112
113
|
if (w(!1), o) return;
|
|
113
|
-
const e =
|
|
114
|
+
const e = Me(
|
|
114
115
|
y,
|
|
115
116
|
t,
|
|
116
117
|
g(u ?? n, t, i),
|
|
@@ -126,19 +127,19 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
129
|
y || (f(void 0), l || c?.(void 0));
|
|
129
|
-
},
|
|
130
|
+
}, We = () => {
|
|
130
131
|
if (o && l) {
|
|
131
132
|
J();
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
134
|
-
const e =
|
|
135
|
+
const e = ze(y, t, i);
|
|
135
136
|
if (e.parsed) {
|
|
136
|
-
l &&
|
|
137
|
+
l && ve(e.parsed);
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
139
140
|
o || (v.current = !0, k(!0));
|
|
140
|
-
}, U =
|
|
141
|
-
() =>
|
|
141
|
+
}, U = he !== $, Re = V && we(y, t, i), be = s.useCallback(
|
|
142
|
+
() => Ve(
|
|
142
143
|
u,
|
|
143
144
|
n,
|
|
144
145
|
(e, r) => e.startDate.getTime() === r.startDate.getTime()
|
|
@@ -148,43 +149,43 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
148
149
|
return s.useLayoutEffect(() => {
|
|
149
150
|
K.current = {
|
|
150
151
|
onDismiss: O,
|
|
151
|
-
resolveFlash:
|
|
152
|
+
resolveFlash: be
|
|
152
153
|
};
|
|
153
|
-
}), /* @__PURE__ */ W(
|
|
154
|
-
/* @__PURE__ */ a(
|
|
154
|
+
}), /* @__PURE__ */ W(Ke, { open: p ? !1 : o, onOpenChange: k, children: [
|
|
155
|
+
/* @__PURE__ */ a($e, { asChild: !0, children: /* @__PURE__ */ a(
|
|
155
156
|
"div",
|
|
156
157
|
{
|
|
157
158
|
ref: z,
|
|
158
159
|
"data-component": "week-picker",
|
|
159
160
|
"data-state": o ? "open" : "closed",
|
|
160
161
|
"data-pending": U || void 0,
|
|
161
|
-
onPointerDown: (e) =>
|
|
162
|
+
onPointerDown: (e) => Oe({
|
|
162
163
|
disabled: p,
|
|
163
164
|
event: e,
|
|
164
165
|
onOpen: () => k(!0),
|
|
165
166
|
focusField: () => N.current?.focus()
|
|
166
167
|
}),
|
|
167
168
|
children: /* @__PURE__ */ a(
|
|
168
|
-
|
|
169
|
+
He,
|
|
169
170
|
{
|
|
170
171
|
ref: N,
|
|
171
|
-
value:
|
|
172
|
-
onChange:
|
|
172
|
+
value: ge,
|
|
173
|
+
onChange: Ie,
|
|
173
174
|
onFocus: () => {
|
|
174
175
|
p || (w(!0), P());
|
|
175
176
|
},
|
|
176
|
-
onBlur:
|
|
177
|
+
onBlur: Pe,
|
|
177
178
|
onClick: () => !p && k(!0),
|
|
178
179
|
onKeyDown: (e) => {
|
|
179
|
-
e.key === "Enter" && !p && (e.preventDefault(),
|
|
180
|
+
e.key === "Enter" && !p && (e.preventDefault(), We()), e.key === "ArrowDown" && !o && !p && (e.preventDefault(), v.current = !0, k(!0)), e.key === "Escape" && o && Le(e, { open: o, onCancel: O });
|
|
180
181
|
},
|
|
181
|
-
placeholder: V ? t :
|
|
182
|
+
placeholder: V ? t : fe,
|
|
182
183
|
disabled: p,
|
|
183
184
|
"data-form-control": "input",
|
|
184
|
-
className:
|
|
185
|
+
className: Se(
|
|
185
186
|
"cursor-pointer",
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
Re ? "text-destructive" : U ? "text-content-placeholder" : "",
|
|
188
|
+
le
|
|
188
189
|
),
|
|
189
190
|
suffix: /* @__PURE__ */ W("div", { className: "flex items-center gap-1", children: [
|
|
190
191
|
n && !p && /* @__PURE__ */ W(Z, { children: [
|
|
@@ -198,7 +199,7 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
198
199
|
e.stopPropagation(), Q();
|
|
199
200
|
},
|
|
200
201
|
className: "inline-flex size-4 items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
201
|
-
children: /* @__PURE__ */ a(
|
|
202
|
+
children: /* @__PURE__ */ a(Te, { className: "size-3 hover:text-content" })
|
|
202
203
|
}
|
|
203
204
|
) }),
|
|
204
205
|
/* @__PURE__ */ a(Y, { variant: "tertiary", side: "top", children: D("calendar.clear") })
|
|
@@ -217,19 +218,19 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
217
218
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), p || (v.current = !0, o ? d() : k(!0)));
|
|
218
219
|
},
|
|
219
220
|
className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
220
|
-
children: /* @__PURE__ */ a(
|
|
221
|
+
children: /* @__PURE__ */ a(Ee, { className: "h-4 w-4 text-secondary-foreground" })
|
|
221
222
|
}
|
|
222
223
|
) }),
|
|
223
224
|
/* @__PURE__ */ a(Y, { variant: "tertiary", side: "top", children: D("datePicker.selectWeek") })
|
|
224
225
|
] })
|
|
225
226
|
] }),
|
|
226
|
-
...
|
|
227
|
+
...pe
|
|
227
228
|
}
|
|
228
229
|
)
|
|
229
230
|
}
|
|
230
231
|
) }),
|
|
231
232
|
/* @__PURE__ */ a(
|
|
232
|
-
|
|
233
|
+
qe,
|
|
233
234
|
{
|
|
234
235
|
className: "w-auto p-0",
|
|
235
236
|
align: "start",
|
|
@@ -237,23 +238,23 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
237
238
|
onOpenAutoFocus: (e) => {
|
|
238
239
|
v.current || e.preventDefault(), v.current = !1;
|
|
239
240
|
},
|
|
240
|
-
...
|
|
241
|
+
...ke,
|
|
241
242
|
children: /* @__PURE__ */ a(
|
|
242
|
-
|
|
243
|
+
Ge,
|
|
243
244
|
{
|
|
244
245
|
pickerType: "week",
|
|
245
246
|
weekMode: "single",
|
|
246
247
|
selectedWeeks: u,
|
|
247
|
-
footerFlashKey:
|
|
248
|
-
footerFlashTarget:
|
|
249
|
-
onWeekSelect:
|
|
250
|
-
month:
|
|
248
|
+
footerFlashKey: de,
|
|
249
|
+
footerFlashTarget: me,
|
|
250
|
+
onWeekSelect: Ce,
|
|
251
|
+
month: ye,
|
|
251
252
|
onMonthChange: h,
|
|
252
|
-
disabled:
|
|
253
|
+
disabled: _e(b, ee),
|
|
253
254
|
startMonth: te,
|
|
254
255
|
endMonth: ne,
|
|
255
256
|
showFooter: l,
|
|
256
|
-
...
|
|
257
|
+
...Ye({
|
|
257
258
|
calendarKind: I,
|
|
258
259
|
fiscalMode: x,
|
|
259
260
|
granularity: T,
|
|
@@ -263,8 +264,9 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
263
264
|
weekStartsOn: A,
|
|
264
265
|
showPresets: se,
|
|
265
266
|
showPeriodBoundaries: oe,
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
autoNavigateToAvailable: ie,
|
|
268
|
+
comparison: ce,
|
|
269
|
+
onComparisonChange: ae
|
|
268
270
|
}),
|
|
269
271
|
onApply: J,
|
|
270
272
|
onCancel: O,
|
|
@@ -277,7 +279,7 @@ const F = (n, c = "MM/dd/yyyy", t) => {
|
|
|
277
279
|
] });
|
|
278
280
|
}
|
|
279
281
|
);
|
|
280
|
-
|
|
282
|
+
Fe.displayName = "WeekPicker";
|
|
281
283
|
export {
|
|
282
|
-
|
|
284
|
+
Fe as WeekPicker
|
|
283
285
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { jsx as u, jsxs as W } from "react/jsx-runtime";
|
|
2
2
|
import * as c from "react";
|
|
3
|
-
import { Cross as
|
|
3
|
+
import { Cross as et, CalendarMonth as tt } from "impact-nova-icons";
|
|
4
4
|
import { format as g } from "date-fns";
|
|
5
5
|
import { cn as Q } from "../../../lib/utils.js";
|
|
6
|
-
import { usePickerDismissActionsRef as
|
|
7
|
-
import { useFieldChrome as
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { Calendar as
|
|
10
|
-
import { buildDateBoundsMatcher as
|
|
6
|
+
import { usePickerDismissActionsRef as rt, usePickerFooterDismissNudge as ot, createRangePickerOpenChangeHandler as nt, parseDateInput as U, normalizeOrderedRange as st, compareDates as it, flashRangeReorder as ct, isDateInputInvalid as ce, resolveRangeFieldBlur as L, resolveRangePickerDismissFlash as lt, handlePickerEscapeKeyDown as le, handlePickerSurfacePointerDown as at, deferRangeInputBlur as ft, maskDateInput as ae, resolveDateInputOnBlur as j } from "./date-input-behavior.js";
|
|
7
|
+
import { useFieldChrome as dt } from "../../../lib/primitives/use-field-chrome.js";
|
|
8
|
+
import { Popover as pt, PopoverAnchor as mt, PopoverContent as ut } from "../../feedback/popover/popover.js";
|
|
9
|
+
import { Calendar as gt } from "../../data-display/calendar/calendar.js";
|
|
10
|
+
import { buildDateBoundsMatcher as kt } from "../../../lib/date-bounds-matcher.js";
|
|
11
11
|
import { Tooltip as fe, TooltipTrigger as de, TooltipContent as pe } from "../../feedback/tooltip/tooltip.js";
|
|
12
|
-
import { resolveWeekSelection as
|
|
13
|
-
import { useImpactNovaI18n as
|
|
14
|
-
import { getDateFnsLocale as
|
|
15
|
-
import { coerceWeekRangeApply as
|
|
16
|
-
import { fiscalCalendarPassThrough as
|
|
12
|
+
import { resolveWeekSelection as Rt } from "../../../lib/fiscal-calendar/week-selection.js";
|
|
13
|
+
import { useImpactNovaI18n as ht } from "../../../i18n/use-impact-nova-i18n.js";
|
|
14
|
+
import { getDateFnsLocale as Dt } from "../../../i18n/getDateFnsLocale.js";
|
|
15
|
+
import { coerceWeekRangeApply as yt, isWeekRangeSelection as vt } from "./calendar-selection-adapters.js";
|
|
16
|
+
import { fiscalCalendarPassThrough as xt } from "./fiscal-pass-through.js";
|
|
17
17
|
const x = (t) => t?.from ? t.to ? t.to.endDate : t.from.endDate : void 0, S = (t) => t?.from ? { from: t.from, to: t.to } : void 0;
|
|
18
18
|
function me(t, l) {
|
|
19
19
|
return !t && !l ? !0 : !t || !l ? !1 : t.startDate.getTime() === l.startDate.getTime();
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function Ct(t, l) {
|
|
22
22
|
return !t && !l ? !0 : !t || !l ? !1 : me(t.from, l.from) && me(t.to, l.to);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const bt = c.forwardRef(
|
|
25
25
|
({
|
|
26
26
|
value: t,
|
|
27
27
|
onChange: l,
|
|
@@ -41,40 +41,41 @@ const Ct = c.forwardRef(
|
|
|
41
41
|
weekStartsOn: M = 1,
|
|
42
42
|
showPresets: ye,
|
|
43
43
|
showPeriodBoundaries: ve,
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
autoNavigateToAvailable: xe,
|
|
45
|
+
comparison: Ce,
|
|
46
|
+
onComparisonChange: be,
|
|
46
47
|
disabled: d,
|
|
47
|
-
className:
|
|
48
|
-
error:
|
|
49
|
-
isError:
|
|
48
|
+
className: we,
|
|
49
|
+
error: Ie,
|
|
50
|
+
isError: Te,
|
|
50
51
|
size: X,
|
|
51
|
-
label:
|
|
52
|
-
helperText:
|
|
53
|
-
helperTextPosition:
|
|
54
|
-
required:
|
|
55
|
-
prefix:
|
|
56
|
-
prefixClick:
|
|
57
|
-
...
|
|
58
|
-
},
|
|
59
|
-
const Z =
|
|
60
|
-
label:
|
|
61
|
-
helperText:
|
|
62
|
-
helperTextPosition:
|
|
52
|
+
label: Ee,
|
|
53
|
+
helperText: Pe,
|
|
54
|
+
helperTextPosition: We = "absolute",
|
|
55
|
+
required: Se,
|
|
56
|
+
prefix: wt,
|
|
57
|
+
prefixClick: It,
|
|
58
|
+
...Be
|
|
59
|
+
}, Ne) => {
|
|
60
|
+
const Z = Ie ?? Te, Ve = dt({
|
|
61
|
+
label: Ee,
|
|
62
|
+
helperText: Pe,
|
|
63
|
+
helperTextPosition: We,
|
|
63
64
|
error: Z,
|
|
64
|
-
required:
|
|
65
|
+
required: Se,
|
|
65
66
|
disabled: d ?? void 0,
|
|
66
67
|
rootClassName: "w-full min-w-[240px]"
|
|
67
|
-
}), { locale: _, t: T } =
|
|
68
|
-
c.useImperativeHandle(
|
|
69
|
-
const [p, R] = c.useState(!1), ee =
|
|
68
|
+
}), { locale: _, t: T } = ht(), s = c.useMemo(() => Dt(_), [_]), $ = ue ?? T("datePicker.selectWeekRange"), V = N === "fiscal", G = c.useRef(null), Y = c.useRef(null), F = c.useRef(null), A = c.useRef(null), J = c.useRef(null);
|
|
69
|
+
c.useImperativeHandle(Ne, () => G.current);
|
|
70
|
+
const [p, R] = c.useState(!1), ee = rt(), { footerFlashKey: Ae, footerFlashTarget: Oe, popoverHandlers: Le } = ot(k, p, ee, F), E = c.useRef(!1), [a, h] = c.useState(t), [m, D] = c.useState(t?.from ? g(t.from.startDate, n, { locale: s }) : ""), [y, v] = c.useState(x(t) ? g(x(t), n, { locale: s }) : ""), [je, P] = c.useState(t?.from?.startDate || /* @__PURE__ */ new Date()), qe = t?.from?.startDate.getTime(), ze = x(t)?.getTime(), te = c.useRef(t);
|
|
70
71
|
c.useEffect(() => {
|
|
71
72
|
te.current = t;
|
|
72
73
|
}), c.useEffect(() => {
|
|
73
74
|
const e = te.current;
|
|
74
75
|
D(e?.from ? g(e.from.startDate, n, { locale: s }) : ""), v(x(e) ? g(x(e), n, { locale: s }) : ""), h(e);
|
|
75
|
-
}, [
|
|
76
|
-
const
|
|
77
|
-
(e) =>
|
|
76
|
+
}, [qe, ze, n, s]);
|
|
77
|
+
const He = c.useCallback(
|
|
78
|
+
(e) => nt({
|
|
78
79
|
disabled: d ?? void 0,
|
|
79
80
|
showFooter: k,
|
|
80
81
|
containerRef: A,
|
|
@@ -90,11 +91,11 @@ const Ct = c.forwardRef(
|
|
|
90
91
|
}
|
|
91
92
|
re.current = p;
|
|
92
93
|
}, [p, m, n, s, a?.from, t?.from, V]);
|
|
93
|
-
const
|
|
94
|
-
const r =
|
|
94
|
+
const Ke = (e) => {
|
|
95
|
+
const r = vt(e) ? e : void 0;
|
|
95
96
|
h(r), r?.from ? (D(g(r.from.startDate, n, { locale: s })), v(g(x(r), n, { locale: s }))) : (D(""), v("")), !k && r?.from && r?.to && r.from.startDate.getTime() !== r.to.startDate.getTime() && (l?.(r), R(!1));
|
|
96
97
|
}, C = c.useCallback(
|
|
97
|
-
(e) =>
|
|
98
|
+
(e) => Rt(e, {
|
|
98
99
|
calendarKind: N,
|
|
99
100
|
fiscalMode: q,
|
|
100
101
|
granularity: z,
|
|
@@ -111,20 +112,20 @@ const Ct = c.forwardRef(
|
|
|
111
112
|
M
|
|
112
113
|
]
|
|
113
114
|
), B = c.useCallback((e, r) => {
|
|
114
|
-
const o =
|
|
115
|
+
const o = st(
|
|
115
116
|
e,
|
|
116
117
|
r,
|
|
117
|
-
(i, f) =>
|
|
118
|
+
(i, f) => it(i.startDate, f.startDate)
|
|
118
119
|
);
|
|
119
|
-
return o.swapped && (o.from && D(g(o.from.startDate, n, { locale: s })), o.to && v(g(x({ from: o.from, to: o.to }), n, { locale: s })),
|
|
120
|
+
return o.swapped && (o.from && D(g(o.from.startDate, n, { locale: s })), o.to && v(g(x({ from: o.from, to: o.to }), n, { locale: s })), ct(A.current)), { from: o.from, to: o.to };
|
|
120
121
|
}, [n, s]), oe = (e) => {
|
|
121
|
-
const r =
|
|
122
|
+
const r = yt(e, S(a)), o = B(r?.from, r?.to), i = o.from ? { from: o.from, to: o.to } : void 0;
|
|
122
123
|
h(i), l?.(i), R(!1);
|
|
123
124
|
}, O = () => {
|
|
124
125
|
h(t), D(t?.from ? g(t.from.startDate, n, { locale: s }) : ""), v(x(t) ? g(x(t), n, { locale: s }) : ""), R(!1);
|
|
125
126
|
}, ne = () => {
|
|
126
127
|
h(void 0), D(""), v(""), l?.(void 0), k || R(!1);
|
|
127
|
-
},
|
|
128
|
+
}, Me = (e) => {
|
|
128
129
|
const r = ae(e.target.value, n, m);
|
|
129
130
|
if (D(r), r === "") {
|
|
130
131
|
const f = { to: a?.to };
|
|
@@ -136,7 +137,7 @@ const Ct = c.forwardRef(
|
|
|
136
137
|
const I = { from: C(o), to: a?.to };
|
|
137
138
|
h(I), a?.to && v(g(x(I), n, { locale: s })), V || P(o), k || l?.(S(I));
|
|
138
139
|
}
|
|
139
|
-
},
|
|
140
|
+
}, Ge = (e) => {
|
|
140
141
|
const r = ae(e.target.value, n, y);
|
|
141
142
|
if (v(r), r === "") {
|
|
142
143
|
const f = { from: a?.from };
|
|
@@ -148,7 +149,7 @@ const Ct = c.forwardRef(
|
|
|
148
149
|
const f = C(o), I = { from: a?.from, to: f };
|
|
149
150
|
h(I), a?.from && D(g(a.from.startDate, n, { locale: s })), V || P(o), k || l?.(S(I));
|
|
150
151
|
}
|
|
151
|
-
},
|
|
152
|
+
}, Je = () => {
|
|
152
153
|
const e = j(m, n, b, s), r = j(y, n, w, s);
|
|
153
154
|
e.resetToCommitted ? D(b) : e.parsed && D(e.display), r.resetToCommitted ? v(w) : r.parsed && v(r.display);
|
|
154
155
|
let o = e.parsed ? C(e.parsed) : a?.from, i = r.parsed ? C(r.parsed) : a?.to;
|
|
@@ -156,7 +157,7 @@ const Ct = c.forwardRef(
|
|
|
156
157
|
const f = o ? { from: o, to: i } : void 0;
|
|
157
158
|
f ? (h(f), l?.(f)) : !m && !y && (h(void 0), l?.(void 0));
|
|
158
159
|
}, se = () => {
|
|
159
|
-
|
|
160
|
+
ft(
|
|
160
161
|
A,
|
|
161
162
|
J,
|
|
162
163
|
() => {
|
|
@@ -175,19 +176,19 @@ const Ct = c.forwardRef(
|
|
|
175
176
|
}
|
|
176
177
|
if (!p) {
|
|
177
178
|
if (k) {
|
|
178
|
-
|
|
179
|
+
Je();
|
|
179
180
|
return;
|
|
180
181
|
}
|
|
181
182
|
const e = j(m, n, b, s), r = j(y, n, w, s);
|
|
182
183
|
if (e.parsed || r.parsed) return;
|
|
183
184
|
E.current = !0, R(!0);
|
|
184
185
|
}
|
|
185
|
-
}, b = t?.from ? g(t.from.startDate, n, { locale: s }) : "", w = x(t) ? g(x(t), n, { locale: s }) : "",
|
|
186
|
+
}, b = t?.from ? g(t.from.startDate, n, { locale: s }) : "", w = x(t) ? g(x(t), n, { locale: s }) : "", Qe = b !== m, Ue = w !== y, Xe = ce(m, n, s), Ze = ce(y, n, s), _e = "Start Date", $e = "End Date", Ye = c.useCallback(() => {
|
|
186
187
|
const e = L(m, n, b, s), r = L(y, n, w, s);
|
|
187
188
|
let o = e.parsed ? C(e.parsed) : e.resetToCommitted ? t?.from : a?.from, i = r.parsed ? C(r.parsed) : r.resetToCommitted ? t?.to : a?.to;
|
|
188
189
|
o && i && ({ from: o, to: i } = B(o, i));
|
|
189
190
|
const f = o || i ? { from: o, to: i } : void 0;
|
|
190
|
-
return
|
|
191
|
+
return lt({
|
|
191
192
|
startInput: m,
|
|
192
193
|
endInput: y,
|
|
193
194
|
committedStart: b,
|
|
@@ -195,7 +196,7 @@ const Ct = c.forwardRef(
|
|
|
195
196
|
committedRange: t,
|
|
196
197
|
pendingRange: S(a),
|
|
197
198
|
computeEffectiveRange: () => f,
|
|
198
|
-
rangesEqual: (I,
|
|
199
|
+
rangesEqual: (I, Fe) => Ct(I, Fe)
|
|
199
200
|
});
|
|
200
201
|
}, [
|
|
201
202
|
m,
|
|
@@ -212,7 +213,7 @@ const Ct = c.forwardRef(
|
|
|
212
213
|
return c.useLayoutEffect(() => {
|
|
213
214
|
ee.current = {
|
|
214
215
|
onDismiss: O,
|
|
215
|
-
resolveFlash:
|
|
216
|
+
resolveFlash: Ye
|
|
216
217
|
};
|
|
217
218
|
}), /* @__PURE__ */ u(
|
|
218
219
|
"div",
|
|
@@ -220,14 +221,14 @@ const Ct = c.forwardRef(
|
|
|
220
221
|
ref: F,
|
|
221
222
|
"data-component": "week-range-picker",
|
|
222
223
|
"data-disabled": d || void 0,
|
|
223
|
-
children:
|
|
224
|
-
/* @__PURE__ */ W(
|
|
225
|
-
/* @__PURE__ */ u(
|
|
224
|
+
children: Ve.wrapControl(
|
|
225
|
+
/* @__PURE__ */ W(pt, { open: d ? !1 : p, onOpenChange: He, children: [
|
|
226
|
+
/* @__PURE__ */ u(mt, { asChild: !0, children: /* @__PURE__ */ W(
|
|
226
227
|
"div",
|
|
227
228
|
{
|
|
228
229
|
ref: A,
|
|
229
230
|
"data-state": p ? "open" : "closed",
|
|
230
|
-
onPointerDown: (e) =>
|
|
231
|
+
onPointerDown: (e) => at({
|
|
231
232
|
disabled: d,
|
|
232
233
|
event: e,
|
|
233
234
|
onOpen: () => R(!0),
|
|
@@ -241,7 +242,7 @@ const Ct = c.forwardRef(
|
|
|
241
242
|
X === "sm" ? "h-6" : X === "md" ? "h-[28px]" : "h-8",
|
|
242
243
|
d && "pointer-events-none opacity-100 bg-disabled-surface border-stroke text-disabled-foreground hover:border-stroke",
|
|
243
244
|
"cursor-pointer",
|
|
244
|
-
|
|
245
|
+
we
|
|
245
246
|
),
|
|
246
247
|
children: [
|
|
247
248
|
/* @__PURE__ */ W("div", { className: "flex items-center gap-4 flex-1 min-w-0", children: [
|
|
@@ -251,7 +252,7 @@ const Ct = c.forwardRef(
|
|
|
251
252
|
ref: G,
|
|
252
253
|
type: "text",
|
|
253
254
|
value: m,
|
|
254
|
-
onChange:
|
|
255
|
+
onChange: Me,
|
|
255
256
|
onBlur: se,
|
|
256
257
|
onClick: () => !d && R(!0),
|
|
257
258
|
onKeyDown: (e) => {
|
|
@@ -259,13 +260,13 @@ const Ct = c.forwardRef(
|
|
|
259
260
|
},
|
|
260
261
|
placeholder: p ? n : $,
|
|
261
262
|
disabled: !!d,
|
|
262
|
-
"aria-label":
|
|
263
|
+
"aria-label": _e,
|
|
263
264
|
"data-field": "start",
|
|
264
265
|
className: Q(
|
|
265
266
|
"flex-1 min-w-0 bg-transparent p-0 text-sm font-medium outline-none placeholder:font-medium placeholder:text-content-empty disabled:cursor-not-allowed disabled:opacity-50",
|
|
266
|
-
|
|
267
|
+
Xe ? "text-destructive" : Qe ? "text-content-placeholder" : ""
|
|
267
268
|
),
|
|
268
|
-
...
|
|
269
|
+
...Be
|
|
269
270
|
}
|
|
270
271
|
),
|
|
271
272
|
/* @__PURE__ */ u(
|
|
@@ -274,7 +275,7 @@ const Ct = c.forwardRef(
|
|
|
274
275
|
ref: Y,
|
|
275
276
|
type: "text",
|
|
276
277
|
value: y,
|
|
277
|
-
onChange:
|
|
278
|
+
onChange: Ge,
|
|
278
279
|
onBlur: se,
|
|
279
280
|
onClick: () => !d && R(!0),
|
|
280
281
|
onKeyDown: (e) => {
|
|
@@ -282,11 +283,11 @@ const Ct = c.forwardRef(
|
|
|
282
283
|
},
|
|
283
284
|
placeholder: p ? n : $,
|
|
284
285
|
disabled: !!d,
|
|
285
|
-
"aria-label":
|
|
286
|
+
"aria-label": $e,
|
|
286
287
|
"data-field": "end",
|
|
287
288
|
className: Q(
|
|
288
289
|
"flex-1 min-w-0 bg-transparent p-0 text-sm font-medium outline-none placeholder:font-medium placeholder:text-content-empty disabled:cursor-not-allowed disabled:opacity-50",
|
|
289
|
-
|
|
290
|
+
Ze ? "text-destructive" : Ue ? "text-content-placeholder" : ""
|
|
290
291
|
)
|
|
291
292
|
}
|
|
292
293
|
)
|
|
@@ -303,7 +304,7 @@ const Ct = c.forwardRef(
|
|
|
303
304
|
e.stopPropagation(), ne();
|
|
304
305
|
},
|
|
305
306
|
className: "inline-flex size-4 items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
306
|
-
children: /* @__PURE__ */ u(
|
|
307
|
+
children: /* @__PURE__ */ u(et, { className: "size-3 hover:text-content text-content-icon" })
|
|
307
308
|
}
|
|
308
309
|
) }),
|
|
309
310
|
/* @__PURE__ */ u(pe, { variant: "tertiary", side: "top", children: T("calendar.clear") })
|
|
@@ -313,7 +314,7 @@ const Ct = c.forwardRef(
|
|
|
313
314
|
e.stopPropagation(), d || R(!p);
|
|
314
315
|
}, onKeyDown: (e) => {
|
|
315
316
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), d || (E.current = !0, R(!p)));
|
|
316
|
-
}, className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer", children: /* @__PURE__ */ u(
|
|
317
|
+
}, className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer", children: /* @__PURE__ */ u(tt, { className: "h-4 w-4 text-secondary-foreground" }) }) }),
|
|
317
318
|
/* @__PURE__ */ u(pe, { variant: "tertiary", side: "top", children: T("datePicker.selectWeekRange") })
|
|
318
319
|
] })
|
|
319
320
|
] })
|
|
@@ -321,7 +322,7 @@ const Ct = c.forwardRef(
|
|
|
321
322
|
}
|
|
322
323
|
) }),
|
|
323
324
|
/* @__PURE__ */ u(
|
|
324
|
-
|
|
325
|
+
ut,
|
|
325
326
|
{
|
|
326
327
|
ref: J,
|
|
327
328
|
className: "w-auto p-0",
|
|
@@ -330,23 +331,23 @@ const Ct = c.forwardRef(
|
|
|
330
331
|
onOpenAutoFocus: (e) => {
|
|
331
332
|
E.current || e.preventDefault(), E.current = !1;
|
|
332
333
|
},
|
|
333
|
-
...
|
|
334
|
+
...Le,
|
|
334
335
|
children: /* @__PURE__ */ u(
|
|
335
|
-
|
|
336
|
+
gt,
|
|
336
337
|
{
|
|
337
338
|
pickerType: "week",
|
|
338
339
|
weekMode: "range",
|
|
339
340
|
selectedWeeks: S(a),
|
|
340
|
-
footerFlashKey:
|
|
341
|
-
footerFlashTarget:
|
|
342
|
-
onWeekSelect:
|
|
343
|
-
month:
|
|
341
|
+
footerFlashKey: Ae,
|
|
342
|
+
footerFlashTarget: Oe,
|
|
343
|
+
onWeekSelect: Ke,
|
|
344
|
+
month: je,
|
|
344
345
|
onMonthChange: P,
|
|
345
|
-
disabled:
|
|
346
|
+
disabled: kt(ge, ke),
|
|
346
347
|
startMonth: Re,
|
|
347
348
|
endMonth: he,
|
|
348
349
|
showFooter: k,
|
|
349
|
-
...
|
|
350
|
+
...xt({
|
|
350
351
|
calendarKind: N,
|
|
351
352
|
fiscalMode: q,
|
|
352
353
|
granularity: z,
|
|
@@ -356,8 +357,9 @@ const Ct = c.forwardRef(
|
|
|
356
357
|
weekStartsOn: M,
|
|
357
358
|
showPresets: ye,
|
|
358
359
|
showPeriodBoundaries: ve,
|
|
359
|
-
|
|
360
|
-
|
|
360
|
+
autoNavigateToAvailable: xe,
|
|
361
|
+
comparison: Ce,
|
|
362
|
+
onComparisonChange: be
|
|
361
363
|
}),
|
|
362
364
|
onApply: oe,
|
|
363
365
|
onCancel: O,
|
|
@@ -373,7 +375,7 @@ const Ct = c.forwardRef(
|
|
|
373
375
|
);
|
|
374
376
|
}
|
|
375
377
|
);
|
|
376
|
-
|
|
378
|
+
bt.displayName = "WeekRangePicker";
|
|
377
379
|
export {
|
|
378
|
-
|
|
380
|
+
bt as WeekRangePicker
|
|
379
381
|
};
|