impact-nova 2.5.7 → 2.5.8
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/ag-grid-react/ag-grid.types.d.ts +2 -2
- package/dist/components/data/ag-grid-react/headers/components/date-filter-picker.d.ts +4 -2
- package/dist/components/data/ag-grid-react/headers/header-search-input.js +65 -65
- package/dist/components/data/ag-grid-react/headers/utils/date-utils.js +55 -48
- package/dist/components/data-display/calendar/calendar-apply-validation.d.ts +4 -2
- package/dist/components/data-display/calendar/calendar-apply-validation.js +80 -61
- package/dist/components/data-display/calendar/calendar-config.d.ts +13 -5
- package/dist/components/data-display/calendar/calendar-config.js +31 -20
- package/dist/components/data-display/calendar/calendar-day-button.js +43 -35
- package/dist/components/data-display/calendar/calendar-day-hover.d.ts +8 -0
- package/dist/components/data-display/calendar/calendar-day-hover.js +20 -0
- package/dist/components/data-display/calendar/calendar-day-picker-classnames.d.ts +8 -1
- package/dist/components/data-display/calendar/calendar-day-picker-classnames.js +40 -20
- package/dist/components/data-display/calendar/calendar-day-picker-components.d.ts +12 -1
- package/dist/components/data-display/calendar/calendar-day-picker-components.js +201 -108
- package/dist/components/data-display/calendar/calendar-day-picker-view.d.ts +11 -3
- package/dist/components/data-display/calendar/calendar-day-picker-view.js +136 -92
- package/dist/components/data-display/calendar/calendar-fiscal-labels.d.ts +38 -0
- package/dist/components/data-display/calendar/calendar-fiscal-labels.js +90 -0
- package/dist/components/data-display/calendar/calendar-footer-summary.d.ts +13 -4
- package/dist/components/data-display/calendar/calendar-footer-summary.js +101 -50
- package/dist/components/data-display/calendar/calendar-footer.d.ts +16 -7
- package/dist/components/data-display/calendar/calendar-footer.js +88 -66
- package/dist/components/data-display/calendar/calendar-gregorian-presets.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-gregorian-presets.js +26 -0
- package/dist/components/data-display/calendar/calendar-interval-caption.d.ts +1 -0
- package/dist/components/data-display/calendar/calendar-interval-caption.js +10 -0
- package/dist/components/data-display/calendar/calendar-interval-utils.d.ts +23 -0
- package/dist/components/data-display/calendar/calendar-interval-utils.js +154 -0
- package/dist/components/data-display/calendar/calendar-month-panes.d.ts +5 -1
- package/dist/components/data-display/calendar/calendar-month-panes.js +9 -7
- package/dist/components/data-display/calendar/calendar-month-picker-panel.d.ts +5 -1
- package/dist/components/data-display/calendar/calendar-month-picker-panel.js +76 -77
- package/dist/components/data-display/calendar/calendar-month-utils.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-month-utils.js +69 -60
- package/dist/components/data-display/calendar/calendar-padding-week.utils.d.ts +15 -0
- package/dist/components/data-display/calendar/calendar-padding-week.utils.js +22 -3
- package/dist/components/data-display/calendar/calendar-panel-context.d.ts +1 -1
- package/dist/components/data-display/calendar/calendar-period-cell.d.ts +18 -0
- package/dist/components/data-display/calendar/calendar-period-cell.js +89 -0
- package/dist/components/data-display/calendar/calendar-period-keyboard.d.ts +2 -0
- package/dist/components/data-display/calendar/calendar-period-keyboard.js +18 -0
- package/dist/components/data-display/calendar/calendar-preset-strip.d.ts +6 -0
- package/dist/components/data-display/calendar/calendar-preset-strip.js +26 -0
- package/dist/components/data-display/calendar/calendar-quarter-panes.d.ts +24 -0
- package/dist/components/data-display/calendar/calendar-quarter-panes.js +115 -0
- package/dist/components/data-display/calendar/calendar-quarter-utils.d.ts +19 -0
- package/dist/components/data-display/calendar/calendar-quarter-utils.js +95 -0
- package/dist/components/data-display/calendar/calendar-selection-appearance.d.ts +38 -0
- package/dist/components/data-display/calendar/calendar-selection-appearance.js +72 -0
- package/dist/components/data-display/calendar/calendar-selection.d.ts +20 -0
- package/dist/components/data-display/calendar/calendar-selection.js +31 -0
- package/dist/components/data-display/calendar/calendar-week-number-cell.d.ts +6 -1
- package/dist/components/data-display/calendar/calendar-week-number-cell.js +53 -38
- package/dist/components/data-display/calendar/calendar-week-number-header.d.ts +4 -0
- package/dist/components/data-display/calendar/calendar-week-number-header.js +15 -0
- package/dist/components/data-display/calendar/calendar-week-utils.d.ts +11 -3
- package/dist/components/data-display/calendar/calendar-week-utils.js +49 -42
- package/dist/components/data-display/calendar/calendar-year-panes.d.ts +18 -0
- package/dist/components/data-display/calendar/calendar-year-panes.js +98 -0
- package/dist/components/data-display/calendar/calendar-year-utils.d.ts +17 -0
- package/dist/components/data-display/calendar/calendar-year-utils.js +75 -0
- package/dist/components/data-display/calendar/calendar.d.ts +1 -1
- package/dist/components/data-display/calendar/calendar.js +303 -181
- package/dist/components/data-display/calendar/calendar.types.d.ts +53 -16
- package/dist/components/data-display/calendar/fiscal-period-caption-select.d.ts +7 -0
- package/dist/components/data-display/calendar/fiscal-period-caption-select.js +63 -0
- package/dist/components/data-display/calendar/index.d.ts +1 -1
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.d.ts +12 -2
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.js +92 -62
- package/dist/components/data-display/calendar/use-calendar-state.d.ts +31 -11
- package/dist/components/data-display/calendar/use-calendar-state.js +370 -163
- package/dist/components/data-display/calendar/use-fiscal-calendar.d.ts +5 -0
- package/dist/components/data-display/calendar/use-fiscal-calendar.js +24 -0
- package/dist/components/feedback/tooltip/overflow-tooltip.js +57 -57
- package/dist/components/forms/date-picker/date-input-behavior.d.ts +7 -0
- package/dist/components/forms/date-picker/date-input-behavior.js +28 -24
- package/dist/components/forms/date-picker/date-picker-shell.d.ts +13 -0
- package/dist/components/forms/date-picker/date-picker-shell.js +31 -0
- package/dist/components/forms/date-picker/date-picker.js +187 -167
- package/dist/components/forms/date-picker/date-picker.types.d.ts +90 -43
- package/dist/components/forms/date-picker/date-range-picker.js +273 -224
- package/dist/components/forms/date-picker/fiscal-pass-through.d.ts +13 -0
- package/dist/components/forms/date-picker/fiscal-pass-through.js +17 -0
- package/dist/components/forms/date-picker/fiscal-period-format.d.ts +9 -0
- package/dist/components/forms/date-picker/fiscal-period-format.js +50 -0
- package/dist/components/forms/date-picker/index.d.ts +12 -0
- package/dist/components/forms/date-picker/index.js +19 -7
- package/dist/components/forms/date-picker/month-picker.js +225 -182
- package/dist/components/forms/date-picker/month-range-picker.js +134 -110
- package/dist/components/forms/date-picker/multi-date-picker.js +77 -56
- package/dist/components/forms/date-picker/multi-month-picker.js +78 -57
- package/dist/components/forms/date-picker/multi-quarter-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/multi-quarter-picker.js +177 -0
- package/dist/components/forms/date-picker/multi-week-picker.js +81 -70
- package/dist/components/forms/date-picker/multi-year-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/multi-year-picker.js +179 -0
- package/dist/components/forms/date-picker/quarter-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/quarter-picker.js +176 -0
- package/dist/components/forms/date-picker/quarter-range-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/quarter-range-picker.js +177 -0
- package/dist/components/forms/date-picker/week-picker.js +148 -137
- package/dist/components/forms/date-picker/week-range-picker.js +216 -205
- package/dist/components/forms/date-picker/year-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/year-picker.js +176 -0
- package/dist/components/forms/date-picker/year-range-picker.d.ts +3 -0
- package/dist/components/forms/date-picker/year-range-picker.js +179 -0
- package/dist/form-react/Fields/DateInputField.js +63 -58
- package/dist/form-react/Fields/DateRangeField.js +42 -37
- package/dist/form-react/Fields/MonthRangeField.js +50 -45
- package/dist/form-react/Fields/MultiWeekPickerField.js +7 -7
- package/dist/form-react/Fields/WeekRangePicker.js +44 -45
- package/dist/form-react/components/FieldRenderer.js +21 -23
- package/dist/form-react/registry/defaultFieldRegistrations.d.ts +9 -1
- package/dist/form-react/registry/defaultFieldRegistrations.js +27 -36
- package/dist/form-react/registry/resolveFieldComponent.d.ts +3 -2
- package/dist/form-react/registry/resolveFieldComponent.js +9 -133
- package/dist/form-react/types/fields.types.d.ts +19 -4
- package/dist/form-react/utils/date.utils.d.ts +1 -1
- package/dist/form-react/utils/date.utils.js +38 -38
- package/dist/i18n/defaultMessages.d.ts +19 -1
- package/dist/i18n/defaultMessages.js +37 -20
- package/dist/i18n/locales/de.js +18 -1
- package/dist/i18n/locales/es.js +18 -1
- package/dist/i18n/locales/hi.js +18 -1
- package/dist/i18n/locales/kn.js +18 -1
- package/dist/impact-nova-components.css +379 -3
- package/dist/impact-nova.css +1 -1
- package/dist/index.js +528 -516
- package/dist/lib/fiscal-calendar/build-year.d.ts +8 -0
- package/dist/lib/fiscal-calendar/build-year.js +173 -0
- package/dist/lib/fiscal-calendar/civil-date.d.ts +21 -0
- package/dist/lib/fiscal-calendar/civil-date.js +94 -0
- package/dist/lib/fiscal-calendar/index.d.ts +10 -0
- package/dist/lib/fiscal-calendar/index.js +40 -0
- package/dist/lib/fiscal-calendar/lookup.d.ts +4 -0
- package/dist/lib/fiscal-calendar/lookup.js +70 -0
- package/dist/lib/fiscal-calendar/presets.d.ts +8 -0
- package/dist/lib/fiscal-calendar/presets.js +99 -0
- package/dist/lib/fiscal-calendar/selection.d.ts +18 -0
- package/dist/lib/fiscal-calendar/selection.js +32 -0
- package/dist/lib/fiscal-calendar/types.d.ts +145 -0
- package/dist/lib/fiscal-calendar/types.js +10 -0
- package/dist/lib/fiscal-calendar/week-selection.d.ts +22 -0
- package/dist/lib/fiscal-calendar/week-selection.js +107 -0
- package/package.json +5 -1
- package/dist/lib/fiscal-calendar.d.ts +0 -62
- package/dist/lib/fiscal-calendar.js +0 -99
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { jsxs as f, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import * as a from "react";
|
|
3
|
-
import { Cross as
|
|
4
|
-
import { format as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Input as
|
|
7
|
-
import { Popover as
|
|
8
|
-
import { Calendar as
|
|
3
|
+
import { Cross as Y, CalendarMonth as Z } from "impact-nova-icons";
|
|
4
|
+
import { format as _ } from "date-fns";
|
|
5
|
+
import { cn as ee } from "../../../lib/utils.js";
|
|
6
|
+
import { Input as te } from "../input/input.js";
|
|
7
|
+
import { Popover as re, PopoverAnchor as oe, PopoverContent as ne } from "../../feedback/popover/popover.js";
|
|
8
|
+
import { Calendar as ae } from "../../data-display/calendar/calendar.js";
|
|
9
9
|
import { Tooltip as P, TooltipTrigger as C, TooltipContent as k } from "../../feedback/tooltip/tooltip.js";
|
|
10
|
-
import { useImpactNovaI18n as
|
|
11
|
-
import { getDateFnsLocale as
|
|
12
|
-
import { coerceDateArrayApply as
|
|
13
|
-
import { usePickerDismissActionsRef as
|
|
14
|
-
import { buildDateBoundsMatcher as
|
|
15
|
-
|
|
10
|
+
import { useImpactNovaI18n as se } from "../../../i18n/use-impact-nova-i18n.js";
|
|
11
|
+
import { getDateFnsLocale as ie } from "../../../i18n/getDateFnsLocale.js";
|
|
12
|
+
import { coerceDateArrayApply as ce, coerceDateArray as le } from "./calendar-selection-adapters.js";
|
|
13
|
+
import { usePickerDismissActionsRef as pe, usePickerFooterDismissNudge as de, handlePickerSurfacePointerDown as fe } from "./date-input-behavior.js";
|
|
14
|
+
import { buildDateBoundsMatcher as me } from "../../../lib/date-bounds-matcher.js";
|
|
15
|
+
import { fiscalCalendarPassThrough as ue } from "./fiscal-pass-through.js";
|
|
16
|
+
const he = a.forwardRef(
|
|
16
17
|
({
|
|
17
18
|
value: t,
|
|
18
19
|
onChange: m,
|
|
@@ -23,62 +24,71 @@ const ae = a.forwardRef(
|
|
|
23
24
|
startMonth: b,
|
|
24
25
|
endMonth: T,
|
|
25
26
|
showFooter: l = !0,
|
|
26
|
-
disabled:
|
|
27
|
+
disabled: o,
|
|
27
28
|
className: R,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
calendarKind: S,
|
|
30
|
+
fiscalMode: F,
|
|
31
|
+
granularity: I,
|
|
32
|
+
fiscalMonthPattern: L,
|
|
33
|
+
fiscalYearStartMonth: j,
|
|
34
|
+
fiscalConfig: O,
|
|
35
|
+
showPresets: w,
|
|
36
|
+
comparison: E,
|
|
37
|
+
onComparisonChange: v,
|
|
38
|
+
...z
|
|
39
|
+
}, K) => {
|
|
40
|
+
const { locale: h, t: s } = se(), q = a.useMemo(() => ie(h), [h]), B = M ?? s("datePicker.selectMultipleDates"), [i, n] = a.useState(!1), u = a.useRef(null), y = pe(), { footerFlashKey: H, footerFlashTarget: V, popoverHandlers: $ } = de(l, i, y, u), [p, d] = a.useState(t);
|
|
31
41
|
a.useEffect(() => {
|
|
32
42
|
d(t);
|
|
33
43
|
}, [i, t]);
|
|
34
|
-
const
|
|
35
|
-
const c =
|
|
44
|
+
const G = (e) => {
|
|
45
|
+
const c = le(e);
|
|
36
46
|
d(c), l || m?.(c);
|
|
37
|
-
},
|
|
38
|
-
const c =
|
|
39
|
-
m?.(c),
|
|
47
|
+
}, J = (e) => {
|
|
48
|
+
const c = ce(e, p);
|
|
49
|
+
m?.(c), n(!1);
|
|
40
50
|
}, g = () => {
|
|
41
|
-
d(t),
|
|
51
|
+
d(t), n(!1);
|
|
42
52
|
}, D = () => {
|
|
43
|
-
d(void 0), m?.(void 0), l ||
|
|
44
|
-
},
|
|
53
|
+
d(void 0), m?.(void 0), l || n(!1);
|
|
54
|
+
}, Q = t && t.length > 0 ? t.length === 1 ? _(t[0], x, { locale: q }) : `${t.length} dates selected` : "", U = a.useCallback(() => {
|
|
45
55
|
const e = p?.length ?? 0, c = t?.length ?? 0;
|
|
46
56
|
return e === c && (p ?? []).every(
|
|
47
|
-
(
|
|
57
|
+
(W, X) => W.getTime() === t?.[X]?.getTime()
|
|
48
58
|
) ? "dismiss" : e > 0 ? "apply" : "cancel";
|
|
49
59
|
}, [p, t]);
|
|
50
60
|
return a.useLayoutEffect(() => {
|
|
51
61
|
y.current = {
|
|
52
62
|
onDismiss: g,
|
|
53
|
-
resolveFlash:
|
|
63
|
+
resolveFlash: U
|
|
54
64
|
};
|
|
55
|
-
}), /* @__PURE__ */ f(
|
|
56
|
-
|
|
65
|
+
}), /* @__PURE__ */ f(re, { open: o ? !1 : i, onOpenChange: (e) => {
|
|
66
|
+
o || !e && l || n(e);
|
|
57
67
|
}, children: [
|
|
58
|
-
/* @__PURE__ */ r(
|
|
68
|
+
/* @__PURE__ */ r(oe, { asChild: !0, children: /* @__PURE__ */ r(
|
|
59
69
|
"div",
|
|
60
70
|
{
|
|
61
71
|
ref: u,
|
|
62
|
-
onPointerDown: (e) =>
|
|
63
|
-
disabled:
|
|
72
|
+
onPointerDown: (e) => fe({
|
|
73
|
+
disabled: o,
|
|
64
74
|
event: e,
|
|
65
|
-
onOpen: () =>
|
|
75
|
+
onOpen: () => n(!0),
|
|
66
76
|
focusField: () => u.current?.querySelector("input")?.focus()
|
|
67
77
|
}),
|
|
68
78
|
children: /* @__PURE__ */ r(
|
|
69
|
-
|
|
79
|
+
te,
|
|
70
80
|
{
|
|
71
|
-
ref:
|
|
72
|
-
value:
|
|
73
|
-
placeholder:
|
|
81
|
+
ref: K,
|
|
82
|
+
value: Q,
|
|
83
|
+
placeholder: B,
|
|
74
84
|
readOnly: !0,
|
|
75
|
-
disabled:
|
|
85
|
+
disabled: o,
|
|
76
86
|
onClick: () => {
|
|
77
|
-
!
|
|
87
|
+
!o && !i && n(!0);
|
|
78
88
|
},
|
|
79
|
-
className:
|
|
89
|
+
className: ee("cursor-pointer", R),
|
|
80
90
|
suffix: /* @__PURE__ */ f("div", { className: "flex items-center gap-1", children: [
|
|
81
|
-
t && t.length > 0 && !
|
|
91
|
+
t && t.length > 0 && !o && /* @__PURE__ */ f(P, { children: [
|
|
82
92
|
/* @__PURE__ */ r(C, { asChild: !0, children: /* @__PURE__ */ r(
|
|
83
93
|
"button",
|
|
84
94
|
{
|
|
@@ -89,7 +99,7 @@ const ae = a.forwardRef(
|
|
|
89
99
|
e.stopPropagation(), D();
|
|
90
100
|
},
|
|
91
101
|
className: "inline-flex size-4 items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
92
|
-
children: /* @__PURE__ */ r(
|
|
102
|
+
children: /* @__PURE__ */ r(Y, { className: "size-3 hover:text-content" })
|
|
93
103
|
}
|
|
94
104
|
) }),
|
|
95
105
|
/* @__PURE__ */ r(k, { variant: "tertiary", side: "top", children: s("calendar.clear") })
|
|
@@ -103,47 +113,58 @@ const ae = a.forwardRef(
|
|
|
103
113
|
"data-component": "calendar-trigger",
|
|
104
114
|
"aria-label": s("datePicker.selectMultipleDates"),
|
|
105
115
|
onPointerDown: (e) => {
|
|
106
|
-
e.preventDefault(), e.stopPropagation(),
|
|
116
|
+
e.preventDefault(), e.stopPropagation(), o || n(!i);
|
|
107
117
|
},
|
|
108
118
|
onKeyDown: (e) => {
|
|
109
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(),
|
|
119
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), o || n(!i));
|
|
110
120
|
},
|
|
111
121
|
className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
112
|
-
children: /* @__PURE__ */ r(
|
|
122
|
+
children: /* @__PURE__ */ r(Z, { className: "h-4 w-4 text-secondary-foreground" })
|
|
113
123
|
}
|
|
114
124
|
) }),
|
|
115
125
|
/* @__PURE__ */ r(k, { variant: "tertiary", side: "top", children: s("datePicker.selectMultipleDates") })
|
|
116
126
|
] })
|
|
117
127
|
] }),
|
|
118
|
-
...
|
|
128
|
+
...z
|
|
119
129
|
}
|
|
120
130
|
)
|
|
121
131
|
}
|
|
122
132
|
) }),
|
|
123
133
|
/* @__PURE__ */ r(
|
|
124
|
-
|
|
134
|
+
ne,
|
|
125
135
|
{
|
|
126
136
|
className: "w-auto p-0",
|
|
127
137
|
align: "start",
|
|
128
138
|
"aria-label": s("datePicker.selectMultipleDates"),
|
|
129
139
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
130
|
-
|
|
140
|
+
...$,
|
|
131
141
|
children: /* @__PURE__ */ r(
|
|
132
|
-
|
|
142
|
+
ae,
|
|
133
143
|
{
|
|
134
144
|
mode: "multiple",
|
|
135
145
|
selected: p,
|
|
136
|
-
footerFlashKey:
|
|
137
|
-
footerFlashTarget:
|
|
138
|
-
onSelect:
|
|
139
|
-
disabled:
|
|
146
|
+
footerFlashKey: H,
|
|
147
|
+
footerFlashTarget: V,
|
|
148
|
+
onSelect: G,
|
|
149
|
+
disabled: me(A, N),
|
|
140
150
|
startMonth: b,
|
|
141
151
|
endMonth: T,
|
|
142
152
|
showFooter: l,
|
|
143
|
-
onApply:
|
|
153
|
+
onApply: J,
|
|
144
154
|
onCancel: g,
|
|
145
155
|
onClear: D,
|
|
146
|
-
captionLayout: "dropdown"
|
|
156
|
+
captionLayout: "dropdown",
|
|
157
|
+
...ue({
|
|
158
|
+
calendarKind: S,
|
|
159
|
+
fiscalMode: F,
|
|
160
|
+
granularity: I,
|
|
161
|
+
fiscalMonthPattern: L,
|
|
162
|
+
fiscalYearStartMonth: j,
|
|
163
|
+
fiscalConfig: O,
|
|
164
|
+
showPresets: w,
|
|
165
|
+
comparison: E,
|
|
166
|
+
onComparisonChange: v
|
|
167
|
+
})
|
|
147
168
|
}
|
|
148
169
|
)
|
|
149
170
|
}
|
|
@@ -151,7 +172,7 @@ const ae = a.forwardRef(
|
|
|
151
172
|
] });
|
|
152
173
|
}
|
|
153
174
|
);
|
|
154
|
-
|
|
175
|
+
he.displayName = "MultiDatePicker";
|
|
155
176
|
export {
|
|
156
|
-
|
|
177
|
+
he as MultiDatePicker
|
|
157
178
|
};
|
|
@@ -1,46 +1,56 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as d, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import { Cross as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { Input as
|
|
6
|
-
import { Popover as
|
|
7
|
-
import { Calendar as
|
|
3
|
+
import { Cross as X, CalendarMonth as Y } from "impact-nova-icons";
|
|
4
|
+
import { cn as Z } from "../../../lib/utils.js";
|
|
5
|
+
import { Input as _ } from "../input/input.js";
|
|
6
|
+
import { Popover as ee, PopoverAnchor as te, PopoverContent as ne } from "../../feedback/popover/popover.js";
|
|
7
|
+
import { Calendar as re } from "../../data-display/calendar/calendar.js";
|
|
8
8
|
import { Tooltip as D, TooltipTrigger as b, TooltipContent as x } from "../../feedback/tooltip/tooltip.js";
|
|
9
|
-
import { useImpactNovaI18n as
|
|
10
|
-
import { coerceMonthArrayApply as
|
|
11
|
-
import { usePickerDismissActionsRef as
|
|
12
|
-
import { buildDateBoundsMatcher as
|
|
13
|
-
|
|
9
|
+
import { useImpactNovaI18n as oe } from "../../../i18n/use-impact-nova-i18n.js";
|
|
10
|
+
import { coerceMonthArrayApply as se, coerceMonthArray as ie } from "./calendar-selection-adapters.js";
|
|
11
|
+
import { usePickerDismissActionsRef as ce, usePickerFooterDismissNudge as ae, handlePickerSurfacePointerDown as le } from "./date-input-behavior.js";
|
|
12
|
+
import { buildDateBoundsMatcher as pe } from "../../../lib/date-bounds-matcher.js";
|
|
13
|
+
import { fiscalCalendarPassThrough as fe } from "./fiscal-pass-through.js";
|
|
14
|
+
const de = s.forwardRef(
|
|
14
15
|
({
|
|
15
16
|
value: t,
|
|
16
|
-
onChange:
|
|
17
|
+
onChange: h,
|
|
17
18
|
placeholder: A,
|
|
18
19
|
minDate: y,
|
|
19
20
|
maxDate: N,
|
|
20
21
|
startMonth: R,
|
|
21
|
-
endMonth:
|
|
22
|
+
endMonth: T,
|
|
22
23
|
showFooter: l = !0,
|
|
23
24
|
disabled: r,
|
|
24
|
-
className:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
className: S,
|
|
26
|
+
calendarKind: I,
|
|
27
|
+
fiscalMode: O,
|
|
28
|
+
granularity: j,
|
|
29
|
+
fiscalMonthPattern: v,
|
|
30
|
+
fiscalYearStartMonth: w,
|
|
31
|
+
fiscalConfig: E,
|
|
32
|
+
showPresets: F,
|
|
33
|
+
comparison: K,
|
|
34
|
+
onComparisonChange: z,
|
|
35
|
+
...L
|
|
36
|
+
}, V) => {
|
|
37
|
+
const { t: i } = oe(), $ = A ?? i("datePicker.selectMultipleMonths"), [c, o] = s.useState(!1), u = s.useRef(!1), m = s.useRef(null), g = ce(), { footerFlashKey: q, footerFlashTarget: B, popoverHandlers: H } = ae(l, c, g, m), [p, f] = s.useState(t);
|
|
28
38
|
s.useEffect(() => {
|
|
29
|
-
|
|
39
|
+
f(t);
|
|
30
40
|
}, [c, t]);
|
|
31
|
-
const
|
|
32
|
-
const a =
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
const a =
|
|
36
|
-
|
|
41
|
+
const G = (e) => {
|
|
42
|
+
const a = ie(e);
|
|
43
|
+
f(a), l || h?.(a);
|
|
44
|
+
}, J = (e) => {
|
|
45
|
+
const a = se(e, p);
|
|
46
|
+
h?.(a), o(!1);
|
|
37
47
|
}, M = () => {
|
|
38
|
-
|
|
48
|
+
f(t), o(!1);
|
|
39
49
|
}, P = () => {
|
|
40
|
-
|
|
41
|
-
},
|
|
50
|
+
f(void 0), h?.(void 0), l || o(!1);
|
|
51
|
+
}, Q = t && t.length > 0 ? t.length === 1 ? `${t[0].month + 1}/${t[0].year}` : i("datePicker.monthsSelected", { count: t.length }) : "", U = (e) => {
|
|
42
52
|
r || !e && l || o(e);
|
|
43
|
-
},
|
|
53
|
+
}, W = s.useCallback(() => {
|
|
44
54
|
const e = p?.length ?? 0, a = t?.length ?? 0;
|
|
45
55
|
return e === a && (p ?? []).every(
|
|
46
56
|
(C, k) => C.month === t?.[k]?.month && C.year === t?.[k]?.year
|
|
@@ -49,33 +59,33 @@ const ne = s.forwardRef(
|
|
|
49
59
|
return s.useLayoutEffect(() => {
|
|
50
60
|
g.current = {
|
|
51
61
|
onDismiss: M,
|
|
52
|
-
resolveFlash:
|
|
62
|
+
resolveFlash: W
|
|
53
63
|
};
|
|
54
|
-
}), /* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */ n(
|
|
64
|
+
}), /* @__PURE__ */ d(ee, { open: r ? !1 : c, onOpenChange: U, children: [
|
|
65
|
+
/* @__PURE__ */ n(te, { asChild: !0, children: /* @__PURE__ */ n(
|
|
56
66
|
"div",
|
|
57
67
|
{
|
|
58
68
|
ref: m,
|
|
59
|
-
onPointerDown: (e) =>
|
|
69
|
+
onPointerDown: (e) => le({
|
|
60
70
|
disabled: r,
|
|
61
71
|
event: e,
|
|
62
72
|
onOpen: () => o(!0),
|
|
63
73
|
focusField: () => m.current?.querySelector("input")?.focus()
|
|
64
74
|
}),
|
|
65
75
|
children: /* @__PURE__ */ n(
|
|
66
|
-
|
|
76
|
+
_,
|
|
67
77
|
{
|
|
68
|
-
ref:
|
|
69
|
-
value:
|
|
70
|
-
placeholder:
|
|
78
|
+
ref: V,
|
|
79
|
+
value: Q,
|
|
80
|
+
placeholder: $,
|
|
71
81
|
readOnly: !0,
|
|
72
82
|
disabled: r,
|
|
73
83
|
onClick: () => {
|
|
74
84
|
!r && !c && o(!0);
|
|
75
85
|
},
|
|
76
|
-
className:
|
|
77
|
-
suffix: /* @__PURE__ */
|
|
78
|
-
t && t.length > 0 && !r && /* @__PURE__ */
|
|
86
|
+
className: Z("cursor-pointer", S),
|
|
87
|
+
suffix: /* @__PURE__ */ d("div", { className: "flex items-center gap-1", children: [
|
|
88
|
+
t && t.length > 0 && !r && /* @__PURE__ */ d(D, { children: [
|
|
79
89
|
/* @__PURE__ */ n(b, { asChild: !0, children: /* @__PURE__ */ n(
|
|
80
90
|
"button",
|
|
81
91
|
{
|
|
@@ -86,12 +96,12 @@ const ne = s.forwardRef(
|
|
|
86
96
|
e.stopPropagation(), P();
|
|
87
97
|
},
|
|
88
98
|
className: "inline-flex size-4 items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
89
|
-
children: /* @__PURE__ */ n(
|
|
99
|
+
children: /* @__PURE__ */ n(X, { className: "size-3 hover:text-content" })
|
|
90
100
|
}
|
|
91
101
|
) }),
|
|
92
102
|
/* @__PURE__ */ n(x, { variant: "tertiary", side: "top", children: i("calendar.clear") })
|
|
93
103
|
] }),
|
|
94
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ d(D, { children: [
|
|
95
105
|
/* @__PURE__ */ n(b, { asChild: !0, children: /* @__PURE__ */ n(
|
|
96
106
|
"button",
|
|
97
107
|
{
|
|
@@ -103,48 +113,59 @@ const ne = s.forwardRef(
|
|
|
103
113
|
e.preventDefault(), e.stopPropagation(), r || o(!c);
|
|
104
114
|
},
|
|
105
115
|
onKeyDown: (e) => {
|
|
106
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), r || (
|
|
116
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), r || (u.current = !0, o(!c)));
|
|
107
117
|
},
|
|
108
118
|
className: "inline-flex items-center justify-center bg-transparent border-none p-0 cursor-pointer",
|
|
109
|
-
children: /* @__PURE__ */ n(
|
|
119
|
+
children: /* @__PURE__ */ n(Y, { className: "h-4 w-4 text-secondary-foreground" })
|
|
110
120
|
}
|
|
111
121
|
) }),
|
|
112
122
|
/* @__PURE__ */ n(x, { variant: "tertiary", side: "top", children: i("datePicker.selectMultipleMonths") })
|
|
113
123
|
] })
|
|
114
124
|
] }),
|
|
115
|
-
...
|
|
125
|
+
...L
|
|
116
126
|
}
|
|
117
127
|
)
|
|
118
128
|
}
|
|
119
129
|
) }),
|
|
120
130
|
/* @__PURE__ */ n(
|
|
121
|
-
|
|
131
|
+
ne,
|
|
122
132
|
{
|
|
123
133
|
className: "w-auto p-0",
|
|
124
134
|
align: "start",
|
|
125
135
|
"aria-label": i("datePicker.selectMultipleMonths"),
|
|
126
136
|
onOpenAutoFocus: (e) => {
|
|
127
|
-
|
|
137
|
+
u.current || e.preventDefault(), u.current = !1;
|
|
128
138
|
},
|
|
129
|
-
...
|
|
139
|
+
...H,
|
|
130
140
|
children: /* @__PURE__ */ n(
|
|
131
|
-
|
|
141
|
+
re,
|
|
132
142
|
{
|
|
133
143
|
pickerType: "month",
|
|
134
144
|
monthMode: "multiple",
|
|
135
145
|
selectedMonths: p,
|
|
136
|
-
footerFlashKey:
|
|
137
|
-
footerFlashTarget:
|
|
138
|
-
onMonthSelect:
|
|
139
|
-
disabled:
|
|
146
|
+
footerFlashKey: q,
|
|
147
|
+
footerFlashTarget: B,
|
|
148
|
+
onMonthSelect: G,
|
|
149
|
+
disabled: pe(y, N),
|
|
140
150
|
startMonth: R,
|
|
141
|
-
endMonth:
|
|
151
|
+
endMonth: T,
|
|
142
152
|
defaultMonth: y,
|
|
143
153
|
showFooter: l,
|
|
144
|
-
onApply:
|
|
154
|
+
onApply: J,
|
|
145
155
|
onCancel: M,
|
|
146
156
|
onClear: P,
|
|
147
|
-
captionLayout: "dropdown"
|
|
157
|
+
captionLayout: "dropdown",
|
|
158
|
+
...fe({
|
|
159
|
+
calendarKind: I,
|
|
160
|
+
fiscalMode: O,
|
|
161
|
+
granularity: j,
|
|
162
|
+
fiscalMonthPattern: v,
|
|
163
|
+
fiscalYearStartMonth: w,
|
|
164
|
+
fiscalConfig: E,
|
|
165
|
+
showPresets: F,
|
|
166
|
+
comparison: K,
|
|
167
|
+
onComparisonChange: z
|
|
168
|
+
})
|
|
148
169
|
}
|
|
149
170
|
)
|
|
150
171
|
}
|
|
@@ -152,7 +173,7 @@ const ne = s.forwardRef(
|
|
|
152
173
|
] });
|
|
153
174
|
}
|
|
154
175
|
);
|
|
155
|
-
|
|
176
|
+
de.displayName = "MultiMonthPicker";
|
|
156
177
|
export {
|
|
157
|
-
|
|
178
|
+
de as MultiMonthPicker
|
|
158
179
|
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { jsx as r, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { Cross as X, CalendarMonth as Y } from "impact-nova-icons";
|
|
4
|
+
import { cn as Z } from "../../../lib/utils.js";
|
|
5
|
+
import { Input as _ } from "../input/input.js";
|
|
6
|
+
import { Calendar as $ } from "../../data-display/calendar/calendar.js";
|
|
7
|
+
import { Tooltip as M, TooltipTrigger as x, TooltipContent as b } from "../../feedback/tooltip/tooltip.js";
|
|
8
|
+
import { useImpactNovaI18n as ee } from "../../../i18n/use-impact-nova-i18n.js";
|
|
9
|
+
import { buildDateBoundsMatcher as te } from "../../../lib/date-bounds-matcher.js";
|
|
10
|
+
import { fiscalCalendarPassThrough as re } from "./fiscal-pass-through.js";
|
|
11
|
+
import { DatePickerShell as ne } from "./date-picker-shell.js";
|
|
12
|
+
import { usePickerDismissActionsRef as oe, usePickerFooterDismissNudge as ae, handleReadonlyPickerKeyDown as ie, handlePickerSurfacePointerDown as ce } from "./date-input-behavior.js";
|
|
13
|
+
import { formatQuarterInput as se } from "../../data-display/calendar/calendar-fiscal-labels.js";
|
|
14
|
+
import { viewMonthFromQuarter as le } from "../../data-display/calendar/calendar-quarter-utils.js";
|
|
15
|
+
const pe = n.forwardRef(
|
|
16
|
+
({
|
|
17
|
+
value: t,
|
|
18
|
+
onChange: u,
|
|
19
|
+
placeholder: R,
|
|
20
|
+
minDate: D,
|
|
21
|
+
maxDate: Q,
|
|
22
|
+
startMonth: N,
|
|
23
|
+
endMonth: S,
|
|
24
|
+
showFooter: s = !0,
|
|
25
|
+
disabled: o,
|
|
26
|
+
className: A,
|
|
27
|
+
calendarKind: I,
|
|
28
|
+
fiscalMode: O,
|
|
29
|
+
granularity: T,
|
|
30
|
+
fiscalMonthPattern: w,
|
|
31
|
+
fiscalYearStartMonth: v,
|
|
32
|
+
fiscalConfig: K,
|
|
33
|
+
showPresets: j,
|
|
34
|
+
...F
|
|
35
|
+
}, z) => {
|
|
36
|
+
const { t: a } = ee(), E = R ?? a("datePicker.selectMultipleQuarters"), f = n.useRef(null), y = n.useRef(null);
|
|
37
|
+
n.useImperativeHandle(z, () => f.current);
|
|
38
|
+
const [i, c] = n.useState(!1), d = n.useRef(!1), k = oe(), { footerFlashKey: H, footerFlashTarget: L, popoverHandlers: V } = ae(s, i, k, y), [P, l] = n.useState(t), [q, B] = n.useState(le(t?.[0]));
|
|
39
|
+
n.useEffect(() => {
|
|
40
|
+
i || l(t);
|
|
41
|
+
}, [i, t]);
|
|
42
|
+
const m = n.useCallback(() => c(!1), []), G = re({
|
|
43
|
+
calendarKind: I,
|
|
44
|
+
fiscalMode: O,
|
|
45
|
+
granularity: T,
|
|
46
|
+
fiscalMonthPattern: w,
|
|
47
|
+
fiscalYearStartMonth: v,
|
|
48
|
+
fiscalConfig: K,
|
|
49
|
+
showPresets: j
|
|
50
|
+
}), J = (e) => {
|
|
51
|
+
const p = Array.isArray(e) && e.length > 0 ? e : void 0;
|
|
52
|
+
l(p), s || u?.(p);
|
|
53
|
+
}, U = () => {
|
|
54
|
+
u?.(P), m();
|
|
55
|
+
}, h = () => {
|
|
56
|
+
l(t), m();
|
|
57
|
+
}, C = () => {
|
|
58
|
+
l(void 0), u?.(void 0), s || m();
|
|
59
|
+
};
|
|
60
|
+
n.useLayoutEffect(() => {
|
|
61
|
+
k.current = { onDismiss: h, resolveFlash: () => "cancel" };
|
|
62
|
+
});
|
|
63
|
+
const W = t && t.length > 0 ? t.length === 1 ? se(t[0]) : a("datePicker.quartersSelected", { count: t.length }) : "";
|
|
64
|
+
return /* @__PURE__ */ r(
|
|
65
|
+
ne,
|
|
66
|
+
{
|
|
67
|
+
open: i,
|
|
68
|
+
disabled: o,
|
|
69
|
+
ariaLabel: a("datePicker.selectMultipleQuarters"),
|
|
70
|
+
onOpenChange: (e) => {
|
|
71
|
+
o || c(e);
|
|
72
|
+
},
|
|
73
|
+
onOpenAutoFocus: (e) => {
|
|
74
|
+
d.current || e.preventDefault(), d.current = !1;
|
|
75
|
+
},
|
|
76
|
+
popoverHandlers: V,
|
|
77
|
+
trigger: /* @__PURE__ */ r(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
ref: y,
|
|
81
|
+
"data-component": "multi-quarter-picker",
|
|
82
|
+
"data-state": i ? "open" : "closed",
|
|
83
|
+
onPointerDown: (e) => ce({
|
|
84
|
+
disabled: o,
|
|
85
|
+
event: e,
|
|
86
|
+
onOpen: () => c(!0),
|
|
87
|
+
focusField: () => f.current?.focus()
|
|
88
|
+
}),
|
|
89
|
+
children: /* @__PURE__ */ r(
|
|
90
|
+
_,
|
|
91
|
+
{
|
|
92
|
+
ref: f,
|
|
93
|
+
value: W,
|
|
94
|
+
readOnly: !0,
|
|
95
|
+
onKeyDown: (e) => ie(e, {
|
|
96
|
+
disabled: o,
|
|
97
|
+
open: i,
|
|
98
|
+
onOpen: () => c(!0),
|
|
99
|
+
onCancel: h,
|
|
100
|
+
onKeyboardOpen: () => {
|
|
101
|
+
d.current = !0;
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
onClick: () => !o && c(!0),
|
|
105
|
+
placeholder: E,
|
|
106
|
+
disabled: o,
|
|
107
|
+
"data-form-control": "input",
|
|
108
|
+
className: Z("cursor-pointer", A),
|
|
109
|
+
suffix: /* @__PURE__ */ g("div", { className: "flex items-center gap-1", children: [
|
|
110
|
+
t && t.length > 0 && !o ? /* @__PURE__ */ g(M, { children: [
|
|
111
|
+
/* @__PURE__ */ r(x, { asChild: !0, children: /* @__PURE__ */ r(
|
|
112
|
+
"button",
|
|
113
|
+
{
|
|
114
|
+
type: "button",
|
|
115
|
+
tabIndex: 0,
|
|
116
|
+
"aria-label": a("calendar.clear"),
|
|
117
|
+
onClick: (e) => {
|
|
118
|
+
e.stopPropagation(), C();
|
|
119
|
+
},
|
|
120
|
+
className: "inline-flex size-4 items-center justify-center border-none bg-transparent p-0",
|
|
121
|
+
children: /* @__PURE__ */ r(X, { className: "size-3 hover:text-content" })
|
|
122
|
+
}
|
|
123
|
+
) }),
|
|
124
|
+
/* @__PURE__ */ r(b, { variant: "tertiary", side: "top", children: a("calendar.clear") })
|
|
125
|
+
] }) : null,
|
|
126
|
+
/* @__PURE__ */ g(M, { children: [
|
|
127
|
+
/* @__PURE__ */ r(x, { asChild: !0, children: /* @__PURE__ */ r(
|
|
128
|
+
"button",
|
|
129
|
+
{
|
|
130
|
+
type: "button",
|
|
131
|
+
tabIndex: 0,
|
|
132
|
+
"data-component": "calendar-trigger",
|
|
133
|
+
"aria-label": a("datePicker.selectMultipleQuarters"),
|
|
134
|
+
onClick: (e) => {
|
|
135
|
+
e.stopPropagation(), o || c((p) => !p);
|
|
136
|
+
},
|
|
137
|
+
className: "inline-flex items-center justify-center border-none bg-transparent p-0",
|
|
138
|
+
children: /* @__PURE__ */ r(Y, { className: "h-4 w-4 text-secondary-foreground" })
|
|
139
|
+
}
|
|
140
|
+
) }),
|
|
141
|
+
/* @__PURE__ */ r(b, { variant: "tertiary", side: "top", children: a("datePicker.selectMultipleQuarters") })
|
|
142
|
+
] })
|
|
143
|
+
] }),
|
|
144
|
+
...F
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
children: /* @__PURE__ */ r(
|
|
150
|
+
$,
|
|
151
|
+
{
|
|
152
|
+
pickerType: "quarter",
|
|
153
|
+
monthMode: "multiple",
|
|
154
|
+
selectedQuarters: P,
|
|
155
|
+
footerFlashKey: H,
|
|
156
|
+
footerFlashTarget: L,
|
|
157
|
+
onQuarterSelect: J,
|
|
158
|
+
month: q,
|
|
159
|
+
onMonthChange: B,
|
|
160
|
+
disabled: te(D, Q),
|
|
161
|
+
startMonth: N,
|
|
162
|
+
endMonth: S,
|
|
163
|
+
showFooter: s,
|
|
164
|
+
onApply: U,
|
|
165
|
+
onCancel: h,
|
|
166
|
+
onClear: C,
|
|
167
|
+
...G
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
pe.displayName = "MultiQuarterPicker";
|
|
175
|
+
export {
|
|
176
|
+
pe as MultiQuarterPicker
|
|
177
|
+
};
|