asma-ui-core 3.71.0 → 3.72.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 +75 -56
- package/dist/datetime/components/time-picker/StyledTimePicker.module.js +6 -6
- package/dist/datetime/components/time-picker/TimePickerPopper.js +21 -59
- package/dist/datetime/components/time-picker/components/TimePickerBody.js +24 -19
- package/dist/datetime/components/time-picker/components/TimePickerColumn.js +12 -11
- package/dist/datetime/components/time-picker/components/TimePickerPanel.js +50 -0
- package/dist/src/datetime/components/time-picker/StyledTimePicker.d.ts +2 -1
- package/dist/src/datetime/components/time-picker/components/TimePickerPanel.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1,71 +1,90 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useIsMobileView as N } from "../../hooks/useWindowWidthSize.hook.js";
|
|
2
|
+
import { StyledDrawer as E } from "../../../components/navigation/drawer/StyledDrawer.js";
|
|
3
|
+
import { useBackNavigationClose as I } from "../../hooks/useBackNavigationClose.hook.js";
|
|
4
|
+
import { usePopupState as j } from "../../../hooks/usePopupState.js";
|
|
2
5
|
import { ClickAwayListener as D } from "../../../components/mui-compat/ClickAwayListener.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
+
import { TimePickerPanel as L } from "./components/TimePickerPanel.js";
|
|
7
|
+
import { TimePickerPopper as O } from "./TimePickerPopper.js";
|
|
8
|
+
import { getTimeFromValue as S } from "./helpers/getTimeFromValue.js";
|
|
9
|
+
import { TimePickerInput as B } from "./TimePickerInput.js";
|
|
6
10
|
import { useState as h } from "react";
|
|
7
|
-
import { jsx as o, jsxs as
|
|
8
|
-
import { format as v, isBefore as
|
|
9
|
-
var
|
|
10
|
-
const { value: a, onSelect:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
import { jsx as o, jsxs as T } from "react/jsx-runtime";
|
|
12
|
+
import { format as v, isBefore as M, isValid as A } from "date-fns";
|
|
13
|
+
var Z = (i) => {
|
|
14
|
+
const { value: a, onSelect: r, notBeforeTime: m } = i, e = j({
|
|
15
|
+
variant: "popper",
|
|
16
|
+
popupId: "time-picker-popper"
|
|
17
|
+
}), V = N();
|
|
18
|
+
I({
|
|
19
|
+
open: V && e.isOpen,
|
|
20
|
+
onClose: e.close
|
|
21
|
+
});
|
|
22
|
+
const x = a ? v(a, "HH:mm") : "", [C, s] = h(x), [P, l] = h(!1), [b, n] = h(!0), c = P ? C : x, u = (t) => !t || !m || !A(m) || !M(t, m), k = c.length === 5 ? S(c, a) : null, g = k ? u(k) : !0, H = (t) => {
|
|
23
|
+
const p = t.target.value;
|
|
24
|
+
if (l(!0), s(p), p.length !== 5) {
|
|
16
25
|
n(!1);
|
|
17
26
|
return;
|
|
18
27
|
}
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
|
|
28
|
+
const d = S(p, a);
|
|
29
|
+
if (!d) {
|
|
30
|
+
r(void 0), n(!1);
|
|
22
31
|
return;
|
|
23
32
|
}
|
|
24
|
-
n(!0), u(
|
|
25
|
-
},
|
|
26
|
-
if (n(!0), u(
|
|
27
|
-
|
|
33
|
+
n(!0), u(d) ? (r(d), l(!1), e.close()) : r(void 0);
|
|
34
|
+
}, w = (t) => {
|
|
35
|
+
if (n(!0), u(t)) {
|
|
36
|
+
r(t), s(t ? v(t, "HH:mm") : ""), l(!1);
|
|
28
37
|
return;
|
|
29
38
|
}
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
60
|
-
...l,
|
|
61
|
-
popupState: e,
|
|
62
|
-
handleClear: L,
|
|
63
|
-
onSelect: (r) => I(r)
|
|
64
|
-
})]
|
|
39
|
+
r(void 0), s(t ? v(t, "HH:mm") : ""), l(!0);
|
|
40
|
+
}, y = () => {
|
|
41
|
+
r(void 0), s(""), l(!1), n(!0);
|
|
42
|
+
}, f = /* @__PURE__ */ o(B, {
|
|
43
|
+
...i,
|
|
44
|
+
popupState: e,
|
|
45
|
+
localValue: c,
|
|
46
|
+
isValidTime: b,
|
|
47
|
+
isValidEndTime: g,
|
|
48
|
+
handleChange: H
|
|
49
|
+
});
|
|
50
|
+
return i.disabled || i.readOnly ? f : V ? /* @__PURE__ */ T("div", {
|
|
51
|
+
className: "relative h-auto w-auto",
|
|
52
|
+
children: [/* @__PURE__ */ o("div", {
|
|
53
|
+
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
54
|
+
children: f
|
|
55
|
+
}), /* @__PURE__ */ o(E, {
|
|
56
|
+
anchor: "bottom",
|
|
57
|
+
open: e.isOpen,
|
|
58
|
+
onClose: e.close,
|
|
59
|
+
anchorEl: e.anchorEl,
|
|
60
|
+
children: /* @__PURE__ */ o("div", {
|
|
61
|
+
className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
|
|
62
|
+
children: /* @__PURE__ */ o(L, {
|
|
63
|
+
dataTest: i.dataTest,
|
|
64
|
+
value: a,
|
|
65
|
+
onSelect: w,
|
|
66
|
+
handleClear: y,
|
|
67
|
+
onConfirm: e.close
|
|
68
|
+
})
|
|
65
69
|
})
|
|
70
|
+
})]
|
|
71
|
+
}) : /* @__PURE__ */ o(D, {
|
|
72
|
+
mouseEvent: "onMouseDown",
|
|
73
|
+
onClickAway: e.close,
|
|
74
|
+
children: /* @__PURE__ */ T("div", {
|
|
75
|
+
className: "relative h-auto w-auto",
|
|
76
|
+
children: [/* @__PURE__ */ o("div", {
|
|
77
|
+
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
78
|
+
children: f
|
|
79
|
+
}), e.isOpen && /* @__PURE__ */ o(O, {
|
|
80
|
+
...i,
|
|
81
|
+
popupState: e,
|
|
82
|
+
handleClear: y,
|
|
83
|
+
onSelect: w
|
|
84
|
+
})]
|
|
66
85
|
})
|
|
67
86
|
});
|
|
68
87
|
};
|
|
69
88
|
export {
|
|
70
|
-
|
|
89
|
+
Z as StyledTimePicker
|
|
71
90
|
};
|
|
@@ -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_qcipa_1",
|
|
3
|
+
"styled-time-picker-root_column": "_styled-time-picker-root_column_qcipa_4",
|
|
4
|
+
"styled-time-picker-root_cell": "_styled-time-picker-root_cell_qcipa_7",
|
|
5
|
+
"styled-time-picker-root_cell__cell-now": "_styled-time-picker-root_cell__cell-now_qcipa_10",
|
|
6
|
+
"styled-time-picker-root_cell__cell-selected": "_styled-time-picker-root_cell__cell-selected_qcipa_13",
|
|
7
|
+
"time-picker-surface": "_time-picker-surface_qcipa_17"
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
10
|
e as default
|
|
@@ -1,73 +1,35 @@
|
|
|
1
|
-
import { StyledButton as r } from "../../shared-components/button/StyledButton.js";
|
|
2
1
|
import { bindPopper as l } from "../../../hooks/usePopupState.js";
|
|
3
|
-
import { Paper as
|
|
2
|
+
import { Paper as n } from "../../../components/mui-compat/Paper.js";
|
|
4
3
|
import { Fade as c } from "../../../components/mui-compat/Fade.js";
|
|
5
|
-
import { Popper as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return /* @__PURE__ */ t(f, {
|
|
15
|
-
...l(e),
|
|
4
|
+
import { Popper as d } from "../../../components/mui-compat/Popper.js";
|
|
5
|
+
import f from "./StyledTimePicker.module.js";
|
|
6
|
+
import { TimePickerPanel as s } from "./components/TimePickerPanel.js";
|
|
7
|
+
import u from "clsx";
|
|
8
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
9
|
+
var C = (o) => {
|
|
10
|
+
const { popupState: r, dataTest: t, value: i, onSelect: m, handleClear: p } = o;
|
|
11
|
+
return /* @__PURE__ */ e(d, {
|
|
12
|
+
...l(r),
|
|
16
13
|
transition: !0,
|
|
17
14
|
style: { zIndex: "1300" },
|
|
18
|
-
children: ({ TransitionProps:
|
|
19
|
-
...
|
|
15
|
+
children: ({ TransitionProps: a }) => /* @__PURE__ */ e(c, {
|
|
16
|
+
...a,
|
|
20
17
|
timeout: 350,
|
|
21
|
-
children: /* @__PURE__ */
|
|
18
|
+
children: /* @__PURE__ */ e(n, {
|
|
22
19
|
elevation: 0,
|
|
23
|
-
className:
|
|
20
|
+
className: u(f["time-picker-surface"]),
|
|
24
21
|
style: { paddingBottom: "1px" },
|
|
25
|
-
children:
|
|
26
|
-
dataTest:
|
|
22
|
+
children: /* @__PURE__ */ e(s, {
|
|
23
|
+
dataTest: t,
|
|
27
24
|
value: i,
|
|
28
|
-
onSelect:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
marginTop: "12px",
|
|
33
|
-
marginBottom: "12px",
|
|
34
|
-
justifyContent: "space-between"
|
|
35
|
-
},
|
|
36
|
-
children: [/* @__PURE__ */ t(r, {
|
|
37
|
-
dataTest: "time-picker-erase-button",
|
|
38
|
-
"data-testid": "time-picker-erase-button",
|
|
39
|
-
variant: "text",
|
|
40
|
-
onClick: p,
|
|
41
|
-
size: "small",
|
|
42
|
-
disabled: !i,
|
|
43
|
-
style: {
|
|
44
|
-
minWidth: "40px",
|
|
45
|
-
marginLeft: "10px"
|
|
46
|
-
},
|
|
47
|
-
children: /* @__PURE__ */ t(x, {
|
|
48
|
-
width: 24,
|
|
49
|
-
height: 24
|
|
50
|
-
})
|
|
51
|
-
}), /* @__PURE__ */ t(r, {
|
|
52
|
-
dataTest: "time-picker-confirm-button",
|
|
53
|
-
"data-testid": "time-picker-confirm-button",
|
|
54
|
-
variant: "contained",
|
|
55
|
-
size: "small",
|
|
56
|
-
onClick: () => e.close(),
|
|
57
|
-
style: {
|
|
58
|
-
minWidth: "40px",
|
|
59
|
-
marginRight: "16px"
|
|
60
|
-
},
|
|
61
|
-
children: /* @__PURE__ */ t(k, {
|
|
62
|
-
width: 20,
|
|
63
|
-
height: 20
|
|
64
|
-
})
|
|
65
|
-
})]
|
|
66
|
-
})]
|
|
25
|
+
onSelect: m,
|
|
26
|
+
handleClear: p,
|
|
27
|
+
onConfirm: () => r.close()
|
|
28
|
+
})
|
|
67
29
|
})
|
|
68
30
|
})
|
|
69
31
|
});
|
|
70
32
|
};
|
|
71
33
|
export {
|
|
72
|
-
|
|
34
|
+
C as TimePickerPopper
|
|
73
35
|
};
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TimePickerColumn as
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { jsx as
|
|
5
|
-
var k = ({ value:
|
|
6
|
-
const
|
|
7
|
-
return
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import f from "../StyledTimePicker.module.js";
|
|
2
|
+
import { TimePickerColumn as s } from "./TimePickerColumn.js";
|
|
3
|
+
import { useEffect as u, useRef as d } from "react";
|
|
4
|
+
import { jsx as m, jsxs as p } from "react/jsx-runtime";
|
|
5
|
+
var k = ({ value: l, onSelect: i, dataTest: n }) => {
|
|
6
|
+
const t = d(null);
|
|
7
|
+
return u(() => {
|
|
8
|
+
const r = t.current;
|
|
9
|
+
if (!r) return;
|
|
10
|
+
const c = r.querySelectorAll('[data-cell="selected"]');
|
|
11
|
+
(c.length ? c : r.querySelectorAll('[data-cell="now"]')).forEach((o) => {
|
|
12
|
+
const e = o.parentElement;
|
|
13
|
+
e && (e.scrollTop = o.offsetTop - e.offsetTop - (e.clientHeight - o.clientHeight) / 2);
|
|
14
|
+
});
|
|
15
|
+
}, [t]), /* @__PURE__ */ p("div", {
|
|
16
|
+
ref: t,
|
|
17
|
+
"data-test": n,
|
|
18
|
+
className: f["styled-time-picker-root"],
|
|
19
|
+
children: [/* @__PURE__ */ m(s, {
|
|
15
20
|
type: "hours",
|
|
16
|
-
value:
|
|
17
|
-
onSelect:
|
|
18
|
-
}), /* @__PURE__ */
|
|
21
|
+
value: l,
|
|
22
|
+
onSelect: i
|
|
23
|
+
}), /* @__PURE__ */ m(s, {
|
|
19
24
|
type: "minutes",
|
|
20
|
-
value:
|
|
21
|
-
onSelect:
|
|
25
|
+
value: l,
|
|
26
|
+
onSelect: i
|
|
22
27
|
})]
|
|
23
28
|
});
|
|
24
29
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import r from "../StyledTimePicker.module.js";
|
|
2
|
-
import
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { getHours as
|
|
5
|
-
var b = ({ type:
|
|
6
|
-
const s = /* @__PURE__ */ new Date(), t =
|
|
7
|
-
return /* @__PURE__ */
|
|
2
|
+
import a from "clsx";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
import { getHours as _, getMinutes as k, set as w } from "date-fns";
|
|
5
|
+
var b = ({ type: m, value: o, onSelect: d }) => {
|
|
6
|
+
const s = /* @__PURE__ */ new Date(), t = m === "hours", u = t ? 24 : 12, p = t ? s.getHours() : s.getMinutes();
|
|
7
|
+
return /* @__PURE__ */ n("div", {
|
|
8
8
|
className: r["styled-time-picker-root_column"],
|
|
9
|
-
children: new Array(
|
|
10
|
-
const e = t ? i : i * 5,
|
|
11
|
-
return /* @__PURE__ */
|
|
9
|
+
children: new Array(u).fill(null).map((y, i) => {
|
|
10
|
+
const e = t ? i : i * 5, l = o && e === (t ? _(o) : k(o)), c = p == e;
|
|
11
|
+
return /* @__PURE__ */ n("button", {
|
|
12
12
|
type: "button",
|
|
13
|
-
|
|
13
|
+
"data-cell": l ? "selected" : c ? "now" : void 0,
|
|
14
|
+
className: a("border-0", r["styled-time-picker-root_cell"], c && r["styled-time-picker-root_cell__cell-now"], l && r["styled-time-picker-root_cell__cell-selected"]),
|
|
14
15
|
onClick: () => {
|
|
15
|
-
|
|
16
|
+
d(w(o ?? /* @__PURE__ */ new Date(), t ? { hours: e } : { minutes: e }));
|
|
16
17
|
},
|
|
17
18
|
children: e.toString().padStart(2, "0")
|
|
18
19
|
}, e);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { StyledButton as e } from "../../../shared-components/button/StyledButton.js";
|
|
2
|
+
import { TimePickerBody as d } 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: n, value: i, onSelect: a, handleClear: m, onConfirm: o }) => /* @__PURE__ */ r(p, { children: [/* @__PURE__ */ t(d, {
|
|
7
|
+
dataTest: `${n}-time-picker-body`,
|
|
8
|
+
value: i,
|
|
9
|
+
onSelect: a
|
|
10
|
+
}), /* @__PURE__ */ r("div", {
|
|
11
|
+
style: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
marginTop: "12px",
|
|
14
|
+
marginBottom: "12px",
|
|
15
|
+
justifyContent: "space-between"
|
|
16
|
+
},
|
|
17
|
+
children: [/* @__PURE__ */ t(e, {
|
|
18
|
+
dataTest: "time-picker-erase-button",
|
|
19
|
+
"data-testid": "time-picker-erase-button",
|
|
20
|
+
variant: "text",
|
|
21
|
+
onClick: m,
|
|
22
|
+
size: "small",
|
|
23
|
+
disabled: !i,
|
|
24
|
+
style: {
|
|
25
|
+
minWidth: "40px",
|
|
26
|
+
marginLeft: "10px"
|
|
27
|
+
},
|
|
28
|
+
children: /* @__PURE__ */ t(s, {
|
|
29
|
+
width: 24,
|
|
30
|
+
height: 24
|
|
31
|
+
})
|
|
32
|
+
}), /* @__PURE__ */ t(e, {
|
|
33
|
+
dataTest: "time-picker-confirm-button",
|
|
34
|
+
"data-testid": "time-picker-confirm-button",
|
|
35
|
+
variant: "contained",
|
|
36
|
+
size: "small",
|
|
37
|
+
onClick: o,
|
|
38
|
+
style: {
|
|
39
|
+
minWidth: "40px",
|
|
40
|
+
marginRight: "16px"
|
|
41
|
+
},
|
|
42
|
+
children: /* @__PURE__ */ t(c, {
|
|
43
|
+
width: 20,
|
|
44
|
+
height: 20
|
|
45
|
+
})
|
|
46
|
+
})]
|
|
47
|
+
})] });
|
|
48
|
+
export {
|
|
49
|
+
g as TimePickerPanel
|
|
50
|
+
};
|
|
@@ -7,6 +7,7 @@ import { StyledTimePickerProps } from './types';
|
|
|
7
7
|
* The dropdown follows the **Menus** surface (delta-300 border + Menus shadow `0 2 4 rgba(34,33,51,
|
|
8
8
|
* .15)`): scrollable hour/minute columns of 36px cells — hover delta-50, "now" gama-50 (like the
|
|
9
9
|
* calendar "today"), selected gama-500 white — plus an eraser + confirm footer. State (Enabled/Focus/
|
|
10
|
-
* Error/Disabled) ← the field.
|
|
10
|
+
* Error/Disabled) ← the field. On mobile (≤768px) the same panel opens in a bottom-sheet `Drawer`
|
|
11
|
+
* instead of the popper, matching `StyledDatePicker`. Non-annotated props are behavioral.
|
|
11
12
|
*/
|
|
12
13
|
export declare const StyledTimePicker: React.FC<StyledTimePickerProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TimePickerPanelProps {
|
|
2
|
+
dataTest: string;
|
|
3
|
+
value?: Date;
|
|
4
|
+
onSelect: (date: Date | undefined) => void;
|
|
5
|
+
handleClear: () => void;
|
|
6
|
+
onConfirm: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Hour/minute columns + eraser/confirm footer — the inner picker surface shared by the desktop
|
|
10
|
+
* popper (`TimePickerPopper`) and the mobile bottom-sheet drawer (`StyledTimePicker`).
|
|
11
|
+
*/
|
|
12
|
+
export declare const TimePickerPanel: React.FC<TimePickerPanelProps>;
|