asma-ui-core 3.131.1 → 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.
Files changed (26) hide show
  1. package/dist/asma-ui-core.css +1 -1
  2. package/dist/datetime/components/time-picker/StyledTimePicker.js +102 -88
  3. package/dist/datetime/components/time-picker/StyledTimePicker.module.js +6 -6
  4. package/dist/datetime/components/time-picker/TimePickerInput.js +44 -44
  5. package/dist/datetime/components/time-picker/TimePickerPopper.js +22 -20
  6. package/dist/datetime/components/time-picker/components/TimePickerBody.js +23 -19
  7. package/dist/datetime/components/time-picker/components/TimePickerColumn.js +25 -18
  8. package/dist/datetime/components/time-picker/components/TimePickerPanel.js +13 -11
  9. package/dist/datetime/components/time-picker/helpers/disabledTime.js +13 -0
  10. package/dist/src/datetime/components/time-picker/TimePickerInput.d.ts +2 -0
  11. package/dist/src/datetime/components/time-picker/components/TimePickerPanel.d.ts +4 -0
  12. package/dist/src/datetime/components/time-picker/helpers/disabledTime.d.ts +35 -0
  13. package/dist/src/datetime/components/time-picker/types.d.ts +20 -0
  14. package/dist/src/table/custom-features/order-columns/columnLayout.d.ts +37 -4
  15. package/dist/src/table/custom-features/order-columns/types.d.ts +23 -3
  16. package/dist/src/table/helpers/columnIds.d.ts +4 -0
  17. package/dist/src/table/helpers/tableStorage.d.ts +2 -1
  18. package/dist/src/table/hooks/useColumnLayoutPersistence.d.ts +77 -0
  19. package/dist/src/table/hooks/useColumnLayoutPersistence.test.d.ts +1 -0
  20. package/dist/src/table/types.d.ts +30 -0
  21. package/dist/table/custom-features/order-columns/columnLayout.js +26 -7
  22. package/dist/table/helpers/columnIds.js +12 -11
  23. package/dist/table/helpers/tableStorage.js +11 -10
  24. package/dist/table/hooks/useColumnLayoutPersistence.js +139 -0
  25. package/dist/table/hooks/useStyledTable.js +132 -95
  26. package/package.json +1 -1
