asma-ui-core 3.98.2 → 3.99.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 +63 -56
- package/dist/datetime/components/time-picker/StyledTimePicker.module.js +6 -6
- package/dist/datetime/components/time-picker/TimePickerInput.js +24 -23
- package/dist/datetime/components/time-picker/TimePickerPopper.js +20 -19
- package/dist/datetime/components/time-picker/components/TimePickerBody.js +19 -17
- package/dist/datetime/components/time-picker/components/TimePickerColumn.js +16 -13
- package/dist/datetime/components/time-picker/components/TimePickerPanel.js +12 -11
- package/dist/datetime/components/time-picker/helpers/getTimeFromValue.js +5 -5
- package/dist/datetime/components/time-picker/helpers/minTime.js +12 -0
- package/dist/src/datetime/components/time-picker/TimePickerInput.d.ts +1 -0
- package/dist/src/datetime/components/time-picker/components/TimePickerPanel.d.ts +1 -0
- package/dist/src/datetime/components/time-picker/helpers/minTime.d.ts +12 -0
- package/dist/src/datetime/components/time-picker/helpers/minTime.test.d.ts +1 -0
- package/dist/src/datetime/components/time-picker/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,103 +1,110 @@
|
|
|
1
|
-
import { useIsMobileView as
|
|
2
|
-
import { StyledDrawer as
|
|
3
|
-
import { useBackNavigationClose as
|
|
4
|
-
import { usePopupState as
|
|
5
|
-
import { ClickAwayListener as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { useIsMobileView as I } from "../../hooks/useWindowWidthSize.hook.js";
|
|
2
|
+
import { StyledDrawer as j } from "../../../components/navigation/drawer/StyledDrawer.js";
|
|
3
|
+
import { useBackNavigationClose as M } from "../../hooks/useBackNavigationClose.hook.js";
|
|
4
|
+
import { usePopupState as A } from "../../../hooks/usePopupState.js";
|
|
5
|
+
import { ClickAwayListener as F } from "../../../components/mui-compat/ClickAwayListener.js";
|
|
6
|
+
import { isBeforeMinTime as V } from "./helpers/minTime.js";
|
|
7
|
+
import { TimePickerPanel as K } from "./components/TimePickerPanel.js";
|
|
8
|
+
import { TimePickerPopper as q } from "./TimePickerPopper.js";
|
|
9
|
+
import { getTimeFromValue as g } from "./helpers/getTimeFromValue.js";
|
|
10
|
+
import { TimePickerInput as z } from "./TimePickerInput.js";
|
|
11
|
+
import { useEffect as G, useState as w } from "react";
|
|
12
|
+
import { jsx as r, jsxs as D } from "react/jsx-runtime";
|
|
13
|
+
import { format as E, isBefore as J, isValid as Q } from "date-fns";
|
|
14
|
+
var ne = (i) => {
|
|
15
|
+
const { value: l, onSelect: n, notBeforeTime: d, minTime: c } = i, o = A({
|
|
15
16
|
variant: "popper",
|
|
16
17
|
popupId: "time-picker-popper"
|
|
17
|
-
}),
|
|
18
|
-
|
|
19
|
-
open:
|
|
18
|
+
}), m = I();
|
|
19
|
+
M({
|
|
20
|
+
open: m && o.isOpen,
|
|
20
21
|
onClose: o.close
|
|
21
22
|
});
|
|
22
|
-
const { isOpen:
|
|
23
|
-
|
|
24
|
-
if (!
|
|
23
|
+
const { isOpen: x, anchorEl: P, close: h } = o;
|
|
24
|
+
G(() => {
|
|
25
|
+
if (!x || m) return;
|
|
25
26
|
const e = (t) => {
|
|
26
|
-
|
|
27
|
+
P?.contains(document.activeElement) && (t.key === "Escape" ? (t.preventDefault(), t.stopPropagation(), h()) : t.key === "Tab" && h());
|
|
27
28
|
};
|
|
28
29
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
29
30
|
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
x,
|
|
32
|
+
P,
|
|
33
|
+
h,
|
|
34
|
+
m
|
|
34
35
|
]);
|
|
35
|
-
const
|
|
36
|
+
const T = l ? E(l, "HH:mm") : "", [H, u] = w(T), [S, a] = w(!1), [L, s] = w(!0), v = S ? H : T, y = (e) => !e || !d || !Q(d) || !J(e, d), f = v.length === 5 ? g(v, l) : null, N = f ? y(f) : !0, O = (e) => {
|
|
36
37
|
const t = e.target.value;
|
|
37
|
-
if (
|
|
38
|
+
if (a(!0), u(t), t.length !== 5) {
|
|
38
39
|
s(!1);
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
42
|
+
const p = g(t, l);
|
|
43
|
+
if (!p) {
|
|
43
44
|
n(void 0), s(!1);
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
s(!0),
|
|
47
|
-
},
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
s(!0), !V(p, c) && (y(p) ? (n(p), a(!1), o.close()) : n(void 0));
|
|
48
|
+
}, C = (e) => {
|
|
49
|
+
if (!(e && V(e, c))) {
|
|
50
|
+
if (s(!0), y(e)) {
|
|
51
|
+
n(e), u(e ? E(e, "HH:mm") : ""), a(!1);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
n(void 0), u(e ? E(e, "HH:mm") : ""), a(!0);
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
}, B = () => {
|
|
57
|
+
S && f && V(f, c) && a(!1);
|
|
58
|
+
}, b = () => {
|
|
59
|
+
n(void 0), u(""), a(!1), s(!0);
|
|
60
|
+
}, k = /* @__PURE__ */ r(z, {
|
|
56
61
|
...i,
|
|
57
62
|
popupState: o,
|
|
58
|
-
localValue:
|
|
59
|
-
isValidTime:
|
|
60
|
-
isValidEndTime:
|
|
61
|
-
handleChange:
|
|
63
|
+
localValue: v,
|
|
64
|
+
isValidTime: L,
|
|
65
|
+
isValidEndTime: N,
|
|
66
|
+
handleChange: O,
|
|
67
|
+
handleBlur: B
|
|
62
68
|
});
|
|
63
|
-
return i.disabled || i.readOnly ?
|
|
69
|
+
return i.disabled || i.readOnly ? k : m ? /* @__PURE__ */ D("div", {
|
|
64
70
|
className: "relative h-auto w-auto",
|
|
65
71
|
children: [/* @__PURE__ */ r("div", {
|
|
66
72
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
67
|
-
children:
|
|
68
|
-
}), /* @__PURE__ */ r(
|
|
73
|
+
children: k
|
|
74
|
+
}), /* @__PURE__ */ r(j, {
|
|
69
75
|
anchor: "bottom",
|
|
70
76
|
open: o.isOpen,
|
|
71
77
|
onClose: o.close,
|
|
72
78
|
anchorEl: o.anchorEl,
|
|
73
79
|
children: /* @__PURE__ */ r("div", {
|
|
74
80
|
className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
|
|
75
|
-
children: /* @__PURE__ */ r(
|
|
81
|
+
children: /* @__PURE__ */ r(K, {
|
|
76
82
|
dataTest: i.dataTest,
|
|
77
|
-
value:
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
value: l,
|
|
84
|
+
minTime: c,
|
|
85
|
+
onSelect: C,
|
|
86
|
+
handleClear: b,
|
|
80
87
|
onConfirm: o.close
|
|
81
88
|
})
|
|
82
89
|
})
|
|
83
90
|
})]
|
|
84
|
-
}) : /* @__PURE__ */ r(
|
|
91
|
+
}) : /* @__PURE__ */ r(F, {
|
|
85
92
|
mouseEvent: "onMouseDown",
|
|
86
93
|
onClickAway: o.close,
|
|
87
|
-
children: /* @__PURE__ */
|
|
94
|
+
children: /* @__PURE__ */ D("div", {
|
|
88
95
|
className: "relative h-auto w-auto",
|
|
89
96
|
children: [/* @__PURE__ */ r("div", {
|
|
90
97
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
91
|
-
children:
|
|
92
|
-
}), o.isOpen && /* @__PURE__ */ r(
|
|
98
|
+
children: k
|
|
99
|
+
}), o.isOpen && /* @__PURE__ */ r(q, {
|
|
93
100
|
...i,
|
|
94
101
|
popupState: o,
|
|
95
|
-
handleClear:
|
|
96
|
-
onSelect:
|
|
102
|
+
handleClear: b,
|
|
103
|
+
onSelect: C
|
|
97
104
|
})]
|
|
98
105
|
})
|
|
99
106
|
});
|
|
100
107
|
};
|
|
101
108
|
export {
|
|
102
|
-
|
|
109
|
+
ne as StyledTimePicker
|
|
103
110
|
};
|
|
@@ -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_5uhjk_1",
|
|
3
|
+
"styled-time-picker-root_column": "_styled-time-picker-root_column_5uhjk_4",
|
|
4
|
+
"styled-time-picker-root_cell": "_styled-time-picker-root_cell_5uhjk_7",
|
|
5
|
+
"styled-time-picker-root_cell__cell-now": "_styled-time-picker-root_cell__cell-now_5uhjk_10",
|
|
6
|
+
"styled-time-picker-root_cell__cell-selected": "_styled-time-picker-root_cell__cell-selected_5uhjk_13",
|
|
7
|
+
"time-picker-surface": "_time-picker-surface_5uhjk_20"
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
10
|
e as default
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { ClockOutlineIcon as
|
|
2
|
-
import { StyledInputField as
|
|
3
|
-
import { useInputMask as
|
|
4
|
-
import { HelperText as
|
|
5
|
-
import { useEffect as
|
|
6
|
-
import { jsx as
|
|
1
|
+
import { ClockOutlineIcon as I } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
|
|
2
|
+
import { StyledInputField as N } from "../../../components/inputs/input-field/StyledInputField.js";
|
|
3
|
+
import { useInputMask as y } from "../../../helpers/inputMask.js";
|
|
4
|
+
import { HelperText as P, defaultTimePickerHelperMessages as R } from "./components/HelperText.js";
|
|
5
|
+
import { useEffect as v, useRef as w } from "react";
|
|
6
|
+
import { jsx as o, jsxs as H } from "react/jsx-runtime";
|
|
7
7
|
var O = (c) => {
|
|
8
|
-
const { placeholder: x, disabled: e, inputClassName:
|
|
8
|
+
const { placeholder: x, disabled: e, inputClassName: u, dataTest: n, width: l, error: f, helperText: h, label: g, locale: k = "en", popupState: a, handleChange: T, handleBlur: C, isValidTime: p, isValidEndTime: m, localValue: b, title: d, readOnly: t } = c, E = y({
|
|
9
9
|
mask: "xx:xx",
|
|
10
10
|
maskChar: "x",
|
|
11
11
|
showMask: !1
|
|
12
|
-
}), i = !p || !m || !!
|
|
13
|
-
return
|
|
12
|
+
}), i = !p || !m || !!f, s = w(null);
|
|
13
|
+
return v(() => {
|
|
14
14
|
s.current && a.setAnchorEl(s.current);
|
|
15
|
-
}, []), /* @__PURE__ */
|
|
15
|
+
}, []), /* @__PURE__ */ H("div", {
|
|
16
16
|
style: { height: t ? "40px" : "75px" },
|
|
17
|
-
children: [d && /* @__PURE__ */
|
|
17
|
+
children: [d && /* @__PURE__ */ o("div", {
|
|
18
18
|
className: "pb-1 font-roboto font-semibold text-delta-800",
|
|
19
19
|
children: d
|
|
20
|
-
}), /* @__PURE__ */
|
|
21
|
-
inputRef:
|
|
20
|
+
}), /* @__PURE__ */ o(N, {
|
|
21
|
+
inputRef: E,
|
|
22
22
|
autoComplete: "off",
|
|
23
23
|
type: "text",
|
|
24
24
|
dataTest: n,
|
|
@@ -26,27 +26,28 @@ var O = (c) => {
|
|
|
26
26
|
placeholder: x,
|
|
27
27
|
size: "small",
|
|
28
28
|
error: i,
|
|
29
|
-
helperText: /* @__PURE__ */
|
|
29
|
+
helperText: /* @__PURE__ */ o(P, {
|
|
30
30
|
isValidTime: p,
|
|
31
31
|
isValidEndTime: m,
|
|
32
32
|
error: i,
|
|
33
33
|
localization: k,
|
|
34
|
-
helperText:
|
|
35
|
-
messages:
|
|
34
|
+
helperText: h,
|
|
35
|
+
messages: R
|
|
36
36
|
}),
|
|
37
37
|
onChange: T,
|
|
38
|
+
onBlur: C,
|
|
38
39
|
slotProps: {
|
|
39
40
|
input: {
|
|
40
41
|
ref: s,
|
|
41
|
-
onClick: (
|
|
42
|
-
!e && !t && a.open(
|
|
42
|
+
onClick: (r) => {
|
|
43
|
+
!e && !t && a.open(r);
|
|
43
44
|
},
|
|
44
|
-
endAdornment: /* @__PURE__ */
|
|
45
|
+
endAdornment: /* @__PURE__ */ o(I, {
|
|
45
46
|
width: 24,
|
|
46
47
|
height: 24,
|
|
47
48
|
className: e ? "text-delta-300" : "text-delta-700",
|
|
48
|
-
onClick: (
|
|
49
|
-
|
|
49
|
+
onClick: (r) => {
|
|
50
|
+
r.stopPropagation(), !e && !t && a.open(r);
|
|
50
51
|
}
|
|
51
52
|
})
|
|
52
53
|
},
|
|
@@ -55,7 +56,7 @@ var O = (c) => {
|
|
|
55
56
|
hideErrorIcon: !0
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
|
-
value:
|
|
59
|
+
value: b,
|
|
59
60
|
sx: {
|
|
60
61
|
maxWidth: l ?? 130,
|
|
61
62
|
width: l,
|
|
@@ -63,7 +64,7 @@ var O = (c) => {
|
|
|
63
64
|
},
|
|
64
65
|
disabled: e,
|
|
65
66
|
readOnly: t,
|
|
66
|
-
className:
|
|
67
|
+
className: u,
|
|
67
68
|
label: g
|
|
68
69
|
})]
|
|
69
70
|
});
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { bindPopper as
|
|
2
|
-
import { Paper as
|
|
3
|
-
import { Fade as
|
|
4
|
-
import { Popper as
|
|
5
|
-
import
|
|
6
|
-
import { TimePickerPanel as
|
|
7
|
-
import
|
|
1
|
+
import { bindPopper as n } from "../../../hooks/usePopupState.js";
|
|
2
|
+
import { Paper as c } from "../../../components/mui-compat/Paper.js";
|
|
3
|
+
import { Fade as d } from "../../../components/mui-compat/Fade.js";
|
|
4
|
+
import { Popper as f } from "../../../components/mui-compat/Popper.js";
|
|
5
|
+
import s from "./StyledTimePicker.module.js";
|
|
6
|
+
import { TimePickerPanel as u } from "./components/TimePickerPanel.js";
|
|
7
|
+
import P from "clsx";
|
|
8
8
|
import { jsx as e } from "react/jsx-runtime";
|
|
9
|
-
var
|
|
10
|
-
const { popupState: r, dataTest: t, value: i,
|
|
11
|
-
return /* @__PURE__ */ e(
|
|
12
|
-
...
|
|
9
|
+
var _ = (o) => {
|
|
10
|
+
const { popupState: r, dataTest: t, value: i, minTime: m, onSelect: p, handleClear: a } = o;
|
|
11
|
+
return /* @__PURE__ */ e(f, {
|
|
12
|
+
...n(r),
|
|
13
13
|
transition: !0,
|
|
14
14
|
style: { zIndex: "1300" },
|
|
15
|
-
children: ({ TransitionProps:
|
|
16
|
-
...
|
|
15
|
+
children: ({ TransitionProps: l }) => /* @__PURE__ */ e(d, {
|
|
16
|
+
...l,
|
|
17
17
|
timeout: 350,
|
|
18
|
-
children: /* @__PURE__ */ e(
|
|
18
|
+
children: /* @__PURE__ */ e(c, {
|
|
19
19
|
elevation: 0,
|
|
20
|
-
className:
|
|
20
|
+
className: P(s["time-picker-surface"]),
|
|
21
21
|
style: { paddingBottom: "1px" },
|
|
22
|
-
children: /* @__PURE__ */ e(
|
|
22
|
+
children: /* @__PURE__ */ e(u, {
|
|
23
23
|
dataTest: t,
|
|
24
24
|
value: i,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
minTime: m,
|
|
26
|
+
onSelect: p,
|
|
27
|
+
handleClear: a,
|
|
27
28
|
onConfirm: () => r.close()
|
|
28
29
|
})
|
|
29
30
|
})
|
|
@@ -31,5 +32,5 @@ var C = (o) => {
|
|
|
31
32
|
});
|
|
32
33
|
};
|
|
33
34
|
export {
|
|
34
|
-
|
|
35
|
+
_ as TimePickerPopper
|
|
35
36
|
};
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TimePickerColumn as
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { jsx as
|
|
5
|
-
var
|
|
6
|
-
const t =
|
|
7
|
-
return
|
|
1
|
+
import u from "../StyledTimePicker.module.js";
|
|
2
|
+
import { TimePickerColumn as n } from "./TimePickerColumn.js";
|
|
3
|
+
import { useEffect as d, useRef as p } from "react";
|
|
4
|
+
import { jsx as f, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
var g = ({ value: l, onSelect: c, dataTest: m, minTime: s }) => {
|
|
6
|
+
const t = p(null);
|
|
7
|
+
return d(() => {
|
|
8
8
|
const r = t.current;
|
|
9
9
|
if (!r) return;
|
|
10
|
-
const
|
|
11
|
-
(
|
|
10
|
+
const i = r.querySelectorAll('[data-cell="selected"]');
|
|
11
|
+
(i.length ? i : r.querySelectorAll('[data-cell="now"]')).forEach((o) => {
|
|
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__ */ a("div", {
|
|
16
16
|
ref: t,
|
|
17
|
-
"data-test":
|
|
18
|
-
className:
|
|
19
|
-
children: [/* @__PURE__ */
|
|
17
|
+
"data-test": m,
|
|
18
|
+
className: u["styled-time-picker-root"],
|
|
19
|
+
children: [/* @__PURE__ */ f(n, {
|
|
20
20
|
type: "hours",
|
|
21
21
|
value: l,
|
|
22
|
-
onSelect:
|
|
23
|
-
|
|
22
|
+
onSelect: c,
|
|
23
|
+
minTime: s
|
|
24
|
+
}), /* @__PURE__ */ f(n, {
|
|
24
25
|
type: "minutes",
|
|
25
26
|
value: l,
|
|
26
|
-
onSelect:
|
|
27
|
+
onSelect: c,
|
|
28
|
+
minTime: s
|
|
27
29
|
})]
|
|
28
30
|
});
|
|
29
31
|
};
|
|
30
32
|
export {
|
|
31
|
-
|
|
33
|
+
g as TimePickerBody
|
|
32
34
|
};
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import r from "../StyledTimePicker.module.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { clampToMinTime as w, isHourDisabled as y, isMinuteDisabled as b } from "../helpers/minTime.js";
|
|
3
|
+
import g from "clsx";
|
|
4
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
5
|
+
import { getHours as u, getMinutes as h, set as M } from "date-fns";
|
|
6
|
+
var C = ({ type: a, value: o, onSelect: p, minTime: s }) => {
|
|
7
|
+
const i = /* @__PURE__ */ new Date(), t = a === "hours", _ = u(o ?? i), f = t ? 24 : 12, k = t ? i.getHours() : i.getMinutes();
|
|
8
|
+
return /* @__PURE__ */ d("div", {
|
|
8
9
|
className: r["styled-time-picker-root_column"],
|
|
9
|
-
children: new Array(
|
|
10
|
-
const e = t ?
|
|
11
|
-
return /* @__PURE__ */
|
|
10
|
+
children: new Array(f).fill(null).map((x, l) => {
|
|
11
|
+
const e = t ? l : l * 5, c = o && e === (t ? u(o) : h(o)), n = k == e;
|
|
12
|
+
return /* @__PURE__ */ d("button", {
|
|
12
13
|
type: "button",
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
disabled: t ? y(e, s) : b(_, e, s),
|
|
15
|
+
"data-cell": c ? "selected" : n ? "now" : void 0,
|
|
16
|
+
className: g("border-0", r["styled-time-picker-root_cell"], n && r["styled-time-picker-root_cell__cell-now"], c && r["styled-time-picker-root_cell__cell-selected"]),
|
|
15
17
|
onClick: () => {
|
|
16
|
-
|
|
18
|
+
const m = M(o ?? /* @__PURE__ */ new Date(), t ? { hours: e } : { minutes: e });
|
|
19
|
+
p(t ? w(m, s) : m);
|
|
17
20
|
},
|
|
18
21
|
children: e.toString().padStart(2, "0")
|
|
19
22
|
}, e);
|
|
@@ -21,5 +24,5 @@ var b = ({ type: m, value: o, onSelect: d }) => {
|
|
|
21
24
|
});
|
|
22
25
|
};
|
|
23
26
|
export {
|
|
24
|
-
|
|
27
|
+
C as TimePickerColumn
|
|
25
28
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
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 l } from "./TimePickerBody.js";
|
|
3
|
+
import { EraserIcon as s } from "../../../shared-components/EraserIcon.js";
|
|
4
|
+
import { CheckIcon as c } from "../../../shared-components/CheckIcon.js";
|
|
5
|
+
import { Fragment as p, jsx as t, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
var g = ({ dataTest: a, value: i, minTime: m, onSelect: n, handleClear: o, onConfirm: d }) => /* @__PURE__ */ r(p, { children: [/* @__PURE__ */ t(l, {
|
|
7
7
|
dataTest: `${a}-time-picker-body`,
|
|
8
8
|
value: i,
|
|
9
|
-
|
|
9
|
+
minTime: m,
|
|
10
|
+
onSelect: n
|
|
10
11
|
}), /* @__PURE__ */ r("div", {
|
|
11
12
|
style: {
|
|
12
13
|
display: "flex",
|
|
@@ -19,14 +20,14 @@ var b = ({ dataTest: a, value: i, onSelect: m, handleClear: n, onConfirm: o }) =
|
|
|
19
20
|
"data-testid": "time-picker-erase-button",
|
|
20
21
|
"aria-label": "Clear time",
|
|
21
22
|
variant: "text",
|
|
22
|
-
onClick:
|
|
23
|
+
onClick: o,
|
|
23
24
|
size: "small",
|
|
24
25
|
disabled: !i,
|
|
25
26
|
style: {
|
|
26
27
|
minWidth: "40px",
|
|
27
28
|
marginLeft: "10px"
|
|
28
29
|
},
|
|
29
|
-
children: /* @__PURE__ */ t(
|
|
30
|
+
children: /* @__PURE__ */ t(s, {
|
|
30
31
|
width: 24,
|
|
31
32
|
height: 24
|
|
32
33
|
})
|
|
@@ -36,17 +37,17 @@ var b = ({ dataTest: a, value: i, onSelect: m, handleClear: n, onConfirm: o }) =
|
|
|
36
37
|
"aria-label": "Confirm time",
|
|
37
38
|
variant: "contained",
|
|
38
39
|
size: "small",
|
|
39
|
-
onClick:
|
|
40
|
+
onClick: d,
|
|
40
41
|
style: {
|
|
41
42
|
minWidth: "40px",
|
|
42
43
|
marginRight: "16px"
|
|
43
44
|
},
|
|
44
|
-
children: /* @__PURE__ */ t(
|
|
45
|
+
children: /* @__PURE__ */ t(c, {
|
|
45
46
|
width: 20,
|
|
46
47
|
height: 20
|
|
47
48
|
})
|
|
48
49
|
})]
|
|
49
50
|
})] });
|
|
50
51
|
export {
|
|
51
|
-
|
|
52
|
+
g as TimePickerPanel
|
|
52
53
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var u = (
|
|
2
|
-
const
|
|
3
|
-
if (
|
|
4
|
-
const r =
|
|
5
|
-
return r.setHours(
|
|
1
|
+
var u = (o, s) => {
|
|
2
|
+
const e = o.split(":"), t = Number(e[0]), n = Number(e[1]);
|
|
3
|
+
if (e[0]?.length == 2 && e[1]?.length == 2 && t >= 0 && t <= 23 && n >= 0 && n <= 59) {
|
|
4
|
+
const r = s ? new Date(s) : /* @__PURE__ */ new Date();
|
|
5
|
+
return r.setHours(t), r.setMinutes(n), r;
|
|
6
6
|
}
|
|
7
7
|
return null;
|
|
8
8
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isValid as M } from "date-fns";
|
|
2
|
+
var e = (r) => r.getHours() * 60 + r.getMinutes(), s = (r) => !!r && M(r), o = (r, t) => s(t) && e(r) < e(t), i = (r, t) => s(t) && r * 60 + 55 < e(t), n = (r, t, a) => s(a) && r * 60 + t < e(a), v = (r, t) => {
|
|
3
|
+
if (!s(t) || !o(r, t)) return r;
|
|
4
|
+
const a = new Date(r);
|
|
5
|
+
return a.setMinutes(Math.ceil(t.getMinutes() / 5) * 5), a;
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
v as clampToMinTime,
|
|
9
|
+
o as isBeforeMinTime,
|
|
10
|
+
i as isHourDisabled,
|
|
11
|
+
n as isMinuteDisabled
|
|
12
|
+
};
|
|
@@ -4,6 +4,7 @@ import { ChangeEvent } from 'react';
|
|
|
4
4
|
export declare const TimePickerInput: React.FC<StyledTimePickerProps & {
|
|
5
5
|
popupState: PopupState;
|
|
6
6
|
handleChange: (e: ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => void;
|
|
7
|
+
handleBlur?: () => void;
|
|
7
8
|
isValidTime: boolean;
|
|
8
9
|
isValidEndTime: boolean;
|
|
9
10
|
localValue: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The minutes column offers 00, 05 … 55. */
|
|
2
|
+
export declare const MINUTE_STEP = 5;
|
|
3
|
+
/** Only the clock time of both dates counts; the calendar day is the consumer's concern. */
|
|
4
|
+
export declare const isBeforeMinTime: (time: Date, minTime?: Date) => boolean;
|
|
5
|
+
/** An hour is disabled when none of its minute cells reaches `minTime` (e.g. hour 12 for 12:57). */
|
|
6
|
+
export declare const isHourDisabled: (hour: number, minTime?: Date) => boolean;
|
|
7
|
+
export declare const isMinuteDisabled: (hour: number, minute: number, minTime?: Date) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Picking the `minTime` hour while the kept minutes fall before it (13:10 → hour 12 with minTime 12:35)
|
|
10
|
+
* would land on a disabled cell, so the minutes move up to the first enabled cell (12:35).
|
|
11
|
+
*/
|
|
12
|
+
export declare const clampToMinTime: (time: Date, minTime?: Date) => Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,5 +17,12 @@ export interface StyledTimePickerProps {
|
|
|
17
17
|
locale?: 'no' | 'en';
|
|
18
18
|
title?: string;
|
|
19
19
|
notBeforeTime?: Date;
|
|
20
|
+
/**
|
|
21
|
+
* @figmaProp none — behavioral; drives the Time item `State=Disabled` cells (node 15086-19871).
|
|
22
|
+
* Earliest selectable clock time; its calendar day is ignored. Earlier hour/minute cells are disabled
|
|
23
|
+
* and a typed earlier time is not committed — the field reverts to the last valid value on blur.
|
|
24
|
+
* Unlike `notBeforeTime`, it never shows an error.
|
|
25
|
+
*/
|
|
26
|
+
minTime?: Date;
|
|
20
27
|
}
|
|
21
28
|
export type IPopupStateType = JSX.Element;
|