@floegence/floe-webapp-core 0.101.33 → 0.101.34

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.
@@ -51,8 +51,8 @@ function de(t) {
51
51
  get isActive() {
52
52
  return f() === n;
53
53
  },
54
- onClick: () => {
55
- d.consumeClick() || C(o());
54
+ onClick: (a) => {
55
+ d.consumeClick(a) || C(o());
56
56
  },
57
57
  elementRef: (a) => {
58
58
  a ? c.set(n, a) : c.delete(n);
@@ -128,7 +128,7 @@ function q(t) {
128
128
  portalScope: "viewport",
129
129
  get children() {
130
130
  var r = p(), C = r.firstChild;
131
- r.$$keydown = x, r.$$contextmenu = B, r.$$click = () => t.onClick(), r.addEventListener("dragstart", (e) => e.preventDefault()), r.$$pointerdown = (e) => t.onPointerDown?.(e);
131
+ r.$$keydown = x, r.$$contextmenu = B, r.$$click = (e) => t.onClick(e), r.addEventListener("dragstart", (e) => e.preventDefault()), r.$$pointerdown = (e) => t.onPointerDown?.(e);
132
132
  var i = v;
133
133
  return typeof i == "function" ? L(i, r) : v = r, g(r, u(T, {
134
134
  get component() {
@@ -20,7 +20,7 @@ export declare function createBarReorder(options: {
20
20
  order: string[];
21
21
  }> | undefined>;
22
22
  keyDown(key: string, event: KeyboardEvent): void;
23
- consumeClick(): boolean;
23
+ consumeClick(event: MouseEvent): boolean;
24
24
  begin(key: string, event: PointerEvent): void;
25
25
  };
26
26
  /** Keyed layout motion survives pin/unpin, reorder and interrupted previews. */
@@ -1,127 +1,124 @@
1
- import { createSignal as D, createEffect as R, onCleanup as v } from "solid-js";
2
- import { startPointerSession as T } from "../ui/pointerSession.js";
3
- function A(n, m, i, y, h) {
4
- const t = n.filter((p) => p !== m && i.has(p));
5
- if (!n.includes(m) || !t.length) return;
6
- let a = t.findIndex((p) => {
7
- const x = i.get(p), e = x.getBoundingClientRect(), o = getComputedStyle(x).transform, r = typeof DOMMatrix == "function" ? new DOMMatrix(o === "none" ? void 0 : o) : void 0;
8
- return h < (y === "x" ? e.left - (r?.m41 ?? 0) + e.width / 2 : e.top - (r?.m42 ?? 0) + e.height / 2);
1
+ import { createSignal as D, createEffect as k, onCleanup as R } from "solid-js";
2
+ import { startPointerSession as E } from "../ui/pointerSession.js";
3
+ function A(n, m, o, h, g) {
4
+ const e = n.filter((M) => M !== m && o.has(M));
5
+ if (!n.includes(m) || !e.length) return;
6
+ let f = e.findIndex((M) => {
7
+ const w = o.get(M), t = w.getBoundingClientRect(), r = getComputedStyle(w).transform, i = typeof DOMMatrix == "function" ? new DOMMatrix(r === "none" ? void 0 : r) : void 0;
8
+ return g < (h === "x" ? t.left - (i?.m41 ?? 0) + t.width / 2 : t.top - (i?.m42 ?? 0) + t.height / 2);
9
9
  });
10
- a < 0 && (a = t.length);
11
- const u = [...t];
12
- return u.splice(a, 0, m), { key: t[Math.min(a, t.length - 1)], edge: a === t.length ? "after" : "before", order: u };
10
+ f < 0 && (f = e.length);
11
+ const u = [...e];
12
+ return u.splice(f, 0, m), { key: e[Math.min(f, e.length - 1)], edge: f === e.length ? "after" : "before", order: u };
13
13
  }
14
- function B(n, m, i, y) {
15
- if (!i.altKey || !i.shiftKey || i.ctrlKey || i.metaKey || i.isComposing) return;
16
- const h = i.key === (y === "x" ? "ArrowLeft" : "ArrowUp") ? -1 : i.key === (y === "x" ? "ArrowRight" : "ArrowDown") ? 1 : 0, t = n.indexOf(m);
17
- if (!h || t < 0) return;
18
- i.preventDefault(), i.stopPropagation();
19
- const a = Math.max(0, Math.min(n.length - 1, t + h));
20
- if (t === a) return;
14
+ function B(n, m, o, h) {
15
+ if (!o.altKey || !o.shiftKey || o.ctrlKey || o.metaKey || o.isComposing) return;
16
+ const g = o.key === (h === "x" ? "ArrowLeft" : "ArrowUp") ? -1 : o.key === (h === "x" ? "ArrowRight" : "ArrowDown") ? 1 : 0, e = n.indexOf(m);
17
+ if (!g || e < 0) return;
18
+ o.preventDefault(), o.stopPropagation();
19
+ const f = Math.max(0, Math.min(n.length - 1, e + g));
20
+ if (e === f) return;
21
21
  const u = [...n];
22
- return u.splice(t, 1), u.splice(a, 0, m), u;
22
+ return u.splice(e, 1), u.splice(f, 0, m), u;
23
23
  }
24
24
  function Y(n) {
25
- const [m, i] = D(), [y, h] = D();
26
- let t, a = !1, u = 0, p;
27
- const x = (o) => {
28
- o.key !== "Escape" || !t || (o.preventDefault(), o.stopPropagation(), t.stop({ commit: !1 }));
25
+ const [m, o] = D(), [h, g] = D();
26
+ let e, f = !1, u = 0;
27
+ const M = (t) => {
28
+ t.key !== "Escape" || !e || (t.preventDefault(), t.stopPropagation(), e.stop({ commit: !1 }));
29
29
  };
30
- R(() => {
31
- n.keys(), n.onReorder(), t?.stop({ commit: !1 });
32
- }), v(() => {
33
- t?.stop({ commit: !1 }), p && clearTimeout(p);
34
- });
35
- const e = (o, r) => {
36
- n.onReorder()?.(r), n.elements.get(o)?.focus({ preventScroll: !0 });
30
+ k(() => {
31
+ n.keys(), n.onReorder(), e?.stop({ commit: !1 });
32
+ }), R(() => e?.stop({ commit: !1 }));
33
+ const w = (t, r) => {
34
+ n.onReorder()?.(r), n.elements.get(t)?.focus({ preventScroll: !0 });
37
35
  };
38
36
  return {
39
37
  dragging: m,
40
- position: y,
41
- keyDown(o, r) {
38
+ position: h,
39
+ keyDown(t, r) {
42
40
  if (!n.onReorder()) return;
43
- const l = B(n.keys(), o, r, "y");
44
- l && e(o, l);
41
+ const i = B(n.keys(), t, r, "y");
42
+ i && w(t, i);
45
43
  },
46
- consumeClick() {
47
- return a ? (a = !1, !0) : !1;
44
+ consumeClick(t) {
45
+ const r = f && t.detail !== 0;
46
+ return f = !1, r;
48
47
  },
49
- begin(o, r) {
50
- if (r.button !== 0 || !n.onReorder() || !n.keys().includes(o)) return;
51
- t?.stop({ commit: !1 });
52
- const l = r.currentTarget, M = r.clientY, w = r.clientX;
53
- let d = w, c = M, b = !1;
54
- const k = (f, s) => {
55
- if (d = f, c = s, b ||= Math.hypot(f - w, s - M) >= 5, !b) return;
56
- i(o);
57
- const g = n.container()?.getBoundingClientRect();
58
- h(g && f >= g.left - 24 && f <= g.right + 24 && s >= g.top && s <= g.bottom ? A(n.keys(), o, n.elements, "y", s) : void 0);
48
+ begin(t, r) {
49
+ if (r.button !== 0 || (f = !1, !n.onReorder() || !n.keys().includes(t))) return;
50
+ e?.stop({ commit: !1 });
51
+ const i = r.currentTarget, d = r.clientY, x = r.clientX;
52
+ let y = x, c = d, a = !1;
53
+ const b = (s, l) => {
54
+ if (y = s, c = l, a ||= Math.hypot(s - x, l - d) >= 5, !a) return;
55
+ o(t);
56
+ const p = n.container()?.getBoundingClientRect();
57
+ g(p && s >= p.left - 24 && s <= p.right + 24 && l >= p.top && l <= p.bottom ? A(n.keys(), t, n.elements, "y", l) : void 0);
59
58
  }, C = () => {
60
- const f = n.container();
61
- if (b && f) {
62
- const s = f.getBoundingClientRect(), g = c < s.top + 28 ? c - s.top - 28 : c > s.bottom - 28 ? c - s.bottom + 28 : 0;
63
- if (d >= s.left - 24 && d <= s.right + 24 && c >= s.top - 24 && c <= s.bottom + 24 && g) {
64
- const E = f.scrollTop;
65
- f.scrollTop += Math.sign(g) * Math.min(10, Math.abs(g) / 3), f.scrollTop !== E && k(d, c);
59
+ const s = n.container();
60
+ if (a && s) {
61
+ const l = s.getBoundingClientRect(), p = c < l.top + 28 ? c - l.top - 28 : c > l.bottom - 28 ? c - l.bottom + 28 : 0;
62
+ if (y >= l.left - 24 && y <= l.right + 24 && c >= l.top - 24 && c <= l.bottom + 24 && p) {
63
+ const v = s.scrollTop;
64
+ s.scrollTop += Math.sign(p) * Math.min(10, Math.abs(p) / 3), s.scrollTop !== v && b(y, c);
66
65
  }
67
66
  }
68
67
  u = requestAnimationFrame(C);
69
68
  };
70
- u = requestAnimationFrame(C), l.ownerDocument.addEventListener("keydown", x, !0), t = T({
69
+ u = requestAnimationFrame(C), i.ownerDocument.addEventListener("keydown", M, !0), e = E({
71
70
  pointerEvent: r,
72
- captureEl: l,
73
- onMove: (f) => k(f.clientX, f.clientY),
74
- onEnd: ({ commit: f, snapshot: s }) => {
75
- k(s.latestClientX, s.latestClientY);
76
- const g = y();
77
- cancelAnimationFrame(u), t = void 0, l.ownerDocument.removeEventListener("keydown", x, !0), i(void 0), h(void 0), b && (a = !0, p && clearTimeout(p), p = setTimeout(() => {
78
- a = !1;
79
- }, 0)), f && b && g && e(o, g.order);
71
+ captureEl: i,
72
+ onMove: (s) => b(s.clientX, s.clientY),
73
+ onEnd: ({ commit: s, snapshot: l }) => {
74
+ b(l.latestClientX, l.latestClientY);
75
+ const p = h();
76
+ cancelAnimationFrame(u), e = void 0, i.ownerDocument.removeEventListener("keydown", M, !0), o(void 0), g(void 0), f = a || !s, s && a && p && w(t, p.order);
80
77
  }
81
78
  });
82
79
  }
83
80
  };
84
81
  }
85
82
  function $(n) {
86
- const m = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
87
- let y = !1, h = 0;
88
- R(() => {
89
- const t = [...n.keys()], a = n.preview(), u = ++h;
83
+ const m = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
84
+ let h = !1, g = 0;
85
+ k(() => {
86
+ const e = [...n.keys()], f = n.preview(), u = ++g;
90
87
  queueMicrotask(() => {
91
- if (h !== u) return;
92
- const p = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, x = new Map(t.flatMap((e) => {
93
- const o = n.elements.get(e);
94
- if (!o) return [];
95
- const r = o.getBoundingClientRect(), l = getComputedStyle(o).transform, M = typeof DOMMatrix == "function" ? new DOMMatrix(l === "none" ? void 0 : l) : void 0;
96
- let w = 0, d = 0;
97
- for (let c = o.parentElement; c; c = c.parentElement)
98
- w += c.scrollLeft, d += c.scrollTop;
99
- return [[e, { left: r.left + w - (M?.m41 ?? 0), top: r.top + d - (M?.m42 ?? 0), dx: M?.m41 ?? 0, dy: M?.m42 ?? 0 }]];
88
+ if (g !== u) return;
89
+ const M = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, w = new Map(e.flatMap((t) => {
90
+ const r = n.elements.get(t);
91
+ if (!r) return [];
92
+ const i = r.getBoundingClientRect(), d = getComputedStyle(r).transform, x = typeof DOMMatrix == "function" ? new DOMMatrix(d === "none" ? void 0 : d) : void 0;
93
+ let y = 0, c = 0;
94
+ for (let a = r.parentElement; a; a = a.parentElement)
95
+ y += a.scrollLeft, c += a.scrollTop;
96
+ return [[t, { left: i.left + y - (x?.m41 ?? 0), top: i.top + c - (x?.m42 ?? 0), dx: x?.m41 ?? 0, dy: x?.m42 ?? 0 }]];
100
97
  }));
101
- for (const e of t) {
102
- const o = n.elements.get(e), r = x.get(e);
103
- if (!o || !r) continue;
104
- const l = m.get(e), M = a ? t[a.indexOf(e)] : e, w = x.get(M) ?? r, d = n.axis === "x" ? w.left - r.left : 0, c = n.axis === "y" ? w.top - r.top : 0;
105
- if (i.get(e)?.cancel(), i.delete(e), o.style.transform = d || c ? `translate3d(${d}px, ${c}px, 0)` : "", !p && y && typeof o.animate == "function") {
106
- const b = l ? l.left - r.left + r.dx : d, k = l ? l.top - r.top + r.dy : c;
107
- if (!l || Math.abs(b - d) + Math.abs(k - c) > 0.5) {
108
- const C = o.animate([
109
- { transform: `translate3d(${b}px, ${k}px, 0)`, opacity: l ? 1 : 0 },
110
- { transform: `translate3d(${d}px, ${c}px, 0)`, opacity: 1 }
98
+ for (const t of e) {
99
+ const r = n.elements.get(t), i = w.get(t);
100
+ if (!r || !i) continue;
101
+ const d = m.get(t), x = f ? e[f.indexOf(t)] : t, y = w.get(x) ?? i, c = n.axis === "x" ? y.left - i.left : 0, a = n.axis === "y" ? y.top - i.top : 0;
102
+ if (o.get(t)?.cancel(), o.delete(t), r.style.transform = c || a ? `translate3d(${c}px, ${a}px, 0)` : "", !M && h && typeof r.animate == "function") {
103
+ const b = d ? d.left - i.left + i.dx : c, C = d ? d.top - i.top + i.dy : a;
104
+ if (!d || Math.abs(b - c) + Math.abs(C - a) > 0.5) {
105
+ const s = r.animate([
106
+ { transform: `translate3d(${b}px, ${C}px, 0)`, ...d ? {} : { opacity: 0 } },
107
+ { transform: `translate3d(${c}px, ${a}px, 0)`, ...d ? {} : { opacity: 1 } }
111
108
  ], { duration: 180, easing: "cubic-bezier(0.33, 1, 0.68, 1)" });
112
- i.set(e, C), C.onfinish = () => {
113
- i.get(e) === C && i.delete(e);
109
+ o.set(t, s), s.onfinish = () => {
110
+ o.get(t) === s && o.delete(t);
114
111
  };
115
112
  }
116
113
  }
117
- m.set(e, { left: r.left, top: r.top });
114
+ m.set(t, { left: i.left, top: i.top });
118
115
  }
119
- for (const e of m.keys()) t.includes(e) || (m.delete(e), i.get(e)?.cancel(), i.delete(e));
120
- y = !0;
116
+ for (const t of m.keys()) e.includes(t) || (m.delete(t), o.get(t)?.cancel(), o.delete(t));
117
+ h = !0;
121
118
  });
122
- }), v(() => {
123
- h += 1;
124
- for (const t of i.values()) t.cancel();
119
+ }), R(() => {
120
+ g += 1;
121
+ for (const e of o.values()) e.cancel();
125
122
  });
126
123
  }
127
124
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.101.33",
3
+ "version": "0.101.34",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",