@floegence/floe-webapp-core 0.101.12 → 0.101.13
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/hooks/useOverlayMask.js +37 -37
- package/package.json +1 -1
|
@@ -10,45 +10,45 @@ function A(t) {
|
|
|
10
10
|
function E(t, o, c) {
|
|
11
11
|
return c ? c(o) : !t || !A(o) ? !1 : t.contains(o);
|
|
12
12
|
}
|
|
13
|
-
function W(t, o, c,
|
|
14
|
-
return c === "none" ? !1 : c === "all" ? !0 : !E(t, o,
|
|
13
|
+
function W(t, o, c, l) {
|
|
14
|
+
return c === "none" ? !1 : c === "all" ? !0 : !E(t, o, l);
|
|
15
15
|
}
|
|
16
16
|
function $(t) {
|
|
17
17
|
return typeof t == "function" ? t() ?? [] : t ?? [];
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function i(t, o) {
|
|
20
20
|
return typeof t == "function" ? t() ?? o : t ?? o;
|
|
21
21
|
}
|
|
22
22
|
function ee(t, o) {
|
|
23
23
|
for (const c of $(o)) {
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
24
|
+
const l = c.trim();
|
|
25
|
+
if (l && _(t, l))
|
|
26
26
|
return !0;
|
|
27
27
|
}
|
|
28
28
|
return !1;
|
|
29
29
|
}
|
|
30
30
|
function se(t) {
|
|
31
|
-
const o = () =>
|
|
32
|
-
const
|
|
31
|
+
const o = () => i(t.lockBodyScroll, !0), c = () => i(t.trapFocus, !0), l = () => {
|
|
32
|
+
const d = i(
|
|
33
33
|
t.closeOnEscape,
|
|
34
34
|
!0
|
|
35
35
|
);
|
|
36
|
-
return
|
|
37
|
-
}, R = () =>
|
|
36
|
+
return d === !1 ? "none" : d === "inside" ? "inside" : d === "none" ? "none" : "always";
|
|
37
|
+
}, R = () => i(t.blockHotkeys, !0), N = () => i(t.restoreFocus, !0), q = () => i(t.blockWheel, "none"), j = () => i(t.blockTouchMove, "none"), z = () => i(t.autoFocus, !0);
|
|
38
38
|
U(() => {
|
|
39
39
|
if (!t.open() || typeof document > "u") return;
|
|
40
|
-
const
|
|
41
|
-
L.set(document,
|
|
42
|
-
const
|
|
43
|
-
global:
|
|
40
|
+
const d = o(), O = c(), h = l(), y = i(t.escapeKeyPhase, "capture"), V = R(), G = N(), k = q(), b = j(), w = z(), m = L.get(document) ?? [];
|
|
41
|
+
L.set(document, m);
|
|
42
|
+
const v = {
|
|
43
|
+
global: d || h === "always",
|
|
44
44
|
contains: (e) => E(t.root(), e, t.containsTarget)
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
m.push(v);
|
|
47
47
|
let T = !0;
|
|
48
|
-
const
|
|
48
|
+
const u = (e) => T && !m.slice(m.indexOf(v) + 1).some((n) => n.global || n.contains(e)), p = document.activeElement instanceof HTMLElement ? document.activeElement : null, J = d ? Y({ overflow: "hidden" }) : null;
|
|
49
49
|
I(() => {
|
|
50
50
|
const e = t.root();
|
|
51
|
-
if (!e?.isConnected || !
|
|
51
|
+
if (!e?.isConnected || !u(e) || w === !1 || v.contains(document.activeElement)) return;
|
|
52
52
|
const n = typeof w == "object" ? w.selector : void 0, r = (n ? e.querySelector(n) : null) ?? e.querySelector("[data-floe-autofocus]") ?? Z(e) ?? e;
|
|
53
53
|
try {
|
|
54
54
|
r.focus({ preventScroll: !0 });
|
|
@@ -56,10 +56,10 @@ function se(t) {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
const M = (e) => {
|
|
59
|
-
if (e.key !== "Tab" || !
|
|
59
|
+
if (e.key !== "Tab" || !u(e.target)) return;
|
|
60
60
|
const n = t.root();
|
|
61
61
|
if (!n) return;
|
|
62
|
-
const
|
|
62
|
+
const s = t.focusRoots?.() ?? [n], r = t.focusRoots ? [...new Set(s.flatMap(H))].filter((a) => a.tabIndex >= 0 && !a.closest('[hidden], [inert], [aria-hidden="true"]')) : H(n);
|
|
63
63
|
if (!r.length) {
|
|
64
64
|
e.preventDefault();
|
|
65
65
|
try {
|
|
@@ -68,21 +68,21 @@ function se(t) {
|
|
|
68
68
|
}
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const K = r[0], x = r[r.length - 1],
|
|
71
|
+
const K = r[0], x = r[r.length - 1], f = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
72
72
|
if (t.focusRoots) {
|
|
73
|
-
const
|
|
73
|
+
const a = f ? r.indexOf(f) : -1, Q = a < 0 ? e.shiftKey ? r.length - 1 : 0 : (a + (e.shiftKey ? -1 : 1) + r.length) % r.length;
|
|
74
74
|
e.preventDefault(), r[Q]?.focus({ preventScroll: !0 });
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
if (e.shiftKey) {
|
|
78
|
-
if (
|
|
78
|
+
if (f === K || !f || !s.some((a) => a.contains(f))) {
|
|
79
79
|
e.preventDefault();
|
|
80
80
|
try {
|
|
81
81
|
x.focus();
|
|
82
82
|
} catch {
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
} else if (
|
|
85
|
+
} else if (f === x || !f || !s.some((a) => a.contains(f))) {
|
|
86
86
|
e.preventDefault();
|
|
87
87
|
try {
|
|
88
88
|
K.focus();
|
|
@@ -90,14 +90,14 @@ function se(t) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}, B = (e) => {
|
|
93
|
-
if (e.key !== "Escape" || !
|
|
94
|
-
const n = t.root(),
|
|
93
|
+
if (e.key !== "Escape" || !u(e.target) || y === "bubble" && (e.defaultPrevented || e.isComposing) || h === "none") return;
|
|
94
|
+
const n = t.root(), s = E(
|
|
95
95
|
n,
|
|
96
96
|
A(e.target) ? e.target : document.activeElement,
|
|
97
97
|
t.containsTarget
|
|
98
98
|
);
|
|
99
|
-
if (
|
|
100
|
-
if (
|
|
99
|
+
if (h === "inside") {
|
|
100
|
+
if (s) {
|
|
101
101
|
e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.();
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
@@ -106,37 +106,37 @@ function se(t) {
|
|
|
106
106
|
}
|
|
107
107
|
e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.();
|
|
108
108
|
}, F = (e) => {
|
|
109
|
-
if (!
|
|
109
|
+
if (!u(e.target)) return;
|
|
110
110
|
const n = t.root();
|
|
111
111
|
n && V && E(n, e.target, t.containsTarget) && (ee(e, t.allowHotkeys) || e.stopPropagation());
|
|
112
112
|
}, S = (e) => {
|
|
113
|
-
if (!
|
|
113
|
+
if (!u(e.target)) return;
|
|
114
114
|
const n = t.root();
|
|
115
115
|
W(n, e.target, k, t.containsTarget) && e.cancelable && e.preventDefault();
|
|
116
116
|
}, C = (e) => {
|
|
117
|
-
|
|
118
|
-
},
|
|
119
|
-
if (!
|
|
117
|
+
u(e.target) && e.stopPropagation();
|
|
118
|
+
}, P = (e) => {
|
|
119
|
+
if (!u(e.target)) return;
|
|
120
120
|
const n = t.root();
|
|
121
121
|
W(n, e.target, b, t.containsTarget) && e.cancelable && e.preventDefault();
|
|
122
122
|
}, g = (e) => {
|
|
123
|
-
|
|
123
|
+
e.composedPath().some((s) => !u(s) || v.contains(s)) || u(e.target) && !v.contains(e.target) && t.onInteractOutside?.(e);
|
|
124
124
|
};
|
|
125
125
|
t.onInteractOutside && (document.addEventListener("pointerdown", g, !0), document.addEventListener("focusin", g)), O && document.addEventListener("keydown", M, !0);
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const D = y === "capture" ? window : document;
|
|
127
|
+
h !== "none" && D.addEventListener(
|
|
128
128
|
"keydown",
|
|
129
129
|
B,
|
|
130
130
|
y === "capture"
|
|
131
|
-
), document.addEventListener("keydown", F), k !== "none" && (document.addEventListener("wheel", S, { capture: !0, passive: !1 }), document.addEventListener("wheel", C)), b !== "none" && document.addEventListener("touchmove",
|
|
131
|
+
), document.addEventListener("keydown", F), k !== "none" && (document.addEventListener("wheel", S, { capture: !0, passive: !1 }), document.addEventListener("wheel", C)), b !== "none" && document.addEventListener("touchmove", P, {
|
|
132
132
|
capture: !0,
|
|
133
133
|
passive: !1
|
|
134
134
|
}), X(() => {
|
|
135
|
-
T = !1, document.removeEventListener("pointerdown", g, !0), document.removeEventListener("focusin", g),
|
|
135
|
+
T = !1, document.removeEventListener("pointerdown", g, !0), document.removeEventListener("focusin", g), m.splice(m.indexOf(v), 1), O && document.removeEventListener("keydown", M, !0), h !== "none" && D.removeEventListener(
|
|
136
136
|
"keydown",
|
|
137
137
|
B,
|
|
138
138
|
y === "capture"
|
|
139
|
-
), document.removeEventListener("keydown", F), k !== "none" && (document.removeEventListener("wheel", S, !0), document.removeEventListener("wheel", C)), b !== "none" && document.removeEventListener("touchmove",
|
|
139
|
+
), document.removeEventListener("keydown", F), k !== "none" && (document.removeEventListener("wheel", S, !0), document.removeEventListener("wheel", C)), b !== "none" && document.removeEventListener("touchmove", P, !0), J?.(), G && p && p.isConnected && I(() => {
|
|
140
140
|
if (typeof document > "u" || L.get(document)?.some((n) => !n.contains(p))) return;
|
|
141
141
|
const e = document.activeElement;
|
|
142
142
|
if (!(e && e !== document.body && e !== document.documentElement))
|