@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.
Files changed (58) hide show
  1. package/_virtual/index.cjs10.js +1 -1
  2. package/_virtual/index.cjs11.js +1 -1
  3. package/_virtual/index.cjs12.js +1 -1
  4. package/_virtual/index.cjs13.js +1 -1
  5. package/_virtual/index.cjs5.js +1 -1
  6. package/_virtual/index.cjs6.js +1 -1
  7. package/_virtual/index.cjs7.js +1 -1
  8. package/_virtual/index.cjs8.js +1 -1
  9. package/_virtual/index.cjs9.js +1 -1
  10. package/_virtual/index.es10.js +1 -1
  11. package/_virtual/index.es11.js +1 -1
  12. package/_virtual/index.es12.js +1 -1
  13. package/_virtual/index.es13.js +2 -4
  14. package/_virtual/index.es5.js +4 -2
  15. package/_virtual/index.es6.js +1 -1
  16. package/_virtual/index.es7.js +1 -1
  17. package/_virtual/index.es8.js +1 -1
  18. package/_virtual/index.es9.js +1 -1
  19. package/bundle-stats.html +1 -1
  20. package/external/@mui/system/colorManipulator.cjs.js +1 -1
  21. package/external/@mui/system/colorManipulator.es.js +2 -2
  22. package/external/@mui/system/createStyled.cjs.js +1 -1
  23. package/external/@mui/system/createStyled.es.js +6 -6
  24. package/external/@mui/system/useThemeWithoutDefault.cjs.js +1 -1
  25. package/external/@mui/system/useThemeWithoutDefault.es.js +1 -1
  26. package/external/toposort/index.cjs.js +1 -1
  27. package/external/toposort/index.es.js +1 -1
  28. package/index.css +1 -1
  29. package/package.json +1 -1
  30. package/src/community/components/form/pickers/calendar/calendar.d.ts +6 -0
  31. package/src/community/components/form/pickers/datepicker/datepicker.d.ts +6 -0
  32. package/src/community/components/form/pickers/datetimepicker/datetimepicker.d.ts +6 -0
  33. package/src/community/components/form/pickers/timepicker/timepicker.d.ts +6 -0
  34. package/src/tedi/components/content/calendar/calendar-grid.cjs.js +1 -1
  35. package/src/tedi/components/content/calendar/calendar-grid.es.js +7 -6
  36. package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.cjs.js +1 -1
  37. package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.es.js +99 -79
  38. package/src/tedi/components/form/date-field/date-field-helpers.cjs.js +1 -0
  39. package/src/tedi/components/form/date-field/date-field-helpers.d.ts +66 -0
  40. package/src/tedi/components/form/date-field/date-field-helpers.es.js +28 -0
  41. package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
  42. package/src/tedi/components/form/date-field/date-field.d.ts +22 -0
  43. package/src/tedi/components/form/date-field/date-field.es.js +248 -212
  44. package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -0
  45. package/src/tedi/components/form/date-time-field/date-time-field.d.ts +207 -0
  46. package/src/tedi/components/form/date-time-field/date-time-field.es.js +376 -0
  47. package/src/tedi/components/form/date-time-field/date-time-field.module.scss.cjs.js +1 -0
  48. package/src/tedi/components/form/date-time-field/date-time-field.module.scss.es.js +30 -0
  49. package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
  50. package/src/tedi/components/form/time-field/time-field.d.ts +9 -0
  51. package/src/tedi/components/form/time-field/time-field.es.js +81 -79
  52. package/src/tedi/components/overlays/dropdown/dropdown.es.js +0 -3
  53. package/src/tedi/index.d.ts +1 -0
  54. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  55. package/src/tedi/providers/label-provider/labels-map.d.ts +28 -0
  56. package/src/tedi/providers/label-provider/labels-map.es.js +93 -65
  57. package/tedi.cjs.js +1 -1
  58. 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 He, Fragment as Je, jsx as y } from "react/jsx-runtime";
