asma-ui-core 3.108.2 → 3.108.4

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 (23) hide show
  1. package/dist/asma-ui-core.css +1 -1
  2. package/dist/components/feedback/dialog/StyledDialog.js +139 -96
  3. package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +180 -171
  4. package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +115 -106
  5. package/dist/components/inputs/select/StyledSelect.js +56 -50
  6. package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +102 -96
  7. package/dist/components/navigation/drawer/StyledDrawer.js +55 -51
  8. package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +158 -118
  9. package/dist/components/utils/popover/PopoverSheet.js +95 -85
  10. package/dist/components/utils/popover/StyledPopover.js +81 -71
  11. package/dist/datetime/components/date-picker/StyledDatePicker.js +33 -28
  12. package/dist/datetime/components/date-picker/components/StyledCalendarPicker.js +9 -8
  13. package/dist/datetime/components/time-picker/StyledTimePicker.js +56 -51
  14. package/dist/datetime/hooks/useBackNavigationClose.hook.js +16 -7
  15. package/dist/hooks/useBackCloses.hook.js +100 -0
  16. package/dist/src/components/feedback/dialog/StyledDialog.d.ts +6 -1
  17. package/dist/src/components/navigation/drawer/StyledDrawer.d.ts +2 -0
  18. package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +6 -2
  19. package/dist/src/components/utils/popover/StyledPopover.d.ts +3 -1
  20. package/dist/src/datetime/hooks/useBackNavigationClose.hook.d.ts +2 -1
  21. package/dist/src/hooks/useBackCloses.hook.d.ts +101 -0
  22. package/dist/src/hooks/useBackCloses.hook.test.d.ts +1 -0
  23. package/package.json +1 -1
@@ -1,124 +1,134 @@
1
1
  import { cn as Y } from "../../../helpers/cn.js";
