@floegence/floe-webapp-core 0.39.2 → 0.39.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,9 +1,9 @@
1
- const a = "data-floe-dialog-surface-host", y = a, p = "data-floe-surface-portal-layer", A = "data-floe-dialog-surface-boundary", g = 1600;
1
+ const d = "data-floe-dialog-surface-host", y = d, p = "data-floe-surface-portal-layer", v = "data-floe-surface-floating-layer", _ = "data-floe-dialog-surface-boundary", g = 1600;
2
2
  let r = null, o = null;
3
3
  function E(t) {
4
4
  return typeof Element < "u" && t instanceof Element ? t : typeof Node < "u" && t instanceof Node ? t.parentElement : null;
5
5
  }
6
- function w(t) {
6
+ function T(t) {
7
7
  const e = t?.activeElement;
8
8
  return e instanceof Element ? e : null;
9
9
  }
@@ -11,7 +11,7 @@ function l(t) {
11
11
  const e = typeof document < "u" ? document : null;
12
12
  r = {
13
13
  target: E(t),
14
- activeElement: w(e),
14
+ activeElement: T(e),
15
15
  recordedAt: Date.now()
16
16
  };
17
17
  }
@@ -21,41 +21,41 @@ function c(t) {
21
21
  function f(t) {
22
22
  l(t.target);
23
23
  }
24
- function d(t) {
24
+ function a(t) {
25
25
  l(t.target);
26
26
  }
27
27
  function s() {
28
- T();
29
- }
30
- function T() {
31
- typeof document > "u" || o !== document && (o && (o.removeEventListener("pointerdown", c, !0), o.removeEventListener("focusin", f, !0), o.removeEventListener("contextmenu", d, !0)), document.addEventListener("pointerdown", c, !0), document.addEventListener("focusin", f, !0), document.addEventListener("contextmenu", d, !0), o = document);
28
+ R();
32
29
  }
33
30
  function R() {
31
+ typeof document > "u" || o !== document && (o && (o.removeEventListener("pointerdown", c, !0), o.removeEventListener("focusin", f, !0), o.removeEventListener("contextmenu", a, !0)), document.addEventListener("pointerdown", c, !0), document.addEventListener("focusin", f, !0), document.addEventListener("contextmenu", a, !0), o = document);
32
+ }
33
+ function w() {
34
34
  return !r || Date.now() - r.recordedAt > g ? null : r;
35
35
  }
36
36
  function i(t) {
37
- const e = t?.closest(`[${a}="true"]`);
37
+ const e = t?.closest(`[${d}="true"]`);
38
38
  return typeof HTMLElement > "u" ? null : e instanceof HTMLElement ? e : null;
39
39
  }
40
- function S(t) {
40
+ function A(t) {
41
41
  if (!t) return null;
42
42
  const e = t.closest(`[${p}="true"]`);
43
43
  return typeof HTMLElement > "u" ? null : e instanceof HTMLElement ? e : null;
44
44
  }
45
45
  function L(t = {}) {
46
46
  s();
47
- const e = R(), n = i(t.owner ?? null) ?? i(e?.target ?? null) ?? i(e?.activeElement ?? null);
47
+ const e = w(), n = i(t.owner ?? null) ?? i(e?.target ?? null) ?? i(e?.activeElement ?? null);
48
48
  return n ? {
49
49
  host: n,
50
50
  boundaryHost: n,
51
- mountHost: S(n) ?? n,
51
+ mountHost: A(n) ?? n,
52
52
  mode: "surface"
53
53
  } : { host: null, boundaryHost: null, mountHost: null, mode: "global" };
54
54
  }
55
55
  function u(t) {
56
56
  return t.mode === "surface" && !!t.boundaryHost?.isConnected;
57
57
  }
58
- function v(t) {
58
+ function S(t) {
59
59
  if (u(t))
60
60
  return t.mountHost ?? t.boundaryHost ?? void 0;
61
61
  }
@@ -76,7 +76,7 @@ function m() {
76
76
  height: window.innerHeight
77
77
  };
78
78
  }
79
- function _(t) {
79
+ function b(t) {
80
80
  if (!u(t) || !t.boundaryHost)
81
81
  return m();
82
82
  const e = t.boundaryHost.getBoundingClientRect();
@@ -90,7 +90,7 @@ function _(t) {
90
90
  };
91
91
  }
92
92
  function h(t) {
93
- const e = v(t);
93
+ const e = S(t);
94
94
  if (!e)
95
95
  return m();
96
96
  const n = e.getBoundingClientRect();
@@ -103,7 +103,7 @@ function h(t) {
103
103
  height: n.height
104
104
  };
105
105
  }
106
- function b(t, e) {
106
+ function P(t, e) {
107
107
  if (!u(e))
108
108
  return t;
109
109
  const n = h(e);
@@ -112,7 +112,7 @@ function b(t, e) {
112
112
  y: t.y - n.top
113
113
  };
114
114
  }
115
- function P(t, e) {
115
+ function C(t, e) {
116
116
  if (!u(e))
117
117
  return t;
118
118
  const n = h(e);
@@ -125,23 +125,24 @@ function P(t, e) {
125
125
  height: t.height
126
126
  };
127
127
  }
128
- function C() {
128
+ function H() {
129
129
  r = null;
130
130
  }
131
131
  typeof document < "u" && s();
132
132
  export {
133
- A as DIALOG_SURFACE_BOUNDARY_ATTR,
134
- a as DIALOG_SURFACE_HOST_ATTR,
133
+ _ as DIALOG_SURFACE_BOUNDARY_ATTR,
134
+ d as DIALOG_SURFACE_HOST_ATTR,
135
+ v as SURFACE_FLOATING_LAYER_ATTR,
135
136
  y as SURFACE_PORTAL_HOST_ATTR,
136
137
  p as SURFACE_PORTAL_LAYER_ATTR,
137
- C as __resetSurfacePortalScopeForTests,
138
+ H as __resetSurfacePortalScopeForTests,
138
139
  s as ensureDialogSurfaceInteractionTracking,
139
- T as ensureSurfacePortalInteractionTracking,
140
+ R as ensureSurfacePortalInteractionTracking,
140
141
  u as isSurfacePortalMode,
141
- b as projectSurfacePortalPosition,
142
- P as projectSurfacePortalRect,
143
- _ as resolveSurfacePortalBoundaryRect,
142
+ P as projectSurfacePortalPosition,
143
+ C as projectSurfacePortalRect,
144
+ b as resolveSurfacePortalBoundaryRect,
144
145
  L as resolveSurfacePortalHost,
145
- v as resolveSurfacePortalMount,
146
+ S as resolveSurfacePortalMount,
146
147
  h as resolveSurfacePortalMountRect
147
148
  };
@@ -4,6 +4,7 @@ export { Input, Textarea, NumberInput, AffixInput, type InputProps, type InputSi
4
4
  export { Dialog, ConfirmDialog, type DialogProps, type ConfirmDialogProps } from './Dialog';
5
5
  export { FloatingWindow, type FloatingWindowProps } from './FloatingWindow';
6
6
  export { createFloatingPresence, type FloatingPresence, type FloatingPresenceOptions, type FloatingPresenceState, } from './floatingPresence';
7
+ export { MENU_ITEM_SELECTOR, focusMenuItem, getMenuItems, handleMenuKeyboardNavigation, moveMenuFocus, type MenuDismissReason, type MenuFocusMode, type MenuKeyboardNavigationOptions, } from './menuUtils';
7
8
  export { resolveFloatingWindowViewport, type FloatingWindowRect, type FloatingWindowViewport, type FloatingWindowViewportInsets, } from './floatingWindowGeometry';
8
9
  export { Dropdown, Select, type DropdownProps, type DropdownItem, type SelectProps, } from './Dropdown';
9
10
  export { SurfaceFloatingLayer, type SurfaceFloatingLayerPosition, type SurfaceFloatingLayerProps, type SurfaceFloatingLayerSize, } from './SurfaceFloatingLayer';
@@ -9,6 +9,10 @@ export type MenuBoundaryRect = Readonly<{
9
9
  height: number;
10
10
  }>;
11
11
  export type MenuFocusMode = 'first' | 'last' | 'selected';
12
+ export type MenuDismissReason = 'escape' | 'tab' | 'shift-tab';
13
+ export type MenuKeyboardNavigationOptions = Readonly<{
14
+ onDismiss: (reason: MenuDismissReason) => void;
15
+ }>;
12
16
  export declare function resolveViewportMenuBoundaryRect(): MenuBoundaryRect;
13
17
  export declare function clampMenuPosition(anchor: Readonly<{
14
18
  x: number;
@@ -32,3 +36,4 @@ export declare function getWrappedMenuItemIndex(length: number, currentIndex: nu
32
36
  export declare function getMenuItems(root: ParentNode | null | undefined): HTMLElement[];
33
37
  export declare function focusMenuItem(root: ParentNode | null | undefined, mode?: MenuFocusMode): boolean;
34
38
  export declare function moveMenuFocus(root: ParentNode | null | undefined, current: HTMLElement | null, delta: 1 | -1): boolean;
39
+ export declare function handleMenuKeyboardNavigation(event: KeyboardEvent, options: MenuKeyboardNavigationOptions): boolean;
@@ -1,5 +1,5 @@
1
- const u = 8, M = '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])';
2
- function a() {
1
+ const E = 8, h = '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])';
2
+ function M() {
3
3
  return typeof window > "u" ? {
4
4
  left: 0,
5
5
  top: 0,
@@ -16,75 +16,97 @@ function a() {
16
16
  height: window.innerHeight
17
17
  };
18
18
  }
19
- function h(e) {
20
- return e ?? a();
19
+ function f(t) {
20
+ return t ?? M();
21
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)
22
+ function w(t, e, r) {
23
+ const n = f(r);
24
+ let o = t.x, i = t.y;
25
+ return o + e.width > n.right - 8 && (o = n.right - e.width - 8), i + e.height > n.bottom - 8 && (i = n.bottom - e.height - 8), {
26
+ x: Math.max(n.left + 8, o),
27
+ y: Math.max(n.top + 8, i)
28
28
  };
29
29
  }
30
- function A(e, t, f, i) {
31
- const o = h(i);
32
- let n;
33
- switch (f) {
30
+ function T(t, e, r, n) {
31
+ const o = f(n);
32
+ let i;
33
+ switch (r) {
34
34
  case "center":
35
- n = e.left + e.width / 2 - t.width / 2;
35
+ i = t.left + t.width / 2 - e.width / 2;
36
36
  break;
37
37
  case "end":
38
- n = e.right - t.width;
38
+ i = t.right - e.width;
39
39
  break;
40
40
  default:
41
- n = e.left;
41
+ i = t.left;
42
42
  }
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;
43
+ let a = t.bottom + 4;
44
+ if (i + e.width > o.right - 8 && (i = o.right - e.width - 8), i = Math.max(o.left + 8, i), a + e.height > o.bottom - 8) {
45
+ const s = t.top - o.top - 8, d = o.bottom - t.bottom - 8;
46
+ s > d && s >= e.height ? a = t.top - e.height - 4 : a = o.bottom - e.height - 8;
47
47
  }
48
- return r = Math.max(o.top + 8, r), { x: n, y: r };
48
+ return a = Math.max(o.top + 8, a), { x: i, y: a };
49
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;
50
+ function A(t, e, r) {
51
+ const n = f(r);
52
+ let o = t.right, i = t.top;
53
+ if (o + e.width > n.right - 8) {
54
+ const a = t.left - e.width;
55
+ a >= n.left + 8 ? o = a : o = n.right - e.width - 8;
56
56
  }
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 };
57
+ return i + e.height > n.bottom - 8 && (i = n.bottom - e.height - 8), o = Math.max(n.left + 8, o), i = Math.max(n.top + 8, i), { x: o, y: i };
58
58
  }
59
- function s(e, t, f) {
60
- return e <= 0 ? null : t < 0 ? f > 0 ? 0 : e - 1 : (t + f + e) % e;
59
+ function c(t, e, r) {
60
+ return t <= 0 ? null : e < 0 ? r > 0 ? 0 : t - 1 : (e + r + t) % t;
61
61
  }
62
- function l(e) {
63
- return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(M)).filter(
64
- (t) => t instanceof HTMLElement
62
+ function I(t) {
63
+ return !t || typeof HTMLElement > "u" ? [] : Array.from(t.querySelectorAll(h)).filter(
64
+ (e) => e instanceof HTMLElement
65
65
  );
66
66
  }
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;
67
+ function l(t, e = "first") {
68
+ const r = I(t);
69
+ if (!r.length) return !1;
70
+ let n = r[0];
71
+ return e === "last" ? n = r[r.length - 1] : e === "selected" && (n = r.find((o) => o.getAttribute("data-floe-selected") === "true") ?? r[0]), n.focus(), !0;
72
72
  }
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);
73
+ function u(t, e, r) {
74
+ const n = I(t);
75
+ if (!n.length) return !1;
76
+ const o = e ? n.indexOf(e) : -1, i = c(n.length, o, r);
77
+ return i === null ? !1 : (n[i]?.focus(), !0);
78
+ }
79
+ function P(t, e) {
80
+ const r = typeof HTMLElement < "u" && t.target instanceof HTMLElement ? t.target : null, n = r?.closest('[role="menu"]');
81
+ if (!n) return !1;
82
+ const o = r?.closest(h);
83
+ switch (t.key) {
84
+ case "ArrowDown":
85
+ return t.preventDefault(), u(n, o, 1), !0;
86
+ case "ArrowUp":
87
+ return t.preventDefault(), u(n, o, -1), !0;
88
+ case "Home":
89
+ return t.preventDefault(), l(n, "first"), !0;
90
+ case "End":
91
+ return t.preventDefault(), l(n, "last"), !0;
92
+ case "Escape":
93
+ return t.preventDefault(), t.stopPropagation(), e.onDismiss("escape"), !0;
94
+ case "Tab":
95
+ return e.onDismiss(t.shiftKey ? "shift-tab" : "tab"), !0;
96
+ default:
97
+ return !1;
98
+ }
78
99
  }
79
100
  export {
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
101
+ h as MENU_ITEM_SELECTOR,
102
+ E as VIEWPORT_MARGIN,
103
+ T as calculateMenuPosition,
104
+ A as calculateSubmenuPosition,
105
+ w as clampMenuPosition,
106
+ l as focusMenuItem,
107
+ I as getMenuItems,
108
+ c as getWrappedMenuItemIndex,
109
+ P as handleMenuKeyboardNavigation,
110
+ u as moveMenuFocus,
111
+ M as resolveViewportMenuBoundaryRect
90
112
  };
@@ -1 +1 @@
1
- export { DIALOG_SURFACE_HOST_ATTR, SURFACE_PORTAL_HOST_ATTR, SURFACE_PORTAL_LAYER_ATTR, DIALOG_SURFACE_BOUNDARY_ATTR, ensureSurfacePortalInteractionTracking, resolveSurfacePortalHost, isSurfacePortalMode, resolveSurfacePortalMount, resolveSurfacePortalBoundaryRect, resolveSurfacePortalMountRect, projectSurfacePortalPosition, projectSurfacePortalRect, __resetSurfacePortalScopeForTests, type SurfacePortalInteractionSnapshot, type SurfacePortalHostResolutionOptions, type SurfacePortalMode, type ResolvedSurfacePortalHost, type SurfacePortalBoundaryRect, type SurfacePortalRect, } from './dialogSurfaceScope';
1
+ export { DIALOG_SURFACE_HOST_ATTR, SURFACE_PORTAL_HOST_ATTR, SURFACE_PORTAL_LAYER_ATTR, SURFACE_FLOATING_LAYER_ATTR, DIALOG_SURFACE_BOUNDARY_ATTR, ensureSurfacePortalInteractionTracking, resolveSurfacePortalHost, isSurfacePortalMode, resolveSurfacePortalMount, resolveSurfacePortalBoundaryRect, resolveSurfacePortalMountRect, projectSurfacePortalPosition, projectSurfacePortalRect, __resetSurfacePortalScopeForTests, type SurfacePortalInteractionSnapshot, type SurfacePortalHostResolutionOptions, type SurfacePortalMode, type ResolvedSurfacePortalHost, type SurfacePortalBoundaryRect, type SurfacePortalRect, } from './dialogSurfaceScope';