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.
- package/dist/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.js +49 -43
- package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +45 -44
- package/dist/components/inputs/input-field/StyledInputField.js +127 -116
- package/dist/components/inputs/radio-button/base-ui/StyledRadioGroup.js +37 -32
- package/dist/components/inputs/search-field/StyledSearchField.js +9 -8
- package/dist/components/inputs/select/StyledSelect.js +123 -111
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +67 -65
- package/dist/components/inputs/slider/StyledSlider.js +69 -61
- package/dist/components/inputs/textarea/StyledTextarea.js +52 -47
- package/dist/datetime/components/date-picker/components/BaseDatePickerInput.js +12 -12
- package/dist/datetime/components/date-picker/hooks/useDatePickerValidation.js +32 -31
- package/dist/datetime/components/time-picker/TimePickerInput.js +19 -18
- package/dist/datetime/components/time-picker/components/HelperText.js +10 -9
- package/dist/helpers/helperTextRoom.js +34 -0
- package/dist/helpers/useHelperAlertRole.js +11 -0
- package/dist/helpers/useHelperRowBudget.js +24 -0
- package/dist/helpers/warnMissingErrorMessage.js +6 -0
- package/dist/index.js +170 -165
- package/dist/src/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.test.d.ts +1 -0
- package/dist/src/components/inputs/dynamic-select/types.d.ts +1 -1
- package/dist/src/components/inputs/input-field/StyledInputField.d.ts +3 -3
- package/dist/src/components/inputs/input-field/StyledInputField.helper-slot.test.d.ts +1 -0
- package/dist/src/components/inputs/radio-button/base-ui/StyledRadioGroup.d.ts +2 -0
- package/dist/src/components/inputs/select/StyledSelect.d.ts +4 -4
- package/dist/src/components/inputs/select-autocomplete/StyledSelectAutocomplete.d.ts +5 -4
- package/dist/src/components/inputs/slider/StyledSlider.d.ts +2 -2
- package/dist/src/components/inputs/textarea/StyledTextarea.d.ts +1 -0
- package/dist/src/datetime/components/date-picker/hooks/useDatePickerValidation.d.ts +18 -1
- package/dist/src/datetime/components/date-picker/index.d.ts +1 -0
- package/dist/src/datetime/components/time-picker/components/HelperText.d.ts +12 -0
- package/dist/src/datetime/components/time-picker/index.d.ts +1 -0
- package/dist/src/helpers/helperTextRoom.d.ts +9 -0
- package/dist/src/helpers/helperTextRoom.test.d.ts +1 -0
- package/dist/src/helpers/useHelperAlertRole.d.ts +2 -0
- package/dist/src/helpers/useHelperAlertRole.test.d.ts +1 -0
- package/dist/src/helpers/useHelperRowBudget.d.ts +7 -0
- package/dist/src/helpers/warnMissingErrorMessage.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,104 +1,112 @@
|
|
|
1
1
|
import { cn as n } from "../../../helpers/cn.js";
|
|
2
|
-
import { ErrorOutlineIcon as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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: `${
|
|
13
|
-
width: `${
|
|
14
|
-
},
|
|
15
|
-
const l =
|
|
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
|
-
},
|
|
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,
|
|
20
|
-
N(
|
|
21
|
-
}, N = (t, l, r,
|
|
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 (!
|
|
26
|
+
if (!f) h = r;
|
|
24
27
|
else {
|
|
25
|
-
const
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
},
|
|
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":
|
|
32
|
-
name:
|
|
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":
|
|
39
|
-
"aria-label": typeof
|
|
40
|
-
"aria-labelledby":
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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__ */
|
|
47
|
-
className: n("relative flex", a ? "h-full w-8 flex-col items-center" : "mt-px w-full flex-col", u?.root,
|
|
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__ */
|
|
54
|
+
/* @__PURE__ */ M("div", {
|
|
50
55
|
className: n("relative", a ? "h-full w-8" : "h-4 w-full"),
|
|
51
|
-
children: [/* @__PURE__ */
|
|
52
|
-
onPointerDown:
|
|
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:
|
|
56
|
-
bottom:
|
|
60
|
+
top: d,
|
|
61
|
+
bottom: d
|
|
57
62
|
} : {
|
|
58
|
-
left:
|
|
59
|
-
right:
|
|
63
|
+
left: d,
|
|
64
|
+
right: d
|
|
60
65
|
},
|
|
61
66
|
children: [
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
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:
|
|
70
|
+
style: I
|
|
66
71
|
}),
|
|
67
|
-
|
|
72
|
+
P.map((t) => {
|
|
68
73
|
const l = F(t.value);
|
|
69
|
-
return /* @__PURE__ */
|
|
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:
|
|
76
|
+
style: O(t.value)
|
|
72
77
|
}, t.value);
|
|
73
78
|
})
|
|
74
79
|
]
|
|
75
|
-
}),
|
|
80
|
+
}), f ? [z(0, i[0]), z(1, i[1])] : z(0, A)]
|
|
76
81
|
}),
|
|
77
|
-
|
|
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:
|
|
81
|
-
bottom:
|
|
85
|
+
top: d,
|
|
86
|
+
bottom: d
|
|
82
87
|
} : {
|
|
83
|
-
marginLeft:
|
|
84
|
-
marginRight:
|
|
88
|
+
marginLeft: d,
|
|
89
|
+
marginRight: d
|
|
85
90
|
},
|
|
86
|
-
children:
|
|
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,
|
|
88
|
-
style:
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
+
mt as StyledSlider
|
|
104
112
|
};
|
|
@@ -1,72 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
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
|
-
|
|
15
|
-
|
|
18
|
+
f,
|
|
19
|
+
e,
|
|
16
20
|
r,
|
|
17
21
|
i,
|
|
18
|
-
|
|
22
|
+
s
|
|
19
23
|
]), i < r && (r = i);
|
|
20
|
-
const
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
className: `relative flex flex-col gap-1 ${
|
|
23
|
-
"data-testid":
|
|
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__ */
|
|
26
|
-
htmlFor:
|
|
27
|
-
className: `${
|
|
28
|
-
children:
|
|
29
|
+
/* @__PURE__ */ o("label", {
|
|
30
|
+
htmlFor: v,
|
|
31
|
+
className: `${a.label} ${a[T]} ${S}`,
|
|
32
|
+
children: d
|
|
29
33
|
}),
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
id:
|
|
32
|
-
|
|
33
|
-
|
|
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__ */
|
|
40
|
+
x === "view_only" ? /* @__PURE__ */ o("div", {
|
|
36
41
|
className: "pt-3 font-roboto text-base font-normal text-delta-700",
|
|
37
|
-
children:
|
|
38
|
-
}) : x === "not_editable" ? /* @__PURE__ */
|
|
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:
|
|
41
|
-
}) : /* @__PURE__ */
|
|
42
|
-
...
|
|
43
|
-
"aria-describedby":
|
|
44
|
-
"aria-invalid":
|
|
45
|
-
"aria-label":
|
|
46
|
-
id:
|
|
47
|
-
ref:
|
|
48
|
-
className: `${
|
|
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:
|
|
55
|
+
value: e,
|
|
51
56
|
disabled: g,
|
|
52
|
-
maxLength:
|
|
57
|
+
maxLength: w
|
|
53
58
|
}),
|
|
54
|
-
|
|
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
|
-
|
|
62
|
+
e.length,
|
|
58
63
|
"/",
|
|
59
|
-
|
|
64
|
+
p
|
|
60
65
|
]
|
|
61
|
-
}), /* @__PURE__ */
|
|
66
|
+
}), /* @__PURE__ */ c("div", {
|
|
62
67
|
id: $,
|
|
63
68
|
"aria-live": "polite",
|
|
64
69
|
className: "sr-only",
|
|
65
|
-
children: [
|
|
70
|
+
children: [p - e.length, " characters remaining"]
|
|
66
71
|
})] })
|
|
67
72
|
]
|
|
68
73
|
});
|
|
69
74
|
};
|
|
70
75
|
export {
|
|
71
|
-
|
|
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 {
|
|
7
|
-
import { useEffect as b, useState as
|
|
8
|
-
import { jsx as m, jsxs as
|
|
9
|
-
import { isValid as
|
|
10
|
-
var
|
|
11
|
-
const { onClick:
|
|
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 =
|
|
87
|
-
h?.(
|
|
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__ */
|
|
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__ */
|
|
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:
|
|
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
|
-
|
|
139
|
+
ce as BaseDatePickerInput
|
|
140
140
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { buildDisabled as
|
|
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
|
|
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
|
-
},
|
|
30
|
-
const [c, e] = y(!1), [p, t] = y(""),
|
|
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:
|
|
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(!!
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
return e(!0), t(
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return e(!0), t(
|
|
45
|
-
if (
|
|
46
|
-
return e(!0), t(
|
|
47
|
-
if (
|
|
48
|
-
return e(!0), t(
|
|
49
|
-
const u = new Date(
|
|
50
|
-
if (!(u.getFullYear() ===
|
|
51
|
-
return e(!0), t(
|
|
52
|
-
const
|
|
53
|
-
if (!U(
|
|
54
|
-
return e(!0), t(
|
|
55
|
-
if (v && b(
|
|
56
|
-
return e(!0), t(
|
|
57
|
-
const f =
|
|
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:
|
|
59
|
+
parsedDate: s,
|
|
60
60
|
disabledDays: f
|
|
61
|
-
}) ? (t(
|
|
62
|
-
}, [
|
|
61
|
+
}) ? (t(a.dateDisabled), e(!0), !0) : (n(), !1);
|
|
62
|
+
}, [n, D]),
|
|
63
63
|
errHelperText: p,
|
|
64
|
-
clearValidation:
|
|
64
|
+
clearValidation: n
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
export {
|
|
68
|
-
|
|
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
|
|
5
|
-
import { useEffect as
|
|
6
|
-
import { jsx as r, jsxs as
|
|
7
|
-
var
|
|
8
|
-
const { placeholder: c, disabled: e, inputClassName: f, dataTest:
|
|
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 || !!
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
}, []), /* @__PURE__ */
|
|
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:
|
|
25
|
-
"data-testid":
|
|
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:
|
|
34
|
-
helperText:
|
|
33
|
+
localization: T,
|
|
34
|
+
helperText: h,
|
|
35
|
+
messages: w
|
|
35
36
|
}),
|
|
36
37
|
onChange: k,
|
|
37
38
|
slotProps: {
|
|
38
39
|
input: {
|
|
39
|
-
ref:
|
|
40
|
+
ref: s,
|
|
40
41
|
onMouseDown: (o) => {
|
|
41
42
|
!e && !t && a.open(o);
|
|
42
43
|
},
|
|
43
|
-
endAdornment: /* @__PURE__ */ r(
|
|
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:
|
|
67
|
+
label: g
|
|
67
68
|
})]
|
|
68
69
|
});
|
|
69
70
|
};
|
|
70
71
|
export {
|
|
71
|
-
|
|
72
|
+
O as TimePickerInput
|
|
72
73
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { OutlineErrorRounded as
|
|
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
|
|
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
|
-
},
|
|
14
|
-
const
|
|
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:
|
|
19
|
-
children:
|
|
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:
|
|
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
|
-
|
|
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
|
+
};
|