2
- import { resolveSx as R } from "../../../helpers/sx.js";
3
- import { tabbableWithin as y } from "../../../helpers/focusable.js";
4
- import { TOP_LAYER_PROPS as W, TOP_LAYER_RESET_STYLE as $, getOpenModalDialogAncestor as j, shouldUsePopoverTopLayer as q, useTopLayerRef as B } from "../../../hooks/useTopLayer.hook.js";
5
- import { useEffect as P, useMemo as G, useRef as J, useState as h } from "react";
6
- import { jsx as T } from "react/jsx-runtime";
7
- import { FloatingPortal as Q, autoUpdate as V, flip as X, offset as Z, shift as C, useDismiss as ee, useFloating as te, useInteractions as oe, useMergeRefs as ne } from "@floating-ui/react";
8
- var re = {
2
+ import { resolveSx as h } from "../../../helpers/sx.js";
3
+ import { tabbableWithin as g } from "../../../helpers/focusable.js";
4
+ import { TOP_LAYER_PROPS as W, TOP_LAYER_RESET_STYLE as $, getOpenModalDialogAncestor as j, shouldUsePopoverTopLayer as q, useTopLayerRef as C } from "../../../hooks/useTopLayer.hook.js";
5
+ import { OverlayBackOwnerContext as G, useBackCloses as J } from "../../../hooks/useBackCloses.hook.js";
6
+ import { useEffect as w, useMemo as Q, useRef as V, useState as x } from "react";
7
+ import { jsx as P } from "react/jsx-runtime";
8
+ import { FloatingPortal as X, autoUpdate as Z, flip as ee, offset as te, shift as oe, useDismiss as ne, useFloating as re, useInteractions as se, useMergeRefs as ie } from "@floating-ui/react";
9
+ var ae = {
9
10
  vertical: "bottom",
10
11
  horizontal: "left"
11
- }, se = {
12
+ }, ce = {
12
13
  vertical: "top",
13
14
  horizontal: "left"
14
- }, ie = (o, t) => `${t.vertical === "bottom" ? "top" : t.vertical === "top" ? "bottom" : o.vertical === "top" ? "top" : "bottom"}${o.horizontal === "left" ? "-start" : o.horizontal === "right" ? "-end" : ""}`, ve = ({ open: o, anchorEl: t, onClose: u, anchorOrigin: b = re, transformOrigin: L = se, id: x, className: D, sx: K, slotProps: l, onClick: S, children: _, keepMounted: E = !1, tabIntoContent: d = !0 }) => {
15
- const F = G(() => ie(b, L), [b, L]), [w, O] = h(o), c = J(!1);
16
- o && !w && O(!0);
17
- const m = o || E && w, p = j(t), [v, k] = h(p);
18
- t && v !== p && k(p);
19
- const { refs: a, floatingStyles: M, context: A } = te({
20
- open: o,
21
- placement: F,
15
+ }, fe = (t, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : t.vertical === "top" ? "top" : "bottom"}${t.horizontal === "left" ? "-start" : t.horizontal === "right" ? "-end" : ""}`, Pe = ({ open: t, anchorEl: o, onClose: c, anchorOrigin: b = ae, transformOrigin: L = ce, id: D, className: T, sx: K, slotProps: l, onClick: k, children: E, keepMounted: O = !1, tabIntoContent: d = !0, registerBackClose: S = !0 }) => {
16
+ const _ = Q(() => fe(b, L), [b, L]), [R, F] = x(t), f = V(!1);
17
+ t && !R && F(!0);
18
+ const m = t || O && R, p = j(o), [v, M] = x(p);
19
+ o && v !== p && M(p);
20
+ const { refs: i, floatingStyles: A, context: N } = re({
21
+ open: t,
22
+ placement: _,
22
23
  strategy: "fixed",
23
- whileElementsMounted: V,
24
- elements: { reference: t ?? void 0 },
24
+ whileElementsMounted: Z,
25
+ elements: { reference: o ?? void 0 },
25
26
  middleware: [
26
- Z(4),
27
- X({ padding: 8 }),
28
- C({ padding: 8 })
27
+ te(4),
28
+ ee({ padding: 8 }),
29
+ oe({ padding: 8 })
29
30
  ],
30
31
  onOpenChange: (e, r, n) => {
31
- e || u?.(r ?? {}, n === "escape-key" ? "escapeKeyDown" : "backdropClick");
32
+ e || c?.(r ?? {}, n === "escape-key" ? "escapeKeyDown" : "backdropClick");
32
33
  }
33
- }), { getFloatingProps: N } = oe([ee(A, {
34
+ }), { getFloatingProps: z } = se([ne(N, {
34
35
  outsidePress: (e) => {
35
36
  const r = e.target;
36
- return !(t instanceof Element && r instanceof Node && t.contains(r));
37
+ return !(o instanceof Element && r instanceof Node && o.contains(r));
37
38
  },
38
39
  escapeKey: !0
39
- })]), f = q(v), z = ne([B(a.setFloating, f)]);
40
- P(() => {
41
- if (!o) return;
42
- const e = t instanceof HTMLElement ? t : null, r = () => a.floating.current?.contains(document.activeElement) ?? !1;
40
+ })]);
41
+ J({
42
+ active: t && S,
43
+ requestClose: (e) => c ? c(e ?? new Event("overlayBack"), "escapeKeyDown") : !1,
44
+ ownerRef: i.floating
45
+ });
46
+ const u = q(v), H = ie([C(i.setFloating, u)]);
47
+ w(() => {
48
+ if (!t) return;
49
+ const e = o instanceof HTMLElement ? o : null, r = () => i.floating.current?.contains(document.activeElement) ?? !1;
43
50
  let n = r();
44
51
  const s = () => {
45
52
  n = r();
46
53
  };
47
54
  return document.addEventListener("focusin", s), () => {
48
55
  document.removeEventListener("focusin", s);
49
- const i = document.activeElement, g = !i || i === document.body || r();
50
- n && g && e?.isConnected && e.focus({ preventScroll: !0 });
56
+ const a = document.activeElement, y = !a || a === document.body || r();
57
+ n && y && e?.isConnected && e.focus({ preventScroll: !0 });
51
58
  };
52
59
  }, [
53
- o,
54
60
  t,
55
- a.floating
56
- ]), P(() => {
57
- if (!o) return;
61
+ o,
62
+ i.floating
63
+ ]), w(() => {
64
+ if (!t) return;
58
65
  const e = (n) => {
59
- if (c.current = n.key === "Tab", !d || !c.current || n.shiftKey || n.defaultPrevented) return;
60
- const s = a.floating.current;
61
- if (!s || !(t instanceof Element) || !t.contains(document.activeElement)) return;
62
- const [i] = y(s);
63
- i && (n.preventDefault(), i.focus({ preventScroll: !0 }), c.current = !1);
66
+ if (f.current = n.key === "Tab", !d || !f.current || n.shiftKey || n.defaultPrevented) return;
67
+ const s = i.floating.current;
68
+ if (!s || !(o instanceof Element) || !o.contains(document.activeElement)) return;
69
+ const [a] = g(s);
70
+ a && (n.preventDefault(), a.focus({ preventScroll: !0 }), f.current = !1);
64
71
  }, r = (n) => {
65
- const s = n.target, i = s instanceof Node && ((a.floating.current?.contains(s) ?? !1) || t instanceof Element && t.contains(s));
66
- c.current && !i && u?.(n, "tabKeyDown"), c.current = !1;
72
+ const s = n.target, a = s instanceof Node && ((i.floating.current?.contains(s) ?? !1) || o instanceof Element && o.contains(s));
73
+ f.current && !a && c?.(n, "tabKeyDown"), f.current = !1;
67
74
  };
68
75
  return document.addEventListener("keydown", e, !0), document.addEventListener("focusin", r), () => {
69
76
  document.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", r);
70
77
  };
71
78
  }, [
72
- o,
73
79
  t,
74
- u,
75
- a.floating,
80
+ o,
81
+ c,
82
+ i.floating,
76
83
  d
77
84
  ]);
78
- const H = o ? N({
79
- onClick: S,
85
+ const U = t ? z({
86
+ onClick: k,
80
87
  onKeyDown: (e) => {
81
- if (e.key !== "Tab" || e.defaultPrevented || !(t instanceof HTMLElement)) return;
82
- const r = e.currentTarget, n = y(r), s = n.indexOf(document.activeElement);
88
+ if (e.key !== "Tab" || e.defaultPrevented || !(o instanceof HTMLElement)) return;
89
+ const r = e.currentTarget, n = g(r), s = n.indexOf(document.activeElement);
83
90
  if (s === -1 || (e.shiftKey ? s !== 0 : s !== n.length - 1)) return;
84
91
  e.preventDefault();
85
- const i = y(document).filter((I) => !r.contains(I)), g = i[i.indexOf(t) + (e.shiftKey ? -1 : 1)], U = (d && e.shiftKey ? void 0 : g) ?? t;
86
- c.current = !1, U.focus({ preventScroll: !0 }), u?.(e, "tabKeyDown");
92
+ const a = g(document).filter((I) => !r.contains(I)), y = a[a.indexOf(o) + (e.shiftKey ? -1 : 1)], B = (d && e.shiftKey ? void 0 : y) ?? o;
93
+ f.current = !1, B.focus({ preventScroll: !0 }), c?.(e, "tabKeyDown");
87
94
  }
88
95
  }) : {};
89
- return P(() => {
90
- if (!m || !f) return;
91
- const e = a.floating.current;
96
+ return w(() => {
97
+ if (!m || !u) return;
98
+ const e = i.floating.current;
92
99
  if (!(!e || typeof e.showPopover != "function"))
93
100
  try {
94
- o && !e.matches(":popover-open") && e.showPopover(), !o && e.matches(":popover-open") && e.hidePopover();
101
+ t && !e.matches(":popover-open") && e.showPopover(), !t && e.matches(":popover-open") && e.hidePopover();
95
102
  } catch {
96
103
  }
97
104
  }, [
98
- o,
105
+ t,
99
106
  m,
100
- f,
101
- a.floating
102
- ]), m ? /* @__PURE__ */ T(Q, {
107
+ u,
108
+ i.floating
109
+ ]), m ? /* @__PURE__ */ P(X, {
103
110
  root: v,
104
- children: /* @__PURE__ */ T("div", {
105
- ref: z,
106
- id: x,
107
- ...f ? W : {},
111
+ children: /* @__PURE__ */ P("div", {
112
+ ref: H,
113
+ id: D,
114
+ ...u ? W : {},
108
115
  style: {
109
- ...f ? $ : {},
110
- ...o ? M : {},
111
- ...R(K),
112
- ...R(l?.paper?.sx),
116
+ ...u ? $ : {},
117
+ ...t ? A : {},
118
+ ...h(K),
119
+ ...h(l?.paper?.sx),
113
120
  ...l?.paper?.style,
114
- ...o ? null : { display: "none" }
121
+ ...t ? null : { display: "none" }
115
122
  },
116
- ...H,
117
- className: Y("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", D ?? "my-1", l?.paper?.className),
118
- children: _
123
+ ...U,
124
+ className: Y("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", T ?? "my-1", l?.paper?.className),
125
+ children: /* @__PURE__ */ P(G.Provider, {
126
+ value: i.floating,
127
+ children: E
128
+ })
119
129
  })
120
130
  }) : null;
121
131
  };
122
132
  export {
123
- ve as StyledPopover
133
+ Pe as StyledPopover
124
134
  };
@@ -1,40 +1,44 @@
1
- import { setPickerPosition as P } from "./helpers.js";
2
- import { StyledDayPicker as k } from "./components/StyledDayPicker.js";
3
- import { StyledCalendarPicker as v } from "./components/StyledCalendarPicker.js";
4
- import { DatePickerInputIndex as y } from "./components/DatePickerInputIndex.js";
1
+ import { isOverlayBackEnabled as k, useBackCloses as P } from "../../../hooks/useBackCloses.hook.js";
2
+ import { setPickerPosition as v } from "./helpers.js";
3
+ import { StyledDayPicker as y } from "./components/StyledDayPicker.js";
4
+ import { StyledCalendarPicker as C } from "./components/StyledCalendarPicker.js";
5
+ import { DatePickerInputIndex as b } from "./components/DatePickerInputIndex.js";
5
6
  import { useIsMobileView as x } from "../../hooks/useWindowWidthSize.hook.js";
6
- import { StyledDrawer as b } from "../../../components/navigation/drawer/StyledDrawer.js";
7
- import { useBackNavigationClose as h } from "../../hooks/useBackNavigationClose.hook.js";
8
- import { useEffect as C, useState as s } from "react";
9
- import { Fragment as D, jsx as t, jsxs as E } from "react/jsx-runtime";
10
- var L = (p) => {
11
- const i = x(), [e, c] = s(null), [m, d] = s(!1), [f, l] = s(!1), u = (r) => {
12
- c(r.currentTarget), P(r, d);
7
+ import { StyledDrawer as h } from "../../../components/navigation/drawer/StyledDrawer.js";
8
+ import { useBackNavigationClose as E } from "../../hooks/useBackNavigationClose.hook.js";
9
+ import { useEffect as D, useState as n } from "react";
10
+ import { Fragment as g, jsx as t, jsxs as w } from "react/jsx-runtime";
11
+ var N = (p) => {
12
+ const i = x(), [e, l] = n(null), [m, d] = n(!1), [f, c] = n(!1), u = (r) => {
13
+ l(r.currentTarget), v(r, d);
13
14
  }, o = () => {
14
- l(!0), c(null);
15
+ c(!0), l(null);
15
16
  };
16
- C(() => {
17
+ D(() => {
17
18
  if (!e) return;
18
- const r = (n) => {
19
- document.activeElement === e && (n.key === "Escape" ? (n.preventDefault(), n.stopPropagation(), o()) : n.key === "Tab" && o());
19
+ const r = (a) => {
20
+ document.activeElement === e && (a.key === "Escape" ? (a.preventDefault(), a.stopPropagation(), o()) : a.key === "Tab" && o());
20
21
  };
21
22
  return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
22
- }, [e]), h({
23
- open: !!e,
23
+ }, [e]), P({
24
+ active: !!e,
25
+ requestClose: o
26
+ }), E({
27
+ open: !!e && !k(),
24
28
  onClose: o
25
29
  });
26
- const a = {
30
+ const s = {
27
31
  ...p,
28
32
  validateOnCalendarClose: f,
29
- onValidatedOnce: () => l(!1)
33
+ onValidatedOnce: () => c(!1)
30
34
  };
31
- return /* @__PURE__ */ E(D, { children: [
32
- /* @__PURE__ */ t(y, {
33
- datePickerProps: a,
35
+ return /* @__PURE__ */ w(g, { children: [
36
+ /* @__PURE__ */ t(b, {
37
+ datePickerProps: s,
34
38
  onClick: u
35
39
  }),
36
- !i && /* @__PURE__ */ t(v, {
37
- datePickerProps: { ...a },
40
+ !i && /* @__PURE__ */ t(C, {
41
+ datePickerProps: { ...s },
38
42
  popoverProps: {
39
43
  open: !!e,
40
44
  anchorEl: e,
@@ -42,15 +46,16 @@ var L = (p) => {
42
46
  },
43
47
  positionAbove: m
44
48
  }),
45
- i && /* @__PURE__ */ t(b, {
49
+ i && /* @__PURE__ */ t(h, {
46
50
  anchor: "bottom",
47
51
  open: !!e,
48
52
  onClose: o,
49
53
  anchorEl: e,
54
+ registerBackClose: !1,
50
55
  children: /* @__PURE__ */ t("div", {
51
56
  className: "mx-auto max-w-[360px] px-2 pb-[max(1.5rem,env(safe-area-inset-bottom))]",
52
- children: /* @__PURE__ */ t(k, {
53
- datePickerProps: { ...a },
57
+ children: /* @__PURE__ */ t(y, {
58
+ datePickerProps: { ...s },
54
59
  popoverProps: {
55
60
  open: !!e,
56
61
  anchorEl: e,
@@ -62,5 +67,5 @@ var L = (p) => {
62
67
  ] });
63
68
  };
64
69
  export {
65
- L as StyledDatePicker
70
+ N as StyledDatePicker
66
71
  };
@@ -1,30 +1,31 @@
1
1
  import { StyledPopover as i } from "../../../../components/utils/popover/StyledPopover.js";
2
2
  import { StyledDayPicker as c } from "./StyledDayPicker.js";
3
3
  import { jsx as r } from "react/jsx-runtime";
4
- var h = ({ datePickerProps: e, popoverProps: t, positionAbove: o }) => {
5
- const { open: l, anchorEl: n, onClose: a } = t;
4
+ var d = ({ datePickerProps: o, popoverProps: t, positionAbove: e }) => {
5
+ const { open: l, anchorEl: a, onClose: n } = t;
6
6
  return /* @__PURE__ */ r(i, {
7
7
  open: l,
8
- anchorEl: n,
9
- onClose: a,
8
+ anchorEl: a,
9
+ onClose: n,
10
10
  tabIntoContent: !1,
11
+ registerBackClose: !1,
11
12
  anchorOrigin: {
12
- vertical: o ? "top" : 50,
13
+ vertical: e ? "top" : 50,
13
14
  horizontal: "left"
14
15
  },
15
16
  transformOrigin: {
16
- vertical: o ? "bottom" : "top",
17
+ vertical: e ? "bottom" : "top",
17
18
  horizontal: "left"
18
19
  },
19
20
  children: /* @__PURE__ */ r("div", {
20
21
  className: "p-4",
21
22
  children: /* @__PURE__ */ r(c, {
22
- datePickerProps: e,
23
+ datePickerProps: o,
23
24
  popoverProps: t
24
25
  })
25
26
  })
26
27
  });
27
28
  };
28
29
  export {
29
- h as StyledCalendarPicker
30
+ d as StyledCalendarPicker
30
31
  };
@@ -1,110 +1,115 @@
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";
1
+ import { isOverlayBackEnabled as I, useBackCloses as j } from "../../../hooks/useBackCloses.hook.js";
2
+ import { useIsMobileView as M } from "../../hooks/useWindowWidthSize.hook.js";
3
+ import { StyledDrawer as A } from "../../../components/navigation/drawer/StyledDrawer.js";
4
+ import { useBackNavigationClose as q } from "../../hooks/useBackNavigationClose.hook.js";
5
+ import { usePopupState as F } from "../../../hooks/usePopupState.js";
6
+ import { ClickAwayListener as K } from "../../../components/mui-compat/ClickAwayListener.js";
7
+ import { isBeforeMinTime as E } from "./helpers/minTime.js";
8
+ import { TimePickerPanel as z } from "./components/TimePickerPanel.js";
9
+ import { TimePickerPopper as G } from "./TimePickerPopper.js";
9
10
  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({
11
+ import { TimePickerInput as J } from "./TimePickerInput.js";
12
+ import { useEffect as Q, useState as V } from "react";
13
+ import { jsx as r, jsxs as B } from "react/jsx-runtime";
14
+ import { format as w, isBefore as R, isValid as U } from "date-fns";
15
+ var le = (i) => {
16
+ const { value: s, onSelect: n, notBeforeTime: d, minTime: c } = i, o = F({
16
17
  variant: "popper",
17
18
  popupId: "time-picker-popper"
18
- }), m = I();
19
- M({
20
- open: m && o.isOpen,
19
+ }), m = M();
20
+ j({
21
+ active: o.isOpen,
22
+ requestClose: o.close
23
+ }), q({
24
+ open: m && o.isOpen && !I(),
21
25
  onClose: o.close
22
26
  });
23
- const { isOpen: x, anchorEl: P, close: h } = o;
24
- G(() => {
27
+ const { isOpen: x, anchorEl: C, close: h } = o;
28
+ Q(() => {
25
29
  if (!x || m) return;
26
30
  const e = (t) => {
27
- P?.contains(document.activeElement) && (t.key === "Escape" ? (t.preventDefault(), t.stopPropagation(), h()) : t.key === "Tab" && h());
31
+ C?.contains(document.activeElement) && (t.key === "Escape" ? (t.preventDefault(), t.stopPropagation(), h()) : t.key === "Tab" && h());
28
32
  };
29
33
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
30
34
  }, [
31
35
  x,
32
- P,
36
+ C,
33
37
  h,
34
38
  m
35
39
  ]);
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) => {
40
+ const P = s ? w(s, "HH:mm") : "", [O, u] = V(P), [T, a] = V(!1), [D, l] = V(!0), v = T ? O : P, k = (e) => !e || !d || !U(d) || !R(e, d), f = v.length === 5 ? g(v, s) : null, H = f ? k(f) : !0, L = (e) => {
37
41
  const t = e.target.value;
38
42
  if (a(!0), u(t), t.length !== 5) {
39
- s(!1);
43
+ l(!1);
40
44
  return;
41
45
  }
42
- const p = g(t, l);
46
+ const p = g(t, s);
43
47
  if (!p) {
44
- n(void 0), s(!1);
48
+ n(void 0), l(!1);
45
49
  return;
46
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);
51
+ l(!0), !E(p, c) && (k(p) ? (n(p), a(!1), o.close()) : n(void 0));
52
+ }, S = (e) => {
53
+ if (!(e && E(e, c))) {
54
+ if (l(!0), k(e)) {
55
+ n(e), u(e ? w(e, "HH:mm") : ""), a(!1);
52
56
  return;
53
57
  }
54
- n(void 0), u(e ? E(e, "HH:mm") : ""), a(!0);
58
+ n(void 0), u(e ? w(e, "HH:mm") : ""), a(!0);
55
59
  }
56
- }, B = () => {
57
- S && f && V(f, c) && a(!1);
60
+ }, N = () => {
61
+ T && f && E(f, c) && a(!1);
58
62
  }, b = () => {
59
- n(void 0), u(""), a(!1), s(!0);
60
- }, k = /* @__PURE__ */ r(z, {
63
+ n(void 0), u(""), a(!1), l(!0);
64
+ }, y = /* @__PURE__ */ r(J, {
61
65
  ...i,
62
66
  popupState: o,
63
67
  localValue: v,
64
- isValidTime: L,
65
- isValidEndTime: N,
66
- handleChange: O,
67
- handleBlur: B
68
+ isValidTime: D,
69
+ isValidEndTime: H,
70
+ handleChange: L,
71
+ handleBlur: N
68
72
  });
69
- return i.disabled || i.readOnly ? k : m ? /* @__PURE__ */ D("div", {
73
+ return i.disabled || i.readOnly ? y : m ? /* @__PURE__ */ B("div", {
70
74
  className: "relative h-auto w-auto",
71
75
  children: [/* @__PURE__ */ r("div", {
72
76
  className: "m-0 flex h-fit items-center justify-center p-0",
73
- children: k
74
- }), /* @__PURE__ */ r(j, {
77
+ children: y
78
+ }), /* @__PURE__ */ r(A, {
75
79
  anchor: "bottom",
76
80
  open: o.isOpen,
77
81
  onClose: o.close,
78
82
  anchorEl: o.anchorEl,
83
+ registerBackClose: !1,
79
84
  children: /* @__PURE__ */ r("div", {
80
85
  className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
81
- children: /* @__PURE__ */ r(K, {
86
+ children: /* @__PURE__ */ r(z, {
82
87
  dataTest: i.dataTest,
83
- value: l,
88
+ value: s,
84
89
  minTime: c,
85
- onSelect: C,
90
+ onSelect: S,
86
91
  handleClear: b,
87
92
  onConfirm: o.close
88
93
  })
89
94
  })
90
95
  })]
91
- }) : /* @__PURE__ */ r(F, {
96
+ }) : /* @__PURE__ */ r(K, {
92
97
  mouseEvent: "onMouseDown",
93
98
  onClickAway: o.close,
94
- children: /* @__PURE__ */ D("div", {
99
+ children: /* @__PURE__ */ B("div", {
95
100
  className: "relative h-auto w-auto",
96
101
  children: [/* @__PURE__ */ r("div", {
97
102
  className: "m-0 flex h-fit items-center justify-center p-0",
98
- children: k
99
- }), o.isOpen && /* @__PURE__ */ r(q, {
103
+ children: y
104
+ }), o.isOpen && /* @__PURE__ */ r(G, {
100
105
  ...i,
101
106
  popupState: o,
102
107
  handleClear: b,
103
- onSelect: C
108
+ onSelect: S
104
109
  })]
105
110
  })
106
111
  });
107
112
  };
108
113
  export {
109
- ne as StyledTimePicker
114
+ le as StyledTimePicker
110
115
  };
@@ -1,10 +1,19 @@
1
- import { useEffect as r } from "react";
2
- var o = ({ open: t, onClose: e }) => (r(() => {
3
- if (t)
4
- return window.history.pushState({ modal: !0 }, ""), window.addEventListener("popstate", e), () => {
5
- window.removeEventListener("popstate", e), window.history.state?.modal && window.history.back();
1
+ import { useEffect as i, useRef as c } from "react";
2
+ var n = "__asmaPickerBack", u = ({ open: r, onClose: e }) => {
3
+ const o = c(e);
4
+ i(() => {
5
+ o.current = e;
6
+ }, [e]), i(() => {
7
+ if (!r) return;
8
+ const t = window.rawWindow ?? window, s = crypto.randomUUID(), a = () => o.current();
9
+ return t.history.pushState({
10
+ ...t.history.state,
11
+ [n]: s
12
+ }, "", t.location.href), t.addEventListener("popstate", a), () => {
13
+ t.removeEventListener("popstate", a), t.history.state?.[n] === s && t.history.back();
6
14
  };
7
- }, [t]), null);
15
+ }, [r]);
16
+ };
8
17
  export {
9
- o as useBackNavigationClose
18
+ u as useBackNavigationClose
10
19
  };
@@ -0,0 +1,100 @@
1
+ import { createContext as v, useContext as y, useEffect as p, useRef as O } from "react";
2
+ function _() {
3
+ return {
4
+ version: 1,
5
+ entries: [],
6
+ adapter: { unregister: null }
7
+ };
8
+ }
9
+ function a() {
10
+ if (!(typeof window > "u"))
11
+ return window.rawWindow ?? document.defaultView ?? window;
12
+ }
13
+ function l() {
14
+ const e = a();
15
+ return e ? e.__asmaOverlayBackRegistry__ ??= _() : k ??= _();
16
+ }
17
+ var k, B = (e) => typeof e == "object" && e !== null && typeof e.then == "function";
18
+ function d(e, n) {
19
+ if (e.parentOwnerRef && e.parentOwnerRef === n.ownerRef) return !0;
20
+ const t = e.parentOwnerRef?.current ?? e.parentOwner, i = n.ownerRef?.current ?? n.owner;
21
+ return !!t && !!i && (t === i || i.contains(t));
22
+ }
23
+ function w(e) {
24
+ if (e.adapter.unregister) return;
25
+ const n = a()?.__ASMA__SHELL__?.overlayBack;
26
+ n?.v !== 1 || typeof n.register != "function" || (e.adapter.unregister = n.register(() => S()));
27
+ }
28
+ function A(e) {
29
+ e.adapter.unregister && Promise.resolve().then(() => {
30
+ if (e.entries.length > 0) return;
31
+ const n = e.adapter.unregister;
32
+ e.adapter.unregister = null, n?.();
33
+ });
34
+ }
35
+ function L(e, n = null, t = null, i, o) {
36
+ const r = l(), s = {
37
+ requestClose: e,
38
+ pending: !1,
39
+ owner: n,
40
+ parentOwner: t,
41
+ ownerRef: i,
42
+ parentOwnerRef: o
43
+ }, c = n || i ? r.entries.findIndex((u) => i !== void 0 && u.parentOwnerRef === i || n !== null && u.parentOwner === n || n !== null && u.owner !== null && n.contains(u.owner)) : -1;
44
+ r.entries.splice(c === -1 ? r.entries.length : c, 0, s), r.entries.length === 1 && w(r);
45
+ let f = !1;
46
+ return () => {
47
+ if (f) return;
48
+ f = !0;
49
+ const u = r.entries.indexOf(s);
50
+ if (u !== -1 && r.entries.splice(u, 1), r.entries.length === 0) {
51
+ A(r);
52
+ return;
53
+ }
54
+ queueMicrotask(() => {
55
+ const g = a()?.__ASMA__SHELL__?.overlayBack;
56
+ r.entries.length > 0 && g?.pendingNavigation && g.continuePendingNavigation?.();
57
+ });
58
+ };
59
+ }
60
+ var R = v(void 0);
61
+ function S(e) {
62
+ const { entries: n } = l(), t = n.reduce((o, r) => !o || d(r, o) ? r : d(o, r) ? o : r, void 0);
63
+ if (!t) return;
64
+ if (t.pending) return !1;
65
+ const i = t.requestClose(e);
66
+ if (B(i)) {
67
+ t.pending = !0;
68
+ const o = () => {
69
+ t.pending = !1, globalThis.setTimeout(() => {
70
+ const r = l(), s = a()?.__ASMA__SHELL__?.overlayBack;
71
+ r.entries.includes(t) && s?.pendingNavigation && s.failOpenPendingNavigation?.();
72
+ }, 0);
73
+ };
74
+ i.then(o, o);
75
+ }
76
+ return i;
77
+ }
78
+ function E() {
79
+ const e = a()?.__ASMA__SHELL__?.overlayBack;
80
+ return e?.v === 1 && e.enabled === !0;
81
+ }
82
+ function m({ active: e, requestClose: n, ownerRef: t }) {
83
+ const i = y(R), o = O(n);
84
+ p(() => {
85
+ o.current = n;
86
+ }, [n]), p(() => {
87
+ if (e)
88
+ return L((r) => o.current(r), t?.current ?? null, i?.current ?? null, t, i);
89
+ }, [
90
+ e,
91
+ t,
92
+ i
93
+ ]);
94
+ }
95
+ export {
96
+ R as OverlayBackOwnerContext,
97
+ E as isOverlayBackEnabled,
98
+ S as requestCloseTopOverlayBack,
99
+ m as useBackCloses
100
+ };