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.
@@ -1,71 +1,90 @@
1
- import { PopupState as j } from "../../../hooks/usePopupState.js";
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 { TimePickerPopper as E } from "./TimePickerPopper.js";
4
- import { getTimeFromValue as P } from "./helpers/getTimeFromValue.js";
5
- import { TimePickerInput as T } from "./TimePickerInput.js";
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 A } from "react/jsx-runtime";
8
- import { format as v, isBefore as B, isValid as N } from "date-fns";
9
- var J = (l) => {
10
- const { value: a, onSelect: i, notBeforeTime: m } = l, V = a ? v(a, "HH:mm") : "", [x, s] = h(V), [w, t] = h(!1), [g, n] = h(!0), c = w ? x : V, u = (e) => !e || !m || !N(m) || !B(e, m), k = c.length === 5 ? P(c, a) : null, y = k ? u(k) : !0, C = (e) => {
11
- const r = e.close;
12
- r?.();
13
- }, H = (e, r) => {
14
- const d = e.target.value;
15
- if (t(!0), s(d), d.length !== 5) {
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 f = P(d, a);
20
- if (!f) {
21
- i(void 0), n(!1);
28
+ const d = S(p, a);
29
+ if (!d) {
30
+ r(void 0), n(!1);
22
31
  return;
23
32
  }
24
- n(!0), u(f) ? (i(f), t(!1), C(r)) : i(void 0);
25
- }, I = (e) => {
26
- if (n(!0), u(e)) {
27
- i(e), s(e ? v(e, "HH:mm") : ""), t(!1);
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
- i(void 0), s(e ? v(e, "HH:mm") : ""), t(!0);
31
- }, L = () => {
32
- i(void 0), s(""), t(!1), n(!0);
33
- };
34
- return /* @__PURE__ */ o(j, {
35
- variant: "popper",
36
- popupId: "time-picker-popper",
37
- children: (e) => l.disabled || l.readOnly ? /* @__PURE__ */ o(T, {
38
- ...l,
39
- popupState: e,
40
- localValue: c,
41
- isValidTime: g,
42
- isValidEndTime: y,
43
- handleChange: (r) => H(r, e)
44
- }) : /* @__PURE__ */ o(D, {
45
- mouseEvent: "onMouseDown",
46
- onClickAway: () => C(e),
47
- children: /* @__PURE__ */ A("div", {
48
- className: "relative h-auto w-auto",
49
- children: [/* @__PURE__ */ o("div", {
50
- className: "m-0 flex h-fit items-center justify-center p-0",
51
- children: /* @__PURE__ */ o(T, {
52
- ...l,
53
- popupState: e,
54
- localValue: c,
55
- isValidTime: g,
56
- isValidEndTime: y,
57
- handleChange: (r) => H(r, e)
58
- })
59
- }), e.isOpen && /* @__PURE__ */ o(E, {
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
- J as StyledTimePicker
89
+ Z as StyledTimePicker
71
90
  };
@@ -1,10 +1,10 @@
1
1
  var e = {
2
- "styled-time-picker-root": "_styled-time-picker-root_ck82a_1",
3
- "styled-time-picker-root_column": "_styled-time-picker-root_column_ck82a_4",
4
- "styled-time-picker-root_cell": "_styled-time-picker-root_cell_ck82a_7",
5
- "styled-time-picker-root_cell__cell-now": "_styled-time-picker-root_cell__cell-now_ck82a_10",
6
- "styled-time-picker-root_cell__cell-selected": "_styled-time-picker-root_cell__cell-selected_ck82a_13",
7
- "time-picker-surface": "_time-picker-surface_ck82a_17"
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 s } from "../../../components/mui-compat/Paper.js";
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 f } from "../../../components/mui-compat/Popper.js";
6
- import h from "./StyledTimePicker.module.js";
7
- import { TimePickerBody as u } from "./components/TimePickerBody.js";
8
- import { EraserIcon as x } from "../../shared-components/EraserIcon.js";
9
- import { CheckIcon as k } from "../../shared-components/CheckIcon.js";
10
- import y from "clsx";
11
- import { jsx as t, jsxs as o } from "react/jsx-runtime";
12
- var I = (m) => {
13
- const { popupState: e, dataTest: a, value: i, onSelect: n, handleClear: p } = m;
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: d }) => /* @__PURE__ */ t(c, {
19
- ...d,
15
+ children: ({ TransitionProps: a }) => /* @__PURE__ */ e(c, {
16
+ ...a,
20
17
  timeout: 350,
21
- children: /* @__PURE__ */ o(s, {
18
+ children: /* @__PURE__ */ e(n, {
22
19
  elevation: 0,
23
- className: y(h["time-picker-surface"]),
20
+ className: u(f["time-picker-surface"]),
24
21
  style: { paddingBottom: "1px" },
25
- children: [/* @__PURE__ */ t(u, {
26
- dataTest: `${a}-time-picker-body`,
22
+ children: /* @__PURE__ */ e(s, {
23
+ dataTest: t,
27
24
  value: i,
28
- onSelect: n
29
- }), /* @__PURE__ */ o("div", {
30
- style: {
31
- display: "flex",
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
- I as TimePickerPopper
34
+ C as TimePickerPopper
73
35
  };
@@ -1,24 +1,29 @@
1
- import m from "../StyledTimePicker.module.js";
2
- import { TimePickerColumn as l } from "./TimePickerColumn.js";
3
- import { useEffect as d, useRef as u } from "react";
4
- import { jsx as o, jsxs as n } from "react/jsx-runtime";
5
- var k = ({ value: t, onSelect: r, dataTest: c }) => {
6
- const e = u(null);
7
- return d(() => {
8
- const i = e.current?.querySelectorAll("div.styled-time-picker-root_cell__cell-selected").length;
9
- e.current?.querySelectorAll(i ? "div.styled-time-picker-root_cell__cell-selected" : "div.styled-time-picker-root_cell__cell-now").forEach((s) => s.scrollIntoView());
10
- }, [e]), /* @__PURE__ */ n("div", {
11
- ref: e,
12
- "data-test": c,
13
- className: m["styled-time-picker-root"],
14
- children: [/* @__PURE__ */ o(l, {
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: t,
17
- onSelect: r
18
- }), /* @__PURE__ */ o(l, {
21
+ value: l,
22
+ onSelect: i
23
+ }), /* @__PURE__ */ m(s, {
19
24
  type: "minutes",
20
- value: t,
21
- onSelect: r
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 _ from "clsx";
3
- import { jsx as c } from "react/jsx-runtime";
4
- import { getHours as a, getMinutes as k, set as y } from "date-fns";
5
- var b = ({ type: l, value: o, onSelect: n }) => {
6
- const s = /* @__PURE__ */ new Date(), t = l === "hours", m = t ? 24 : 12, u = t ? s.getHours() : s.getMinutes();
7
- return /* @__PURE__ */ c("div", {
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(m).fill(null).map((f, i) => {
10
- const e = t ? i : i * 5, d = o && e === (t ? a(o) : k(o)), p = u == e;
11
- return /* @__PURE__ */ c("button", {
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
- className: _("border-0", r["styled-time-picker-root_cell"], p && r["styled-time-picker-root_cell__cell-now"], d && r["styled-time-picker-root_cell__cell-selected"]),
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
- n(y(o ?? /* @__PURE__ */ new Date(), t ? { hours: e } : { minutes: e }));
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. Non-annotated props are behavioral.
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>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.71.0",
6
+ "version": "3.72.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",