@@ -1,125 +1,139 @@
1
- import { cn as L } from "../../../helpers/cn.js";
2
- import { isOverlayBackEnabled as K, useBackCloses as R } from "../../../hooks/useBackCloses.hook.js";
3
- import { useIsMobileView as W } from "../../hooks/useWindowWidthSize.hook.js";
4
- import { StyledDrawer as z } from "../../../components/navigation/drawer/StyledDrawer.js";
5
- import { useBackNavigationClose as G } from "../../hooks/useBackNavigationClose.hook.js";
6
- import { usePopupState as J } from "../../../hooks/usePopupState.js";
7
- import { ClickAwayListener as Q } from "../../../components/mui-compat/ClickAwayListener.js";
8
- import { isBeforeMinTime as T } from "./helpers/minTime.js";
9
- import { TimePickerPanel as U } from "./components/TimePickerPanel.js";
10
- import { TimePickerPopper as X } from "./TimePickerPopper.js";
11
- import { getTimeFromValue as V } from "./helpers/getTimeFromValue.js";
12
- import { timePickerWidthProps as M } from "./helpers/timePickerWidth.js";
13
- import { TimePickerInput as Y } from "./TimePickerInput.js";
14
- import { useEffect as Z, useState as b } from "react";
15
- import { jsx as n, jsxs as j } from "react/jsx-runtime";
16
- import { format as S, isBefore as _, isValid as $ } from "date-fns";
17
- var ve = (i) => {
18
- const { value: s, onSelect: r, notBeforeTime: v, minTime: u, required: k } = i, o = J({
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
- }), f = W();
22
- R({
23
- active: o.isOpen,
24
- requestClose: o.close
25
- }), G({
26
- open: f && o.isOpen && !K(),
27
- onClose: o.close
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: x, anchorEl: g, close: w } = o;
30
- Z(() => {
31
- if (!x || f) return;
32
- const e = (t) => {
33
- g?.contains(document.activeElement) && (t.key === "Escape" ? (t.preventDefault(), t.stopPropagation(), w()) : t.key === "Tab" && w());
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
- x,
38
- g,
39
- w,
40
- f
38
+ O,
39
+ D,
40
+ E,
41
+ d
41
42
  ]);
42
- const B = s ? S(s, "HH:mm") : "", [y, d] = b(B), [E, a] = b(!1), [C, c] = b(!1), l = E ? y : B, p = (e) => !e || !v || !$(v) || !_(e, v), m = l.length === 5 ? V(l, s) : null, I = !C || l === "" || m !== null, A = !C || !m || p(m), O = !!k && C && l === "", N = (e) => {
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 t = V(e, s);
45
- return t !== null && p(t);
46
- }, q = (e) => {
47
- const t = e.target.value;
48
- if (a(!0), d(t), (O || N(t)) && c(!1), t.length !== 5) return;
49
- const h = V(t, s);
50
- if (!h) {
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
- T(h, u) || (p(h) ? (r(h), a(!1), o.close()) : r(void 0));
55
- }, D = (e) => {
56
- if (e && T(e, u)) return;
57
- const t = p(e);
58
- if (c(!t), t) {
59
- r(e), d(e ? S(e, "HH:mm") : ""), a(!1);
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), d(e ? S(e, "HH:mm") : ""), a(!0);
63
- }, F = () => {
64
- if (k && l === "" && !o.isOpen) {
65
- E && r(void 0), c(!0);
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
- E && (m && T(m, u) ? a(!1) : y === "" ? r(void 0) : N(y) || c(!0));
69
- }, H = () => {
70
- r(void 0), d(""), a(!1), c(!!k);
71
- }, P = /* @__PURE__ */ n(Y, {
72
- ...i,
73
- popupState: o,
74
- localValue: l,
75
- isValidTime: I,
76
- isValidEndTime: A,
77
- isMissingTime: O,
78
- handleChange: q,
79
- handleBlur: F
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 i.disabled || i.readOnly || i.lockedReason ? P : f ? /* @__PURE__ */ j("div", {
82
- className: L("relative h-auto", typeof i.width == "number" && "w-auto"),
83
- ...M(i.width),
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(z, {
99
+ }), /* @__PURE__ */ n(X, {
88
100
  anchor: "bottom",
89
- open: o.isOpen,
90
- onClose: o.close,
91
- anchorEl: o.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(U, {
96
- dataTest: i.dataTest,
107
+ children: /* @__PURE__ */ n($, {
108
+ dataTest: t.dataTest,
97
109
  value: s,
98
- minTime: u,
99
- onSelect: D,
100
- handleClear: H,
101
- onConfirm: o.close
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(Q, {
119
+ }) : /* @__PURE__ */ n(_, {
106
120
  mouseEvent: "onMouseDown",
107
- onClickAway: o.close,
108
- children: /* @__PURE__ */ j("div", {
109
- className: L("relative h-auto", typeof i.width == "number" && "w-auto"),
110
- ...M(i.width),
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
- }), o.isOpen && /* @__PURE__ */ n(X, {
115
- ...i,
116
- popupState: o,
117
- handleClear: H,
118
- onSelect: D
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
- ve as StyledTimePicker
138
+ Te as StyledTimePicker
125
139
  };
@@ -1,10 +1,10 @@
1
1
  var e = {
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"
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 A } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
2
- import { fieldLabelAboveClass as B } from "../../../components/inputs/field-styles.js";
3
- import { StyledInputField as M } from "../../../components/inputs/input-field/StyledInputField.js";
4
- import { getTitleLabelling as O } from "../../helpers/getTitleLabelling.js";
5
- import { useInputMask as w } from "../../../helpers/inputMask.js";
6
- import { HelperText as H, defaultTimePickerHelperMessages as V } from "./components/HelperText.js";
7
- import { timePickerWidthProps as W } from "./helpers/timePickerWidth.js";
8
- import { useEffect as j, useId as q, useRef as z } from "react";
9
- import { jsx as o, jsxs as L } from "react/jsx-runtime";
10
- var Y = (g) => {
11
- const { placeholder: k, disabled: e, inputClassName: T, dataTest: m, width: t, error: p, helperText: C, label: d, locale: I = "en", popupState: i, handleChange: P, handleBlur: b, isValidTime: u, isValidEndTime: c, isMissingTime: f, localValue: v, title: l, required: y, readOnly: E, lockedReason: a, inputAriaProps: N } = g, s = !!E || !!a, R = w({
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
- }), h = !u || !c || !!f || !!p, n = z(null), x = q();
16
- return j(() => {
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__ */ L("div", {
19
- ...W(t),
18
+ }, []), /* @__PURE__ */ S("div", {
19
+ ...j(r),
20
20
  "data-helper-room-box": "",
21
21
  children: [l && /* @__PURE__ */ o("div", {
22
- id: x,
23
- className: B({ disabled: e }),
22
+ id: T,
23
+ className: M({ disabled: e }),
24
24
  children: l
25
- }), /* @__PURE__ */ o(M, {
26
- inputRef: R,
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: h,
34
- helperText: /* @__PURE__ */ o(H, {
33
+ error: x,
34
+ helperText: h ?? /* @__PURE__ */ o(V, {
35
35
  isValidTime: u,
36
36
  isValidEndTime: c,
37
37
  isMissingTime: f,
38
- error: !!p,
38
+ error: !!d,
39
39
  localization: I,
40
- helperText: C,
41
- messages: V
40
+ helperText: b,
41
+ messages: W
42
42
  }),
43
43
  onChange: P,
44
- onBlur: b,
44
+ onBlur: v,
45
45
  slotProps: {
46
46
  htmlInput: {
47
- "aria-required": y ? !0 : void 0,
48
- ...O({
47
+ "aria-required": E ? !0 : void 0,
48
+ ...w({
49
49
  title: l,
50
- titleId: x,
51
- label: d,
52
- inputAriaProps: N
50
+ titleId: T,
51
+ label: p,
52
+ inputAriaProps: R
53
53
  })
54
54
  },
55
55
  input: {
56
56
  ref: n,
57
- onClick: (r) => {
58
- !e && !s && i.open(r);
57
+ onClick: (t) => {
58
+ !e && !s && i.open(t);
59
59
  },
60
- endAdornment: !a && /* @__PURE__ */ o(A, {
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: (r) => {
65
- r.stopPropagation(), !e && !s && i.open(r);
64
+ onClick: (t) => {
65
+ t.stopPropagation(), !e && !s && i.open(t);
66
66
  }
67
67
  })
68
68
  },
69
69
  formHelperText: {
70
- className: h ? "ml-0 mr-[14px] mt-1 leading-[23.24px]" : "mx-[14px] mt-1 leading-[23.24px]",
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: v,
75
- sx: typeof t == "number" ? {
76
- maxWidth: t,
77
- width: t,
78
- minWidth: t
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: T,
84
- label: d
83
+ className: C,
84
+ label: p
85
85
  })]
86
86
  });
87
87
  };
88
88
  export {
89
- Y as TimePickerInput
89
+ Z as TimePickerInput
90
90
  };
@@ -1,30 +1,32 @@
1
- import { bindPopper as n } from "../../../hooks/usePopupState.js";
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 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";
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 _ = (o) => {
10
- const { popupState: r, dataTest: t, value: i, minTime: m, onSelect: p, handleClear: a } = o;
11
- return /* @__PURE__ */ e(f, {
12
- ...n(r),
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: l }) => /* @__PURE__ */ e(d, {
16
- ...l,
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(s["time-picker-surface"]),
20
+ className: x(P["time-picker-surface"]),
21
21
  style: { paddingBottom: "1px" },
22
- children: /* @__PURE__ */ e(u, {
23
- dataTest: t,
24
- value: i,
25
- minTime: m,
26
- onSelect: p,
27
- handleClear: a,
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
- _ as TimePickerPopper
37
+ g as TimePickerPopper
36
38
  };
@@ -1,10 +1,10 @@
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(() => {
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__ */ a("div", {
15
+ }, [t]), /* @__PURE__ */ h("div", {
16
16
  ref: t,
17
- "data-test": m,
18
- className: u["styled-time-picker-root"],
19
- children: [/* @__PURE__ */ f(n, {
17
+ "data-test": p,
18
+ className: d["styled-time-picker-root"],
19
+ children: [/* @__PURE__ */ u(m, {
20
20
  type: "hours",
21
- value: l,
22
- onSelect: c,
23
- minTime: s
24
- }), /* @__PURE__ */ f(n, {
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: l,
27
- onSelect: c,
28
- minTime: s
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
- g as TimePickerBody
37
+ P as TimePickerBody
34
38
  };
@@ -1,28 +1,35 @@
1
- import r from "../StyledTimePicker.module.js";
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", {
9
- className: r["styled-time-picker-root_column"],
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", {
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: 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
+ 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
- const m = M(o ?? /* @__PURE__ */ new Date(), t ? { hours: e } : { minutes: e });
19
- p(t ? w(m, s) : m);
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
- C as TimePickerColumn
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 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, {
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
- onSelect: n
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: o,
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(s, {
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: d,
42
+ onClick: s,
41
43
  style: {
42
44
  minWidth: "40px",
43
45
  marginRight: "16px"
44
46
  },
45
- children: /* @__PURE__ */ t(c, {
47
+ children: /* @__PURE__ */ t(h, {
46
48
  width: 20,
47
49
  height: 20
48
50
  })
49
51
  })]
50
52
  })] });
51
53
  export {
52
- g as TimePickerPanel
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
+ };