2
- import { useFloating as Ke, useClick as Qe, useInteractions as Xe, useDismiss as Ze, useRole as et, FloatingPortal as tt, FloatingFocusManager as rt } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
3
- import Q from "../../../../../external/classnames/index.es.js";
4
- import X, { useState as w, useCallback as Z, useEffect as A, useMemo as ee } from "react";
5
- import { Calendar as it } from "../../content/calendar/calendar.es.js";
6
- import { MultiValueField as at } from "../multi-value-field/multi-value-field.es.js";
7
- import { TextField as nt } from "../textfield/textfield.es.js";
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 { et as ot } from "../../../../../external/react-day-picker/dist/esm/locale/et.es.js";
10
- import { autoUpdate as st } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
11
- import { offset as lt, flip as ft, shift as ct, size as dt } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
12
- import { useBreakpointProps as ut } from "../../../helpers/hooks/use-breakpoint-props.es.js";
13
- import { useBreakpoint as mt, isBreakpointBelow as pt } from "../../../helpers/hooks/use-breakpoint.es.js";
14
- import { dateMatchModifiers as ht } from "../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.es.js";
15
- const gt = 4, de = 8, yt = X.forwardRef((v, C) => {
16
- const { getCurrentBreakpointProps: ue } = ut(v.defaultServerBreakpoint), {
17
- useNativePicker: me = !1,
18
- enableCalendar: f = !0,
19
- calendarTrigger: I = "button",
20
- numberOfMonths: $
21
- } = ue(v), {
22
- id: te,
23
- mode: c = "single",
24
- label: re,
25
- selected: F,
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: N,
28
- placeholder: pe,
29
- className: he,
30
- formatDate: l,
31
- required: V,
32
- showOutsideDays: ge = !0,
33
- parseDate: ye,
34
- monthYearSelectType: be,
35
- selectionLevel: P = "days",
36
- locale: De = ot,
37
- localeCode: E = "et-EE",
38
- initialMonth: j,
39
- closeOnSelect: xe,
40
- footer: _e,
41
- defaultValue: O,
42
- minDate: W,
43
- maxDate: S,
44
- disablePast: ie,
45
- disableFuture: ae,
46
- shouldDisableMonth: Y,
47
- shouldDisableYear: L,
48
- readOnly: U,
49
- availableDays: Ce,
50
- inputProps: m,
51
- useNativePicker: bt,
52
- enableCalendar: Dt,
53
- calendarTrigger: xt,
54
- numberOfMonths: _t,
55
- defaultServerBreakpoint: Ct,
56
- sm: Ft,
57
- md: Nt,
58
- lg: kt,
59
- xl: Mt,
60
- xxl: wt,
61
- ...Fe
62
- } = v, d = me && c === "single", Ne = mt(v.defaultServerBreakpoint), ke = pt(Ne, "md") && typeof $ == "number" && $ > 1 ? 1 : $, [Me, h] = w(F ?? O), [u, D] = w(!1), [we, ne] = w(P), [Ae, x] = w(""), n = F !== void 0, o = n ? F : Me, oe = X.useRef(null), ve = X.useCallback(
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
- oe.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
68
+ le.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
65
69
  },
66
70
  [C]
67
- ), Pe = (e) => {
71
+ ), Re = (e) => {
68
72
  if (!e) return "";
69
- const r = e.getFullYear(), t = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
70
- return `${r}-${t}-${a}`;
71
- }, Oe = d && o instanceof Date ? Pe(o) : "", q = Z((e, r) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [...e].sort((t, a) => t.getTime() - a.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 : r ?? /* @__PURE__ */ new Date(), []), [Re, z] = w(() => q(o, j));
72
- A(() => {
73
- u || z(q(o, j));
74
- }, [o, j, u, q]), A(() => {
75
- u && ne(P);
76
- }, [u, P]), A(() => {
77
- n && h(F);
78
- }, [F, n]);
79
- const g = ee(
80
- () => new Intl.DateTimeFormat(E, {
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
- [E]
86
- ), _ = Z(
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((r) => g.format(r)).join(", ");
94
+ if (Array.isArray(e)) return e.map((t) => g.format(t)).join(", ");
91
95
  if (e.from) {
92
- const r = g.format(e.from);
93
- return e.to ? `${r} – ${g.format(e.to)}` : r;
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
- ), G = xe ?? c === "single", se = c === "multiple" && Array.isArray(o) ? o.map((e, r) => ({
99
- id: r,
100
- label: l ? l(e) : _(e),
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
- })) : [], H = ee(() => {
106
+ })) : [], G = te(() => {
103
107
  const e = [];
104
- return N && (Array.isArray(N) ? e.push(...N) : e.push(N)), W && e.push({ before: W }), S && e.push({ after: S }), ie && e.push({ before: /* @__PURE__ */ new Date() }), ae && e.push({ after: /* @__PURE__ */ new Date() }), Y && e.push((r) => Y(r)), L && e.push((r) => L(r)), e;
105
- }, [N, W, S, ie, ae, Y, L]), le = Z(
106
- (e) => ht(e, H),
107
- [H]
108
- ), Te = (e, r, t, a) => {
109
- if (n || h(e), i == null || i(e, r, t, a), e) {
110
- const p = l ? l(e) : _(e);
111
- x(p);
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
- G && D(!1);
115
- }, Be = (e) => {
116
- if (le(e)) return;
117
- n || h(e), i == null || i(e, e, {}, {});
118
- const r = l ? l(e) : _(e);
119
- x(r), G && D(!1);
120
- }, Ie = ee(() => {
121
- const e = new Date(2099, 11, 31), r = g.formatToParts(e), t = [], a = [];
122
- for (const s of r)
123
- s.type === "day" || s.type === "month" || s.type === "year" ? t.push(s.type) : s.type === "literal" && t.length > 0 && a.length < 2 && a.push(s.value);
124
- const p = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ue = t.map((s, k) => {
125
- const T = s === "year" ? "\\d{4}" : "\\d{2}";
126
- return `${k > 0 ? p(a[k - 1] ?? "") : ""}(${T})`;
127
- }).join(""), qe = new RegExp(`^${Ue}$`);
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: B, month: J, year: K } = T;
136
- if (B === void 0 || J === void 0 || K === void 0) return;
137
- const M = new Date(K, J - 1, B);
138
- if (!(isNaN(M.getTime()) || M.getFullYear() !== K || M.getMonth() !== J - 1 || M.getDate() !== B))
139
- return M;
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]), $e = (e) => {
142
- x(e);
143
- const t = (ye ?? (c === "single" ? Ie : () => {
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
- (c === "single" && t instanceof Date || c === "multiple" && Array.isArray(t) || c === "range" && t && !Array.isArray(t) && "from" in t) && (t instanceof Date && le(t) || (n || h(t), i == null || i(t, t, {}, {}), t instanceof Date && z(t), G && D(!1)));
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
- A(() => {
148
- if (n) {
149
- const e = l ? l(o) : _(o);
166
+ v(() => {
167
+ if (o) {
168
+ const e = f ? f(s) : _(s);
150
169
  x(e);
151
170
  }
152
- }, [o, n, l, _]), A(() => {
153
- if (!n && O) {
154
- const e = l ? l(O) : _(O);
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 Ve = Ke({
177
+ const je = Qe({
159
178
  open: u,
160
179
  onOpenChange: D,
161
- placement: I === "input" ? "bottom-start" : "bottom-end",
180
+ placement: B === "input" ? "bottom-start" : "bottom-end",
162
181
  middleware: [
163
- lt(gt),
164
- ft(),
165
- ct({ padding: de }),
166
- dt({
167
- padding: de,
168
- apply({ availableWidth: e, elements: r }) {
169
- const t = r.floating;
170
- t.style.width = "max-content", t.style.maxWidth = "", t.getBoundingClientRect().width > e ? (t.style.width = "min-content", t.style.maxWidth = `${e}px`) : (t.style.width = "", t.style.maxWidth = "");
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: st
175
- }), { refs: fe, context: R, x: Ee, y: je, strategy: We } = Ve, Se = Qe(R), ce = Xe([
176
- ...f && !d && I === "input" ? [Se] : [],
177
- Ze(R),
178
- et(R, { role: "dialog" })
179
- ]), Ye = () => {
180
- var r;
181
- const e = (r = oe.current) == null ? void 0 : r.input;
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
- }, Le = (e) => {
215
+ }, qe = (e) => {
192
216
  if (!e) {
193
- n || h(void 0), i == null || i(void 0, void 0, {}, {});
217
+ h(!1), o || p(void 0), i == null || i(void 0, void 0, {}, {});
194
218
  return;
195
219
  }
196
- const [r, t, a] = e.split("-").map(Number);
197
- if (!r || !t || !a) return;
198
- const p = new Date(r, t - 1, a);
199
- Number.isNaN(p.getTime()) || (n || h(p), i == null || i(p, p, {}, {}));
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__ */ He(Je, { children: [
231
+ return /* @__PURE__ */ Je(Ke, { children: [
202
232
  /* @__PURE__ */ y(
203
233
  "div",
204
234
  {
205
- className: Q(b["tedi-date-field__container"], he),
235
+ className: X(b["tedi-date-field__container"], ye),
206
236
  ...ce.getReferenceProps(),
207
- ref: fe.setReference,
208
- children: c === "multiple" ? /* @__PURE__ */ y(
209
- at,
237
+ ref: de.setReference,
238
+ children: m === "multiple" ? /* @__PURE__ */ y(
239
+ nt,
210
240
  {
211
- ...m,
212
- id: te,
213
- label: re,
214
- values: se.map((e) => e.label),
241
+ ...n,
242
+ id: re,
243
+ label: ie,
244
+ values: fe.map((e) => e.label),
215
245
  icon: "calendar_today",
216
- onIconClick: () => f && D((e) => !e),
217
- iconButtonProps: f ? { "aria-expanded": u, "aria-haspopup": "dialog" } : void 0,
246
+ onIconClick: () => d && D((e) => !e),
247
+ iconButtonProps: d ? { "aria-expanded": u, "aria-haspopup": "dialog" } : void 0,
218
248
  isClearable: !0,
219
- required: V,
249
+ required: T,
220
250
  onChange: (e) => {
221
- if (!Array.isArray(o)) return;
222
- const r = se.filter((t) => e.includes(t.label)).map((t) => t.date);
223
- n || h(r), i == null || i(r, {}, {}, {});
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: Q(b["tedi-date-field__textfield"], {
226
- [b["tedi-date-field__icon--disabled"]]: !f || U
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
- nt,
260
+ ot,
231
261
  {
232
- ...m,
233
- ref: ve,
234
- id: te,
235
- label: re,
236
- readOnly: U,
237
- value: d ? Oe : Ae,
238
- placeholder: pe,
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
- f && (d ? Ye() : D((e) => !e));
273
+ d && (c ? Ue() : D((e) => !e));
243
274
  },
244
- iconButtonProps: f && !d ? { "aria-expanded": u, "aria-haspopup": "dialog" } : void 0,
245
- onChange: (e) => d ? Le(e) : $e(e),
246
- required: V,
247
- className: Q(b["tedi-date-field__textfield"], {
248
- [b["tedi-date-field__textfield--disabled"]]: m == null ? void 0 : m.disabled,
249
- [b["tedi-date-field__icon--disabled"]]: !f || U
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
- ...m == null ? void 0 : m.input,
253
- ...d && { type: "date" },
254
- ...f && !d && I === "input" ? { "aria-haspopup": "dialog", "aria-expanded": u } : {}
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
- f && !d && /* @__PURE__ */ y(tt, { children: u && /* @__PURE__ */ y(rt, { context: R, modal: !1, initialFocus: -1, children: /* @__PURE__ */ y(
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: fe.setFloating,
299
+ ref: de.setFloating,
264
300
  ...ce.getFloatingProps({
265
301
  style: {
266
- position: We,
267
- top: je ?? 0,
268
- left: Ee ?? 0
302
+ position: Ye,
303
+ top: Se ?? 0,
304
+ left: We ?? 0
269
305
  }
270
306
  }),
271
307
  children: /* @__PURE__ */ y(
272
- it,
308
+ at,
273
309
  {
274
- ...Fe,
275
- numberOfMonths: ke,
276
- view: we,
277
- selectionLevel: P,
278
- currentMonth: Re,
279
- setCurrentMonth: z,
280
- setView: ne,
281
- mode: c,
282
- value: o,
283
- locale: De,
284
- localeCode: E,
285
- showOutsideDays: ge,
286
- disabledMatchers: H,
287
- required: V,
288
- availableDays: Ce,
289
- footer: _e,
290
- monthYearSelectType: be,
291
- handleSelect: Te,
292
- applyValue: Be,
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
- yt.displayName = "DateField";
336
+ _t.displayName = "DateField";
301
337
  export {
302
- yt as DateField
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;