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