@floegence/floe-webapp-core 0.90.1 → 0.90.2
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 +37 -37
- package/dist/components/ui/Tabs.js +159 -162
- package/dist/components/ui/tabReorder.d.ts +1 -3
- package/dist/components/ui/tabReorder.js +83 -45
- package/dist/styles.css +1 -1
- package/dist/surface.css +36 -2
- package/package.json +1 -1
|
@@ -1,55 +1,93 @@
|
|
|
1
|
-
import { createSignal as
|
|
2
|
-
import { startPointerSession as
|
|
3
|
-
function
|
|
4
|
-
const [
|
|
5
|
-
let
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { createSignal as K, createEffect as Y, onCleanup as q } from "solid-js";
|
|
2
|
+
import { startPointerSession as I } from "./pointerSession.js";
|
|
3
|
+
function $(i) {
|
|
4
|
+
const [m, D] = K();
|
|
5
|
+
let c, g, s = [], R = [], f = 0, k = 0, T = 0, u = 1, l = 0, x = !1, p, h;
|
|
6
|
+
const w = /* @__PURE__ */ new Map(), A = (e) => {
|
|
7
|
+
delete e.dataset.floeTabMotion, e.style.removeProperty("--floe-tab-offset");
|
|
8
|
+
}, C = () => {
|
|
9
|
+
for (const [e, t] of w)
|
|
10
|
+
t.cancel(), A(e);
|
|
11
|
+
w.clear();
|
|
12
|
+
}, F = () => {
|
|
13
|
+
const e = i.container();
|
|
14
|
+
if (!e) return;
|
|
15
|
+
const t = e.getBoundingClientRect();
|
|
16
|
+
u = e.offsetWidth > 0 && t.width > 0 ? t.width / e.offsetWidth : 1, T = e.scrollLeft, s = i.items().flatMap((n) => {
|
|
17
|
+
const r = i.elements.get(n.id);
|
|
18
|
+
if (!r) return [];
|
|
19
|
+
const o = r.getBoundingClientRect();
|
|
20
|
+
return [{ id: n.id, element: r, left: (o.left - t.left) / u + T, width: o.width / u }];
|
|
13
21
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
const t = e.
|
|
31
|
-
|
|
22
|
+
}, E = () => {
|
|
23
|
+
const e = i.container(), t = s.find((a) => a.id === g);
|
|
24
|
+
if (!e || !t) return;
|
|
25
|
+
const n = s[0], r = s.at(-1), o = Math.max(n.left, Math.min(
|
|
26
|
+
r.left + r.width - t.width,
|
|
27
|
+
t.left + (f - k) / u + e.scrollLeft - T
|
|
28
|
+
)), b = o + t.width / 2, y = s.filter((a) => a !== t), M = y.findIndex((a) => b < a.left + a.width / 2), d = [...y];
|
|
29
|
+
d.splice(M < 0 ? y.length : M, 0, t), R = d.map((a) => a.id);
|
|
30
|
+
const S = s.length > 1 ? s[1].left - n.left - n.width : 0;
|
|
31
|
+
let B = n.left;
|
|
32
|
+
for (const a of d)
|
|
33
|
+
a.element.dataset.floeTabMotion = a === t ? "dragging" : "neighbor", a.element.style.setProperty("--floe-tab-offset", `${(a === t ? o : B) - a.left}px`), B += a.width + S;
|
|
34
|
+
}, P = () => {
|
|
35
|
+
l = 0;
|
|
36
|
+
const e = i.container();
|
|
37
|
+
if (!m() || !e) return;
|
|
38
|
+
const t = e.getBoundingClientRect(), n = f < t.left + 28 ? f - t.left - 28 : f > t.right - 28 ? f - t.right + 28 : 0;
|
|
39
|
+
n && (e.scrollLeft += Math.sign(n) * Math.min(12, Math.abs(n) / 3) / u), E(), l = requestAnimationFrame(P);
|
|
40
|
+
}, L = (e) => {
|
|
41
|
+
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), c?.stop({ commit: !1 }));
|
|
42
|
+
}, V = (e) => {
|
|
43
|
+
const t = !!m();
|
|
44
|
+
l && cancelAnimationFrame(l), l = 0, t && E();
|
|
45
|
+
const n = s.map((r) => ({ element: r.element, rect: r.element.getBoundingClientRect() }));
|
|
46
|
+
h?.defaultView?.removeEventListener("keydown", L, !0), c = void 0, g = void 0, D(void 0), e && t && R.join("\0") !== i.items().map((r) => r.id).join("\0") && i.onReorder()?.(R);
|
|
47
|
+
for (const { element: r } of n) A(r);
|
|
48
|
+
if (t && (x = !0, p !== void 0 && clearTimeout(p), p = setTimeout(() => {
|
|
49
|
+
x = !1;
|
|
50
|
+
}, 0), !h?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches))
|
|
51
|
+
for (const { element: o, rect: b } of n) {
|
|
52
|
+
if (!o.isConnected || typeof o.animate != "function") continue;
|
|
53
|
+
const y = o.getBoundingClientRect(), M = (b.left - y.left) / u;
|
|
54
|
+
if (Math.abs(M) < 0.5) continue;
|
|
55
|
+
o.dataset.floeTabMotion = "settling";
|
|
56
|
+
const d = o.animate([
|
|
57
|
+
{ transform: `translate3d(${M}px, 0, 0)` },
|
|
58
|
+
{ transform: "translate3d(0, 0, 0)" }
|
|
59
|
+
], { duration: 180, easing: "cubic-bezier(0.22, 1, 0.36, 1)" });
|
|
60
|
+
w.set(o, d), d.onfinish = () => {
|
|
61
|
+
w.get(o) === d && (w.delete(o), A(o));
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
s = [], R = [];
|
|
65
|
+
}, X = (e, t) => {
|
|
66
|
+
if (!i.onReorder() || t.disabled || e.button !== 0 || c || e.target?.closest('button, a, input, [contenteditable="true"]')) return;
|
|
67
|
+
C(), k = e.clientX;
|
|
68
|
+
const n = e.clientY;
|
|
69
|
+
g = t.id, f = k, h = e.currentTarget.ownerDocument, h.defaultView?.addEventListener("keydown", L, !0), c = I({
|
|
32
70
|
pointerEvent: e,
|
|
33
71
|
captureEl: e.currentTarget,
|
|
34
72
|
capturePointer: !1,
|
|
35
|
-
onMove: (
|
|
36
|
-
|
|
73
|
+
onMove: (r) => {
|
|
74
|
+
f = r.clientX, !(!m() && Math.hypot(r.clientX - k, r.clientY - n) < 5) && (m() || (F(), D(t.id), c?.capturePointer()), r.preventDefault(), E(), l || (l = requestAnimationFrame(P)));
|
|
37
75
|
},
|
|
38
|
-
onEnd: (
|
|
76
|
+
onEnd: (r) => V(r.commit && (r.reason === "pointer_up" || r.reason === "buttons_released"))
|
|
39
77
|
});
|
|
40
|
-
},
|
|
41
|
-
if (!
|
|
42
|
-
e.preventDefault(), e.stopPropagation();
|
|
43
|
-
const
|
|
44
|
-
return
|
|
78
|
+
}, j = (e, t) => {
|
|
79
|
+
if (!i.onReorder() || t.disabled || !e.altKey || !e.shiftKey || !["ArrowLeft", "ArrowRight"].includes(e.key)) return !1;
|
|
80
|
+
e.preventDefault(), e.stopPropagation(), C();
|
|
81
|
+
const n = i.items().map((b) => b.id), r = n.indexOf(t.id), o = r + (e.key === "ArrowLeft" ? -1 : 1);
|
|
82
|
+
return o >= 0 && o < n.length && ([n[r], n[o]] = [n[o], n[r]], i.onReorder()?.(n), i.elements.get(t.id)?.focus({ preventScroll: !0 }), i.elements.get(t.id)?.scrollIntoView({ block: "nearest", inline: "nearest" })), !0;
|
|
45
83
|
};
|
|
46
|
-
return
|
|
47
|
-
const e =
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
}), { start:
|
|
84
|
+
return Y(() => {
|
|
85
|
+
const e = i.items(), t = i.onReorder();
|
|
86
|
+
g && (!t || !e.some((n) => n.id === g && !n.disabled) || s.length && e.map((n) => n.id).join("\0") !== s.map((n) => n.id).join("\0")) && c?.stop({ commit: !1 });
|
|
87
|
+
}), q(() => {
|
|
88
|
+
c?.stop({ commit: !1 }), C(), l && cancelAnimationFrame(l), p !== void 0 && clearTimeout(p), h?.defaultView?.removeEventListener("keydown", L, !0);
|
|
89
|
+
}), { start: X, keyDown: j, dragging: m, suppressClick: () => x };
|
|
52
90
|
}
|
|
53
91
|
export {
|
|
54
|
-
|
|
92
|
+
$ as createTabReorder
|
|
55
93
|
};
|