asma-ui-core 3.121.0 → 3.121.1
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/miscellaneous/StyledInputLabel.js +20 -17
- package/dist/datetime/components/date-picker/components/BaseDatePickerInput.js +107 -100
- package/dist/datetime/components/date-picker/components/DatePickerInputSingle.js +11 -10
- package/dist/datetime/components/date-picker/hooks/useDatePickerValidation.js +13 -13
- package/dist/datetime/components/time-picker/StyledTimePicker.js +96 -91
- package/dist/datetime/components/time-picker/TimePickerInput.js +50 -45
- package/dist/datetime/components/time-picker/components/HelperText.js +22 -22
- package/dist/helpers/HelperRow.js +13 -10
- package/dist/helpers/helperTextRoom.js +27 -15
- package/dist/helpers/useHelperRowBudget.js +15 -15
- package/dist/src/datetime/components/date-picker/components/BaseDatePickerInput.d.ts +1 -0
- package/dist/src/datetime/components/date-picker/types.d.ts +2 -0
- package/dist/src/datetime/components/time-picker/TimePickerInput.d.ts +1 -0
- package/dist/src/datetime/components/time-picker/components/HelperText.d.ts +6 -1
- package/dist/src/datetime/components/time-picker/types.d.ts +3 -0
- package/dist/src/helpers/helperTextRoom.d.ts +10 -0
- package/package.json +1 -1
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import { cn as
|
|
1
|
+
import { cn as d } from "../../helpers/cn.js";
|
|
2
2
|
import { fieldLabelAboveClass as x, floatingLabelClass as h, floatingLabelLayoutStyle as v } from "../inputs/field-styles.js";
|
|
3
3
|
import { useFormControlContext as L } from "./FormControlContext.js";
|
|
4
|
-
import { jsx as n, jsxs as
|
|
5
|
-
var g = ({ children:
|
|
6
|
-
const e = L(),
|
|
4
|
+
import { jsx as n, jsxs as f } from "react/jsx-runtime";
|
|
5
|
+
var g = ({ children: r, htmlFor: l, id: s, required: b, disabled: a, error: u, size: c, shrink: m, labelPlacement: p = "above", className: o }) => {
|
|
6
|
+
const e = L(), i = m ?? (e ? e.focused || e.filled : !1), t = b ?? e?.required ?? !1;
|
|
7
7
|
return p === "above" ? /* @__PURE__ */ n("div", {
|
|
8
|
-
className:
|
|
9
|
-
children: /* @__PURE__ */
|
|
10
|
-
htmlFor:
|
|
8
|
+
className: d(x({ disabled: a ?? e?.disabled }), o),
|
|
9
|
+
children: /* @__PURE__ */ f("label", {
|
|
10
|
+
htmlFor: l,
|
|
11
11
|
id: s ?? e?.labelId,
|
|
12
|
-
children: [
|
|
12
|
+
children: [r, t && /* @__PURE__ */ n("span", {
|
|
13
13
|
"aria-hidden": "true",
|
|
14
14
|
children: " *"
|
|
15
15
|
})]
|
|
16
16
|
})
|
|
17
|
-
}) : /* @__PURE__ */
|
|
18
|
-
htmlFor:
|
|
17
|
+
}) : /* @__PURE__ */ f("label", {
|
|
18
|
+
htmlFor: l,
|
|
19
19
|
id: s ?? e?.labelId,
|
|
20
|
-
className:
|
|
21
|
-
shrink:
|
|
20
|
+
className: d(h({
|
|
21
|
+
shrink: i,
|
|
22
22
|
focused: e?.focused,
|
|
23
|
-
error:
|
|
23
|
+
error: u ?? e?.error,
|
|
24
24
|
disabled: a ?? e?.disabled,
|
|
25
|
-
size:
|
|
26
|
-
}),
|
|
27
|
-
style: v(
|
|
28
|
-
|
|
25
|
+
size: c ?? e?.size
|
|
26
|
+
}), o),
|
|
27
|
+
style: i ? v(!0) : {
|
|
28
|
+
top: "1.25rem",
|
|
29
|
+
transform: "translateY(-50%)"
|
|
30
|
+
},
|
|
31
|
+
children: [r, t && " *"]
|
|
29
32
|
});
|
|
30
33
|
};
|
|
31
34
|
export {
|
|
@@ -1,133 +1,140 @@
|
|
|
1
|
-
import { fieldLabelAboveClass as
|
|
2
|
-
import { StyledInputField as
|
|
3
|
-
import { getValue as
|
|
4
|
-
import { DatePickerButton as
|
|
5
|
-
import { getTitleLabelling as
|
|
6
|
-
import { DATE_INPUT_FONT_FAMILY as
|
|
7
|
-
import { useDatePickerMask as
|
|
8
|
-
import { defaultDatePickerValidationMessages as
|
|
9
|
-
import { useEffect as
|
|
10
|
-
import { jsx as
|
|
11
|
-
import { isValid as
|
|
12
|
-
var
|
|
13
|
-
const { onClick: Y, inputClassName: B, dateFormat: a, selected: e, error:
|
|
1
|
+
import { fieldLabelAboveClass as V, fieldWidthStyle as ee } from "../../../../components/inputs/field-styles.js";
|
|
2
|
+
import { StyledInputField as te } from "../../../../components/inputs/input-field/StyledInputField.js";
|
|
3
|
+
import { getValue as x } from "../helpers.js";
|
|
4
|
+
import { DatePickerButton as re } from "./DatePickerButton.js";
|
|
5
|
+
import { getTitleLabelling as ae } from "../../../helpers/getTitleLabelling.js";
|
|
6
|
+
import { DATE_INPUT_FONT_FAMILY as le } from "../../../../helpers/inputMask.js";
|
|
7
|
+
import { useDatePickerMask as ie } from "../hooks/useDatePickerMask.js";
|
|
8
|
+
import { defaultDatePickerValidationMessages as oe, useDatePickerValidation as de } from "../hooks/useDatePickerValidation.js";
|
|
9
|
+
import { useEffect as A, useId as E, useRef as se, useState as H } from "react";
|
|
10
|
+
import { jsx as r, jsxs as b } from "react/jsx-runtime";
|
|
11
|
+
import { isValid as ne, parse as ce } from "date-fns";
|
|
12
|
+
var Te = (R) => {
|
|
13
|
+
const { onClick: Y, inputClassName: B, dateFormat: a, selected: e, error: L, helperText: O, errorText: S, onInputChange: y, hideCalendar: _, locale: l, disabledDays: s, label: h, title: v, inputAriaProps: j, readOnly: i, disallowPast: n, disallowFuture: c, validateOnCalendarClose: T, onValidatedOnce: C, hideDefaultHelperText: q, reserveHelperText: W, required: o, minDate: m, width: N = "s", ...p } = R, { validationError: z, handleValidation: u, errHelperText: U, clearValidation: P } = de(oe), { maskRef: G } = ie(), M = E(), k = E(), [t, w] = H(e ? x(e, a) : ""), g = se(!1), [I, J] = H({
|
|
14
14
|
selected: e,
|
|
15
15
|
dateFormat: a
|
|
16
16
|
});
|
|
17
|
-
(e !==
|
|
17
|
+
(e !== I.selected || a !== I.dateFormat) && (J({
|
|
18
18
|
selected: e,
|
|
19
19
|
dateFormat: a
|
|
20
|
-
}),
|
|
21
|
-
const
|
|
22
|
-
|
|
20
|
+
}), w(e ? x(e, a) : ""));
|
|
21
|
+
const K = l?.code?.startsWith("nb") ? "DD/MM/ÅÅÅÅ" : "DD/MM/YYYY", Q = q ? void 0 : K, F = !!(z || L), d = F ? S ?? U : O ?? Q;
|
|
22
|
+
A(() => {
|
|
23
23
|
if (!e) {
|
|
24
|
-
|
|
24
|
+
g.current || P(), g.current = !1;
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
value:
|
|
29
|
-
disabledDays:
|
|
30
|
-
localeCode:
|
|
31
|
-
disallowPast:
|
|
32
|
-
disallowFuture:
|
|
33
|
-
required:
|
|
34
|
-
minDate:
|
|
27
|
+
u({
|
|
28
|
+
value: x(e, a),
|
|
29
|
+
disabledDays: s,
|
|
30
|
+
localeCode: l?.code,
|
|
31
|
+
disallowPast: n,
|
|
32
|
+
disallowFuture: c,
|
|
33
|
+
required: o,
|
|
34
|
+
minDate: m
|
|
35
35
|
});
|
|
36
36
|
}, [
|
|
37
37
|
e,
|
|
38
38
|
a,
|
|
39
|
-
o,
|
|
40
|
-
r?.code,
|
|
41
39
|
s,
|
|
40
|
+
l?.code,
|
|
42
41
|
n,
|
|
43
|
-
i,
|
|
44
42
|
c,
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
o,
|
|
44
|
+
m,
|
|
45
|
+
u,
|
|
46
|
+
P
|
|
47
47
|
]);
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
48
|
+
const X = /\d/.test(t), Z = (D) => {
|
|
49
|
+
const f = D.target.value;
|
|
50
|
+
w(f.replace(/\D/g, "").length ? f : "");
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
A(() => {
|
|
53
|
+
T && (u({
|
|
54
54
|
value: t,
|
|
55
|
-
disabledDays:
|
|
56
|
-
localeCode:
|
|
57
|
-
disallowPast:
|
|
58
|
-
disallowFuture:
|
|
59
|
-
required:
|
|
60
|
-
minDate:
|
|
61
|
-
}),
|
|
55
|
+
disabledDays: s,
|
|
56
|
+
localeCode: l?.code,
|
|
57
|
+
disallowPast: n,
|
|
58
|
+
disallowFuture: c,
|
|
59
|
+
required: o,
|
|
60
|
+
minDate: m
|
|
61
|
+
}), C?.());
|
|
62
62
|
}, [
|
|
63
|
-
|
|
63
|
+
T,
|
|
64
64
|
t,
|
|
65
|
-
o,
|
|
66
|
-
r?.code,
|
|
67
65
|
s,
|
|
66
|
+
l?.code,
|
|
68
67
|
n,
|
|
69
|
-
i,
|
|
70
68
|
c,
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
o,
|
|
70
|
+
m,
|
|
71
|
+
C,
|
|
72
|
+
u
|
|
73
73
|
]);
|
|
74
|
-
const
|
|
75
|
-
|
|
74
|
+
const $ = () => {
|
|
75
|
+
const D = u({
|
|
76
76
|
value: t,
|
|
77
|
-
disabledDays:
|
|
78
|
-
localeCode:
|
|
79
|
-
disallowPast:
|
|
80
|
-
disallowFuture:
|
|
81
|
-
required:
|
|
82
|
-
minDate:
|
|
83
|
-
})
|
|
77
|
+
disabledDays: s,
|
|
78
|
+
localeCode: l?.code,
|
|
79
|
+
disallowPast: n,
|
|
80
|
+
disallowFuture: c,
|
|
81
|
+
required: o,
|
|
82
|
+
minDate: m
|
|
83
|
+
});
|
|
84
84
|
if (!t.replace(/\D/g, "").length) {
|
|
85
|
-
g?.(void 0);
|
|
85
|
+
g.current = !!e, y?.(void 0);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
if (D) return;
|
|
89
|
+
const f = ce(t, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
90
|
+
y?.(ne(f) ? f : void 0);
|
|
90
91
|
};
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
+
return /* @__PURE__ */ b("div", {
|
|
92
93
|
className: "cursor-default",
|
|
93
|
-
"data-field-width":
|
|
94
|
-
style:
|
|
94
|
+
"data-field-width": N,
|
|
95
|
+
style: ee(N),
|
|
96
|
+
"data-helper-room-box": "",
|
|
95
97
|
children: [
|
|
96
|
-
|
|
97
|
-
id:
|
|
98
|
-
className:
|
|
99
|
-
children:
|
|
98
|
+
v && /* @__PURE__ */ r("div", {
|
|
99
|
+
id: M,
|
|
100
|
+
className: V({ disabled: p.disabled }),
|
|
101
|
+
children: v
|
|
100
102
|
}),
|
|
101
|
-
|
|
102
|
-
className:
|
|
103
|
-
children: /* @__PURE__ */
|
|
104
|
-
htmlFor:
|
|
105
|
-
children: [
|
|
103
|
+
h && /* @__PURE__ */ r("div", {
|
|
104
|
+
className: V({ disabled: p.disabled }),
|
|
105
|
+
children: /* @__PURE__ */ b("label", {
|
|
106
|
+
htmlFor: k,
|
|
107
|
+
children: [h, o && /* @__PURE__ */ r("span", {
|
|
106
108
|
"aria-hidden": "true",
|
|
107
109
|
children: " *"
|
|
108
110
|
})]
|
|
109
111
|
})
|
|
110
112
|
}),
|
|
111
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ b("div", {
|
|
112
114
|
className: "flex items-start gap-1",
|
|
113
|
-
children: [/* @__PURE__ */
|
|
115
|
+
children: [/* @__PURE__ */ r("div", {
|
|
114
116
|
className: "min-w-0 flex-1",
|
|
115
|
-
children: /* @__PURE__ */
|
|
117
|
+
children: /* @__PURE__ */ r("div", {
|
|
116
118
|
className: "relative",
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
...
|
|
119
|
-
id:
|
|
120
|
-
readOnly:
|
|
121
|
-
"data-testid":
|
|
119
|
+
children: /* @__PURE__ */ r(te, {
|
|
120
|
+
...p,
|
|
121
|
+
id: k,
|
|
122
|
+
readOnly: i,
|
|
123
|
+
"data-testid": p.dataTest,
|
|
122
124
|
autoComplete: "off",
|
|
123
|
-
inputRef:
|
|
124
|
-
placeholder: !
|
|
125
|
+
inputRef: i ? void 0 : G,
|
|
126
|
+
placeholder: !i && !X ? " / / " : void 0,
|
|
125
127
|
size: "small",
|
|
126
|
-
value:
|
|
128
|
+
value: i ? t.replaceAll("/", ".") : t,
|
|
127
129
|
className: B,
|
|
128
|
-
error:
|
|
129
|
-
onBlur:
|
|
130
|
-
helperText:
|
|
130
|
+
error: F,
|
|
131
|
+
onBlur: i ? void 0 : $,
|
|
132
|
+
helperText: d == null || d === "" ? d : /* @__PURE__ */ r("span", {
|
|
133
|
+
className: "block truncate",
|
|
134
|
+
title: typeof d == "string" ? d : void 0,
|
|
135
|
+
children: d
|
|
136
|
+
}),
|
|
137
|
+
reserveHelperText: W,
|
|
131
138
|
slotProps: {
|
|
132
139
|
formHelperText: { sx: {
|
|
133
140
|
marginTop: "4px",
|
|
@@ -135,31 +142,31 @@ var xe = (H) => {
|
|
|
135
142
|
marginRight: 0
|
|
136
143
|
} },
|
|
137
144
|
htmlInput: {
|
|
138
|
-
"aria-required":
|
|
139
|
-
...
|
|
140
|
-
title:
|
|
141
|
-
titleId:
|
|
142
|
-
label:
|
|
143
|
-
inputAriaProps:
|
|
145
|
+
"aria-required": o ? !0 : void 0,
|
|
146
|
+
...ae({
|
|
147
|
+
title: v,
|
|
148
|
+
titleId: M,
|
|
149
|
+
label: h,
|
|
150
|
+
inputAriaProps: j
|
|
144
151
|
}),
|
|
145
|
-
...
|
|
152
|
+
...i ? {} : {
|
|
146
153
|
inputMode: "numeric",
|
|
147
|
-
style: { fontFamily:
|
|
154
|
+
style: { fontFamily: le }
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
},
|
|
151
|
-
onChange:
|
|
158
|
+
onChange: Z
|
|
152
159
|
})
|
|
153
160
|
})
|
|
154
|
-
}), !
|
|
161
|
+
}), !_ && !i && /* @__PURE__ */ r(re, {
|
|
155
162
|
onClick: Y,
|
|
156
|
-
disabled: !!
|
|
157
|
-
localeCode:
|
|
163
|
+
disabled: !!p.disabled,
|
|
164
|
+
localeCode: l?.code
|
|
158
165
|
})]
|
|
159
166
|
})
|
|
160
167
|
]
|
|
161
168
|
});
|
|
162
169
|
};
|
|
163
170
|
export {
|
|
164
|
-
|
|
171
|
+
Te as BaseDatePickerInput
|
|
165
172
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { BaseDatePickerInput as
|
|
2
|
-
import { jsx as
|
|
1
|
+
import { BaseDatePickerInput as y } from "./BaseDatePickerInput.js";
|
|
2
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
3
3
|
var q = ({ 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: h, disallowPast:
|
|
5
|
-
return /* @__PURE__ */ y
|
|
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: h, disallowPast: x, required: C, minDate: D, validateOnCalendarClose: T, onValidatedOnce: b, onInputChange: I, selected: P, title: f, hideDefaultHelperText: g, reserveHelperText: v, inputAriaProps: w, width: O } = e;
|
|
5
|
+
return /* @__PURE__ */ F(y, {
|
|
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: (k) =>
|
|
13
|
-
selected:
|
|
12
|
+
onInputChange: (k) => I?.(k),
|
|
13
|
+
selected: P,
|
|
14
14
|
error: !!i,
|
|
15
15
|
locale: n,
|
|
16
16
|
hideCalendar: o,
|
|
@@ -19,13 +19,14 @@ var q = ({ datePickerProps: e, onClick: a }) => {
|
|
|
19
19
|
label: d,
|
|
20
20
|
errorText: c,
|
|
21
21
|
disallowFuture: h,
|
|
22
|
-
disallowPast:
|
|
23
|
-
required:
|
|
22
|
+
disallowPast: x,
|
|
23
|
+
required: C,
|
|
24
24
|
minDate: D,
|
|
25
|
-
validateOnCalendarClose:
|
|
26
|
-
onValidatedOnce:
|
|
25
|
+
validateOnCalendarClose: T,
|
|
26
|
+
onValidatedOnce: b,
|
|
27
27
|
title: f,
|
|
28
28
|
hideDefaultHelperText: g,
|
|
29
|
+
reserveHelperText: v,
|
|
29
30
|
inputAriaProps: w,
|
|
30
31
|
width: O
|
|
31
32
|
});
|
|
@@ -15,7 +15,7 @@ var F = {
|
|
|
15
15
|
futureNotAllowed: "Future date is not allowed"
|
|
16
16
|
},
|
|
17
17
|
nb: {
|
|
18
|
-
required: "
|
|
18
|
+
required: "Obligatorisk",
|
|
19
19
|
minDate: "Sluttdato må være etter startdato",
|
|
20
20
|
invalidDay: "Ugyldig dag",
|
|
21
21
|
invalidMonth: "Ugyldig måned",
|
|
@@ -26,13 +26,13 @@ var F = {
|
|
|
26
26
|
pastNotAllowed: "Dato i fortiden er ikke tillatt",
|
|
27
27
|
futureNotAllowed: "Dato i fremtiden er ikke tillatt"
|
|
28
28
|
}
|
|
29
|
-
}, I = /^(\d{2})\/(\d{2})\/(\d{4})$/,
|
|
29
|
+
}, I = /^(\d{2})\/(\d{2})\/(\d{4})$/, $ = (D = F) => {
|
|
30
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: k, disallowFuture: w, required: o, minDate:
|
|
35
|
+
handleValidation: g(({ value: m, disabledDays: M, localeCode: h, disallowPast: k, disallowFuture: w, required: o, minDate: f }) => {
|
|
36
36
|
const a = D[h === "nb" ? "nb" : "en"];
|
|
37
37
|
if (!m.replace(/\D/g, "").length)
|
|
38
38
|
return e(!!o), t(o ? a.required : ""), !!o;
|
|
@@ -46,18 +46,18 @@ var F = {
|
|
|
46
46
|
return e(!0), t(a.invalidMonth), !0;
|
|
47
47
|
if (l < 1900 || l > 2100)
|
|
48
48
|
return e(!0), t(a.invalidYear), !0;
|
|
49
|
-
const
|
|
50
|
-
if (!(
|
|
49
|
+
const s = new Date(l, d - 1, i);
|
|
50
|
+
if (!(s.getFullYear() === l && s.getMonth() === d - 1 && s.getDate() === i))
|
|
51
51
|
return e(!0), t(a.invalidDate), !0;
|
|
52
|
-
const
|
|
53
|
-
if (!U(
|
|
52
|
+
const u = x(`${r[1]}/${r[2]}/${r[3]}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
53
|
+
if (!U(u))
|
|
54
54
|
return e(!0), t(a.invalidDate), !0;
|
|
55
|
-
if (
|
|
55
|
+
if (f && b(u) <= b(f))
|
|
56
56
|
return e(!0), t(a.minDate), !0;
|
|
57
|
-
const
|
|
58
|
-
return
|
|
59
|
-
parsedDate:
|
|
60
|
-
disabledDays:
|
|
57
|
+
const v = Y(M, k, w);
|
|
58
|
+
return v.length && N({
|
|
59
|
+
parsedDate: u,
|
|
60
|
+
disabledDays: v
|
|
61
61
|
}) ? (t(a.dateDisabled), e(!0), !0) : (n(), !1);
|
|
62
62
|
}, [n, D]),
|
|
63
63
|
errHelperText: p,
|
|
@@ -66,5 +66,5 @@ var F = {
|
|
|
66
66
|
};
|
|
67
67
|
export {
|
|
68
68
|
F as defaultDatePickerValidationMessages,
|
|
69
|
-
|
|
69
|
+
$ as useDatePickerValidation
|
|
70
70
|
};
|
|
@@ -1,120 +1,125 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { isOverlayBackEnabled as
|
|
3
|
-
import { useIsMobileView as
|
|
4
|
-
import { StyledDrawer as
|
|
5
|
-
import { useBackNavigationClose as
|
|
6
|
-
import { usePopupState as
|
|
7
|
-
import { ClickAwayListener as
|
|
8
|
-
import { isBeforeMinTime as
|
|
9
|
-
import { TimePickerPanel as
|
|
10
|
-
import { TimePickerPopper as
|
|
11
|
-
import { getTimeFromValue as
|
|
12
|
-
import { timePickerWidthProps as
|
|
13
|
-
import { TimePickerInput as
|
|
14
|
-
import { useEffect as
|
|
15
|
-
import { jsx as
|
|
16
|
-
import { format as
|
|
17
|
-
var
|
|
18
|
-
const { value:
|
|
1
|
+
import { cn as L } from "../../../helpers/cn.js";
|
|
2
|
+
import { isOverlayBackEnabled as K, useBackCloses as W } from "../../../hooks/useBackCloses.hook.js";
|
|
3
|
+
import { useIsMobileView as z } from "../../hooks/useWindowWidthSize.hook.js";
|
|
4
|
+
import { StyledDrawer as G } from "../../../components/navigation/drawer/StyledDrawer.js";
|
|
5
|
+
import { useBackNavigationClose as J } from "../../hooks/useBackNavigationClose.hook.js";
|
|
6
|
+
import { usePopupState as Q } from "../../../hooks/usePopupState.js";
|
|
7
|
+
import { ClickAwayListener as R } from "../../../components/mui-compat/ClickAwayListener.js";
|
|
8
|
+
import { isBeforeMinTime as T } from "./helpers/minTime.js";
|
|
9
|
+
import { TimePickerPanel as U } from "./components/TimePickerPanel.js";
|
|
10
|
+
import { TimePickerPopper as X } from "./TimePickerPopper.js";
|
|
11
|
+
import { getTimeFromValue as V } from "./helpers/getTimeFromValue.js";
|
|
12
|
+
import { timePickerWidthProps as M } from "./helpers/timePickerWidth.js";
|
|
13
|
+
import { TimePickerInput as Y } from "./TimePickerInput.js";
|
|
14
|
+
import { useEffect as Z, useState as b } from "react";
|
|
15
|
+
import { jsx as n, jsxs as j } from "react/jsx-runtime";
|
|
16
|
+
import { format as S, isBefore as _, isValid as $ } from "date-fns";
|
|
17
|
+
var ve = (i) => {
|
|
18
|
+
const { value: s, onSelect: r, notBeforeTime: v, minTime: u, required: w } = i, o = Q({
|
|
19
19
|
variant: "popper",
|
|
20
20
|
popupId: "time-picker-popper"
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
active:
|
|
24
|
-
requestClose:
|
|
25
|
-
}),
|
|
26
|
-
open:
|
|
27
|
-
onClose:
|
|
21
|
+
}), f = z();
|
|
22
|
+
W({
|
|
23
|
+
active: o.isOpen,
|
|
24
|
+
requestClose: o.close
|
|
25
|
+
}), J({
|
|
26
|
+
open: f && o.isOpen && !K(),
|
|
27
|
+
onClose: o.close
|
|
28
28
|
});
|
|
29
|
-
const { isOpen:
|
|
30
|
-
|
|
31
|
-
if (!
|
|
32
|
-
const e = (
|
|
33
|
-
|
|
29
|
+
const { isOpen: x, anchorEl: g, close: k } = o;
|
|
30
|
+
Z(() => {
|
|
31
|
+
if (!x || f) return;
|
|
32
|
+
const e = (t) => {
|
|
33
|
+
g?.contains(document.activeElement) && (t.key === "Escape" ? (t.preventDefault(), t.stopPropagation(), k()) : t.key === "Tab" && k());
|
|
34
34
|
};
|
|
35
35
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
36
36
|
}, [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
x,
|
|
38
|
+
g,
|
|
39
|
+
k,
|
|
40
|
+
f
|
|
41
41
|
]);
|
|
42
|
-
const
|
|
42
|
+
const B = s ? S(s, "HH:mm") : "", [y, p] = b(B), [E, a] = b(!1), [C, c] = b(!1), l = E ? y : B, d = (e) => !e || !v || !$(v) || !_(e, v), m = l.length === 5 ? V(l, s) : null, I = !C || l === "" || m !== null, A = !C || !m || d(m), O = !!w && C && l === "", N = (e) => {
|
|
43
43
|
if (e === "") return !0;
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
},
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
const h =
|
|
44
|
+
const t = V(e, s);
|
|
45
|
+
return t !== null && d(t);
|
|
46
|
+
}, q = (e) => {
|
|
47
|
+
const t = e.target.value;
|
|
48
|
+
if (a(!0), p(t), (O || N(t)) && c(!1), t.length !== 5) return;
|
|
49
|
+
const h = V(t, s);
|
|
50
50
|
if (!h) {
|
|
51
|
-
|
|
51
|
+
r(void 0);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
if (e &&
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
|
|
54
|
+
T(h, u) || (d(h) ? (r(h), a(!1), o.close()) : r(void 0));
|
|
55
|
+
}, D = (e) => {
|
|
56
|
+
if (e && T(e, u)) return;
|
|
57
|
+
const t = d(e);
|
|
58
|
+
if (c(!t), t) {
|
|
59
|
+
r(e), p(e ? S(e, "HH:mm") : ""), a(!1);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
r(void 0), p(e ? S(e, "HH:mm") : ""), a(!0);
|
|
63
|
+
}, F = () => {
|
|
64
|
+
if (w && l === "" && !o.isOpen) {
|
|
65
|
+
E && r(void 0), c(!0);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
E && (m && T(m, u) ? a(!1) : y === "" ? r(void 0) : N(y) || c(!0));
|
|
69
|
+
}, H = () => {
|
|
70
|
+
r(void 0), p(""), a(!1), c(!!w);
|
|
71
|
+
}, P = /* @__PURE__ */ n(Y, {
|
|
72
|
+
...i,
|
|
73
|
+
popupState: o,
|
|
74
|
+
localValue: l,
|
|
75
|
+
isValidTime: I,
|
|
76
|
+
isValidEndTime: A,
|
|
77
|
+
isMissingTime: O,
|
|
78
|
+
handleChange: q,
|
|
79
|
+
handleBlur: F
|
|
75
80
|
});
|
|
76
|
-
return
|
|
77
|
-
className:
|
|
78
|
-
...
|
|
79
|
-
children: [/* @__PURE__ */
|
|
81
|
+
return i.disabled || i.readOnly ? P : f ? /* @__PURE__ */ j("div", {
|
|
82
|
+
className: L("relative h-auto", typeof i.width == "number" && "w-auto"),
|
|
83
|
+
...M(i.width),
|
|
84
|
+
children: [/* @__PURE__ */ n("div", {
|
|
80
85
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
81
|
-
children:
|
|
82
|
-
}), /* @__PURE__ */
|
|
86
|
+
children: P
|
|
87
|
+
}), /* @__PURE__ */ n(G, {
|
|
83
88
|
anchor: "bottom",
|
|
84
|
-
open:
|
|
85
|
-
onClose:
|
|
86
|
-
anchorEl:
|
|
89
|
+
open: o.isOpen,
|
|
90
|
+
onClose: o.close,
|
|
91
|
+
anchorEl: o.anchorEl,
|
|
87
92
|
registerBackClose: !1,
|
|
88
|
-
children: /* @__PURE__ */
|
|
93
|
+
children: /* @__PURE__ */ n("div", {
|
|
89
94
|
className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
|
|
90
|
-
children: /* @__PURE__ */
|
|
91
|
-
dataTest:
|
|
92
|
-
value:
|
|
93
|
-
minTime:
|
|
94
|
-
onSelect:
|
|
95
|
-
handleClear:
|
|
96
|
-
onConfirm:
|
|
95
|
+
children: /* @__PURE__ */ n(U, {
|
|
96
|
+
dataTest: i.dataTest,
|
|
97
|
+
value: s,
|
|
98
|
+
minTime: u,
|
|
99
|
+
onSelect: D,
|
|
100
|
+
handleClear: H,
|
|
101
|
+
onConfirm: o.close
|
|
97
102
|
})
|
|
98
103
|
})
|
|
99
104
|
})]
|
|
100
|
-
}) : /* @__PURE__ */
|
|
105
|
+
}) : /* @__PURE__ */ n(R, {
|
|
101
106
|
mouseEvent: "onMouseDown",
|
|
102
|
-
onClickAway:
|
|
103
|
-
children: /* @__PURE__ */
|
|
104
|
-
className:
|
|
105
|
-
...
|
|
106
|
-
children: [/* @__PURE__ */
|
|
107
|
+
onClickAway: o.close,
|
|
108
|
+
children: /* @__PURE__ */ j("div", {
|
|
109
|
+
className: L("relative h-auto", typeof i.width == "number" && "w-auto"),
|
|
110
|
+
...M(i.width),
|
|
111
|
+
children: [/* @__PURE__ */ n("div", {
|
|
107
112
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
108
|
-
children:
|
|
109
|
-
}),
|
|
110
|
-
...
|
|
111
|
-
popupState:
|
|
112
|
-
handleClear:
|
|
113
|
-
onSelect:
|
|
113
|
+
children: P
|
|
114
|
+
}), o.isOpen && /* @__PURE__ */ n(X, {
|
|
115
|
+
...i,
|
|
116
|
+
popupState: o,
|
|
117
|
+
handleClear: H,
|
|
118
|
+
onSelect: D
|
|
114
119
|
})]
|
|
115
120
|
})
|
|
116
121
|
});
|
|
117
122
|
};
|
|
118
123
|
export {
|
|
119
|
-
|
|
124
|
+
ve as StyledTimePicker
|
|
120
125
|
};
|
|
@@ -1,68 +1,73 @@
|
|
|
1
|
-
import { ClockOutlineIcon as
|
|
2
|
-
import { fieldLabelAboveClass as
|
|
3
|
-
import { StyledInputField as
|
|
4
|
-
import { getTitleLabelling as
|
|
5
|
-
import { useInputMask as
|
|
6
|
-
import { HelperText as
|
|
7
|
-
import { timePickerWidthProps as
|
|
8
|
-
import { useEffect as
|
|
9
|
-
import { jsx as
|
|
10
|
-
var
|
|
11
|
-
const { placeholder:
|
|
1
|
+
import { ClockOutlineIcon as y } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
|
|
2
|
+
import { fieldLabelAboveClass as A } from "../../../components/inputs/field-styles.js";
|
|
3
|
+
import { StyledInputField as M } from "../../../components/inputs/input-field/StyledInputField.js";
|
|
4
|
+
import { getTitleLabelling as R } from "../../helpers/getTitleLabelling.js";
|
|
5
|
+
import { useInputMask as w } from "../../../helpers/inputMask.js";
|
|
6
|
+
import { HelperText as H, defaultTimePickerHelperMessages as V } from "./components/HelperText.js";
|
|
7
|
+
import { timePickerWidthProps as W } from "./helpers/timePickerWidth.js";
|
|
8
|
+
import { useEffect as j, useId as q, useRef as z } from "react";
|
|
9
|
+
import { jsx as i, jsxs as B } from "react/jsx-runtime";
|
|
10
|
+
var U = (x) => {
|
|
11
|
+
const { placeholder: g, disabled: e, inputClassName: T, dataTest: n, width: t, error: m, helperText: k, label: p, locale: C = "en", popupState: o, handleChange: I, handleBlur: b, isValidTime: d, isValidEndTime: u, isMissingTime: c, localValue: P, title: l, required: v, readOnly: a, inputAriaProps: E } = x, N = w({
|
|
12
12
|
mask: "xx:xx",
|
|
13
13
|
maskChar: "x",
|
|
14
14
|
showMask: !1
|
|
15
|
-
}),
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
}, []), /* @__PURE__ */
|
|
19
|
-
...
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
}), f = !d || !u || !!c || !!m, s = z(null), h = q();
|
|
16
|
+
return j(() => {
|
|
17
|
+
s.current && o.setAnchorEl(s.current);
|
|
18
|
+
}, []), /* @__PURE__ */ B("div", {
|
|
19
|
+
...W(t),
|
|
20
|
+
"data-helper-room-box": "",
|
|
21
|
+
children: [l && /* @__PURE__ */ i("div", {
|
|
22
|
+
id: h,
|
|
23
|
+
className: A({ disabled: e }),
|
|
23
24
|
children: l
|
|
24
|
-
}), /* @__PURE__ */
|
|
25
|
-
inputRef:
|
|
25
|
+
}), /* @__PURE__ */ i(M, {
|
|
26
|
+
inputRef: N,
|
|
26
27
|
autoComplete: "off",
|
|
27
28
|
type: "text",
|
|
28
|
-
dataTest:
|
|
29
|
-
"data-testid":
|
|
30
|
-
placeholder:
|
|
29
|
+
dataTest: n,
|
|
30
|
+
"data-testid": n,
|
|
31
|
+
placeholder: g,
|
|
31
32
|
size: "small",
|
|
32
|
-
error:
|
|
33
|
-
helperText: /* @__PURE__ */
|
|
33
|
+
error: f,
|
|
34
|
+
helperText: /* @__PURE__ */ i(H, {
|
|
34
35
|
isValidTime: d,
|
|
35
|
-
isValidEndTime:
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
isValidEndTime: u,
|
|
37
|
+
isMissingTime: c,
|
|
38
|
+
error: !!m,
|
|
39
|
+
localization: C,
|
|
38
40
|
helperText: k,
|
|
39
|
-
messages:
|
|
41
|
+
messages: V
|
|
40
42
|
}),
|
|
41
|
-
onChange:
|
|
42
|
-
onBlur:
|
|
43
|
+
onChange: I,
|
|
44
|
+
onBlur: b,
|
|
43
45
|
slotProps: {
|
|
44
|
-
htmlInput:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
htmlInput: {
|
|
47
|
+
"aria-required": v ? !0 : void 0,
|
|
48
|
+
...R({
|
|
49
|
+
title: l,
|
|
50
|
+
titleId: h,
|
|
51
|
+
label: p,
|
|
52
|
+
inputAriaProps: E
|
|
53
|
+
})
|
|
54
|
+
},
|
|
50
55
|
input: {
|
|
51
|
-
ref:
|
|
56
|
+
ref: s,
|
|
52
57
|
onClick: (r) => {
|
|
53
|
-
!e && !a &&
|
|
58
|
+
!e && !a && o.open(r);
|
|
54
59
|
},
|
|
55
|
-
endAdornment: /* @__PURE__ */
|
|
60
|
+
endAdornment: /* @__PURE__ */ i(y, {
|
|
56
61
|
width: 24,
|
|
57
62
|
height: 24,
|
|
58
63
|
className: e ? "text-delta-300" : "text-delta-700",
|
|
59
64
|
onClick: (r) => {
|
|
60
|
-
r.stopPropagation(), !e && !a &&
|
|
65
|
+
r.stopPropagation(), !e && !a && o.open(r);
|
|
61
66
|
}
|
|
62
67
|
})
|
|
63
68
|
},
|
|
64
69
|
formHelperText: {
|
|
65
|
-
className:
|
|
70
|
+
className: f ? "ml-0 mr-[14px] mt-1 leading-[23.24px]" : "mx-[14px] mt-1 leading-[23.24px]",
|
|
66
71
|
hideErrorIcon: !0
|
|
67
72
|
}
|
|
68
73
|
},
|
|
@@ -74,11 +79,11 @@ var K = (f) => {
|
|
|
74
79
|
} : void 0,
|
|
75
80
|
disabled: e,
|
|
76
81
|
readOnly: a,
|
|
77
|
-
className:
|
|
82
|
+
className: T,
|
|
78
83
|
label: p
|
|
79
84
|
})]
|
|
80
85
|
});
|
|
81
86
|
};
|
|
82
87
|
export {
|
|
83
|
-
|
|
88
|
+
U as TimePickerInput
|
|
84
89
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { OutlineErrorRounded as
|
|
3
|
-
import { jsx as
|
|
4
|
-
var
|
|
1
|
+
import { cn as m } from "../../../../helpers/cn.js";
|
|
2
|
+
import { OutlineErrorRounded as c } from "../../../shared-components/OutlineErrorRounded.js";
|
|
3
|
+
import { jsx as a, jsxs as u } from "react/jsx-runtime";
|
|
4
|
+
var f = {
|
|
5
5
|
invalid: {
|
|
6
6
|
en: "Invalid time format",
|
|
7
7
|
no: "Ugyldig tidsformat"
|
|
@@ -9,35 +9,35 @@ var c = {
|
|
|
9
9
|
afterStartTime: {
|
|
10
10
|
en: "Must be after start time",
|
|
11
11
|
no: "Må være etter starttid"
|
|
12
|
+
},
|
|
13
|
+
required: {
|
|
14
|
+
en: "Required",
|
|
15
|
+
no: "Obligatorisk"
|
|
12
16
|
}
|
|
13
|
-
},
|
|
14
|
-
const
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
className: "flex items-start gap-1",
|
|
17
|
-
children: [/* @__PURE__ */
|
|
18
|
-
className:
|
|
19
|
-
children:
|
|
17
|
+
}, g = ({ isValidTime: n, isValidEndTime: i, isMissingTime: l, localization: r = "en", error: s, helperText: t, messages: e = f }) => {
|
|
18
|
+
const d = !n || !i || !!l || !!s, o = n ? i ? s && t != null ? t : l ? (e.required ?? f.required)[r] : t : e.afterStartTime[r] : e.invalid[r];
|
|
19
|
+
return /* @__PURE__ */ u("span", {
|
|
20
|
+
className: "flex min-w-0 items-start gap-1",
|
|
21
|
+
children: [/* @__PURE__ */ a("span", {
|
|
22
|
+
className: m("flex", "transform-gpu transition-all duration-300 ease-in-out"),
|
|
23
|
+
children: d && /* @__PURE__ */ a(c, {
|
|
20
24
|
width: 20,
|
|
21
25
|
height: 20,
|
|
22
26
|
color: "var(--colors-error-500)"
|
|
23
27
|
})
|
|
24
|
-
}), /* @__PURE__ */
|
|
25
|
-
className: "flex-1
|
|
28
|
+
}), /* @__PURE__ */ a("span", {
|
|
29
|
+
className: "min-w-0 flex-1 truncate pt-[2px] text-left leading-4",
|
|
30
|
+
title: typeof o == "string" ? o : void 0,
|
|
26
31
|
style: {
|
|
27
|
-
display: "-webkit-box",
|
|
28
|
-
WebkitLineClamp: 2,
|
|
29
|
-
WebkitBoxOrient: "vertical",
|
|
30
|
-
overflow: "hidden",
|
|
31
|
-
maxHeight: 32,
|
|
32
32
|
fontFamily: "roboto, sans-serif",
|
|
33
|
-
color:
|
|
33
|
+
color: d ? "var(--colors-error-500)" : "var(--colors-delta-600)",
|
|
34
34
|
fontSize: 14
|
|
35
35
|
},
|
|
36
|
-
children:
|
|
36
|
+
children: o
|
|
37
37
|
})]
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
g as HelperText,
|
|
42
|
+
f as defaultTimePickerHelperMessages
|
|
43
43
|
};
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { ErrorOutlineIcon as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { jsx as e, jsxs as
|
|
5
|
-
var
|
|
6
|
-
ref:
|
|
1
|
+
import { cn as l } from "./cn.js";
|
|
2
|
+
import { ErrorOutlineIcon as p } from "../components/icons/error-outline-icon/ErrorOutlineIcon.js";
|
|
3
|
+
import { forwardRef as c } from "react";
|
|
4
|
+
import { jsx as e, jsxs as x } from "react/jsx-runtime";
|
|
5
|
+
var g = c(({ id: t, role: i, error: r, message: m, hideErrorIcon: a, className: o, style: n }, s) => /* @__PURE__ */ x("div", {
|
|
6
|
+
ref: s,
|
|
7
7
|
id: t,
|
|
8
8
|
role: i,
|
|
9
|
-
className:
|
|
9
|
+
className: l("flex min-h-[24px] gap-1 pt-1 text-sm leading-5 tracking-[0.03333em]", r ? "text-error-500" : "text-delta-600", o),
|
|
10
10
|
style: n,
|
|
11
|
-
children: [r && !
|
|
11
|
+
children: [r && !a && /* @__PURE__ */ e(p, {
|
|
12
12
|
width: 20,
|
|
13
13
|
height: 20,
|
|
14
14
|
className: "min-w-5 shrink-0"
|
|
15
|
-
}), /* @__PURE__ */ e("span", {
|
|
15
|
+
}), /* @__PURE__ */ e("span", {
|
|
16
|
+
className: "min-w-0",
|
|
17
|
+
children: m
|
|
18
|
+
})]
|
|
16
19
|
}));
|
|
17
20
|
export {
|
|
18
|
-
|
|
21
|
+
g as HelperRow
|
|
19
22
|
};
|
|
@@ -1,34 +1,46 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
1
|
+
var l = 14, g = 8, p = 24;
|
|
2
|
+
function a(t, n) {
|
|
3
3
|
let o = Number.POSITIVE_INFINITY;
|
|
4
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 -
|
|
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 - g));
|
|
6
6
|
return o;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function s(t, n, o) {
|
|
9
9
|
if (!(n > 0)) return;
|
|
10
|
-
const e = n -
|
|
10
|
+
const e = n - l, i = o - t - l;
|
|
11
11
|
return Number.isFinite(i) && i > e ? Math.floor(i) : void 0;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function c(t) {
|
|
14
14
|
const { left: n } = t.getBoundingClientRect(), o = Number.parseFloat(getComputedStyle(t).paddingRight) || 0;
|
|
15
15
|
return n + t.clientLeft + t.clientWidth - o;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
for (let n = t.parentElement; n; n = n.parentElement) if (getComputedStyle(n).overflowX !== "visible") return
|
|
17
|
+
function R(t) {
|
|
18
|
+
for (let n = t.parentElement; n; n = n.parentElement) if (getComputedStyle(n).overflowX !== "visible") return c(n);
|
|
19
19
|
return Number.POSITIVE_INFINITY;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var h = "[data-helper-room-box]";
|
|
22
|
+
function d(t) {
|
|
23
|
+
const n = t.closest(h);
|
|
24
|
+
let o = n ?? t;
|
|
25
|
+
const e = [];
|
|
26
|
+
for (let i = o.parentElement; i; o = i, i = i.parentElement)
|
|
27
|
+
if (e.push(...Array.from(i.children).filter((r) => r !== o)), !n || !i.parentElement || c(i) > o.getBoundingClientRect().right + 0.5) return {
|
|
28
|
+
container: i,
|
|
29
|
+
neighbours: e
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function m(t, n) {
|
|
33
|
+
const o = d(t);
|
|
23
34
|
if (!o) return;
|
|
24
|
-
const e = t.getBoundingClientRect(), i = n.getBoundingClientRect().top,
|
|
35
|
+
const e = t.getBoundingClientRect(), i = n.getBoundingClientRect().top, r = {
|
|
25
36
|
top: i,
|
|
26
|
-
bottom: i +
|
|
37
|
+
bottom: i + p,
|
|
27
38
|
left: e.left,
|
|
28
39
|
right: e.right
|
|
29
|
-
},
|
|
30
|
-
return
|
|
40
|
+
}, u = Math.min(c(o.container), R(t), a(r, o.neighbours.map((f) => f.getBoundingClientRect())));
|
|
41
|
+
return s(e.left, e.width, u);
|
|
31
42
|
}
|
|
32
43
|
export {
|
|
33
|
-
|
|
44
|
+
d as findHelperRoom,
|
|
45
|
+
m as measureHelperRowMaxWidth
|
|
34
46
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { measureHelperRowMaxWidth as
|
|
2
|
-
import { useCallback as
|
|
3
|
-
function
|
|
4
|
-
const n =
|
|
5
|
-
const e = n.current, t =
|
|
6
|
-
|
|
7
|
-
}, [
|
|
8
|
-
return
|
|
9
|
-
const e = n.current?.
|
|
10
|
-
if (!
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
}, [
|
|
1
|
+
import { findHelperRoom as l, measureHelperRowMaxWidth as m } from "./helperTextRoom.js";
|
|
2
|
+
import { useCallback as a, useEffect as R, useLayoutEffect as w, useRef as f, useState as p } from "react";
|
|
3
|
+
function b(o) {
|
|
4
|
+
const n = f(null), c = f(null), [u, d] = p(), s = a(() => {
|
|
5
|
+
const e = n.current, t = c.current, r = o && e && t ? m(e, t) : void 0;
|
|
6
|
+
d((i) => i === r ? i : r);
|
|
7
|
+
}, [o]);
|
|
8
|
+
return w(s), R(() => {
|
|
9
|
+
const e = n.current, t = e ? l(e)?.container : void 0;
|
|
10
|
+
if (!o || !t || typeof ResizeObserver > "u") return;
|
|
11
|
+
const r = new ResizeObserver(s);
|
|
12
|
+
return r.observe(t), () => r.disconnect();
|
|
13
|
+
}, [o, s]), {
|
|
14
14
|
fieldRef: n,
|
|
15
|
-
rowRef:
|
|
15
|
+
rowRef: c,
|
|
16
16
|
rowStyle: u != null ? {
|
|
17
17
|
width: "max-content",
|
|
18
18
|
maxWidth: u
|
|
@@ -20,5 +20,5 @@ function x(r) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
b as useHelperRowBudget
|
|
24
24
|
};
|
|
@@ -29,6 +29,8 @@ export interface DatePickerSingleFieldProps {
|
|
|
29
29
|
disallowPast?: boolean;
|
|
30
30
|
disallowFuture?: boolean;
|
|
31
31
|
hideDefaultHelperText?: boolean;
|
|
32
|
+
/** Keeps the one-line helper row even without a helper or error, so an error never moves the layout. */
|
|
33
|
+
reserveHelperText?: boolean;
|
|
32
34
|
/**
|
|
33
35
|
* Extra ARIA attributes for the text input (e.g. `aria-label`, `aria-required`). Without them the
|
|
34
36
|
* input is named by `title`, which is otherwise plain text above the field.
|
|
@@ -8,11 +8,16 @@ export interface TimePickerHelperMessages {
|
|
|
8
8
|
en: string;
|
|
9
9
|
no: string;
|
|
10
10
|
};
|
|
11
|
+
required?: {
|
|
12
|
+
en: string;
|
|
13
|
+
no: string;
|
|
14
|
+
};
|
|
11
15
|
}
|
|
12
|
-
export declare const defaultTimePickerHelperMessages: TimePickerHelperMessages
|
|
16
|
+
export declare const defaultTimePickerHelperMessages: Required<TimePickerHelperMessages>;
|
|
13
17
|
export declare const HelperText: React.FC<{
|
|
14
18
|
isValidTime: boolean;
|
|
15
19
|
isValidEndTime: boolean;
|
|
20
|
+
isMissingTime?: boolean;
|
|
16
21
|
error?: boolean;
|
|
17
22
|
localization: 'en' | 'no';
|
|
18
23
|
helperText?: ReactNode;
|
|
@@ -14,7 +14,10 @@ export interface StyledTimePickerProps {
|
|
|
14
14
|
/** Field width pattern step; defaults to XS. A number (a fixed `px` width) is deprecated: use a step. */
|
|
15
15
|
width?: FieldWidth | number;
|
|
16
16
|
error?: boolean;
|
|
17
|
+
/** Shown under the field; with `error`, it replaces the picker's own message (form errors win). */
|
|
17
18
|
helperText?: ReactNode;
|
|
19
|
+
/** An empty field shows "Required" after blur or the eraser, and the input is `aria-required`. */
|
|
20
|
+
required?: boolean;
|
|
18
21
|
label?: string;
|
|
19
22
|
locale?: 'no' | 'en';
|
|
20
23
|
title?: string;
|
|
@@ -6,4 +6,14 @@ export interface EdgeBox {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function blockingLeftEdge(band: EdgeBox, neighbours: EdgeBox[]): number;
|
|
8
8
|
export declare function helperRowMaxWidth(fieldLeft: number, fieldWidth: number, limitRight: number): number | undefined;
|
|
9
|
+
interface HelperRoom {
|
|
10
|
+
container: HTMLElement;
|
|
11
|
+
neighbours: Element[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A plain field measures against its parent. A marked picker climbs past the wrappers that end where
|
|
15
|
+
* it ends, to the first ancestor with room to its right, collecting every sibling on the way.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findHelperRoom(field: HTMLElement): HelperRoom | undefined;
|
|
9
18
|
export declare function measureHelperRowMaxWidth(field: HTMLElement, helperRow: HTMLElement): number | undefined;
|
|
19
|
+
export {};
|