@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.
- package/dist/components/file-browser/FileContextMenu.js +263 -225
- package/dist/components/ui/Dialog.js +44 -44
- package/dist/components/ui/Dropdown.js +207 -169
- package/dist/components/ui/dialogSurfaceScope.d.ts +26 -1
- package/dist/components/ui/dialogSurfaceScope.js +81 -28
- package/dist/components/ui/menuUtils.d.ts +21 -2
- package/dist/components/ui/menuUtils.js +73 -43
- package/dist/components/ui/surfacePortalScope.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,45 +1,98 @@
|
|
|
1
|
-
const a = "data-floe-dialog-surface-host",
|
|
2
|
-
let o = null,
|
|
3
|
-
function
|
|
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
|
|
7
|
-
const
|
|
8
|
-
return
|
|
6
|
+
function h(e) {
|
|
7
|
+
const t = e?.activeElement;
|
|
8
|
+
return t instanceof Element ? t : null;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
10
|
+
function l(e) {
|
|
11
|
+
const t = typeof document < "u" ? document : null;
|
|
12
12
|
o = {
|
|
13
|
-
target:
|
|
14
|
-
activeElement:
|
|
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
|
-
|
|
19
|
+
l(e.target);
|
|
23
20
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
21
|
+
function c(e) {
|
|
22
|
+
l(e.target);
|
|
26
23
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
24
|
+
function f() {
|
|
25
|
+
m();
|
|
29
26
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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" &&
|
|
87
|
+
typeof document < "u" && f();
|
|
40
88
|
export {
|
|
41
|
-
|
|
89
|
+
w as DIALOG_SURFACE_BOUNDARY_ATTR,
|
|
42
90
|
a as DIALOG_SURFACE_HOST_ATTR,
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
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
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
35
|
+
n = e.left + e.width / 2 - t.width / 2;
|
|
8
36
|
break;
|
|
9
37
|
case "end":
|
|
10
|
-
|
|
38
|
+
n = e.right - t.width;
|
|
11
39
|
break;
|
|
12
40
|
default:
|
|
13
|
-
|
|
41
|
+
n = e.left;
|
|
14
42
|
}
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
17
|
-
const I = e.top - 8,
|
|
18
|
-
I >
|
|
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
|
|
21
|
-
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
|
|
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
|
|
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
|
|
32
|
-
return e <= 0 ? null : t < 0 ?
|
|
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
|
|
35
|
-
return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(
|
|
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
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
let
|
|
43
|
-
return t === "last" ?
|
|
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
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
return
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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';
|