@floegence/floe-webapp-core 0.39.1 → 0.39.3
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/index.d.ts +1 -0
- package/dist/components/ui/menuUtils.d.ts +5 -0
- package/dist/components/ui/menuUtils.js +76 -54
- package/dist/full.js +352 -346
- package/dist/ui.js +115 -109
- package/package.json +3 -2
|
@@ -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
|
};
|