@floegence/floe-webapp-core 0.36.10 → 0.36.11

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.
@@ -1,14 +1,14 @@
1
1
  import { insert as s, createComponent as g, Dynamic as D, effect as W, setAttribute as b, className as S, style as k, template as m } from "solid-js/web";
2
- import { createMemo as l, Show as C } from "solid-js";
3
- import { cn as x } from "../../utils/cn.js";
4
- import { useDeck as z } from "../../context/DeckContext.js";
5
- import { useWidgetRegistry as R } from "../../context/WidgetRegistry.js";
2
+ import { createMemo as l, Show as z } from "solid-js";
3
+ import { cn as C } from "../../utils/cn.js";
4
+ import { useDeck as R } from "../../context/DeckContext.js";
5
+ import { useWidgetRegistry as x } from "../../context/WidgetRegistry.js";
6
6
  import { WidgetStateProvider as M } from "../../context/WidgetStateContext.js";
7
7
  import { positionToGridArea as A } from "../../utils/gridLayout.js";
8
8
  import { WidgetFrame as I } from "./WidgetFrame.js";
9
9
  var P = /* @__PURE__ */ m("<div data-floe-dialog-surface-host=true data-floe-geometry-surface=deck-widget>"), T = /* @__PURE__ */ m('<div class="h-full flex items-center justify-center text-muted-foreground text-xs"><span>Widget: ');
