@floegence/floe-webapp-core 0.26.2 → 0.26.5
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/chat/input/ChatInput.js +59 -46
- package/dist/components/deck/WidgetResizeHandle.js +49 -49
- package/dist/components/file-browser/FileBrowser.js +41 -40
- package/dist/components/file-browser/FileBrowserToolbar.js +27 -26
- package/dist/components/file-browser/FileGridView.js +158 -142
- package/dist/components/launchpad/LaunchpadModal.js +53 -85
- package/dist/components/ui/CommandPalette.js +108 -94
- package/dist/components/ui/Dialog.js +53 -76
- package/dist/components/ui/Tabs.js +156 -116
- package/dist/hooks/useDeckDrag.js +36 -36
- package/dist/hooks/useFileBrowserDrag.js +50 -50
- package/dist/hooks/useOverlayMask.d.ts +26 -0
- package/dist/hooks/useOverlayMask.js +85 -0
- package/dist/styles.css +1 -1
- package/dist/utils/focus.d.ts +2 -0
- package/dist/utils/focus.js +25 -0
- package/package.json +1 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { createSignal as
|
|
2
|
-
import { lockBodyStyle as
|
|
3
|
-
import { useFileBrowserDrag as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const e =
|
|
7
|
-
let c = null, D = 0, P = 0, u = 0, g = 0, d = null, l = null, s = null, m = null, h = !1, p = "mouse";
|
|
8
|
-
const
|
|
1
|
+
import { createSignal as x, createEffect as q, onCleanup as Y } from "solid-js";
|
|
2
|
+
import { lockBodyStyle as V } from "../utils/bodyStyleLock.js";
|
|
3
|
+
import { useFileBrowserDrag as X } from "../context/FileBrowserDragContext.js";
|
|
4
|
+
const W = 5, j = 500, z = 10, i = 48, b = 24;
|
|
5
|
+
function $(n) {
|
|
6
|
+
const e = X(), [f, T] = x(!1);
|
|
7
|
+
let c = null, D = 0, P = 0, u = 0, g = 0, d = null, l = null, s = null, m = null, h = !1, p = "mouse", I = null;
|
|
8
|
+
const L = () => (n.enabled?.() ?? !0) && !!e, _ = () => {
|
|
9
9
|
m !== null && (clearTimeout(m), m = null);
|
|
10
|
-
},
|
|
10
|
+
}, R = (t) => {
|
|
11
11
|
if (!t) {
|
|
12
12
|
l?.(), l = null;
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
l?.(), l =
|
|
16
|
-
},
|
|
17
|
-
s !== null && (cancelAnimationFrame(s), s = null),
|
|
18
|
-
},
|
|
15
|
+
l?.(), l = V({ cursor: "grabbing", "user-select": "none" });
|
|
16
|
+
}, v = () => {
|
|
17
|
+
s !== null && (cancelAnimationFrame(s), s = null), _(), c = null, d = null, h = !1, I = null, R(!1), T(!1);
|
|
18
|
+
}, w = () => {
|
|
19
19
|
if (!e) return;
|
|
20
20
|
const t = e.getInstances();
|
|
21
21
|
for (const [, a] of t) {
|
|
22
22
|
const o = a.getScrollContainer();
|
|
23
|
-
o &&
|
|
23
|
+
o && M(o, u, g);
|
|
24
24
|
const r = a.getSidebarScrollContainer();
|
|
25
|
-
r &&
|
|
25
|
+
r && M(r, u, g);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
const r = t.getBoundingClientRect();
|
|
29
|
-
if (a < r.left || a > r.right || o < r.top || o > r.bottom)
|
|
27
|
+
}, M = (t, a, o) => {
|
|
28
|
+
const r = I?.get(t) ?? t.getBoundingClientRect();
|
|
29
|
+
if (I?.set(t, r), a < r.left || a > r.right || o < r.top || o > r.bottom)
|
|
30
30
|
return;
|
|
31
|
-
const
|
|
32
|
-
let
|
|
33
|
-
if (
|
|
34
|
-
const S = Math.max(0, Math.min(t.scrollTop +
|
|
31
|
+
const O = o - r.top, y = r.bottom - o, A = a - r.left, B = r.right - a;
|
|
32
|
+
let E = 0, C = 0;
|
|
33
|
+
if (O < i ? E = -Math.ceil((i - O) / i * b) : y < i && (E = Math.ceil((i - y) / i * b)), A < i ? C = -Math.ceil((i - A) / i * b) : B < i && (C = Math.ceil((i - B) / i * b)), E !== 0) {
|
|
34
|
+
const S = Math.max(0, Math.min(t.scrollTop + E, t.scrollHeight - t.clientHeight));
|
|
35
35
|
S !== t.scrollTop && (t.scrollTop = S);
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
38
|
-
const S = Math.max(0, Math.min(t.scrollLeft +
|
|
37
|
+
if (C !== 0) {
|
|
38
|
+
const S = Math.max(0, Math.min(t.scrollLeft + C, t.scrollWidth - t.clientWidth));
|
|
39
39
|
S !== t.scrollLeft && (t.scrollLeft = S);
|
|
40
40
|
}
|
|
41
41
|
}, F = () => {
|
|
@@ -45,20 +45,20 @@ function Z(n) {
|
|
|
45
45
|
s = null;
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
w(), s = requestAnimationFrame(t);
|
|
49
49
|
};
|
|
50
50
|
s = requestAnimationFrame(t);
|
|
51
51
|
}, H = () => {
|
|
52
52
|
if (!e || !d) return;
|
|
53
|
-
n.isSelected(d.id) || n.selectItem(d.id, !1);
|
|
53
|
+
I = /* @__PURE__ */ new Map(), n.isSelected(d.id) || n.selectItem(d.id, !1);
|
|
54
54
|
const t = n.getSelectedItems(), o = (t.length > 0 && n.isSelected(d.id) ? t : [d]).map((r) => ({
|
|
55
55
|
item: r,
|
|
56
56
|
sourceInstanceId: n.instanceId,
|
|
57
57
|
sourcePath: n.currentPath()
|
|
58
58
|
}));
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
59
|
+
R(!0), T(!0), e.startDrag(o, u, g), n.onDragStart?.(), F();
|
|
60
|
+
}, U = (t, a) => {
|
|
61
|
+
L() && c === null && (t.pointerType === "mouse" && t.button !== 0 || (c = t.pointerId, p = t.pointerType, D = t.clientX, P = t.clientY, u = D, g = P, d = a, h = !1, t.currentTarget.setPointerCapture(t.pointerId), (p === "touch" || p === "pen") && (_(), m = setTimeout(() => {
|
|
62
62
|
if (c !== null && d) {
|
|
63
63
|
if (h = !0, "vibrate" in navigator)
|
|
64
64
|
try {
|
|
@@ -67,43 +67,43 @@ function Z(n) {
|
|
|
67
67
|
}
|
|
68
68
|
H();
|
|
69
69
|
}
|
|
70
|
-
},
|
|
71
|
-
},
|
|
70
|
+
}, j))));
|
|
71
|
+
}, k = (t) => {
|
|
72
72
|
if (c !== t.pointerId) return;
|
|
73
73
|
u = t.clientX, g = t.clientY;
|
|
74
74
|
const a = u - D, o = g - P, r = Math.sqrt(a * a + o * o);
|
|
75
|
-
if ((p === "touch" || p === "pen") && !h && r >
|
|
76
|
-
|
|
75
|
+
if ((p === "touch" || p === "pen") && !h && r > z) {
|
|
76
|
+
_(), v();
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
p === "mouse" && !f() && r >
|
|
80
|
-
},
|
|
79
|
+
p === "mouse" && !f() && r > W && H(), f() && e && e.updateDrag(u, g);
|
|
80
|
+
}, G = (t) => {
|
|
81
81
|
if (c === t.pointerId) {
|
|
82
82
|
try {
|
|
83
83
|
t.currentTarget?.releasePointerCapture(t.pointerId);
|
|
84
84
|
} catch {
|
|
85
85
|
}
|
|
86
|
-
f() && e && e.endDrag(!0),
|
|
86
|
+
f() && e && e.endDrag(!0), v();
|
|
87
87
|
}
|
|
88
|
-
},
|
|
89
|
-
c === t.pointerId && (f() && e && e.endDrag(!1),
|
|
88
|
+
}, N = (t) => {
|
|
89
|
+
c === t.pointerId && (f() && e && e.endDrag(!1), v());
|
|
90
90
|
};
|
|
91
|
-
return
|
|
92
|
-
if (!
|
|
93
|
-
const t = (r) =>
|
|
94
|
-
document.addEventListener("pointermove", t, !0), document.addEventListener("pointerup", a, !0), document.addEventListener("pointercancel", o, !0),
|
|
95
|
-
|
|
91
|
+
return q(() => {
|
|
92
|
+
if (!L() || typeof document > "u") return;
|
|
93
|
+
const t = (r) => k(r), a = (r) => G(r), o = (r) => N(r);
|
|
94
|
+
document.addEventListener("pointermove", t, !0), document.addEventListener("pointerup", a, !0), document.addEventListener("pointercancel", o, !0), Y(() => {
|
|
95
|
+
v(), document.removeEventListener("pointermove", t, !0), document.removeEventListener("pointerup", a, !0), document.removeEventListener("pointercancel", o, !0);
|
|
96
96
|
});
|
|
97
97
|
}), {
|
|
98
98
|
isDragging: f,
|
|
99
99
|
getDragHandlers: (t) => ({
|
|
100
|
-
onPointerDown: (a) =>
|
|
100
|
+
onPointerDown: (a) => U(a, t),
|
|
101
101
|
"data-draggable": "true"
|
|
102
102
|
})
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
const e =
|
|
105
|
+
function tt(n) {
|
|
106
|
+
const e = X(), [f, T] = x(!1), c = () => (n.enabled?.() ?? !0) && !!e, D = () => f() ? e?.dragState()?.isDragging ?? !1 : !1, P = () => {
|
|
107
107
|
if (!D() || !e) return !1;
|
|
108
108
|
const l = e.dragState();
|
|
109
109
|
return l.isDragging ? e.canDropOn(
|
|
@@ -117,7 +117,7 @@ function $(n) {
|
|
|
117
117
|
const s = e.dragState();
|
|
118
118
|
if (!s.isDragging) return;
|
|
119
119
|
T(!0);
|
|
120
|
-
const m = n.targetPath(), h = n.targetItem(), p = e.canDropOn(s.draggedItems, m, h, n.instanceId),
|
|
120
|
+
const m = n.targetPath(), h = n.targetItem(), p = e.canDropOn(s.draggedItems, m, h, n.instanceId), L = l.currentTarget?.getBoundingClientRect() ?? null;
|
|
121
121
|
e.setDropTarget(
|
|
122
122
|
{
|
|
123
123
|
instanceId: n.instanceId,
|
|
@@ -125,7 +125,7 @@ function $(n) {
|
|
|
125
125
|
targetItem: h
|
|
126
126
|
},
|
|
127
127
|
p,
|
|
128
|
-
|
|
128
|
+
L
|
|
129
129
|
);
|
|
130
130
|
}, g = (l) => {
|
|
131
131
|
if (!e) return;
|
|
@@ -144,6 +144,6 @@ function $(n) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
export {
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
tt as useFileBrowserDropTarget,
|
|
148
|
+
$ as useFileBrowserItemDrag
|
|
149
149
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
export type OverlayScrollBlockMode = 'none' | 'outside' | 'all';
|
|
3
|
+
export interface UseOverlayMaskOptions {
|
|
4
|
+
open: Accessor<boolean>;
|
|
5
|
+
root: Accessor<HTMLElement | undefined>;
|
|
6
|
+
onClose?: () => void;
|
|
7
|
+
/** Lock `document.body` scroll while the overlay is open (default: true). */
|
|
8
|
+
lockBodyScroll?: boolean;
|
|
9
|
+
/** Prevent scroll via wheel events (default: none). */
|
|
10
|
+
blockWheel?: OverlayScrollBlockMode;
|
|
11
|
+
/** Prevent scroll via touch-move events (default: none). */
|
|
12
|
+
blockTouchMove?: OverlayScrollBlockMode;
|
|
13
|
+
/** Keep tab focus within the overlay root (default: true). */
|
|
14
|
+
trapFocus?: boolean;
|
|
15
|
+
/** Close on Escape and never leak to underlying window handlers (default: true). */
|
|
16
|
+
closeOnEscape?: boolean;
|
|
17
|
+
/** Stop bubbling keydown events to window-level hotkeys (default: true). */
|
|
18
|
+
blockHotkeys?: boolean;
|
|
19
|
+
/** Auto-focus on open (default: true). */
|
|
20
|
+
autoFocus?: boolean | {
|
|
21
|
+
selector?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Restore focus to the previously active element on close (default: true). */
|
|
24
|
+
restoreFocus?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function useOverlayMask(options: UseOverlayMaskOptions): void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createEffect as g, onCleanup as T } from "solid-js";
|
|
2
|
+
import { lockBodyStyle as B } from "../utils/bodyStyleLock.js";
|
|
3
|
+
import { deferAfterPaint as E } from "../utils/defer.js";
|
|
4
|
+
import { getFocusableElements as F, getFirstFocusableElement as M } from "../utils/focus.js";
|
|
5
|
+
function k(t) {
|
|
6
|
+
return typeof Node < "u" && t instanceof Node;
|
|
7
|
+
}
|
|
8
|
+
function p(t, c, r) {
|
|
9
|
+
return r === "none" ? !1 : r === "all" || !t || !k(c) ? !0 : !t.contains(c);
|
|
10
|
+
}
|
|
11
|
+
function H(t) {
|
|
12
|
+
const c = () => t.lockBodyScroll !== !1, r = () => t.trapFocus !== !1, s = () => t.closeOnEscape !== !1, b = () => t.blockHotkeys !== !1, w = () => t.restoreFocus !== !1;
|
|
13
|
+
g(() => {
|
|
14
|
+
if (!t.open() || typeof document > "u") return;
|
|
15
|
+
const a = document.activeElement instanceof HTMLElement ? document.activeElement : null, L = c() ? B({ overflow: "hidden" }) : null;
|
|
16
|
+
E(() => {
|
|
17
|
+
const e = t.root();
|
|
18
|
+
if (!e) return;
|
|
19
|
+
const n = t.autoFocus;
|
|
20
|
+
if (n === !1) return;
|
|
21
|
+
const o = typeof n == "object" ? n.selector : void 0, u = (o ? e.querySelector(o) : null) ?? e.querySelector("[data-floe-autofocus]") ?? M(e) ?? e;
|
|
22
|
+
try {
|
|
23
|
+
u.focus();
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const d = (e) => {
|
|
28
|
+
if (e.key !== "Tab") return;
|
|
29
|
+
const n = t.root();
|
|
30
|
+
if (!n) return;
|
|
31
|
+
const o = F(n);
|
|
32
|
+
if (!o.length) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
try {
|
|
35
|
+
n.focus();
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const f = o[0], u = o[o.length - 1], l = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
41
|
+
if (e.shiftKey) {
|
|
42
|
+
if (l === f || !l || !n.contains(l)) {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
try {
|
|
45
|
+
u.focus();
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} else if (l === u) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
try {
|
|
52
|
+
f.focus();
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, i = (e) => {
|
|
57
|
+
e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.());
|
|
58
|
+
}, m = (e) => {
|
|
59
|
+
const n = t.root();
|
|
60
|
+
n && b() && k(e.target) && n.contains(e.target) && e.stopPropagation();
|
|
61
|
+
}, v = (e) => {
|
|
62
|
+
const n = t.blockWheel ?? "none", o = t.root();
|
|
63
|
+
p(o, e.target, n) && e.cancelable && e.preventDefault();
|
|
64
|
+
}, h = (e) => {
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
}, y = (e) => {
|
|
67
|
+
const n = t.blockTouchMove ?? "none", o = t.root();
|
|
68
|
+
p(o, e.target, n) && e.cancelable && e.preventDefault();
|
|
69
|
+
};
|
|
70
|
+
r() && document.addEventListener("keydown", d, !0), s() && window.addEventListener("keydown", i, !0), document.addEventListener("keydown", m), (t.blockWheel ?? "none") !== "none" && (document.addEventListener("wheel", v, { capture: !0, passive: !1 }), document.addEventListener("wheel", h)), (t.blockTouchMove ?? "none") !== "none" && document.addEventListener("touchmove", y, { capture: !0, passive: !1 }), T(() => {
|
|
71
|
+
r() && document.removeEventListener("keydown", d, !0), s() && window.removeEventListener("keydown", i, !0), document.removeEventListener("keydown", m), (t.blockWheel ?? "none") !== "none" && (document.removeEventListener("wheel", v, !0), document.removeEventListener("wheel", h)), (t.blockTouchMove ?? "none") !== "none" && document.removeEventListener("touchmove", y, !0), L?.(), w() && a && a.isConnected && E(() => {
|
|
72
|
+
if (typeof document > "u") return;
|
|
73
|
+
const e = document.activeElement;
|
|
74
|
+
if (!(e && e !== document.body && e !== document.documentElement))
|
|
75
|
+
try {
|
|
76
|
+
a.focus();
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
H as useOverlayMask
|
|
85
|
+
};
|