@floegence/floe-webapp-core 0.36.12 → 0.36.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.
@@ -1,45 +1,98 @@
1
- const a = "data-floe-dialog-surface-host", m = "data-floe-dialog-surface-boundary";
2
- let o = null, t = null;
3
- function d(e) {
1
+ const a = "data-floe-dialog-surface-host", w = "data-floe-dialog-surface-boundary";
2
+ let o = null, n = null;
3
+ function s(e) {
4
4
  return typeof Element < "u" && e instanceof Element ? e : typeof Node < "u" && e instanceof Node ? e.parentElement : null;
5
5
  }
6
- function f(e) {
7
- const n = e?.activeElement;
8
- return n instanceof Element ? n : null;
6
+ function h(e) {
7
+ const t = e?.activeElement;
8
+ return t instanceof Element ? t : null;
9
9
  }
10
- function i(e) {
11
- const n = typeof document < "u" ? document : null;
10
+ function l(e) {
11
+ const t = typeof document < "u" ? document : null;
12
12
  o = {
13
- target: d(e),
14
- activeElement: f(n),
13
+ target: s(e),
14
+ activeElement: h(t),
15
15
  recordedAt: Date.now()
16
16
  };
17
17
  }
18
- function r(e) {
19
- i(e.target);
20
- }
21
18
  function u(e) {
22
- i(e.target);
19
+ l(e.target);
23
20
  }
24
- function l() {
25
- typeof document > "u" || t !== document && (t && (t.removeEventListener("pointerdown", r, !0), t.removeEventListener("focusin", u, !0)), document.addEventListener("pointerdown", r, !0), document.addEventListener("focusin", u, !0), t = document);
21
+ function c(e) {
22
+ l(e.target);
26
23
  }
27
- function s() {
28
- return !o || Date.now() - o.recordedAt > 1600 ? null : o;
24
+ function f() {
25
+ m();
29
26
  }
30
- function c(e) {
31
- const n = e?.closest(`[${a}="true"]`);
32
- return n instanceof HTMLElement && n.isConnected ? n : null;
27
+ function m() {
28
+ typeof document > "u" || n !== document && (n && (n.removeEventListener("pointerdown", u, !0), n.removeEventListener("focusin", c, !0)), document.addEventListener("pointerdown", u, !0), document.addEventListener("focusin", c, !0), n = document);
33
29
  }
34
30
  function E() {
35
- l();
36
- const e = s(), n = c(e?.target ?? null) ?? c(e?.activeElement ?? null);
37
- return n ? { host: n, mode: "surface" } : { host: null, mode: "global" };
31
+ return !o || Date.now() - o.recordedAt > 1600 ? null : o;
32
+ }
33
+ function d(e) {
34
+ const t = e?.closest(`[${a}="true"]`);
35
+ return typeof HTMLElement > "u" ? null : t instanceof HTMLElement && t.isConnected ? t : null;
36
+ }
37
+ function T() {
38
+ f();
39
+ const e = E(), t = d(e?.target ?? null) ?? d(e?.activeElement ?? null);
40
+ return t ? { host: t, mode: "surface" } : { host: null, mode: "global" };
41
+ }
42
+ function r(e) {
43
+ return e.mode === "surface" && !!e.host?.isConnected;
44
+ }
45
+ function v(e) {
46
+ return r(e) ? e.host ?? void 0 : void 0;
47
+ }
48
+ function p() {
49
+ return typeof window > "u" ? {
50
+ left: 0,
51
+ top: 0,
52
+ right: 0,
53
+ bottom: 0,
54
+ width: 0,
55
+ height: 0
56
+ } : {
57
+ left: 0,
58
+ top: 0,
59
+ right: window.innerWidth,
60
+ bottom: window.innerHeight,
61
+ width: window.innerWidth,
62
+ height: window.innerHeight
63
+ };
64
+ }
65
+ function g(e) {
66
+ if (!r(e) || !e.host)
67
+ return p();
68
+ const t = e.host.getBoundingClientRect();
69
+ return {
70
+ left: t.left,
71
+ top: t.top,
72
+ right: t.right,
73
+ bottom: t.bottom,
74
+ width: t.width,
75
+ height: t.height
76
+ };
77
+ }
78
+ function S(e, t) {
79
+ if (!r(t))
80
+ return e;
81
+ const i = g(t);
82
+ return {
83
+ x: e.x - i.left,
84
+ y: e.y - i.top
85
+ };
38
86
  }
39
- typeof document < "u" && l();
87
+ typeof document < "u" && f();
40
88
  export {
41
- m as DIALOG_SURFACE_BOUNDARY_ATTR,
89
+ w as DIALOG_SURFACE_BOUNDARY_ATTR,
42
90
  a as DIALOG_SURFACE_HOST_ATTR,
43
- l as ensureDialogSurfaceInteractionTracking,
44
- E as resolveDialogSurfaceHost
91
+ f as ensureDialogSurfaceInteractionTracking,
92
+ m as ensureSurfacePortalInteractionTracking,
93
+ r as isSurfacePortalMode,
94
+ S as projectSurfacePortalPosition,
95
+ g as resolveSurfacePortalBoundaryRect,
96
+ T as resolveSurfacePortalHost,
97
+ v as resolveSurfacePortalMount
45
98
  };
@@ -1,11 +1,30 @@
1
1
  export declare const VIEWPORT_MARGIN = 8;
2
2
  export declare const MENU_ITEM_SELECTOR = "[role=\"menuitem\"]:not([disabled]):not([aria-disabled=\"true\"])";
3
+ export type MenuBoundaryRect = Readonly<{
4
+ left: number;
5
+ top: number;
6
+ right: number;
7
+ bottom: number;
8
+ width: number;
9
+ height: number;
10
+ }>;
3
11
  export type MenuFocusMode = 'first' | 'last' | 'selected';
4
- export declare function calculateMenuPosition(triggerRect: DOMRect, menuRect: DOMRect, align: 'start' | 'center' | 'end'): {
12
+ export declare function resolveViewportMenuBoundaryRect(): MenuBoundaryRect;
13
+ export declare function clampMenuPosition(anchor: Readonly<{
14
+ x: number;
15
+ y: number;
16
+ }>, menuRect: Readonly<{
17
+ width: number;
18
+ height: number;
19
+ }>, boundaryRect?: MenuBoundaryRect): {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ export declare function calculateMenuPosition(triggerRect: DOMRect, menuRect: DOMRect, align: 'start' | 'center' | 'end', boundaryRect?: MenuBoundaryRect): {
5
24
  x: number;
6
25
  y: number;
7
26
  };
8
- export declare function calculateSubmenuPosition(parentRect: DOMRect, submenuRect: DOMRect): {
27
+ export declare function calculateSubmenuPosition(parentRect: DOMRect, submenuRect: DOMRect, boundaryRect?: MenuBoundaryRect): {
9
28
  x: number;
10
29
  y: number;
11
30
  };
@@ -1,60 +1,90 @@
1
- const d = 8, r = '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])';
2
- function M(e, t, n) {
3
- const o = window.innerWidth, f = window.innerHeight;
4
- let i;
5
- switch (n) {
1
+ const u = 8, M = '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])';
2
+ function a() {
3
+ return typeof window > "u" ? {
4
+ left: 0,
5
+ top: 0,
6
+ right: 0,
7
+ bottom: 0,
8
+ width: 0,
9
+ height: 0
10
+ } : {
11
+ left: 0,
12
+ top: 0,
13
+ right: window.innerWidth,
14
+ bottom: window.innerHeight,
15
+ width: window.innerWidth,
16
+ height: window.innerHeight
17
+ };
18
+ }
19
+ function h(e) {
20
+ return e ?? a();
21
+ }
22
+ function E(e, t, f) {
23
+ const i = h(f);
24
+ let o = e.x, n = e.y;
25
+ return o + t.width > i.right - 8 && (o = i.right - t.width - 8), n + t.height > i.bottom - 8 && (n = i.bottom - t.height - 8), {
26
+ x: Math.max(i.left + 8, o),
27
+ y: Math.max(i.top + 8, n)
28
+ };
29
+ }
30
+ function A(e, t, f, i) {
31
+ const o = h(i);
32
+ let n;
33
+ switch (f) {
6
34
  case "center":
7
- i = e.left + e.width / 2 - t.width / 2;
35
+ n = e.left + e.width / 2 - t.width / 2;
8
36
  break;
9
37
  case "end":
10
- i = e.right - t.width;
38
+ n = e.right - t.width;
11
39
  break;
12
40
  default:
13
- i = e.left;
41
+ n = e.left;
14
42
  }
15
- let l = e.bottom + 4;
16
- if (i + t.width > o - 8 && (i = o - t.width - 8), i = Math.max(8, i), l + t.height > f - 8) {
17
- const I = e.top - 8, h = f - e.bottom - 8;
18
- I > h && I >= t.height ? l = e.top - t.height - 4 : l = f - t.height - 8;
43
+ let r = e.bottom + 4;
44
+ if (n + t.width > o.right - 8 && (n = o.right - t.width - 8), n = Math.max(o.left + 8, n), r + t.height > o.bottom - 8) {
45
+ const I = e.top - o.top - 8, d = o.bottom - e.bottom - 8;
46
+ I > d && I >= t.height ? r = e.top - t.height - 4 : r = o.bottom - t.height - 8;
19
47
  }
20
- return l = Math.max(8, l), { x: i, y: l };
21
- }
22
- function u(e, t) {
23
- const n = window.innerWidth, o = window.innerHeight;
24
- let f = e.right, i = e.top;
25
- if (f + t.width > n - 8) {
26
- const l = e.left - t.width;
27
- l >= 8 ? f = l : f = n - t.width - 8;
48
+ return r = Math.max(o.top + 8, r), { x: n, y: r };
49
+ }
50
+ function P(e, t, f) {
51
+ const i = h(f);
52
+ let o = e.right, n = e.top;
53
+ if (o + t.width > i.right - 8) {
54
+ const r = e.left - t.width;
55
+ r >= i.left + 8 ? o = r : o = i.right - t.width - 8;
28
56
  }
29
- return i + t.height > o - 8 && (i = o - t.height - 8), f = Math.max(8, f), i = Math.max(8, i), { x: f, y: i };
57
+ return n + t.height > i.bottom - 8 && (n = i.bottom - t.height - 8), o = Math.max(i.left + 8, o), n = Math.max(i.top + 8, n), { x: o, y: n };
30
58
  }
31
- function a(e, t, n) {
32
- return e <= 0 ? null : t < 0 ? n > 0 ? 0 : e - 1 : (t + n + e) % e;
59
+ function s(e, t, f) {
60
+ return e <= 0 ? null : t < 0 ? f > 0 ? 0 : e - 1 : (t + f + e) % e;
33
61
  }
34
- function s(e) {
35
- return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(r)).filter(
62
+ function l(e) {
63
+ return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(M)).filter(
36
64
  (t) => t instanceof HTMLElement
37
65
  );
38
66
  }
39
- function w(e, t = "first") {
40
- const n = s(e);
41
- if (!n.length) return !1;
42
- let o = n[0];
43
- return t === "last" ? o = n[n.length - 1] : t === "selected" && (o = n.find((f) => f.getAttribute("data-floe-selected") === "true") ?? n[0]), o.focus(), !0;
67
+ function T(e, t = "first") {
68
+ const f = l(e);
69
+ if (!f.length) return !1;
70
+ let i = f[0];
71
+ return t === "last" ? i = f[f.length - 1] : t === "selected" && (i = f.find((o) => o.getAttribute("data-floe-selected") === "true") ?? f[0]), i.focus(), !0;
44
72
  }
45
- function E(e, t, n) {
46
- const o = s(e);
47
- if (!o.length) return !1;
48
- const f = t ? o.indexOf(t) : -1, i = a(o.length, f, n);
49
- return i === null ? !1 : (o[i]?.focus(), !0);
73
+ function w(e, t, f) {
74
+ const i = l(e);
75
+ if (!i.length) return !1;
76
+ const o = t ? i.indexOf(t) : -1, n = s(i.length, o, f);
77
+ return n === null ? !1 : (i[n]?.focus(), !0);
50
78
  }
51
79
  export {
52
- r as MENU_ITEM_SELECTOR,
53
- d as VIEWPORT_MARGIN,
54
- M as calculateMenuPosition,
55
- u as calculateSubmenuPosition,
56
- w as focusMenuItem,
57
- s as getMenuItems,
58
- a as getWrappedMenuItemIndex,
59
- E as moveMenuFocus
80
+ M as MENU_ITEM_SELECTOR,
81
+ u as VIEWPORT_MARGIN,
82
+ A as calculateMenuPosition,
83
+ P as calculateSubmenuPosition,
84
+ E as clampMenuPosition,
85
+ T as focusMenuItem,
86
+ l as getMenuItems,
87
+ s as getWrappedMenuItemIndex,
88
+ w as moveMenuFocus,
89
+ a as resolveViewportMenuBoundaryRect
60
90
  };
@@ -0,0 +1 @@
1
+ export { SURFACE_PORTAL_HOST_ATTR, ensureSurfacePortalInteractionTracking, resolveSurfacePortalHost, isSurfacePortalMode, resolveSurfacePortalMount, resolveSurfacePortalBoundaryRect, projectSurfacePortalPosition, __resetSurfacePortalScopeForTests, type SurfacePortalInteractionSnapshot, type SurfacePortalMode, type ResolvedSurfacePortalHost, type SurfacePortalBoundaryRect, } from './dialogSurfaceScope';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.12",
3
+ "version": "0.36.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",