asma-ui-core 3.134.3 → 3.134.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.
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { tabbableWithin as
|
|
4
|
-
import { TOP_LAYER_PROPS as
|
|
5
|
-
import { OverlayBackOwnerContext as
|
|
6
|
-
import { useEffect as
|
|
7
|
-
import { jsx as
|
|
8
|
-
import { FloatingPortal as
|
|
9
|
-
var
|
|
1
|
+
import { cn as $ } 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 j, TOP_LAYER_RESET_STYLE as q, getOpenModalDialogAncestor as C, shouldUsePopoverTopLayer as G, useTopLayerRef as J } from "../../../hooks/useTopLayer.hook.js";
|
|
5
|
+
import { OverlayBackOwnerContext as Q, useBackCloses as V } from "../../../hooks/useBackCloses.hook.js";
|
|
6
|
+
import { useEffect as P, useMemo as X, useRef as Z, useState as w } from "react";
|
|
7
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
8
|
+
import { FloatingPortal as ee, autoUpdate as te, flip as oe, offset as ne, shift as re, size as se, useDismiss as ie, useFloating as ae, useInteractions as ce, useMergeRefs as fe } from "@floating-ui/react";
|
|
9
|
+
var ue = {
|
|
10
10
|
vertical: "bottom",
|
|
11
11
|
horizontal: "left"
|
|
12
|
-
},
|
|
12
|
+
}, le = {
|
|
13
13
|
vertical: "top",
|
|
14
14
|
horizontal: "left"
|
|
15
|
-
},
|
|
16
|
-
const _ =
|
|
17
|
-
t && !
|
|
18
|
-
const m = t || O &&
|
|
19
|
-
o && v !== p &&
|
|
20
|
-
const { refs: i, floatingStyles:
|
|
15
|
+
}, de = (t, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : t.vertical === "top" ? "top" : "bottom"}${t.horizontal === "left" ? "-start" : t.horizontal === "right" ? "-end" : ""}`, be = ({ open: t, anchorEl: o, onClose: c, anchorOrigin: h = ue, transformOrigin: b = le, id: D, className: T, sx: K, slotProps: l, onClick: k, children: E, keepMounted: O = !1, tabIntoContent: d = !0, registerBackClose: S = !0 }) => {
|
|
16
|
+
const _ = X(() => de(h, b), [h, b]), [L, F] = w(t), f = Z(!1), [M, H] = w();
|
|
17
|
+
t && !L && F(!0);
|
|
18
|
+
const m = t || O && L, p = C(o), [v, A] = w(p);
|
|
19
|
+
o && v !== p && A(p);
|
|
20
|
+
const { refs: i, floatingStyles: z, context: N } = ae({
|
|
21
21
|
open: t,
|
|
22
22
|
placement: _,
|
|
23
23
|
strategy: "fixed",
|
|
24
|
-
whileElementsMounted:
|
|
24
|
+
whileElementsMounted: te,
|
|
25
25
|
elements: { reference: o ?? void 0 },
|
|
26
26
|
middleware: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
ne(4),
|
|
28
|
+
oe({ padding: 8 }),
|
|
29
|
+
re({ padding: 8 }),
|
|
30
|
+
se({
|
|
31
|
+
padding: 8,
|
|
32
|
+
apply: ({ availableHeight: e }) => H(e)
|
|
33
|
+
})
|
|
30
34
|
],
|
|
31
35
|
onOpenChange: (e, r, n) => {
|
|
32
36
|
e || c?.(r ?? {}, n === "escape-key" ? "escapeKeyDown" : "backdropClick");
|
|
33
37
|
}
|
|
34
|
-
}), { getFloatingProps:
|
|
38
|
+
}), { getFloatingProps: U } = ce([ie(N, {
|
|
35
39
|
outsidePress: (e) => {
|
|
36
40
|
const r = e.target;
|
|
37
41
|
return !(o instanceof Element && r instanceof Node && o.contains(r));
|
|
38
42
|
},
|
|
39
43
|
escapeKey: !0
|
|
40
44
|
})]);
|
|
41
|
-
|
|
45
|
+
V({
|
|
42
46
|
active: t && S,
|
|
43
47
|
requestClose: (e) => c ? c(e ?? new Event("overlayBack"), "escapeKeyDown") : !1,
|
|
44
48
|
ownerRef: i.floating
|
|
45
49
|
});
|
|
46
|
-
const u =
|
|
47
|
-
|
|
50
|
+
const u = G(v), B = fe([J(i.setFloating, u)]);
|
|
51
|
+
P(() => {
|
|
48
52
|
if (!t) return;
|
|
49
53
|
const e = o instanceof HTMLElement ? o : null, r = () => i.floating.current?.contains(document.activeElement) ?? !1;
|
|
50
54
|
let n = r();
|
|
@@ -53,20 +57,20 @@ var ae = {
|
|
|
53
57
|
};
|
|
54
58
|
return document.addEventListener("focusin", s), () => {
|
|
55
59
|
document.removeEventListener("focusin", s);
|
|
56
|
-
const a = document.activeElement,
|
|
57
|
-
n &&
|
|
60
|
+
const a = document.activeElement, g = !a || a === document.body || r();
|
|
61
|
+
n && g && e?.isConnected && e.focus({ preventScroll: !0 });
|
|
58
62
|
};
|
|
59
63
|
}, [
|
|
60
64
|
t,
|
|
61
65
|
o,
|
|
62
66
|
i.floating
|
|
63
|
-
]),
|
|
67
|
+
]), P(() => {
|
|
64
68
|
if (!t) return;
|
|
65
69
|
const e = (n) => {
|
|
66
70
|
if (f.current = n.key === "Tab", !d || !f.current || n.shiftKey || n.defaultPrevented) return;
|
|
67
71
|
const s = i.floating.current;
|
|
68
72
|
if (!s || !(o instanceof Element) || !o.contains(document.activeElement)) return;
|
|
69
|
-
const [a] =
|
|
73
|
+
const [a] = y(s);
|
|
70
74
|
a && (n.preventDefault(), a.focus({ preventScroll: !0 }), f.current = !1);
|
|
71
75
|
}, r = (n) => {
|
|
72
76
|
const s = n.target, a = s instanceof Node && ((i.floating.current?.contains(s) ?? !1) || o instanceof Element && o.contains(s));
|
|
@@ -82,18 +86,18 @@ var ae = {
|
|
|
82
86
|
i.floating,
|
|
83
87
|
d
|
|
84
88
|
]);
|
|
85
|
-
const
|
|
89
|
+
const I = t ? U({
|
|
86
90
|
onClick: k,
|
|
87
91
|
onKeyDown: (e) => {
|
|
88
92
|
if (e.key !== "Tab" || e.defaultPrevented || !(o instanceof HTMLElement)) return;
|
|
89
|
-
const r = e.currentTarget, n =
|
|
93
|
+
const r = e.currentTarget, n = y(r), s = n.indexOf(document.activeElement);
|
|
90
94
|
if (s === -1 || (e.shiftKey ? s !== 0 : s !== n.length - 1)) return;
|
|
91
95
|
e.preventDefault();
|
|
92
|
-
const a =
|
|
93
|
-
f.current = !1,
|
|
96
|
+
const a = y(document).filter((W) => !r.contains(W)), g = a[a.indexOf(o) + (e.shiftKey ? -1 : 1)], Y = (d && e.shiftKey ? void 0 : g) ?? o;
|
|
97
|
+
f.current = !1, Y.focus({ preventScroll: !0 }), c?.(e, "tabKeyDown");
|
|
94
98
|
}
|
|
95
99
|
}) : {};
|
|
96
|
-
return
|
|
100
|
+
return P(() => {
|
|
97
101
|
if (!m || !u) return;
|
|
98
102
|
const e = i.floating.current;
|
|
99
103
|
if (!(!e || typeof e.showPopover != "function"))
|
|
@@ -106,23 +110,26 @@ var ae = {
|
|
|
106
110
|
m,
|
|
107
111
|
u,
|
|
108
112
|
i.floating
|
|
109
|
-
]), m ? /* @__PURE__ */
|
|
113
|
+
]), m ? /* @__PURE__ */ x(ee, {
|
|
110
114
|
root: v,
|
|
111
|
-
children: /* @__PURE__ */
|
|
112
|
-
ref:
|
|
115
|
+
children: /* @__PURE__ */ x("div", {
|
|
116
|
+
ref: B,
|
|
113
117
|
id: D,
|
|
114
|
-
...u ?
|
|
118
|
+
...u ? j : {},
|
|
115
119
|
style: {
|
|
116
|
-
...u ?
|
|
117
|
-
...t ?
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
...u ? q : {},
|
|
121
|
+
...t ? {
|
|
122
|
+
...z,
|
|
123
|
+
maxHeight: M
|
|
124
|
+
} : {},
|
|
125
|
+
...R(K),
|
|
126
|
+
...R(l?.paper?.sx),
|
|
120
127
|
...l?.paper?.style,
|
|
121
128
|
...t ? null : { display: "none" }
|
|
122
129
|
},
|
|
123
|
-
...
|
|
124
|
-
className:
|
|
125
|
-
children: /* @__PURE__ */
|
|
130
|
+
...I,
|
|
131
|
+
className: $("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", T ?? "my-1", l?.paper?.className),
|
|
132
|
+
children: /* @__PURE__ */ x(Q.Provider, {
|
|
126
133
|
value: i.floating,
|
|
127
134
|
children: E
|
|
128
135
|
})
|
|
@@ -130,5 +137,5 @@ var ae = {
|
|
|
130
137
|
}) : null;
|
|
131
138
|
};
|
|
132
139
|
export {
|
|
133
|
-
|
|
140
|
+
be as StyledPopover
|
|
134
141
|
};
|