asma-ui-core 3.106.0 → 3.107.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.
@@ -1,47 +1,53 @@
1
- import { cn as c } from "../../../../helpers/cn.js";
2
- import { firstTabbable as I } from "../../../../helpers/focusable.js";
3
- import { StyledTooltip as G } from "../../../data-display/tooltip/StyledTooltip.js";
4
- import { DialogBusyContext as j, useDialogBusyBoundary as J } from "../../dialog/DialogBusyContext.js";
5
- import { useMobileMediaQuery as K } from "../../../../hooks/useMediaQuery.hook.js";
6
- import { useFocusTrap as X } from "../../../../hooks/useFocusTrap.hook.js";
7
- import { CloseBtn as D } from "../components/CloseBtn.js";
8
- import { MinimizeBtn as P } from "../components/MinimizeBtn.js";
9
- import { FullScreenBtn as Y } from "../components/FullscreenBtn.js";
10
- import p from "./MinimizableDialogV2.module.js";
11
- import { useTranslations as Z } from "./useTranslations.js";
12
- import { useControlledProps as ee } from "./useControlledProps.js";
13
- import te from "clsx";
14
- import { useLayoutEffect as A, useRef as u } from "react";
15
- import { Fragment as ie, jsx as e, jsxs as o } from "react/jsx-runtime";
16
- var ge = (y) => {
17
- const { showCloseIcon: z = !0, showMinimizeIcon: O = !0, showExpandIcon: V = !0, enableFullscreen: q = !0, title: r, label: x, children: E, open: d, onClose: W, classNameOverrides: v = {
1
+ import { cn as s } from "../../../../helpers/cn.js";
2
+ import { firstTabbable as A } from "../../../../helpers/focusable.js";
3
+ import { StyledTooltip as te } from "../../../data-display/tooltip/StyledTooltip.js";
4
+ import { DialogBusyContext as $, useDialogBusyBoundary as ie } from "../../dialog/DialogBusyContext.js";
5
+ import { useMobileMediaQuery as le } from "../../../../hooks/useMediaQuery.hook.js";
6
+ import { useFocusTrap as ne } from "../../../../hooks/useFocusTrap.hook.js";
7
+ import { CloseBtn as O } from "../components/CloseBtn.js";
8
+ import { MinimizeBtn as V } from "../components/MinimizeBtn.js";
9
+ import { FullScreenBtn as oe } from "../components/FullscreenBtn.js";
10
+ import v from "./MinimizableDialogV2.module.js";
11
+ import { useTranslations as re } from "./useTranslations.js";
12
+ import { useControlledProps as se } from "./useControlledProps.js";
13
+ import ce from "clsx";
14
+ import { useId as q, useLayoutEffect as H, useRef as c } from "react";
15
+ import { Fragment as ae, jsx as e, jsxs as n } from "react/jsx-runtime";
16
+ var Se = (N) => {
17
+ const { showCloseIcon: R = !0, showMinimizeIcon: L = !0, showExpandIcon: W = !0, enableFullscreen: _ = !0, title: u, label: f, children: Q, open: o, onClose: U, classNameOverrides: h = {
18
18
  maximized: "",
19
19
  minimized: "",
20
20
  fullscreen: ""
21
- }, dataTest: _, actionNode: $, locale: H = "en", busyReason: L, style: w, initialFocusRef: N } = y, s = K(), i = Z(H), m = u(null), f = u(null), R = u(null), C = u(null), S = u(!1), { minimized: t, setMinimized: F, fullScreen: l, setFullScreen: T } = ee(y), n = l && !t, { busy: h, busyReason: B, contextValue: M } = J(L ?? i.waitUntilSaved), b = () => {
22
- h || (F(!1), W());
21
+ }, dataTest: G, actionNode: J, locale: K = "en", busyReason: X, style: C, initialFocusRef: S } = N, r = le(), i = re(K), a = c(null), p = c(null), F = c(null), T = c(null), b = c(!1), g = c(null), x = q(), I = q(), { minimized: t, setMinimized: M, fullScreen: l, setFullScreen: B } = se(N), d = l && !t, { busy: y, busyReason: E, contextValue: j } = ie(X ?? i.waitUntilSaved), z = () => {
22
+ y || (M(!1), U());
23
23
  };
24
- A(() => {
25
- m.current?.toggleAttribute("inert", t), f.current?.toggleAttribute("inert", !t);
26
- }, [t]), A(() => {
27
- const g = d && !S.current;
28
- if (S.current = d, !g) return;
29
- const a = t ? f.current : m.current, U = t ? C.current : R.current;
30
- (N?.current ?? U ?? (a ? I(a) : void 0))?.focus({ preventScroll: !0 });
24
+ H(() => {
25
+ a.current?.toggleAttribute("inert", t), p.current?.toggleAttribute("inert", !t);
26
+ }, [t]), H(() => {
27
+ const w = o && !b.current, m = !o && b.current;
28
+ if (b.current = o, m) {
29
+ const P = g.current;
30
+ g.current = null, (!document.activeElement || document.activeElement === document.body) && P?.isConnected && P.focus({ preventScroll: !0 });
31
+ return;
32
+ }
33
+ if (!w) return;
34
+ g.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
35
+ const D = t ? p.current : a.current, ee = t ? T.current : F.current;
36
+ (S?.current ?? ee ?? (D ? A(D) : void 0))?.focus({ preventScroll: !0 });
31
37
  }, [
32
- N,
38
+ S,
33
39
  t,
34
- d
40
+ o
35
41
  ]);
36
42
  const k = () => {
37
- const g = t ? m : f;
38
- F(!t), requestAnimationFrame(() => {
39
- const a = g.current;
40
- a && (a.querySelector('[data-testid="toggle-minimize-btn"]') ?? I(a))?.focus({ preventScroll: !0 });
43
+ const w = t ? a : p;
44
+ M(!t), requestAnimationFrame(() => {
45
+ const m = w.current;
46
+ m && (m.querySelector('[data-testid="toggle-minimize-btn"]') ?? A(m))?.focus({ preventScroll: !0 });
41
47
  });
42
48
  };
43
- X(d && n, m, b);
44
- const Q = n ? s ? {
49
+ ne(o && d, a, z);
50
+ const Y = d ? r ? {
45
51
  inset: 0,
46
52
  maxHeight: "100dvh",
47
53
  maxWidth: "100dvw",
@@ -58,115 +64,120 @@ var ge = (y) => {
58
64
  maxWidth: "min(1000px, calc(100vw - 32px))",
59
65
  height: "95dvh"
60
66
  } : void 0;
61
- return d ? /* @__PURE__ */ o(ie, { children: [
67
+ if (!o) return null;
68
+ const Z = f ? `${I} ${x}` : x;
69
+ return /* @__PURE__ */ n(ae, { children: [
62
70
  /* @__PURE__ */ e("div", {
63
- ref: f,
71
+ ref: p,
64
72
  style: {
65
73
  zIndex: 51,
66
- ...w
74
+ ...C
67
75
  },
68
- className: c(p["minimized-dialog"], !t && p.hidden, v.minimized),
69
- children: /* @__PURE__ */ o("div", {
70
- className: te("flex items-center justify-between", !t && "hidden"),
71
- "data-testid": _,
76
+ className: s(v["minimized-dialog"], !t && v.hidden, h.minimized),
77
+ children: /* @__PURE__ */ n("div", {
78
+ className: ce("flex items-center justify-between", !t && "hidden"),
79
+ "data-testid": G,
72
80
  children: [/* @__PURE__ */ e("div", {
73
81
  className: "max-w-[303px] truncate pr-1 text-lg font-semibold text-delta-800",
74
- children: /* @__PURE__ */ e(G, {
75
- title: r,
82
+ children: /* @__PURE__ */ e(te, {
83
+ title: u,
76
84
  placement: "top",
77
85
  children: /* @__PURE__ */ e("div", {
78
86
  className: "truncate",
79
- children: r
87
+ children: u
80
88
  })
81
89
  })
82
- }), /* @__PURE__ */ o("div", {
90
+ }), /* @__PURE__ */ n("div", {
83
91
  className: "flex items-center gap-x-1",
84
- children: [/* @__PURE__ */ e(P, {
92
+ children: [/* @__PURE__ */ e(V, {
85
93
  type: "expand",
86
- visibility: V,
94
+ visibility: W,
87
95
  onClick: k,
88
96
  tooltipTitle: i.expand
89
- }), /* @__PURE__ */ e(D, {
90
- buttonRef: C,
91
- showCloseIcon: z,
92
- onClick: b,
93
- disabledReason: h ? B : void 0,
97
+ }), /* @__PURE__ */ e(O, {
98
+ buttonRef: T,
99
+ showCloseIcon: R,
100
+ onClick: z,
101
+ disabledReason: y ? E : void 0,
94
102
  tooltipTitle: i.close
95
103
  })]
96
104
  })]
97
105
  })
98
106
  }),
99
- n && /* @__PURE__ */ e("div", {
107
+ d && /* @__PURE__ */ e("div", {
100
108
  className: "fixed inset-0 z-[52] bg-[rgb(98,110,126)] bg-opacity-70",
101
109
  onClick: () => {
102
- T(!1);
110
+ B(!1);
103
111
  }
104
112
  }),
105
- /* @__PURE__ */ o("div", {
113
+ /* @__PURE__ */ n("div", {
106
114
  style: {
107
115
  zIndex: 51,
108
- ...w,
109
- ...Q
116
+ ...C,
117
+ ...Y
110
118
  },
111
- ref: m,
112
- role: n ? "dialog" : void 0,
113
- "aria-modal": n ? !0 : void 0,
114
- "aria-label": n && typeof r == "string" ? r : void 0,
115
- className: c(p.dialog, t && p.hidden, !l && v.maximized, l && v.fullscreen, n && "fixed z-[53] duration-0"),
116
- children: [/* @__PURE__ */ o("div", {
117
- className: c("flex flex-col border-b-[1px] border-delta-200 px-4", s ? "py-3" : "py-4"),
118
- children: [/* @__PURE__ */ o("div", {
119
+ ref: a,
120
+ role: "dialog",
121
+ "aria-modal": d ? !0 : void 0,
122
+ "aria-labelledby": Z,
123
+ className: s(v.dialog, t && v.hidden, !l && h.maximized, l && h.fullscreen, d && "fixed z-[53] duration-0"),
124
+ children: [/* @__PURE__ */ n("div", {
125
+ className: s("flex flex-col border-b-[1px] border-delta-200 px-4", r ? "py-3" : "py-4"),
126
+ children: [/* @__PURE__ */ n("div", {
119
127
  className: "flex items-center justify-between",
120
- children: [x ? /* @__PURE__ */ e("div", {
128
+ children: [f ? /* @__PURE__ */ e("div", {
129
+ id: I,
121
130
  className: "text-sm text-delta-700",
122
- children: x
131
+ children: f
123
132
  }) : /* @__PURE__ */ e("div", {
124
- className: c("font-semibold text-delta-800", s ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
125
- children: r
126
- }), /* @__PURE__ */ o("div", {
133
+ id: x,
134
+ className: s("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
135
+ children: u
136
+ }), /* @__PURE__ */ n("div", {
127
137
  className: "flex items-center gap-x-1",
128
138
  children: [
129
- /* @__PURE__ */ e(j.Provider, {
130
- value: M,
131
- children: $
139
+ /* @__PURE__ */ e($.Provider, {
140
+ value: j,
141
+ children: J
132
142
  }),
133
- /* @__PURE__ */ e(P, {
134
- visibility: O && !s && !l,
143
+ /* @__PURE__ */ e(V, {
144
+ visibility: L && !r && !l,
135
145
  type: "minimize",
136
146
  onClick: k,
137
147
  tooltipTitle: i.minimize
138
148
  }),
139
- /* @__PURE__ */ e(Y, {
140
- showFullScreenIcon: q && !s,
149
+ /* @__PURE__ */ e(oe, {
150
+ showFullScreenIcon: _ && !r,
141
151
  fullScreen: l,
142
152
  onClick: () => {
143
- T(!l);
153
+ B(!l);
144
154
  },
145
155
  tooltipTitle: l ? i.exitFullscreen : i.fullscreen
146
156
  }),
147
- /* @__PURE__ */ e(D, {
148
- buttonRef: R,
149
- showCloseIcon: z,
150
- onClick: b,
151
- disabledReason: h ? B : void 0,
157
+ /* @__PURE__ */ e(O, {
158
+ buttonRef: F,
159
+ showCloseIcon: R,
160
+ onClick: z,
161
+ disabledReason: y ? E : void 0,
152
162
  tooltipTitle: i.close
153
163
  })
154
164
  ]
155
165
  })]
156
- }), x && /* @__PURE__ */ e("div", {
157
- className: c("font-semibold text-delta-800", s ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
158
- children: r
166
+ }), f && /* @__PURE__ */ e("div", {
167
+ id: x,
168
+ className: s("font-semibold text-delta-800", r ? "line-clamp-2 text-xl" : "line-clamp-1 text-2xl"),
169
+ children: u
159
170
  })]
160
171
  }), /* @__PURE__ */ e("div", {
161
- className: c(t && "hidden", "flex flex-grow flex-col overflow-y-auto overscroll-contain"),
162
- children: /* @__PURE__ */ e(j.Provider, {
163
- value: M,
164
- children: E
172
+ className: s(t && "hidden", "flex flex-grow flex-col overflow-y-auto overscroll-contain"),
173
+ children: /* @__PURE__ */ e($.Provider, {
174
+ value: j,
175
+ children: Q
165
176
  })
166
177
  })]
167
178
  })
168
- ] }) : null;
179
+ ] });
169
180
  };
170
181
  export {
171
- ge as MinimizableDialogV2
182
+ Se as MinimizableDialogV2
172
183
  };
@@ -1,29 +1,30 @@
1
- import { StyledInputField as G } from "../../../../components/inputs/input-field/StyledInputField.js";
2
- import { getValue as f } from "../helpers.js";
3
- import { DatePickerButton as J } from "./DatePickerButton.js";
4
- import { DATE_INPUT_FONT_FAMILY as K } from "../../../../helpers/inputMask.js";
5
- import { useDatePickerMask as Q } from "../hooks/useDatePickerMask.js";
6
- import { defaultDatePickerValidationMessages as X, useDatePickerValidation as Z } from "../hooks/useDatePickerValidation.js";
7
- import { useEffect as b, useState as k } from "react";
8
- import { jsx as m, jsxs as N } from "react/jsx-runtime";
9
- import { isValid as $, parse as ee } from "date-fns";
10
- var ce = (V) => {
11
- const { onClick: F, inputClassName: w, dateFormat: r, selected: e, error: I, helperText: H, errorText: Y, onInputChange: h, hideCalendar: B, locale: o, disabledDays: l, label: E, title: v, readOnly: t, disallowPast: i, disallowFuture: s, validateOnCalendarClose: D, onValidatedOnce: g, hideDefaultHelperText: O, required: d, minDate: n, ...u } = V, { validationError: A, handleValidation: c, errHelperText: R, clearValidation: x } = Z(X), { maskRef: S } = Q(), [a, y] = k(e ? f(e, r) : ""), [C, _] = k({
1
+ import { StyledInputField as K } from "../../../../components/inputs/input-field/StyledInputField.js";
2
+ import { getValue as h } from "../helpers.js";
3
+ import { DatePickerButton as Q } from "./DatePickerButton.js";
4
+ import { getTitleLabelling as X } from "../../../helpers/getTitleLabelling.js";
5
+ import { DATE_INPUT_FONT_FAMILY as Z } from "../../../../helpers/inputMask.js";
6
+ import { useDatePickerMask as $ } from "../hooks/useDatePickerMask.js";
7
+ import { defaultDatePickerValidationMessages as ee, useDatePickerValidation as te } from "../hooks/useDatePickerValidation.js";
8
+ import { useEffect as I, useId as ae, useState as N } from "react";
9
+ import { jsx as p, jsxs as V } from "react/jsx-runtime";
10
+ import { isValid as re, parse as oe } from "date-fns";
11
+ var he = (F) => {
12
+ const { onClick: w, inputClassName: H, dateFormat: r, selected: e, error: Y, helperText: A, errorText: B, onInputChange: v, hideCalendar: E, locale: o, disabledDays: l, label: g, title: u, inputAriaProps: O, readOnly: t, disallowPast: i, disallowFuture: s, validateOnCalendarClose: D, onValidatedOnce: x, hideDefaultHelperText: L, required: d, minDate: n, ...f } = F, { validationError: R, handleValidation: c, errHelperText: S, clearValidation: y } = te(ee), { maskRef: _ } = $(), T = ae(), [a, C] = N(e ? h(e, r) : ""), [P, j] = N({
12
13
  selected: e,
13
14
  dateFormat: r
14
15
  });
15
- (e !== C.selected || r !== C.dateFormat) && (_({
16
+ (e !== P.selected || r !== P.dateFormat) && (j({
16
17
  selected: e,
17
18
  dateFormat: r
18
- }), y(e ? f(e, r) : ""));
19
- const j = o?.code?.startsWith("nb") ? "DD/MM/ÅÅÅÅ" : "DD/MM/YYYY", L = O ? void 0 : j, T = !!(A || I), q = T ? Y ?? R : H ?? L;
20
- b(() => {
19
+ }), C(e ? h(e, r) : ""));
20
+ const q = o?.code?.startsWith("nb") ? "DD/MM/ÅÅÅÅ" : "DD/MM/YYYY", z = L ? void 0 : q, M = !!(R || Y), U = M ? B ?? S : A ?? z;
21
+ I(() => {
21
22
  if (!e) {
22
- x();
23
+ y();
23
24
  return;
24
25
  }
25
26
  c({
26
- value: f(e, r),
27
+ value: h(e, r),
27
28
  disabledDays: l,
28
29
  localeCode: o?.code,
29
30
  disallowPast: i,
@@ -41,13 +42,13 @@ var ce = (V) => {
41
42
  d,
42
43
  n,
43
44
  c,
44
- x
45
+ y
45
46
  ]);
46
- const z = /\d/.test(a), U = (p) => {
47
- const P = p.target.value;
48
- y(P.replace(/\D/g, "").length ? P : "");
47
+ const W = /\d/.test(a), G = (m) => {
48
+ const k = m.target.value;
49
+ C(k.replace(/\D/g, "").length ? k : "");
49
50
  };
50
- b(() => {
51
+ I(() => {
51
52
  D && (c({
52
53
  value: a,
53
54
  disabledDays: l,
@@ -56,7 +57,7 @@ var ce = (V) => {
56
57
  disallowFuture: s,
57
58
  required: d,
58
59
  minDate: n
59
- }), g?.());
60
+ }), x?.());
60
61
  }, [
61
62
  D,
62
63
  a,
@@ -66,10 +67,10 @@ var ce = (V) => {
66
67
  s,
67
68
  d,
68
69
  n,
69
- g,
70
+ x,
70
71
  c
71
72
  ]);
72
- const W = () => {
73
+ const J = () => {
73
74
  if (c({
74
75
  value: a,
75
76
  disabledDays: l,
@@ -80,61 +81,70 @@ var ce = (V) => {
80
81
  minDate: n
81
82
  })) return;
82
83
  if (!a.replace(/\D/g, "").length) {
83
- h?.(void 0);
84
+ v?.(void 0);
84
85
  return;
85
86
  }
86
- const p = ee(a, "dd/MM/yyyy", /* @__PURE__ */ new Date());
87
- h?.($(p) ? p : void 0);
88
- }, M = t ? 120 : 156;
89
- return /* @__PURE__ */ N("div", {
87
+ const m = oe(a, "dd/MM/yyyy", /* @__PURE__ */ new Date());
88
+ v?.(re(m) ? m : void 0);
89
+ }, b = t ? 120 : 156;
90
+ return /* @__PURE__ */ V("div", {
90
91
  className: "cursor-default",
91
- children: [v && /* @__PURE__ */ m("div", {
92
+ children: [u && /* @__PURE__ */ p("div", {
93
+ id: T,
92
94
  className: "pb-1 font-roboto font-semibold text-delta-800",
93
- children: v
94
- }), /* @__PURE__ */ N("div", {
95
+ children: u
96
+ }), /* @__PURE__ */ V("div", {
95
97
  className: "flex gap-1",
96
98
  style: { height: t ? 40 : 75 },
97
- children: [/* @__PURE__ */ m("div", {
98
- style: { width: M },
99
- children: /* @__PURE__ */ m("div", {
99
+ children: [/* @__PURE__ */ p("div", {
100
+ style: { width: b },
101
+ children: /* @__PURE__ */ p("div", {
100
102
  className: "relative",
101
- children: /* @__PURE__ */ m(G, {
102
- ...u,
103
- label: E,
103
+ children: /* @__PURE__ */ p(K, {
104
+ ...f,
105
+ label: g,
104
106
  readOnly: t,
105
- "data-testid": u.dataTest,
107
+ "data-testid": f.dataTest,
106
108
  autoComplete: "off",
107
- inputRef: t ? void 0 : S,
108
- placeholder: !t && !z ? " / / " : void 0,
109
+ inputRef: t ? void 0 : _,
110
+ placeholder: !t && !W ? " / / " : void 0,
109
111
  size: "small",
110
112
  value: t ? a.replaceAll("/", ".") : a,
111
- className: w,
112
- style: { width: M },
113
- error: T,
114
- onBlur: t ? void 0 : W,
115
- helperText: q,
113
+ className: H,
114
+ style: { width: b },
115
+ error: M,
116
+ onBlur: t ? void 0 : J,
117
+ helperText: U,
116
118
  slotProps: {
117
119
  formHelperText: { sx: {
118
120
  marginTop: "4px",
119
121
  marginLeft: 0,
120
122
  marginRight: 0
121
123
  } },
122
- htmlInput: { ...t ? {} : {
123
- inputMode: "numeric",
124
- style: { fontFamily: K }
125
- } }
124
+ htmlInput: {
125
+ ...X({
126
+ title: u,
127
+ titleId: T,
128
+ label: g,
129
+ inputAriaProps: O
130
+ }),
131
+ ...t ? {} : {
132
+ inputMode: "numeric",
133
+ style: { fontFamily: Z }
134
+ }
135
+ }
126
136
  },
127
- onChange: U
137
+ onChange: G
128
138
  })
129
139
  })
130
- }), !B && !t && /* @__PURE__ */ m(J, {
131
- onClick: F,
132
- disabled: !!u.disabled,
140
+ }), !E && !t && /* @__PURE__ */ p(Q, {
141
+ onClick: w,
142
+ disabled: !!f.disabled,
133
143
  localeCode: o?.code
134
144
  })]
135
145
  })]
136
146
  });
137
147
  };
138
148
  export {
139
- ce as BaseDatePickerInput
149
+ he as BaseDatePickerInput
140
150
  };
@@ -1,18 +1,18 @@
1
- import { BaseDatePickerInput as k } from "./BaseDatePickerInput.js";
2
- import { jsx as v } from "react/jsx-runtime";
3
- var F = ({ datePickerProps: e, onClick: a }) => {
4
- const { inputClassName: r, disabled: t, helperText: l, label: d, error: n, locale: i, hideCalendar: o, dateFormat: s, disabledDays: p, dataTest: u, readOnly: m, errorText: c, disallowFuture: C, disallowPast: h, required: x, minDate: D, validateOnCalendarClose: b, onValidatedOnce: I, onInputChange: T, selected: f, title: g, hideDefaultHelperText: O } = e;
5
- return /* @__PURE__ */ v(k, {
1
+ import { BaseDatePickerInput as v } from "./BaseDatePickerInput.js";
2
+ import { jsx as w } from "react/jsx-runtime";
3
+ var j = ({ datePickerProps: e, onClick: a }) => {
4
+ const { inputClassName: r, disabled: t, helperText: l, label: d, error: i, locale: n, hideCalendar: o, dateFormat: s, disabledDays: p, dataTest: u, readOnly: m, errorText: c, disallowFuture: C, disallowPast: h, required: x, minDate: D, validateOnCalendarClose: b, onValidatedOnce: I, onInputChange: P, selected: T, title: f, hideDefaultHelperText: g, inputAriaProps: O } = e;
5
+ return /* @__PURE__ */ w(v, {
6
6
  dataTest: u,
7
7
  inputClassName: r,
8
8
  readOnly: m,
9
9
  disabled: !!t,
10
10
  helperText: l,
11
11
  onClick: a,
12
- onInputChange: (P) => T?.(P),
13
- selected: f,
14
- error: !!n,
15
- locale: i,
12
+ onInputChange: (k) => P?.(k),
13
+ selected: T,
14
+ error: !!i,
15
+ locale: n,
16
16
  hideCalendar: o,
17
17
  dateFormat: s,
18
18
  disabledDays: p,
@@ -24,10 +24,11 @@ var F = ({ datePickerProps: e, onClick: a }) => {
24
24
  minDate: D,
25
25
  validateOnCalendarClose: b,
26
26
  onValidatedOnce: I,
27
- title: g,
28
- hideDefaultHelperText: O
27
+ title: f,
28
+ hideDefaultHelperText: g,
29
+ inputAriaProps: O
29
30
  });
30
31
  };
31
32
  export {
32
- F as DatePickerInputSingle
33
+ j as DatePickerInputSingle
33
34
  };
@@ -1,74 +1,82 @@
1
- import { ClockOutlineIcon as I } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
2
- import { StyledInputField as N } from "../../../components/inputs/input-field/StyledInputField.js";
3
- import { useInputMask as y } from "../../../helpers/inputMask.js";
4
- import { HelperText as P, defaultTimePickerHelperMessages as R } from "./components/HelperText.js";
5
- import { useEffect as v, useRef as w } from "react";
6
- import { jsx as o, jsxs as H } from "react/jsx-runtime";
7
- var O = (c) => {
8
- const { placeholder: x, disabled: e, inputClassName: u, dataTest: n, width: l, error: f, helperText: h, label: g, locale: k = "en", popupState: a, handleChange: T, handleBlur: C, isValidTime: p, isValidEndTime: m, localValue: b, title: d, readOnly: t } = c, E = y({
1
+ import { ClockOutlineIcon as P } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
2
+ import { StyledInputField as y } from "../../../components/inputs/input-field/StyledInputField.js";
3
+ import { getTitleLabelling as R } from "../../helpers/getTitleLabelling.js";
4
+ import { useInputMask as v } from "../../../helpers/inputMask.js";
5
+ import { HelperText as w, defaultTimePickerHelperMessages as A } from "./components/HelperText.js";
6
+ import { useEffect as H, useId as M, useRef as V } from "react";
7
+ import { jsx as l, jsxs as j } from "react/jsx-runtime";
8
+ var q = (x) => {
9
+ const { placeholder: f, disabled: e, inputClassName: h, dataTest: p, width: o, error: g, helperText: T, label: m, locale: k = "en", popupState: i, handleChange: C, handleBlur: I, isValidTime: d, isValidEndTime: c, localValue: b, title: a, readOnly: t, inputAriaProps: E } = x, N = v({
9
10
  mask: "xx:xx",
10
11
  maskChar: "x",
11
12
  showMask: !1
12
- }), i = !p || !m || !!f, s = w(null);
13
- return v(() => {
14
- s.current && a.setAnchorEl(s.current);
15
- }, []), /* @__PURE__ */ H("div", {
13
+ }), s = !d || !c || !!g, n = V(null), u = M();
14
+ return H(() => {
15
+ n.current && i.setAnchorEl(n.current);
16
+ }, []), /* @__PURE__ */ j("div", {
16
17
  style: { height: t ? "40px" : "75px" },
17
- children: [d && /* @__PURE__ */ o("div", {
18
+ children: [a && /* @__PURE__ */ l("div", {
19
+ id: u,
18
20
  className: "pb-1 font-roboto font-semibold text-delta-800",
19
- children: d
20
- }), /* @__PURE__ */ o(N, {
21
- inputRef: E,
21
+ children: a
22
+ }), /* @__PURE__ */ l(y, {
23
+ inputRef: N,
22
24
  autoComplete: "off",
23
25
  type: "text",
24
- dataTest: n,
25
- "data-testid": n,
26
- placeholder: x,
26
+ dataTest: p,
27
+ "data-testid": p,
28
+ placeholder: f,
27
29
  size: "small",
28
- error: i,
29
- helperText: /* @__PURE__ */ o(P, {
30
- isValidTime: p,
31
- isValidEndTime: m,
32
- error: i,
30
+ error: s,
31
+ helperText: /* @__PURE__ */ l(w, {
32
+ isValidTime: d,
33
+ isValidEndTime: c,
34
+ error: s,
33
35
  localization: k,
34
- helperText: h,
35
- messages: R
36
+ helperText: T,
37
+ messages: A
36
38
  }),
37
- onChange: T,
38
- onBlur: C,
39
+ onChange: C,
40
+ onBlur: I,
39
41
  slotProps: {
42
+ htmlInput: R({
43
+ title: a,
44
+ titleId: u,
45
+ label: m,
46
+ inputAriaProps: E
47
+ }),
40
48
  input: {
41
- ref: s,
49
+ ref: n,
42
50
  onClick: (r) => {
43
- !e && !t && a.open(r);
51
+ !e && !t && i.open(r);
44
52
  },
45
- endAdornment: /* @__PURE__ */ o(I, {
53
+ endAdornment: /* @__PURE__ */ l(P, {
46
54
  width: 24,
47
55
  height: 24,
48
56
  className: e ? "text-delta-300" : "text-delta-700",
49
57
  onClick: (r) => {
50
- r.stopPropagation(), !e && !t && a.open(r);
58
+ r.stopPropagation(), !e && !t && i.open(r);
51
59
  }
52
60
  })
53
61
  },
54
62
  formHelperText: {
55
- className: i ? "ml-0 mr-[14px] mt-1 leading-[23.24px]" : "mx-[14px] mt-1 leading-[23.24px]",
63
+ className: s ? "ml-0 mr-[14px] mt-1 leading-[23.24px]" : "mx-[14px] mt-1 leading-[23.24px]",
56
64
  hideErrorIcon: !0
57
65
  }
58
66
  },
59
67
  value: b,
60
68
  sx: {
61
- maxWidth: l ?? 130,
62
- width: l,
63
- minWidth: l
69
+ maxWidth: o ?? 130,
70
+ width: o,
71
+ minWidth: o
64
72
  },
65
73
  disabled: e,
66
74
  readOnly: t,
67
- className: u,
68
- label: g
75
+ className: h,
76
+ label: m
69
77
  })]
70
78
  });
71
79
  };
72
80
  export {
73
- O as TimePickerInput
81
+ q as TimePickerInput
74
82
  };
@@ -0,0 +1,10 @@
1
+ var t = ({ title: e, titleId: l, label: b, inputAriaProps: a }) => {
2
+ const r = !!b || !!a?.["aria-label"] || !!a?.["aria-labelledby"];
3
+ return {
4
+ ...e && !r ? { "aria-labelledby": l } : {},
5
+ ...a
6
+ };
7
+ };
8
+ export {
9
+ t as getTitleLabelling
10
+ };
@@ -1,3 +1,4 @@
1
+ import { AriaAttributes } from 'react';
1
2
  import { DayPickerProps as ReactDayPickerProps, Matcher } from 'react-day-picker';
2
3
  export interface IBaseDatePickerInput {
3
4
  dataTest: string;
@@ -23,5 +24,6 @@ export interface IBaseDatePickerInput {
23
24
  hideDefaultHelperText?: boolean;
24
25
  required?: boolean;
25
26
  minDate?: Date;
27
+ inputAriaProps?: AriaAttributes;
26
28
  }
27
29
  export declare const BaseDatePickerInput: React.FC<IBaseDatePickerInput>;
@@ -1,3 +1,4 @@
1
+ import { AriaAttributes } from 'react';
1
2
  import { DayPicker, Matcher } from 'react-day-picker';
2
3
  export type CalendarProps = React.ComponentProps<typeof DayPicker>;
3
4
  type CommonDatePickerProps = {
@@ -25,6 +26,11 @@ export interface DatePickerSingleFieldProps {
25
26
  disallowPast?: boolean;
26
27
  disallowFuture?: boolean;
27
28
  hideDefaultHelperText?: boolean;
29
+ /**
30
+ * Extra ARIA attributes for the text input (e.g. `aria-label`, `aria-required`). Without them the
31
+ * input is named by `title`, which is otherwise plain text above the field.
32
+ */
33
+ inputAriaProps?: AriaAttributes;
28
34
  }
29
35
  export interface DatePickerRangeFieldProps {
30
36
  labelFrom?: string;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { AriaAttributes, ReactNode } from 'react';
2
2
  /**
3
3
  * @param notBeforeTime - Start time of the range. Selected time must be after this value.
4
4
  */
@@ -24,5 +24,10 @@ export interface StyledTimePickerProps {
24
24
  * Unlike `notBeforeTime`, it never shows an error.
25
25
  */
26
26
  minTime?: Date;
27
+ /**
28
+ * Extra ARIA attributes for the text input (e.g. `aria-label`, `aria-required`) — for a visible
29
+ * label rendered outside the picker. Without them the input is named by `title` or `label`.
30
+ */
31
+ inputAriaProps?: AriaAttributes;
27
32
  }
28
33
  export type IPopupStateType = JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { AriaAttributes } from 'react';
2
+ /**
3
+ * ARIA naming for a datetime input that shows its `title` as plain text above the field: points the
4
+ * input at the title unless a floating `label` or an explicit name in `inputAriaProps` already names it
5
+ * (`aria-labelledby` would otherwise override that name). `inputAriaProps` are spread last.
6
+ */
7
+ export declare const getTitleLabelling: ({ title, titleId, label, inputAriaProps, }: {
8
+ title?: string;
9
+ titleId: string;
10
+ label?: string;
11
+ inputAriaProps?: AriaAttributes;
12
+ }) => AriaAttributes;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.106.0",
6
+ "version": "3.107.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",