impact-nova 2.5.8 → 2.5.10
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/data-table/column-runtime-state-guard.js +42 -42
- package/dist/components/data/data-table/data-table-column-tree-cache.d.ts +15 -0
- package/dist/components/data/data-table/data-table-column-tree-cache.js +109 -80
- package/dist/components/data/data-table/use-data-table-column-list-sync.js +65 -62
- package/dist/components/data/expandable-list-item/expandable-list-item-attributes.js +2 -3
- package/dist/components/data/expandable-list-item/expandable-list-item-metrics.js +2 -3
- package/dist/components/data-display/calendar/calendar-day-picker-classnames.d.ts +6 -1
- package/dist/components/data-display/calendar/calendar-day-picker-classnames.js +31 -23
- package/dist/components/data-display/calendar/calendar-day-picker-components.d.ts +2 -1
- package/dist/components/data-display/calendar/calendar-day-picker-components.js +197 -164
- package/dist/components/data-display/calendar/calendar-day-picker-view.d.ts +3 -2
- package/dist/components/data-display/calendar/calendar-day-picker-view.js +130 -129
- package/dist/components/data-display/calendar/calendar-fiscal-labels.js +6 -6
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.d.ts +16 -0
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.js +41 -0
- package/dist/components/data-display/calendar/calendar-padding-week.utils.d.ts +5 -1
- package/dist/components/data-display/calendar/calendar-padding-week.utils.js +20 -16
- 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 +43 -42
- package/dist/components/data-display/calendar/calendar-week-utils.d.ts +6 -0
- package/dist/components/data-display/calendar/calendar-week-utils.js +51 -47
- package/dist/components/data-display/calendar/calendar.js +102 -100
- package/dist/components/data-display/calendar/calendar.types.d.ts +2 -0
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.d.ts +4 -2
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.js +77 -72
- package/dist/components/data-display/calendar/use-fiscal-calendar.js +16 -15
- package/dist/components/feedback/dialog/dialog.js +12 -12
- package/dist/components/feedback/sheet/sheet.js +22 -22
- package/dist/components/feedback/tooltip/tab-tooltip-render.js +2 -3
- 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/calendar-selection-adapters.d.ts +2 -0
- package/dist/components/forms/date-picker/calendar-selection-adapters.js +36 -31
- package/dist/components/forms/date-picker/date-input-behavior.d.ts +10 -0
- package/dist/components/forms/date-picker/date-input-behavior.js +111 -90
- package/dist/components/forms/date-picker/date-picker.js +71 -69
- package/dist/components/forms/date-picker/date-picker.types.d.ts +2 -0
- package/dist/components/forms/date-picker/date-range-picker.js +146 -144
- package/dist/components/forms/date-picker/fiscal-pass-through.d.ts +1 -0
- package/dist/components/forms/date-picker/fiscal-pass-through.js +1 -0
- package/dist/components/forms/date-picker/month-picker.js +82 -80
- package/dist/components/forms/date-picker/month-range-picker.js +145 -143
- 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/picker-story-layout.d.ts +2 -0
- 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 +82 -80
- package/dist/components/forms/date-picker/week-range-picker.js +169 -164
- 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/SelectMenuPanel.js +3 -2
- package/dist/components/forms/select/components/SelectTriggerValue.js +2 -3
- package/dist/components/forms/select/components/Submenu.js +2 -3
- package/dist/components/forms/select/select.js +1 -0
- package/dist/components/forms/smart-input/smart-input.js +106 -85
- package/dist/components/forms/smart-input/smart-input.types.d.ts +5 -0
- package/dist/components/forms/textarea/textarea.js +29 -28
- package/dist/components/forms/textarea/textarea.types.d.ts +1 -0
- package/dist/form-react/Fields/TextField.js +25 -24
- package/dist/form-react/Fields/WeekRangePicker.js +47 -48
- package/dist/form-react/types/fields.types.d.ts +8 -0
- package/dist/impact-nova.css +1 -1
- package/dist/lib/fiscal-calendar/civil-date.js +18 -18
- package/dist/lib/overlay/overlay-portal-context.js +16 -16
- package/dist/llms/rules/best-practices.js +1 -1
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/real-world-patterns.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +1 -1
|
@@ -25,6 +25,8 @@ export declare function createRangePickerOpenChangeHandler(options: {
|
|
|
25
25
|
popoverContentRef: RefObject<HTMLElement | null>;
|
|
26
26
|
setOpen: (open: boolean) => void;
|
|
27
27
|
}): (newOpen: boolean) => void;
|
|
28
|
+
export declare function isNestedPickerOverlayOpen(): boolean;
|
|
29
|
+
export declare function isEventOnNestedPickerOverlay(event: Event): boolean;
|
|
28
30
|
/** True when the outside-dismiss event originated on the picker field chrome (not a real outside click). */
|
|
29
31
|
export declare function isEventOnPickerSurface(event: Event, surfaceRef: RefObject<HTMLElement | null>): boolean;
|
|
30
32
|
export type PickerSurfaceField = "start" | "end";
|
|
@@ -41,6 +43,14 @@ export declare function handleReadonlyPickerKeyDown(event: React.KeyboardEvent,
|
|
|
41
43
|
onCancel: () => void;
|
|
42
44
|
onKeyboardOpen?: () => void;
|
|
43
45
|
}): void;
|
|
46
|
+
/** Close the picker on Escape unless a nested caption overlay is handling it. */
|
|
47
|
+
export declare function handlePickerEscapeKeyDown(event: {
|
|
48
|
+
key: string;
|
|
49
|
+
preventDefault: () => void;
|
|
50
|
+
}, options: {
|
|
51
|
+
open: boolean;
|
|
52
|
+
onCancel: () => void;
|
|
53
|
+
}): void;
|
|
44
54
|
/** Opens the picker when clicking dead zones on the field shell (padding, gaps, icon gutter). */
|
|
45
55
|
export declare function handlePickerSurfacePointerDown({ disabled, event, onOpen, focusField, }: PickerSurfacePointerDownOptions): void;
|
|
46
56
|
/** Block Radix outside-dismiss when the calendar footer requires explicit Apply/Cancel. */
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { parse as
|
|
2
|
-
import * as
|
|
3
|
-
import { resolveRangeFooterFlashTarget as
|
|
4
|
-
import { padValidDateString as
|
|
5
|
-
function
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
function
|
|
9
|
-
const r =
|
|
1
|
+
import { parse as D, isValid as k } from "date-fns";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
import { resolveRangeFooterFlashTarget as E } from "../../data-display/calendar/calendar-footer-emphasis.js";
|
|
4
|
+
import { padValidDateString as O, maskDate as v } from "../../../lib/utils.js";
|
|
5
|
+
function b(e, t, n) {
|
|
6
|
+
return v(e, t, n);
|
|
7
|
+
}
|
|
8
|
+
function p(e, t, n) {
|
|
9
|
+
const r = O(e, t), a = D(r, t, /* @__PURE__ */ new Date(), n ? { locale: n } : {}), i = k(a) && r.length === t.length;
|
|
10
10
|
return {
|
|
11
11
|
padded: r,
|
|
12
|
-
parsed:
|
|
12
|
+
parsed: i ? a : void 0,
|
|
13
13
|
isComplete: e.length === t.length,
|
|
14
|
-
isValid:
|
|
14
|
+
isValid: i
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return !e || e.length !== t.length ? !1 : !
|
|
17
|
+
function B(e, t, n) {
|
|
18
|
+
return !e || e.length !== t.length ? !1 : !p(e, t, n).isValid;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function g(e, t) {
|
|
21
21
|
const n = document.activeElement;
|
|
22
22
|
return n instanceof Node ? !!(e.current?.contains(n) || t.current?.contains(n)) : !1;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function N(e) {
|
|
25
25
|
return (t) => {
|
|
26
26
|
if (!e.disabled) {
|
|
27
27
|
if (t) {
|
|
@@ -33,37 +33,55 @@ function S(e) {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
queueMicrotask(() => {
|
|
36
|
-
|
|
36
|
+
g(e.containerRef, e.popoverContentRef) || e.setOpen(!1);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
const f = '[data-component="select-menu"], [data-component="dropdown-menu-content"]';
|
|
42
|
+
function h() {
|
|
43
|
+
return !!document.querySelector(f);
|
|
44
|
+
}
|
|
45
|
+
function P(e) {
|
|
46
|
+
if ((typeof e.composedPath == "function" ? e.composedPath() : []).some(
|
|
47
|
+
(r) => r instanceof Element && r.closest(f)
|
|
48
|
+
))
|
|
49
|
+
return !0;
|
|
50
|
+
const n = e.target;
|
|
51
|
+
return n instanceof Element ? !!n.closest(f) : !1;
|
|
52
|
+
}
|
|
53
|
+
function R(e, t) {
|
|
42
54
|
const n = e.target;
|
|
43
55
|
return n instanceof Node ? !!t.current?.contains(n) : !1;
|
|
44
56
|
}
|
|
45
|
-
function
|
|
46
|
-
t.disabled || (e.key === "ArrowDown" && !t.open && (e.preventDefault(), t.onKeyboardOpen?.(), t.onOpen()), e.key === "Escape" && t.open && (e
|
|
57
|
+
function q(e, t) {
|
|
58
|
+
t.disabled || (e.key === "ArrowDown" && !t.open && (e.preventDefault(), t.onKeyboardOpen?.(), t.onOpen()), e.key === "Escape" && t.open && w(e, {
|
|
59
|
+
open: t.open,
|
|
60
|
+
onCancel: t.onCancel
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function w(e, t) {
|
|
64
|
+
e.key !== "Escape" || !t.open || h() || (e.preventDefault(), t.onCancel());
|
|
47
65
|
}
|
|
48
|
-
function
|
|
66
|
+
function K({
|
|
49
67
|
disabled: e,
|
|
50
68
|
event: t,
|
|
51
69
|
onOpen: n,
|
|
52
70
|
focusField: r
|
|
53
71
|
}) {
|
|
54
72
|
if (e) return;
|
|
55
|
-
const
|
|
56
|
-
if (!(
|
|
57
|
-
const
|
|
58
|
-
r(
|
|
73
|
+
const a = t.target;
|
|
74
|
+
if (!(a instanceof HTMLElement) || a.closest("button") || (n(), !r)) return;
|
|
75
|
+
const s = a.closest("[data-field]")?.getAttribute("data-field");
|
|
76
|
+
r(s === "end" ? "end" : "start");
|
|
59
77
|
}
|
|
60
|
-
function
|
|
78
|
+
function C(e, t, n, r) {
|
|
61
79
|
return e ? {
|
|
62
|
-
onInteractOutside: (
|
|
63
|
-
|
|
80
|
+
onInteractOutside: (s) => {
|
|
81
|
+
s.preventDefault();
|
|
64
82
|
},
|
|
65
|
-
onPointerDownOutside: (
|
|
66
|
-
if (
|
|
83
|
+
onPointerDownOutside: (s) => {
|
|
84
|
+
if (s.preventDefault(), !(P(s) || r && R(s, r)) && t) {
|
|
67
85
|
const o = t.current.resolveFlash();
|
|
68
86
|
if (o === "dismiss") {
|
|
69
87
|
t.current.onDismiss();
|
|
@@ -72,96 +90,96 @@ function F(e, t, n, r) {
|
|
|
72
90
|
n?.(o);
|
|
73
91
|
}
|
|
74
92
|
},
|
|
75
|
-
onEscapeKeyDown: t ? (
|
|
76
|
-
|
|
93
|
+
onEscapeKeyDown: t ? (s) => {
|
|
94
|
+
s.preventDefault(), !h() && t.current.onDismiss();
|
|
77
95
|
} : void 0
|
|
78
96
|
} : {};
|
|
79
97
|
}
|
|
80
|
-
function
|
|
81
|
-
const r = e == null,
|
|
82
|
-
return r &&
|
|
98
|
+
function M(e, t, n) {
|
|
99
|
+
const r = e == null, a = t == null;
|
|
100
|
+
return r && a || !r && !a && n(e, t) ? "dismiss" : r ? "cancel" : "apply";
|
|
83
101
|
}
|
|
84
|
-
function
|
|
102
|
+
function L(e) {
|
|
85
103
|
const {
|
|
86
104
|
startInput: t,
|
|
87
105
|
endInput: n,
|
|
88
106
|
committedStart: r,
|
|
89
|
-
committedEnd:
|
|
90
|
-
committedRange:
|
|
91
|
-
pendingRange:
|
|
107
|
+
committedEnd: a,
|
|
108
|
+
committedRange: i,
|
|
109
|
+
pendingRange: s,
|
|
92
110
|
computeEffectiveRange: u,
|
|
93
111
|
rangesEqual: o
|
|
94
|
-
} = e, c = t !== r || n !==
|
|
95
|
-
return !c && !
|
|
96
|
-
c ?
|
|
112
|
+
} = e, c = t !== r || n !== a, d = u(), m = !c && s !== void 0 ? s : d, y = !o(m, i);
|
|
113
|
+
return !c && !y ? "dismiss" : E(
|
|
114
|
+
c ? d : m
|
|
97
115
|
) === "apply" ? "apply" : "cancel";
|
|
98
116
|
}
|
|
99
|
-
function
|
|
100
|
-
return
|
|
117
|
+
function X() {
|
|
118
|
+
return l.useRef({
|
|
101
119
|
onDismiss: () => {
|
|
102
120
|
},
|
|
103
121
|
resolveFlash: () => "cancel"
|
|
104
122
|
});
|
|
105
123
|
}
|
|
106
|
-
function
|
|
107
|
-
const [
|
|
108
|
-
|
|
109
|
-
|
|
124
|
+
function x(e, t, n, r) {
|
|
125
|
+
const [a, i] = l.useState({ key: 0, target: "cancel" }), s = l.useRef(t);
|
|
126
|
+
l.useLayoutEffect(() => {
|
|
127
|
+
s.current !== t && (s.current = t, i({ key: 0, target: "cancel" }));
|
|
110
128
|
}, [t]);
|
|
111
|
-
const u =
|
|
129
|
+
const u = l.useCallback(
|
|
112
130
|
(c) => {
|
|
113
|
-
e &&
|
|
131
|
+
e && i((d) => ({ key: d.key + 1, target: c }));
|
|
114
132
|
},
|
|
115
133
|
[e]
|
|
116
|
-
), o =
|
|
134
|
+
), o = C(
|
|
117
135
|
e,
|
|
118
136
|
n,
|
|
119
137
|
u,
|
|
120
138
|
r
|
|
121
139
|
);
|
|
122
140
|
return {
|
|
123
|
-
footerFlashKey:
|
|
124
|
-
footerFlashTarget:
|
|
141
|
+
footerFlashKey: a.key,
|
|
142
|
+
footerFlashTarget: a.key > 0 ? a.target : void 0,
|
|
125
143
|
triggerFooterFlash: u,
|
|
126
144
|
popoverHandlers: o
|
|
127
145
|
};
|
|
128
146
|
}
|
|
129
|
-
function
|
|
147
|
+
function H(e, t, n) {
|
|
130
148
|
queueMicrotask(() => {
|
|
131
|
-
|
|
149
|
+
g(e, t) || n();
|
|
132
150
|
});
|
|
133
151
|
}
|
|
134
|
-
function
|
|
152
|
+
function F(e, t, n, r) {
|
|
135
153
|
if (!e)
|
|
136
154
|
return { display: "", parsed: void 0, resetToCommitted: !1 };
|
|
137
|
-
const
|
|
138
|
-
return
|
|
139
|
-
display:
|
|
140
|
-
parsed:
|
|
155
|
+
const a = p(e, t, r);
|
|
156
|
+
return a.isValid ? {
|
|
157
|
+
display: a.padded,
|
|
158
|
+
parsed: a.parsed,
|
|
141
159
|
resetToCommitted: !1
|
|
142
160
|
} : e.length < t.length ? { display: e, parsed: void 0, resetToCommitted: !1 } : { display: n, parsed: void 0, resetToCommitted: !0 };
|
|
143
161
|
}
|
|
144
|
-
function
|
|
145
|
-
const
|
|
162
|
+
function _(e, t, n, r) {
|
|
163
|
+
const a = F(e, t, n, r);
|
|
146
164
|
return {
|
|
147
|
-
...
|
|
148
|
-
isPartial: !!e && e.length < t.length && !
|
|
165
|
+
...a,
|
|
166
|
+
isPartial: !!e && e.length < t.length && !a.resetToCommitted
|
|
149
167
|
};
|
|
150
168
|
}
|
|
151
|
-
function
|
|
152
|
-
const r =
|
|
169
|
+
function z(e, t, n) {
|
|
170
|
+
const r = p(e, t, n);
|
|
153
171
|
return r.isValid && r.parsed ? { parsed: r.parsed, shouldOpenPopover: !1 } : { parsed: void 0, shouldOpenPopover: !0 };
|
|
154
172
|
}
|
|
155
|
-
function
|
|
173
|
+
function A(e, t, n) {
|
|
156
174
|
return e === void 0 || t === void 0 ? { from: e, to: t, swapped: !1 } : n(e, t) <= 0 ? { from: e, to: t, swapped: !1 } : { from: t, to: e, swapped: !0 };
|
|
157
175
|
}
|
|
158
|
-
function
|
|
176
|
+
function W(e, t) {
|
|
159
177
|
return e.year * 12 + e.month - (t.year * 12 + t.month);
|
|
160
178
|
}
|
|
161
|
-
function
|
|
179
|
+
function Y(e, t) {
|
|
162
180
|
return e.getTime() - t.getTime();
|
|
163
181
|
}
|
|
164
|
-
function
|
|
182
|
+
function j(e) {
|
|
165
183
|
if (!e || typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
166
184
|
return;
|
|
167
185
|
const t = e.querySelector('[data-field="start"]'), n = e.querySelector('[data-field="end"]');
|
|
@@ -176,25 +194,28 @@ function W(e) {
|
|
|
176
194
|
));
|
|
177
195
|
}
|
|
178
196
|
export {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
Y as compareDates,
|
|
198
|
+
W as compareMonthSelection,
|
|
199
|
+
N as createRangePickerOpenChangeHandler,
|
|
200
|
+
H as deferRangeInputBlur,
|
|
201
|
+
j as flashRangeReorder,
|
|
202
|
+
w as handlePickerEscapeKeyDown,
|
|
203
|
+
K as handlePickerSurfacePointerDown,
|
|
204
|
+
q as handleReadonlyPickerKeyDown,
|
|
205
|
+
B as isDateInputInvalid,
|
|
206
|
+
P as isEventOnNestedPickerOverlay,
|
|
207
|
+
R as isEventOnPickerSurface,
|
|
208
|
+
g as isFocusInsidePicker,
|
|
209
|
+
h as isNestedPickerOverlayOpen,
|
|
210
|
+
b as maskDateInput,
|
|
211
|
+
A as normalizeOrderedRange,
|
|
212
|
+
p as parseDateInput,
|
|
213
|
+
C as preventOutsideDismissWhenFooter,
|
|
214
|
+
F as resolveDateInputOnBlur,
|
|
215
|
+
z as resolveDateInputOnEnter,
|
|
216
|
+
_ as resolveRangeFieldBlur,
|
|
217
|
+
L as resolveRangePickerDismissFlash,
|
|
218
|
+
M as resolveSingleValueDismissFlash,
|
|
219
|
+
X as usePickerDismissActionsRef,
|
|
220
|
+
x as usePickerFooterDismissNudge
|
|
200
221
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsx as s, jsxs as S } from "react/jsx-runtime";
|
|
2
2
|
import * as r from "react";
|
|
3
|
-
import { Cross as
|
|
3
|
+
import { Cross as De, CalendarMonth as ge } from "impact-nova-icons";
|
|
4
4
|
import { format as b } from "date-fns";
|
|
5
|
-
import { cn as
|
|
6
|
-
import { usePickerDismissActionsRef as
|
|
7
|
-
import { Input as
|
|
8
|
-
import { Calendar as
|
|
9
|
-
import { Tooltip as
|
|
10
|
-
import { useImpactNovaI18n as
|
|
11
|
-
import { getDateFnsLocale as
|
|
12
|
-
import { createComponent as
|
|
13
|
-
import { coerceSingleDateApply as
|
|
14
|
-
import { buildDateBoundsMatcher as
|
|
15
|
-
import { fiscalCalendarPassThrough as
|
|
16
|
-
import { DatePickerShell as
|
|
17
|
-
const
|
|
5
|
+
import { cn as ye } from "../../../lib/utils.js";
|
|
6
|
+
import { usePickerDismissActionsRef as ke, usePickerFooterDismissNudge as ve, isDateInputInvalid as Ce, resolveSingleValueDismissFlash as Ie, handlePickerEscapeKeyDown as Pe, handlePickerSurfacePointerDown as Me, maskDateInput as xe, parseDateInput as Re, resolveDateInputOnBlur as Se, resolveDateInputOnEnter as be } from "./date-input-behavior.js";
|
|
7
|
+
import { Input as we } from "../input/input.js";
|
|
8
|
+
import { Calendar as Te } from "../../data-display/calendar/calendar.js";
|
|
9
|
+
import { Tooltip as K, TooltipTrigger as j, TooltipContent as B } from "../../feedback/tooltip/tooltip.js";
|
|
10
|
+
import { useImpactNovaI18n as Ee } from "../../../i18n/use-impact-nova-i18n.js";
|
|
11
|
+
import { getDateFnsLocale as Ae } from "../../../i18n/getDateFnsLocale.js";
|
|
12
|
+
import { createComponent as Ne } from "../../../lib/primitives/create-component.js";
|
|
13
|
+
import { coerceSingleDateApply as Le, coerceSingleDate as Oe } from "./calendar-selection-adapters.js";
|
|
14
|
+
import { buildDateBoundsMatcher as Ve } from "../../../lib/date-bounds-matcher.js";
|
|
15
|
+
import { fiscalCalendarPassThrough as Ke } from "./fiscal-pass-through.js";
|
|
16
|
+
import { DatePickerShell as je } from "./date-picker-shell.js";
|
|
17
|
+
const et = Ne(
|
|
18
18
|
"DatePicker",
|
|
19
19
|
({
|
|
20
20
|
value: n,
|
|
@@ -36,13 +36,14 @@ const $e = Ee(
|
|
|
36
36
|
fiscalYearStartMonth: Z,
|
|
37
37
|
fiscalConfig: _,
|
|
38
38
|
showPresets: $,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
r.
|
|
45
|
-
|
|
39
|
+
showPeriodBoundaries: F,
|
|
40
|
+
comparison: ee,
|
|
41
|
+
onComparisonChange: te,
|
|
42
|
+
...ne
|
|
43
|
+
}, re) => {
|
|
44
|
+
const { locale: T, t: h } = Ee(), f = r.useMemo(() => Ae(T), [T]), ie = z ?? h("datePicker.selectDate"), g = r.useRef(null), E = r.useRef(null), I = r.useRef(null);
|
|
45
|
+
r.useImperativeHandle(re, () => g.current);
|
|
46
|
+
const [i, A] = r.useState(!1), N = ke(), { footerFlashKey: oe, footerFlashTarget: se, popoverHandlers: ce } = ve(a, i, N, E), y = r.useRef(!1), [x, o] = r.useState(null), k = n ? b(n, l, { locale: f }) : "", d = x?.input ?? k, P = i ? x?.pending ?? n : n, le = x?.viewMonth ?? n ?? /* @__PURE__ */ new Date(), u = r.useCallback(() => {
|
|
46
47
|
o(null), A(!1);
|
|
47
48
|
}, []), m = (e) => {
|
|
48
49
|
if (!c) {
|
|
@@ -58,15 +59,15 @@ const $e = Ee(
|
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
r.useEffect(() => {
|
|
61
|
-
g.current &&
|
|
62
|
+
g.current && I.current !== null && (g.current.setSelectionRange(I.current, I.current), I.current = null);
|
|
62
63
|
}, [d]);
|
|
63
|
-
const
|
|
64
|
-
const t =
|
|
64
|
+
const ae = (e) => {
|
|
65
|
+
const t = Oe(e), D = t ? b(t, l, { locale: f }) : "";
|
|
65
66
|
o(
|
|
66
67
|
(v) => v ? { ...v, pending: t, input: D, viewMonth: t ?? v.viewMonth } : null
|
|
67
68
|
), t && !a && (p?.(t), u());
|
|
68
69
|
}, L = (e) => {
|
|
69
|
-
const t =
|
|
70
|
+
const t = Le(e, P);
|
|
70
71
|
p?.(t), u();
|
|
71
72
|
}, R = () => {
|
|
72
73
|
u();
|
|
@@ -81,27 +82,27 @@ const $e = Ee(
|
|
|
81
82
|
viewMonth: n ?? /* @__PURE__ */ new Date()
|
|
82
83
|
}),
|
|
83
84
|
[k, n]
|
|
84
|
-
),
|
|
85
|
-
const t =
|
|
86
|
-
if (o((
|
|
87
|
-
o((
|
|
85
|
+
), ue = (e) => {
|
|
86
|
+
const t = xe(e.target.value, l, d);
|
|
87
|
+
if (o((C) => ({ ...C ?? M(), input: t })), t === "") {
|
|
88
|
+
o((C) => ({ ...C ?? M(), input: "", pending: void 0 })), a || p?.(void 0);
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
|
-
const { parsed: D, isValid: v } =
|
|
91
|
-
v && D && (o((
|
|
92
|
-
...
|
|
91
|
+
const { parsed: D, isValid: v } = Re(t, l, f);
|
|
92
|
+
v && D && (o((C) => ({
|
|
93
|
+
...C ?? M(),
|
|
93
94
|
input: t,
|
|
94
95
|
pending: D,
|
|
95
96
|
viewMonth: D
|
|
96
97
|
})), a || p?.(D));
|
|
97
|
-
},
|
|
98
|
+
}, pe = r.useCallback(
|
|
98
99
|
(e) => {
|
|
99
100
|
p?.(e), u();
|
|
100
101
|
},
|
|
101
102
|
[p, u]
|
|
102
|
-
),
|
|
103
|
+
), fe = () => {
|
|
103
104
|
if (i) return;
|
|
104
|
-
const e =
|
|
105
|
+
const e = Se(
|
|
105
106
|
d,
|
|
106
107
|
l,
|
|
107
108
|
k,
|
|
@@ -121,18 +122,18 @@ const $e = Ee(
|
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
124
|
o(null);
|
|
124
|
-
},
|
|
125
|
+
}, de = () => {
|
|
125
126
|
if (i && a) {
|
|
126
127
|
L();
|
|
127
128
|
return;
|
|
128
129
|
}
|
|
129
|
-
const e =
|
|
130
|
+
const e = be(d, l, f);
|
|
130
131
|
if (e.parsed) {
|
|
131
|
-
a &&
|
|
132
|
+
a && pe(e.parsed);
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
134
135
|
i || (y.current = !0, m(!0));
|
|
135
|
-
}, V = (n ? b(n, l, { locale: f }) : "") !== d,
|
|
136
|
+
}, V = (n ? b(n, l, { locale: f }) : "") !== d, me = Ce(d, l, f), he = r.useCallback(
|
|
136
137
|
() => Ie(
|
|
137
138
|
P,
|
|
138
139
|
n,
|
|
@@ -143,10 +144,10 @@ const $e = Ee(
|
|
|
143
144
|
return r.useLayoutEffect(() => {
|
|
144
145
|
N.current = {
|
|
145
146
|
onDismiss: R,
|
|
146
|
-
resolveFlash:
|
|
147
|
+
resolveFlash: he
|
|
147
148
|
};
|
|
148
149
|
}), /* @__PURE__ */ s(
|
|
149
|
-
|
|
150
|
+
je,
|
|
150
151
|
{
|
|
151
152
|
open: i,
|
|
152
153
|
disabled: c,
|
|
@@ -155,7 +156,7 @@ const $e = Ee(
|
|
|
155
156
|
onOpenAutoFocus: (e) => {
|
|
156
157
|
y.current || e.preventDefault(), y.current = !1;
|
|
157
158
|
},
|
|
158
|
-
popoverHandlers:
|
|
159
|
+
popoverHandlers: ce,
|
|
159
160
|
trigger: /* @__PURE__ */ s(
|
|
160
161
|
"div",
|
|
161
162
|
{
|
|
@@ -163,34 +164,34 @@ const $e = Ee(
|
|
|
163
164
|
"data-component": "date-picker",
|
|
164
165
|
"data-state": i ? "open" : "closed",
|
|
165
166
|
"data-pending": V || void 0,
|
|
166
|
-
onPointerDown: (e) =>
|
|
167
|
+
onPointerDown: (e) => Me({
|
|
167
168
|
disabled: c,
|
|
168
169
|
event: e,
|
|
169
170
|
onOpen: () => m(!0),
|
|
170
171
|
focusField: () => g.current?.focus()
|
|
171
172
|
}),
|
|
172
173
|
children: /* @__PURE__ */ s(
|
|
173
|
-
|
|
174
|
+
we,
|
|
174
175
|
{
|
|
175
176
|
ref: g,
|
|
176
177
|
value: d,
|
|
177
|
-
onChange:
|
|
178
|
-
onBlur:
|
|
178
|
+
onChange: ue,
|
|
179
|
+
onBlur: fe,
|
|
179
180
|
onClick: () => !c && m(!0),
|
|
180
181
|
onKeyDown: (e) => {
|
|
181
|
-
e.key === "Enter" && !c && (e.preventDefault(),
|
|
182
|
+
e.key === "Enter" && !c && (e.preventDefault(), de()), e.key === "ArrowDown" && !i && !c && (e.preventDefault(), y.current = !0, m(!0)), e.key === "Escape" && i && Pe(e, { open: i, onCancel: R });
|
|
182
183
|
},
|
|
183
|
-
placeholder: i ? l :
|
|
184
|
+
placeholder: i ? l : ie,
|
|
184
185
|
disabled: c,
|
|
185
186
|
"data-form-control": "input",
|
|
186
|
-
className:
|
|
187
|
+
className: ye(
|
|
187
188
|
"cursor-pointer",
|
|
188
|
-
|
|
189
|
+
me ? "text-destructive" : V ? "text-content-placeholder" : "",
|
|
189
190
|
Q
|
|
190
191
|
),
|
|
191
192
|
suffix: /* @__PURE__ */ S("div", { className: "flex items-center gap-1", children: [
|
|
192
|
-
n && !c && /* @__PURE__ */ S(
|
|
193
|
-
/* @__PURE__ */ s(
|
|
193
|
+
n && !c && /* @__PURE__ */ S(K, { children: [
|
|
194
|
+
/* @__PURE__ */ s(j, { asChild: !0, children: /* @__PURE__ */ s(
|
|
194
195
|
"button",
|
|
195
196
|
{
|
|
196
197
|
type: "button",
|
|
@@ -200,38 +201,38 @@ const $e = Ee(
|
|
|
200
201
|
e.stopPropagation(), O();
|
|
201
202
|
},
|
|
202
203
|
className: "inline-flex size-4 items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
203
|
-
children: /* @__PURE__ */ s(
|
|
204
|
+
children: /* @__PURE__ */ s(De, { className: "size-3 hover:text-content" })
|
|
204
205
|
}
|
|
205
206
|
) }),
|
|
206
|
-
/* @__PURE__ */ s(
|
|
207
|
+
/* @__PURE__ */ s(B, { variant: "tertiary", side: "top", children: h("calendar.clear") })
|
|
207
208
|
] }),
|
|
208
|
-
/* @__PURE__ */ S(
|
|
209
|
-
/* @__PURE__ */ s(
|
|
209
|
+
/* @__PURE__ */ S(K, { children: [
|
|
210
|
+
/* @__PURE__ */ s(j, { asChild: !0, children: /* @__PURE__ */ s("button", { type: "button", tabIndex: 0, "aria-label": h("datePicker.selectDate"), onClick: (e) => {
|
|
210
211
|
e.stopPropagation(), c || (i ? u() : m(!0));
|
|
211
212
|
}, onKeyDown: (e) => {
|
|
212
213
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), c || (y.current = !0, i ? u() : m(!0)));
|
|
213
|
-
}, className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer", children: /* @__PURE__ */ s(
|
|
214
|
-
/* @__PURE__ */ s(
|
|
214
|
+
}, className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer", children: /* @__PURE__ */ s(ge, { className: "h-4 w-4 text-secondary-foreground" }) }) }),
|
|
215
|
+
/* @__PURE__ */ s(B, { variant: "tertiary", side: "top", children: h("datePicker.selectDate") })
|
|
215
216
|
] })
|
|
216
217
|
] }),
|
|
217
|
-
...
|
|
218
|
+
...ne
|
|
218
219
|
}
|
|
219
220
|
)
|
|
220
221
|
}
|
|
221
222
|
),
|
|
222
223
|
children: /* @__PURE__ */ s(
|
|
223
|
-
|
|
224
|
+
Te,
|
|
224
225
|
{
|
|
225
226
|
mode: "single",
|
|
226
227
|
selected: P,
|
|
227
|
-
footerFlashKey:
|
|
228
|
-
footerFlashTarget:
|
|
229
|
-
onSelect:
|
|
230
|
-
month:
|
|
228
|
+
footerFlashKey: oe,
|
|
229
|
+
footerFlashTarget: se,
|
|
230
|
+
onSelect: ae,
|
|
231
|
+
month: le,
|
|
231
232
|
onMonthChange: (e) => o(
|
|
232
233
|
(t) => t ? { ...t, viewMonth: e } : null
|
|
233
234
|
),
|
|
234
|
-
disabled:
|
|
235
|
+
disabled: Ve(H, q),
|
|
235
236
|
startMonth: G,
|
|
236
237
|
endMonth: J,
|
|
237
238
|
showFooter: a,
|
|
@@ -240,7 +241,7 @@ const $e = Ee(
|
|
|
240
241
|
onClear: O,
|
|
241
242
|
captionLayout: "dropdown",
|
|
242
243
|
...w !== void 0 ? { weekStartsOn: w } : {},
|
|
243
|
-
...
|
|
244
|
+
...Ke({
|
|
244
245
|
calendarKind: U,
|
|
245
246
|
fiscalMode: W,
|
|
246
247
|
granularity: X,
|
|
@@ -248,8 +249,9 @@ const $e = Ee(
|
|
|
248
249
|
fiscalYearStartMonth: Z,
|
|
249
250
|
fiscalConfig: _,
|
|
250
251
|
showPresets: $,
|
|
251
|
-
|
|
252
|
-
|
|
252
|
+
showPeriodBoundaries: F,
|
|
253
|
+
comparison: ee,
|
|
254
|
+
onComparisonChange: te
|
|
253
255
|
})
|
|
254
256
|
}
|
|
255
257
|
)
|
|
@@ -258,5 +260,5 @@ const $e = Ee(
|
|
|
258
260
|
}
|
|
259
261
|
);
|
|
260
262
|
export {
|
|
261
|
-
|
|
263
|
+
et as DatePicker
|
|
262
264
|
};
|
|
@@ -11,6 +11,8 @@ export interface FiscalPickerProps {
|
|
|
11
11
|
fiscalConfig?: FiscalCalendarConfig;
|
|
12
12
|
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
13
13
|
showPresets?: boolean;
|
|
14
|
+
/** Draw `(` / `)` on fiscal period start/end days. Default false. */
|
|
15
|
+
showPeriodBoundaries?: boolean;
|
|
14
16
|
comparison?: "prior-fy";
|
|
15
17
|
onComparisonChange?: (value: YoYComparison | undefined) => void;
|
|
16
18
|
}
|