@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.
- package/dist/components/ui/FloatingWindow.js +105 -102
- package/dist/components/ui/SurfaceFloatingLayer.js +19 -17
- package/dist/components/ui/dialogSurfaceScope.d.ts +1 -0
- package/dist/components/ui/dialogSurfaceScope.js +27 -26
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/menuUtils.d.ts +5 -0
- package/dist/components/ui/menuUtils.js +76 -54
- package/dist/components/ui/surfacePortalScope.d.ts +1 -1
- package/dist/full.js +352 -346
- package/dist/ui.js +115 -109
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
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
|
|
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:
|
|
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
|
|
24
|
+
function a(t) {
|
|
25
25
|
l(t.target);
|
|
26
26
|
}
|
|
27
27
|
function s() {
|
|
28
|
-
|
|
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(`[${
|
|
37
|
+
const e = t?.closest(`[${d}="true"]`);
|
|
38
38
|
return typeof HTMLElement > "u" ? null : e instanceof HTMLElement ? e : null;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
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 =
|
|
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:
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
128
|
+
function H() {
|
|
129
129
|
r = null;
|
|
130
130
|
}
|
|
131
131
|
typeof document < "u" && s();
|
|
132
132
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
138
|
+
H as __resetSurfacePortalScopeForTests,
|
|
138
139
|
s as ensureDialogSurfaceInteractionTracking,
|
|
139
|
-
|
|
140
|
+
R as ensureSurfacePortalInteractionTracking,
|
|
140
141
|
u as isSurfacePortalMode,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
P as projectSurfacePortalPosition,
|
|
143
|
+
C as projectSurfacePortalRect,
|
|
144
|
+
b as resolveSurfacePortalBoundaryRect,
|
|
144
145
|
L as resolveSurfacePortalHost,
|
|
145
|
-
|
|
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
|
|
2
|
-
function
|
|
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
|
|
20
|
-
return
|
|
19
|
+
function f(t) {
|
|
20
|
+
return t ?? M();
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
let o =
|
|
25
|
-
return o +
|
|
26
|
-
x: Math.max(
|
|
27
|
-
y: Math.max(
|
|
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
|
|
31
|
-
const o =
|
|
32
|
-
let
|
|
33
|
-
switch (
|
|
30
|
+
function T(t, e, r, n) {
|
|
31
|
+
const o = f(n);
|
|
32
|
+
let i;
|
|
33
|
+
switch (r) {
|
|
34
34
|
case "center":
|
|
35
|
-
|
|
35
|
+
i = t.left + t.width / 2 - e.width / 2;
|
|
36
36
|
break;
|
|
37
37
|
case "end":
|
|
38
|
-
|
|
38
|
+
i = t.right - e.width;
|
|
39
39
|
break;
|
|
40
40
|
default:
|
|
41
|
-
|
|
41
|
+
i = t.left;
|
|
42
42
|
}
|
|
43
|
-
let
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
|
|
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
|
|
48
|
+
return a = Math.max(o.top + 8, a), { x: i, y: a };
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
let o =
|
|
53
|
-
if (o +
|
|
54
|
-
const
|
|
55
|
-
|
|
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
|
|
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
|
|
60
|
-
return
|
|
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
|
|
63
|
-
return !
|
|
64
|
-
(
|
|
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
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
let
|
|
71
|
-
return
|
|
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
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
76
|
-
const o =
|
|
77
|
-
return
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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';
|