asma-ui-core 3.132.0 → 3.133.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/asma-ui-core.css +1 -1
- package/dist/components/utils/popover/PopoverSheet.js +168 -151
- 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,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
|
+
};
|
|
@@ -8,5 +8,7 @@ export declare const TimePickerInput: React.FC<StyledTimePickerProps & {
|
|
|
8
8
|
isValidTime: boolean;
|
|
9
9
|
isValidEndTime: boolean;
|
|
10
10
|
isMissingTime?: boolean;
|
|
11
|
+
/** Set only while the current entry is one `isTimeDisabled` refuses; carries its reason. */
|
|
12
|
+
disabledTimeError?: React.ReactNode;
|
|
11
13
|
localValue: string;
|
|
12
14
|
}>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { TimePredicate } from '../helpers/disabledTime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
1
3
|
export interface TimePickerPanelProps {
|
|
2
4
|
dataTest: string;
|
|
3
5
|
value?: Date;
|
|
4
6
|
minTime?: Date;
|
|
7
|
+
isTimeDisabled?: TimePredicate;
|
|
8
|
+
disabledTimeReason?: ReactNode;
|
|
5
9
|
onSelect: (date: Date | undefined) => void;
|
|
6
10
|
handleClear: () => void;
|
|
7
11
|
onConfirm: () => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marking individual clock times unavailable, from a predicate the consumer owns.
|
|
3
|
+
*
|
|
4
|
+
* ## Why a predicate rather than a second bound
|
|
5
|
+
*
|
|
6
|
+
* `minTime` answers one shape of question — "nothing before this" — with a single `<` on day
|
|
7
|
+
* minutes. The question that needed answering here is a **band**, and the band that motivated it
|
|
8
|
+
* wraps midnight: a customer's quiet hours for patient SMS are typically `22:00–06:00`, where
|
|
9
|
+
* `start < end` is false and no pair of bounds expresses it. Mirroring `minTime` with a `maxTime`
|
|
10
|
+
* would have left the wrap rule implicit (`start > end` secretly meaning "inverted") and still only
|
|
11
|
+
* ever described one contiguous band.
|
|
12
|
+
*
|
|
13
|
+
* A predicate states the rule at the call site, where the domain lives, and this file stays a
|
|
14
|
+
* question of which *cells* that rule rejects.
|
|
15
|
+
*
|
|
16
|
+
* ## Only the clock time counts
|
|
17
|
+
*
|
|
18
|
+
* Same contract as {@link isBeforeMinTime}: the calendar day of the date handed to the predicate is
|
|
19
|
+
* the consumer's concern, never this picker's. Cells are probed on the day of the current value so
|
|
20
|
+
* a predicate that happens to read the date still sees a coherent instant.
|
|
21
|
+
*/
|
|
22
|
+
export type TimePredicate = (time: Date) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* An hour cell is unavailable only when **every** minute cell inside it is.
|
|
25
|
+
*
|
|
26
|
+
* This deliberately mirrors `isHourDisabled`'s rule for `minTime` rather than probing the hour on
|
|
27
|
+
* its own: an hour that is half available is still reachable, and greying it would strand the
|
|
28
|
+
* minutes the consumer does allow. Only the steps the minutes column actually offers are probed —
|
|
29
|
+
* checking all 60 would disable an hour the user can never select into anyway.
|
|
30
|
+
*/
|
|
31
|
+
export declare const isHourRejected: (hour: number, reference: Date, isTimeDisabled?: TimePredicate) => boolean;
|
|
32
|
+
/** A single minute cell, gated by the hour the minutes column is currently showing. */
|
|
33
|
+
export declare const isMinuteRejected: (hour: number, minute: number, reference: Date, isTimeDisabled?: TimePredicate) => boolean;
|
|
34
|
+
/** A complete time — what a typed entry or a stale panel pick has to be checked against. */
|
|
35
|
+
export declare const isTimeRejected: (time: Date | undefined, isTimeDisabled?: TimePredicate) => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AriaAttributes, ReactNode } from 'react';
|
|
2
2
|
import { FieldWidth } from '../../../components/inputs/field-styles';
|
|
3
|
+
import { TimePredicate } from './helpers/disabledTime';
|
|
3
4
|
/**
|
|
4
5
|
* @param notBeforeTime - Start time of the range. Selected time must be after this value.
|
|
5
6
|
*/
|
|
@@ -31,6 +32,25 @@ export interface StyledTimePickerProps {
|
|
|
31
32
|
* Unlike `notBeforeTime`, it never shows an error.
|
|
32
33
|
*/
|
|
33
34
|
minTime?: Date;
|
|
35
|
+
/**
|
|
36
|
+
* @figmaProp none — behavioral; drives the Time item `State=Disabled` cells (node 15086-19871).
|
|
37
|
+
* Marks arbitrary clock times unavailable, including a band that wraps midnight, which no pair
|
|
38
|
+
* of bounds can express. An hour cell greys only when every minute cell inside it is rejected,
|
|
39
|
+
* matching `minTime`'s rule.
|
|
40
|
+
*
|
|
41
|
+
* Unlike `minTime`, a rejected time typed by hand **raises the error state** rather than
|
|
42
|
+
* silently reverting: the consumer asked for these times to be refused, so swallowing the entry
|
|
43
|
+
* would leave the author believing it was accepted.
|
|
44
|
+
*
|
|
45
|
+
* Pair it with {@link disabledTimeReason}; a disabled cell with no reason is a dead end.
|
|
46
|
+
*/
|
|
47
|
+
isTimeDisabled?: TimePredicate;
|
|
48
|
+
/**
|
|
49
|
+
* Why {@link isTimeDisabled} rejects what it rejects. Serves twice, so one string cannot drift
|
|
50
|
+
* from the other: the tooltip on a rejected cell, and the field error when a rejected time is
|
|
51
|
+
* typed. Copy stays with the consumer — this picker knows nothing about anyone's domain.
|
|
52
|
+
*/
|
|
53
|
+
disabledTimeReason?: ReactNode;
|
|
34
54
|
/**
|
|
35
55
|
* Extra ARIA attributes for the text input (e.g. `aria-label`, `aria-required`) — for a visible
|
|
36
56
|
* label rendered outside the picker. Without them the input is named by `title` or `label`.
|