asma-ui-core 3.68.6 → 3.69.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.
Files changed (38) hide show
  1. package/dist/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.js +49 -43
  2. package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +45 -44
  3. package/dist/components/inputs/input-field/StyledInputField.js +127 -116
  4. package/dist/components/inputs/radio-button/base-ui/StyledRadioGroup.js +37 -32
  5. package/dist/components/inputs/search-field/StyledSearchField.js +9 -8
  6. package/dist/components/inputs/select/StyledSelect.js +123 -111
  7. package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +67 -65
  8. package/dist/components/inputs/slider/StyledSlider.js +69 -61
  9. package/dist/components/inputs/textarea/StyledTextarea.js +52 -47
  10. package/dist/datetime/components/date-picker/components/BaseDatePickerInput.js +12 -12
  11. package/dist/datetime/components/date-picker/hooks/useDatePickerValidation.js +32 -31
  12. package/dist/datetime/components/time-picker/TimePickerInput.js +19 -18
  13. package/dist/datetime/components/time-picker/components/HelperText.js +10 -9
  14. package/dist/helpers/helperTextRoom.js +34 -0
  15. package/dist/helpers/useHelperAlertRole.js +11 -0
  16. package/dist/helpers/useHelperRowBudget.js +24 -0
  17. package/dist/helpers/warnMissingErrorMessage.js +6 -0
  18. package/dist/index.js +170 -165
  19. package/dist/src/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.test.d.ts +1 -0
  20. package/dist/src/components/inputs/dynamic-select/types.d.ts +1 -1
  21. package/dist/src/components/inputs/input-field/StyledInputField.d.ts +3 -3
  22. package/dist/src/components/inputs/input-field/StyledInputField.helper-slot.test.d.ts +1 -0
  23. package/dist/src/components/inputs/radio-button/base-ui/StyledRadioGroup.d.ts +2 -0
  24. package/dist/src/components/inputs/select/StyledSelect.d.ts +4 -4
  25. package/dist/src/components/inputs/select-autocomplete/StyledSelectAutocomplete.d.ts +5 -4
  26. package/dist/src/components/inputs/slider/StyledSlider.d.ts +2 -2
  27. package/dist/src/components/inputs/textarea/StyledTextarea.d.ts +1 -0
  28. package/dist/src/datetime/components/date-picker/hooks/useDatePickerValidation.d.ts +18 -1
  29. package/dist/src/datetime/components/date-picker/index.d.ts +1 -0
  30. package/dist/src/datetime/components/time-picker/components/HelperText.d.ts +12 -0
  31. package/dist/src/datetime/components/time-picker/index.d.ts +1 -0
  32. package/dist/src/helpers/helperTextRoom.d.ts +9 -0
  33. package/dist/src/helpers/helperTextRoom.test.d.ts +1 -0
  34. package/dist/src/helpers/useHelperAlertRole.d.ts +2 -0
  35. package/dist/src/helpers/useHelperAlertRole.test.d.ts +1 -0
  36. package/dist/src/helpers/useHelperRowBudget.d.ts +7 -0
  37. package/dist/src/helpers/warnMissingErrorMessage.d.ts +2 -0
  38. package/package.json +1 -1
@@ -1,104 +1,112 @@
1
1
  import { cn as n } from "../../../helpers/cn.js";
