@tedi-design-system/react 18.0.0-rc.8 → 18.0.0-rc.9
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/_virtual/index.cjs10.js +1 -1
- package/_virtual/index.cjs11.js +1 -1
- package/_virtual/index.cjs12.js +1 -1
- package/_virtual/index.cjs13.js +1 -1
- package/_virtual/index.cjs5.js +1 -1
- package/_virtual/index.cjs6.js +1 -1
- package/_virtual/index.cjs7.js +1 -1
- package/_virtual/index.cjs8.js +1 -1
- package/_virtual/index.cjs9.js +1 -1
- package/_virtual/index.es10.js +1 -1
- package/_virtual/index.es11.js +1 -1
- package/_virtual/index.es12.js +1 -1
- package/_virtual/index.es13.js +2 -4
- package/_virtual/index.es5.js +4 -2
- package/_virtual/index.es6.js +1 -1
- package/_virtual/index.es7.js +1 -1
- package/_virtual/index.es8.js +1 -1
- package/_virtual/index.es9.js +1 -1
- package/bundle-stats.html +1 -1
- package/external/@mui/system/colorManipulator.cjs.js +1 -1
- package/external/@mui/system/colorManipulator.es.js +2 -2
- package/external/@mui/system/createStyled.cjs.js +1 -1
- package/external/@mui/system/createStyled.es.js +6 -6
- package/external/@mui/system/useThemeWithoutDefault.cjs.js +1 -1
- package/external/@mui/system/useThemeWithoutDefault.es.js +1 -1
- package/external/toposort/index.cjs.js +1 -1
- package/external/toposort/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/form/pickers/calendar/calendar.d.ts +6 -0
- package/src/community/components/form/pickers/datepicker/datepicker.d.ts +6 -0
- package/src/community/components/form/pickers/datetimepicker/datetimepicker.d.ts +6 -0
- package/src/community/components/form/pickers/timepicker/timepicker.d.ts +6 -0
- package/src/tedi/components/content/calendar/calendar-grid.cjs.js +1 -1
- package/src/tedi/components/content/calendar/calendar-grid.es.js +7 -6
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.cjs.js +1 -1
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.es.js +99 -79
- package/src/tedi/components/form/date-field/date-field-helpers.cjs.js +1 -0
- package/src/tedi/components/form/date-field/date-field-helpers.d.ts +66 -0
- package/src/tedi/components/form/date-field/date-field-helpers.es.js +28 -0
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +22 -0
- package/src/tedi/components/form/date-field/date-field.es.js +248 -212
- package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -0
- package/src/tedi/components/form/date-time-field/date-time-field.d.ts +207 -0
- package/src/tedi/components/form/date-time-field/date-time-field.es.js +376 -0
- package/src/tedi/components/form/date-time-field/date-time-field.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/date-time-field/date-time-field.module.scss.es.js +30 -0
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.d.ts +9 -0
- package/src/tedi/components/form/time-field/time-field.es.js +81 -79
- package/src/tedi/components/overlays/dropdown/dropdown.es.js +0 -3
- package/src/tedi/index.d.ts +1 -0
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +28 -0
- package/src/tedi/providers/label-provider/labels-map.es.js +93 -65
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +217 -215
|
@@ -70,8 +70,22 @@ export interface DateFieldProps extends BreakpointSupport<DateFieldBreakpointPro
|
|
|
70
70
|
onSelect?: OnSelectHandler<Date | Date[] | DateRange | undefined>;
|
|
71
71
|
/**
|
|
72
72
|
* Disable specific dates. Accepts the same matchers as React DayPicker's `disabled` prop.
|
|
73
|
+
*
|
|
74
|
+
* @deprecated Use `disabledMatchers` instead — same shape, semantics, and merging
|
|
75
|
+
* behaviour. The current overload re-uses the form-control `disabled` name for a
|
|
76
|
+
* matcher prop, which is inconsistent with `DateTimeField`'s boolean `disabled`
|
|
77
|
+
* and confusing for consumers migrating between the two siblings. `disabledMatchers`
|
|
78
|
+
* stays additive for now; this overload will be replaced by `disabled?: boolean`
|
|
79
|
+
* in a future major.
|
|
73
80
|
*/
|
|
74
81
|
disabled?: Matcher | Matcher[];
|
|
82
|
+
/**
|
|
83
|
+
* Disable specific dates via react-day-picker matchers. Mirrors the
|
|
84
|
+
* `disabledMatchers` prop on `DateTimeField` so the API is consistent across
|
|
85
|
+
* the date-field family. Merges with the (deprecated) `disabled` overload —
|
|
86
|
+
* if both are supplied, the union of both matcher sets is applied.
|
|
87
|
+
*/
|
|
88
|
+
disabledMatchers?: Matcher | Matcher[];
|
|
75
89
|
/**
|
|
76
90
|
* Input placeholder text when no date is selected.
|
|
77
91
|
*/
|
|
@@ -197,6 +211,14 @@ export interface DateFieldProps extends BreakpointSupport<DateFieldBreakpointPro
|
|
|
197
211
|
* Props to pass down to the underlying TextField (in 'single' mode) or MultiValueField (in 'multiple' mode). This allows for additional customization of the input field, such as adding custom styles, attributes, or event handlers.
|
|
198
212
|
*/
|
|
199
213
|
inputProps?: DateTextFieldProps | DateMultiValueFieldProps;
|
|
214
|
+
/**
|
|
215
|
+
* Error message rendered below the input when the user types a date that
|
|
216
|
+
* matches one of the disable matchers (`disablePast`, `disableFuture`,
|
|
217
|
+
* `minDate`, `maxDate`, `disabledMatchers`, or the deprecated `disabled`
|
|
218
|
+
* overload). Falls back to the localised `dateField.disabledDateError`
|
|
219
|
+
* label.
|
|
220
|
+
*/
|
|
221
|
+
disabledDateErrorMessage?: string;
|
|
200
222
|
}
|
|
201
223
|
export declare const DateField: React.ForwardRefExoticComponent<DateFieldProps & React.RefAttributes<TextFieldForwardRef>>;
|
|
202
224
|
export {};
|
|
@@ -1,184 +1,208 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useFloating as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Calendar as
|
|
6
|
-
import { MultiValueField as
|
|
7
|
-
import { TextField as
|
|
1
|
+
import { jsxs as Je, Fragment as Ke, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as Qe, useClick as Xe, useInteractions as Ze, useDismiss as et, useRole as tt, FloatingPortal as rt, FloatingFocusManager as it } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
|
+
import X from "../../../../../external/classnames/index.es.js";
|
|
4
|
+
import Z, { useState as F, useCallback as ee, useEffect as v, useMemo as te } from "react";
|
|
5
|
+
import { Calendar as at } from "../../content/calendar/calendar.es.js";
|
|
6
|
+
import { MultiValueField as nt } from "../multi-value-field/multi-value-field.es.js";
|
|
7
|
+
import { TextField as ot } from "../textfield/textfield.es.js";
|
|
8
8
|
import b from "./date-field.module.scss.es.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
import { getLocaleDateParts as st, buildDateRegexSource as lt, CALENDAR_POPOVER_OFFSET as ft, CALENDAR_POPOVER_PADDING as ue } from "./date-field-helpers.es.js";
|
|
10
|
+
import { et as dt } from "../../../../../external/react-day-picker/dist/esm/locale/et.es.js";
|
|
11
|
+
import { autoUpdate as ct } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
|
|
12
|
+
import { offset as ut, flip as mt, shift as pt, size as ht } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
|
|
13
|
+
import { useBreakpointProps as gt } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
14
|
+
import { useLabels as yt } from "../../../providers/label-provider/use-labels.es.js";
|
|
15
|
+
import { useBreakpoint as bt, isBreakpointBelow as Dt } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
16
|
+
import { dateMatchModifiers as xt } from "../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.es.js";
|
|
17
|
+
const _t = Z.forwardRef((O, C) => {
|
|
18
|
+
const { getCurrentBreakpointProps: me } = gt(O.defaultServerBreakpoint), { getLabel: pe } = yt(), {
|
|
19
|
+
useNativePicker: he = !1,
|
|
20
|
+
enableCalendar: d = !0,
|
|
21
|
+
calendarTrigger: B = "button",
|
|
22
|
+
numberOfMonths: I
|
|
23
|
+
} = me(O), {
|
|
24
|
+
id: re,
|
|
25
|
+
mode: m = "single",
|
|
26
|
+
label: ie,
|
|
27
|
+
selected: N,
|
|
26
28
|
onSelect: i,
|
|
27
|
-
disabled:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
29
|
+
disabled: k,
|
|
30
|
+
disabledMatchers: w,
|
|
31
|
+
placeholder: ge,
|
|
32
|
+
className: ye,
|
|
33
|
+
formatDate: f,
|
|
34
|
+
required: T,
|
|
35
|
+
showOutsideDays: be = !0,
|
|
36
|
+
parseDate: De,
|
|
37
|
+
monthYearSelectType: xe,
|
|
38
|
+
selectionLevel: E = "days",
|
|
39
|
+
locale: _e = dt,
|
|
40
|
+
localeCode: $ = "et-EE",
|
|
41
|
+
initialMonth: L,
|
|
42
|
+
closeOnSelect: Ae,
|
|
43
|
+
footer: Me,
|
|
44
|
+
defaultValue: R,
|
|
45
|
+
minDate: j,
|
|
46
|
+
maxDate: W,
|
|
47
|
+
disablePast: ae,
|
|
48
|
+
disableFuture: ne,
|
|
49
|
+
shouldDisableMonth: S,
|
|
50
|
+
shouldDisableYear: Y,
|
|
51
|
+
readOnly: H,
|
|
52
|
+
availableDays: Fe,
|
|
53
|
+
inputProps: n,
|
|
54
|
+
disabledDateErrorMessage: Ce = pe("dateField.disabledDateError"),
|
|
55
|
+
useNativePicker: At,
|
|
56
|
+
enableCalendar: Mt,
|
|
57
|
+
calendarTrigger: Ft,
|
|
58
|
+
numberOfMonths: Ct,
|
|
59
|
+
defaultServerBreakpoint: Nt,
|
|
60
|
+
sm: kt,
|
|
61
|
+
md: wt,
|
|
62
|
+
lg: Pt,
|
|
63
|
+
xl: vt,
|
|
64
|
+
xxl: Ot,
|
|
65
|
+
...Ne
|
|
66
|
+
} = O, c = he && m === "single", ke = bt(O.defaultServerBreakpoint), we = Dt(ke, "md") && typeof I == "number" && I > 1 ? 1 : I, [Pe, p] = F(N ?? R), [u, D] = F(!1), [ve, oe] = F(E), [Oe, x] = F(""), [se, h] = F(!1), o = N !== void 0, s = o ? N : Pe, le = Z.useRef(null), Ee = Z.useCallback(
|
|
63
67
|
(e) => {
|
|
64
|
-
|
|
68
|
+
le.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
|
|
65
69
|
},
|
|
66
70
|
[C]
|
|
67
|
-
),
|
|
71
|
+
), Re = (e) => {
|
|
68
72
|
if (!e) return "";
|
|
69
|
-
const
|
|
70
|
-
return `${
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
u ||
|
|
74
|
-
}, [
|
|
75
|
-
u &&
|
|
76
|
-
}, [u,
|
|
77
|
-
|
|
78
|
-
}, [
|
|
79
|
-
const g =
|
|
80
|
-
() => new Intl.DateTimeFormat(
|
|
73
|
+
const t = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), l = String(e.getDate()).padStart(2, "0");
|
|
74
|
+
return `${t}-${r}-${l}`;
|
|
75
|
+
}, Ve = c && s instanceof Date ? Re(s) : "", U = ee((e, t) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [...e].sort((r, l) => r.getTime() - l.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(), []), [Be, q] = F(() => U(s, L));
|
|
76
|
+
v(() => {
|
|
77
|
+
u || q(U(s, L));
|
|
78
|
+
}, [s, L, u, U]), v(() => {
|
|
79
|
+
u && oe(E);
|
|
80
|
+
}, [u, E]), v(() => {
|
|
81
|
+
o && p(N);
|
|
82
|
+
}, [N, o]);
|
|
83
|
+
const g = te(
|
|
84
|
+
() => new Intl.DateTimeFormat($, {
|
|
81
85
|
day: "2-digit",
|
|
82
86
|
month: "2-digit",
|
|
83
87
|
year: "numeric"
|
|
84
88
|
}),
|
|
85
|
-
[
|
|
86
|
-
), _ =
|
|
89
|
+
[$]
|
|
90
|
+
), _ = ee(
|
|
87
91
|
(e) => {
|
|
88
92
|
if (!e) return "";
|
|
89
93
|
if (e instanceof Date) return g.format(e);
|
|
90
|
-
if (Array.isArray(e)) return e.map((
|
|
94
|
+
if (Array.isArray(e)) return e.map((t) => g.format(t)).join(", ");
|
|
91
95
|
if (e.from) {
|
|
92
|
-
const
|
|
93
|
-
return e.to ? `${
|
|
96
|
+
const t = g.format(e.from);
|
|
97
|
+
return e.to ? `${t} – ${g.format(e.to)}` : t;
|
|
94
98
|
}
|
|
95
99
|
return "";
|
|
96
100
|
},
|
|
97
101
|
[g]
|
|
98
|
-
),
|
|
99
|
-
id:
|
|
100
|
-
label:
|
|
102
|
+
), z = Ae ?? m === "single", fe = m === "multiple" && Array.isArray(s) ? s.map((e, t) => ({
|
|
103
|
+
id: t,
|
|
104
|
+
label: f ? f(e) : _(e),
|
|
101
105
|
date: e
|
|
102
|
-
})) : [],
|
|
106
|
+
})) : [], G = te(() => {
|
|
103
107
|
const e = [];
|
|
104
|
-
return
|
|
105
|
-
}, [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
return k && (Array.isArray(k) ? e.push(...k) : e.push(k)), w && (Array.isArray(w) ? e.push(...w) : e.push(w)), j && e.push({ before: j }), W && e.push({ after: W }), ae && e.push({ before: /* @__PURE__ */ new Date() }), ne && e.push({ after: /* @__PURE__ */ new Date() }), S && e.push((t) => S(t)), Y && e.push((t) => Y(t)), e;
|
|
109
|
+
}, [
|
|
110
|
+
k,
|
|
111
|
+
w,
|
|
112
|
+
j,
|
|
113
|
+
W,
|
|
114
|
+
ae,
|
|
115
|
+
ne,
|
|
116
|
+
S,
|
|
117
|
+
Y
|
|
118
|
+
]), A = ee(
|
|
119
|
+
(e) => xt(e, G),
|
|
120
|
+
[G]
|
|
121
|
+
), Ie = (e, t, r, l) => {
|
|
122
|
+
if (o || p(e), i == null || i(e, t, r, l), e) {
|
|
123
|
+
const a = f ? f(e) : _(e);
|
|
124
|
+
x(a);
|
|
112
125
|
} else
|
|
113
126
|
x("");
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
x(
|
|
120
|
-
},
|
|
121
|
-
const e =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return (s) => {
|
|
129
|
-
const k = s.match(qe);
|
|
130
|
-
if (!k) return;
|
|
131
|
-
const T = {};
|
|
132
|
-
t.forEach((ze, Ge) => {
|
|
133
|
-
T[ze] = Number(k[Ge + 1]);
|
|
127
|
+
z && D(!1);
|
|
128
|
+
}, Te = (e) => {
|
|
129
|
+
if (A(e)) return;
|
|
130
|
+
o || p(e), i == null || i(e, e, {}, {});
|
|
131
|
+
const t = f ? f(e) : _(e);
|
|
132
|
+
x(t), z && D(!1);
|
|
133
|
+
}, $e = te(() => {
|
|
134
|
+
const e = st(g), t = new RegExp(`^${lt(e)}$`), { fieldOrder: r } = e;
|
|
135
|
+
return (l) => {
|
|
136
|
+
const a = l.match(t);
|
|
137
|
+
if (!a) return;
|
|
138
|
+
const J = {};
|
|
139
|
+
r.forEach((ze, Ge) => {
|
|
140
|
+
J[ze] = Number(a[Ge + 1]);
|
|
134
141
|
});
|
|
135
|
-
const { day:
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
138
|
-
if (!(isNaN(
|
|
139
|
-
return
|
|
142
|
+
const { day: M, month: K, year: Q } = J;
|
|
143
|
+
if (M === void 0 || K === void 0 || Q === void 0) return;
|
|
144
|
+
const P = new Date(Q, K - 1, M);
|
|
145
|
+
if (!(isNaN(P.getTime()) || P.getFullYear() !== Q || P.getMonth() !== K - 1 || P.getDate() !== M))
|
|
146
|
+
return P;
|
|
140
147
|
};
|
|
141
|
-
}, [g]),
|
|
142
|
-
x(e)
|
|
143
|
-
|
|
148
|
+
}, [g]), Le = (e) => {
|
|
149
|
+
if (x(e), e.trim() === "") {
|
|
150
|
+
h(!1);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const r = (De ?? (m === "single" ? $e : () => {
|
|
144
154
|
}))(e);
|
|
145
|
-
(
|
|
155
|
+
if (!(m === "single" && r instanceof Date || m === "multiple" && Array.isArray(r) || m === "range" && !!r && !Array.isArray(r) && "from" in r)) {
|
|
156
|
+
h(!1);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const a = r && !Array.isArray(r) && "from" in r ? r : null;
|
|
160
|
+
if (r instanceof Date && A(r) || Array.isArray(r) && r.some((M) => M instanceof Date && A(M)) || !!a && (a.from && A(a.from) || a.to && A(a.to))) {
|
|
161
|
+
h(!0);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
h(!1), o || p(r), i == null || i(r, r, {}, {}), r instanceof Date && q(r), z && D(!1);
|
|
146
165
|
};
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
const e =
|
|
166
|
+
v(() => {
|
|
167
|
+
if (o) {
|
|
168
|
+
const e = f ? f(s) : _(s);
|
|
150
169
|
x(e);
|
|
151
170
|
}
|
|
152
|
-
}, [
|
|
153
|
-
if (!
|
|
154
|
-
const e =
|
|
171
|
+
}, [s, o, f, _]), v(() => {
|
|
172
|
+
if (!o && R) {
|
|
173
|
+
const e = f ? f(R) : _(R);
|
|
155
174
|
x(e);
|
|
156
175
|
}
|
|
157
176
|
}, []);
|
|
158
|
-
const
|
|
177
|
+
const je = Qe({
|
|
159
178
|
open: u,
|
|
160
179
|
onOpenChange: D,
|
|
161
|
-
placement:
|
|
180
|
+
placement: B === "input" ? "bottom-start" : "bottom-end",
|
|
162
181
|
middleware: [
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
padding:
|
|
168
|
-
apply({ availableWidth: e, elements:
|
|
169
|
-
const
|
|
170
|
-
|
|
182
|
+
ut(ft),
|
|
183
|
+
mt(),
|
|
184
|
+
pt({ padding: ue }),
|
|
185
|
+
ht({
|
|
186
|
+
padding: ue,
|
|
187
|
+
apply({ availableWidth: e, elements: t }) {
|
|
188
|
+
const r = t.floating;
|
|
189
|
+
r.style.width = "max-content", r.style.maxWidth = "", r.getBoundingClientRect().width > e ? (r.style.width = "min-content", r.style.maxWidth = `${e}px`) : (r.style.width = "", r.style.maxWidth = "");
|
|
171
190
|
}
|
|
172
191
|
})
|
|
173
192
|
],
|
|
174
|
-
whileElementsMounted:
|
|
175
|
-
}), { refs:
|
|
176
|
-
...
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
193
|
+
whileElementsMounted: ct
|
|
194
|
+
}), { refs: de, context: V, x: We, y: Se, strategy: Ye } = je, He = Xe(V), ce = Ze([
|
|
195
|
+
...d && !c && B === "input" ? [He] : [],
|
|
196
|
+
et(V, {
|
|
197
|
+
outsidePress: (e) => {
|
|
198
|
+
const t = e.target;
|
|
199
|
+
return !(t != null && t.closest('[role="menu"], [role="listbox"]'));
|
|
200
|
+
}
|
|
201
|
+
}),
|
|
202
|
+
tt(V, { role: "dialog" })
|
|
203
|
+
]), Ue = () => {
|
|
204
|
+
var t;
|
|
205
|
+
const e = (t = le.current) == null ? void 0 : t.input;
|
|
182
206
|
if (e) {
|
|
183
207
|
if (typeof e.showPicker == "function")
|
|
184
208
|
try {
|
|
@@ -188,108 +212,120 @@ const gt = 4, de = 8, yt = X.forwardRef((v, C) => {
|
|
|
188
212
|
}
|
|
189
213
|
e.focus();
|
|
190
214
|
}
|
|
191
|
-
},
|
|
215
|
+
}, qe = (e) => {
|
|
192
216
|
if (!e) {
|
|
193
|
-
|
|
217
|
+
h(!1), o || p(void 0), i == null || i(void 0, void 0, {}, {});
|
|
194
218
|
return;
|
|
195
219
|
}
|
|
196
|
-
const [
|
|
197
|
-
if (!
|
|
198
|
-
const
|
|
199
|
-
Number.isNaN(
|
|
220
|
+
const [t, r, l] = e.split("-").map(Number);
|
|
221
|
+
if (!t || !r || !l) return;
|
|
222
|
+
const a = new Date(t, r - 1, l);
|
|
223
|
+
if (!Number.isNaN(a.getTime())) {
|
|
224
|
+
if (A(a)) {
|
|
225
|
+
h(!0);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
h(!1), o || p(a), i == null || i(a, a, {}, {});
|
|
229
|
+
}
|
|
200
230
|
};
|
|
201
|
-
return /* @__PURE__ */
|
|
231
|
+
return /* @__PURE__ */ Je(Ke, { children: [
|
|
202
232
|
/* @__PURE__ */ y(
|
|
203
233
|
"div",
|
|
204
234
|
{
|
|
205
|
-
className:
|
|
235
|
+
className: X(b["tedi-date-field__container"], ye),
|
|
206
236
|
...ce.getReferenceProps(),
|
|
207
|
-
ref:
|
|
208
|
-
children:
|
|
209
|
-
|
|
237
|
+
ref: de.setReference,
|
|
238
|
+
children: m === "multiple" ? /* @__PURE__ */ y(
|
|
239
|
+
nt,
|
|
210
240
|
{
|
|
211
|
-
...
|
|
212
|
-
id:
|
|
213
|
-
label:
|
|
214
|
-
values:
|
|
241
|
+
...n,
|
|
242
|
+
id: re,
|
|
243
|
+
label: ie,
|
|
244
|
+
values: fe.map((e) => e.label),
|
|
215
245
|
icon: "calendar_today",
|
|
216
|
-
onIconClick: () =>
|
|
217
|
-
iconButtonProps:
|
|
246
|
+
onIconClick: () => d && D((e) => !e),
|
|
247
|
+
iconButtonProps: d ? { "aria-expanded": u, "aria-haspopup": "dialog" } : void 0,
|
|
218
248
|
isClearable: !0,
|
|
219
|
-
required:
|
|
249
|
+
required: T,
|
|
220
250
|
onChange: (e) => {
|
|
221
|
-
if (!Array.isArray(
|
|
222
|
-
const
|
|
223
|
-
|
|
251
|
+
if (!Array.isArray(s)) return;
|
|
252
|
+
const t = fe.filter((r) => e.includes(r.label)).map((r) => r.date);
|
|
253
|
+
o || p(t), i == null || i(t, {}, {}, {});
|
|
224
254
|
},
|
|
225
|
-
className:
|
|
226
|
-
[b["tedi-date-field__icon--disabled"]]: !
|
|
255
|
+
className: X(b["tedi-date-field__textfield"], {
|
|
256
|
+
[b["tedi-date-field__icon--disabled"]]: !d || H
|
|
227
257
|
})
|
|
228
258
|
}
|
|
229
259
|
) : /* @__PURE__ */ y(
|
|
230
|
-
|
|
260
|
+
ot,
|
|
231
261
|
{
|
|
232
|
-
...
|
|
233
|
-
ref:
|
|
234
|
-
id:
|
|
235
|
-
label:
|
|
236
|
-
readOnly:
|
|
237
|
-
value:
|
|
238
|
-
placeholder:
|
|
262
|
+
...n,
|
|
263
|
+
ref: Ee,
|
|
264
|
+
id: re,
|
|
265
|
+
label: ie,
|
|
266
|
+
readOnly: H,
|
|
267
|
+
value: c ? Ve : Oe,
|
|
268
|
+
placeholder: ge,
|
|
239
269
|
icon: "calendar_today",
|
|
270
|
+
"aria-expanded": d && !c ? u : void 0,
|
|
240
271
|
isClearable: !0,
|
|
241
272
|
onIconClick: () => {
|
|
242
|
-
|
|
273
|
+
d && (c ? Ue() : D((e) => !e));
|
|
243
274
|
},
|
|
244
|
-
iconButtonProps:
|
|
245
|
-
onChange: (e) =>
|
|
246
|
-
required:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
275
|
+
iconButtonProps: d && !c ? { "aria-expanded": u, "aria-haspopup": "dialog" } : void 0,
|
|
276
|
+
onChange: (e) => c ? qe(e) : Le(e),
|
|
277
|
+
required: T,
|
|
278
|
+
invalid: se || (n == null ? void 0 : n.invalid),
|
|
279
|
+
helper: (() => {
|
|
280
|
+
const e = n == null ? void 0 : n.helper, t = se ? { text: Ce, type: "error" } : null;
|
|
281
|
+
return t ? e ? Array.isArray(e) ? [...e, t] : [e, t] : t : e;
|
|
282
|
+
})(),
|
|
283
|
+
className: X(b["tedi-date-field__textfield"], {
|
|
284
|
+
[b["tedi-date-field__textfield--disabled"]]: n == null ? void 0 : n.disabled,
|
|
285
|
+
[b["tedi-date-field__icon--disabled"]]: !d || H
|
|
250
286
|
}),
|
|
251
287
|
input: {
|
|
252
|
-
...
|
|
253
|
-
...
|
|
254
|
-
...
|
|
288
|
+
...n == null ? void 0 : n.input,
|
|
289
|
+
...c && { type: "date" },
|
|
290
|
+
...d && !c && B === "input" ? { "aria-haspopup": "dialog", "aria-expanded": u } : {}
|
|
255
291
|
}
|
|
256
292
|
}
|
|
257
293
|
)
|
|
258
294
|
}
|
|
259
295
|
),
|
|
260
|
-
|
|
296
|
+
d && !c && /* @__PURE__ */ y(rt, { children: u && /* @__PURE__ */ y(it, { context: V, modal: !1, initialFocus: -1, children: /* @__PURE__ */ y(
|
|
261
297
|
"div",
|
|
262
298
|
{
|
|
263
|
-
ref:
|
|
299
|
+
ref: de.setFloating,
|
|
264
300
|
...ce.getFloatingProps({
|
|
265
301
|
style: {
|
|
266
|
-
position:
|
|
267
|
-
top:
|
|
268
|
-
left:
|
|
302
|
+
position: Ye,
|
|
303
|
+
top: Se ?? 0,
|
|
304
|
+
left: We ?? 0
|
|
269
305
|
}
|
|
270
306
|
}),
|
|
271
307
|
children: /* @__PURE__ */ y(
|
|
272
|
-
|
|
308
|
+
at,
|
|
273
309
|
{
|
|
274
|
-
...
|
|
275
|
-
numberOfMonths:
|
|
276
|
-
view:
|
|
277
|
-
selectionLevel:
|
|
278
|
-
currentMonth:
|
|
279
|
-
setCurrentMonth:
|
|
280
|
-
setView:
|
|
281
|
-
mode:
|
|
282
|
-
value:
|
|
283
|
-
locale:
|
|
284
|
-
localeCode:
|
|
285
|
-
showOutsideDays:
|
|
286
|
-
disabledMatchers:
|
|
287
|
-
required:
|
|
288
|
-
availableDays:
|
|
289
|
-
footer:
|
|
290
|
-
monthYearSelectType:
|
|
291
|
-
handleSelect:
|
|
292
|
-
applyValue:
|
|
310
|
+
...Ne,
|
|
311
|
+
numberOfMonths: we,
|
|
312
|
+
view: ve,
|
|
313
|
+
selectionLevel: E,
|
|
314
|
+
currentMonth: Be,
|
|
315
|
+
setCurrentMonth: q,
|
|
316
|
+
setView: oe,
|
|
317
|
+
mode: m,
|
|
318
|
+
value: s,
|
|
319
|
+
locale: _e,
|
|
320
|
+
localeCode: $,
|
|
321
|
+
showOutsideDays: be,
|
|
322
|
+
disabledMatchers: G,
|
|
323
|
+
required: T,
|
|
324
|
+
availableDays: Fe,
|
|
325
|
+
footer: Me,
|
|
326
|
+
monthYearSelectType: xe,
|
|
327
|
+
handleSelect: Ie,
|
|
328
|
+
applyValue: Te,
|
|
293
329
|
className: b["tedi-date-field__calendar"]
|
|
294
330
|
}
|
|
295
331
|
)
|
|
@@ -297,7 +333,7 @@ const gt = 4, de = 8, yt = X.forwardRef((v, C) => {
|
|
|
297
333
|
) }) })
|
|
298
334
|
] });
|
|
299
335
|
});
|
|
300
|
-
|
|
336
|
+
_t.displayName = "DateField";
|
|
301
337
|
export {
|
|
302
|
-
|
|
338
|
+
_t as DateField
|
|
303
339
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[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"),Fe=require("../../buttons/button/button.cjs.js"),vt=require("../../content/calendar/calendar.cjs.js"),y=require("../date-field/date-field-helpers.cjs.js"),xt=require("../textfield/textfield.cjs.js"),Te=require("../time-picker/time-picker.cjs.js"),a=require("./date-time-field.module.scss.cjs.js"),Nt=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),Dt=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),G=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),yt=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),jt=require("../../../providers/label-provider/use-labels.cjs.js"),Me=require("../../../helpers/hooks/use-breakpoint.cjs.js"),kt=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[U,b]=c.split(":"),R=Number(U),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,Ft=s=>s?`${s.getFullYear()}-${h(s.getMonth()+1)}-${h(s.getDate())}T${h(s.getHours())}:${h(s.getMinutes())}`:"",Tt=s=>{if(!s)return;const c=new Date(s);return isNaN(c.getTime())?void 0:c},Mt=s=>!s||ne(s)?{}:s,St=s=>ne(s)?s:void 0,le=n.forwardRef((s,c)=>{const{getCurrentBreakpointProps:U}=yt.useBreakpointProps(s.defaultServerBreakpoint),{getLabel:b}=jt.useLabels(),R=Me.useBreakpoint(s.defaultServerBreakpoint),P=Me.isBreakpointBelow(R,"md"),{layout:E="side-by-side",useNativePicker:Se=!1,monthYearSelectType:Ce="dropdown",timeGridVariant:we,showOutsideDays:Re=!0,availableTimes:v,timeHeading:z=b("dateTimeField.timeHeading")}=U(s),{id:Pe,label:Ee,placeholder:Ve,className:qe,value:de,defaultValue:Ae,onChange:W,required:oe,readOnly:Oe,disabled:V,minDate:ce,maxDate:ue,disablePast:me,disableFuture:fe,disabledMatchers:j,stepMinutes:he=15,initialMonth:Y,locale:$e=Nt.et,localeCode:k="et-EE",selectTimeLabel:Le=b("dateTimeField.selectTime"),backLabel:Be=b("dateTimeField.back"),mode:He="single",selectionLevel:Ie="days",inputProps:l,disabledDateErrorMessage:Ge=b("dateField.disabledDateError")}=s,d=He==="range",f=Se&&!d,F=d?"side-by-side":E,pe=we??(F==="multi-step"?"radio":"button"),ge=de!==void 0,[Ue,ze]=n.useState(Ae),x=ge?de:Ue,u=d?Mt(x):{},m=d?void 0:St(x),[N,J]=n.useState(!1),[We,K]=n.useState("date"),[Ye,_e]=n.useState("days"),Q=d?u.from:m,[Je,q]=n.useState(()=>Q??Y??new Date),be=n.useRef(Q);be.current=Q,n.useEffect(()=>{N||(K("date"),_e("days"),q(be.current??Y??new Date))},[N,Y]);const A=n.useMemo(()=>new Intl.DateTimeFormat(k,{day:"2-digit",month:"2-digit",year:"numeric"}),[k]),Ke=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]),Qe=n.useMemo(()=>{const e=y.getLocaleDateParts(A),{fieldOrder:t}=e,r=new RegExp(`^${y.buildDateRegexSource(e)}\\s+(\\d{2}):(\\d{2})$`);return gt=>{const I=gt.trim().match(r);if(!I)return;const ye={};t.forEach((_t,bt)=>{ye[_t]=Number(I[bt+1])});const je=Number(I[t.length+1]),ke=Number(I[t.length+2]),{day:ae,month:se,year:re}=ye;if(ae===void 0||se===void 0||re===void 0||je>23||ke>59)return;const C=new Date(re,se-1,ae,je,ke,0,0);if(!(isNaN(C.getTime())||C.getFullYear()!==re||C.getMonth()!==se-1||C.getDate()!==ae))return C}},[A]),[Xe,X]=n.useState(()=>$(x)),[ve,p]=n.useState(!1);n.useEffect(()=>{X($(x))},[x,$]);const Ze=D.useFloating({open:N,onOpenChange:J,placement:"bottom-end",middleware:[G.offset(y.CALENDAR_POPOVER_OFFSET),G.flip(),G.shift({padding:y.CALENDAR_POPOVER_PADDING}),G.size({padding:y.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){t.floating.style.maxWidth=`${e}px`}})],whileElementsMounted:Dt.autoUpdate}),{refs:Z,context:ee,x:et,y:tt,strategy:it}=Ze,at=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),st=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=>{ge||ze(e),W==null||W(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]),rt=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)},nt=e=>{if(d){o({from:_(e,M(e,g(u.from)))});return}o(_(e,M(e,g(m))))},lt=e=>{const t=m??new Date;o(_(t,e)),F==="multi-step"&&T(t)&&J(!1)},dt=e=>t=>{const r=u[e]??u.from??new Date;o({...u,[e]:_(r,t)})},B=n.useMemo(()=>[...y.buildDisabledMatchers({minDate:ce,maxDate:ue,disablePast:me,disableFuture:fe}),...j?Array.isArray(j)?j:[j]:[]],[ce,ue,me,fe,j]),xe=n.useCallback(e=>kt.dateMatchModifiers(e,B),[B]),ot=e=>{if(X(e),e===""){p(!1),o(void 0);return}if(f){const r=Tt(e);if(!r){p(!1);return}if(xe(r)){p(!0);return}p(!1),o(r),q(r);return}if(d)return;const t=Qe(e);if(!t){p(!1);return}if(xe(t)){p(!0);return}p(!1),o(t),q(t)},ct=()=>{var t;const e=(t=L.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function"){e.showPicker();return}e.focus()}},ut=()=>{if(!V){if(f){ct();return}J(e=>!e)}},mt=F==="multi-step"?i.jsx("div",{className:a.default["tedi-date-time-field__select-time-wrapper"],children:i.jsx(Fe.Button,{type:"button",visualType:"link",size:"small",iconLeft:"schedule",onClick:()=>K("time"),children:Le})}):void 0,te=i.jsx(vt.Calendar,{view:Ye,setView:_e,selectionLevel:Ie,currentMonth:Je,setCurrentMonth:q,mode:d?"range":"single",value:d?u:m,numberOfMonths:d&&!P?2:1,locale:$e,localeCode:k,showOutsideDays:Re,monthYearSelectType:Ce,disabledMatchers:B.length?B:void 0,required:oe,handleSelect:rt,applyValue:nt,footer:mt,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),ft=!ie||ie.length===0,Ne=i.jsx(Te.TimePicker,{value:g(m),stepMinutes:he,availableTimes:ie,gridVariant:pe,onChange:lt,className:w.default(a.default["tedi-date-time-field__time-picker"],{[a.default["tedi-date-time-field__time-picker--wheel"]]:ft})}),De=e=>{const t=T(u[e]),r=!t||t.length===0;return i.jsx(Te.TimePicker,{value:g(u[e]),stepMinutes:he,availableTimes:t,gridVariant:pe,onChange:dt(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,H=ve?{text:Ge,type:"error"}:null,ht=H?S?Array.isArray(S)?[...S,H]:[S,H]:H:S,pt={...l,id:Pe,label:Ee,value:f?Ft(m):Xe,placeholder:Ve,readOnly:Oe||!f&&!!v&&!!x,icon:"calendar_today",isClearable:!0,required:oe,disabled:V,invalid:ve||(l==null?void 0:l.invalid),helper:ht,onIconClick:ut,onChange:ot,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(xt.TextField,{ref:st,"aria-expanded":f?void 0:N,...pt})}),!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"],...at.getFloatingProps({style:{position:it,top:tt??0,left:et??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:z})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:De("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:z})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:De("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:z})}),i.jsx("div",{className:a.default["tedi-date-time-field__split-time-body"],children:Ne})]})]}):We==="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(Fe.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:Ke.format(m??new Date)})]}),i.jsx("div",{className:a.default["tedi-date-time-field__time-body"],children:Ne})]})})})})]})});le.displayName="DateTimeField";exports.DateTimeField=le;exports.default=le;
|