@floegence/floe-webapp-core 0.77.2 → 0.78.0

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,4 +1,5 @@
1
1
  export { Shell, type ShellProps, type ShellSlotClassNames } from './Shell';
2
+ export type { MobileNavigationPanelProps } from './MobileNavigationPanel';
2
3
  export { ActivityBar, type ActivityBarItem, type ActivityBarProps } from './ActivityBar';
3
4
  export type { BarItemContextMenuHandler, BarItemContextMenuRequest, BarItemContextMenuSource, } from './barItemContextMenu';
4
5
  export { Sidebar, SidebarContent, SidebarItemList, SidebarSection, SidebarItem, type SidebarProps, type SidebarContentProps, type SidebarItemListProps, type SidebarSectionProps, type SidebarItemProps, } from './Sidebar';
@@ -5,6 +5,8 @@ type MaybeAccessor<T> = T | Accessor<T>;
5
5
  export interface UseOverlayMaskOptions {
6
6
  open: Accessor<boolean>;
7
7
  root: Accessor<HTMLElement | undefined>;
8
+ /** Ordered focus regions that belong to one overlay, including persistent navigation. */
9
+ focusRoots?: Accessor<readonly HTMLElement[]>;
8
10
  onClose?: () => void;
9
11
  /** Treat additional nodes as part of the overlay surface (e.g. portaled layers). */
10
12
  containsTarget?: (target: EventTarget | null) => boolean;
@@ -1,66 +1,66 @@
1
- import { createEffect as R, onCleanup as V } from "solid-js";
2
- import { lockBodyStyle as G } from "../utils/bodyStyleLock.js";
3
- import { deferAfterPaint as D } from "../utils/defer.js";
4
- import { getFocusableElements as J, getFirstFocusableElement as Q } from "../utils/focus.js";
5
- import { matchKeybind as U } from "../utils/keybind.js";
6
- const S = /* @__PURE__ */ new WeakMap();
7
- function K(t) {
1
+ import { createEffect as Q, onCleanup as U } from "solid-js";
2
+ import { lockBodyStyle as X } from "../utils/bodyStyleLock.js";
3
+ import { deferAfterPaint as K } from "../utils/defer.js";
4
+ import { getFocusableElements as x, getFirstFocusableElement as Y } from "../utils/focus.js";
5
+ import { matchKeybind as Z } from "../utils/keybind.js";
6
+ const H = /* @__PURE__ */ new WeakMap();
7
+ function A(t) {
8
8
  return typeof Node < "u" && t instanceof Node;
9
9
  }
10
- function p(t, o, r) {
11
- return r ? r(o) : !t || !K(o) ? !1 : t.contains(o);
10
+ function p(t, o, c) {
11
+ return c ? c(o) : !t || !A(o) ? !1 : t.contains(o);
12
12
  }
13
- function H(t, o, r, a) {
14
- return r === "none" ? !1 : r === "all" ? !0 : !p(t, o, a);
13
+ function W(t, o, c, i) {
14
+ return c === "none" ? !1 : c === "all" ? !0 : !p(t, o, i);
15
15
  }
16
- function X(t) {
16
+ function _(t) {
17
17
  return typeof t == "function" ? t() ?? [] : t ?? [];
18
18
  }
19
- function c(t, o) {
19
+ function s(t, o) {
20
20
  return typeof t == "function" ? t() ?? o : t ?? o;
21
21
  }
22
- function Y(t, o) {
23
- for (const r of X(o)) {
24
- const a = r.trim();
25
- if (a && U(t, a))
22
+ function $(t, o) {
23
+ for (const c of _(o)) {
24
+ const i = c.trim();
25
+ if (i && Z(t, i))
26
26
  return !0;
27
27
  }
28
28
  return !1;
29
29
  }
30
- function oe(t) {
31
- const o = () => c(t.lockBodyScroll, !0), r = () => c(t.trapFocus, !0), a = () => {
32
- const i = c(
30
+ function ue(t) {
31
+ const o = () => s(t.lockBodyScroll, !0), c = () => s(t.trapFocus, !0), i = () => {
32
+ const f = s(
33
33
  t.closeOnEscape,
34
34
  !0
35
35
  );
36
- return i === !1 ? "none" : i === "inside" ? "inside" : i === "none" ? "none" : "always";
37
- }, W = () => c(t.blockHotkeys, !0), A = () => c(t.restoreFocus, !0), x = () => c(t.blockWheel, "none"), I = () => c(t.blockTouchMove, "none"), N = () => c(t.autoFocus, !0);
38
- R(() => {
36
+ return f === !1 ? "none" : f === "inside" ? "inside" : f === "none" ? "none" : "always";
37
+ }, I = () => s(t.blockHotkeys, !0), R = () => s(t.restoreFocus, !0), N = () => s(t.blockWheel, "none"), q = () => s(t.blockTouchMove, "none"), j = () => s(t.autoFocus, !0);
38
+ Q(() => {
39
39
  if (!t.open() || typeof document > "u") return;
40
- const i = o(), b = r(), d = a(), m = c(t.escapeKeyPhase, "capture"), q = W(), j = A(), h = x(), k = I(), E = N(), l = S.get(document) ?? [];
41
- S.set(document, l);
42
- const v = {
43
- global: i || d === "always",
40
+ const f = o(), w = c(), v = i(), h = s(t.escapeKeyPhase, "capture"), z = I(), V = R(), g = N(), k = q(), E = j(), d = H.get(document) ?? [];
41
+ H.set(document, d);
42
+ const y = {
43
+ global: f || v === "always",
44
44
  contains: (e) => p(t.root(), e, t.containsTarget)
45
45
  };
46
- l.push(v);
47
- let w = !0;
48
- const u = (e) => w && !l.slice(l.indexOf(v) + 1).some((n) => n.global || n.contains(e)), g = document.activeElement instanceof HTMLElement ? document.activeElement : null, z = i ? G({ overflow: "hidden" }) : null;
49
- D(() => {
46
+ d.push(y);
47
+ let T = !0;
48
+ const l = (e) => T && !d.slice(d.indexOf(y) + 1).some((n) => n.global || n.contains(e)), b = document.activeElement instanceof HTMLElement ? document.activeElement : null, G = f ? X({ overflow: "hidden" }) : null;
49
+ K(() => {
50
50
  const e = t.root();
51
- if (!e?.isConnected || !u(e) || E === !1 || v.contains(document.activeElement)) return;
52
- const n = typeof E == "object" ? E.selector : void 0, y = (n ? e.querySelector(n) : null) ?? e.querySelector("[data-floe-autofocus]") ?? Q(e) ?? e;
51
+ if (!e?.isConnected || !l(e) || E === !1 || y.contains(document.activeElement)) return;
52
+ const n = typeof E == "object" ? E.selector : void 0, r = (n ? e.querySelector(n) : null) ?? e.querySelector("[data-floe-autofocus]") ?? Y(e) ?? e;
53
53
  try {
54
- y.focus();
54
+ r.focus({ preventScroll: !0 });
55
55
  } catch {
56
56
  }
57
57
  });
58
- const T = (e) => {
59
- if (e.key !== "Tab" || !u(e.target)) return;
58
+ const L = (e) => {
59
+ if (e.key !== "Tab" || !l(e.target)) return;
60
60
  const n = t.root();
61
61
  if (!n) return;
62
- const s = J(n);
63
- if (!s.length) {
62
+ const m = t.focusRoots?.() ?? [n], r = t.focusRoots ? [...new Set(m.flatMap(x))].filter((u) => u.tabIndex >= 0 && !u.closest('[hidden], [inert], [aria-hidden="true"]')) : x(n);
63
+ if (!r.length) {
64
64
  e.preventDefault();
65
65
  try {
66
66
  n.focus();
@@ -68,31 +68,36 @@ function oe(t) {
68
68
  }
69
69
  return;
70
70
  }
71
- const y = s[0], P = s[s.length - 1], f = document.activeElement instanceof HTMLElement ? document.activeElement : null;
71
+ const D = r[0], P = r[r.length - 1], a = document.activeElement instanceof HTMLElement ? document.activeElement : null;
72
+ if (t.focusRoots) {
73
+ const u = a ? r.indexOf(a) : -1, J = u < 0 ? e.shiftKey ? r.length - 1 : 0 : (u + (e.shiftKey ? -1 : 1) + r.length) % r.length;
74
+ e.preventDefault(), r[J]?.focus({ preventScroll: !0 });
75
+ return;
76
+ }
72
77
  if (e.shiftKey) {
73
- if (f === y || !f || !n.contains(f)) {
78
+ if (a === D || !a || !m.some((u) => u.contains(a))) {
74
79
  e.preventDefault();
75
80
  try {
76
81
  P.focus();
77
82
  } catch {
78
83
  }
79
84
  }
80
- } else if (f === P || !f || !n.contains(f)) {
85
+ } else if (a === P || !a || !m.some((u) => u.contains(a))) {
81
86
  e.preventDefault();
82
87
  try {
83
- y.focus();
88
+ D.focus();
84
89
  } catch {
85
90
  }
86
91
  }
87
- }, L = (e) => {
88
- if (e.key !== "Escape" || !u(e.target) || m === "bubble" && (e.defaultPrevented || e.isComposing) || d === "none") return;
89
- const n = t.root(), s = p(
92
+ }, M = (e) => {
93
+ if (e.key !== "Escape" || !l(e.target) || h === "bubble" && (e.defaultPrevented || e.isComposing) || v === "none") return;
94
+ const n = t.root(), m = p(
90
95
  n,
91
- K(e.target) ? e.target : document.activeElement,
96
+ A(e.target) ? e.target : document.activeElement,
92
97
  t.containsTarget
93
98
  );
94
- if (d === "inside") {
95
- if (s) {
99
+ if (v === "inside") {
100
+ if (m) {
96
101
  e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.();
97
102
  return;
98
103
  }
@@ -100,41 +105,41 @@ function oe(t) {
100
105
  return;
101
106
  }
102
107
  e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.();
103
- }, M = (e) => {
104
- if (!u(e.target)) return;
105
- const n = t.root();
106
- n && q && p(n, e.target, t.containsTarget) && (Y(e, t.allowHotkeys) || e.stopPropagation());
107
108
  }, O = (e) => {
108
- if (!u(e.target)) return;
109
+ if (!l(e.target)) return;
109
110
  const n = t.root();
110
- H(n, e.target, h, t.containsTarget) && e.cancelable && e.preventDefault();
111
+ n && z && p(n, e.target, t.containsTarget) && ($(e, t.allowHotkeys) || e.stopPropagation());
111
112
  }, B = (e) => {
112
- u(e.target) && e.stopPropagation();
113
+ if (!l(e.target)) return;
114
+ const n = t.root();
115
+ W(n, e.target, g, t.containsTarget) && e.cancelable && e.preventDefault();
113
116
  }, F = (e) => {
114
- if (!u(e.target)) return;
117
+ l(e.target) && e.stopPropagation();
118
+ }, S = (e) => {
119
+ if (!l(e.target)) return;
115
120
  const n = t.root();
116
- H(n, e.target, k, t.containsTarget) && e.cancelable && e.preventDefault();
121
+ W(n, e.target, k, t.containsTarget) && e.cancelable && e.preventDefault();
117
122
  };
118
- b && document.addEventListener("keydown", T, !0);
119
- const C = m === "capture" ? window : document;
120
- d !== "none" && C.addEventListener(
123
+ w && document.addEventListener("keydown", L, !0);
124
+ const C = h === "capture" ? window : document;
125
+ v !== "none" && C.addEventListener(
121
126
  "keydown",
122
- L,
123
- m === "capture"
124
- ), document.addEventListener("keydown", M), h !== "none" && (document.addEventListener("wheel", O, { capture: !0, passive: !1 }), document.addEventListener("wheel", B)), k !== "none" && document.addEventListener("touchmove", F, {
127
+ M,
128
+ h === "capture"
129
+ ), document.addEventListener("keydown", O), g !== "none" && (document.addEventListener("wheel", B, { capture: !0, passive: !1 }), document.addEventListener("wheel", F)), k !== "none" && document.addEventListener("touchmove", S, {
125
130
  capture: !0,
126
131
  passive: !1
127
- }), V(() => {
128
- w = !1, l.splice(l.indexOf(v), 1), b && document.removeEventListener("keydown", T, !0), d !== "none" && C.removeEventListener(
132
+ }), U(() => {
133
+ T = !1, d.splice(d.indexOf(y), 1), w && document.removeEventListener("keydown", L, !0), v !== "none" && C.removeEventListener(
129
134
  "keydown",
130
- L,
131
- m === "capture"
132
- ), document.removeEventListener("keydown", M), h !== "none" && (document.removeEventListener("wheel", O, !0), document.removeEventListener("wheel", B)), k !== "none" && document.removeEventListener("touchmove", F, !0), z?.(), j && g && g.isConnected && D(() => {
135
+ M,
136
+ h === "capture"
137
+ ), document.removeEventListener("keydown", O), g !== "none" && (document.removeEventListener("wheel", B, !0), document.removeEventListener("wheel", F)), k !== "none" && document.removeEventListener("touchmove", S, !0), G?.(), V && b && b.isConnected && K(() => {
133
138
  if (typeof document > "u") return;
134
139
  const e = document.activeElement;
135
140
  if (!(e && e !== document.body && e !== document.documentElement))
136
141
  try {
137
- g.focus();
142
+ b.focus({ preventScroll: !0 });
138
143
  } catch {
139
144
  }
140
145
  });
@@ -142,5 +147,5 @@ function oe(t) {
142
147
  });
143
148
  }
144
149
  export {
145
- oe as useOverlayMask
150
+ ue as useOverlayMask
146
151
  };