asma-ui-core 3.132.0 → 3.133.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/asma-ui-core.css +1 -1
- package/dist/datetime/components/time-picker/StyledTimePicker.js +102 -88
- package/dist/datetime/components/time-picker/StyledTimePicker.module.js +6 -6
- package/dist/datetime/components/time-picker/TimePickerInput.js +44 -44
- package/dist/datetime/components/time-picker/TimePickerPopper.js +22 -20
- package/dist/datetime/components/time-picker/components/TimePickerBody.js +23 -19
- package/dist/datetime/components/time-picker/components/TimePickerColumn.js +25 -18
- package/dist/datetime/components/time-picker/components/TimePickerPanel.js +13 -11
- package/dist/datetime/components/time-picker/helpers/disabledTime.js +13 -0
- package/dist/src/datetime/components/time-picker/TimePickerInput.d.ts +2 -0
- package/dist/src/datetime/components/time-picker/components/TimePickerPanel.d.ts +4 -0
- package/dist/src/datetime/components/time-picker/helpers/disabledTime.d.ts +35 -0
- package/dist/src/datetime/components/time-picker/types.d.ts +20 -0
- package/package.json +1 -1
|
@@ -1,125 +1,139 @@
|
|
|
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 {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { cn as I } from "../../../helpers/cn.js";
|
|
2
|
+
import { isOverlayBackEnabled as J, useBackCloses as Q } from "../../../hooks/useBackCloses.hook.js";
|
|
3
|
+
import { useIsMobileView as U } from "../../hooks/useWindowWidthSize.hook.js";
|
|
4
|
+
import { StyledDrawer as X } from "../../../components/navigation/drawer/StyledDrawer.js";
|
|
5
|
+
import { useBackNavigationClose as Y } from "../../hooks/useBackNavigationClose.hook.js";
|
|
6
|
+
import { usePopupState as Z } from "../../../hooks/usePopupState.js";
|
|
7
|
+
import { ClickAwayListener as _ } from "../../../components/mui-compat/ClickAwayListener.js";
|
|
8
|
+
import { isBeforeMinTime as V } from "./helpers/minTime.js";
|
|
9
|
+
import { isTimeRejected as A } from "./helpers/disabledTime.js";
|
|
10
|
+
import { TimePickerPanel as $ } from "./components/TimePickerPanel.js";
|
|
11
|
+
import { TimePickerPopper as ee } from "./TimePickerPopper.js";
|
|
12
|
+
import { getTimeFromValue as S } from "./helpers/getTimeFromValue.js";
|
|
13
|
+
import { timePickerWidthProps as R } from "./helpers/timePickerWidth.js";
|
|
14
|
+
import { TimePickerInput as oe } from "./TimePickerInput.js";
|
|
15
|
+
import { useEffect as ie, useState as x } from "react";
|
|
16
|
+
import { jsx as n, jsxs as q } from "react/jsx-runtime";
|
|
17
|
+
import { format as g, isBefore as te, isValid as re } from "date-fns";
|
|
18
|
+
var Te = (t) => {
|
|
19
|
+
const { value: s, onSelect: r, notBeforeTime: k, minTime: f, required: w, isTimeDisabled: y, disabledTimeReason: B } = t, i = Z({
|
|
19
20
|
variant: "popper",
|
|
20
21
|
popupId: "time-picker-popper"
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
active:
|
|
24
|
-
requestClose:
|
|
25
|
-
}),
|
|
26
|
-
open:
|
|
27
|
-
onClose:
|
|
22
|
+
}), d = U();
|
|
23
|
+
Q({
|
|
24
|
+
active: i.isOpen,
|
|
25
|
+
requestClose: i.close
|
|
26
|
+
}), Y({
|
|
27
|
+
open: d && i.isOpen && !J(),
|
|
28
|
+
onClose: i.close
|
|
28
29
|
});
|
|
29
|
-
const { isOpen:
|
|
30
|
-
|
|
31
|
-
if (!
|
|
32
|
-
const e = (
|
|
33
|
-
|
|
30
|
+
const { isOpen: O, anchorEl: D, close: E } = i;
|
|
31
|
+
ie(() => {
|
|
32
|
+
if (!O || d) return;
|
|
33
|
+
const e = (o) => {
|
|
34
|
+
D?.contains(document.activeElement) && (o.key === "Escape" ? (o.preventDefault(), o.stopPropagation(), E()) : o.key === "Tab" && E());
|
|
34
35
|
};
|
|
35
36
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
36
37
|
}, [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
O,
|
|
39
|
+
D,
|
|
40
|
+
E,
|
|
41
|
+
d
|
|
41
42
|
]);
|
|
42
|
-
const
|
|
43
|
+
const N = s ? g(s, "HH:mm") : "", [b, p] = x(N), [T, a] = x(!1), [h, l] = x(!1), c = T ? b : N, v = (e) => !e || !k || !re(k) || !te(e, k), C = (e) => !A(e, y), m = c.length === 5 ? S(c, s) : null, F = !h || c === "" || m !== null, K = !h || !m || v(m), H = !!w && h && c === "", W = h && A(m ?? void 0, y) ? B : void 0, L = (e) => {
|
|
43
44
|
if (e === "") return !0;
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
},
|
|
47
|
-
const
|
|
48
|
-
if (a(!0),
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
45
|
+
const o = S(e, s);
|
|
46
|
+
return o !== null && v(o) && C(o);
|
|
47
|
+
}, z = (e) => {
|
|
48
|
+
const o = e.target.value;
|
|
49
|
+
if (a(!0), p(o), (H || L(o)) && l(!1), o.length !== 5) return;
|
|
50
|
+
const u = S(o, s);
|
|
51
|
+
if (!u) {
|
|
51
52
|
r(void 0);
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
if (!V(u, f)) {
|
|
56
|
+
if (!C(u)) {
|
|
57
|
+
r(void 0);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
v(u) ? (r(u), a(!1), i.close()) : r(void 0);
|
|
61
|
+
}
|
|
62
|
+
}, j = (e) => {
|
|
63
|
+
if (e && V(e, f)) return;
|
|
64
|
+
if (!C(e)) {
|
|
65
|
+
l(!0);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const o = v(e);
|
|
69
|
+
if (l(!o), o) {
|
|
70
|
+
r(e), p(e ? g(e, "HH:mm") : ""), a(!1);
|
|
60
71
|
return;
|
|
61
72
|
}
|
|
62
|
-
r(void 0),
|
|
63
|
-
},
|
|
64
|
-
if (
|
|
65
|
-
|
|
73
|
+
r(void 0), p(e ? g(e, "HH:mm") : ""), a(!0);
|
|
74
|
+
}, G = () => {
|
|
75
|
+
if (w && c === "" && !i.isOpen) {
|
|
76
|
+
T && r(void 0), l(!0);
|
|
66
77
|
return;
|
|
67
78
|
}
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
r(void 0),
|
|
71
|
-
}, P = /* @__PURE__ */ n(
|
|
72
|
-
...
|
|
73
|
-
popupState:
|
|
74
|
-
localValue:
|
|
75
|
-
isValidTime:
|
|
76
|
-
isValidEndTime:
|
|
77
|
-
isMissingTime:
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
T && (m && V(m, f) ? a(!1) : b === "" ? r(void 0) : L(b) || l(!0));
|
|
80
|
+
}, M = () => {
|
|
81
|
+
r(void 0), p(""), a(!1), l(!!w);
|
|
82
|
+
}, P = /* @__PURE__ */ n(oe, {
|
|
83
|
+
...t,
|
|
84
|
+
popupState: i,
|
|
85
|
+
localValue: c,
|
|
86
|
+
isValidTime: F,
|
|
87
|
+
isValidEndTime: K,
|
|
88
|
+
isMissingTime: H,
|
|
89
|
+
disabledTimeError: W,
|
|
90
|
+
handleChange: z,
|
|
91
|
+
handleBlur: G
|
|
80
92
|
});
|
|
81
|
-
return
|
|
82
|
-
className:
|
|
83
|
-
...
|
|
93
|
+
return t.disabled || t.readOnly || t.lockedReason ? P : d ? /* @__PURE__ */ q("div", {
|
|
94
|
+
className: I("relative h-auto", typeof t.width == "number" && "w-auto"),
|
|
95
|
+
...R(t.width),
|
|
84
96
|
children: [/* @__PURE__ */ n("div", {
|
|
85
97
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
86
98
|
children: P
|
|
87
|
-
}), /* @__PURE__ */ n(
|
|
99
|
+
}), /* @__PURE__ */ n(X, {
|
|
88
100
|
anchor: "bottom",
|
|
89
|
-
open:
|
|
90
|
-
onClose:
|
|
91
|
-
anchorEl:
|
|
101
|
+
open: i.isOpen,
|
|
102
|
+
onClose: i.close,
|
|
103
|
+
anchorEl: i.anchorEl,
|
|
92
104
|
registerBackClose: !1,
|
|
93
105
|
children: /* @__PURE__ */ n("div", {
|
|
94
106
|
className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
|
|
95
|
-
children: /* @__PURE__ */ n(
|
|
96
|
-
dataTest:
|
|
107
|
+
children: /* @__PURE__ */ n($, {
|
|
108
|
+
dataTest: t.dataTest,
|
|
97
109
|
value: s,
|
|
98
|
-
minTime:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
minTime: f,
|
|
111
|
+
isTimeDisabled: y,
|
|
112
|
+
disabledTimeReason: B,
|
|
113
|
+
onSelect: j,
|
|
114
|
+
handleClear: M,
|
|
115
|
+
onConfirm: i.close
|
|
102
116
|
})
|
|
103
117
|
})
|
|
104
118
|
})]
|
|
105
|
-
}) : /* @__PURE__ */ n(
|
|
119
|
+
}) : /* @__PURE__ */ n(_, {
|
|
106
120
|
mouseEvent: "onMouseDown",
|
|
107
|
-
onClickAway:
|
|
108
|
-
children: /* @__PURE__ */
|
|
109
|
-
className:
|
|
110
|
-
...
|
|
121
|
+
onClickAway: i.close,
|
|
122
|
+
children: /* @__PURE__ */ q("div", {
|
|
123
|
+
className: I("relative h-auto", typeof t.width == "number" && "w-auto"),
|
|
124
|
+
...R(t.width),
|
|
111
125
|
children: [/* @__PURE__ */ n("div", {
|
|
112
126
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
113
127
|
children: P
|
|
114
|
-
}),
|
|
115
|
-
...
|
|
116
|
-
popupState:
|
|
117
|
-
handleClear:
|
|
118
|
-
onSelect:
|
|
128
|
+
}), i.isOpen && /* @__PURE__ */ n(ee, {
|
|
129
|
+
...t,
|
|
130
|
+
popupState: i,
|
|
131
|
+
handleClear: M,
|
|
132
|
+
onSelect: j
|
|
119
133
|
})]
|
|
120
134
|
})
|
|
121
135
|
});
|
|
122
136
|
};
|
|
123
137
|
export {
|
|
124
|
-
|
|
138
|
+
Te as StyledTimePicker
|
|
125
139
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
"styled-time-picker-root": "_styled-time-picker-
|
|
3
|
-
"styled-time-picker-root_column": "_styled-time-picker-
|
|
4
|
-
"styled-time-picker-root_cell": "_styled-time-picker-
|
|
5
|
-
"styled-time-picker-root_cell__cell-now": "_styled-time-picker-root_cell__cell-
|
|
6
|
-
"styled-time-picker-root_cell__cell-selected": "_styled-time-picker-root_cell__cell-
|
|
7
|
-
"time-picker-surface": "_time-picker-
|
|
2
|
+
"styled-time-picker-root": "_styled-time-picker-root_19h3v_1",
|
|
3
|
+
"styled-time-picker-root_column": "_styled-time-picker-root_column_19h3v_4",
|
|
4
|
+
"styled-time-picker-root_cell": "_styled-time-picker-root_cell_19h3v_7",
|
|
5
|
+
"styled-time-picker-root_cell__cell-now": "_styled-time-picker-root_cell__cell-now_19h3v_10",
|
|
6
|
+
"styled-time-picker-root_cell__cell-selected": "_styled-time-picker-root_cell__cell-selected_19h3v_13",
|
|
7
|
+
"time-picker-surface": "_time-picker-surface_19h3v_20"
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
10
|
e as default
|
|
@@ -1,90 +1,90 @@
|
|
|
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 o, jsxs as
|
|
10
|
-
var
|
|
11
|
-
const { placeholder: k, disabled: e, inputClassName:
|
|
1
|
+
import { ClockOutlineIcon as B } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
|
|
2
|
+
import { fieldLabelAboveClass as M } from "../../../components/inputs/field-styles.js";
|
|
3
|
+
import { StyledInputField as O } from "../../../components/inputs/input-field/StyledInputField.js";
|
|
4
|
+
import { getTitleLabelling as w } from "../../helpers/getTitleLabelling.js";
|
|
5
|
+
import { useInputMask as H } from "../../../helpers/inputMask.js";
|
|
6
|
+
import { HelperText as V, defaultTimePickerHelperMessages as W } from "./components/HelperText.js";
|
|
7
|
+
import { timePickerWidthProps as j } from "./helpers/timePickerWidth.js";
|
|
8
|
+
import { useEffect as q, useId as z, useRef as L } from "react";
|
|
9
|
+
import { jsx as o, jsxs as S } from "react/jsx-runtime";
|
|
10
|
+
var Z = (g) => {
|
|
11
|
+
const { placeholder: k, disabled: e, inputClassName: C, dataTest: m, width: r, error: d, helperText: b, label: p, locale: I = "en", popupState: i, handleChange: P, handleBlur: v, isValidTime: u, isValidEndTime: c, isMissingTime: f, disabledTimeError: h, localValue: y, title: l, required: E, readOnly: N, lockedReason: a, inputAriaProps: R } = g, s = !!N || !!a, A = H({
|
|
12
12
|
mask: "xx:xx",
|
|
13
13
|
maskChar: "x",
|
|
14
14
|
showMask: !1
|
|
15
|
-
}),
|
|
16
|
-
return
|
|
15
|
+
}), x = !u || !c || !!f || !!d || !!h, n = L(null), T = z();
|
|
16
|
+
return q(() => {
|
|
17
17
|
n.current && i.setAnchorEl(n.current);
|
|
18
|
-
}, []), /* @__PURE__ */
|
|
19
|
-
...
|
|
18
|
+
}, []), /* @__PURE__ */ S("div", {
|
|
19
|
+
...j(r),
|
|
20
20
|
"data-helper-room-box": "",
|
|
21
21
|
children: [l && /* @__PURE__ */ o("div", {
|
|
22
|
-
id:
|
|
23
|
-
className:
|
|
22
|
+
id: T,
|
|
23
|
+
className: M({ disabled: e }),
|
|
24
24
|
children: l
|
|
25
|
-
}), /* @__PURE__ */ o(
|
|
26
|
-
inputRef:
|
|
25
|
+
}), /* @__PURE__ */ o(O, {
|
|
26
|
+
inputRef: A,
|
|
27
27
|
autoComplete: "off",
|
|
28
28
|
type: "text",
|
|
29
29
|
dataTest: m,
|
|
30
30
|
"data-testid": m,
|
|
31
31
|
placeholder: k,
|
|
32
32
|
size: "small",
|
|
33
|
-
error:
|
|
34
|
-
helperText: /* @__PURE__ */ o(
|
|
33
|
+
error: x,
|
|
34
|
+
helperText: h ?? /* @__PURE__ */ o(V, {
|
|
35
35
|
isValidTime: u,
|
|
36
36
|
isValidEndTime: c,
|
|
37
37
|
isMissingTime: f,
|
|
38
|
-
error: !!
|
|
38
|
+
error: !!d,
|
|
39
39
|
localization: I,
|
|
40
|
-
helperText:
|
|
41
|
-
messages:
|
|
40
|
+
helperText: b,
|
|
41
|
+
messages: W
|
|
42
42
|
}),
|
|
43
43
|
onChange: P,
|
|
44
|
-
onBlur:
|
|
44
|
+
onBlur: v,
|
|
45
45
|
slotProps: {
|
|
46
46
|
htmlInput: {
|
|
47
|
-
"aria-required":
|
|
48
|
-
...
|
|
47
|
+
"aria-required": E ? !0 : void 0,
|
|
48
|
+
...w({
|
|
49
49
|
title: l,
|
|
50
|
-
titleId:
|
|
51
|
-
label:
|
|
52
|
-
inputAriaProps:
|
|
50
|
+
titleId: T,
|
|
51
|
+
label: p,
|
|
52
|
+
inputAriaProps: R
|
|
53
53
|
})
|
|
54
54
|
},
|
|
55
55
|
input: {
|
|
56
56
|
ref: n,
|
|
57
|
-
onClick: (
|
|
58
|
-
!e && !s && i.open(
|
|
57
|
+
onClick: (t) => {
|
|
58
|
+
!e && !s && i.open(t);
|
|
59
59
|
},
|
|
60
|
-
endAdornment: !a && /* @__PURE__ */ o(
|
|
60
|
+
endAdornment: !a && /* @__PURE__ */ o(B, {
|
|
61
61
|
width: 24,
|
|
62
62
|
height: 24,
|
|
63
63
|
className: e ? "text-delta-300" : "text-delta-700",
|
|
64
|
-
onClick: (
|
|
65
|
-
|
|
64
|
+
onClick: (t) => {
|
|
65
|
+
t.stopPropagation(), !e && !s && i.open(t);
|
|
66
66
|
}
|
|
67
67
|
})
|
|
68
68
|
},
|
|
69
69
|
formHelperText: {
|
|
70
|
-
className:
|
|
70
|
+
className: x ? "ml-0 mr-[14px] mt-1 leading-[23.24px]" : "mx-[14px] mt-1 leading-[23.24px]",
|
|
71
71
|
hideErrorIcon: !0
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
value:
|
|
75
|
-
sx: typeof
|
|
76
|
-
maxWidth:
|
|
77
|
-
width:
|
|
78
|
-
minWidth:
|
|
74
|
+
value: y,
|
|
75
|
+
sx: typeof r == "number" ? {
|
|
76
|
+
maxWidth: r,
|
|
77
|
+
width: r,
|
|
78
|
+
minWidth: r
|
|
79
79
|
} : void 0,
|
|
80
80
|
disabled: e,
|
|
81
81
|
readOnly: s,
|
|
82
82
|
lockedReason: a,
|
|
83
|
-
className:
|
|
84
|
-
label:
|
|
83
|
+
className: C,
|
|
84
|
+
label: p
|
|
85
85
|
})]
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
export {
|
|
89
|
-
|
|
89
|
+
Z as TimePickerInput
|
|
90
90
|
};
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import { bindPopper as
|
|
1
|
+
import { bindPopper as s } from "../../../hooks/usePopupState.js";
|
|
2
2
|
import { Paper as c } from "../../../components/mui-compat/Paper.js";
|
|
3
|
-
import { Fade as
|
|
4
|
-
import { Popper as
|
|
5
|
-
import
|
|
6
|
-
import { TimePickerPanel as
|
|
7
|
-
import
|
|
3
|
+
import { Fade as f } from "../../../components/mui-compat/Fade.js";
|
|
4
|
+
import { Popper as u } from "../../../components/mui-compat/Popper.js";
|
|
5
|
+
import P from "./StyledTimePicker.module.js";
|
|
6
|
+
import { TimePickerPanel as T } from "./components/TimePickerPanel.js";
|
|
7
|
+
import x from "clsx";
|
|
8
8
|
import { jsx as e } from "react/jsx-runtime";
|
|
9
|
-
var
|
|
10
|
-
const { popupState: r, dataTest:
|
|
11
|
-
return /* @__PURE__ */ e(
|
|
12
|
-
...
|
|
9
|
+
var g = (i) => {
|
|
10
|
+
const { popupState: r, dataTest: o, value: m, minTime: t, isTimeDisabled: p, disabledTimeReason: a, onSelect: l, handleClear: n } = i;
|
|
11
|
+
return /* @__PURE__ */ e(u, {
|
|
12
|
+
...s(r),
|
|
13
13
|
transition: !0,
|
|
14
14
|
style: { zIndex: "1300" },
|
|
15
|
-
children: ({ TransitionProps:
|
|
16
|
-
...
|
|
15
|
+
children: ({ TransitionProps: d }) => /* @__PURE__ */ e(f, {
|
|
16
|
+
...d,
|
|
17
17
|
timeout: 350,
|
|
18
18
|
children: /* @__PURE__ */ e(c, {
|
|
19
19
|
elevation: 0,
|
|
20
|
-
className: P
|
|
20
|
+
className: x(P["time-picker-surface"]),
|
|
21
21
|
style: { paddingBottom: "1px" },
|
|
22
|
-
children: /* @__PURE__ */ e(
|
|
23
|
-
dataTest:
|
|
24
|
-
value:
|
|
25
|
-
minTime:
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
children: /* @__PURE__ */ e(T, {
|
|
23
|
+
dataTest: o,
|
|
24
|
+
value: m,
|
|
25
|
+
minTime: t,
|
|
26
|
+
isTimeDisabled: p,
|
|
27
|
+
disabledTimeReason: a,
|
|
28
|
+
onSelect: l,
|
|
29
|
+
handleClear: n,
|
|
28
30
|
onConfirm: () => r.close()
|
|
29
31
|
})
|
|
30
32
|
})
|
|
@@ -32,5 +34,5 @@ var _ = (o) => {
|
|
|
32
34
|
});
|
|
33
35
|
};
|
|
34
36
|
export {
|
|
35
|
-
|
|
37
|
+
g as TimePickerPopper
|
|
36
38
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TimePickerColumn as
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { jsx as
|
|
5
|
-
var
|
|
6
|
-
const t =
|
|
7
|
-
return
|
|
1
|
+
import d from "../StyledTimePicker.module.js";
|
|
2
|
+
import { TimePickerColumn as m } from "./TimePickerColumn.js";
|
|
3
|
+
import { useEffect as a, useRef as y } from "react";
|
|
4
|
+
import { jsx as u, jsxs as h } from "react/jsx-runtime";
|
|
5
|
+
var P = ({ value: c, onSelect: l, dataTest: p, minTime: f, isTimeDisabled: n, disabledTimeReason: s }) => {
|
|
6
|
+
const t = y(null);
|
|
7
|
+
return a(() => {
|
|
8
8
|
const r = t.current;
|
|
9
9
|
if (!r) return;
|
|
10
10
|
const i = r.querySelectorAll('[data-cell="selected"]');
|
|
@@ -12,23 +12,27 @@ var g = ({ value: l, onSelect: c, dataTest: m, minTime: s }) => {
|
|
|
12
12
|
const e = o.parentElement;
|
|
13
13
|
e && (e.scrollTop = o.offsetTop - e.offsetTop - (e.clientHeight - o.clientHeight) / 2);
|
|
14
14
|
});
|
|
15
|
-
}, [t]), /* @__PURE__ */
|
|
15
|
+
}, [t]), /* @__PURE__ */ h("div", {
|
|
16
16
|
ref: t,
|
|
17
|
-
"data-test":
|
|
18
|
-
className:
|
|
19
|
-
children: [/* @__PURE__ */
|
|
17
|
+
"data-test": p,
|
|
18
|
+
className: d["styled-time-picker-root"],
|
|
19
|
+
children: [/* @__PURE__ */ u(m, {
|
|
20
20
|
type: "hours",
|
|
21
|
-
value:
|
|
22
|
-
onSelect:
|
|
23
|
-
minTime:
|
|
24
|
-
|
|
21
|
+
value: c,
|
|
22
|
+
onSelect: l,
|
|
23
|
+
minTime: f,
|
|
24
|
+
isTimeDisabled: n,
|
|
25
|
+
disabledTimeReason: s
|
|
26
|
+
}), /* @__PURE__ */ u(m, {
|
|
25
27
|
type: "minutes",
|
|
26
|
-
value:
|
|
27
|
-
onSelect:
|
|
28
|
-
minTime:
|
|
28
|
+
value: c,
|
|
29
|
+
onSelect: l,
|
|
30
|
+
minTime: f,
|
|
31
|
+
isTimeDisabled: n,
|
|
32
|
+
disabledTimeReason: s
|
|
29
33
|
})]
|
|
30
34
|
});
|
|
31
35
|
};
|
|
32
36
|
export {
|
|
33
|
-
|
|
37
|
+
P as TimePickerBody
|
|
34
38
|
};
|
|
@@ -1,28 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { StyledTooltip as S } from "../../../../components/data-display/tooltip/StyledTooltip.js";
|
|
2
|
+
import s from "../StyledTimePicker.module.js";
|
|
3
|
+
import { clampToMinTime as j, isHourDisabled as x, isMinuteDisabled as D } from "../helpers/minTime.js";
|
|
4
|
+
import { isHourRejected as N, isMinuteRejected as C } from "../helpers/disabledTime.js";
|
|
5
|
+
import P from "clsx";
|
|
6
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
7
|
+
import { getHours as w, getMinutes as R, set as T } from "date-fns";
|
|
8
|
+
var G = ({ type: M, value: o, onSelect: h, minTime: c, isTimeDisabled: l, disabledTimeReason: d }) => {
|
|
9
|
+
const r = /* @__PURE__ */ new Date(), t = M === "hours", m = w(o ?? r), u = o ?? r, b = t ? 24 : 12, g = t ? r.getHours() : r.getMinutes();
|
|
10
|
+
return /* @__PURE__ */ n("div", {
|
|
11
|
+
className: s["styled-time-picker-root_column"],
|
|
12
|
+
children: new Array(b).fill(null).map((z, p) => {
|
|
13
|
+
const e = t ? p : p * 5, a = o && e === (t ? w(o) : R(o)), f = g == e, H = t ? x(e, c) : D(m, e, c), _ = t ? N(e, u, l) : C(m, e, u, l), i = _ && !!d, y = /* @__PURE__ */ n("button", {
|
|
13
14
|
type: "button",
|
|
14
|
-
disabled:
|
|
15
|
-
"
|
|
16
|
-
|
|
15
|
+
disabled: H || _ && !i,
|
|
16
|
+
"aria-disabled": i || void 0,
|
|
17
|
+
"data-cell": a ? "selected" : f ? "now" : void 0,
|
|
18
|
+
className: P("border-0", s["styled-time-picker-root_cell"], f && s["styled-time-picker-root_cell__cell-now"], a && s["styled-time-picker-root_cell__cell-selected"]),
|
|
17
19
|
onClick: () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
if (i) return;
|
|
21
|
+
const k = T(o ?? /* @__PURE__ */ new Date(), t ? { hours: e } : { minutes: e });
|
|
22
|
+
h(t ? j(k, c) : k);
|
|
20
23
|
},
|
|
21
24
|
children: e.toString().padStart(2, "0")
|
|
22
25
|
}, e);
|
|
26
|
+
return i ? /* @__PURE__ */ n(S, {
|
|
27
|
+
title: d,
|
|
28
|
+
children: y
|
|
29
|
+
}, e) : y;
|
|
23
30
|
})
|
|
24
31
|
});
|
|
25
32
|
};
|
|
26
33
|
export {
|
|
27
|
-
|
|
34
|
+
G as TimePickerColumn
|
|
28
35
|
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { StyledButton as e } from "../../../shared-components/button/StyledButton.js";
|
|
2
|
-
import { TimePickerBody as
|
|
3
|
-
import { EraserIcon as
|
|
4
|
-
import { CheckIcon as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
var
|
|
2
|
+
import { TimePickerBody as c } from "./TimePickerBody.js";
|
|
3
|
+
import { EraserIcon as p } from "../../../shared-components/EraserIcon.js";
|
|
4
|
+
import { CheckIcon as h } from "../../../shared-components/CheckIcon.js";
|
|
5
|
+
import { Fragment as f, jsx as t, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
var C = ({ dataTest: a, value: i, minTime: m, isTimeDisabled: n, disabledTimeReason: o, onSelect: d, handleClear: l, onConfirm: s }) => /* @__PURE__ */ r(f, { children: [/* @__PURE__ */ t(c, {
|
|
7
7
|
dataTest: `${a}-time-picker-body`,
|
|
8
8
|
value: i,
|
|
9
9
|
minTime: m,
|
|
10
|
-
|
|
10
|
+
isTimeDisabled: n,
|
|
11
|
+
disabledTimeReason: o,
|
|
12
|
+
onSelect: d
|
|
11
13
|
}), /* @__PURE__ */ r("div", {
|
|
12
14
|
style: {
|
|
13
15
|
display: "flex",
|
|
@@ -20,14 +22,14 @@ var g = ({ dataTest: a, value: i, minTime: m, onSelect: n, handleClear: o, onCon
|
|
|
20
22
|
"data-testid": "time-picker-erase-button",
|
|
21
23
|
"aria-label": "Clear time",
|
|
22
24
|
variant: "text",
|
|
23
|
-
onClick:
|
|
25
|
+
onClick: l,
|
|
24
26
|
size: "small",
|
|
25
27
|
disabled: !i,
|
|
26
28
|
style: {
|
|
27
29
|
minWidth: "40px",
|
|
28
30
|
marginLeft: "10px"
|
|
29
31
|
},
|
|
30
|
-
children: /* @__PURE__ */ t(
|
|
32
|
+
children: /* @__PURE__ */ t(p, {
|
|
31
33
|
width: 24,
|
|
32
34
|
height: 24
|
|
33
35
|
})
|
|
@@ -37,17 +39,17 @@ var g = ({ dataTest: a, value: i, minTime: m, onSelect: n, handleClear: o, onCon
|
|
|
37
39
|
"aria-label": "Confirm time",
|
|
38
40
|
variant: "contained",
|
|
39
41
|
size: "small",
|
|
40
|
-
onClick:
|
|
42
|
+
onClick: s,
|
|
41
43
|
style: {
|
|
42
44
|
minWidth: "40px",
|
|
43
45
|
marginRight: "16px"
|
|
44
46
|
},
|
|
45
|
-
children: /* @__PURE__ */ t(
|
|
47
|
+
children: /* @__PURE__ */ t(h, {
|
|
46
48
|
width: 20,
|
|
47
49
|
height: 20
|
|
48
50
|
})
|
|
49
51
|
})]
|
|
50
52
|
})] });
|
|
51
53
|
export {
|
|
52
|
-
|
|
54
|
+
C as TimePickerPanel
|
|
53
55
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var u = (r, t, n) => {
|
|
2
|
+
const e = new Date(r);
|
|
3
|
+
return e.setHours(t, n, 0, 0), e;
|
|
4
|
+
}, a = (r, t, n) => {
|
|
5
|
+
if (!n) return !1;
|
|
6
|
+
for (let e = 0; e < 60; e += 5) if (!n(u(t, r, e))) return !1;
|
|
7
|
+
return !0;
|
|
8
|
+
}, f = (r, t, n, e) => e ? e(u(n, r, t)) : !1, o = (r, t) => !!r && !!t && t(r);
|
|
9
|
+
export {
|
|
10
|
+
a as isHourRejected,
|
|
11
|
+
f as isMinuteRejected,
|
|
12
|
+
o as isTimeRejected
|
|
13
|
+
};
|