10
10
  function B(e) {
11
- const r = z(), n = R(), f = () => r.editMode(), d = () => e.widget.type, a = l(() => n.getWidget(d())), w = l(() => A(e.position)), h = () => r.getWidgetState(e.widget.id), v = (i, t) => {
11
+ const r = R(), n = x(), f = () => r.editMode(), d = () => e.widget.type, a = l(() => n.getWidget(d())), w = l(() => A(e.position)), h = () => r.getWidgetState(e.widget.id), v = (i, t) => {
12
12
  r.updateWidgetState(e.widget.id, i, t);
13
13
  }, o = () => a()?.component;
14
14
  return (() => {
@@ -27,7 +27,7 @@ function B(e) {
27
27
  return e.isResizing;
28
28
  },
29
29
  get children() {
30
- return g(C, {
30
+ return g(z, {
31
31
  get when() {
32
32
  return o();
33
33
  },
@@ -66,17 +66,7 @@ function B(e) {
66
66
  });
67
67
  }
68
68
  })), W((t) => {
69
- var c = e.widget.id, u = x(
70
- "deck-cell relative rounded-md overflow-hidden group",
71
- "bg-card border border-border",
72
- // Smooth transition when not dragging (for snap-back animation)
73
- !e.isDragging && "transition-transform duration-200 ease-out",
74
- e.isDragging && "shadow-2xl z-50 ring-2 ring-primary/70",
75
- e.isResizing && "shadow-lg z-50 ring-2 ring-primary",
76
- !e.isDragging && !e.isResizing && "hover:ring-1 hover:ring-primary/50",
77
- "select-none",
78
- e.isDragging && "cursor-grabbing"
79
- ), y = e.dragOverlayStyle ?? {
69
+ var c = e.widget.id, u = C("deck-cell relative rounded-md overflow-hidden group", "bg-card border border-border", !e.isDragging && !e.isResizing && "transition-shadow duration-150 ease-out", e.isDragging && "shadow-2xl z-50 ring-2 ring-primary/70", e.isResizing && "shadow-lg z-50 ring-2 ring-primary", !e.isDragging && !e.isResizing && "hover:ring-1 hover:ring-primary/50", "select-none", e.isDragging && "cursor-grabbing"), y = e.dragOverlayStyle ?? {
80
70
  "grid-area": w()
81
71
  };
82
72
  return c !== t.e && b(i, "data-floe-deck-widget-id", t.e = c), u !== t.t && S(i, t.t = u), t.a = k(i, y, t.a), t;
@@ -1,54 +1,54 @@
1
- import { setStyleProperty as u, setAttribute as D, insert as b, createComponent as h, effect as E, className as ot, template as W, use as it, delegateEvents as at } from "solid-js/web";
2
- import { createSignal as G, createMemo as d, onMount as st, Show as L, For as ct, onCleanup as lt } from "solid-js";
1
+ import { setStyleProperty as u, setAttribute as M, insert as y, createComponent as h, effect as T, className as ot, template as N, use as it, delegateEvents as at } from "solid-js/web";
2
+ import { createSignal as I, createMemo as d, onMount as st, Show as F, For as ct, onCleanup as lt } from "solid-js";
3
3
  import { cn as dt } from "../../utils/cn.js";
4
4
  import { useDeck as ut } from "../../context/DeckContext.js";
5
5
  import { useLayout as gt } from "../../context/LayoutContext.js";
6
- import { useResolvedFloeConfig as mt } from "../../context/FloeConfigContext.js";
7
- import { useWidgetRegistry as pt } from "../../context/WidgetRegistry.js";
6
+ import { useResolvedFloeConfig as pt } from "../../context/FloeConfigContext.js";
7
+ import { useWidgetRegistry as mt } from "../../context/WidgetRegistry.js";
8
8
  import { hasCollision as ft } from "../../utils/gridCollision.js";
9
9
  import { DeckCell as vt } from "./DeckCell.js";
10
10
  import { DeckContextMenu as ht } from "./DeckContextMenu.js";
11
11
  import { DropZonePreview as xt } from "./DropZonePreview.js";
12
- import { DECK_DEFAULT_ROWS as g, DECK_MIN_ROW_HEIGHT as F, DECK_GAP as p, DECK_PADDING as O, DECK_GRID_COLS as M, positionToDeckPixelRect as wt, getGridConfigFromElement as bt, measureDeckGridSurface as T } from "./deckGridMetrics.js";
13
- import { DECK_GRID_CONFIG as Tt } from "./deckGridMetrics.js";
14
- var yt = /* @__PURE__ */ W('<div class="pointer-events-none z-0"style="grid-column:1 / -1;background-position:0 0, 0 0, 0 0, 0 0, 0 0, 0 0">'), kt = /* @__PURE__ */ W('<div style=scrollbar-gutter:stable><div class=pointer-events-none aria-hidden=true style="grid-column:1 / -1">');
15
- const Dt = (M - 1) * p;
16
- function Lt($) {
17
- const m = ut(), H = gt(), A = pt(), K = mt();
12
+ import { DECK_DEFAULT_ROWS as g, DECK_MIN_ROW_HEIGHT as W, DECK_GAP as f, DECK_PADDING as A, DECK_GRID_COLS as S, positionToDeckPixelRect as wt, positionDeltaToDeckPixelOffset as yt, getGridConfigFromElement as bt, measureDeckGridSurface as K } from "./deckGridMetrics.js";
13
+ import { DECK_GRID_CONFIG as Wt } from "./deckGridMetrics.js";
14
+ var kt = /* @__PURE__ */ N('<div class="pointer-events-none z-0"style="grid-column:1 / -1;background-position:0 0, 0 0, 0 0, 0 0, 0 0, 0 0">'), Dt = /* @__PURE__ */ N('<div style=scrollbar-gutter:stable><div class=pointer-events-none aria-hidden=true style="grid-column:1 / -1">');
15
+ const Mt = (S - 1) * f;
16
+ function Lt(z) {
17
+ const p = ut(), O = gt(), X = mt(), Y = pt();
18
18
  let n;
19
- const [S, I] = G(0), [N, X] = G(null), [y, C] = G(null), z = () => m.activeLayout()?.widgets ?? [], x = () => m.dragState(), Y = () => m.dragMotion(), R = () => m.resizeState(), B = () => N() ?? (n ? T(n) : null), _ = () => !H.isMobile(), j = () => (K.config.deck.presetsMode ?? "mutable") === "immutable" && !!m.activeLayout()?.isPreset, V = d(() => Array.from(A.widgets().values()).map((t) => ({
19
+ const [C, _] = I(0), [B, j] = I(null), [b, P] = I(null), E = () => p.activeLayout()?.widgets ?? [], x = () => p.dragState(), V = () => p.dragMotion(), R = () => p.resizeState(), U = () => B() ?? (n ? K(n) : null), L = () => !O.isMobile(), Z = () => (Y.config.deck.presetsMode ?? "mutable") === "immutable" && !!p.activeLayout()?.isPreset, q = d(() => Array.from(X.widgets().values()).map((t) => ({
20
20
  type: t.type,
21
21
  name: t.name,
22
22
  icon: t.icon
23
- }))), U = (t) => {
24
- if (H.isMobile() || j() || t.target?.closest(".deck-cell") || !n) return;
23
+ }))), J = (t) => {
24
+ if (O.isMobile() || Z() || t.target?.closest(".deck-cell") || !n) return;
25
25
  t.preventDefault();
26
26
  const o = n.getBoundingClientRect(), {
27
27
  cols: e,
28
28
  rowHeight: i,
29
29
  gap: s
30
- } = bt(n), c = window.getComputedStyle(n), l = parseFloat(c.paddingLeft) || 0, a = parseFloat(c.paddingTop) || 0, f = (n.clientWidth - l - (parseFloat(c.paddingRight) || 0) - s * (e - 1)) / e, v = i + s;
31
- if (!Number.isFinite(f) || f <= 0) return;
32
- const tt = t.clientX - o.left + n.scrollLeft - l, et = t.clientY - o.top + n.scrollTop - a, rt = Math.max(0, Math.min(e - 1, Math.floor(tt / (f + s)))), nt = Math.max(0, Math.floor(et / v));
33
- C({
30
+ } = bt(n), c = window.getComputedStyle(n), l = parseFloat(c.paddingLeft) || 0, a = parseFloat(c.paddingTop) || 0, m = (n.clientWidth - l - (parseFloat(c.paddingRight) || 0) - s * (e - 1)) / e, v = i + s;
31
+ if (!Number.isFinite(m) || m <= 0) return;
32
+ const D = t.clientX - o.left + n.scrollLeft - l, $ = t.clientY - o.top + n.scrollTop - a, H = Math.max(0, Math.min(e - 1, Math.floor(D / (m + s)))), nt = Math.max(0, Math.floor($ / v));
33
+ P({
34
34
  x: t.clientX,
35
35
  y: t.clientY,
36
- col: rt,
36
+ col: H,
37
37
  row: nt
38
38
  });
39
- }, Z = (t) => {
40
- const r = y();
41
- C(null), r && m.addWidget(t, {
39
+ }, Q = (t) => {
40
+ const r = b();
41
+ P(null), r && p.addWidget(t, {
42
42
  col: r.col,
43
43
  row: r.row
44
44
  });
45
- }, q = d(() => {
45
+ }, tt = d(() => {
46
46
  const t = x();
47
47
  if (!t) return !0;
48
- const r = m.activeLayout();
48
+ const r = p.activeLayout();
49
49
  return r ? !ft(t.currentPosition, r.widgets, t.widgetId) : !0;
50
- }), J = d(() => {
51
- const t = z();
50
+ }), et = d(() => {
51
+ const t = E();
52
52
  if (t.length === 0) return g;
53
53
  let r = g;
54
54
  for (const o of t) {
@@ -56,8 +56,8 @@ function Lt($) {
56
56
  e > r && (r = e);
57
57
  }
58
58
  return r;
59
- }), P = d(() => {
60
- let t = J();
59
+ }), G = d(() => {
60
+ let t = et();
61
61
  const r = x();
62
62
  if (r) {
63
63
  const e = r.currentPosition.row + r.currentPosition.rowSpan;
@@ -70,36 +70,36 @@ function Lt($) {
70
70
  }
71
71
  return Math.max(g, t);
72
72
  }), k = d(() => {
73
- const t = S();
74
- if (t <= 0) return F;
75
- const o = (t - O * 2 - (g - 1) * p) / g;
76
- return Math.max(F, o);
73
+ const t = C();
74
+ if (t <= 0) return W;
75
+ const o = (t - A * 2 - (g - 1) * f) / g;
76
+ return Math.max(W, o);
77
77
  });
78
78
  st(() => {
79
79
  const t = () => {
80
- n && (I(n.clientHeight), X(T(n)));
80
+ n && (_(n.clientHeight), j(K(n)));
81
81
  };
82
82
  if (t(), !n || typeof ResizeObserver > "u") return;
83
83
  const r = new ResizeObserver((o) => {
84
84
  for (const e of o)
85
- I(e.contentRect.height);
85
+ _(e.contentRect.height);
86
86
  t();
87
87
  });
88
88
  r.observe(n), lt(() => r.disconnect());
89
89
  });
90
- const Q = d(() => P() > g ? !0 : S() <= 0 ? !1 : g * k() + (g - 1) * p + O * 2 > S() + 1);
90
+ const rt = d(() => G() > g ? !0 : C() <= 0 ? !1 : g * k() + (g - 1) * f + A * 2 > C() + 1);
91
91
  return (() => {
92
- var t = kt(), r = t.firstChild;
93
- t.$$contextmenu = U;
92
+ var t = Dt(), r = t.firstChild;
93
+ t.$$contextmenu = J;
94
94
  var o = n;
95
- return typeof o == "function" ? it(o, t) : n = t, u(t, "grid-template-columns", `repeat(${M}, 1fr)`), u(t, "gap", `${p}px`), D(t, "data-grid-cols", M), D(t, "data-gap", p), D(t, "data-default-rows", g), b(t, h(L, {
95
+ return typeof o == "function" ? it(o, t) : n = t, u(t, "grid-template-columns", `repeat(${S}, 1fr)`), u(t, "gap", `${f}px`), M(t, "data-grid-cols", S), M(t, "data-gap", f), M(t, "data-default-rows", g), y(t, h(F, {
96
96
  get when() {
97
- return _();
97
+ return L();
98
98
  },
99
99
  get children() {
100
- var e = yt();
101
- return u(e, "--deck-grid-unit-x", `calc((100% - ${Dt}px) / ${M} + ${p}px)`), E((i) => {
102
- var s = `1 / ${P() + 1}`, c = `${k() + p}px`, l = [
100
+ var e = kt();
101
+ return u(e, "--deck-grid-unit-x", `calc((100% - ${Mt}px) / ${S} + ${f}px)`), T((i) => {
102
+ var s = `1 / ${G() + 1}`, c = `${k() + f}px`, l = [
103
103
  // Fine
104
104
  "linear-gradient(to right, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
105
105
  "linear-gradient(to bottom, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
@@ -128,7 +128,7 @@ function Lt($) {
128
128
  o: void 0
129
129
  }), e;
130
130
  }
131
- }), null), b(t, h(L, {
131
+ }), null), y(t, h(F, {
132
132
  get when() {
133
133
  return x();
134
134
  },
@@ -137,12 +137,12 @@ function Lt($) {
137
137
  return e().currentPosition;
138
138
  },
139
139
  get isValid() {
140
- return q();
140
+ return tt();
141
141
  }
142
142
  })
143
- }), null), b(t, h(ct, {
143
+ }), null), y(t, h(ct, {
144
144
  get each() {
145
- return z();
145
+ return E();
146
146
  },
147
147
  children: (e) => {
148
148
  const i = d(() => {
@@ -151,18 +151,18 @@ function Lt($) {
151
151
  }), s = d(() => x()?.widgetId === e.id), c = d(() => R()?.widgetId === e.id), l = d(() => {
152
152
  const a = x();
153
153
  if (!a || a.widgetId !== e.id) return;
154
- const w = Y();
154
+ const w = V();
155
155
  if (!w || w.widgetId !== e.id) return;
156
- const f = B();
157
- if (!f) return;
158
- const v = wt(a.originalPosition, f);
156
+ const m = U();
157
+ if (!m) return;
158
+ const v = wt(a.currentPosition, m), D = yt(a.originalPosition, a.currentPosition, m), $ = w.deltaX - D.x, H = w.deltaY - D.y;
159
159
  return {
160
160
  position: "absolute",
161
161
  left: `${v.left}px`,
162
162
  top: `${v.top}px`,
163
163
  width: `${v.width}px`,
164
164
  height: `${v.height}px`,
165
- transform: `translate3d(${w.deltaX}px, ${w.deltaY}px, 0) scale(0.992)`,
165
+ transform: `translate3d(${$}px, ${H}px, 0) scale(0.992)`,
166
166
  "transform-origin": "center center",
167
167
  "will-change": "transform"
168
168
  };
@@ -183,31 +183,31 @@ function Lt($) {
183
183
  }
184
184
  });
185
185
  }
186
- }), null), b(t, () => $.children, null), b(t, h(ht, {
186
+ }), null), y(t, () => z.children, null), y(t, h(ht, {
187
187
  get open() {
188
- return y() !== null;
188
+ return b() !== null;
189
189
  },
190
190
  get x() {
191
- return y()?.x ?? 0;
191
+ return b()?.x ?? 0;
192
192
  },
193
193
  get y() {
194
- return y()?.y ?? 0;
194
+ return b()?.y ?? 0;
195
195
  },
196
196
  get items() {
197
- return V();
197
+ return q();
198
198
  },
199
- onSelect: Z,
200
- onDismiss: () => C(null)
201
- }), null), E((e) => {
199
+ onSelect: Q,
200
+ onDismiss: () => P(null)
201
+ }), null), T((e) => {
202
202
  var i = dt(
203
203
  "deck-grid relative w-full h-full overflow-x-hidden",
204
204
  // Only enable vertical scroll when content exceeds 24 rows
205
- Q() ? "overflow-y-scroll" : "overflow-y-hidden",
205
+ rt() ? "overflow-y-scroll" : "overflow-y-hidden",
206
206
  "grid p-1",
207
- _() && "bg-muted/20",
208
- $.class
209
- ), s = `${k()}px`, c = k(), l = `1 / ${P() + 1}`;
210
- return i !== e.e && ot(t, e.e = i), s !== e.t && u(t, "grid-auto-rows", e.t = s), c !== e.a && D(t, "data-row-height", e.a = c), l !== e.o && u(r, "grid-row", e.o = l), e;
207
+ L() && "bg-muted/20",
208
+ z.class
209
+ ), s = `${k()}px`, c = k(), l = `1 / ${G() + 1}`;
210
+ return i !== e.e && ot(t, e.e = i), s !== e.t && u(t, "grid-auto-rows", e.t = s), c !== e.a && M(t, "data-row-height", e.a = c), l !== e.o && u(r, "grid-row", e.o = l), e;
211
211
  }, {
212
212
  e: void 0,
213
213
  t: void 0,
@@ -218,7 +218,7 @@ function Lt($) {
218
218
  }
219
219
  at(["contextmenu"]);
220
220
  export {
221
- Tt as DECK_GRID_CONFIG,
221
+ Wt as DECK_GRID_CONFIG,
222
222
  Lt as DeckGrid,
223
223
  bt as getGridConfigFromElement
224
224
  };
@@ -2,10 +2,10 @@ import { effect as m, className as h, setAttribute as p, template as b, use as v
2
2
  import { createSignal as R, onCleanup as S } from "solid-js";
3
3
  import { cn as D } from "../../utils/cn.js";
4
4
  import { useDeck as y } from "../../context/DeckContext.js";
5
- import { applyResizeDelta as k } from "../../utils/gridLayout.js";
6
- import { startDeckPointerSession as C } from "./deckPointerSession.js";
7
- var M = /* @__PURE__ */ b("<div style=touch-action:none>");
8
- const P = {
5
+ import { applyResizeDelta as P } from "../../utils/gridLayout.js";
6
+ import { startDeckPointerSession as k } from "./deckPointerSession.js";
7
+ var C = /* @__PURE__ */ b("<div style=touch-action:none>");
8
+ const M = {
9
9
  n: "top-0 left-2 right-2 h-2 cursor-ns-resize",
10
10
  s: "bottom-0 left-2 right-2 h-2 cursor-ns-resize",
11
11
  e: "right-0 top-2 bottom-2 w-2 cursor-ew-resize",
@@ -24,45 +24,45 @@ const P = {
24
24
  se: "nwse-resize",
25
25
  sw: "nesw-resize"
26
26
  };
27
- function G(t) {
27
+ function W(t) {
28
28
  const s = y(), [u, d] = R(!1);
29
- let c, o = null;
29
+ let l, n = null;
30
30
  const a = (e) => {
31
- o?.stop({
31
+ n?.stop({
32
32
  commit: e
33
- }), o = null;
33
+ }), n = null;
34
34
  }, g = (e) => {
35
35
  if (e.pointerType === "mouse" && e.button !== 0) return;
36
36
  e.preventDefault(), e.stopPropagation();
37
- const n = e.currentTarget?.closest(".deck-grid");
38
- if (!n) return;
37
+ const o = e.currentTarget?.closest(".deck-grid");
38
+ if (!o) return;
39
39
  a(!1), s.startResize(t.widget.id, t.edge, e.clientX, e.clientY);
40
40
  const r = s.resizeState();
41
- !r || r.widgetId !== t.widget.id || r.edge !== t.edge || (d(!0), o = C({
41
+ !r || r.widgetId !== t.widget.id || r.edge !== t.edge || (d(!0), n = k({
42
42
  kind: "resize",
43
43
  widgetId: t.widget.id,
44
- gridEl: n,
45
- captureEl: c,
44
+ gridEl: o,
45
+ captureEl: l,
46
46
  pointerEvent: e,
47
47
  cursor: A[t.edge],
48
48
  onMove: (i) => {
49
- const l = Math.round(i.deltaX / i.cellWidth), z = Math.round(i.deltaY / i.cellHeight), w = s.getWidgetMinConstraints(t.widget.type), f = k(t.widget.position, t.edge, l, z, w.minColSpan, w.minRowSpan, i.cols);
49
+ const c = Math.round(i.deltaX / i.colPitch), z = Math.round(i.deltaY / i.rowPitch), w = s.getWidgetMinConstraints(t.widget.type), f = P(t.widget.position, t.edge, c, z, w.minColSpan, w.minRowSpan, i.cols);
50
50
  s.updateResize(f);
51
51
  },
52
52
  onEnd: ({
53
53
  commit: i
54
54
  }) => {
55
- o = null, d(!1), s.endResize(i);
55
+ n = null, d(!1), s.endResize(i);
56
56
  }
57
57
  }));
58
58
  };
59
59
  return S(() => a(!1)), (() => {
60
- var e = M();
60
+ var e = C();
61
61
  e.$$pointerdown = g;
62
- var n = c;
63
- return typeof n == "function" ? v(n, e) : c = e, m((r) => {
64
- var i = D("absolute z-30", P[t.edge], "hover:bg-primary/30 transition-colors", u() && "bg-primary/50"), l = t.edge;
65
- return i !== r.e && h(e, r.e = i), l !== r.t && p(e, "data-widget-resize-handle", r.t = l), r;
62
+ var o = l;
63
+ return typeof o == "function" ? v(o, e) : l = e, m((r) => {
64
+ var i = D("absolute z-30", M[t.edge], "hover:bg-primary/30 transition-colors", u() && "bg-primary/50"), c = t.edge;
65
+ return i !== r.e && h(e, r.e = i), c !== r.t && p(e, "data-widget-resize-handle", r.t = c), r;
66
66
  }, {
67
67
  e: void 0,
68
68
  t: void 0
@@ -71,5 +71,5 @@ function G(t) {
71
71
  }
72
72
  E(["pointerdown"]);
73
73
  export {
74
- G as WidgetResizeHandle
74
+ W as WidgetResizeHandle
75
75
  };
@@ -26,6 +26,10 @@ export interface DeckGridPixelRect {
26
26
  width: number;
27
27
  height: number;
28
28
  }
29
+ export interface DeckGridPixelOffset {
30
+ x: number;
31
+ y: number;
32
+ }
29
33
  export declare const DECK_GRID_CONFIG: {
30
34
  readonly cols: 24;
31
35
  readonly defaultRows: 24;
@@ -38,4 +42,7 @@ export declare function measureDeckGrid(gridEl: HTMLElement, options?: {
38
42
  paddingRight?: number;
39
43
  }): DeckGridMeasurements | null;
40
44
  export declare function measureDeckGridSurface(gridEl: HTMLElement): DeckGridSurfaceMeasurements | null;
45
+ export declare function getDeckGridColPitch(measurements: Pick<DeckGridMeasurements, 'cellWidth' | 'gap'>): number;
46
+ export declare function getDeckGridRowPitch(measurements: Pick<DeckGridMeasurements, 'cellHeight'>): number;
41
47
  export declare function positionToDeckPixelRect(position: GridPosition, measurements: DeckGridSurfaceMeasurements): DeckGridPixelRect;
48
+ export declare function positionDeltaToDeckPixelOffset(from: GridPosition, to: GridPosition, measurements: DeckGridSurfaceMeasurements): DeckGridPixelOffset;
@@ -1,10 +1,10 @@
1
- const l = 24, r = 24, D = 4, _ = 20, h = 4, s = {
1
+ const D = 24, _ = 24, h = 4, s = 20, f = 4, C = {
2
2
  cols: 24,
3
3
  defaultRows: 24,
4
4
  gap: 4,
5
5
  rowHeight: 20
6
6
  };
7
- function g(t) {
7
+ function r(t) {
8
8
  return {
9
9
  cols: parseInt(t.dataset.gridCols || String(24), 10),
10
10
  rowHeight: parseFloat(t.dataset.rowHeight || String(20)),
@@ -12,41 +12,56 @@ function g(t) {
12
12
  defaultRows: parseInt(t.dataset.defaultRows || String(24), 10)
13
13
  };
14
14
  }
15
- function p(t, n) {
16
- const o = g(t), a = n?.paddingLeft ?? 0, d = n?.paddingRight ?? 0, c = t.clientWidth - a - d, e = o.gap * (o.cols - 1), i = (c - e) / o.cols;
17
- return !Number.isFinite(i) || i <= 0 ? null : {
15
+ function l(t, n) {
16
+ const o = r(t), e = n?.paddingLeft ?? 0, c = n?.paddingRight ?? 0, i = t.clientWidth - e - c, a = o.gap * (o.cols - 1), d = (i - a) / o.cols;
17
+ return !Number.isFinite(d) || d <= 0 ? null : {
18
18
  ...o,
19
- cellWidth: i,
19
+ cellWidth: d,
20
20
  cellHeight: o.rowHeight + o.gap
21
21
  };
22
22
  }
23
- function C(t) {
24
- const n = t.ownerDocument.defaultView?.getComputedStyle(t) ?? getComputedStyle(t), o = parseFloat(n.paddingLeft) || 0, a = parseFloat(n.paddingRight) || 0, d = parseFloat(n.paddingTop) || 0, c = parseFloat(n.paddingBottom) || 0, e = p(t, { paddingLeft: o, paddingRight: a });
25
- return e ? {
26
- ...e,
23
+ function u(t) {
24
+ const n = t.ownerDocument.defaultView?.getComputedStyle(t) ?? getComputedStyle(t), o = parseFloat(n.paddingLeft) || 0, e = parseFloat(n.paddingRight) || 0, c = parseFloat(n.paddingTop) || 0, i = parseFloat(n.paddingBottom) || 0, a = l(t, { paddingLeft: o, paddingRight: e });
25
+ return a ? {
26
+ ...a,
27
27
  paddingLeft: o,
28
- paddingRight: a,
29
- paddingTop: d,
30
- paddingBottom: c
28
+ paddingRight: e,
29
+ paddingTop: c,
30
+ paddingBottom: i
31
31
  } : null;
32
32
  }
33
- function f(t, n) {
33
+ function g(t) {
34
+ return t.cellWidth + t.gap;
35
+ }
36
+ function p(t) {
37
+ return t.cellHeight;
38
+ }
39
+ function R(t, n) {
34
40
  return {
35
- left: n.paddingLeft + t.col * (n.cellWidth + n.gap),
36
- top: n.paddingTop + t.row * (n.rowHeight + n.gap),
41
+ left: n.paddingLeft + t.col * g(n),
42
+ top: n.paddingTop + t.row * p(n),
37
43
  width: t.colSpan * n.cellWidth + Math.max(0, t.colSpan - 1) * n.gap,
38
44
  height: t.rowSpan * n.rowHeight + Math.max(0, t.rowSpan - 1) * n.gap
39
45
  };
40
46
  }
47
+ function G(t, n, o) {
48
+ return {
49
+ x: (n.col - t.col) * g(o),
50
+ y: (n.row - t.row) * p(o)
51
+ };
52
+ }
41
53
  export {
42
- r as DECK_DEFAULT_ROWS,
43
- D as DECK_GAP,
44
- l as DECK_GRID_COLS,
45
- s as DECK_GRID_CONFIG,
46
- _ as DECK_MIN_ROW_HEIGHT,
47
- h as DECK_PADDING,
48
- g as getGridConfigFromElement,
49
- p as measureDeckGrid,
50
- C as measureDeckGridSurface,
51
- f as positionToDeckPixelRect
54
+ _ as DECK_DEFAULT_ROWS,
55
+ h as DECK_GAP,
56
+ D as DECK_GRID_COLS,
57
+ C as DECK_GRID_CONFIG,
58
+ s as DECK_MIN_ROW_HEIGHT,
59
+ f as DECK_PADDING,
60
+ g as getDeckGridColPitch,
61
+ p as getDeckGridRowPitch,
62
+ r as getGridConfigFromElement,
63
+ l as measureDeckGrid,
64
+ u as measureDeckGridSurface,
65
+ G as positionDeltaToDeckPixelOffset,
66
+ R as positionToDeckPixelRect
52
67
  };
@@ -27,6 +27,8 @@ export interface DeckPointerSessionFrame {
27
27
  gap: number;
28
28
  cellWidth: number;
29
29
  cellHeight: number;
30
+ colPitch: number;
31
+ rowPitch: number;
30
32
  }
31
33
  export interface StartDeckPointerSessionOptions {
32
34
  kind: HotInteractionKind;
@@ -1,5 +1,5 @@
1
- import { startHotInteraction as X } from "../../utils/hotInteraction.js";
2
- import { measureDeckGrid as h } from "./deckGridMetrics.js";
1
+ import { startHotInteraction as Y } from "../../utils/hotInteraction.js";
2
+ import { measureDeckGrid as P } from "./deckGridMetrics.js";
3
3
  function C(e) {
4
4
  const d = e.lastClientY - e.gridRect.top, t = e.gridRect.bottom - e.lastClientY;
5
5
  let n = 0;
@@ -12,23 +12,25 @@ function v(e) {
12
12
  if (e.lastClientX === e.lastAppliedClientX && e.lastClientY === e.lastAppliedClientY && i === e.lastAppliedScrollTop)
13
13
  return null;
14
14
  e.lastAppliedClientX = e.lastClientX, e.lastAppliedClientY = e.lastClientY, e.lastAppliedScrollTop = i;
15
- const l = h(e.gridEl, {
15
+ const r = P(e.gridEl, {
16
16
  paddingLeft: e.gridPaddingLeft,
17
17
  paddingRight: e.gridPaddingRight
18
18
  });
19
- return l ? {
19
+ return r ? {
20
20
  snapshot: e,
21
21
  deltaX: e.lastClientX - e.startClientX,
22
22
  deltaY: e.lastClientY - e.startClientY + (i - e.startScrollTop),
23
- cols: l.cols,
24
- rowHeight: l.rowHeight,
25
- gap: l.gap,
26
- cellWidth: l.cellWidth,
27
- cellHeight: l.cellHeight
23
+ cols: r.cols,
24
+ rowHeight: r.rowHeight,
25
+ gap: r.gap,
26
+ cellWidth: r.cellWidth,
27
+ cellHeight: r.cellHeight,
28
+ colPitch: r.cellWidth + r.gap,
29
+ rowPitch: r.cellHeight
28
30
  } : null;
29
31
  }
30
32
  function L(e) {
31
- const i = e.gridEl.ownerDocument, l = i.defaultView ?? window, d = l.getComputedStyle(e.gridEl), t = {
33
+ const i = e.gridEl.ownerDocument, r = i.defaultView ?? window, d = r.getComputedStyle(e.gridEl), t = {
32
34
  pointerId: e.pointerEvent.pointerId,
33
35
  kind: e.kind,
34
36
  widgetId: e.widgetId,
@@ -45,7 +47,7 @@ function L(e) {
45
47
  lastAppliedClientY: e.pointerEvent.clientY,
46
48
  lastAppliedScrollTop: e.gridEl.scrollTop,
47
49
  rafId: null,
48
- stopHotInteraction: X({
50
+ stopHotInteraction: Y({
49
51
  kind: e.kind,
50
52
  cursor: e.cursor,
51
53
  lockUserSelect: !0
@@ -54,15 +56,15 @@ function L(e) {
54
56
  let n = !0;
55
57
  const a = () => {
56
58
  if (t.rafId = null, !n) return;
57
- const r = C(t), c = v(t);
58
- c && e.onMove(c), n && r && o();
59
+ const l = C(t), c = v(t);
60
+ c && e.onMove(c), n && l && o();
59
61
  }, o = () => {
60
62
  if (!(!n || t.rafId !== null)) {
61
- if (typeof l.requestAnimationFrame != "function") {
63
+ if (typeof r.requestAnimationFrame != "function") {
62
64
  a();
63
65
  return;
64
66
  }
65
- t.rafId = l.requestAnimationFrame(a);
67
+ t.rafId = r.requestAnimationFrame(a);
66
68
  }
67
69
  }, I = () => {
68
70
  if (!(!e.captureEl || typeof e.captureEl.releasePointerCapture != "function"))
@@ -70,30 +72,35 @@ function L(e) {
70
72
  e.captureEl.releasePointerCapture(t.pointerId);
71
73
  } catch {
72
74
  }
73
- }, Y = () => {
75
+ }, h = () => {
74
76
  i.removeEventListener("pointermove", g, !0), i.removeEventListener("pointerup", p, !0), i.removeEventListener("pointercancel", m, !0), e.captureEl?.removeEventListener("lostpointercapture", s);
75
- }, u = (r) => {
77
+ }, u = (l) => {
76
78
  if (!n) return;
77
- const c = r?.event;
79
+ const c = l?.event;
78
80
  if (!(c && c.pointerId !== t.pointerId)) {
79
- if (c && (t.lastClientX = c.clientX, t.lastClientY = c.clientY), n = !1, t.rafId !== null && typeof l.cancelAnimationFrame == "function" && (l.cancelAnimationFrame(t.rafId), t.rafId = null), r?.commit !== !1) {
81
+ if (c && (t.lastClientX = c.clientX, t.lastClientY = c.clientY), n = !1, t.rafId !== null && typeof r.cancelAnimationFrame == "function" && (r.cancelAnimationFrame(t.rafId), t.rafId = null), l?.commit !== !1) {
80
82
  C(t);
81
83
  const E = v(t);
82
84
  E && e.onMove(E);
83
85
  }
84
- Y(), I(), t.stopHotInteraction?.(), t.stopHotInteraction = null, e.onEnd({
85
- commit: r?.commit !== !1,
86
- snapshot: t
87
- });
86
+ h(), I();
87
+ try {
88
+ e.onEnd({
89
+ commit: l?.commit !== !1,
90
+ snapshot: t
91
+ });
92
+ } finally {
93
+ t.stopHotInteraction?.(), t.stopHotInteraction = null;
94
+ }
88
95
  }
89
- }, f = (r) => {
90
- !n || r.pointerId !== t.pointerId || (t.lastClientX = r.clientX, t.lastClientY = r.clientY, o());
91
- }, g = (r) => {
92
- f(r);
93
- }, p = (r) => {
94
- u({ event: r });
95
- }, m = (r) => {
96
- u({ event: r, commit: !1 });
96
+ }, f = (l) => {
97
+ !n || l.pointerId !== t.pointerId || (t.lastClientX = l.clientX, t.lastClientY = l.clientY, o());
98
+ }, g = (l) => {
99
+ f(l);
100
+ }, p = (l) => {
101
+ u({ event: l });
102
+ }, m = (l) => {
103
+ u({ event: l, commit: !1 });
97
104
  }, s = () => {
98
105
  u();
99
106
  };
@@ -1,7 +1,7 @@
1
1
  import { createEffect as m, onCleanup as E } from "solid-js";
2
2
  import { useDeck as h } from "../context/DeckContext.js";
3
- import { applyDragDelta as k } from "../utils/gridLayout.js";
4
- import { startDeckPointerSession as y } from "../components/deck/deckPointerSession.js";
3
+ import { applyDragDelta as P } from "../utils/gridLayout.js";
4
+ import { startDeckPointerSession as k } from "../components/deck/deckPointerSession.js";
5
5
  function L() {
6
6
  const o = h();
7
7
  let i = null, l = null, r = null;
@@ -20,7 +20,7 @@ function L() {
20
20
  if (!g) return;
21
21
  e.preventDefault(), e.stopPropagation(), s(!1), o.startDrag(n, e.clientX, e.clientY);
22
22
  const p = o.dragState();
23
- !p || p.widgetId !== n || (l = n, r = { ...g.position }, i = y({
23
+ !p || p.widgetId !== n || (l = n, r = { ...g.position }, i = k({
24
24
  kind: "drag",
25
25
  widgetId: n,
26
26
  gridEl: c,
@@ -29,7 +29,7 @@ function L() {
29
29
  cursor: "grabbing",
30
30
  onMove: (t) => {
31
31
  if (!l || !r) return;
32
- const f = Math.round(t.deltaX / t.cellWidth), D = Math.round(t.deltaY / t.cellHeight), w = k(r, f, D, t.cols);
32
+ const f = Math.round(t.deltaX / t.colPitch), D = Math.round(t.deltaY / t.rowPitch), w = P(r, f, D, t.cols);
33
33
  o.updateDrag(w, {
34
34
  deltaX: t.deltaX,
35
35
  deltaY: t.deltaY
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.10",
3
+ "version": "0.36.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",