@floegence/floe-webapp-core 0.50.2 → 0.50.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,53 +1,56 @@
1
- import { createEffect as K, onCleanup as I } from "solid-js";
2
- import { lockBodyStyle as N } from "../utils/bodyStyleLock.js";
3
- import { deferAfterPaint as B } from "../utils/defer.js";
4
- import { getFocusableElements as q, getFirstFocusableElement as j } from "../utils/focus.js";
5
- import { matchKeybind as x } from "../utils/keybind.js";
6
- function M(e) {
1
+ import { createEffect as N, onCleanup as q } from "solid-js";
2
+ import { lockBodyStyle as j } from "../utils/bodyStyleLock.js";
3
+ import { deferAfterPaint as M } from "../utils/defer.js";
4
+ import { getFocusableElements as x, getFirstFocusableElement as z } from "../utils/focus.js";
5
+ import { matchKeybind as R } from "../utils/keybind.js";
6
+ function C(e) {
7
7
  return typeof Node < "u" && e instanceof Node;
8
8
  }
9
9
  function h(e, o, r) {
10
- return r ? r(o) : !e || !M(o) ? !1 : e.contains(o);
10
+ return r ? r(o) : !e || !C(o) ? !1 : e.contains(o);
11
11
  }
12
- function F(e, o, r, s) {
12
+ function O(e, o, r, s) {
13
13
  return r === "none" ? !1 : r === "all" ? !0 : !h(e, o, s);
14
14
  }
15
- function z(e) {
15
+ function V(e) {
16
16
  return typeof e == "function" ? e() ?? [] : e ?? [];
17
17
  }
18
18
  function c(e, o) {
19
19
  return typeof e == "function" ? e() ?? o : e ?? o;
20
20
  }
21
- function R(e, o) {
22
- for (const r of z(o)) {
21
+ function G(e, o) {
22
+ for (const r of V(o)) {
23
23
  const s = r.trim();
24
- if (s && x(e, s))
24
+ if (s && R(e, s))
25
25
  return !0;
26
26
  }
27
27
  return !1;
28
28
  }
29
- function Y(e) {
29
+ function _(e) {
30
30
  const o = () => c(e.lockBodyScroll, !0), r = () => c(e.trapFocus, !0), s = () => {
31
- const a = c(e.closeOnEscape, !0);
31
+ const a = c(
32
+ e.closeOnEscape,
33
+ !0
34
+ );
32
35
  return a === !1 ? "none" : a === "inside" ? "inside" : a === "none" ? "none" : "always";
33
- }, O = () => c(e.blockHotkeys, !0), C = () => c(e.restoreFocus, !0), D = () => c(e.blockWheel, "none"), S = () => c(e.blockTouchMove, "none"), H = () => c(e.autoFocus, !0);
34
- K(() => {
36
+ }, P = () => c(e.blockHotkeys, !0), D = () => c(e.restoreFocus, !0), S = () => c(e.blockWheel, "none"), H = () => c(e.blockTouchMove, "none"), K = () => c(e.autoFocus, !0);
37
+ N(() => {
35
38
  if (!e.open() || typeof document > "u") return;
36
- const a = o(), p = r(), l = s(), P = O(), W = C(), d = D(), m = S(), v = H(), y = document.activeElement instanceof HTMLElement ? document.activeElement : null, A = a ? N({ overflow: "hidden" }) : null;
37
- B(() => {
39
+ const a = o(), E = r(), l = s(), f = c(e.escapeKeyPhase, "capture"), W = P(), A = D(), m = S(), v = H(), y = K(), p = document.activeElement instanceof HTMLElement ? document.activeElement : null, I = a ? j({ overflow: "hidden" }) : null;
40
+ M(() => {
38
41
  const t = e.root();
39
- if (!t || v === !1) return;
40
- const n = typeof v == "object" ? v.selector : void 0, f = (n ? t.querySelector(n) : null) ?? t.querySelector("[data-floe-autofocus]") ?? j(t) ?? t;
42
+ if (!t || y === !1) return;
43
+ const n = typeof y == "object" ? y.selector : void 0, i = (n ? t.querySelector(n) : null) ?? t.querySelector("[data-floe-autofocus]") ?? z(t) ?? t;
41
44
  try {
42
- f.focus();
45
+ i.focus();
43
46
  } catch {
44
47
  }
45
48
  });
46
- const E = (t) => {
49
+ const k = (t) => {
47
50
  if (t.key !== "Tab") return;
48
51
  const n = e.root();
49
52
  if (!n) return;
50
- const u = q(n);
53
+ const u = x(n);
51
54
  if (!u.length) {
52
55
  t.preventDefault();
53
56
  try {
@@ -56,25 +59,29 @@ function Y(e) {
56
59
  }
57
60
  return;
58
61
  }
59
- const f = u[0], T = u[u.length - 1], i = document.activeElement instanceof HTMLElement ? document.activeElement : null;
62
+ const i = u[0], F = u[u.length - 1], d = document.activeElement instanceof HTMLElement ? document.activeElement : null;
60
63
  if (t.shiftKey) {
61
- if (i === f || !i || !n.contains(i)) {
64
+ if (d === i || !d || !n.contains(d)) {
62
65
  t.preventDefault();
63
66
  try {
64
- T.focus();
67
+ F.focus();
65
68
  } catch {
66
69
  }
67
70
  }
68
- } else if (i === T) {
71
+ } else if (d === F) {
69
72
  t.preventDefault();
70
73
  try {
71
- f.focus();
74
+ i.focus();
72
75
  } catch {
73
76
  }
74
77
  }
75
- }, k = (t) => {
76
- if (t.key !== "Escape" || l === "none") return;
77
- const n = e.root(), u = h(n, M(t.target) ? t.target : document.activeElement, e.containsTarget);
78
+ }, b = (t) => {
79
+ if (t.key !== "Escape" || f === "bubble" && (t.defaultPrevented || t.isComposing) || l === "none") return;
80
+ const n = e.root(), u = h(
81
+ n,
82
+ C(t.target) ? t.target : document.activeElement,
83
+ e.containsTarget
84
+ );
78
85
  if (l === "inside") {
79
86
  if (u) {
80
87
  t.preventDefault(), t.stopImmediatePropagation(), e.onClose?.();
@@ -84,25 +91,38 @@ function Y(e) {
84
91
  return;
85
92
  }
86
93
  t.preventDefault(), t.stopImmediatePropagation(), e.onClose?.();
87
- }, b = (t) => {
94
+ }, g = (t) => {
88
95
  const n = e.root();
89
- n && P && h(n, t.target, e.containsTarget) && (R(t, e.allowHotkeys) || t.stopPropagation());
96
+ n && W && h(n, t.target, e.containsTarget) && (G(t, e.allowHotkeys) || t.stopPropagation());
90
97
  }, w = (t) => {
91
98
  const n = e.root();
92
- F(n, t.target, d, e.containsTarget) && t.cancelable && t.preventDefault();
93
- }, g = (t) => {
94
- t.stopPropagation();
99
+ O(n, t.target, m, e.containsTarget) && t.cancelable && t.preventDefault();
95
100
  }, L = (t) => {
101
+ t.stopPropagation();
102
+ }, T = (t) => {
96
103
  const n = e.root();
97
- F(n, t.target, m, e.containsTarget) && t.cancelable && t.preventDefault();
104
+ O(n, t.target, v, e.containsTarget) && t.cancelable && t.preventDefault();
98
105
  };
99
- p && document.addEventListener("keydown", E, !0), l !== "none" && window.addEventListener("keydown", k, !0), document.addEventListener("keydown", b), d !== "none" && (document.addEventListener("wheel", w, { capture: !0, passive: !1 }), document.addEventListener("wheel", g)), m !== "none" && document.addEventListener("touchmove", L, { capture: !0, passive: !1 }), I(() => {
100
- p && document.removeEventListener("keydown", E, !0), l !== "none" && window.removeEventListener("keydown", k, !0), document.removeEventListener("keydown", b), d !== "none" && (document.removeEventListener("wheel", w, !0), document.removeEventListener("wheel", g)), m !== "none" && document.removeEventListener("touchmove", L, !0), A?.(), W && y && y.isConnected && B(() => {
106
+ E && document.addEventListener("keydown", k, !0);
107
+ const B = f === "capture" ? window : document;
108
+ l !== "none" && B.addEventListener(
109
+ "keydown",
110
+ b,
111
+ f === "capture"
112
+ ), document.addEventListener("keydown", g), m !== "none" && (document.addEventListener("wheel", w, { capture: !0, passive: !1 }), document.addEventListener("wheel", L)), v !== "none" && document.addEventListener("touchmove", T, {
113
+ capture: !0,
114
+ passive: !1
115
+ }), q(() => {
116
+ E && document.removeEventListener("keydown", k, !0), l !== "none" && B.removeEventListener(
117
+ "keydown",
118
+ b,
119
+ f === "capture"
120
+ ), document.removeEventListener("keydown", g), m !== "none" && (document.removeEventListener("wheel", w, !0), document.removeEventListener("wheel", L)), v !== "none" && document.removeEventListener("touchmove", T, !0), I?.(), A && p && p.isConnected && M(() => {
101
121
  if (typeof document > "u") return;
102
122
  const t = document.activeElement;
103
123
  if (!(t && t !== document.body && t !== document.documentElement))
104
124
  try {
105
- y.focus();
125
+ p.focus();
106
126
  } catch {
107
127
  }
108
128
  });
@@ -110,5 +130,5 @@ function Y(e) {
110
130
  });
111
131
  }
112
132
  export {
113
- Y as useOverlayMask
133
+ _ as useOverlayMask
114
134
  };