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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/feedback/dialog/StyledDialog.js +139 -96
- package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +180 -171
- package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +115 -106
- package/dist/components/inputs/select/StyledSelect.js +56 -50
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +102 -96
- package/dist/components/navigation/drawer/StyledDrawer.js +55 -51
- package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +158 -118
- package/dist/components/utils/popover/PopoverSheet.js +95 -85
- package/dist/components/utils/popover/StyledPopover.js +81 -71
- package/dist/datetime/components/date-picker/StyledDatePicker.js +33 -28
- package/dist/datetime/components/date-picker/components/StyledCalendarPicker.js +9 -8
- package/dist/datetime/components/time-picker/StyledTimePicker.js +56 -51
- package/dist/datetime/hooks/useBackNavigationClose.hook.js +16 -7
- package/dist/hooks/useBackCloses.hook.js +100 -0
- package/dist/src/components/feedback/dialog/StyledDialog.d.ts +6 -1
- package/dist/src/components/navigation/drawer/StyledDrawer.d.ts +2 -0
- package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +6 -2
- package/dist/src/components/utils/popover/StyledPopover.d.ts +3 -1
- package/dist/src/datetime/hooks/useBackNavigationClose.hook.d.ts +2 -1
- package/dist/src/hooks/useBackCloses.hook.d.ts +101 -0
- package/dist/src/hooks/useBackCloses.hook.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,124 +1,134 @@
|
|
|
1
1
|
import { cn as Y } from "../../../helpers/cn.js";
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { tabbableWithin as
|
|
4
|
-
import { TOP_LAYER_PROPS as W, TOP_LAYER_RESET_STYLE as $, getOpenModalDialogAncestor as j, shouldUsePopoverTopLayer as q, useTopLayerRef as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
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
|
-
},
|
|
12
|
+
}, ce = {
|
|
12
13
|
vertical: "top",
|
|
13
14
|
horizontal: "left"
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const m =
|
|
18
|
-
|
|
19
|
-
const { refs:
|
|
20
|
-
open:
|
|
21
|
-
placement:
|
|
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:
|
|
24
|
-
elements: { reference:
|
|
24
|
+
whileElementsMounted: Z,
|
|
25
|
+
elements: { reference: o ?? void 0 },
|
|
25
26
|
middleware: [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
te(4),
|
|
28
|
+
ee({ padding: 8 }),
|
|
29
|
+
oe({ padding: 8 })
|
|
29
30
|
],
|
|
30
31
|
onOpenChange: (e, r, n) => {
|
|
31
|
-
e ||
|
|
32
|
+
e || c?.(r ?? {}, n === "escape-key" ? "escapeKeyDown" : "backdropClick");
|
|
32
33
|
}
|
|
33
|
-
}), { getFloatingProps:
|
|
34
|
+
}), { getFloatingProps: z } = se([ne(N, {
|
|
34
35
|
outsidePress: (e) => {
|
|
35
36
|
const r = e.target;
|
|
36
|
-
return !(
|
|
37
|
+
return !(o instanceof Element && r instanceof Node && o.contains(r));
|
|
37
38
|
},
|
|
38
39
|
escapeKey: !0
|
|
39
|
-
})])
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
50
|
-
n &&
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
o,
|
|
62
|
+
i.floating
|
|
63
|
+
]), w(() => {
|
|
64
|
+
if (!t) return;
|
|
58
65
|
const e = (n) => {
|
|
59
|
-
if (
|
|
60
|
-
const s =
|
|
61
|
-
if (!s || !(
|
|
62
|
-
const [
|
|
63
|
-
|
|
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,
|
|
66
|
-
|
|
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
|
-
|
|
75
|
-
|
|
80
|
+
o,
|
|
81
|
+
c,
|
|
82
|
+
i.floating,
|
|
76
83
|
d
|
|
77
84
|
]);
|
|
78
|
-
const
|
|
79
|
-
onClick:
|
|
85
|
+
const U = t ? z({
|
|
86
|
+
onClick: k,
|
|
80
87
|
onKeyDown: (e) => {
|
|
81
|
-
if (e.key !== "Tab" || e.defaultPrevented || !(
|
|
82
|
-
const r = e.currentTarget, n =
|
|
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
|
|
86
|
-
|
|
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
|
|
90
|
-
if (!m || !
|
|
91
|
-
const e =
|
|
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
|
-
|
|
101
|
+
t && !e.matches(":popover-open") && e.showPopover(), !t && e.matches(":popover-open") && e.hidePopover();
|
|
95
102
|
} catch {
|
|
96
103
|
}
|
|
97
104
|
}, [
|
|
98
|
-
|
|
105
|
+
t,
|
|
99
106
|
m,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
]), m ? /* @__PURE__ */
|
|
107
|
+
u,
|
|
108
|
+
i.floating
|
|
109
|
+
]), m ? /* @__PURE__ */ P(X, {
|
|
103
110
|
root: v,
|
|
104
|
-
children: /* @__PURE__ */
|
|
105
|
-
ref:
|
|
106
|
-
id:
|
|
107
|
-
...
|
|
111
|
+
children: /* @__PURE__ */ P("div", {
|
|
112
|
+
ref: H,
|
|
113
|
+
id: D,
|
|
114
|
+
...u ? W : {},
|
|
108
115
|
style: {
|
|
109
|
-
...
|
|
110
|
-
...
|
|
111
|
-
...
|
|
112
|
-
...
|
|
116
|
+
...u ? $ : {},
|
|
117
|
+
...t ? A : {},
|
|
118
|
+
...h(K),
|
|
119
|
+
...h(l?.paper?.sx),
|
|
113
120
|
...l?.paper?.style,
|
|
114
|
-
...
|
|
121
|
+
...t ? null : { display: "none" }
|
|
115
122
|
},
|
|
116
|
-
...
|
|
117
|
-
className: Y("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]",
|
|
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
|
-
|
|
133
|
+
Pe as StyledPopover
|
|
124
134
|
};
|
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
7
|
-
import { useBackNavigationClose as
|
|
8
|
-
import { useEffect as
|
|
9
|
-
import { Fragment as
|
|
10
|
-
var
|
|
11
|
-
const i = x(), [e,
|
|
12
|
-
|
|
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
|
-
|
|
15
|
+
c(!0), l(null);
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
D(() => {
|
|
17
18
|
if (!e) return;
|
|
18
|
-
const r = (
|
|
19
|
-
document.activeElement === e && (
|
|
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]),
|
|
23
|
-
|
|
23
|
+
}, [e]), P({
|
|
24
|
+
active: !!e,
|
|
25
|
+
requestClose: o
|
|
26
|
+
}), E({
|
|
27
|
+
open: !!e && !k(),
|
|
24
28
|
onClose: o
|
|
25
29
|
});
|
|
26
|
-
const
|
|
30
|
+
const s = {
|
|
27
31
|
...p,
|
|
28
32
|
validateOnCalendarClose: f,
|
|
29
|
-
onValidatedOnce: () =>
|
|
33
|
+
onValidatedOnce: () => c(!1)
|
|
30
34
|
};
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */ t(
|
|
33
|
-
datePickerProps:
|
|
35
|
+
return /* @__PURE__ */ w(g, { children: [
|
|
36
|
+
/* @__PURE__ */ t(b, {
|
|
37
|
+
datePickerProps: s,
|
|
34
38
|
onClick: u
|
|
35
39
|
}),
|
|
36
|
-
!i && /* @__PURE__ */ t(
|
|
37
|
-
datePickerProps: { ...
|
|
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(
|
|
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(
|
|
53
|
-
datePickerProps: { ...
|
|
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
|
-
|
|
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
|
|
5
|
-
const { open: l, anchorEl:
|
|
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:
|
|
9
|
-
onClose:
|
|
8
|
+
anchorEl: a,
|
|
9
|
+
onClose: n,
|
|
10
10
|
tabIntoContent: !1,
|
|
11
|
+
registerBackClose: !1,
|
|
11
12
|
anchorOrigin: {
|
|
12
|
-
vertical:
|
|
13
|
+
vertical: e ? "top" : 50,
|
|
13
14
|
horizontal: "left"
|
|
14
15
|
},
|
|
15
16
|
transformOrigin: {
|
|
16
|
-
vertical:
|
|
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:
|
|
23
|
+
datePickerProps: o,
|
|
23
24
|
popoverProps: t
|
|
24
25
|
})
|
|
25
26
|
})
|
|
26
27
|
});
|
|
27
28
|
};
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
+
d as StyledCalendarPicker
|
|
30
31
|
};
|
|
@@ -1,110 +1,115 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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
|
|
11
|
-
import { useEffect as
|
|
12
|
-
import { jsx as r, jsxs as
|
|
13
|
-
import { format as
|
|
14
|
-
var
|
|
15
|
-
const { value:
|
|
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 =
|
|
19
|
-
|
|
20
|
-
|
|
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:
|
|
24
|
-
|
|
27
|
+
const { isOpen: x, anchorEl: C, close: h } = o;
|
|
28
|
+
Q(() => {
|
|
25
29
|
if (!x || m) return;
|
|
26
30
|
const e = (t) => {
|
|
27
|
-
|
|
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
|
-
|
|
36
|
+
C,
|
|
33
37
|
h,
|
|
34
38
|
m
|
|
35
39
|
]);
|
|
36
|
-
const
|
|
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
|
-
|
|
43
|
+
l(!1);
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
|
-
const p = g(t,
|
|
46
|
+
const p = g(t, s);
|
|
43
47
|
if (!p) {
|
|
44
|
-
n(void 0),
|
|
48
|
+
n(void 0), l(!1);
|
|
45
49
|
return;
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
if (!(e &&
|
|
50
|
-
if (
|
|
51
|
-
n(e), u(e ?
|
|
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 ?
|
|
58
|
+
n(void 0), u(e ? w(e, "HH:mm") : ""), a(!0);
|
|
55
59
|
}
|
|
56
|
-
},
|
|
57
|
-
|
|
60
|
+
}, N = () => {
|
|
61
|
+
T && f && E(f, c) && a(!1);
|
|
58
62
|
}, b = () => {
|
|
59
|
-
n(void 0), u(""), a(!1),
|
|
60
|
-
},
|
|
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:
|
|
65
|
-
isValidEndTime:
|
|
66
|
-
handleChange:
|
|
67
|
-
handleBlur:
|
|
68
|
+
isValidTime: D,
|
|
69
|
+
isValidEndTime: H,
|
|
70
|
+
handleChange: L,
|
|
71
|
+
handleBlur: N
|
|
68
72
|
});
|
|
69
|
-
return i.disabled || i.readOnly ?
|
|
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:
|
|
74
|
-
}), /* @__PURE__ */ r(
|
|
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(
|
|
86
|
+
children: /* @__PURE__ */ r(z, {
|
|
82
87
|
dataTest: i.dataTest,
|
|
83
|
-
value:
|
|
88
|
+
value: s,
|
|
84
89
|
minTime: c,
|
|
85
|
-
onSelect:
|
|
90
|
+
onSelect: S,
|
|
86
91
|
handleClear: b,
|
|
87
92
|
onConfirm: o.close
|
|
88
93
|
})
|
|
89
94
|
})
|
|
90
95
|
})]
|
|
91
|
-
}) : /* @__PURE__ */ r(
|
|
96
|
+
}) : /* @__PURE__ */ r(K, {
|
|
92
97
|
mouseEvent: "onMouseDown",
|
|
93
98
|
onClickAway: o.close,
|
|
94
|
-
children: /* @__PURE__ */
|
|
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:
|
|
99
|
-
}), o.isOpen && /* @__PURE__ */ r(
|
|
103
|
+
children: y
|
|
104
|
+
}), o.isOpen && /* @__PURE__ */ r(G, {
|
|
100
105
|
...i,
|
|
101
106
|
popupState: o,
|
|
102
107
|
handleClear: b,
|
|
103
|
-
onSelect:
|
|
108
|
+
onSelect: S
|
|
104
109
|
})]
|
|
105
110
|
})
|
|
106
111
|
});
|
|
107
112
|
};
|
|
108
113
|
export {
|
|
109
|
-
|
|
114
|
+
le as StyledTimePicker
|
|
110
115
|
};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { useEffect as
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
}, [
|
|
15
|
+
}, [r]);
|
|
16
|
+
};
|
|
8
17
|
export {
|
|
9
|
-
|
|
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
|
+
};
|