@floegence/floe-webapp-core 0.89.2 → 0.90.0
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 +30 -30
- package/dist/components/ui/Tabs.d.ts +2 -0
- package/dist/components/ui/Tabs.js +190 -172
- package/dist/components/ui/WindowTabs.js +1 -1
- package/dist/components/ui/tabReorder.d.ts +19 -0
- package/dist/components/ui/tabReorder.js +55 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createSignal as p, createEffect as M, onCleanup as P } from "solid-js";
|
|
2
|
+
import { startPointerSession as X } from "./pointerSession.js";
|
|
3
|
+
function C(o) {
|
|
4
|
+
const [d, w] = p(), [h, b] = p(), [A, k] = p();
|
|
5
|
+
let a, l, c = 0, s = 0, u = !1, m, f;
|
|
6
|
+
const E = (e, r) => {
|
|
7
|
+
const t = o.items().map((n) => n.id).filter((n) => n !== e), i = r ? t.indexOf(r) : t.length;
|
|
8
|
+
return t.splice(i < 0 ? t.length : i, 0, e), t;
|
|
9
|
+
}, y = () => {
|
|
10
|
+
const e = o.items().filter((t) => t.id !== l), r = e.find((t) => {
|
|
11
|
+
const i = o.elements.get(t.id)?.getBoundingClientRect();
|
|
12
|
+
return i && c < i.left + i.width / 2;
|
|
13
|
+
});
|
|
14
|
+
b(r?.id), k(r ? void 0 : e.at(-1)?.id);
|
|
15
|
+
}, R = () => {
|
|
16
|
+
s = 0;
|
|
17
|
+
const e = o.container();
|
|
18
|
+
if (!d() || !e) return;
|
|
19
|
+
const r = e.getBoundingClientRect(), t = c < r.left + 28 ? c - r.left - 28 : c > r.right - 28 ? c - r.right + 28 : 0;
|
|
20
|
+
t && (e.scrollLeft += Math.sign(t) * Math.min(12, Math.abs(t) / 3)), y(), s = requestAnimationFrame(R);
|
|
21
|
+
}, g = (e) => {
|
|
22
|
+
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), a?.stop({ commit: !1 }));
|
|
23
|
+
}, D = (e) => {
|
|
24
|
+
const r = l, t = !!d(), i = r && t ? E(r, h()) : void 0;
|
|
25
|
+
s && cancelAnimationFrame(s), s = 0, f?.defaultView?.removeEventListener("keydown", g, !0), a = void 0, l = void 0, w(void 0), b(void 0), k(void 0), t && (u = !0, m = setTimeout(() => {
|
|
26
|
+
u = !1;
|
|
27
|
+
}, 0)), e && i && i.join("\0") !== o.items().map((n) => n.id).join("\0") && o.onReorder()?.(i);
|
|
28
|
+
}, L = (e, r) => {
|
|
29
|
+
if (!o.onReorder() || r.disabled || e.button !== 0 || a || e.target?.closest('button, a, input, [contenteditable="true"]')) return;
|
|
30
|
+
const t = e.clientX, i = e.clientY;
|
|
31
|
+
l = r.id, c = t, f = e.currentTarget.ownerDocument, f.defaultView?.addEventListener("keydown", g, !0), a = X({
|
|
32
|
+
pointerEvent: e,
|
|
33
|
+
captureEl: e.currentTarget,
|
|
34
|
+
capturePointer: !1,
|
|
35
|
+
onMove: (n) => {
|
|
36
|
+
c = n.clientX, !(!d() && Math.hypot(n.clientX - t, n.clientY - i) < 5) && (d() || (w(r.id), a?.capturePointer()), n.preventDefault(), y(), s || (s = requestAnimationFrame(R)));
|
|
37
|
+
},
|
|
38
|
+
onEnd: (n) => D(n.commit && (n.reason === "pointer_up" || n.reason === "buttons_released"))
|
|
39
|
+
});
|
|
40
|
+
}, T = (e, r) => {
|
|
41
|
+
if (!o.onReorder() || r.disabled || !e.altKey || !e.shiftKey || !["ArrowLeft", "ArrowRight"].includes(e.key)) return !1;
|
|
42
|
+
e.preventDefault(), e.stopPropagation();
|
|
43
|
+
const t = o.items().map((F) => F.id), i = t.indexOf(r.id), n = i + (e.key === "ArrowLeft" ? -1 : 1);
|
|
44
|
+
return n >= 0 && n < t.length && ([t[i], t[n]] = [t[n], t[i]], o.onReorder()?.(t), o.elements.get(r.id)?.focus({ preventScroll: !0 }), o.elements.get(r.id)?.scrollIntoView({ block: "nearest", inline: "nearest" })), !0;
|
|
45
|
+
};
|
|
46
|
+
return M(() => {
|
|
47
|
+
const e = o.items(), r = o.onReorder();
|
|
48
|
+
l && (!r || !e.some((t) => t.id === l && !t.disabled)) && a?.stop({ commit: !1 });
|
|
49
|
+
}), P(() => {
|
|
50
|
+
a?.stop({ commit: !1 }), s && cancelAnimationFrame(s), m !== void 0 && clearTimeout(m), f?.defaultView?.removeEventListener("keydown", g, !0);
|
|
51
|
+
}), { start: L, keyDown: T, dragging: d, before: h, after: A, suppressClick: () => u };
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
C as createTabReorder
|
|
55
|
+
};
|