@floegence/floe-webapp-core 0.36.1 → 0.36.2

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