@floegence/floe-webapp-core 0.36.8 → 0.36.9

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.
@@ -5,11 +5,6 @@ export interface DeckCellProps {
5
5
  position: GridPosition;
6
6
  isDragging?: boolean;
7
7
  isResizing?: boolean;
8
- /** Pixel offset for smooth drag following */
9
- pixelOffset?: {
10
- x: number;
11
- y: number;
12
- };
13
8
  }
14
9
  /**
15
10
  * Widget cell wrapper positioned via CSS grid-area
@@ -1,33 +1,24 @@
1
- import { insert as u, createComponent as n, Dynamic as D, effect as x, className as W, style as S, template as l } from "solid-js/web";
2
- import { createMemo as d, Show as b } from "solid-js";
3
- import { cn as C } from "../../utils/cn.js";
1
+ import { insert as m, createComponent as n, Dynamic as D, effect as W, setAttribute as b, className as S, setStyleProperty as C, template as f } from "solid-js/web";
2
+ import { createMemo as l, Show as k } from "solid-js";
3
+ import { cn as x } from "../../utils/cn.js";
4
4
  import { useDeck as z } from "../../context/DeckContext.js";
5
5
  import { useWidgetRegistry as R } from "../../context/WidgetRegistry.js";
6
- import { WidgetStateProvider as k } from "../../context/WidgetStateContext.js";
7
- import { positionToGridArea as $ } from "../../utils/gridLayout.js";
8
- import { WidgetFrame as M } from "./WidgetFrame.js";
9
- var _ = /* @__PURE__ */ l("<div data-floe-dialog-surface-host=true>"), A = /* @__PURE__ */ l('<div class="h-full flex items-center justify-center text-muted-foreground text-xs"><span>Widget: ');
10
- function q(e) {
11
- const i = z(), g = R(), f = () => i.editMode(), o = () => e.widget.type, a = d(() => g.getWidget(o())), m = d(() => $(e.position)), w = () => i.getWidgetState(e.widget.id), h = (t, r) => {
12
- i.updateWidgetState(e.widget.id, t, r);
13
- }, s = () => a()?.component, v = d(() => {
14
- if (!e.isDragging || !e.pixelOffset) return {};
15
- const {
16
- x: t,
17
- y: r
18
- } = e.pixelOffset;
19
- return t === 0 && r === 0 ? {} : {
20
- transform: `translate(${t}px, ${r}px)`
21
- };
22
- });
6
+ import { WidgetStateProvider as M } from "../../context/WidgetStateContext.js";
7
+ import { positionToGridArea as A } from "../../utils/gridLayout.js";
8
+ import { WidgetFrame as P } from "./WidgetFrame.js";
9
+ var I = /* @__PURE__ */ f("<div data-floe-dialog-surface-host=true>"), T = /* @__PURE__ */ f('<div class="h-full flex items-center justify-center text-muted-foreground text-xs"><span>Widget: ');
10
+ function H(e) {
11
+ const r = z(), g = R(), w = () => r.editMode(), d = () => e.widget.type, o = l(() => g.getWidget(d())), h = l(() => A(e.position)), v = () => r.getWidgetState(e.widget.id), y = (i, t) => {
12
+ r.updateWidgetState(e.widget.id, i, t);
13
+ }, a = () => o()?.component;
23
14
  return (() => {
24
- var t = _();
25
- return u(t, n(M, {
15
+ var i = I();
16
+ return m(i, n(P, {
26
17
  get widget() {
27
18
  return e.widget;
28
19
  },
29
20
  get widgetDef() {
30
- return a();
21
+ return o();
31
22
  },
32
23
  get isDragging() {
33
24
  return e.isDragging;
@@ -36,28 +27,28 @@ function q(e) {
36
27
  return e.isResizing;
37
28
  },
38
29
  get children() {
39
- return n(b, {
30
+ return n(k, {
40
31
  get when() {
41
- return s();
32
+ return a();
42
33
  },
43
34
  get fallback() {
44
- return n(I, {
35
+ return n(_, {
45
36
  get type() {
46
- return o();
37
+ return d();
47
38
  }
48
39
  });
49
40
  },
50
41
  get children() {
51
- return n(k, {
42
+ return n(M, {
52
43
  get widgetId() {
53
44
  return e.widget.id;
54
45
  },
55
- state: w,
56
- onStateChange: h,
46
+ state: v,
47
+ onStateChange: y,
57
48
  get children() {
58
49
  return n(D, {
59
50
  get component() {
60
- return s();
51
+ return a();
61
52
  },
62
53
  get widgetId() {
63
54
  return e.widget.id;
@@ -66,7 +57,7 @@ function q(e) {
66
57
  return e.widget.config;
67
58
  },
68
59
  get isEditMode() {
69
- return f();
60
+ return w();
70
61
  }
71
62
  });
72
63
  }
@@ -74,8 +65,8 @@ function q(e) {
74
65
  }
75
66
  });
76
67
  }
77
- })), x((r) => {
78
- var c = C(
68
+ })), W((t) => {
69
+ var c = e.widget.id, s = x(
79
70
  "deck-cell relative rounded-md overflow-hidden group",
80
71
  "bg-card border border-border",
81
72
  // Smooth transition when not dragging (for snap-back animation)
@@ -85,23 +76,21 @@ function q(e) {
85
76
  !e.isDragging && !e.isResizing && "hover:ring-1 hover:ring-primary/50",
86
77
  "select-none",
87
78
  e.isDragging && "cursor-grabbing"
88
- ), y = {
89
- "grid-area": m(),
90
- ...v()
91
- };
92
- return c !== r.e && W(t, r.e = c), r.t = S(t, y, r.t), r;
79
+ ), u = h();
80
+ return c !== t.e && b(i, "data-floe-deck-widget-id", t.e = c), s !== t.t && S(i, t.t = s), u !== t.a && C(i, "grid-area", t.a = u), t;
93
81
  }, {
94
82
  e: void 0,
95
- t: void 0
96
- }), t;
83
+ t: void 0,
84
+ a: void 0
85
+ }), i;
97
86
  })();
98
87
  }
99
- function I(e) {
88
+ function _(e) {
100
89
  return (() => {
101
- var i = A(), g = i.firstChild;
102
- return g.firstChild, u(g, () => e.type, null), i;
90
+ var r = T(), g = r.firstChild;
91
+ return g.firstChild, m(g, () => e.type, null), r;
103
92
  })();
104
93
  }
105
94
  export {
106
- q as DeckCell
95
+ H as DeckCell
107
96
  };
@@ -1,4 +1,5 @@
1
1
  import { type JSX } from 'solid-js';
2
+ import { DECK_GRID_CONFIG, getGridConfigFromElement } from './deckGridMetrics';
2
3
  export interface DeckGridProps {
3
4
  class?: string;
4
5
  children?: JSX.Element;
@@ -12,19 +13,4 @@ export interface DeckGridProps {
12
13
  * 3. Row height is calculated dynamically based on container height
13
14
  */
14
15
  export declare function DeckGrid(props: DeckGridProps): JSX.Element;
15
- export declare const DECK_GRID_CONFIG: {
16
- cols: number;
17
- defaultRows: number;
18
- gap: number;
19
- rowHeight: number;
20
- };
21
- /**
22
- * Get grid configuration from the DOM element
23
- * Use this for accurate row height during drag/resize operations
24
- */
25
- export declare function getGridConfigFromElement(gridEl: HTMLElement): {
26
- cols: number;
27
- rowHeight: number;
28
- gap: number;
29
- defaultRows: number;
30
- };
16
+ export { DECK_GRID_CONFIG, getGridConfigFromElement };
@@ -1,55 +1,54 @@
1
- import { insert as h, createComponent as m, effect as F, setStyleProperty as v, className as J, setAttribute as Q, template as W, use as tt, delegateEvents as et } from "solid-js/web";
2
- import { createSignal as O, createMemo as d, onMount as rt, Show as G, For as nt, onCleanup as ot } from "solid-js";
3
- import { cn as it } from "../../utils/cn.js";
4
- import { useDeck as at } from "../../context/DeckContext.js";
5
- import { useLayout as st } from "../../context/LayoutContext.js";
6
- import { useResolvedFloeConfig as ct } from "../../context/FloeConfigContext.js";
7
- import { useWidgetRegistry as lt } from "../../context/WidgetRegistry.js";
8
- import { hasCollision as dt } from "../../utils/gridCollision.js";
9
- import { DeckCell as ut } from "./DeckCell.js";
10
- import { DeckContextMenu as gt } from "./DeckContextMenu.js";
11
- import { DropZonePreview as pt } from "./DropZonePreview.js";
12
- var ft = /* @__PURE__ */ W('<div class="pointer-events-none z-0"style="grid-column:1 / -1;--deck-grid-unit-x:calc((100% - 92px) / 24 + 4px);background-position:0 0, 0 0, 0 0, 0 0, 0 0, 0 0">'), mt = /* @__PURE__ */ W('<div data-grid-cols=24 data-gap=4 data-default-rows=24 style="scrollbar-gutter:stable;grid-template-columns:repeat(24, 1fr);gap:4px"><div class=pointer-events-none aria-hidden=true style="grid-column:1 / -1">');
13
- const T = 24, u = 24, x = 4, k = 20, L = 4, vt = {
14
- x: 0,
15
- y: 0
16
- };
17
- function Dt(g) {
18
- const p = at(), I = st(), A = lt(), N = ct();
1
+ import { setStyleProperty as l, setAttribute as b, insert as h, createComponent as f, effect as G, className as J, template as W, use as Q, delegateEvents as tt } from "solid-js/web";
2
+ import { createSignal as _, createMemo as d, onMount as et, Show as E, For as rt, onCleanup as nt } from "solid-js";
3
+ import { cn as ot } from "../../utils/cn.js";
4
+ import { useDeck as it } from "../../context/DeckContext.js";
5
+ import { useLayout as at } from "../../context/LayoutContext.js";
6
+ import { useResolvedFloeConfig as st } from "../../context/FloeConfigContext.js";
7
+ import { useWidgetRegistry as ct } from "../../context/WidgetRegistry.js";
8
+ import { hasCollision as lt } from "../../utils/gridCollision.js";
9
+ import { DeckCell as dt } from "./DeckCell.js";
10
+ import { DeckContextMenu as ut } from "./DeckContextMenu.js";
11
+ import { DropZonePreview as gt } from "./DropZonePreview.js";
12
+ import { DECK_DEFAULT_ROWS as u, DECK_MIN_ROW_HEIGHT as L, DECK_GAP as m, DECK_PADDING as F, DECK_GRID_COLS as y, getGridConfigFromElement as mt } from "./deckGridMetrics.js";
13
+ import { DECK_GRID_CONFIG as _t } from "./deckGridMetrics.js";
14
+ var pt = /* @__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">'), ft = /* @__PURE__ */ W('<div style=scrollbar-gutter:stable><div class=pointer-events-none aria-hidden=true style="grid-column:1 / -1">');
15
+ const vt = (y - 1) * m;
16
+ function It(R) {
17
+ const p = it(), P = at(), $ = ct(), T = st();
19
18
  let a;
20
- const [S, D] = O(0), [w, R] = O(null), P = () => p.activeLayout()?.widgets ?? [], f = () => p.dragState(), M = () => p.resizeState(), z = () => !I.isMobile(), _ = () => (N.config.deck.presetsMode ?? "mutable") === "immutable" && !!p.activeLayout()?.isPreset, E = d(() => Array.from(A.widgets().values()).map((t) => ({
19
+ const [k, H] = _(0), [x, D] = _(null), I = () => p.activeLayout()?.widgets ?? [], v = () => p.dragState(), C = () => p.resizeState(), z = () => !P.isMobile(), A = () => (T.config.deck.presetsMode ?? "mutable") === "immutable" && !!p.activeLayout()?.isPreset, O = d(() => Array.from($.widgets().values()).map((t) => ({
21
20
  type: t.type,
22
21
  name: t.name,
23
22
  icon: t.icon
24
- }))), $ = (t) => {
25
- if (I.isMobile() || _() || t.target?.closest(".deck-cell") || !a) return;
23
+ }))), K = (t) => {
24
+ if (P.isMobile() || A() || t.target?.closest(".deck-cell") || !a) return;
26
25
  t.preventDefault();
27
26
  const n = a.getBoundingClientRect(), {
28
27
  cols: e,
29
28
  rowHeight: o,
30
29
  gap: s
31
- } = ht(a), c = window.getComputedStyle(a), l = parseFloat(c.paddingLeft) || 0, i = parseFloat(c.paddingTop) || 0, H = (a.clientWidth - l - (parseFloat(c.paddingRight) || 0) - s * (e - 1)) / e, V = o + s;
32
- if (!Number.isFinite(H) || H <= 0) return;
33
- const Z = t.clientX - n.left + a.scrollLeft - l, K = t.clientY - n.top + a.scrollTop - i, U = Math.max(0, Math.min(e - 1, Math.floor(Z / (H + s)))), q = Math.max(0, Math.floor(K / V));
34
- R({
30
+ } = mt(a), c = window.getComputedStyle(a), i = parseFloat(c.paddingLeft) || 0, g = parseFloat(c.paddingTop) || 0, M = (a.clientWidth - i - (parseFloat(c.paddingRight) || 0) - s * (e - 1)) / e, j = o + s;
31
+ if (!Number.isFinite(M) || M <= 0) return;
32
+ const V = t.clientX - n.left + a.scrollLeft - i, U = t.clientY - n.top + a.scrollTop - g, Z = Math.max(0, Math.min(e - 1, Math.floor(V / (M + s)))), q = Math.max(0, Math.floor(U / j));
33
+ D({
35
34
  x: t.clientX,
36
35
  y: t.clientY,
37
- col: U,
36
+ col: Z,
38
37
  row: q
39
38
  });
40
- }, B = (t) => {
41
- const r = w();
42
- R(null), r && p.addWidget(t, {
39
+ }, N = (t) => {
40
+ const r = x();
41
+ D(null), r && p.addWidget(t, {
43
42
  col: r.col,
44
43
  row: r.row
45
44
  });
46
- }, X = d(() => {
47
- const t = f();
45
+ }, B = d(() => {
46
+ const t = v();
48
47
  if (!t) return !0;
49
48
  const r = p.activeLayout();
50
- return r ? !dt(t.currentPosition, r.widgets, t.widgetId) : !0;
51
- }), Y = d(() => {
52
- const t = P();
49
+ return r ? !lt(t.currentPosition, r.widgets, t.widgetId) : !0;
50
+ }), X = d(() => {
51
+ const t = I();
53
52
  if (t.length === 0) return u;
54
53
  let r = u;
55
54
  for (const n of t) {
@@ -57,46 +56,46 @@ function Dt(g) {
57
56
  e > r && (r = e);
58
57
  }
59
58
  return r;
60
- }), C = d(() => {
61
- let t = Y();
62
- const r = f();
59
+ }), S = d(() => {
60
+ let t = X();
61
+ const r = v();
63
62
  if (r) {
64
63
  const e = r.currentPosition.row + r.currentPosition.rowSpan;
65
64
  e > t && (t = e);
66
65
  }
67
- const n = M();
66
+ const n = C();
68
67
  if (n) {
69
68
  const e = n.currentPosition.row + n.currentPosition.rowSpan;
70
69
  e > t && (t = e);
71
70
  }
72
71
  return Math.max(u, t);
73
- }), b = d(() => {
74
- const t = S();
75
- if (t <= 0) return k;
76
- const n = (t - L * 2 - (u - 1) * x) / u;
77
- return Math.max(k, n);
72
+ }), w = d(() => {
73
+ const t = k();
74
+ if (t <= 0) return L;
75
+ const n = (t - F * 2 - (u - 1) * m) / u;
76
+ return Math.max(L, n);
78
77
  });
79
- rt(() => {
78
+ et(() => {
80
79
  if (!a || typeof ResizeObserver > "u") return;
81
80
  const t = new ResizeObserver((r) => {
82
81
  for (const n of r)
83
- D(n.contentRect.height);
82
+ H(n.contentRect.height);
84
83
  });
85
- t.observe(a), D(a.clientHeight), ot(() => t.disconnect());
84
+ t.observe(a), H(a.clientHeight), nt(() => t.disconnect());
86
85
  });
87
- const j = d(() => C() > u ? !0 : S() <= 0 ? !1 : u * b() + (u - 1) * x + L * 2 > S() + 1);
86
+ const Y = d(() => S() > u ? !0 : k() <= 0 ? !1 : u * w() + (u - 1) * m + F * 2 > k() + 1);
88
87
  return (() => {
89
- var t = mt(), r = t.firstChild;
90
- t.$$contextmenu = $;
88
+ var t = ft(), r = t.firstChild;
89
+ t.$$contextmenu = K;
91
90
  var n = a;
92
- return typeof n == "function" ? tt(n, t) : a = t, h(t, m(G, {
91
+ return typeof n == "function" ? Q(n, t) : a = t, l(t, "grid-template-columns", `repeat(${y}, 1fr)`), l(t, "gap", `${m}px`), b(t, "data-grid-cols", y), b(t, "data-gap", m), b(t, "data-default-rows", u), h(t, f(E, {
93
92
  get when() {
94
93
  return z();
95
94
  },
96
95
  get children() {
97
- var e = ft();
98
- return F((o) => {
99
- var s = `1 / ${C() + 1}`, c = `${b() + x}px`, l = [
96
+ var e = pt();
97
+ return l(e, "--deck-grid-unit-x", `calc((100% - ${vt}px) / ${y} + ${m}px)`), G((o) => {
98
+ var s = `1 / ${S() + 1}`, c = `${w() + m}px`, i = [
100
99
  // Fine
101
100
  "linear-gradient(to right, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
102
101
  "linear-gradient(to bottom, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
@@ -106,7 +105,7 @@ function Dt(g) {
106
105
  // Major (12)
107
106
  "linear-gradient(to right, color-mix(in srgb, var(--border) 75%, transparent) 2px, transparent 2px)",
108
107
  "linear-gradient(to bottom, color-mix(in srgb, var(--border) 75%, transparent) 2px, transparent 2px)"
109
- ].join(", "), i = [
108
+ ].join(", "), g = [
110
109
  // Fine
111
110
  "var(--deck-grid-unit-x) var(--deck-grid-unit-y)",
112
111
  "var(--deck-grid-unit-x) var(--deck-grid-unit-y)",
@@ -117,7 +116,7 @@ function Dt(g) {
117
116
  "calc(var(--deck-grid-unit-x) * 12) calc(var(--deck-grid-unit-y) * 12)",
118
117
  "calc(var(--deck-grid-unit-x) * 12) calc(var(--deck-grid-unit-y) * 12)"
119
118
  ].join(", ");
120
- return s !== o.e && v(e, "grid-row", o.e = s), c !== o.t && v(e, "--deck-grid-unit-y", o.t = c), l !== o.a && v(e, "background-image", o.a = l), i !== o.o && v(e, "background-size", o.o = i), o;
119
+ return s !== o.e && l(e, "grid-row", o.e = s), c !== o.t && l(e, "--deck-grid-unit-y", o.t = c), i !== o.a && l(e, "background-image", o.a = i), g !== o.o && l(e, "background-size", o.o = g), o;
121
120
  }, {
122
121
  e: void 0,
123
122
  t: void 0,
@@ -125,34 +124,31 @@ function Dt(g) {
125
124
  o: void 0
126
125
  }), e;
127
126
  }
128
- }), null), h(t, m(G, {
127
+ }), null), h(t, f(E, {
129
128
  get when() {
130
- return f();
129
+ return v();
131
130
  },
132
- children: (e) => m(pt, {
131
+ children: (e) => f(gt, {
133
132
  get position() {
134
133
  return e().currentPosition;
135
134
  },
136
135
  get isValid() {
137
- return X();
136
+ return B();
138
137
  }
139
138
  })
140
- }), null), h(t, m(nt, {
139
+ }), null), h(t, f(rt, {
141
140
  get each() {
142
- return P();
141
+ return I();
143
142
  },
144
143
  children: (e) => {
145
144
  const o = d(() => {
146
- const i = f();
145
+ const i = v();
147
146
  if (i && i.widgetId === e.id)
148
- return e.position;
149
- const y = M();
150
- return y && y.widgetId === e.id ? y.currentPosition : e.position;
151
- }), s = d(() => f()?.widgetId === e.id), c = d(() => M()?.widgetId === e.id), l = d(() => {
152
- const i = f();
153
- return i && i.widgetId === e.id ? i.pixelOffset : vt;
154
- });
155
- return m(ut, {
147
+ return i.currentPosition;
148
+ const g = C();
149
+ return g && g.widgetId === e.id ? g.currentPosition : e.position;
150
+ }), s = d(() => v()?.widgetId === e.id), c = d(() => C()?.widgetId === e.id);
151
+ return f(dt, {
156
152
  widget: e,
157
153
  get position() {
158
154
  return o();
@@ -162,37 +158,34 @@ function Dt(g) {
162
158
  },
163
159
  get isResizing() {
164
160
  return c();
165
- },
166
- get pixelOffset() {
167
- return l();
168
161
  }
169
162
  });
170
163
  }
171
- }), null), h(t, () => g.children, null), h(t, m(gt, {
164
+ }), null), h(t, () => R.children, null), h(t, f(ut, {
172
165
  get open() {
173
- return w() !== null;
166
+ return x() !== null;
174
167
  },
175
168
  get x() {
176
- return w()?.x ?? 0;
169
+ return x()?.x ?? 0;
177
170
  },
178
171
  get y() {
179
- return w()?.y ?? 0;
172
+ return x()?.y ?? 0;
180
173
  },
181
174
  get items() {
182
- return E();
175
+ return O();
183
176
  },
184
- onSelect: B,
185
- onDismiss: () => R(null)
186
- }), null), F((e) => {
187
- var o = it(
177
+ onSelect: N,
178
+ onDismiss: () => D(null)
179
+ }), null), G((e) => {
180
+ var o = ot(
188
181
  "deck-grid relative w-full h-full overflow-x-hidden",
189
182
  // Only enable vertical scroll when content exceeds 24 rows
190
- j() ? "overflow-y-scroll" : "overflow-y-hidden",
183
+ Y() ? "overflow-y-scroll" : "overflow-y-hidden",
191
184
  "grid p-1",
192
185
  z() && "bg-muted/20",
193
- g.class
194
- ), s = `${b()}px`, c = b(), l = `1 / ${C() + 1}`;
195
- return o !== e.e && J(t, e.e = o), s !== e.t && v(t, "grid-auto-rows", e.t = s), c !== e.a && Q(t, "data-row-height", e.a = c), l !== e.o && v(r, "grid-row", e.o = l), e;
186
+ R.class
187
+ ), s = `${w()}px`, c = w(), i = `1 / ${S() + 1}`;
188
+ return o !== e.e && J(t, e.e = o), s !== e.t && l(t, "grid-auto-rows", e.t = s), c !== e.a && b(t, "data-row-height", e.a = c), i !== e.o && l(r, "grid-row", e.o = i), e;
196
189
  }, {
197
190
  e: void 0,
198
191
  t: void 0,
@@ -201,24 +194,9 @@ function Dt(g) {
201
194
  }), t;
202
195
  })();
203
196
  }
204
- const Pt = {
205
- cols: T,
206
- defaultRows: u,
207
- gap: x,
208
- // Deprecated: use getGridConfig() or read from data-row-height attribute instead
209
- rowHeight: k
210
- };
211
- function ht(g) {
212
- return {
213
- cols: parseInt(g.dataset.gridCols || String(T), 10),
214
- rowHeight: parseFloat(g.dataset.rowHeight || String(k)),
215
- gap: parseInt(g.dataset.gap || String(x), 10),
216
- defaultRows: parseInt(g.dataset.defaultRows || String(u), 10)
217
- };
218
- }
219
- et(["contextmenu"]);
197
+ tt(["contextmenu"]);
220
198
  export {
221
- Pt as DECK_GRID_CONFIG,
222
- Dt as DeckGrid,
223
- ht as getGridConfigFromElement
199
+ _t as DECK_GRID_CONFIG,
200
+ It as DeckGrid,
201
+ mt as getGridConfigFromElement
224
202
  };
@@ -4,6 +4,8 @@ export interface WidgetResizeHandleProps {
4
4
  edge: ResizeState['edge'];
5
5
  }
6
6
  /**
7
- * Resize handle for a specific edge of a widget
7
+ * Resize handle for a specific edge of a widget.
8
+ * The active pointer session is owned by the shared Deck pointer-session helper,
9
+ * so pointer release remains reliable even when the cursor crosses other widgets.
8
10
  */
9
11
  export declare function WidgetResizeHandle(props: WidgetResizeHandleProps): import("solid-js").JSX.Element;
@@ -1,12 +1,11 @@
1
- import { effect as L, className as B, setAttribute as U, template as _, use as N, delegateEvents as O } from "solid-js/web";
2
- import { createSignal as j, onCleanup as J } from "solid-js";
3
- import { cn as K } from "../../utils/cn.js";
4
- import { useDeck as Q } from "../../context/DeckContext.js";
5
- import { applyResizeDelta as V } from "../../utils/gridLayout.js";
6
- import { getGridConfigFromElement as Z } from "./DeckGrid.js";
7
- import { startHotInteraction as ee } from "../../utils/hotInteraction.js";
8
- var te = /* @__PURE__ */ _("<div style=touch-action:none>");
9
- const ne = {
1
+ import { effect as m, className as h, setAttribute as p, template as b, use as v, delegateEvents as E } from "solid-js/web";
2
+ import { createSignal as R, onCleanup as S } from "solid-js";
3
+ import { cn as D } from "../../utils/cn.js";
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 = {
10
9
  n: "top-0 left-2 right-2 h-2 cursor-ns-resize",
11
10
  s: "bottom-0 left-2 right-2 h-2 cursor-ns-resize",
12
11
  e: "right-0 top-2 bottom-2 w-2 cursor-ew-resize",
@@ -15,7 +14,7 @@ const ne = {
15
14
  nw: "top-0 left-0 w-4 h-4 cursor-nwse-resize",
16
15
  se: "bottom-0 right-0 w-4 h-4 cursor-nwse-resize",
17
16
  sw: "bottom-0 left-0 w-4 h-4 cursor-nesw-resize"
18
- }, re = {
17
+ }, A = {
19
18
  n: "ns-resize",
20
19
  s: "ns-resize",
21
20
  e: "ew-resize",
@@ -25,85 +24,52 @@ const ne = {
25
24
  se: "nwse-resize",
26
25
  sw: "nesw-resize"
27
26
  };
28
- function ue(i) {
29
- const f = Q(), [m, C] = j(!1);
30
- let g, h = null, d = 0, u = 0, y = 0, p = 0, s = 0, R = 0, b = 0, S = 0, l = null, w = null, r = null, A = null, P = 0, F = 0;
31
- const I = (e) => {
32
- if (!e) {
33
- w?.(), w = null;
34
- return;
35
- }
36
- w?.(), w = ee({
37
- kind: "resize",
38
- cursor: re[i.edge],
39
- lockUserSelect: !0
40
- });
41
- }, E = () => {
42
- m() && (l !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(l), l = null), C(!1), h = null, r = null, A = null, I(!1), f.endResize(!0));
43
- }, H = () => {
44
- if (!r) return;
45
- const e = A ?? r.getBoundingClientRect(), t = 48, n = 24, o = s - e.top, a = e.bottom - s;
46
- let c = 0;
47
- if (o < t ? c = -Math.ceil((t - o) / t * n) : a < t && (c = Math.ceil((t - a) / t * n)), c === 0) return;
48
- const z = r.scrollTop, v = Math.max(0, Math.min(z + c, r.scrollHeight - r.clientHeight));
49
- v !== z && (r.scrollTop = v);
50
- }, Y = () => {
51
- if (l !== null || typeof requestAnimationFrame > "u") return;
52
- const e = () => {
53
- if (!m()) {
54
- l = null;
55
- return;
56
- }
57
- D(), l = requestAnimationFrame(e);
58
- };
59
- l = requestAnimationFrame(e);
60
- }, $ = (e) => {
27
+ function G(t) {
28
+ const s = y(), [u, d] = R(!1);
29
+ let c, o = null;
30
+ const a = (e) => {
31
+ o?.stop({
32
+ commit: e
33
+ }), o = null;
34
+ }, g = (e) => {
61
35
  if (e.pointerType === "mouse" && e.button !== 0) return;
62
36
  e.preventDefault(), e.stopPropagation();
63
- const t = e.currentTarget?.closest(".deck-grid");
64
- if (!t) return;
65
- h = e.pointerId, d = e.clientX, u = e.clientY, p = d, s = u, R = d, b = u, C(!0), I(!0), r = t, A = t.getBoundingClientRect(), y = t.scrollTop, S = y;
66
- const n = window.getComputedStyle(t);
67
- P = parseFloat(n.paddingLeft) || 0, F = parseFloat(n.paddingRight) || 0, f.startResize(i.widget.id, i.edge, d, u), g?.setPointerCapture(e.pointerId), Y();
68
- }, G = (e) => {
69
- !m() || h !== e.pointerId || (p = e.clientX, s = e.clientY, typeof requestAnimationFrame > "u" && D());
70
- }, D = () => {
71
- if (!r) return;
72
- H();
73
- const e = r.scrollTop;
74
- if (p === R && s === b && e === S) return;
75
- R = p, b = s, S = e;
76
- const t = p - d, n = s - u + (e - y), {
77
- cols: o,
78
- rowHeight: a,
79
- gap: c
80
- } = Z(r), z = r.clientWidth - P - F, v = c * (o - 1), T = (z - v) / o;
81
- if (!Number.isFinite(T) || T <= 0) return;
82
- const W = a + c, X = Math.round(t / T), q = Math.round(n / W), k = f.getWidgetMinConstraints(i.widget.type), x = V(i.widget.position, i.edge, X, q, k.minColSpan, k.minRowSpan, o);
83
- f.updateResize(x);
84
- }, M = (e) => {
85
- if (h === e.pointerId) {
86
- try {
87
- g?.releasePointerCapture(e.pointerId);
88
- } catch {
37
+ const n = e.currentTarget?.closest(".deck-grid");
38
+ if (!n) return;
39
+ a(!1), s.startResize(t.widget.id, t.edge, e.clientX, e.clientY);
40
+ const r = s.resizeState();
41
+ !r || r.widgetId !== t.widget.id || r.edge !== t.edge || (d(!0), o = C({
42
+ kind: "resize",
43
+ widgetId: t.widget.id,
44
+ gridEl: n,
45
+ captureEl: c,
46
+ pointerEvent: e,
47
+ cursor: A[t.edge],
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);
50
+ s.updateResize(f);
51
+ },
52
+ onEnd: ({
53
+ commit: i
54
+ }) => {
55
+ o = null, d(!1), s.endResize(i);
89
56
  }
90
- E();
91
- }
57
+ }));
92
58
  };
93
- return J(() => E()), (() => {
94
- var e = te();
95
- e.addEventListener("pointercancel", M), e.$$pointerup = M, e.$$pointermove = G, e.$$pointerdown = $;
96
- var t = g;
97
- return typeof t == "function" ? N(t, e) : g = e, L((n) => {
98
- var o = K("absolute z-30", ne[i.edge], "hover:bg-primary/30 transition-colors", m() && "bg-primary/50"), a = i.edge;
99
- return o !== n.e && B(e, n.e = o), a !== n.t && U(e, "data-widget-resize-handle", n.t = a), n;
59
+ return S(() => a(!1)), (() => {
60
+ var e = M();
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;
100
66
  }, {
101
67
  e: void 0,
102
68
  t: void 0
103
69
  }), e;
104
70
  })();
105
71
  }
106
- O(["pointerdown", "pointermove", "pointerup"]);
72
+ E(["pointerdown"]);
107
73
  export {
108
- ue as WidgetResizeHandle
74
+ G as WidgetResizeHandle
109
75
  };