@floegence/floe-webapp-core 0.86.40 → 0.86.42
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/components/ui/KeyedFor.js +20 -18
- package/dist/hooks/useOverlayMask.js +40 -40
- package/package.json +1 -1
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
import { createMemo as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
const e = /* @__PURE__ */ new Map(),
|
|
6
|
-
for (const
|
|
7
|
-
const
|
|
8
|
-
if (e.has(
|
|
9
|
-
e.set(
|
|
1
|
+
import { createComponent as u } from "solid-js/web";
|
|
2
|
+
import { createMemo as c, For as i, untrack as l } from "solid-js";
|
|
3
|
+
function m(r) {
|
|
4
|
+
const s = c(() => {
|
|
5
|
+
const e = /* @__PURE__ */ new Map(), n = [];
|
|
6
|
+
for (const o of r.each ?? []) {
|
|
7
|
+
const t = r.by(o);
|
|
8
|
+
if (e.has(t)) throw new Error("KeyedFor requires unique keys");
|
|
9
|
+
e.set(t, o), n.push(t);
|
|
10
10
|
}
|
|
11
11
|
return {
|
|
12
12
|
values: e,
|
|
13
|
-
keys:
|
|
13
|
+
keys: n
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
|
-
return
|
|
16
|
+
return u(i, {
|
|
17
17
|
get each() {
|
|
18
|
-
return
|
|
18
|
+
return s().keys;
|
|
19
19
|
},
|
|
20
20
|
get fallback() {
|
|
21
21
|
return r.fallback;
|
|
22
22
|
},
|
|
23
|
-
children: (e,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
children: (e, n) => {
|
|
24
|
+
const o = c((t) => {
|
|
25
|
+
const a = s().values;
|
|
26
|
+
return a.has(e) ? a.get(e) : t;
|
|
27
|
+
}, l(() => s().values.get(e)));
|
|
28
|
+
return r.children(o, n);
|
|
29
|
+
}
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
export {
|
|
31
|
-
|
|
33
|
+
m as KeyedFor
|
|
32
34
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createEffect as U, onCleanup as X } from "solid-js";
|
|
2
2
|
import { lockBodyStyle as Y } from "../utils/bodyStyleLock.js";
|
|
3
|
-
import { deferAfterPaint as
|
|
4
|
-
import { getFocusableElements as
|
|
3
|
+
import { deferAfterPaint as I } from "../utils/defer.js";
|
|
4
|
+
import { getFocusableElements as H, getFirstFocusableElement as Z } from "../utils/focus.js";
|
|
5
5
|
import { matchKeybind as _ } from "../utils/keybind.js";
|
|
6
|
-
const
|
|
6
|
+
const L = /* @__PURE__ */ new WeakMap();
|
|
7
7
|
function A(t) {
|
|
8
8
|
return typeof Node < "u" && t instanceof Node;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function E(t, o, c) {
|
|
11
11
|
return c ? c(o) : !t || !A(o) ? !1 : t.contains(o);
|
|
12
12
|
}
|
|
13
13
|
function W(t, o, c, f) {
|
|
14
|
-
return c === "none" ? !1 : c === "all" ? !0 : !
|
|
14
|
+
return c === "none" ? !1 : c === "all" ? !0 : !E(t, o, f);
|
|
15
15
|
}
|
|
16
16
|
function $(t) {
|
|
17
17
|
return typeof t == "function" ? t() ?? [] : t ?? [];
|
|
@@ -37,29 +37,29 @@ function se(t) {
|
|
|
37
37
|
}, R = () => s(t.blockHotkeys, !0), N = () => s(t.restoreFocus, !0), q = () => s(t.blockWheel, "none"), j = () => s(t.blockTouchMove, "none"), z = () => s(t.autoFocus, !0);
|
|
38
38
|
U(() => {
|
|
39
39
|
if (!t.open() || typeof document > "u") return;
|
|
40
|
-
const l = o(),
|
|
41
|
-
|
|
40
|
+
const l = o(), O = c(), v = f(), y = s(t.escapeKeyPhase, "capture"), V = R(), G = N(), k = q(), b = j(), w = z(), d = L.get(document) ?? [];
|
|
41
|
+
L.set(document, d);
|
|
42
42
|
const h = {
|
|
43
43
|
global: l || v === "always",
|
|
44
|
-
contains: (e) =>
|
|
44
|
+
contains: (e) => E(t.root(), e, t.containsTarget)
|
|
45
45
|
};
|
|
46
46
|
d.push(h);
|
|
47
|
-
let
|
|
48
|
-
const a = (e) =>
|
|
49
|
-
|
|
47
|
+
let T = !0;
|
|
48
|
+
const a = (e) => T && !d.slice(d.indexOf(h) + 1).some((n) => n.global || n.contains(e)), p = document.activeElement instanceof HTMLElement ? document.activeElement : null, J = l ? Y({ overflow: "hidden" }) : null;
|
|
49
|
+
I(() => {
|
|
50
50
|
const e = t.root();
|
|
51
|
-
if (!e?.isConnected || !a(e) ||
|
|
52
|
-
const n = typeof
|
|
51
|
+
if (!e?.isConnected || !a(e) || w === !1 || h.contains(document.activeElement)) return;
|
|
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 });
|
|
55
55
|
} catch {
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
const
|
|
58
|
+
const M = (e) => {
|
|
59
59
|
if (e.key !== "Tab" || !a(e.target)) return;
|
|
60
60
|
const n = t.root();
|
|
61
61
|
if (!n) return;
|
|
62
|
-
const m = t.focusRoots?.() ?? [n], r = t.focusRoots ? [...new Set(m.flatMap(
|
|
62
|
+
const m = t.focusRoots?.() ?? [n], r = t.focusRoots ? [...new Set(m.flatMap(H))].filter((u) => u.tabIndex >= 0 && !u.closest('[hidden], [inert], [aria-hidden="true"]')) : H(n);
|
|
63
63
|
if (!r.length) {
|
|
64
64
|
e.preventDefault();
|
|
65
65
|
try {
|
|
@@ -68,30 +68,30 @@ function se(t) {
|
|
|
68
68
|
}
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const K = r[0], x = r[r.length - 1], i = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
72
72
|
if (t.focusRoots) {
|
|
73
73
|
const u = i ? r.indexOf(i) : -1, Q = u < 0 ? e.shiftKey ? r.length - 1 : 0 : (u + (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 (i ===
|
|
78
|
+
if (i === K || !i || !m.some((u) => u.contains(i))) {
|
|
79
79
|
e.preventDefault();
|
|
80
80
|
try {
|
|
81
|
-
|
|
81
|
+
x.focus();
|
|
82
82
|
} catch {
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
} else if (i ===
|
|
85
|
+
} else if (i === x || !i || !m.some((u) => u.contains(i))) {
|
|
86
86
|
e.preventDefault();
|
|
87
87
|
try {
|
|
88
|
-
|
|
88
|
+
K.focus();
|
|
89
89
|
} catch {
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
},
|
|
92
|
+
}, B = (e) => {
|
|
93
93
|
if (e.key !== "Escape" || !a(e.target) || y === "bubble" && (e.defaultPrevented || e.isComposing) || v === "none") return;
|
|
94
|
-
const n = t.root(), m =
|
|
94
|
+
const n = t.root(), m = E(
|
|
95
95
|
n,
|
|
96
96
|
A(e.target) ? e.target : document.activeElement,
|
|
97
97
|
t.containsTarget
|
|
@@ -105,43 +105,43 @@ function se(t) {
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.();
|
|
108
|
-
}, B = (e) => {
|
|
109
|
-
if (!a(e.target)) return;
|
|
110
|
-
const n = t.root();
|
|
111
|
-
n && V && g(n, e.target, t.containsTarget) && (ee(e, t.allowHotkeys) || e.stopPropagation());
|
|
112
108
|
}, F = (e) => {
|
|
113
109
|
if (!a(e.target)) return;
|
|
114
110
|
const n = t.root();
|
|
115
|
-
|
|
111
|
+
n && V && E(n, e.target, t.containsTarget) && (ee(e, t.allowHotkeys) || e.stopPropagation());
|
|
116
112
|
}, S = (e) => {
|
|
117
|
-
a(e.target) && e.stopPropagation();
|
|
118
|
-
}, C = (e) => {
|
|
119
113
|
if (!a(e.target)) return;
|
|
120
114
|
const n = t.root();
|
|
121
115
|
W(n, e.target, k, t.containsTarget) && e.cancelable && e.preventDefault();
|
|
122
|
-
},
|
|
116
|
+
}, C = (e) => {
|
|
117
|
+
a(e.target) && e.stopPropagation();
|
|
118
|
+
}, D = (e) => {
|
|
119
|
+
if (!a(e.target)) return;
|
|
120
|
+
const n = t.root();
|
|
121
|
+
W(n, e.target, b, t.containsTarget) && e.cancelable && e.preventDefault();
|
|
122
|
+
}, g = (e) => {
|
|
123
123
|
a(e.target) && !h.contains(e.target) && t.onInteractOutside?.(e);
|
|
124
124
|
};
|
|
125
|
-
t.onInteractOutside && (document.addEventListener("pointerdown",
|
|
126
|
-
const
|
|
127
|
-
v !== "none" &&
|
|
125
|
+
t.onInteractOutside && (document.addEventListener("pointerdown", g, !0), document.addEventListener("focusin", g)), O && document.addEventListener("keydown", M, !0);
|
|
126
|
+
const P = y === "capture" ? window : document;
|
|
127
|
+
v !== "none" && P.addEventListener(
|
|
128
128
|
"keydown",
|
|
129
|
-
|
|
129
|
+
B,
|
|
130
130
|
y === "capture"
|
|
131
|
-
), document.addEventListener("keydown",
|
|
131
|
+
), document.addEventListener("keydown", F), k !== "none" && (document.addEventListener("wheel", S, { capture: !0, passive: !1 }), document.addEventListener("wheel", C)), b !== "none" && document.addEventListener("touchmove", D, {
|
|
132
132
|
capture: !0,
|
|
133
133
|
passive: !1
|
|
134
134
|
}), X(() => {
|
|
135
|
-
|
|
135
|
+
T = !1, document.removeEventListener("pointerdown", g, !0), document.removeEventListener("focusin", g), d.splice(d.indexOf(h), 1), O && document.removeEventListener("keydown", M, !0), v !== "none" && P.removeEventListener(
|
|
136
136
|
"keydown",
|
|
137
|
-
|
|
137
|
+
B,
|
|
138
138
|
y === "capture"
|
|
139
|
-
), document.removeEventListener("keydown",
|
|
140
|
-
if (typeof document > "u") return;
|
|
139
|
+
), document.removeEventListener("keydown", F), k !== "none" && (document.removeEventListener("wheel", S, !0), document.removeEventListener("wheel", C)), b !== "none" && document.removeEventListener("touchmove", D, !0), J?.(), G && p && p.isConnected && I(() => {
|
|
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))
|
|
143
143
|
try {
|
|
144
|
-
|
|
144
|
+
p.focus({ preventScroll: !0 });
|
|
145
145
|
} catch {
|
|
146
146
|
}
|
|
147
147
|
});
|