@tedi-design-system/react 19.0.0-rc.9 → 19.0.0
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/bundle-stats.html +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +4 -3
- package/src/community/components/card/card.cjs.js +1 -1
- package/src/community/components/card/card.es.js +20 -19
- package/src/community/components/color-tokens.cjs.js +1 -0
- package/src/community/components/color-tokens.d.ts +14 -0
- package/src/community/components/color-tokens.es.js +35 -0
- package/src/community/components/layout/header/components/header-role/header-role.cjs.js +1 -1
- package/src/community/components/layout/header/components/header-role/header-role.es.js +19 -19
- package/src/community/components/layout/header/components/header-role/header-role.module.scss.cjs.js +1 -1
- package/src/community/components/layout/header/components/header-role/header-role.module.scss.es.js +2 -1
- package/src/community/components/map-components/button-group/button-group.cjs.js +1 -1
- package/src/community/components/map-components/button-group/button-group.es.js +18 -14
- package/src/community/components/map-components/map-button/map-button.cjs.js +1 -1
- package/src/community/components/map-components/map-button/map-button.es.js +34 -33
- package/src/community/components/tooltip/tooltip.cjs.js +1 -1
- package/src/community/components/tooltip/tooltip.es.js +31 -30
- package/src/tedi/components/content/list/list-item.cjs.js +1 -1
- package/src/tedi/components/content/list/list-item.d.ts +1 -1
- package/src/tedi/components/content/list/list-item.es.js +8 -8
- package/src/tedi/components/content/list/list.cjs.js +1 -1
- package/src/tedi/components/content/list/list.d.ts +1 -1
- package/src/tedi/components/content/list/list.es.js +29 -23
- package/src/tedi/components/content/list/list.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/list/list.module.scss.es.js +3 -2
- package/src/tedi/components/content/text-group/text-group-list/text-group-list.d.ts +6 -5
- package/src/tedi/components/content/text-group/text-group.d.ts +7 -5
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +6 -0
- package/src/tedi/components/form/date-field/date-field.es.js +163 -162
- package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -1
- package/src/tedi/components/form/date-time-field/date-time-field.d.ts +6 -0
- package/src/tedi/components/form/date-time-field/date-time-field.es.js +101 -100
- package/src/tedi/components/form/select/components/select-multi-option.cjs.js +1 -1
- package/src/tedi/components/form/select/components/select-multi-option.es.js +24 -23
- package/src/tedi/components/form/select/components/select-single-option.cjs.js +1 -1
- package/src/tedi/components/form/select/components/select-single-option.es.js +11 -10
- package/src/tedi/components/form/select/select.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/select/select.module.scss.es.js +2 -1
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.d.ts +6 -0
- package/src/tedi/components/form/time-field/time-field.es.js +37 -36
- package/src/tedi/components/form/time-picker/time-picker.cjs.js +1 -1
- package/src/tedi/components/form/time-picker/time-picker.es.js +1 -1
- package/src/tedi/components/layout/vertical-spacing/vertical-spacing-item.cjs.js +1 -1
- package/src/tedi/components/layout/vertical-spacing/vertical-spacing-item.d.ts +5 -0
- package/src/tedi/components/layout/vertical-spacing/vertical-spacing-item.es.js +14 -13
- package/src/tedi/components/layout/vertical-spacing/vertical-spacing.cjs.js +1 -1
- package/src/tedi/components/layout/vertical-spacing/vertical-spacing.d.ts +5 -0
- package/src/tedi/components/layout/vertical-spacing/vertical-spacing.es.js +18 -17
- package/src/tedi/components/misc/ellipsis/ellipsis.cjs.js +1 -1
- package/src/tedi/components/misc/ellipsis/ellipsis.es.js +20 -19
- package/src/tedi/components/misc/timeline/timeline.cjs.js +1 -1
- package/src/tedi/components/misc/timeline/timeline.es.js +24 -27
- package/src/tedi/components/overlays/overlay/overlay-content.cjs.js +1 -1
- package/src/tedi/components/overlays/overlay/overlay-content.d.ts +6 -1
- package/src/tedi/components/overlays/overlay/overlay-content.es.js +28 -27
- package/src/tedi/components/overlays/overlay/overlay.cjs.js +1 -1
- package/src/tedi/components/overlays/overlay/overlay.es.js +29 -28
- package/src/tedi/components/overlays/popover/popover-content.cjs.js +1 -1
- package/src/tedi/components/overlays/popover/popover-content.d.ts +7 -0
- package/src/tedi/components/overlays/popover/popover-content.es.js +47 -36
- package/src/tedi/helpers/index.d.ts +1 -0
|
@@ -1,93 +1,94 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useFloating as
|
|
1
|
+
import { jsxs as vt, Fragment as Ft, jsx as D } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as wt, useClick as Nt, useInteractions as kt, useDismiss as Pt, useRole as Et, FloatingPortal as Ot, FloatingFocusManager as Rt } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
3
|
import B from "../../../../../external/classnames/index.es.js";
|
|
4
4
|
import F, { useState as _, useCallback as ue, useEffect as T, useMemo as me } from "react";
|
|
5
|
-
import { Calendar as
|
|
6
|
-
import { MultiValueField as
|
|
7
|
-
import { TextField as
|
|
5
|
+
import { Calendar as It } from "../../content/calendar/calendar.es.js";
|
|
6
|
+
import { MultiValueField as Vt } from "../multi-value-field/multi-value-field.es.js";
|
|
7
|
+
import { TextField as Bt } from "../textfield/textfield.es.js";
|
|
8
8
|
import y from "./date-field.module.scss.es.js";
|
|
9
|
-
import { getLocaleDateParts as
|
|
10
|
-
import { DatePickerModal as
|
|
11
|
-
import { useBreakpointProps as
|
|
12
|
-
import { useLabels as
|
|
13
|
-
import { et as
|
|
14
|
-
import
|
|
15
|
-
import { autoUpdate as
|
|
16
|
-
import { offset as
|
|
17
|
-
import { dateMatchModifiers as
|
|
18
|
-
const
|
|
19
|
-
const { getCurrentBreakpointProps:
|
|
20
|
-
useNativePicker:
|
|
9
|
+
import { getLocaleDateParts as Tt, buildDateRegexSource as $t, resolveRangeSelection as Lt, CALENDAR_POPOVER_OFFSET as Yt, CALENDAR_POPOVER_PADDING as He } from "./date-field-helpers.es.js";
|
|
10
|
+
import { DatePickerModal as jt } from "./date-picker-modal/date-picker-modal.es.js";
|
|
11
|
+
import { useBreakpointProps as Ht } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
12
|
+
import { useLabels as Wt } from "../../../providers/label-provider/use-labels.es.js";
|
|
13
|
+
import { et as St } from "../../../../../external/react-day-picker/dist/esm/locale/et.es.js";
|
|
14
|
+
import Ut, { isBreakpointBelow as We } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
15
|
+
import { autoUpdate as qt } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
|
|
16
|
+
import { offset as zt, flip as Gt, shift as Xt, size as Jt } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
|
|
17
|
+
import { dateMatchModifiers as Kt } from "../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.es.js";
|
|
18
|
+
const Qt = F.forwardRef((w, N) => {
|
|
19
|
+
const { getCurrentBreakpointProps: Se } = Ht(w.defaultServerBreakpoint), { getLabel: z } = Wt(), {
|
|
20
|
+
useNativePicker: Ue = !1,
|
|
21
21
|
enableCalendar: m = !0,
|
|
22
22
|
calendarTrigger: $ = "button",
|
|
23
|
-
numberOfMonths: G
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
numberOfMonths: G,
|
|
24
|
+
clearable: pe = !0
|
|
25
|
+
} = Se(w), {
|
|
26
|
+
id: he,
|
|
26
27
|
mode: s = "single",
|
|
27
|
-
label:
|
|
28
|
+
label: ge,
|
|
28
29
|
selected: L,
|
|
29
30
|
onSelect: a,
|
|
30
31
|
disabled: k,
|
|
31
32
|
disabledMatchers: P,
|
|
32
|
-
placeholder:
|
|
33
|
-
className:
|
|
33
|
+
placeholder: qe,
|
|
34
|
+
className: ze,
|
|
34
35
|
formatDate: d,
|
|
35
36
|
required: Y,
|
|
36
|
-
showOutsideDays:
|
|
37
|
-
parseDate:
|
|
38
|
-
monthYearSelectType:
|
|
39
|
-
minYear:
|
|
40
|
-
maxYear:
|
|
41
|
-
dayStatus:
|
|
42
|
-
tagsDirection:
|
|
43
|
-
showNavigation:
|
|
37
|
+
showOutsideDays: ye = !0,
|
|
38
|
+
parseDate: Ge,
|
|
39
|
+
monthYearSelectType: be,
|
|
40
|
+
minYear: De,
|
|
41
|
+
maxYear: _e,
|
|
42
|
+
dayStatus: Ce,
|
|
43
|
+
tagsDirection: Xe,
|
|
44
|
+
showNavigation: Me = !0,
|
|
44
45
|
selectionLevel: E = "days",
|
|
45
46
|
initialView: j,
|
|
46
|
-
locale:
|
|
47
|
+
locale: xe = St,
|
|
47
48
|
localeCode: H = "et-EE",
|
|
48
49
|
initialMonth: W,
|
|
49
|
-
closeOnSelect:
|
|
50
|
-
footer:
|
|
50
|
+
closeOnSelect: Je,
|
|
51
|
+
footer: Ae,
|
|
51
52
|
defaultValue: S,
|
|
52
53
|
minDate: X,
|
|
53
54
|
maxDate: J,
|
|
54
|
-
disablePast:
|
|
55
|
-
disableFuture:
|
|
55
|
+
disablePast: ve,
|
|
56
|
+
disableFuture: Fe,
|
|
56
57
|
shouldDisableMonth: K,
|
|
57
58
|
shouldDisableYear: Q,
|
|
58
59
|
readOnly: O,
|
|
59
|
-
availableDays:
|
|
60
|
+
availableDays: we,
|
|
60
61
|
inputProps: i,
|
|
61
62
|
modal: Z = !1,
|
|
62
|
-
modalProps:
|
|
63
|
-
modalTitle:
|
|
64
|
-
disabledDateErrorMessage:
|
|
65
|
-
invalidDateErrorMessage:
|
|
66
|
-
useNativePicker:
|
|
67
|
-
enableCalendar:
|
|
68
|
-
calendarTrigger:
|
|
69
|
-
numberOfMonths:
|
|
70
|
-
defaultServerBreakpoint:
|
|
71
|
-
sm:
|
|
72
|
-
md:
|
|
73
|
-
lg:
|
|
74
|
-
xl:
|
|
75
|
-
xxl:
|
|
76
|
-
...
|
|
77
|
-
} = w, c =
|
|
63
|
+
modalProps: Ke,
|
|
64
|
+
modalTitle: Qe,
|
|
65
|
+
disabledDateErrorMessage: Ze = z("dateField.disabledDateError"),
|
|
66
|
+
invalidDateErrorMessage: et = z("dateField.invalidDateError"),
|
|
67
|
+
useNativePicker: Zt,
|
|
68
|
+
enableCalendar: er,
|
|
69
|
+
calendarTrigger: tr,
|
|
70
|
+
numberOfMonths: rr,
|
|
71
|
+
defaultServerBreakpoint: ar,
|
|
72
|
+
sm: ir,
|
|
73
|
+
md: or,
|
|
74
|
+
lg: nr,
|
|
75
|
+
xl: sr,
|
|
76
|
+
xxl: lr,
|
|
77
|
+
...Ne
|
|
78
|
+
} = w, c = Ue && s === "single", ke = Ut(w.defaultServerBreakpoint), A = We(ke, "md"), [tt, p] = _(L ?? S), [h, R] = _(!1), [ee, Pe] = _(!1), [rt, Ee] = _(j ?? E), [te, b] = _(""), [Oe, u] = _(!1), [Re, re] = _(!1), g = m && !c && !O && (Z === !0 || typeof Z == "string" && We(ke, Z)), Ie = A && !g && typeof G == "number" && G > 1 ? 1 : G, { current: f } = F.useRef("selected" in w), o = f ? L : tt, ae = F.useRef(null), Ve = F.useRef(null), at = F.useCallback(
|
|
78
79
|
(e) => {
|
|
79
80
|
ae.current = e, typeof N == "function" ? N(e) : N && (N.current = e);
|
|
80
81
|
},
|
|
81
82
|
[N]
|
|
82
|
-
),
|
|
83
|
+
), it = (e) => {
|
|
83
84
|
if (!e) return "";
|
|
84
85
|
const t = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
|
|
85
86
|
return `${t}-${r}-${n}`;
|
|
86
|
-
},
|
|
87
|
+
}, ot = c && o instanceof Date ? it(o) : "", ie = ue((e, t) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [...e].sort((r, n) => r.getTime() - n.getTime())[0] : e && typeof e == "object" && "from" in e && e.from instanceof Date ? e.from : e && typeof e == "object" && "to" in e && e.to instanceof Date ? e.to : t ?? /* @__PURE__ */ new Date(), []), [nt, oe] = _(() => ie(o, W));
|
|
87
88
|
T(() => {
|
|
88
89
|
h || oe(ie(o, W));
|
|
89
90
|
}, [o, W, h, ie]), T(() => {
|
|
90
|
-
h &&
|
|
91
|
+
h && Ee(j ?? E);
|
|
91
92
|
}, [h, E, j]), T(() => {
|
|
92
93
|
f && p(L);
|
|
93
94
|
}, [L, f]);
|
|
@@ -110,47 +111,47 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
110
111
|
return "";
|
|
111
112
|
},
|
|
112
113
|
[C]
|
|
113
|
-
), ne =
|
|
114
|
+
), ne = Je ?? s === "single", Be = s === "multiple" && Array.isArray(o) ? o.map((e, t) => ({
|
|
114
115
|
id: t,
|
|
115
116
|
label: d ? d(e) : M(e),
|
|
116
117
|
date: e
|
|
117
118
|
})) : [], U = me(() => {
|
|
118
119
|
const e = [];
|
|
119
|
-
return k && (Array.isArray(k) ? e.push(...k) : e.push(k)), P && (Array.isArray(P) ? e.push(...P) : e.push(P)), X && e.push({ before: X }), J && e.push({ after: J }),
|
|
120
|
+
return k && (Array.isArray(k) ? e.push(...k) : e.push(k)), P && (Array.isArray(P) ? e.push(...P) : e.push(P)), X && e.push({ before: X }), J && e.push({ after: J }), ve && e.push({ before: /* @__PURE__ */ new Date() }), Fe && e.push({ after: /* @__PURE__ */ new Date() }), K && e.push((t) => K(t)), Q && e.push((t) => Q(t)), e;
|
|
120
121
|
}, [
|
|
121
122
|
k,
|
|
122
123
|
P,
|
|
123
124
|
X,
|
|
124
125
|
J,
|
|
125
|
-
Ae,
|
|
126
126
|
ve,
|
|
127
|
+
Fe,
|
|
127
128
|
K,
|
|
128
129
|
Q
|
|
129
130
|
]), v = ue(
|
|
130
|
-
(e) =>
|
|
131
|
+
(e) => Kt(e, U),
|
|
131
132
|
[U]
|
|
132
|
-
),
|
|
133
|
-
const l = s === "range" ?
|
|
133
|
+
), st = (e, t, r, n) => {
|
|
134
|
+
const l = s === "range" ? Lt(e, o, t) : e;
|
|
134
135
|
if (u(!1), f || p(l), a == null || a(l, t, r, n), l) {
|
|
135
136
|
const x = d ? d(l) : M(l);
|
|
136
137
|
b(x);
|
|
137
138
|
} else
|
|
138
139
|
b("");
|
|
139
140
|
ne && R(!1);
|
|
140
|
-
},
|
|
141
|
+
}, lt = (e) => {
|
|
141
142
|
if (v(e)) return;
|
|
142
143
|
const t = s === "range" ? { from: e, to: void 0 } : s === "multiple" ? [...Array.isArray(o) ? o : [], e] : e;
|
|
143
144
|
u(!1), f || p(t), a == null || a(t, e, {}, {});
|
|
144
145
|
const r = d ? d(t) : M(t);
|
|
145
146
|
b(r), ne && R(!1);
|
|
146
|
-
},
|
|
147
|
-
const e =
|
|
147
|
+
}, ft = me(() => {
|
|
148
|
+
const e = Tt(C), t = new RegExp(`^${$t(e)}$`), { fieldOrder: r } = e;
|
|
148
149
|
return (n) => {
|
|
149
150
|
const l = n.match(t);
|
|
150
151
|
if (!l) return;
|
|
151
152
|
const x = {};
|
|
152
|
-
r.forEach((
|
|
153
|
-
x[
|
|
153
|
+
r.forEach((xt, At) => {
|
|
154
|
+
x[xt] = Number(l[At + 1]);
|
|
154
155
|
});
|
|
155
156
|
const { day: fe, month: de, year: ce } = x;
|
|
156
157
|
if (fe === void 0 || de === void 0 || ce === void 0) return;
|
|
@@ -158,14 +159,14 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
158
159
|
if (!(isNaN(V.getTime()) || V.getFullYear() !== ce || V.getMonth() !== de - 1 || V.getDate() !== fe))
|
|
159
160
|
return V;
|
|
160
161
|
};
|
|
161
|
-
}, [C]),
|
|
162
|
-
}))(e),
|
|
162
|
+
}, [C]), Te = (e) => (Ge ?? (s === "single" ? ft : () => {
|
|
163
|
+
}))(e), $e = (e) => s === "single" && e instanceof Date || s === "multiple" && Array.isArray(e) || s === "range" && !!e && !Array.isArray(e) && "from" in e, dt = (e) => {
|
|
163
164
|
if (b(e), re(!1), e.trim() === "") {
|
|
164
165
|
u(!1), o !== void 0 && (f || p(void 0), a == null || a(void 0, void 0, {}, {}));
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
|
-
const t =
|
|
168
|
-
if (
|
|
168
|
+
const t = Te(e);
|
|
169
|
+
if (!$e(t)) {
|
|
169
170
|
u(!1);
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
@@ -175,12 +176,12 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
178
|
u(!1), f || p(t), a == null || a(t, t, {}, {}), t instanceof Date && oe(t), ne && R(!1);
|
|
178
|
-
},
|
|
179
|
+
}, ct = () => {
|
|
179
180
|
if (te.trim() === "") {
|
|
180
181
|
re(!1);
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
|
-
re(
|
|
184
|
+
re(!$e(Te(te)));
|
|
184
185
|
};
|
|
185
186
|
T(() => {
|
|
186
187
|
if (f) {
|
|
@@ -193,16 +194,16 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
193
194
|
b(e);
|
|
194
195
|
}
|
|
195
196
|
}, []);
|
|
196
|
-
const
|
|
197
|
+
const ut = wt({
|
|
197
198
|
open: h,
|
|
198
199
|
onOpenChange: R,
|
|
199
200
|
placement: $ === "input" ? "bottom-start" : "bottom-end",
|
|
200
201
|
middleware: [
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
padding:
|
|
202
|
+
zt(Yt),
|
|
203
|
+
Gt(),
|
|
204
|
+
Xt({ padding: He }),
|
|
205
|
+
Jt({
|
|
206
|
+
padding: He,
|
|
206
207
|
apply({ availableWidth: e, elements: t }) {
|
|
207
208
|
const r = t.floating;
|
|
208
209
|
if (r.style.width = "", r.style.maxWidth = "", r.style.overflowX = "", A) return;
|
|
@@ -210,23 +211,23 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
210
211
|
}
|
|
211
212
|
})
|
|
212
213
|
],
|
|
213
|
-
whileElementsMounted:
|
|
214
|
-
}), { refs: I, context: q, x:
|
|
215
|
-
...m && !c && $ === "input" && !g ? [
|
|
216
|
-
|
|
214
|
+
whileElementsMounted: qt
|
|
215
|
+
}), { refs: I, context: q, x: mt, y: pt, strategy: ht } = ut, gt = Nt(q), Le = kt([
|
|
216
|
+
...m && !c && $ === "input" && !g ? [gt] : [],
|
|
217
|
+
Pt(q, {
|
|
217
218
|
outsidePress: (e) => {
|
|
218
219
|
const t = e.target;
|
|
219
220
|
return !(t != null && t.closest('[role="menu"], [role="listbox"]'));
|
|
220
221
|
}
|
|
221
222
|
}),
|
|
222
|
-
|
|
223
|
+
Et(q, { role: "dialog" })
|
|
223
224
|
]);
|
|
224
225
|
F.useEffect(() => {
|
|
225
226
|
var t, r;
|
|
226
|
-
const e = s === "multiple" ? ((t =
|
|
227
|
+
const e = s === "multiple" ? ((t = Ve.current) == null ? void 0 : t.wrapper) ?? null : ((r = ae.current) == null ? void 0 : r.input) ?? null;
|
|
227
228
|
I.setPositionReference(e ?? I.reference.current);
|
|
228
229
|
}, [s, h, I]);
|
|
229
|
-
const
|
|
230
|
+
const yt = () => {
|
|
230
231
|
var t;
|
|
231
232
|
const e = (t = ae.current) == null ? void 0 : t.input;
|
|
232
233
|
if (e) {
|
|
@@ -239,14 +240,14 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
239
240
|
e.focus();
|
|
240
241
|
}
|
|
241
242
|
}, se = () => {
|
|
242
|
-
!m || O || (c ?
|
|
243
|
-
},
|
|
243
|
+
!m || O || (c ? yt() : g ? Pe(!0) : R((e) => !e));
|
|
244
|
+
}, bt = (e) => {
|
|
244
245
|
if (u(!1), f || p(e), a == null || a(e, e, {}, {}), e) {
|
|
245
246
|
const t = d ? d(e) : M(e);
|
|
246
247
|
b(t);
|
|
247
248
|
} else
|
|
248
249
|
b("");
|
|
249
|
-
},
|
|
250
|
+
}, Dt = (e) => {
|
|
250
251
|
if (!e) {
|
|
251
252
|
u(!1), f || p(void 0), a == null || a(void 0, void 0, {}, {});
|
|
252
253
|
return;
|
|
@@ -261,44 +262,44 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
261
262
|
}
|
|
262
263
|
u(!1), f || p(l), a == null || a(l, l, {}, {});
|
|
263
264
|
}
|
|
264
|
-
},
|
|
265
|
+
}, _t = Le.getReferenceProps(
|
|
265
266
|
g && $ === "input" ? { onClick: () => se() } : void 0
|
|
266
267
|
), {
|
|
267
|
-
role:
|
|
268
|
-
"aria-expanded":
|
|
269
|
-
"aria-haspopup":
|
|
270
|
-
"aria-controls":
|
|
271
|
-
...
|
|
272
|
-
} =
|
|
268
|
+
role: fr,
|
|
269
|
+
"aria-expanded": dr,
|
|
270
|
+
"aria-haspopup": cr,
|
|
271
|
+
"aria-controls": Ct,
|
|
272
|
+
...Mt
|
|
273
|
+
} = _t, Ye = g ? void 0 : Ct, le = z("dateField.openCalendar"), je = {
|
|
273
274
|
"aria-label": le,
|
|
274
275
|
"aria-expanded": g ? ee : h,
|
|
275
276
|
"aria-haspopup": "dialog",
|
|
276
|
-
"aria-controls":
|
|
277
|
+
"aria-controls": Ye
|
|
277
278
|
};
|
|
278
|
-
return /* @__PURE__ */
|
|
279
|
+
return /* @__PURE__ */ vt(Ft, { children: [
|
|
279
280
|
/* @__PURE__ */ D(
|
|
280
281
|
"div",
|
|
281
282
|
{
|
|
282
|
-
className: B(y["tedi-date-field__container"],
|
|
283
|
-
...
|
|
283
|
+
className: B(y["tedi-date-field__container"], ze),
|
|
284
|
+
...Mt,
|
|
284
285
|
ref: I.setReference,
|
|
285
286
|
children: s === "multiple" ? /* @__PURE__ */ D(
|
|
286
|
-
|
|
287
|
+
Vt,
|
|
287
288
|
{
|
|
288
289
|
...i,
|
|
289
|
-
ref:
|
|
290
|
-
id:
|
|
291
|
-
label:
|
|
292
|
-
tagsDirection:
|
|
293
|
-
values:
|
|
290
|
+
ref: Ve,
|
|
291
|
+
id: he,
|
|
292
|
+
label: ge,
|
|
293
|
+
tagsDirection: Xe,
|
|
294
|
+
values: Be.map((e) => e.label),
|
|
294
295
|
icon: "calendar_today",
|
|
295
296
|
onIconClick: se,
|
|
296
|
-
iconButtonProps: m ?
|
|
297
|
-
isClearable:
|
|
297
|
+
iconButtonProps: m ? je : { "aria-label": le },
|
|
298
|
+
isClearable: pe,
|
|
298
299
|
required: Y,
|
|
299
300
|
onChange: (e) => {
|
|
300
301
|
if (!Array.isArray(o)) return;
|
|
301
|
-
const t =
|
|
302
|
+
const t = Be.filter((r) => e.includes(r.label)).map((r) => r.date);
|
|
302
303
|
f || p(t), a == null || a(t, {}, {}, {});
|
|
303
304
|
},
|
|
304
305
|
className: B(y["tedi-date-field__textfield"], {
|
|
@@ -306,28 +307,28 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
306
307
|
})
|
|
307
308
|
}
|
|
308
309
|
) : /* @__PURE__ */ D(
|
|
309
|
-
|
|
310
|
+
Bt,
|
|
310
311
|
{
|
|
311
312
|
...i,
|
|
312
|
-
ref:
|
|
313
|
-
id:
|
|
314
|
-
label:
|
|
313
|
+
ref: at,
|
|
314
|
+
id: he,
|
|
315
|
+
label: ge,
|
|
315
316
|
readOnly: O,
|
|
316
|
-
value: c ?
|
|
317
|
-
placeholder:
|
|
317
|
+
value: c ? ot : te,
|
|
318
|
+
placeholder: qe,
|
|
318
319
|
icon: "calendar_today",
|
|
319
|
-
isClearable:
|
|
320
|
+
isClearable: pe,
|
|
320
321
|
onIconClick: se,
|
|
321
|
-
iconButtonProps: m && !c ?
|
|
322
|
-
onChange: (e) => c ?
|
|
322
|
+
iconButtonProps: m && !c ? je : { "aria-label": le },
|
|
323
|
+
onChange: (e) => c ? Dt(e) : dt(e),
|
|
323
324
|
onBlur: (e) => {
|
|
324
325
|
var t;
|
|
325
|
-
c ||
|
|
326
|
+
c || ct(), (t = i == null ? void 0 : i.onBlur) == null || t.call(i, e);
|
|
326
327
|
},
|
|
327
328
|
required: Y,
|
|
328
|
-
invalid:
|
|
329
|
+
invalid: Oe || Re || (i == null ? void 0 : i.invalid),
|
|
329
330
|
helper: (() => {
|
|
330
|
-
const e = i == null ? void 0 : i.helper, t =
|
|
331
|
+
const e = i == null ? void 0 : i.helper, t = Oe ? Ze : Re ? et : null, r = t ? { text: t, type: "error" } : null;
|
|
331
332
|
return r ? e ? Array.isArray(e) ? [...e, r] : [e, r] : r : e;
|
|
332
333
|
})(),
|
|
333
334
|
className: B(y["tedi-date-field__textfield"], {
|
|
@@ -341,7 +342,7 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
341
342
|
role: "combobox",
|
|
342
343
|
"aria-haspopup": "dialog",
|
|
343
344
|
"aria-expanded": g ? ee : h,
|
|
344
|
-
"aria-controls":
|
|
345
|
+
"aria-controls": Ye
|
|
345
346
|
} : {}
|
|
346
347
|
}
|
|
347
348
|
}
|
|
@@ -349,75 +350,75 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
349
350
|
}
|
|
350
351
|
),
|
|
351
352
|
g && /* @__PURE__ */ D(
|
|
352
|
-
|
|
353
|
+
jt,
|
|
353
354
|
{
|
|
354
355
|
open: ee,
|
|
355
|
-
onOpenChange:
|
|
356
|
+
onOpenChange: Pe,
|
|
356
357
|
value: o,
|
|
357
|
-
onConfirm:
|
|
358
|
+
onConfirm: bt,
|
|
358
359
|
mode: s,
|
|
359
|
-
numberOfMonths:
|
|
360
|
-
locale:
|
|
360
|
+
numberOfMonths: Ie,
|
|
361
|
+
locale: xe,
|
|
361
362
|
localeCode: H,
|
|
362
|
-
showOutsideDays:
|
|
363
|
+
showOutsideDays: ye,
|
|
363
364
|
disabledMatchers: U,
|
|
364
365
|
required: Y,
|
|
365
|
-
availableDays:
|
|
366
|
-
footer:
|
|
367
|
-
monthYearSelectType:
|
|
368
|
-
minYear:
|
|
369
|
-
maxYear:
|
|
370
|
-
dayStatus:
|
|
371
|
-
showNavigation:
|
|
366
|
+
availableDays: we,
|
|
367
|
+
footer: Ae,
|
|
368
|
+
monthYearSelectType: be,
|
|
369
|
+
minYear: De,
|
|
370
|
+
maxYear: _e,
|
|
371
|
+
dayStatus: Ce,
|
|
372
|
+
showNavigation: Me,
|
|
372
373
|
selectionLevel: E,
|
|
373
374
|
initialView: j,
|
|
374
375
|
initialMonth: W,
|
|
375
|
-
modalProps:
|
|
376
|
-
...
|
|
377
|
-
title:
|
|
376
|
+
modalProps: Ke,
|
|
377
|
+
...Ne,
|
|
378
|
+
title: Qe
|
|
378
379
|
}
|
|
379
380
|
),
|
|
380
|
-
m && !c && !g && /* @__PURE__ */ D(
|
|
381
|
+
m && !c && !g && /* @__PURE__ */ D(Ot, { children: h && /* @__PURE__ */ D(Rt, { context: q, modal: !1, initialFocus: -1, children: /* @__PURE__ */ D(
|
|
381
382
|
"div",
|
|
382
383
|
{
|
|
383
384
|
ref: I.setFloating,
|
|
384
385
|
className: B({
|
|
385
386
|
[y["tedi-date-field__calendar-popover--fullwidth"]]: A
|
|
386
387
|
}),
|
|
387
|
-
|
|
388
|
+
...Le.getFloatingProps({
|
|
388
389
|
style: {
|
|
389
|
-
position:
|
|
390
|
-
top:
|
|
391
|
-
left: A ? 0 :
|
|
390
|
+
position: ht,
|
|
391
|
+
top: pt ?? 0,
|
|
392
|
+
left: A ? 0 : mt ?? 0,
|
|
392
393
|
right: A ? 0 : void 0
|
|
393
394
|
}
|
|
394
395
|
}),
|
|
395
396
|
children: /* @__PURE__ */ D(
|
|
396
|
-
|
|
397
|
+
It,
|
|
397
398
|
{
|
|
398
|
-
...
|
|
399
|
-
numberOfMonths:
|
|
400
|
-
view:
|
|
399
|
+
...Ne,
|
|
400
|
+
numberOfMonths: Ie,
|
|
401
|
+
view: rt,
|
|
401
402
|
selectionLevel: E,
|
|
402
|
-
currentMonth:
|
|
403
|
+
currentMonth: nt,
|
|
403
404
|
setCurrentMonth: oe,
|
|
404
|
-
setView:
|
|
405
|
+
setView: Ee,
|
|
405
406
|
mode: s,
|
|
406
407
|
value: o,
|
|
407
|
-
locale:
|
|
408
|
+
locale: xe,
|
|
408
409
|
localeCode: H,
|
|
409
|
-
showOutsideDays:
|
|
410
|
+
showOutsideDays: ye,
|
|
410
411
|
disabledMatchers: U,
|
|
411
412
|
required: Y,
|
|
412
|
-
availableDays:
|
|
413
|
-
footer:
|
|
414
|
-
monthYearSelectType:
|
|
415
|
-
minYear:
|
|
416
|
-
maxYear:
|
|
417
|
-
dayStatus:
|
|
418
|
-
showNavigation:
|
|
419
|
-
handleSelect:
|
|
420
|
-
applyValue:
|
|
413
|
+
availableDays: we,
|
|
414
|
+
footer: Ae,
|
|
415
|
+
monthYearSelectType: be,
|
|
416
|
+
minYear: De,
|
|
417
|
+
maxYear: _e,
|
|
418
|
+
dayStatus: Ce,
|
|
419
|
+
showNavigation: Me,
|
|
420
|
+
handleSelect: st,
|
|
421
|
+
applyValue: lt,
|
|
421
422
|
className: B(y["tedi-date-field__calendar"], {
|
|
422
423
|
[y["tedi-date-field__calendar--fullwidth"]]: A
|
|
423
424
|
})
|
|
@@ -427,7 +428,7 @@ const Kt = F.forwardRef((w, N) => {
|
|
|
427
428
|
) }) })
|
|
428
429
|
] });
|
|
429
430
|
});
|
|
430
|
-
|
|
431
|
+
Qt.displayName = "DateField";
|
|
431
432
|
export {
|
|
432
|
-
|
|
433
|
+
Qt as DateField
|
|
433
434
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),D=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),w=require("../../../../../external/classnames/index.cjs.js"),n=require("react"),ke=require("../../buttons/button/button.cjs.js"),Nt=require("../../content/calendar/calendar.cjs.js"),y=require("../date-field/date-field-helpers.cjs.js"),Dt=require("../textfield/textfield.cjs.js"),Fe=require("../time-picker/time-picker.cjs.js"),a=require("./date-time-field.module.scss.cjs.js"),yt=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),jt=require("../../../providers/label-provider/use-labels.cjs.js"),Te=require("../../../helpers/hooks/use-breakpoint.cjs.js"),kt=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),Ft=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),Y=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),Tt=require("../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),h=s=>String(s).padStart(2,"0"),g=s=>s?`${h(s.getHours())}:${h(s.getMinutes())}`:"00:00",_=(s,c)=>{const[G,b]=c.split(":"),R=Number(G),P=Number(b),E=new Date(s);return E.setHours(Number.isFinite(R)?R:0,Number.isFinite(P)?P:0,0,0),E},ne=s=>s instanceof Date,Mt=s=>s?`${s.getFullYear()}-${h(s.getMonth()+1)}-${h(s.getDate())}T${h(s.getHours())}:${h(s.getMinutes())}`:"",St=s=>{if(!s)return;const c=new Date(s);return isNaN(c.getTime())?void 0:c},Ct=s=>!s||ne(s)?{}:s,wt=s=>ne(s)?s:void 0,Me=n.forwardRef((s,c)=>{const{getCurrentBreakpointProps:G}=yt.useBreakpointProps(s.defaultServerBreakpoint),{getLabel:b}=jt.useLabels(),R=Te.default(s.defaultServerBreakpoint),P=Te.isBreakpointBelow(R,"md"),{layout:E="side-by-side",useNativePicker:Se=!1,monthYearSelectType:Ce="dropdown",timeGridVariant:we,showOutsideDays:Re=!0,availableTimes:v,timeHeading:U=b("dateTimeField.timeHeading")}=G(s),{id:Pe,label:Ee,placeholder:Ve,className:qe,value:le,defaultValue:Ae,onChange:z,required:de,readOnly:Oe,disabled:V,minDate:oe,maxDate:ce,disablePast:ue,disableFuture:me,disabledMatchers:j,stepMinutes:fe=15,initialMonth:W,locale:$e=kt.et,localeCode:k="et-EE",selectTimeLabel:Le=b("dateTimeField.selectTime"),backLabel:He=b("dateTimeField.back"),mode:Be="single",selectionLevel:Ie="days",minYear:Ye,maxYear:Ge,inputProps:l,disabledDateErrorMessage:Ue=b("dateField.disabledDateError")}=s,d=Be==="range",f=Se&&!d,F=d?"side-by-side":E,he=we??(F==="multi-step"?"radio":"button"),pe=le!==void 0,[ze,We]=n.useState(Ae),x=pe?le:ze,u=d?Ct(x):{},m=d?void 0:wt(x),[N,J]=n.useState(!1),[Je,K]=n.useState("date"),[Ke,ge]=n.useState("days"),Q=d?u.from:m,[Qe,q]=n.useState(()=>Q??W??new Date),_e=n.useRef(Q);_e.current=Q,n.useEffect(()=>{N||(K("date"),ge("days"),q(_e.current??W??new Date))},[N,W]);const A=n.useMemo(()=>new Intl.DateTimeFormat(k,{day:"2-digit",month:"2-digit",year:"numeric"}),[k]),Xe=n.useMemo(()=>new Intl.DateTimeFormat(k,{day:"2-digit",month:"2-digit",year:"2-digit"}),[k]),O=n.useCallback(e=>e?`${A.format(e)} ${h(e.getHours())}:${h(e.getMinutes())}`:"",[A]),$=n.useCallback(e=>{if(!e)return"";if(ne(e))return O(e);const t=O(e.from),r=O(e.to);return!t&&!r?"":r?t?`${t} – ${r}`:r:t},[O]),Ze=n.useMemo(()=>{const e=y.getLocaleDateParts(A),{fieldOrder:t}=e,r=new RegExp(`^${y.buildDateRegexSource(e)}\\s+(\\d{2}):(\\d{2})$`);return bt=>{const I=bt.trim().match(r);if(!I)return;const De={};t.forEach((vt,xt)=>{De[vt]=Number(I[xt+1])});const ye=Number(I[t.length+1]),je=Number(I[t.length+2]),{day:ae,month:se,year:re}=De;if(ae===void 0||se===void 0||re===void 0||ye>23||je>59)return;const C=new Date(re,se-1,ae,ye,je,0,0);if(!(isNaN(C.getTime())||C.getFullYear()!==re||C.getMonth()!==se-1||C.getDate()!==ae))return C}},[A]),[et,X]=n.useState(()=>$(x)),[be,p]=n.useState(!1);n.useEffect(()=>{X($(x))},[x,$]);const tt=D.useFloating({open:N,onOpenChange:J,placement:"bottom-end",middleware:[Y.offset(y.CALENDAR_POPOVER_OFFSET),Y.flip(),Y.shift({padding:y.CALENDAR_POPOVER_PADDING}),Y.size({padding:y.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){t.floating.style.maxWidth=`${e}px`}})],whileElementsMounted:Ft.autoUpdate}),{refs:Z,context:ee,x:it,y:at,strategy:st}=tt,rt=D.useInteractions([D.useDismiss(ee,{outsidePress:e=>{const t=e.target;return!(t!=null&&t.closest('[role="menu"], [role="listbox"]'))}}),D.useRole(ee,{role:"dialog"})]),L=n.useRef(null),nt=n.useCallback(e=>{L.current=e,typeof c=="function"?c(e):c&&(c.current=e)},[c]);n.useEffect(()=>{var e;(e=L.current)!=null&&e.inner&&Z.setReference(L.current.inner)},[Z]);const o=e=>{pe||We(e),z==null||z(e),X($(e))},T=n.useCallback(e=>{if(v)return typeof v=="function"?v(e??new Date):v},[v]),M=n.useCallback((e,t)=>{const r=T(e);return!r||r.length===0||r.includes(t)?t:r[0]},[T]),lt=e=>{if(d){const t=e;if(!t||!t.from&&!t.to){o(void 0);return}const r={};t.from&&(r.from=_(t.from,M(t.from,g(u.from)))),t.to&&(r.to=_(t.to,M(t.to,g(u.to)))),o(r);return}e instanceof Date?o(_(e,M(e,g(m)))):e===void 0&&o(void 0)},dt=e=>{if(d){o({from:_(e,M(e,g(u.from)))});return}o(_(e,M(e,g(m))))},ot=e=>{const t=m??new Date;o(_(t,e)),F==="multi-step"&&T(t)&&J(!1)},ct=e=>t=>{const r=u[e]??u.from??new Date;o({...u,[e]:_(r,t)})},H=n.useMemo(()=>[...y.buildDisabledMatchers({minDate:oe,maxDate:ce,disablePast:ue,disableFuture:me}),...j?Array.isArray(j)?j:[j]:[]],[oe,ce,ue,me,j]),ve=n.useCallback(e=>Tt.dateMatchModifiers(e,H),[H]),ut=e=>{if(X(e),e===""){p(!1),o(void 0);return}if(f){const r=St(e);if(!r){p(!1);return}if(ve(r)){p(!0);return}p(!1),o(r),q(r);return}if(d)return;const t=Ze(e);if(!t){p(!1);return}if(ve(t)){p(!0);return}p(!1),o(t),q(t)},mt=()=>{var t;const e=(t=L.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function"){e.showPicker();return}e.focus()}},ft=()=>{if(!V){if(f){mt();return}J(e=>!e)}},ht=F==="multi-step"?i.jsx("div",{className:a.default["tedi-date-time-field__select-time-wrapper"],children:i.jsx(ke.Button,{type:"button",visualType:"link",size:"small",iconLeft:"schedule",onClick:()=>K("time"),children:Le})}):void 0,te=i.jsx(Nt.Calendar,{view:Ke,setView:ge,selectionLevel:Ie,currentMonth:Qe,setCurrentMonth:q,mode:d?"range":"single",value:d?u:m,numberOfMonths:d&&!P?2:1,locale:$e,localeCode:k,showOutsideDays:Re,monthYearSelectType:Ce,minYear:Ye,maxYear:Ge,disabledMatchers:H.length?H:void 0,required:de,handleSelect:lt,applyValue:dt,footer:ht,className:w.default(a.default["tedi-date-time-field__calendar"],F==="side-by-side"&&a.default["tedi-date-time-field__calendar--split"])}),ie=T(m),pt=!ie||ie.length===0,xe=i.jsx(Fe.TimePicker,{value:g(m),stepMinutes:fe,availableTimes:ie,gridVariant:he,onChange:ot,className:w.default(a.default["tedi-date-time-field__time-picker"],{[a.default["tedi-date-time-field__time-picker--wheel"]]:pt})}),Ne=e=>{const t=T(u[e]),r=!t||t.length===0;return i.jsx(Fe.TimePicker,{value:g(u[e]),stepMinutes:fe,availableTimes:t,gridVariant:he,onChange:ct(e),className:w.default(a.default["tedi-date-time-field__time-picker"],{[a.default["tedi-date-time-field__time-picker--wheel"]]:r})})},S=l==null?void 0:l.helper,B=be?{text:Ue,type:"error"}:null,gt=B?S?Array.isArray(S)?[...S,B]:[S,B]:B:S,_t={...l,id:Pe,label:Ee,value:f?Mt(m):et,placeholder:Ve,readOnly:Oe||!f&&!!v&&!!x,icon:"calendar_today",isClearable:!0,required:de,disabled:V,invalid:be||(l==null?void 0:l.invalid),helper:gt,onIconClick:ft,onChange:ut,className:w.default(a.default["tedi-date-time-field__textfield"],l==null?void 0:l.className,{[a.default["tedi-date-time-field__icon--disabled"]]:V}),input:{...l==null?void 0:l.input,type:f?"datetime-local":"text","aria-expanded":f?void 0:N}};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:w.default(a.default["tedi-date-time-field__container"],qe),"aria-haspopup":"dialog",children:i.jsx(Dt.TextField,{ref:nt,"aria-expanded":f?void 0:N,..._t})}),!f&&i.jsx(D.FloatingPortal,{children:N&&!V&&i.jsx(D.FloatingFocusManager,{context:ee,modal:!1,initialFocus:-1,children:i.jsx("div",{ref:Z.setFloating,className:a.default["tedi-date-time-field__popup"],...rt.getFloatingProps({style:{position:st,top:at??0,left:it??0}}),children:d?i.jsxs("div",{className:a.default["tedi-date-time-field__range"],children:[te,i.jsx("div",{className:a.default["tedi-date-time-field__range-separator"],"aria-hidden":"true",children:i.jsx("div",{className:a.default["tedi-date-time-field__range-separator-line"]})}),i.jsxs("div",{className:a.default["tedi-date-time-field__range-times"],children:[i.jsxs("div",{className:a.default["tedi-date-time-field__range-time"],children:[i.jsx("div",{className:a.default["tedi-date-time-field__split-time-header"],children:i.jsx("span",{className:a.default["tedi-date-time-field__split-heading"],children:U})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:Ne("from")})]}),i.jsxs("div",{className:a.default["tedi-date-time-field__range-time"],children:[i.jsx("div",{className:a.default["tedi-date-time-field__split-time-header"],children:i.jsx("span",{className:a.default["tedi-date-time-field__split-heading"],children:U})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:Ne("to")})]})]})]}):F==="side-by-side"?i.jsxs("div",{className:a.default["tedi-date-time-field__split"],children:[te,i.jsx("div",{className:a.default["tedi-date-time-field__split-separator"],"aria-hidden":"true",children:i.jsx("div",{className:a.default["tedi-date-time-field__split-separator-line"]})}),i.jsxs("div",{className:a.default["tedi-date-time-field__split-time"],children:[i.jsx("div",{className:a.default["tedi-date-time-field__split-time-header"],children:i.jsx("span",{className:a.default["tedi-date-time-field__split-heading"],children:U})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:xe})]})]}):Je==="date"?te:i.jsxs("div",{className:a.default["tedi-date-time-field__time-step"],children:[i.jsxs("header",{className:a.default["tedi-date-time-field__time-header"],children:[i.jsx(ke.Button,{type:"button",visualType:"link",size:"small",iconLeft:"arrow_back",onClick:()=>K("date"),children:He}),i.jsx("span",{className:a.default["tedi-date-time-field__time-date"],children:Xe.format(m??new Date)})]}),i.jsx("div",{className:a.default["tedi-date-time-field__time-body"],children:xe})]})})})})]})});Me.displayName="DateTimeField";exports.DateTimeField=Me;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),D=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),w=require("../../../../../external/classnames/index.cjs.js"),n=require("react"),ke=require("../../buttons/button/button.cjs.js"),Dt=require("../../content/calendar/calendar.cjs.js"),y=require("../date-field/date-field-helpers.cjs.js"),yt=require("../textfield/textfield.cjs.js"),Fe=require("../time-picker/time-picker.cjs.js"),a=require("./date-time-field.module.scss.cjs.js"),jt=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),kt=require("../../../providers/label-provider/use-labels.cjs.js"),Te=require("../../../helpers/hooks/use-breakpoint.cjs.js"),Ft=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),Tt=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),Y=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),Mt=require("../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),h=s=>String(s).padStart(2,"0"),g=s=>s?`${h(s.getHours())}:${h(s.getMinutes())}`:"00:00",_=(s,c)=>{const[G,b]=c.split(":"),R=Number(G),P=Number(b),E=new Date(s);return E.setHours(Number.isFinite(R)?R:0,Number.isFinite(P)?P:0,0,0),E},ne=s=>s instanceof Date,St=s=>s?`${s.getFullYear()}-${h(s.getMonth()+1)}-${h(s.getDate())}T${h(s.getHours())}:${h(s.getMinutes())}`:"",Ct=s=>{if(!s)return;const c=new Date(s);return isNaN(c.getTime())?void 0:c},wt=s=>!s||ne(s)?{}:s,Rt=s=>ne(s)?s:void 0,Me=n.forwardRef((s,c)=>{const{getCurrentBreakpointProps:G}=jt.useBreakpointProps(s.defaultServerBreakpoint),{getLabel:b}=kt.useLabels(),R=Te.default(s.defaultServerBreakpoint),P=Te.isBreakpointBelow(R,"md"),{layout:E="side-by-side",useNativePicker:Se=!1,monthYearSelectType:Ce="dropdown",timeGridVariant:we,showOutsideDays:Re=!0,availableTimes:v,timeHeading:U=b("dateTimeField.timeHeading"),clearable:Pe=!0}=G(s),{id:Ee,label:Ve,placeholder:qe,className:Ae,value:le,defaultValue:Oe,onChange:z,required:de,readOnly:$e,disabled:V,minDate:oe,maxDate:ce,disablePast:ue,disableFuture:me,disabledMatchers:j,stepMinutes:fe=15,initialMonth:W,locale:Le=Ft.et,localeCode:k="et-EE",selectTimeLabel:He=b("dateTimeField.selectTime"),backLabel:Be=b("dateTimeField.back"),mode:Ie="single",selectionLevel:Ye="days",minYear:Ge,maxYear:Ue,inputProps:l,disabledDateErrorMessage:ze=b("dateField.disabledDateError")}=s,d=Ie==="range",f=Se&&!d,F=d?"side-by-side":E,he=we??(F==="multi-step"?"radio":"button"),pe=le!==void 0,[We,Je]=n.useState(Oe),x=pe?le:We,u=d?wt(x):{},m=d?void 0:Rt(x),[N,J]=n.useState(!1),[Ke,K]=n.useState("date"),[Qe,ge]=n.useState("days"),Q=d?u.from:m,[Xe,q]=n.useState(()=>Q??W??new Date),_e=n.useRef(Q);_e.current=Q,n.useEffect(()=>{N||(K("date"),ge("days"),q(_e.current??W??new Date))},[N,W]);const A=n.useMemo(()=>new Intl.DateTimeFormat(k,{day:"2-digit",month:"2-digit",year:"numeric"}),[k]),Ze=n.useMemo(()=>new Intl.DateTimeFormat(k,{day:"2-digit",month:"2-digit",year:"2-digit"}),[k]),O=n.useCallback(e=>e?`${A.format(e)} ${h(e.getHours())}:${h(e.getMinutes())}`:"",[A]),$=n.useCallback(e=>{if(!e)return"";if(ne(e))return O(e);const t=O(e.from),r=O(e.to);return!t&&!r?"":r?t?`${t} – ${r}`:r:t},[O]),et=n.useMemo(()=>{const e=y.getLocaleDateParts(A),{fieldOrder:t}=e,r=new RegExp(`^${y.buildDateRegexSource(e)}\\s+(\\d{2}):(\\d{2})$`);return vt=>{const I=vt.trim().match(r);if(!I)return;const De={};t.forEach((xt,Nt)=>{De[xt]=Number(I[Nt+1])});const ye=Number(I[t.length+1]),je=Number(I[t.length+2]),{day:ae,month:se,year:re}=De;if(ae===void 0||se===void 0||re===void 0||ye>23||je>59)return;const C=new Date(re,se-1,ae,ye,je,0,0);if(!(isNaN(C.getTime())||C.getFullYear()!==re||C.getMonth()!==se-1||C.getDate()!==ae))return C}},[A]),[tt,X]=n.useState(()=>$(x)),[be,p]=n.useState(!1);n.useEffect(()=>{X($(x))},[x,$]);const it=D.useFloating({open:N,onOpenChange:J,placement:"bottom-end",middleware:[Y.offset(y.CALENDAR_POPOVER_OFFSET),Y.flip(),Y.shift({padding:y.CALENDAR_POPOVER_PADDING}),Y.size({padding:y.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){t.floating.style.maxWidth=`${e}px`}})],whileElementsMounted:Tt.autoUpdate}),{refs:Z,context:ee,x:at,y:st,strategy:rt}=it,nt=D.useInteractions([D.useDismiss(ee,{outsidePress:e=>{const t=e.target;return!(t!=null&&t.closest('[role="menu"], [role="listbox"]'))}}),D.useRole(ee,{role:"dialog"})]),L=n.useRef(null),lt=n.useCallback(e=>{L.current=e,typeof c=="function"?c(e):c&&(c.current=e)},[c]);n.useEffect(()=>{var e;(e=L.current)!=null&&e.inner&&Z.setReference(L.current.inner)},[Z]);const o=e=>{pe||Je(e),z==null||z(e),X($(e))},T=n.useCallback(e=>{if(v)return typeof v=="function"?v(e??new Date):v},[v]),M=n.useCallback((e,t)=>{const r=T(e);return!r||r.length===0||r.includes(t)?t:r[0]},[T]),dt=e=>{if(d){const t=e;if(!t||!t.from&&!t.to){o(void 0);return}const r={};t.from&&(r.from=_(t.from,M(t.from,g(u.from)))),t.to&&(r.to=_(t.to,M(t.to,g(u.to)))),o(r);return}e instanceof Date?o(_(e,M(e,g(m)))):e===void 0&&o(void 0)},ot=e=>{if(d){o({from:_(e,M(e,g(u.from)))});return}o(_(e,M(e,g(m))))},ct=e=>{const t=m??new Date;o(_(t,e)),F==="multi-step"&&T(t)&&J(!1)},ut=e=>t=>{const r=u[e]??u.from??new Date;o({...u,[e]:_(r,t)})},H=n.useMemo(()=>[...y.buildDisabledMatchers({minDate:oe,maxDate:ce,disablePast:ue,disableFuture:me}),...j?Array.isArray(j)?j:[j]:[]],[oe,ce,ue,me,j]),ve=n.useCallback(e=>Mt.dateMatchModifiers(e,H),[H]),mt=e=>{if(X(e),e===""){p(!1),o(void 0);return}if(f){const r=Ct(e);if(!r){p(!1);return}if(ve(r)){p(!0);return}p(!1),o(r),q(r);return}if(d)return;const t=et(e);if(!t){p(!1);return}if(ve(t)){p(!0);return}p(!1),o(t),q(t)},ft=()=>{var t;const e=(t=L.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function"){e.showPicker();return}e.focus()}},ht=()=>{if(!V){if(f){ft();return}J(e=>!e)}},pt=F==="multi-step"?i.jsx("div",{className:a.default["tedi-date-time-field__select-time-wrapper"],children:i.jsx(ke.Button,{type:"button",visualType:"link",size:"small",iconLeft:"schedule",onClick:()=>K("time"),children:He})}):void 0,te=i.jsx(Dt.Calendar,{view:Qe,setView:ge,selectionLevel:Ye,currentMonth:Xe,setCurrentMonth:q,mode:d?"range":"single",value:d?u:m,numberOfMonths:d&&!P?2:1,locale:Le,localeCode:k,showOutsideDays:Re,monthYearSelectType:Ce,minYear:Ge,maxYear:Ue,disabledMatchers:H.length?H:void 0,required:de,handleSelect:dt,applyValue:ot,footer:pt,className:w.default(a.default["tedi-date-time-field__calendar"],F==="side-by-side"&&a.default["tedi-date-time-field__calendar--split"])}),ie=T(m),gt=!ie||ie.length===0,xe=i.jsx(Fe.TimePicker,{value:g(m),stepMinutes:fe,availableTimes:ie,gridVariant:he,onChange:ct,className:w.default(a.default["tedi-date-time-field__time-picker"],{[a.default["tedi-date-time-field__time-picker--wheel"]]:gt})}),Ne=e=>{const t=T(u[e]),r=!t||t.length===0;return i.jsx(Fe.TimePicker,{value:g(u[e]),stepMinutes:fe,availableTimes:t,gridVariant:he,onChange:ut(e),className:w.default(a.default["tedi-date-time-field__time-picker"],{[a.default["tedi-date-time-field__time-picker--wheel"]]:r})})},S=l==null?void 0:l.helper,B=be?{text:ze,type:"error"}:null,_t=B?S?Array.isArray(S)?[...S,B]:[S,B]:B:S,bt={...l,id:Ee,label:Ve,value:f?St(m):tt,placeholder:qe,readOnly:$e||!f&&!!v&&!!x,icon:"calendar_today",isClearable:Pe,required:de,disabled:V,invalid:be||(l==null?void 0:l.invalid),helper:_t,onIconClick:ht,onChange:mt,className:w.default(a.default["tedi-date-time-field__textfield"],l==null?void 0:l.className,{[a.default["tedi-date-time-field__icon--disabled"]]:V}),input:{...l==null?void 0:l.input,type:f?"datetime-local":"text","aria-expanded":f?void 0:N}};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:w.default(a.default["tedi-date-time-field__container"],Ae),"aria-haspopup":"dialog",children:i.jsx(yt.TextField,{ref:lt,"aria-expanded":f?void 0:N,...bt})}),!f&&i.jsx(D.FloatingPortal,{children:N&&!V&&i.jsx(D.FloatingFocusManager,{context:ee,modal:!1,initialFocus:-1,children:i.jsx("div",{ref:Z.setFloating,className:a.default["tedi-date-time-field__popup"],...nt.getFloatingProps({style:{position:rt,top:st??0,left:at??0}}),children:d?i.jsxs("div",{className:a.default["tedi-date-time-field__range"],children:[te,i.jsx("div",{className:a.default["tedi-date-time-field__range-separator"],"aria-hidden":"true",children:i.jsx("div",{className:a.default["tedi-date-time-field__range-separator-line"]})}),i.jsxs("div",{className:a.default["tedi-date-time-field__range-times"],children:[i.jsxs("div",{className:a.default["tedi-date-time-field__range-time"],children:[i.jsx("div",{className:a.default["tedi-date-time-field__split-time-header"],children:i.jsx("span",{className:a.default["tedi-date-time-field__split-heading"],children:U})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:Ne("from")})]}),i.jsxs("div",{className:a.default["tedi-date-time-field__range-time"],children:[i.jsx("div",{className:a.default["tedi-date-time-field__split-time-header"],children:i.jsx("span",{className:a.default["tedi-date-time-field__split-heading"],children:U})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:Ne("to")})]})]})]}):F==="side-by-side"?i.jsxs("div",{className:a.default["tedi-date-time-field__split"],children:[te,i.jsx("div",{className:a.default["tedi-date-time-field__split-separator"],"aria-hidden":"true",children:i.jsx("div",{className:a.default["tedi-date-time-field__split-separator-line"]})}),i.jsxs("div",{className:a.default["tedi-date-time-field__split-time"],children:[i.jsx("div",{className:a.default["tedi-date-time-field__split-time-header"],children:i.jsx("span",{className:a.default["tedi-date-time-field__split-heading"],children:U})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:xe})]})]}):Ke==="date"?te:i.jsxs("div",{className:a.default["tedi-date-time-field__time-step"],children:[i.jsxs("header",{className:a.default["tedi-date-time-field__time-header"],children:[i.jsx(ke.Button,{type:"button",visualType:"link",size:"small",iconLeft:"arrow_back",onClick:()=>K("date"),children:Be}),i.jsx("span",{className:a.default["tedi-date-time-field__time-date"],children:Ze.format(m??new Date)})]}),i.jsx("div",{className:a.default["tedi-date-time-field__time-body"],children:xe})]})})})})]})});Me.displayName="DateTimeField";exports.DateTimeField=Me;
|
|
@@ -20,6 +20,12 @@ type DateTimeFieldBreakpointProps = {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
useNativePicker?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the field shows a clear button to reset the value. Disable it
|
|
25
|
+
* when the field is required or the value should not be cleared.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
clearable?: boolean;
|
|
23
29
|
/**
|
|
24
30
|
* Layout of the date-and-time popover. `mode='range'` always uses
|
|
25
31
|
* `'side-by-side'` regardless of this value — the range UI needs the
|