2
- import { ErrorOutlineIcon as C } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
3
- import { StyledFormHelperText as I } from "../../miscellaneous/StyledFormHelperText.js";
4
- import g from "./StyledSlider.module.js";
5
- import { useState as tt } from "react";
6
- import { jsx as b, jsxs as x } from "react/jsx-runtime";
7
- var R = (s, e, o) => o === e ? 0 : Math.min(100, Math.max(0, (s - e) / (o - e) * 100)), et = (s) => Array.isArray(s) ? [s[0] ?? 0, s[1] ?? 0] : null, ct = ({ dataTest: s, min: e = 0, max: o = 100, step: p = 1, value: z, defaultValue: E, disabled: v, size: H = "medium", orientation: L = "horizontal", marks: M, name: K, className: O, classes: u, slotProps: w, error: y, errorText: X, helperText: U, ariaLabel: S, ariaLabelledBy: Y, onChange: _, onChangeCommitted: j }) => {
8
- const a = L === "vertical", f = H === "small" ? 6 : 8, [G, J] = tt(E ?? e), A = z ?? G, i = et(A), d = i !== null, Q = (y ?? !1) || !!U, W = y ? X ?? "Required" : U, T = (M === !0 && Number.isFinite(p) && p > 0 && o > e ? Array.from({ length: Math.floor((o - e) / p) + 1 }, (t, l) => ({ value: e + p * l })) : Array.isArray(M) ? M : []).filter((t) => t.value >= e && t.value <= o), B = d ? Math.min(i[0], i[1]) : e, $ = d ? Math.max(i[0], i[1]) : A, F = (t) => d ? t >= B && t <= $ : t <= $, P = d ? R(B, e, o) : 0, V = R($, e, o) - P, Z = a ? {
9
- bottom: `${P}%`,
10
- height: `${V}%`
2
+ import { ErrorOutlineIcon as et } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
3
+ import { useHelperAlertRole as lt } from "../../../helpers/useHelperAlertRole.js";
4
+ import { warnMissingErrorMessage as at } from "../../../helpers/warnMissingErrorMessage.js";
5
+ import y from "./StyledSlider.module.js";
6
+ import { useId as rt, useState as ot } from "react";
7
+ import { jsx as m, jsxs as M } from "react/jsx-runtime";
8
+ var D = (c, e, o) => o === e ? 0 : Math.min(100, Math.max(0, (c - e) / (o - e) * 100)), nt = (c) => Array.isArray(c) ? [c[0] ?? 0, c[1] ?? 0] : null, mt = ({ dataTest: c, min: e = 0, max: o = 100, step: p = 1, value: H, defaultValue: X, disabled: v, size: L = "medium", orientation: U = "horizontal", marks: w, name: Y, className: q, classes: u, slotProps: S, error: b, errorText: G, helperText: _, reserveHelperText: J = !0, ariaLabel: x, ariaLabelledBy: Q, onChange: j, onChangeCommitted: B }) => {
9
+ const E = rt(), a = U === "vertical", d = L === "small" ? 6 : 8, [W, Z] = ot(X ?? e), A = H ?? W, i = nt(A), f = i !== null, $ = b ? G ?? _ : _, V = J || $ != null || !!b;
10
+ at("StyledSlider", b, $);
11
+ const C = lt(b), P = (w === !0 && Number.isFinite(p) && p > 0 && o > e ? Array.from({ length: Math.floor((o - e) / p) + 1 }, (t, l) => ({ value: e + p * l })) : Array.isArray(w) ? w : []).filter((t) => t.value >= e && t.value <= o), k = f ? Math.min(i[0], i[1]) : e, R = f ? Math.max(i[0], i[1]) : A, F = (t) => f ? t >= k && t <= R : t <= R, T = f ? D(k, e, o) : 0, K = D(R, e, o) - T, I = a ? {
12
+ bottom: `${T}%`,
13
+ height: `${K}%`
11
14
  } : {
12
- left: `${P}%`,
13
- width: `${V}%`
14
- }, q = (t) => {
15
- const l = R(t, e, o);
15
+ left: `${T}%`,
16
+ width: `${K}%`
17
+ }, O = (t) => {
18
+ const l = D(t, e, o);
16
19
  return a ? { bottom: `${l}%` } : { left: `${l}%` };
17
- }, k = (t) => {
20
+ }, tt = (t) => {
18
21
  if (v) return;
19
- const l = t.currentTarget.getBoundingClientRect(), r = a ? 1 - (t.clientY - l.top) / l.height : (t.clientX - l.left) / l.width, m = e + Math.round(Math.min(1, Math.max(0, r)) * ((o - e) / p)) * p, h = Math.min(o, Math.max(e, m));
20
- N(_, t, h, d && Math.abs((i?.[1] ?? e) - h) < Math.abs((i?.[0] ?? e) - h) ? 1 : 0);
21
- }, N = (t, l, r, m) => {
22
+ const l = t.currentTarget.getBoundingClientRect(), r = a ? 1 - (t.clientY - l.top) / l.height : (t.clientX - l.left) / l.width, g = e + Math.round(Math.min(1, Math.max(0, r)) * ((o - e) / p)) * p, h = Math.min(o, Math.max(e, g));
23
+ N(j, t, h, f && Math.abs((i?.[1] ?? e) - h) < Math.abs((i?.[0] ?? e) - h) ? 1 : 0);
24
+ }, N = (t, l, r, g) => {
22
25
  let h = r;
23
- if (!d) h = r;
26
+ if (!f) h = r;
24
27
  else {
25
- const c = [i?.[0] ?? 0, i?.[1] ?? 0];
26
- c[m] = r, m === 0 && c[0] > c[1] && (c[0] = c[1]), m === 1 && c[1] < c[0] && (c[1] = c[0]), h = c;
28
+ const s = [i?.[0] ?? 0, i?.[1] ?? 0];
29
+ s[g] = r, g === 0 && s[0] > s[1] && (s[0] = s[1]), g === 1 && s[1] < s[0] && (s[1] = s[0]), h = s;
27
30
  }
28
- z === void 0 && J(h), t && t(l, h, m);
29
- }, D = (t, l) => /* @__PURE__ */ b("input", {
31
+ H === void 0 && Z(h), t && t(l, h, g);
32
+ }, z = (t, l) => /* @__PURE__ */ m("input", {
30
33
  type: "range",
31
- "data-testid": d ? `${s}-thumb-${t}` : s,
32
- name: K,
34
+ "data-testid": f ? `${c}-thumb-${t}` : c,
35
+ name: Y,
33
36
  min: e,
34
37
  max: o,
35
38
  step: p,
36
39
  value: l,
37
40
  disabled: v,
38
- "aria-orientation": L,
39
- "aria-label": typeof S == "function" ? S(t) : S,
40
- "aria-labelledby": Y,
41
- className: n(g.SliderInput, a ? g.Vertical : g.Horizontal, !a && "z-0", H === "small" && g.Small, v && g.Disabled, u?.thumb, w?.thumb?.className),
42
- onChange: (r) => N(_, r, Number(r.currentTarget.value), t),
43
- onPointerUp: (r) => N(j, r, Number(r.currentTarget.value), t),
44
- onKeyUp: (r) => N(j, r, Number(r.currentTarget.value), t)
41
+ "aria-orientation": U,
42
+ "aria-label": typeof x == "function" ? x(t) : x,
43
+ "aria-labelledby": Q,
44
+ "aria-invalid": b ? !0 : void 0,
45
+ "aria-describedby": V ? E : void 0,
46
+ className: n(y.SliderInput, a ? y.Vertical : y.Horizontal, !a && "z-0", L === "small" && y.Small, v && y.Disabled, u?.thumb, S?.thumb?.className),
47
+ onChange: (r) => N(j, r, Number(r.currentTarget.value), t),
48
+ onPointerUp: (r) => N(B, r, Number(r.currentTarget.value), t),
49
+ onKeyUp: (r) => N(B, r, Number(r.currentTarget.value), t)
45
50
  }, t);
46
- return /* @__PURE__ */ x("div", {
47
- className: n("relative flex", a ? "h-full w-8 flex-col items-center" : "mt-px w-full flex-col", u?.root, O),
51
+ return /* @__PURE__ */ M("div", {
52
+ className: n("relative flex", a ? "h-full w-8 flex-col items-center" : "mt-px w-full flex-col", u?.root, q),
48
53
  children: [
49
- /* @__PURE__ */ x("div", {
54
+ /* @__PURE__ */ M("div", {
50
55
  className: n("relative", a ? "h-full w-8" : "h-4 w-full"),
51
- children: [/* @__PURE__ */ x("div", {
52
- onPointerDown: k,
56
+ children: [/* @__PURE__ */ M("div", {
57
+ onPointerDown: tt,
53
58
  className: n("absolute", a ? "left-1/2 w-1 -translate-x-1/2" : "top-[calc(50%+6px)] h-1 -translate-y-1/2"),
54
59
  style: a ? {
55
- top: f,
56
- bottom: f
60
+ top: d,
61
+ bottom: d
57
62
  } : {
58
- left: f,
59
- right: f
63
+ left: d,
64
+ right: d
60
65
  },
61
66
  children: [
62
- /* @__PURE__ */ b("div", { className: n("absolute inset-0 rounded-full bg-delta-100", u?.rail, w?.rail?.className) }),
63
- /* @__PURE__ */ b("div", {
67
+ /* @__PURE__ */ m("div", { className: n("absolute inset-0 rounded-full bg-delta-100", u?.rail, S?.rail?.className) }),
68
+ /* @__PURE__ */ m("div", {
64
69
  className: n("absolute rounded-full", a ? "left-0 w-full" : "top-0 h-full", v ? "bg-delta-200" : "bg-gama-500", u?.track),
65
- style: Z
70
+ style: I
66
71
  }),
67
- T.map((t) => {
72
+ P.map((t) => {
68
73
  const l = F(t.value);
69
- return /* @__PURE__ */ b("span", {
74
+ return /* @__PURE__ */ m("span", {
70
75
  className: n("absolute z-10 box-border h-2 w-2 -translate-x-1/2 rounded-full border border-solid", a ? "left-1/2 translate-y-1/2" : "top-1/2 -translate-y-1/2", l ? n(v ? "border-delta-200 bg-delta-200" : "border-gama-500 bg-gama-500", u?.markActive) : n("border-delta-300 bg-white", u?.mark)),
71
- style: q(t.value)
76
+ style: O(t.value)
72
77
  }, t.value);
73
78
  })
74
79
  ]
75
- }), d ? [D(0, i[0]), D(1, i[1])] : D(0, A)]
80
+ }), f ? [z(0, i[0]), z(1, i[1])] : z(0, A)]
76
81
  }),
77
- T.some((t) => t.label != null) && /* @__PURE__ */ b("div", {
82
+ P.some((t) => t.label != null) && /* @__PURE__ */ m("div", {
78
83
  className: n(a ? "pointer-events-none absolute inset-x-0" : "relative mt-[14px] h-6"),
79
84
  style: a ? {
80
- top: f,
81
- bottom: f
85
+ top: d,
86
+ bottom: d
82
87
  } : {
83
- marginLeft: f,
84
- marginRight: f
88
+ marginLeft: d,
89
+ marginRight: d
85
90
  },
86
- children: T.map((t) => t.label == null ? null : /* @__PURE__ */ b("span", {
87
- className: n("absolute text-base font-semibold text-delta-700", a ? "left-[37px] translate-y-1/2" : "-translate-x-1/2", F(t.value) && u?.markLabelActive, u?.markLabel, w?.markLabel?.className),
88
- style: q(t.value),
91
+ children: P.map((t) => t.label == null ? null : /* @__PURE__ */ m("span", {
92
+ className: n("absolute text-base font-semibold text-delta-700", a ? "left-[37px] translate-y-1/2" : "-translate-x-1/2", F(t.value) && u?.markLabelActive, u?.markLabel, S?.markLabel?.className),
93
+ style: O(t.value),
89
94
  children: t.label
90
95
  }, t.value))
91
96
  }),
92
- Q && /* @__PURE__ */ x(I, {
93
- className: n("m-0 flex items-center gap-1 pt-1 text-sm", y ? "text-error-500" : "text-delta-600"),
94
- children: [y && /* @__PURE__ */ b(C, {
97
+ V && /* @__PURE__ */ M("div", {
98
+ id: E,
99
+ role: C,
100
+ className: n("m-0 flex min-h-[24px] items-center gap-1 pt-1 text-sm leading-5 tracking-[0.03333em]", b ? "text-error-500" : "text-delta-600"),
101
+ children: [b && /* @__PURE__ */ m(et, {
95
102
  width: 20,
96
- height: 20
97
- }), W]
103
+ height: 20,
104
+ className: "min-w-5 shrink-0"
105
+ }), /* @__PURE__ */ m("span", { children: $ })]
98
106
  })
99
107
  ]
100
108
  });
101
109
  };
102
110
  export {
103
- ct as StyledSlider
111
+ mt as StyledSlider
104
112
  };
@@ -1,72 +1,77 @@
1
- import e from "./StyledTextarea.module.js";
2
- import { useEffect as J, useId as m, useRef as K } from "react";
3
- import { Fragment as O, jsx as n, jsxs as s } from "react/jsx-runtime";
4
- var X = ({ id: T, variant: x = "active", label: c = "", labelClassName: A = "", description: o = "", value: t = "", minRows: r = 3, maxRows: i = 1 / 0, disabled: g, error: l, errorMessage: H, containerClassName: M = "", className: S = "", maxLength: _ = 1 / 0, counter: j, refLink: B, dataTest: E, counterLimit: d, ...y }) => {
5
- const k = K(null), p = B ?? k, f = !!(j && d), b = m(), $ = m(), w = m(), u = T ?? w;
6
- J(() => {
7
- const a = p.current;
8
- if (!a) return;
9
- const h = window.getComputedStyle(a), N = parseFloat(h.lineHeight) || 24, I = parseFloat(h.paddingTop), F = parseFloat(h.paddingBottom);
10
- a.style.height = "auto";
11
- const z = a.scrollHeight - I - F, D = Math.max(1, Math.ceil(z / N)), G = Math.min(Math.max(D, r), i);
12
- a.style.height = `${G * N + I + F}px`;
1
+ import { useHelperAlertRole as Q } from "../../../helpers/useHelperAlertRole.js";
2
+ import { warnMissingErrorMessage as U } from "../../../helpers/warnMissingErrorMessage.js";
3
+ import a from "./StyledTextarea.module.js";
4
+ import { useEffect as V, useId as m, useRef as W } from "react";
5
+ import { Fragment as X, jsx as o, jsxs as c } from "react/jsx-runtime";
6
+ var at = ({ id: M, variant: x = "active", label: d = "", labelClassName: S = "", description: l = "", reserveHelperText: j = !0, value: e = "", minRows: r = 3, maxRows: i = 1 / 0, disabled: g, error: t, errorMessage: y, containerClassName: B = "", className: _ = "", maxLength: w = 1 / 0, counter: E, refLink: k, dataTest: C, counterLimit: p, ...b }) => {
7
+ const R = W(null), f = k ?? R, s = !!(E && p), u = m(), $ = m(), q = m(), v = M ?? q, N = t ? y : l, I = j || N != null || !!t;
8
+ U("StyledTextarea", t, y);
9
+ const z = Q(t);
10
+ V(() => {
11
+ const n = f.current;
12
+ if (!n) return;
13
+ const h = window.getComputedStyle(n), A = parseFloat(h.lineHeight) || 24, F = parseFloat(h.paddingTop), H = parseFloat(h.paddingBottom);
14
+ n.style.height = "auto";
15
+ const J = n.scrollHeight - F - H, K = Math.max(1, Math.ceil(J / A)), O = Math.min(Math.max(K, r), i);
16
+ n.style.height = `${O * A + F + H}px`;
13
17
  }, [
14
- p,
15
- t,
18
+ f,
19
+ e,
16
20
  r,
17
21
  i,
18
- f
22
+ s
19
23
  ]), i < r && (r = i);
20
- const C = l ? "error" : "active", v = l ? "error" : g ? "disabled" : "active", q = typeof c != "string" || c.trim() !== "" ? void 0 : typeof o == "string" && o.trim() !== "" ? o : y.placeholder;
21
- return /* @__PURE__ */ s("div", {
22
- className: `relative flex flex-col gap-1 ${M}`,
23
- "data-testid": E,
24
+ const D = t ? "error" : "active", T = t ? "error" : g ? "disabled" : "active", G = typeof d != "string" || d.trim() !== "" ? void 0 : typeof l == "string" && l.trim() !== "" ? l : b.placeholder;
25
+ return /* @__PURE__ */ c("div", {
26
+ className: `relative flex flex-col gap-1 ${B}`,
27
+ "data-testid": C,
24
28
  children: [
25
- /* @__PURE__ */ n("label", {
26
- htmlFor: u,
27
- className: `${e.label} ${e[v]} ${A}`,
28
- children: c
29
+ /* @__PURE__ */ o("label", {
30
+ htmlFor: v,
31
+ className: `${a.label} ${a[T]} ${S}`,
32
+ children: d
29
33
  }),
30
- /* @__PURE__ */ n("span", {
31
- id: b,
32
- className: `${e.description} ${e[v]}`,
33
- children: l ? H : o
34
+ I && /* @__PURE__ */ o("span", {
35
+ id: u,
36
+ role: z,
37
+ className: `${a.description} ${a[T]} min-h-[24px]`,
38
+ children: N
34
39
  }),
35
- x === "view_only" ? /* @__PURE__ */ n("div", {
40
+ x === "view_only" ? /* @__PURE__ */ o("div", {
36
41
  className: "pt-3 font-roboto text-base font-normal text-delta-700",
37
- children: t
38
- }) : x === "not_editable" ? /* @__PURE__ */ n("div", {
42
+ children: e
43
+ }) : x === "not_editable" ? /* @__PURE__ */ o("div", {
39
44
  className: "rounded bg-delta-50 p-3 font-roboto text-base font-normal text-delta-700",
40
- children: t
41
- }) : /* @__PURE__ */ n("textarea", {
42
- ...y,
43
- "aria-describedby": `${b} ${$}`,
44
- "aria-invalid": l,
45
- "aria-label": q,
46
- id: u,
47
- ref: p,
48
- className: `${e.textarea} ${e[C]} ${S} ${f ? "pb-[32px]" : ""}`,
45
+ children: e
46
+ }) : /* @__PURE__ */ o("textarea", {
47
+ ...b,
48
+ "aria-describedby": [I ? u : null, s ? $ : null].filter(Boolean).join(" ") || void 0,
49
+ "aria-invalid": t,
50
+ "aria-label": G,
51
+ id: v,
52
+ ref: f,
53
+ className: `${a.textarea} ${a[D]} ${_} ${s ? "pb-[32px]" : ""}`,
49
54
  wrap: "soft",
50
- value: t,
55
+ value: e,
51
56
  disabled: g,
52
- maxLength: _
57
+ maxLength: w
53
58
  }),
54
- f && /* @__PURE__ */ s(O, { children: [/* @__PURE__ */ s("div", {
59
+ s && /* @__PURE__ */ c(X, { children: [/* @__PURE__ */ c("div", {
55
60
  className: "pointer-events-none absolute bottom-3 right-3 flex h-[15px] justify-end font-roboto text-[10px]",
56
61
  children: [
57
- t.length,
62
+ e.length,
58
63
  "/",
59
- d
64
+ p
60
65
  ]
61
- }), /* @__PURE__ */ s("div", {
66
+ }), /* @__PURE__ */ c("div", {
62
67
  id: $,
63
68
  "aria-live": "polite",
64
69
  className: "sr-only",
65
- children: [d - t.length, " characters remaining"]
70
+ children: [p - e.length, " characters remaining"]
66
71
  })] })
67
72
  ]
68
73
  });
69
74
  };
70
75
  export {
71
- X as StyledTextarea
76
+ at as StyledTextarea
72
77
  };
@@ -3,12 +3,12 @@ import { getValue as f } from "../helpers.js";
3
3
  import { DatePickerButton as J } from "./DatePickerButton.js";
4
4
  import { DATE_INPUT_FONT_FAMILY as K } from "../../../../helpers/inputMask.js";
5
5
  import { useDatePickerMask as Q } from "../hooks/useDatePickerMask.js";
6
- import { useDatePickerValidation as X } from "../hooks/useDatePickerValidation.js";
7
- import { useEffect as b, useState as N } from "react";
8
- import { jsx as m, jsxs as k } from "react/jsx-runtime";
9
- import { isValid as Z, parse as $ } from "date-fns";
10
- var ne = (F) => {
11
- const { onClick: V, 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 } = F, { validationError: A, handleValidation: c, errHelperText: R, clearValidation: x } = X(), { maskRef: S } = Q(), [a, y] = N(e ? f(e, r) : ""), [C, _] = N({
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({
12
12
  selected: e,
13
13
  dateFormat: r
14
14
  });
@@ -83,15 +83,15 @@ var ne = (F) => {
83
83
  h?.(void 0);
84
84
  return;
85
85
  }
86
- const p = $(a, "dd/MM/yyyy", /* @__PURE__ */ new Date());
87
- h?.(Z(p) ? p : void 0);
86
+ const p = ee(a, "dd/MM/yyyy", /* @__PURE__ */ new Date());
87
+ h?.($(p) ? p : void 0);
88
88
  }, M = t ? 120 : 160;
89
- return /* @__PURE__ */ k("div", {
89
+ return /* @__PURE__ */ N("div", {
90
90
  className: "cursor-default",
91
91
  children: [v && /* @__PURE__ */ m("div", {
92
92
  className: "pb-1 font-roboto font-semibold text-delta-800",
93
93
  children: v
94
- }), /* @__PURE__ */ k("div", {
94
+ }), /* @__PURE__ */ N("div", {
95
95
  className: "flex gap-1",
96
96
  style: { height: t ? 40 : 75 },
97
97
  children: [/* @__PURE__ */ m("div", {
@@ -128,7 +128,7 @@ var ne = (F) => {
128
128
  })
129
129
  })
130
130
  }), !B && !t && /* @__PURE__ */ m(J, {
131
- onClick: V,
131
+ onClick: F,
132
132
  disabled: !!u.disabled,
133
133
  localeCode: o?.code
134
134
  })]
@@ -136,5 +136,5 @@ var ne = (F) => {
136
136
  });
137
137
  };
138
138
  export {
139
- ne as BaseDatePickerInput
139
+ ce as BaseDatePickerInput
140
140
  };
@@ -1,7 +1,7 @@
1
- import { buildDisabled as k, isDisabledDate as N } from "../helpers.js";
1
+ import { buildDisabled as Y, isDisabledDate as N } from "../helpers.js";
2
2
  import { useCallback as g, useState as y } from "react";
3
3
  import { isValid as U, parse as x, startOfDay as b } from "date-fns";
4
- var r = {
4
+ var F = {
5
5
  en: {
6
6
  required: "Required",
7
7
  minDate: "End date must be after the start date",
@@ -26,44 +26,45 @@ var r = {
26
26
  pastNotAllowed: "Dato i fortiden er ikke tillatt",
27
27
  futureNotAllowed: "Dato i fremtiden er ikke tillatt"
28
28
  }
29
- }, F = /^(\d{2})\/(\d{2})\/(\d{4})$/, V = () => {
30
- const [c, e] = y(!1), [p, t] = y(""), o = g(() => {
29
+ }, I = /^(\d{2})\/(\d{2})\/(\d{4})$/, P = (D = F) => {
30
+ const [c, e] = y(!1), [p, t] = y(""), n = g(() => {
31
31
  e(!1), t("");
32
32
  }, []);
33
33
  return {
34
34
  validationError: c,
35
- handleValidation: g(({ value: m, disabledDays: M, localeCode: h, disallowPast: w, disallowFuture: Y, required: s, minDate: v }) => {
36
- const a = h === "nb" ? "nb" : "en";
35
+ handleValidation: g(({ value: m, disabledDays: M, localeCode: h, disallowPast: k, disallowFuture: w, required: o, minDate: v }) => {
36
+ const a = D[h === "nb" ? "nb" : "en"];
37
37
  if (!m.replace(/\D/g, "").length)
38
- return e(!!s), t(s ? r[a].required : ""), !!s;
39
- const i = F.exec(m);
40
- if (!i)
41
- return e(!0), t(r[a].invalidFormat), !0;
42
- const d = Number(i[1]), l = Number(i[2]), n = Number(i[3]);
43
- if (d < 1 || d > 31)
44
- return e(!0), t(r[a].invalidDay), !0;
45
- if (l < 1 || l > 12)
46
- return e(!0), t(r[a].invalidMonth), !0;
47
- if (n < 1900 || n > 2100)
48
- return e(!0), t(r[a].invalidYear), !0;
49
- const u = new Date(n, l - 1, d);
50
- if (!(u.getFullYear() === n && u.getMonth() === l - 1 && u.getDate() === d))
51
- return e(!0), t(r[a].invalidDate), !0;
52
- const D = x(`${i[1]}/${i[2]}/${i[3]}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
53
- if (!U(D))
54
- return e(!0), t(r[a].invalidDate), !0;
55
- if (v && b(D) <= b(v))
56
- return e(!0), t(r[a].minDate), !0;
57
- const f = k(M, w, Y);
38
+ return e(!!o), t(o ? a.required : ""), !!o;
39
+ const r = I.exec(m);
40
+ if (!r)
41
+ return e(!0), t(a.invalidFormat), !0;
42
+ const i = Number(r[1]), d = Number(r[2]), l = Number(r[3]);
43
+ if (i < 1 || i > 31)
44
+ return e(!0), t(a.invalidDay), !0;
45
+ if (d < 1 || d > 12)
46
+ return e(!0), t(a.invalidMonth), !0;
47
+ if (l < 1900 || l > 2100)
48
+ return e(!0), t(a.invalidYear), !0;
49
+ const u = new Date(l, d - 1, i);
50
+ if (!(u.getFullYear() === l && u.getMonth() === d - 1 && u.getDate() === i))
51
+ return e(!0), t(a.invalidDate), !0;
52
+ const s = x(`${r[1]}/${r[2]}/${r[3]}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
53
+ if (!U(s))
54
+ return e(!0), t(a.invalidDate), !0;
55
+ if (v && b(s) <= b(v))
56
+ return e(!0), t(a.minDate), !0;
57
+ const f = Y(M, k, w);
58
58
  return f.length && N({
59
- parsedDate: D,
59
+ parsedDate: s,
60
60
  disabledDays: f
61
- }) ? (t(r[a].dateDisabled), e(!0), !0) : (o(), !1);
62
- }, [o]),
61
+ }) ? (t(a.dateDisabled), e(!0), !0) : (n(), !1);
62
+ }, [n, D]),
63
63
  errHelperText: p,
64
- clearValidation: o
64
+ clearValidation: n
65
65
  };
66
66
  };
67
67
  export {
68
- V as useDatePickerValidation
68
+ F as defaultDatePickerValidationMessages,
69
+ P as useDatePickerValidation
69
70
  };
@@ -1,18 +1,18 @@
1
1
  import { StyledInputField as E } from "../../../components/inputs/input-field/StyledInputField.js";
2
2
  import { useInputMask as I } from "../../../helpers/inputMask.js";
3
- import { HelperText as N } from "./components/HelperText.js";
4
- import { ClockOutlineIcon as w } from "../../shared-components/ClockOutlineIcon.js";
5
- import { useEffect as y, useRef as R } from "react";
6
- import { jsx as r, jsxs as v } from "react/jsx-runtime";
7
- var H = (x) => {
8
- const { placeholder: c, disabled: e, inputClassName: f, dataTest: s, width: l, error: h, helperText: u, label: T, locale: g = "en", popupState: a, handleChange: k, isValidTime: p, isValidEndTime: m, localValue: C, title: d, readOnly: t } = x, b = I({
3
+ import { HelperText as N, defaultTimePickerHelperMessages as w } from "./components/HelperText.js";
4
+ import { ClockOutlineIcon as y } from "../../shared-components/ClockOutlineIcon.js";
5
+ import { useEffect as M, useRef as P } from "react";
6
+ import { jsx as r, jsxs as R } from "react/jsx-runtime";
7
+ var O = (x) => {
8
+ const { placeholder: c, disabled: e, inputClassName: f, dataTest: n, width: l, error: u, helperText: h, label: g, locale: T = "en", popupState: a, handleChange: k, isValidTime: p, isValidEndTime: m, localValue: C, title: d, readOnly: t } = x, b = I({
9
9
  mask: "xx:xx",
10
10
  maskChar: "x",
11
11
  showMask: !1
12
- }), i = !p || !m || !!h, n = R(null);
13
- return y(() => {
14
- n.current && a.setAnchorEl(n.current);
15
- }, []), /* @__PURE__ */ v("div", {
12
+ }), i = !p || !m || !!u, s = P(null);
13
+ return M(() => {
14
+ s.current && a.setAnchorEl(s.current);
15
+ }, []), /* @__PURE__ */ R("div", {
16
16
  style: { height: t ? "40px" : "75px" },
17
17
  children: [d && /* @__PURE__ */ r("div", {
18
18
  className: "pb-1 font-roboto font-semibold text-delta-800",
@@ -21,8 +21,8 @@ var H = (x) => {
21
21
  inputRef: b,
22
22
  autoComplete: "off",
23
23
  type: "text",
24
- dataTest: s,
25
- "data-testid": s,
24
+ dataTest: n,
25
+ "data-testid": n,
26
26
  placeholder: c,
27
27
  size: "small",
28
28
  error: i,
@@ -30,17 +30,18 @@ var H = (x) => {
30
30
  isValidTime: p,
31
31
  isValidEndTime: m,
32
32
  error: i,
33
- localization: g,
34
- helperText: u
33
+ localization: T,
34
+ helperText: h,
35
+ messages: w
35
36
  }),
36
37
  onChange: k,
37
38
  slotProps: {
38
39
  input: {
39
- ref: n,
40
+ ref: s,
40
41
  onMouseDown: (o) => {
41
42
  !e && !t && a.open(o);
42
43
  },
43
- endAdornment: /* @__PURE__ */ r(w, {
44
+ endAdornment: /* @__PURE__ */ r(y, {
44
45
  width: 24,
45
46
  height: 24,
46
47
  className: e ? "text-delta-300" : "text-delta-700",
@@ -63,10 +64,10 @@ var H = (x) => {
63
64
  disabled: e,
64
65
  readOnly: t,
65
66
  className: f,
66
- label: T
67
+ label: g
67
68
  })]
68
69
  });
69
70
  };
70
71
  export {
71
- H as TimePickerInput
72
+ O as TimePickerInput
72
73
  };
@@ -1,7 +1,7 @@
1
- import { cn as m } from "../../../helpers/cn.js";
2
- import { OutlineErrorRounded as f } from "../../../shared-components/OutlineErrorRounded.js";
1
+ import { cn as f } from "../../../helpers/cn.js";
2
+ import { OutlineErrorRounded as m } from "../../../shared-components/OutlineErrorRounded.js";
3
3
  import { jsx as r, jsxs as d } from "react/jsx-runtime";
4
- var i = {
4
+ var c = {
5
5
  invalid: {
6
6
  en: "Invalid time format",
7
7
  no: "Ugyldig tidsformat"
@@ -10,13 +10,13 @@ var i = {
10
10
  en: "Must be after start time",
11
11
  no: "Må være etter starttid"
12
12
  }
13
- }, v = ({ isValidTime: t, isValidEndTime: e, localization: o = "en", error: s, helperText: n }) => {
14
- const a = !t || !e || !!s, l = t ? e ? n : i.afterStartTime[o] : i.invalid[o];
13
+ }, h = ({ isValidTime: e, isValidEndTime: t, localization: a = "en", error: s, helperText: n, messages: o = c }) => {
14
+ const i = !e || !t || !!s, l = e ? t ? n : o.afterStartTime[a] : o.invalid[a];
15
15
  return /* @__PURE__ */ d("span", {
16
16
  className: "flex items-start gap-1",
17
17
  children: [/* @__PURE__ */ r("span", {
18
- className: m("flex", "transform-gpu transition-all duration-300 ease-in-out"),
19
- children: a && /* @__PURE__ */ r(f, {
18
+ className: f("flex", "transform-gpu transition-all duration-300 ease-in-out"),
19
+ children: i && /* @__PURE__ */ r(m, {
20
20
  width: 20,
21
21
  height: 20,
22
22
  color: "var(--colors-error-500)"
@@ -30,7 +30,7 @@ var i = {
30
30
  overflow: "hidden",
31
31
  maxHeight: 32,
32
32
  fontFamily: "roboto, sans-serif",
33
- color: a ? "var(--colors-error-500)" : "var(--colors-delta-600)",
33
+ color: i ? "var(--colors-error-500)" : "var(--colors-delta-600)",
34
34
  fontSize: 14
35
35
  },
36
36
  children: l
@@ -38,5 +38,6 @@ var i = {
38
38
  });
39
39
  };
40
40
  export {
41
- v as HelperText
41
+ h as HelperText,
42
+ c as defaultTimePickerHelperMessages
42
43
  };
@@ -0,0 +1,34 @@
1
+ var c = 14, p = 8, a = 24;
2
+ function s(t, n) {
3
+ let o = Number.POSITIVE_INFINITY;
4
+ for (const e of n)
5
+ e.right <= e.left || e.bottom <= e.top || e.left < t.left || e.bottom <= t.top || e.top >= t.bottom || (o = Math.min(o, e.left - p));
6
+ return o;
7
+ }
8
+ function d(t, n, o) {
9
+ if (!(n > 0)) return;
10
+ const e = n - c, i = o - t - c;
11
+ return Number.isFinite(i) && i > e ? Math.floor(i) : void 0;
12
+ }
13
+ function l(t) {
14
+ const { left: n } = t.getBoundingClientRect(), o = Number.parseFloat(getComputedStyle(t).paddingRight) || 0;
15
+ return n + t.clientLeft + t.clientWidth - o;
16
+ }
17
+ function h(t) {
18
+ for (let n = t.parentElement; n; n = n.parentElement) if (getComputedStyle(n).overflowX !== "visible") return l(n);
19
+ return Number.POSITIVE_INFINITY;
20
+ }
21
+ function R(t, n) {
22
+ const o = t.parentElement;
23
+ if (!o) return;
24
+ const e = t.getBoundingClientRect(), i = n.getBoundingClientRect().top, u = {
25
+ top: i,
26
+ bottom: i + a,
27
+ left: e.left,
28
+ right: e.right
29
+ }, f = Array.from(o.children).filter((r) => r !== t).map((r) => r.getBoundingClientRect()), g = Math.min(l(o), h(t), s(u, f));
30
+ return d(e.left, e.width, g);
31
+ }
32
+ export {
33
+ R as measureHelperRowMaxWidth
34
+ };
@@ -0,0 +1,11 @@
1
+ import { useState as o } from "react";
2
+ function l(r, e) {
3
+ return r && !e ? "alert" : "status";
4
+ }
5
+ function f(r) {
6
+ const e = !!r, [t, s] = o(e), [n, u] = o(l(e, !1));
7
+ return e !== t && (s(e), u(l(e, t))), n;
8
+ }
9
+ export {
10
+ f as useHelperAlertRole
11
+ };