@griddle/vue 0.1.7 → 0.1.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.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { defineComponent as $e, ref as E, computed as p, watch as Me, onMounted as Ne, onBeforeUnmount as Ae, nextTick as _e, openBlock as H, createElementBlock as M, normalizeStyle as $, normalizeClass as Ie, createElementVNode as Oe, createCommentVNode as ne, Fragment as we, renderList as Se, renderSlot as Re, createBlock as Ke, withCtx as Ue, normalizeProps as Ve, guardReactiveProps as Je, toDisplayString as qe, shallowRef as We, onScopeDispose as je } from "vue";
2
- import { resolveLoop as Qe, loopPeriod as Ze, PanController as et, loopInstances as tt, DragController as Be, visibleRange as it, visibleTiles as nt, gridContentSize as ot, GroupDragController as lt, computeTileLayout as De, resolveStickyStacking as at, isOutOfFlow as rt, pixelsToPin as st, Grid as dt } from "@griddle/core";
3
- import { animateReposition as Fe, liftTransition as ut } from "./animation.js";
4
- import { measureInteractionScale as Le, toLocalInteractionDelta as Ce } from "./interaction.js";
5
- const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost", "aria-hidden", "onPointerdown"], vt = ["data-griddle-handle", "onPointerdown"], pt = ["data-griddle-tile"], Ge = "a, button, input, textarea, select, [contenteditable]", gt = 4, wt = /* @__PURE__ */ $e({
1
+ import { defineComponent as Te, ref as H, computed as p, watch as ze, onMounted as We, onBeforeUnmount as De, nextTick as Me, openBlock as k, createElementBlock as X, normalizeStyle as G, normalizeClass as xe, createElementVNode as Le, createCommentVNode as ie, Fragment as ve, renderList as me, renderSlot as ye, createBlock as Ae, withCtx as _e, normalizeProps as Oe, guardReactiveProps as Be, toDisplayString as Fe, shallowRef as Xe, onScopeDispose as Ke } from "vue";
2
+ import { resolveLoop as Ue, loopPeriod as Ve, PanController as Je, loopInstances as qe, DragController as Ge, visibleRange as je, visibleTiles as Qe, gridContentSize as Ze, GroupDragController as et, computeTileLayout as Ee, resolveStickyStacking as tt, isOutOfFlow as it, pixelsToPin as nt, Grid as ot } from "@griddle/core";
3
+ import { animateReposition as $e, liftTransition as lt } from "./animation.js";
4
+ import { resolveResizePreview as Ne, measureInteractionScale as Re, clampInteractionCell as fe, toLocalInteractionDelta as he } from "./interaction.js";
5
+ const at = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost", "aria-hidden", "onPointerdown"], rt = ["data-griddle-handle", "onPointerdown"], st = ["data-griddle-tile"], Ye = "a, button, input, textarea, select, [contenteditable]", dt = 4, ut = /* @__PURE__ */ Te({
6
6
  __name: "LoopGrid",
7
7
  props: {
8
8
  api: {},
@@ -12,80 +12,80 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
12
12
  selection: {}
13
13
  },
14
14
  emits: ["selectionChange", "dragStart", "dragEnd", "resizeStart", "resizeEnd", "cameraChange"],
15
- setup(O, { emit: I }) {
16
- const s = O, w = I, B = E(null), Y = E(null), c = p(() => s.api.config.value), d = p(() => Qe(c.value)), g = p(() => {
15
+ setup(_, { emit: C }) {
16
+ const s = _, f = C, O = H(null), Y = H(null), v = p(() => s.api.config.value), r = p(() => Ue(v.value)), w = p(() => {
17
17
  var e;
18
- return ((e = d.value) == null ? void 0 : e.interaction) === "edit";
19
- }), x = p(() => c.value.gap ?? 0), b = p(() => x.value / 2), h = p(() => c.value.unitWidth + x.value), T = p(() => c.value.unitHeight + x.value), se = p(() => Ze(c.value, s.api.tiles.value)), N = new et();
20
- Me(d, (e) => {
21
- e && N.setPhysics({ friction: e.friction, ease: e.ease, maxVelocity: e.maxVelocity });
18
+ return ((e = r.value) == null ? void 0 : e.interaction) === "edit";
19
+ }), y = p(() => v.value.gap ?? 0), b = p(() => y.value / 2), h = p(() => v.value.unitWidth + y.value), T = p(() => v.value.unitHeight + y.value), re = p(() => Ve(v.value, s.api.tiles.value)), $ = new Je();
20
+ ze(r, (e) => {
21
+ e && $.setPhysics({ friction: e.friction, ease: e.ease, maxVelocity: e.maxVelocity });
22
22
  }, { immediate: !0 });
23
- const A = E({ cxCell: 0, cyCell: 0, vw: 1e3, vh: 800 });
24
- let U = null, oe = 0, W = null;
25
- function q(e) {
23
+ const N = H({ cxCell: 0, cyCell: 0, vw: 1e3, vh: 800 });
24
+ let K = null, ne = 0, W = null;
25
+ function J(e) {
26
26
  e.preventDefault();
27
27
  const t = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 100 : 1;
28
- N.scrollBy(e.deltaX * t, e.deltaY * t);
28
+ $.scrollBy(e.deltaX * t, e.deltaY * t);
29
29
  }
30
- function j(e) {
31
- oe = requestAnimationFrame(j);
32
- const t = N.tick(e), n = Y.value;
30
+ function q(e) {
31
+ ne = requestAnimationFrame(q);
32
+ const t = $.tick(e), n = Y.value;
33
33
  n && (n.style.transform = `translate3d(${-t.x}px, ${-t.y}px, 0)`);
34
- const l = B.value;
34
+ const l = O.value;
35
35
  l && s.showGrid !== !1 && (l.style.backgroundPosition = `${-t.x % h.value}px ${-t.y % T.value}px`);
36
- const a = Math.floor(t.x / h.value), u = Math.floor(t.y / T.value), r = A.value;
37
- (a !== r.cxCell || u !== r.cyCell) && (A.value = { ...r, cxCell: a, cyCell: u }), (!U || U.x !== t.x || U.y !== t.y || U.isMoving !== t.isMoving || U.isDragging !== t.isDragging) && (U = t, w("cameraChange", t));
36
+ const a = Math.floor(t.x / h.value), u = Math.floor(t.y / T.value), d = N.value;
37
+ (a !== d.cxCell || u !== d.cyCell) && (N.value = { ...d, cxCell: a, cyCell: u }), (!K || K.x !== t.x || K.y !== t.y || K.isMoving !== t.isMoving || K.isDragging !== t.isDragging) && (K = t, f("cameraChange", t));
38
38
  }
39
- const le = p(() => {
39
+ const oe = p(() => {
40
40
  s.api.version.value;
41
41
  const e = 2 * h.value, t = 2 * T.value;
42
- return tt(c.value, s.api.tiles.value, {
43
- x: A.value.cxCell * h.value - e,
44
- y: A.value.cyCell * T.value - t,
45
- width: A.value.vw + h.value + 2 * e,
46
- height: A.value.vh + T.value + 2 * t
42
+ return qe(v.value, s.api.tiles.value, {
43
+ x: N.value.cxCell * h.value - e,
44
+ y: N.value.cyCell * T.value - t,
45
+ width: N.value.vw + h.value + 2 * e,
46
+ height: N.value.vh + T.value + 2 * t
47
47
  });
48
48
  });
49
- let S = null, z = !1;
50
- function de(e) {
49
+ let I = null, S = !1;
50
+ function se(e) {
51
51
  var l;
52
52
  const t = !!e.target.closest("[data-griddle-tile]");
53
- if (g.value && !t && D(/* @__PURE__ */ new Set()), !((l = d.value) != null && l.dragPan) || e.button !== 0) return;
54
- const n = c.value.dragIgnoreFrom ?? Ge;
55
- n && e.target.closest(n) || (S = { pointerId: e.pointerId, startX: e.clientX, startY: e.clientY, moved: !1 });
53
+ if (w.value && !t && D(/* @__PURE__ */ new Set()), !((l = r.value) != null && l.dragPan) || e.button !== 0) return;
54
+ const n = v.value.dragIgnoreFrom ?? Ye;
55
+ n && e.target.closest(n) || (I = { pointerId: e.pointerId, startX: e.clientX, startY: e.clientY, moved: !1 });
56
56
  }
57
- function ue(e) {
58
- z && (z = !1, e.preventDefault(), e.stopPropagation());
57
+ function de(e) {
58
+ S && (S = !1, e.preventDefault(), e.stopPropagation());
59
59
  }
60
- const F = E(/* @__PURE__ */ new Set()), P = p(() => s.selection ?? F.value);
60
+ const E = H(/* @__PURE__ */ new Set()), R = p(() => s.selection ?? E.value);
61
61
  function D(e) {
62
- s.selection || (F.value = e), w("selectionChange", e);
62
+ s.selection || (E.value = e), f("selectionChange", e);
63
63
  }
64
- const k = new Be(s.api.grid), m = E(null);
65
- let L = 0, he = 0;
66
- const K = E(null);
67
- function fe() {
64
+ const z = new Ge(s.api.grid), m = H(null);
65
+ let M = 0, pe = 0;
66
+ const B = H(null);
67
+ function ge() {
68
68
  s.api.tiles.value = s.api.grid.tiles, s.api.version.value++;
69
69
  }
70
- function _(e) {
70
+ function A(e) {
71
71
  return e.kx === 0 && e.ky === 0;
72
72
  }
73
- function ce(e) {
74
- return g.value && !_(e);
73
+ function ue(e) {
74
+ return w.value && !A(e);
75
75
  }
76
- function ae(e, t) {
77
- if (!g.value || !_(t)) return;
76
+ function le(e, t) {
77
+ if (!w.value || !A(t)) return;
78
78
  const n = t.tile;
79
79
  if (n.draggable === !1 || e.target.dataset.griddleHandle) return;
80
- const l = c.value.dragIgnoreFrom ?? Ge;
80
+ const l = v.value.dragIgnoreFrom ?? Ye;
81
81
  if (!(l && e.target.closest(l))) {
82
82
  if (e.metaKey || e.ctrlKey) {
83
83
  e.preventDefault();
84
- const a = new Set(P.value);
84
+ const a = new Set(R.value);
85
85
  a.has(n.id) ? a.delete(n.id) : a.add(n.id), D(a), e.stopPropagation();
86
86
  return;
87
87
  }
88
- D(/* @__PURE__ */ new Set([n.id])), k.start(n.id) && (L = e.clientX, he = e.clientY, m.value = {
88
+ D(/* @__PURE__ */ new Set([n.id])), z.start(n.id) && (M = e.clientX, pe = e.clientY, m.value = {
89
89
  tileId: n.id,
90
90
  instanceLeft: t.left,
91
91
  instanceTop: t.top,
@@ -95,16 +95,16 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
95
95
  deltaY: 0,
96
96
  indicatorCol: n.col,
97
97
  indicatorRow: n.row
98
- }, w("dragStart", n.id), e.stopPropagation());
98
+ }, f("dragStart", n.id), e.stopPropagation());
99
99
  }
100
100
  }
101
- function re(e, t, n) {
102
- if (!g.value) return;
101
+ function ae(e, t, n) {
102
+ if (!w.value) return;
103
103
  const l = t.tile;
104
104
  if (l.resizable === !1) return;
105
105
  e.currentTarget.setPointerCapture(e.pointerId);
106
106
  const a = l.col * h.value + b.value, u = l.row * T.value + b.value;
107
- K.value = {
107
+ B.value = {
108
108
  tileId: l.id,
109
109
  instanceKey: t.key,
110
110
  instanceDx: t.left - a,
@@ -120,48 +120,60 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
120
120
  previewH: l.h,
121
121
  previewCol: l.col,
122
122
  previewRow: l.row
123
- }, w("resizeStart", l.id), e.stopPropagation();
123
+ }, f("resizeStart", l.id), e.stopPropagation();
124
124
  }
125
- function Q(e) {
126
- if (S && e.pointerId === S.pointerId) {
125
+ function j(e) {
126
+ if (I && e.pointerId === I.pointerId) {
127
127
  const l = performance.now();
128
- S.moved ? N.dragMove(e.clientX, e.clientY, l) : Math.hypot(e.clientX - S.startX, e.clientY - S.startY) >= gt && (S.moved = !0, N.dragStart(S.startX, S.startY, l), N.dragMove(e.clientX, e.clientY, l));
128
+ I.moved ? $.dragMove(e.clientX, e.clientY, l) : Math.hypot(e.clientX - I.startX, e.clientY - I.startY) >= dt && (I.moved = !0, $.dragStart(I.startX, I.startY, l), $.dragMove(e.clientX, e.clientY, l));
129
129
  return;
130
130
  }
131
131
  const t = m.value;
132
132
  if (t) {
133
- const l = e.clientX - L, a = e.clientY - he, u = {
133
+ const l = e.clientX - M, a = e.clientY - pe, u = {
134
134
  col: t.pickupCol + Math.round(l / h.value),
135
135
  row: t.pickupRow + Math.round(a / T.value)
136
- }, r = k.update(u);
136
+ }, d = z.update(u);
137
137
  m.value = {
138
138
  ...t,
139
139
  deltaX: l,
140
140
  deltaY: a,
141
- indicatorCol: r.indicatorCell ? r.indicatorCell.col : null,
142
- indicatorRow: r.indicatorCell ? r.indicatorCell.row : null
143
- }, r.changed && fe();
141
+ indicatorCol: d.indicatorCell ? d.indicatorCell.col : null,
142
+ indicatorRow: d.indicatorCell ? d.indicatorCell.row : null
143
+ }, d.changed && ge();
144
144
  }
145
- const n = K.value;
145
+ const n = B.value;
146
146
  if (n) {
147
- const l = e.clientX - n.startPointerX, a = e.clientY - n.startPointerY;
148
- let u = 0, r = 0, v = 0, f = 0;
149
- const C = Math.round(l / h.value), y = Math.round(a / T.value);
150
- (n.corner === "se" || n.corner === "ne") && (u = C), (n.corner === "se" || n.corner === "sw") && (r = y), (n.corner === "sw" || n.corner === "nw") && (u = -C, v = C), (n.corner === "ne" || n.corner === "nw") && (r = -y, f = y);
151
- const R = s.api.grid.getTile(n.tileId), ve = (R == null ? void 0 : R.minW) ?? 1, pe = (R == null ? void 0 : R.minH) ?? 1, X = Math.min((R == null ? void 0 : R.maxW) ?? 1 / 0, c.value.cols), Ee = Math.min((R == null ? void 0 : R.maxH) ?? 1 / 0, c.value.rows), xe = Math.min(X, Math.max(ve, n.startW + u)), ye = Math.min(Ee, Math.max(pe, n.startH + r)), be = n.startCol + v, ge = n.startRow + f;
152
- (xe !== n.previewW || ye !== n.previewH || be !== n.previewCol || ge !== n.previewRow) && (K.value = { ...n, previewW: xe, previewH: ye, previewCol: be, previewRow: ge });
147
+ const l = e.clientX - n.startPointerX, a = e.clientY - n.startPointerY, u = Math.round(l / h.value), d = Math.round(a / T.value), c = s.api.grid.getTile(n.tileId), x = Ne({
148
+ corner: n.corner,
149
+ startCol: n.startCol,
150
+ startRow: n.startRow,
151
+ startW: n.startW,
152
+ startH: n.startH,
153
+ stepsX: u,
154
+ stepsY: d,
155
+ minW: (c == null ? void 0 : c.minW) ?? 1,
156
+ minH: (c == null ? void 0 : c.minH) ?? 1,
157
+ maxW: (c == null ? void 0 : c.maxW) ?? 1 / 0,
158
+ maxH: (c == null ? void 0 : c.maxH) ?? 1 / 0,
159
+ cols: v.value.cols,
160
+ rows: v.value.rows,
161
+ infiniteX: v.value.infiniteX ?? v.value.cols === 1 / 0,
162
+ infiniteY: v.value.infiniteY ?? v.value.rows === 1 / 0
163
+ }), P = x.w, g = x.h, F = x.col, ce = x.row;
164
+ (P !== n.previewW || g !== n.previewH || F !== n.previewCol || ce !== n.previewRow) && (B.value = { ...n, previewW: P, previewH: g, previewCol: F, previewRow: ce });
153
165
  }
154
166
  }
155
- function Z(e) {
156
- if (S && e.pointerId === S.pointerId) {
157
- S.moved && (N.dragEnd(performance.now()), z = !0), S = null;
167
+ function Q(e) {
168
+ if (I && e.pointerId === I.pointerId) {
169
+ I.moved && ($.dragEnd(performance.now()), S = !0), I = null;
158
170
  return;
159
171
  }
160
172
  if (m.value) {
161
- const n = m.value.tileId, { committed: l } = k.end();
162
- m.value = null, fe(), w("dragEnd", n, l);
173
+ const n = m.value.tileId, { committed: l } = z.end();
174
+ m.value = null, ge(), f("dragEnd", n, l);
163
175
  }
164
- const t = K.value;
176
+ const t = B.value;
165
177
  if (t) {
166
178
  const n = s.api.grid.getTile(t.tileId);
167
179
  let l = !1;
@@ -169,52 +181,52 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
169
181
  const a = { col: t.previewCol, row: t.previewRow };
170
182
  (a.col !== n.col || a.row !== n.row) && s.api.moveTile(t.tileId, a), t.previewW !== n.w || t.previewH !== n.h ? l = s.api.resizeTile(t.tileId, { w: t.previewW, h: t.previewH }) : l = t.previewCol !== t.startCol || t.previewRow !== t.startRow || t.previewW !== t.startW || t.previewH !== t.startH;
171
183
  }
172
- K.value = null, w("resizeEnd", t.tileId, l);
184
+ B.value = null, f("resizeEnd", t.tileId, l);
173
185
  }
174
186
  }
175
- function V(e) {
176
- e.key === "Escape" && g.value && D(/* @__PURE__ */ new Set());
187
+ function U(e) {
188
+ e.key === "Escape" && w.value && D(/* @__PURE__ */ new Set());
177
189
  }
178
- Ne(() => {
179
- const e = B.value;
190
+ We(() => {
191
+ const e = O.value;
180
192
  if (e) {
181
- e.addEventListener("wheel", q, { passive: !1 });
193
+ e.addEventListener("wheel", J, { passive: !1 });
182
194
  const t = () => {
183
- const n = A.value;
184
- (e.clientWidth !== n.vw || e.clientHeight !== n.vh) && (A.value = { ...n, vw: e.clientWidth, vh: e.clientHeight });
195
+ const n = N.value;
196
+ (e.clientWidth !== n.vw || e.clientHeight !== n.vh) && (N.value = { ...n, vw: e.clientWidth, vh: e.clientHeight });
185
197
  };
186
198
  t(), W = new ResizeObserver(t), W.observe(e);
187
199
  }
188
- oe = requestAnimationFrame(j), window.addEventListener("pointermove", Q), window.addEventListener("pointerup", Z), window.addEventListener("pointercancel", Z), window.addEventListener("keydown", V);
189
- }), Ae(() => {
200
+ ne = requestAnimationFrame(q), window.addEventListener("pointermove", j), window.addEventListener("pointerup", Q), window.addEventListener("pointercancel", Q), window.addEventListener("keydown", U);
201
+ }), De(() => {
190
202
  var e;
191
- cancelAnimationFrame(oe), (e = B.value) == null || e.removeEventListener("wheel", q), W == null || W.disconnect(), window.removeEventListener("pointermove", Q), window.removeEventListener("pointerup", Z), window.removeEventListener("pointercancel", Z), window.removeEventListener("keydown", V);
203
+ cancelAnimationFrame(ne), (e = O.value) == null || e.removeEventListener("wheel", J), W == null || W.disconnect(), window.removeEventListener("pointermove", j), window.removeEventListener("pointerup", Q), window.removeEventListener("pointercancel", Q), window.removeEventListener("keydown", U);
192
204
  });
193
- const ee = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map();
194
- function ze(e, t) {
195
- t ? ee.set(e, t) : ee.delete(e);
205
+ const Z = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
206
+ function be(e, t) {
207
+ t ? Z.set(e, t) : Z.delete(e);
196
208
  }
197
- Me(() => s.api.version.value, async () => {
209
+ ze(() => s.api.version.value, async () => {
198
210
  var n;
199
- await _e();
211
+ await Me();
200
212
  const e = ((n = m.value) == null ? void 0 : n.tileId) ?? null, t = /* @__PURE__ */ new Set();
201
- for (const l of le.value) {
213
+ for (const l of oe.value) {
202
214
  const a = l.key;
203
215
  t.add(a);
204
- const u = l.left, r = l.top;
205
- if (g.value && l.tile.id !== e) {
206
- const v = J.get(a), f = ee.get(a);
207
- if (v && f) {
208
- const C = v.x - u, y = v.y - r;
209
- (C !== 0 || y !== 0) && Math.abs(C) < se.value.width / 2 && Math.abs(y) < se.value.height / 2 && Fe(f, C, y, c.value.animation);
216
+ const u = l.left, d = l.top;
217
+ if (w.value && l.tile.id !== e) {
218
+ const c = V.get(a), x = Z.get(a);
219
+ if (c && x) {
220
+ const P = c.x - u, g = c.y - d;
221
+ (P !== 0 || g !== 0) && Math.abs(P) < re.value.width / 2 && Math.abs(g) < re.value.height / 2 && $e(x, P, g, v.value.animation);
210
222
  }
211
223
  }
212
- J.set(a, { x: u, y: r });
224
+ V.set(a, { x: u, y: d });
213
225
  }
214
- for (const l of J.keys())
215
- t.has(l) || J.delete(l);
226
+ for (const l of V.keys())
227
+ t.has(l) || V.delete(l);
216
228
  });
217
- const Pe = p(() => {
229
+ const Ce = p(() => {
218
230
  var n;
219
231
  const t = s.showGrid !== !1 ? {
220
232
  backgroundImage: "linear-gradient(to right, rgba(0,0,0,0.08) 1px, transparent 1px), linear-gradient(to bottom, rgba(0,0,0,0.08) 1px, transparent 1px)",
@@ -228,11 +240,11 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
228
240
  touchAction: "none",
229
241
  userSelect: "none",
230
242
  willChange: "translate",
231
- cursor: !g.value && ((n = d.value) != null && n.dragPan) ? "grab" : void 0,
232
- "--griddle-tile-radius": (c.value.tileRadius ?? 4) + "px",
243
+ cursor: !w.value && ((n = r.value) != null && n.dragPan) ? "grab" : void 0,
244
+ "--griddle-tile-radius": (v.value.tileRadius ?? 4) + "px",
233
245
  ...t
234
246
  };
235
- }), ke = p(() => ({
247
+ }), Ie = p(() => ({
236
248
  position: "absolute",
237
249
  top: "0",
238
250
  left: "0",
@@ -240,39 +252,39 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
240
252
  height: "0",
241
253
  willChange: "transform"
242
254
  }));
243
- function te(e) {
244
- const t = K.value, n = (t == null ? void 0 : t.instanceKey) === e.key;
245
- let l = e.left, a = e.top, u = e.width, r = e.height;
246
- n && t && (l = t.previewCol * h.value + b.value + t.instanceDx, a = t.previewRow * T.value + b.value + t.instanceDy, u = t.previewW * c.value.unitWidth + (t.previewW - 1) * x.value, r = t.previewH * c.value.unitHeight + (t.previewH - 1) * x.value);
247
- const v = ce(e), f = g.value && _(e) && P.value.has(e.tile.id);
255
+ function ee(e) {
256
+ const t = B.value, n = (t == null ? void 0 : t.instanceKey) === e.key;
257
+ let l = e.left, a = e.top, u = e.width, d = e.height;
258
+ n && t && (l = t.previewCol * h.value + b.value + t.instanceDx, a = t.previewRow * T.value + b.value + t.instanceDy, u = t.previewW * v.value.unitWidth + (t.previewW - 1) * y.value, d = t.previewH * v.value.unitHeight + (t.previewH - 1) * y.value);
259
+ const c = ue(e), x = w.value && A(e) && R.value.has(e.tile.id);
248
260
  return {
249
261
  position: "absolute",
250
262
  left: l + "px",
251
263
  top: a + "px",
252
264
  width: u + "px",
253
- height: r + "px",
265
+ height: d + "px",
254
266
  boxSizing: "border-box",
255
- cursor: g.value && _(e) ? "grab" : void 0,
267
+ cursor: w.value && A(e) ? "grab" : void 0,
256
268
  userSelect: "none",
257
269
  // Ghosts are display-only: pointer-transparent (so the gesture falls
258
270
  // through to drag-pan) and dimmed to mark the editable copy.
259
- pointerEvents: v ? "none" : void 0,
271
+ pointerEvents: c ? "none" : void 0,
260
272
  zIndex: n ? 10 : 1,
261
- opacity: n ? 0.85 : v ? 0.55 : 1,
262
- boxShadow: f ? "0 0 0 3px rgba(59, 91, 219, 0.85), inset 0 0 0 1px rgba(59, 91, 219, 0.3)" : "",
263
- borderRadius: (c.value.tileRadius ?? 4) + "px"
273
+ opacity: n ? 0.85 : c ? 0.55 : 1,
274
+ boxShadow: x ? "0 0 0 3px rgba(59, 91, 219, 0.85), inset 0 0 0 1px rgba(59, 91, 219, 0.3)" : "",
275
+ borderRadius: (v.value.tileRadius ?? 4) + "px"
264
276
  };
265
277
  }
266
- const G = p(
278
+ const L = p(
267
279
  () => m.value ? s.api.grid.getTile(m.value.tileId) ?? null : null
268
- ), He = p(() => {
269
- const e = m.value, t = G.value;
280
+ ), Se = p(() => {
281
+ const e = m.value, t = L.value;
270
282
  return !e || !t ? {} : {
271
283
  position: "absolute",
272
284
  left: e.instanceLeft + "px",
273
285
  top: e.instanceTop + "px",
274
- width: t.w * c.value.unitWidth + (t.w - 1) * x.value + "px",
275
- height: t.h * c.value.unitHeight + (t.h - 1) * x.value + "px",
286
+ width: t.w * v.value.unitWidth + (t.w - 1) * y.value + "px",
287
+ height: t.h * v.value.unitHeight + (t.h - 1) * y.value + "px",
276
288
  boxSizing: "border-box",
277
289
  cursor: "grabbing",
278
290
  userSelect: "none",
@@ -280,22 +292,22 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
280
292
  opacity: 0.85,
281
293
  transform: `translate(${e.deltaX}px, ${e.deltaY}px)`,
282
294
  filter: "drop-shadow(0 8px 16px rgba(0,0,0,0.18))",
283
- borderRadius: (c.value.tileRadius ?? 4) + "px",
295
+ borderRadius: (v.value.tileRadius ?? 4) + "px",
284
296
  pointerEvents: "none"
285
297
  };
286
- }), ie = p(() => {
298
+ }), te = p(() => {
287
299
  const e = m.value;
288
300
  if (!e || e.indicatorCol === null || e.indicatorRow === null) return null;
289
301
  const t = s.api.grid.getTile(e.tileId);
290
302
  return t ? {
291
303
  left: e.indicatorCol * h.value + b.value,
292
304
  top: e.indicatorRow * T.value + b.value,
293
- width: t.w * c.value.unitWidth + (t.w - 1) * x.value,
294
- height: t.h * c.value.unitHeight + (t.h - 1) * x.value
305
+ width: t.w * v.value.unitWidth + (t.w - 1) * y.value,
306
+ height: t.h * v.value.unitHeight + (t.h - 1) * y.value
295
307
  } : null;
296
308
  });
297
- function me(e) {
298
- return e.resizeHandles ?? c.value.resizeHandles ?? ["se"];
309
+ function we(e) {
310
+ return e.resizeHandles ?? v.value.resizeHandles ?? ["se"];
299
311
  }
300
312
  function i(e) {
301
313
  const n = {
@@ -311,84 +323,84 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
311
323
  return e === "nw" ? { ...n, top: -12 / 2 + "px", left: -12 / 2 + "px" } : e === "ne" ? { ...n, top: -12 / 2 + "px", right: -12 / 2 + "px" } : e === "sw" ? { ...n, bottom: -12 / 2 + "px", left: -12 / 2 + "px" } : { ...n, bottom: -12 / 2 + "px", right: -12 / 2 + "px" };
312
324
  }
313
325
  const o = p(() => s.className ?? "");
314
- return (e, t) => (H(), M("div", {
326
+ return (e, t) => (k(), X("div", {
315
327
  ref_key: "viewportEl",
316
- ref: B,
317
- class: Ie(o.value),
318
- style: $(Pe.value),
319
- onPointerdown: de,
320
- onClickCapture: ue
328
+ ref: O,
329
+ class: xe(o.value),
330
+ style: G(Ce.value),
331
+ onPointerdown: se,
332
+ onClickCapture: de
321
333
  }, [
322
- Oe("div", {
334
+ Le("div", {
323
335
  ref_key: "planeEl",
324
336
  ref: Y,
325
- style: $(ke.value)
337
+ style: G(Ie.value)
326
338
  }, [
327
- ie.value ? (H(), M("div", {
339
+ te.value ? (k(), X("div", {
328
340
  key: 0,
329
341
  class: "griddle-drop-indicator",
330
- style: $({
342
+ style: G({
331
343
  position: "absolute",
332
- left: ie.value.left + "px",
333
- top: ie.value.top + "px",
334
- width: ie.value.width + "px",
335
- height: ie.value.height + "px",
344
+ left: te.value.left + "px",
345
+ top: te.value.top + "px",
346
+ width: te.value.width + "px",
347
+ height: te.value.height + "px",
336
348
  boxSizing: "border-box",
337
349
  border: "2px dashed rgba(59, 91, 219, 0.55)",
338
350
  background: "rgba(59, 91, 219, 0.08)",
339
- borderRadius: (c.value.tileRadius ?? 4) + "px",
351
+ borderRadius: (v.value.tileRadius ?? 4) + "px",
340
352
  pointerEvents: "none",
341
353
  zIndex: 5
342
354
  })
343
- }, null, 4)) : ne("", !0),
344
- (H(!0), M(we, null, Se(le.value, (n) => {
355
+ }, null, 4)) : ie("", !0),
356
+ (k(!0), X(ve, null, me(oe.value, (n) => {
345
357
  var l;
346
- return H(), M(we, {
358
+ return k(), X(ve, {
347
359
  key: n.key
348
360
  }, [
349
- m.value && n.tile.id === m.value.tileId ? ne("", !0) : (H(), M("div", {
361
+ m.value && n.tile.id === m.value.tileId ? ie("", !0) : (k(), X("div", {
350
362
  key: 0,
351
363
  "data-griddle-tile": n.tile.id,
352
364
  "data-griddle-instance": n.key,
353
- "data-griddle-ghost": ce(n) ? "" : void 0,
354
- "aria-hidden": _(n) ? void 0 : !0,
355
- class: Ie(["griddle-tile", {
356
- "griddle-resizing": ((l = K.value) == null ? void 0 : l.instanceKey) === n.key,
357
- "griddle-selected": g.value && _(n) && P.value.has(n.tile.id)
365
+ "data-griddle-ghost": ue(n) ? "" : void 0,
366
+ "aria-hidden": A(n) ? void 0 : !0,
367
+ class: xe(["griddle-tile", {
368
+ "griddle-resizing": ((l = B.value) == null ? void 0 : l.instanceKey) === n.key,
369
+ "griddle-selected": w.value && A(n) && R.value.has(n.tile.id)
358
370
  }]),
359
- style: $(te(n)),
371
+ style: G(ee(n)),
360
372
  ref_for: !0,
361
- ref: (a) => ze(n.key, a),
362
- onPointerdown: (a) => ae(a, n)
373
+ ref: (a) => be(n.key, a),
374
+ onPointerdown: (a) => le(a, n)
363
375
  }, [
364
- Re(e.$slots, "tile", {
376
+ ye(e.$slots, "tile", {
365
377
  tile: n.tile,
366
- selected: g.value && _(n) && P.value.has(n.tile.id)
378
+ selected: w.value && A(n) && R.value.has(n.tile.id)
367
379
  }),
368
- g.value && _(n) && n.tile.resizable !== !1 ? (H(!0), M(we, { key: 0 }, Se(me(n.tile), (a) => (H(), M("div", {
380
+ w.value && A(n) && n.tile.resizable !== !1 ? (k(!0), X(ve, { key: 0 }, me(we(n.tile), (a) => (k(), X("div", {
369
381
  key: a,
370
382
  "data-griddle-handle": a,
371
- style: $(i(a)),
372
- onPointerdown: (u) => re(u, n, a)
373
- }, null, 44, vt))), 128)) : ne("", !0)
374
- ], 46, ct))
383
+ style: G(i(a)),
384
+ onPointerdown: (u) => ae(u, n, a)
385
+ }, null, 44, rt))), 128)) : ie("", !0)
386
+ ], 46, at))
375
387
  ], 64);
376
388
  }), 128)),
377
- m.value && G.value ? (H(), M("div", {
389
+ m.value && L.value ? (k(), X("div", {
378
390
  key: 1,
379
- "data-griddle-tile": G.value.id,
391
+ "data-griddle-tile": L.value.id,
380
392
  class: "griddle-tile griddle-dragging",
381
- style: $(He.value)
393
+ style: G(Se.value)
382
394
  }, [
383
- Re(e.$slots, "tile", {
384
- tile: G.value,
385
- selected: P.value.has(G.value.id)
395
+ ye(e.$slots, "tile", {
396
+ tile: L.value,
397
+ selected: R.value.has(L.value.id)
386
398
  })
387
- ], 12, pt)) : ne("", !0)
399
+ ], 12, st)) : ie("", !0)
388
400
  ], 4)
389
401
  ], 38));
390
402
  }
391
- }), ht = ["data-griddle-tile", "onPointerdown"], ft = ["data-griddle-handle", "onPointerdown"], mt = "a, button, input, textarea, select, [contenteditable]", xt = 12, St = /* @__PURE__ */ $e({
403
+ }), ct = ["data-griddle-tile", "onPointerdown"], vt = ["data-griddle-handle", "onPointerdown"], pt = "a, button, input, textarea, select, [contenteditable]", gt = 12, mt = /* @__PURE__ */ Te({
392
404
  __name: "GriddleGrid",
393
405
  props: {
394
406
  api: {},
@@ -398,44 +410,44 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
398
410
  selection: {}
399
411
  },
400
412
  emits: ["selectionChange", "drawCreate", "dragStart", "dragEnd", "resizeStart", "resizeEnd", "cameraChange"],
401
- setup(O, { emit: I }) {
402
- const s = O, w = I, B = p(() => {
413
+ setup(_, { emit: C }) {
414
+ const s = _, f = C, O = p(() => {
403
415
  var i;
404
416
  return ((i = s.api.config.value.loop) == null ? void 0 : i.enabled) === !0;
405
- }), Y = E(null), c = E({ scrollX: 0, scrollY: 0, width: 1e3, height: 800 }), d = p(() => s.api.config.value), g = p(() => d.value.gap ?? 0), x = p(() => g.value / 2), b = p(() => d.value.unitWidth + g.value), h = p(() => d.value.unitHeight + g.value), T = p(() => it(d.value, c.value, 4)), se = p(() => nt(s.api.tiles.value, T.value)), N = p(() => ot(d.value, s.api.tiles.value)), A = p(() => {
406
- const i = d.value.scroll !== "none", o = {
417
+ }), Y = H(null), v = H({ scrollX: 0, scrollY: 0, width: 1e3, height: 800 }), r = p(() => s.api.config.value), w = p(() => r.value.gap ?? 0), y = p(() => w.value / 2), b = p(() => r.value.unitWidth + w.value), h = p(() => r.value.unitHeight + w.value), T = p(() => je(r.value, v.value, 4)), re = p(() => Qe(s.api.tiles.value, T.value)), $ = p(() => Ze(r.value, s.api.tiles.value)), N = p(() => {
418
+ const i = r.value.scroll !== "none", o = {
407
419
  position: "relative",
408
420
  overflow: i ? "auto" : "visible",
409
421
  height: i ? s.height ?? "100%" : s.height ?? "auto"
410
422
  };
411
423
  return i && (o.touchAction = "none"), o;
412
- }), U = p(() => {
424
+ }), K = p(() => {
413
425
  const o = s.showGrid !== !1 ? {
414
426
  backgroundImage: "linear-gradient(to right, rgba(0,0,0,0.08) 1px, transparent 1px), linear-gradient(to bottom, rgba(0,0,0,0.08) 1px, transparent 1px)",
415
427
  backgroundSize: `${b.value}px ${h.value}px`
416
428
  } : {};
417
429
  return {
418
430
  position: "relative",
419
- width: N.value.width || "100%",
420
- height: N.value.height || "100%",
431
+ width: $.value.width || "100%",
432
+ height: $.value.height || "100%",
421
433
  minWidth: "100%",
422
434
  minHeight: "100%",
423
435
  // Expose tile radius as a CSS variable so user tile content can pick it up.
424
- "--griddle-tile-radius": (d.value.tileRadius ?? 4) + "px",
436
+ "--griddle-tile-radius": (r.value.tileRadius ?? 4) + "px",
425
437
  ...o
426
438
  };
427
- }), oe = E(/* @__PURE__ */ new Set()), W = p(() => s.selection ?? oe.value), q = p(() => {
439
+ }), ne = H(/* @__PURE__ */ new Set()), W = p(() => s.selection ?? ne.value), J = p(() => {
428
440
  var i;
429
- return new Set(((i = P.value) == null ? void 0 : i.tileIds) ?? []);
441
+ return new Set(((i = R.value) == null ? void 0 : i.tileIds) ?? []);
430
442
  });
431
- function j(i) {
432
- s.selection || (oe.value = i), w("selectionChange", i);
443
+ function q(i) {
444
+ s.selection || (ne.value = i), f("selectionChange", i);
433
445
  }
434
- const le = new Be(s.api.grid), S = new lt(s.api.grid), z = E(null);
435
- let de = 0, ue = 0, F = { x: 1, y: 1 };
436
- const P = E(null), D = E(null), k = E(null), m = E(null);
437
- let L = null;
438
- function he(i) {
446
+ const oe = new Ge(s.api.grid), I = new et(s.api.grid), S = H(null);
447
+ let se = 0, de = 0, E = { x: 1, y: 1 };
448
+ const R = H(null), D = H(null), z = H(null), m = H(null);
449
+ let M = null;
450
+ function pe(i) {
439
451
  const o = s.api.grid.getTile(i.tileId);
440
452
  if (!o) return !1;
441
453
  try {
@@ -443,29 +455,29 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
443
455
  } catch {
444
456
  return !1;
445
457
  }
446
- if (de = i.startPointerX, ue = i.startPointerY, F = Le(Y.value), i.mode === "pin") {
447
- const e = De({
458
+ if (se = i.startPointerX, de = i.startPointerY, E = Re(Y.value), i.mode === "pin") {
459
+ const e = Ee({
448
460
  tile: o,
449
- config: d.value,
450
- scrollX: c.value.scrollX,
451
- scrollY: c.value.scrollY,
452
- viewportWidth: c.value.width,
453
- viewportHeight: c.value.height
454
- }), t = o.position === "fixed" ? { x: e.left - c.value.scrollX, y: e.top - c.value.scrollY } : { x: e.left, y: e.top };
461
+ config: r.value,
462
+ scrollX: v.value.scrollX,
463
+ scrollY: v.value.scrollY,
464
+ viewportWidth: v.value.width,
465
+ viewportHeight: v.value.height
466
+ }), t = o.position === "fixed" ? { x: e.left - v.value.scrollX, y: e.top - v.value.scrollY } : { x: e.left, y: e.top };
455
467
  return D.value = {
456
468
  tileId: o.id,
457
469
  startPinPx: t,
458
470
  startPointerX: i.startPointerX,
459
471
  startPointerY: i.startPointerY
460
- }, w("dragStart", o.id), !0;
472
+ }, f("dragStart", o.id), !0;
461
473
  }
462
- return i.mode === "group" ? S.start(i.groupTileIds) ? (P.value = {
474
+ return i.mode === "group" ? I.start(i.groupTileIds) ? (R.value = {
463
475
  tileIds: i.groupTileIds,
464
476
  deltaX: 0,
465
477
  deltaY: 0,
466
478
  committedDcol: 0,
467
479
  committedDrow: 0
468
- }, w("dragStart", o.id), !0) : !1 : le.start(o.id) ? (z.value = {
480
+ }, f("dragStart", o.id), !0) : !1 : oe.start(o.id) ? (S.value = {
469
481
  tileId: o.id,
470
482
  pickupCol: o.col,
471
483
  pickupRow: o.row,
@@ -473,15 +485,15 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
473
485
  deltaY: 0,
474
486
  indicatorCol: o.col,
475
487
  indicatorRow: o.row
476
- }, w("dragStart", o.id), !0) : !1;
488
+ }, f("dragStart", o.id), !0) : !1;
477
489
  }
478
- function K(i, o) {
490
+ function B(i, o) {
479
491
  if (i.button !== 0 || o.draggable === !1 || i.target.dataset.griddleHandle) return;
480
- const e = d.value.dragIgnoreFrom ?? mt;
492
+ const e = r.value.dragIgnoreFrom ?? pt;
481
493
  if (e && i.target.closest(e)) return;
482
494
  const t = i.metaKey || i.ctrlKey;
483
- if (d.value.enablePositioning && rt(o)) {
484
- L = {
495
+ if (r.value.enablePositioning && it(o)) {
496
+ M = {
485
497
  pointerId: i.pointerId,
486
498
  tileId: o.id,
487
499
  tileElement: i.currentTarget,
@@ -495,13 +507,13 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
495
507
  if (t) {
496
508
  i.preventDefault();
497
509
  const u = new Set(W.value);
498
- u.has(o.id) ? u.delete(o.id) : u.add(o.id), j(u), i.stopPropagation();
510
+ u.has(o.id) ? u.delete(o.id) : u.add(o.id), q(u), i.stopPropagation();
499
511
  return;
500
512
  }
501
513
  const n = W.value.has(o.id);
502
- n || j(/* @__PURE__ */ new Set([o.id]));
514
+ n || q(/* @__PURE__ */ new Set([o.id]));
503
515
  const l = n ? W.value : /* @__PURE__ */ new Set([o.id]), a = Array.from(l);
504
- L = {
516
+ M = {
505
517
  pointerId: i.pointerId,
506
518
  tileId: o.id,
507
519
  tileElement: i.currentTarget,
@@ -511,17 +523,26 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
511
523
  groupTileIds: a
512
524
  }, i.stopPropagation();
513
525
  }
514
- function fe(i) {
526
+ function ge(i) {
515
527
  var u;
516
- if (i.target.closest("[data-griddle-tile]") || ((u = d.value.interactive) == null ? void 0 : u.drawToCreate) === !1) return;
517
- j(/* @__PURE__ */ new Set());
528
+ if (i.target.closest("[data-griddle-tile]") || ((u = r.value.interactive) == null ? void 0 : u.drawToCreate) === !1) return;
529
+ q(/* @__PURE__ */ new Set());
518
530
  const o = Y.value;
519
531
  if (!o) return;
520
- const e = o.getBoundingClientRect(), t = i.clientX - e.left + o.scrollLeft, n = i.clientY - e.top + o.scrollTop, l = Math.floor(t / b.value), a = Math.floor(n / h.value);
532
+ E = Re(o);
533
+ const e = o.getBoundingClientRect(), t = (i.clientX - e.left) / E.x + o.scrollLeft, n = (i.clientY - e.top) / E.y + o.scrollTop, l = fe(
534
+ Math.floor(t / b.value),
535
+ r.value.cols,
536
+ r.value.infiniteX ?? r.value.cols === 1 / 0
537
+ ), a = fe(
538
+ Math.floor(n / h.value),
539
+ r.value.rows,
540
+ r.value.infiniteY ?? r.value.rows === 1 / 0
541
+ );
521
542
  m.value = { anchorCol: l, anchorRow: a, currentCol: l, currentRow: a }, o.setPointerCapture(i.pointerId);
522
543
  }
523
- function _(i, o, e) {
524
- o.resizable !== !1 && (i.currentTarget.setPointerCapture(i.pointerId), F = Le(Y.value), k.value = {
544
+ function A(i, o, e) {
545
+ o.resizable !== !1 && (i.currentTarget.setPointerCapture(i.pointerId), E = Re(Y.value), z.value = {
525
546
  tileId: o.id,
526
547
  corner: e,
527
548
  startPointerX: i.clientX,
@@ -534,207 +555,227 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
534
555
  previewH: o.h,
535
556
  previewCol: o.col,
536
557
  previewRow: o.row
537
- }, w("resizeStart", o.id), i.stopPropagation());
558
+ }, f("resizeStart", o.id), i.stopPropagation());
538
559
  }
539
- function ce(i) {
560
+ function ue(i) {
540
561
  var a, u;
541
562
  if (m.value) {
542
- const r = Y.value;
543
- if (r) {
544
- const v = r.getBoundingClientRect(), f = i.clientX - v.left + r.scrollLeft, C = i.clientY - v.top + r.scrollTop, y = Math.max(0, Math.floor(f / b.value)), R = Math.max(0, Math.floor(C / h.value));
545
- m.value = { ...m.value, currentCol: y, currentRow: R };
563
+ const d = Y.value;
564
+ if (d) {
565
+ const c = d.getBoundingClientRect(), x = (i.clientX - c.left) / E.x + d.scrollLeft, P = (i.clientY - c.top) / E.y + d.scrollTop, g = fe(
566
+ Math.floor(x / b.value),
567
+ r.value.cols,
568
+ r.value.infiniteX ?? r.value.cols === 1 / 0
569
+ ), F = fe(
570
+ Math.floor(P / h.value),
571
+ r.value.rows,
572
+ r.value.infiniteY ?? r.value.rows === 1 / 0
573
+ );
574
+ m.value = { ...m.value, currentCol: g, currentRow: F };
546
575
  }
547
576
  return;
548
577
  }
549
- const o = L;
578
+ const o = M;
550
579
  if (o && i.pointerId === o.pointerId) {
551
580
  if (Math.hypot(
552
581
  i.clientX - o.startPointerX,
553
582
  i.clientY - o.startPointerY
554
- ) <= xt || (L = null, !he(o))) return;
583
+ ) <= gt || (M = null, !pe(o))) return;
555
584
  i.preventDefault();
556
585
  }
557
- const e = D.value, t = P.value, n = z.value, l = k.value;
586
+ const e = D.value, t = R.value, n = S.value, l = z.value;
558
587
  if (e) {
559
- const { dx: r, dy: v } = Ce(
588
+ const { dx: d, dy: c } = he(
560
589
  i.clientX - e.startPointerX,
561
590
  i.clientY - e.startPointerY,
562
- F
563
- ), f = { x: e.startPinPx.x + r, y: e.startPinPx.y + v }, C = st(f, d.value);
564
- s.api.grid.setTilePinned(e.tileId, C);
591
+ E
592
+ ), x = { x: e.startPinPx.x + d, y: e.startPinPx.y + c }, P = nt(x, r.value);
593
+ s.api.grid.setTilePinned(e.tileId, P);
565
594
  }
566
595
  if (t) {
567
- const { dx: r, dy: v } = Ce(
568
- i.clientX - de,
569
- i.clientY - ue,
570
- F
571
- ), f = Math.round(r / b.value), C = Math.round(v / h.value), y = S.update({ dcol: f, drow: C });
572
- P.value = {
596
+ const { dx: d, dy: c } = he(
597
+ i.clientX - se,
598
+ i.clientY - de,
599
+ E
600
+ ), x = Math.round(d / b.value), P = Math.round(c / h.value), g = I.update({ dcol: x, drow: P });
601
+ R.value = {
573
602
  ...t,
574
- deltaX: r,
575
- deltaY: v,
576
- committedDcol: ((a = y.indicatorDelta) == null ? void 0 : a.dcol) ?? t.committedDcol,
577
- committedDrow: ((u = y.indicatorDelta) == null ? void 0 : u.drow) ?? t.committedDrow
578
- }, y.changed && ae();
603
+ deltaX: d,
604
+ deltaY: c,
605
+ committedDcol: ((a = g.indicatorDelta) == null ? void 0 : a.dcol) ?? t.committedDcol,
606
+ committedDrow: ((u = g.indicatorDelta) == null ? void 0 : u.drow) ?? t.committedDrow
607
+ }, g.changed && le();
579
608
  }
580
609
  if (n) {
581
- const { dx: r, dy: v } = Ce(
582
- i.clientX - de,
583
- i.clientY - ue,
584
- F
585
- ), f = n.pickupCol + Math.round(r / b.value), C = n.pickupRow + Math.round(v / h.value), y = le.update({ col: f, row: C });
586
- z.value = {
610
+ const { dx: d, dy: c } = he(
611
+ i.clientX - se,
612
+ i.clientY - de,
613
+ E
614
+ ), x = n.pickupCol + Math.round(d / b.value), P = n.pickupRow + Math.round(c / h.value), g = oe.update({ col: x, row: P });
615
+ S.value = {
587
616
  ...n,
588
- deltaX: r,
589
- deltaY: v,
590
- indicatorCol: y.indicatorCell ? y.indicatorCell.col : null,
591
- indicatorRow: y.indicatorCell ? y.indicatorCell.row : null
592
- }, y.changed && ae();
617
+ deltaX: d,
618
+ deltaY: c,
619
+ indicatorCol: g.indicatorCell ? g.indicatorCell.col : null,
620
+ indicatorRow: g.indicatorCell ? g.indicatorCell.row : null
621
+ }, g.changed && le();
593
622
  }
594
623
  if (l) {
595
- const { dx: r, dy: v } = Ce(
624
+ const { dx: d, dy: c } = he(
596
625
  i.clientX - l.startPointerX,
597
626
  i.clientY - l.startPointerY,
598
- F
599
- );
600
- let f = 0, C = 0, y = 0, R = 0;
601
- const ve = Math.round(r / b.value), pe = Math.round(v / h.value);
602
- (l.corner === "se" || l.corner === "ne") && (f = ve), (l.corner === "se" || l.corner === "sw") && (C = pe), (l.corner === "sw" || l.corner === "nw") && (f = -ve, y = ve), (l.corner === "ne" || l.corner === "nw") && (C = -pe, R = pe);
603
- const X = s.api.grid.getTile(l.tileId), Ee = (X == null ? void 0 : X.minW) ?? 1, xe = (X == null ? void 0 : X.minH) ?? 1, ye = (X == null ? void 0 : X.maxW) ?? 1 / 0, be = (X == null ? void 0 : X.maxH) ?? 1 / 0, ge = Math.min(ye, Math.max(Ee, l.startW + f)), Xe = Math.min(be, Math.max(xe, l.startH + C)), Ye = l.startCol + y, Te = l.startRow + R;
604
- (ge !== l.previewW || Xe !== l.previewH || Ye !== l.previewCol || Te !== l.previewRow) && (k.value = { ...l, previewW: ge, previewH: Xe, previewCol: Ye, previewRow: Te });
627
+ E
628
+ ), x = Math.round(d / b.value), P = Math.round(c / h.value), g = s.api.grid.getTile(l.tileId), F = Ne({
629
+ corner: l.corner,
630
+ startCol: l.startCol,
631
+ startRow: l.startRow,
632
+ startW: l.startW,
633
+ startH: l.startH,
634
+ stepsX: x,
635
+ stepsY: P,
636
+ minW: (g == null ? void 0 : g.minW) ?? 1,
637
+ minH: (g == null ? void 0 : g.minH) ?? 1,
638
+ maxW: (g == null ? void 0 : g.maxW) ?? 1 / 0,
639
+ maxH: (g == null ? void 0 : g.maxH) ?? 1 / 0,
640
+ cols: r.value.cols,
641
+ rows: r.value.rows,
642
+ infiniteX: r.value.infiniteX ?? r.value.cols === 1 / 0,
643
+ infiniteY: r.value.infiniteY ?? r.value.rows === 1 / 0
644
+ }), ce = F.w, Pe = F.h, ke = F.col, He = F.row;
645
+ (ce !== l.previewW || Pe !== l.previewH || ke !== l.previewCol || He !== l.previewRow) && (z.value = { ...l, previewW: ce, previewH: Pe, previewCol: ke, previewRow: He });
605
646
  }
606
647
  }
607
- function ae() {
648
+ function le() {
608
649
  s.api.tiles.value = s.api.grid.tiles, s.api.version.value++;
609
650
  }
610
- function re(i) {
611
- if ((L == null ? void 0 : L.pointerId) === i.pointerId) {
612
- L = null;
651
+ function ae(i) {
652
+ if ((M == null ? void 0 : M.pointerId) === i.pointerId) {
653
+ M = null;
613
654
  return;
614
655
  }
615
656
  if (m.value) {
616
657
  const e = m.value, t = Math.min(e.anchorCol, e.currentCol), n = Math.min(e.anchorRow, e.currentRow), l = Math.max(1, Math.abs(e.currentCol - e.anchorCol) + 1), a = Math.max(1, Math.abs(e.currentRow - e.anchorRow) + 1);
617
- m.value = null, w("drawCreate", { col: t, row: n, w: l, h: a });
658
+ m.value = null, f("drawCreate", { col: t, row: n, w: l, h: a });
618
659
  return;
619
660
  }
620
661
  if (D.value) {
621
662
  const e = D.value.tileId;
622
- D.value = null, w("dragEnd", e, !0);
663
+ D.value = null, f("dragEnd", e, !0);
623
664
  }
624
- if (P.value) {
625
- const e = P.value.tileIds, { committed: t } = S.end();
626
- P.value = null, ae();
665
+ if (R.value) {
666
+ const e = R.value.tileIds, { committed: t } = I.end();
667
+ R.value = null, le();
627
668
  const n = e[0];
628
- n !== void 0 && w("dragEnd", n, t);
669
+ n !== void 0 && f("dragEnd", n, t);
629
670
  }
630
- if (z.value) {
631
- const e = z.value.tileId, { committed: t } = le.end();
632
- z.value = null, ae(), w("dragEnd", e, t);
671
+ if (S.value) {
672
+ const e = S.value.tileId, { committed: t } = oe.end();
673
+ S.value = null, le(), f("dragEnd", e, t);
633
674
  }
634
- const o = k.value;
675
+ const o = z.value;
635
676
  if (o) {
636
677
  const e = s.api.grid.getTile(o.tileId);
637
678
  let t = !1;
638
- e && ((o.previewCol !== e.col || o.previewRow !== e.row) && s.api.moveTile(o.tileId, { col: o.previewCol, row: o.previewRow }), o.previewW !== e.w || o.previewH !== e.h ? t = s.api.resizeTile(o.tileId, { w: o.previewW, h: o.previewH }) : t = o.previewCol !== o.startCol || o.previewRow !== o.startRow || o.previewW !== o.startW || o.previewH !== o.startH), k.value = null, w("resizeEnd", o.tileId, t);
679
+ e && ((o.previewCol !== e.col || o.previewRow !== e.row) && s.api.moveTile(o.tileId, { col: o.previewCol, row: o.previewRow }), o.previewW !== e.w || o.previewH !== e.h ? t = s.api.resizeTile(o.tileId, { w: o.previewW, h: o.previewH }) : t = o.previewCol !== o.startCol || o.previewRow !== o.startRow || o.previewW !== o.startW || o.previewH !== o.startH), z.value = null, f("resizeEnd", o.tileId, t);
639
680
  }
640
681
  }
641
- function Q() {
682
+ function j() {
642
683
  const i = Y.value;
643
- i && (c.value = {
684
+ i && (v.value = {
644
685
  scrollX: i.scrollLeft,
645
686
  scrollY: i.scrollTop,
646
687
  width: i.clientWidth,
647
688
  height: i.clientHeight
648
689
  });
649
690
  }
650
- function Z(i) {
651
- i.key === "Escape" && j(/* @__PURE__ */ new Set());
691
+ function Q(i) {
692
+ i.key === "Escape" && q(/* @__PURE__ */ new Set());
652
693
  }
653
- let V = null;
654
- Ne(() => {
655
- Q();
694
+ let U = null;
695
+ We(() => {
696
+ j();
656
697
  const i = Y.value;
657
- i && (i.addEventListener("scroll", Q, { passive: !0 }), V = new ResizeObserver(Q), V.observe(i)), window.addEventListener("pointermove", ce), window.addEventListener("pointerup", re), window.addEventListener("pointercancel", re), window.addEventListener("keydown", Z);
658
- }), Ae(() => {
659
- L = null;
698
+ i && (i.addEventListener("scroll", j, { passive: !0 }), U = new ResizeObserver(j), U.observe(i)), window.addEventListener("pointermove", ue), window.addEventListener("pointerup", ae), window.addEventListener("pointercancel", ae), window.addEventListener("keydown", Q);
699
+ }), De(() => {
700
+ M = null;
660
701
  const i = Y.value;
661
- i && i.removeEventListener("scroll", Q), V == null || V.disconnect(), window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", re), window.removeEventListener("pointercancel", re), window.removeEventListener("keydown", Z);
702
+ i && i.removeEventListener("scroll", j), U == null || U.disconnect(), window.removeEventListener("pointermove", ue), window.removeEventListener("pointerup", ae), window.removeEventListener("pointercancel", ae), window.removeEventListener("keydown", Q);
662
703
  });
663
- const ee = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map();
664
- function ze(i, o) {
665
- o ? ee.set(i, o) : ee.delete(i);
704
+ const Z = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
705
+ function be(i, o) {
706
+ o ? Z.set(i, o) : Z.delete(i);
666
707
  }
667
- Me(() => s.api.version.value, async () => {
708
+ ze(() => s.api.version.value, async () => {
668
709
  var e;
669
- await _e();
670
- const i = ((e = z.value) == null ? void 0 : e.tileId) ?? null, o = q.value;
710
+ await Me();
711
+ const i = ((e = S.value) == null ? void 0 : e.tileId) ?? null, o = J.value;
671
712
  for (const t of s.api.tiles.value) {
672
- const n = t.col * b.value + x.value, l = t.row * h.value + x.value;
713
+ const n = t.col * b.value + y.value, l = t.row * h.value + y.value;
673
714
  if (t.id === i || o.has(t.id)) {
674
- J.set(t.id, { x: n, y: l });
715
+ V.set(t.id, { x: n, y: l });
675
716
  continue;
676
717
  }
677
- const a = J.get(t.id), u = ee.get(t.id);
718
+ const a = V.get(t.id), u = Z.get(t.id);
678
719
  if (a && u) {
679
- const r = a.x - n, v = a.y - l;
680
- (r !== 0 || v !== 0) && Fe(u, r, v, d.value.animation);
720
+ const d = a.x - n, c = a.y - l;
721
+ (d !== 0 || c !== 0) && $e(u, d, c, r.value.animation);
681
722
  }
682
- J.set(t.id, { x: n, y: l });
723
+ V.set(t.id, { x: n, y: l });
683
724
  }
684
725
  });
685
- const Pe = p(() => {
726
+ const Ce = p(() => {
686
727
  var n, l;
687
- const i = /* @__PURE__ */ new Map(), o = [], e = P.value, t = q.value;
688
- for (const a of se.value) {
728
+ const i = /* @__PURE__ */ new Map(), o = [], e = R.value, t = J.value;
729
+ for (const a of re.value) {
689
730
  let u;
690
- if (((n = k.value) == null ? void 0 : n.tileId) === a.id) {
691
- const r = k.value.previewW, v = k.value.previewH;
731
+ if (((n = z.value) == null ? void 0 : n.tileId) === a.id) {
732
+ const d = z.value.previewW, c = z.value.previewH;
692
733
  u = {
693
- left: k.value.previewCol * b.value + x.value,
694
- top: k.value.previewRow * h.value + x.value,
695
- width: r * d.value.unitWidth + (r - 1) * g.value,
696
- height: v * d.value.unitHeight + (v - 1) * g.value,
734
+ left: z.value.previewCol * b.value + y.value,
735
+ top: z.value.previewRow * h.value + y.value,
736
+ width: d * r.value.unitWidth + (d - 1) * w.value,
737
+ height: c * r.value.unitHeight + (c - 1) * w.value,
697
738
  zIndex: 10,
698
739
  effective: "static"
699
740
  };
700
- } else if (((l = z.value) == null ? void 0 : l.tileId) === a.id) {
701
- const r = z.value;
741
+ } else if (((l = S.value) == null ? void 0 : l.tileId) === a.id) {
742
+ const d = S.value;
702
743
  u = {
703
- left: r.pickupCol * b.value + x.value,
704
- top: r.pickupRow * h.value + x.value,
705
- width: a.w * d.value.unitWidth + (a.w - 1) * g.value,
706
- height: a.h * d.value.unitHeight + (a.h - 1) * g.value,
707
- transform: `translate(${r.deltaX}px, ${r.deltaY}px)`,
744
+ left: d.pickupCol * b.value + y.value,
745
+ top: d.pickupRow * h.value + y.value,
746
+ width: a.w * r.value.unitWidth + (a.w - 1) * w.value,
747
+ height: a.h * r.value.unitHeight + (a.h - 1) * w.value,
748
+ transform: `translate(${d.deltaX}px, ${d.deltaY}px)`,
708
749
  zIndex: 20,
709
750
  effective: "static"
710
751
  };
711
752
  } else if (e && t.has(a.id)) {
712
- const r = S.pickupCell(a.id), v = (r ? r.col * b.value : a.col * b.value) + x.value, f = (r ? r.row * h.value : a.row * h.value) + x.value;
753
+ const d = I.pickupCell(a.id), c = (d ? d.col * b.value : a.col * b.value) + y.value, x = (d ? d.row * h.value : a.row * h.value) + y.value;
713
754
  u = {
714
- left: v,
715
- top: f,
716
- width: a.w * d.value.unitWidth + (a.w - 1) * g.value,
717
- height: a.h * d.value.unitHeight + (a.h - 1) * g.value,
755
+ left: c,
756
+ top: x,
757
+ width: a.w * r.value.unitWidth + (a.w - 1) * w.value,
758
+ height: a.h * r.value.unitHeight + (a.h - 1) * w.value,
718
759
  transform: `translate(${e.deltaX}px, ${e.deltaY}px)`,
719
760
  zIndex: 20,
720
761
  effective: "static"
721
762
  };
722
763
  } else
723
- u = De({
764
+ u = Ee({
724
765
  tile: a,
725
- config: d.value,
726
- scrollX: c.value.scrollX,
727
- scrollY: c.value.scrollY,
728
- viewportWidth: c.value.width,
729
- viewportHeight: c.value.height
766
+ config: r.value,
767
+ scrollX: v.value.scrollX,
768
+ scrollY: v.value.scrollY,
769
+ viewportWidth: v.value.width,
770
+ viewportHeight: v.value.height
730
771
  }), u.effective === "sticky" && o.push({ tile: a, layout: u });
731
772
  i.set(a.id, u);
732
773
  }
733
- return o.length > 1 && at(o), i;
774
+ return o.length > 1 && tt(o), i;
734
775
  });
735
- function ke(i) {
736
- var r, v, f;
737
- const o = ((r = z.value) == null ? void 0 : r.tileId) === i.id, e = q.value.has(i.id) && P.value !== null, t = ((v = D.value) == null ? void 0 : v.tileId) === i.id, n = ((f = k.value) == null ? void 0 : f.tileId) === i.id, l = W.value.has(i.id), a = Pe.value.get(i.id) ?? {
776
+ function Ie(i) {
777
+ var d, c, x;
778
+ const o = ((d = S.value) == null ? void 0 : d.tileId) === i.id, e = J.value.has(i.id) && R.value !== null, t = ((c = D.value) == null ? void 0 : c.tileId) === i.id, n = ((x = z.value) == null ? void 0 : x.tileId) === i.id, l = W.value.has(i.id), a = Ce.value.get(i.id) ?? {
738
779
  left: 0,
739
780
  top: 0,
740
781
  width: 0,
@@ -755,37 +796,37 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
755
796
  willChange: "transform, translate",
756
797
  transform: a.transform ?? "",
757
798
  filter: u ? "drop-shadow(0 8px 16px rgba(0,0,0,0.18))" : "",
758
- transition: u ? ut(d.value.animation) : "",
799
+ transition: u ? lt(r.value.animation) : "",
759
800
  boxShadow: l ? "0 0 0 3px rgba(59, 91, 219, 0.85), inset 0 0 0 1px rgba(59, 91, 219, 0.3)" : "",
760
- borderRadius: (d.value.tileRadius ?? 4) + "px"
801
+ borderRadius: (r.value.tileRadius ?? 4) + "px"
761
802
  };
762
803
  }
763
- const te = p(() => {
764
- const i = z.value;
804
+ const ee = p(() => {
805
+ const i = S.value;
765
806
  if (!i || i.indicatorCol === null || i.indicatorRow === null) return null;
766
807
  const o = s.api.grid.getTile(i.tileId);
767
808
  return o ? {
768
- left: i.indicatorCol * b.value + x.value,
769
- top: i.indicatorRow * h.value + x.value,
770
- width: o.w * d.value.unitWidth + (o.w - 1) * g.value,
771
- height: o.h * d.value.unitHeight + (o.h - 1) * g.value
809
+ left: i.indicatorCol * b.value + y.value,
810
+ top: i.indicatorRow * h.value + y.value,
811
+ width: o.w * r.value.unitWidth + (o.w - 1) * w.value,
812
+ height: o.h * r.value.unitHeight + (o.h - 1) * w.value
772
813
  } : null;
773
- }), G = p(() => {
814
+ }), L = p(() => {
774
815
  const i = m.value;
775
816
  if (!i) return null;
776
817
  const o = Math.min(i.anchorCol, i.currentCol), e = Math.min(i.anchorRow, i.currentRow), t = Math.max(1, Math.abs(i.currentCol - i.anchorCol) + 1), n = Math.max(1, Math.abs(i.currentRow - i.anchorRow) + 1);
777
818
  return {
778
- left: o * b.value + x.value,
779
- top: e * h.value + x.value,
780
- width: t * d.value.unitWidth + (t - 1) * g.value,
781
- height: n * d.value.unitHeight + (n - 1) * g.value,
819
+ left: o * b.value + y.value,
820
+ top: e * h.value + y.value,
821
+ width: t * r.value.unitWidth + (t - 1) * w.value,
822
+ height: n * r.value.unitHeight + (n - 1) * w.value,
782
823
  label: `${t}×${n}`
783
824
  };
784
825
  });
785
- function He(i) {
786
- return i.resizeHandles ?? d.value.resizeHandles ?? ["se"];
826
+ function Se(i) {
827
+ return i.resizeHandles ?? r.value.resizeHandles ?? ["se"];
787
828
  }
788
- function ie(i) {
829
+ function te(i) {
789
830
  const e = {
790
831
  position: "absolute",
791
832
  width: "12px",
@@ -798,66 +839,66 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
798
839
  };
799
840
  return i === "nw" ? { ...e, top: -12 / 2 + "px", left: -12 / 2 + "px" } : i === "ne" ? { ...e, top: -12 / 2 + "px", right: -12 / 2 + "px" } : i === "sw" ? { ...e, bottom: -12 / 2 + "px", left: -12 / 2 + "px" } : { ...e, bottom: -12 / 2 + "px", right: -12 / 2 + "px" };
800
841
  }
801
- const me = p(() => s.className ?? "");
802
- return (i, o) => B.value ? (H(), Ke(wt, {
842
+ const we = p(() => s.className ?? "");
843
+ return (i, o) => O.value ? (k(), Ae(ut, {
803
844
  key: 0,
804
- api: O.api,
805
- "class-name": me.value,
806
- height: O.height,
807
- "show-grid": O.showGrid,
845
+ api: _.api,
846
+ "class-name": we.value,
847
+ height: _.height,
848
+ "show-grid": _.showGrid,
808
849
  selection: s.selection,
809
- onSelectionChange: o[0] || (o[0] = (e) => w("selectionChange", e)),
810
- onDragStart: o[1] || (o[1] = (e) => w("dragStart", e)),
811
- onDragEnd: o[2] || (o[2] = (e, t) => w("dragEnd", e, t)),
812
- onResizeStart: o[3] || (o[3] = (e) => w("resizeStart", e)),
813
- onResizeEnd: o[4] || (o[4] = (e, t) => w("resizeEnd", e, t)),
814
- onCameraChange: o[5] || (o[5] = (e) => w("cameraChange", e))
850
+ onSelectionChange: o[0] || (o[0] = (e) => f("selectionChange", e)),
851
+ onDragStart: o[1] || (o[1] = (e) => f("dragStart", e)),
852
+ onDragEnd: o[2] || (o[2] = (e, t) => f("dragEnd", e, t)),
853
+ onResizeStart: o[3] || (o[3] = (e) => f("resizeStart", e)),
854
+ onResizeEnd: o[4] || (o[4] = (e, t) => f("resizeEnd", e, t)),
855
+ onCameraChange: o[5] || (o[5] = (e) => f("cameraChange", e))
815
856
  }, {
816
- tile: Ue((e) => [
817
- Re(i.$slots, "tile", Ve(Je(e)))
857
+ tile: _e((e) => [
858
+ ye(i.$slots, "tile", Oe(Be(e)))
818
859
  ]),
819
860
  _: 3
820
- }, 8, ["api", "class-name", "height", "show-grid", "selection"])) : (H(), M("div", {
861
+ }, 8, ["api", "class-name", "height", "show-grid", "selection"])) : (k(), X("div", {
821
862
  key: 1,
822
863
  ref_key: "scrollEl",
823
864
  ref: Y,
824
- class: Ie(me.value),
825
- style: $(A.value),
826
- onPointerdown: fe
865
+ class: xe(we.value),
866
+ style: G(N.value),
867
+ onPointerdown: ge
827
868
  }, [
828
- Oe("div", {
829
- style: $(U.value)
869
+ Le("div", {
870
+ style: G(K.value)
830
871
  }, [
831
- te.value ? (H(), M("div", {
872
+ ee.value ? (k(), X("div", {
832
873
  key: 0,
833
874
  class: "griddle-drop-indicator",
834
- style: $({
875
+ style: G({
835
876
  position: "absolute",
836
- left: te.value.left + "px",
837
- top: te.value.top + "px",
838
- width: te.value.width + "px",
839
- height: te.value.height + "px",
877
+ left: ee.value.left + "px",
878
+ top: ee.value.top + "px",
879
+ width: ee.value.width + "px",
880
+ height: ee.value.height + "px",
840
881
  boxSizing: "border-box",
841
882
  border: "2px dashed rgba(59, 91, 219, 0.55)",
842
883
  background: "rgba(59, 91, 219, 0.08)",
843
- borderRadius: (d.value.tileRadius ?? 4) + "px",
884
+ borderRadius: (r.value.tileRadius ?? 4) + "px",
844
885
  pointerEvents: "none",
845
886
  zIndex: 5
846
887
  })
847
- }, null, 4)) : ne("", !0),
848
- G.value ? (H(), M("div", {
888
+ }, null, 4)) : ie("", !0),
889
+ L.value ? (k(), X("div", {
849
890
  key: 1,
850
891
  class: "griddle-draw-ghost",
851
- style: $({
892
+ style: G({
852
893
  position: "absolute",
853
- left: G.value.left + "px",
854
- top: G.value.top + "px",
855
- width: G.value.width + "px",
856
- height: G.value.height + "px",
894
+ left: L.value.left + "px",
895
+ top: L.value.top + "px",
896
+ width: L.value.width + "px",
897
+ height: L.value.height + "px",
857
898
  boxSizing: "border-box",
858
899
  border: "2px dashed rgba(59, 91, 219, 0.55)",
859
900
  background: "rgba(59, 91, 219, 0.08)",
860
- borderRadius: (d.value.tileRadius ?? 4) + "px",
901
+ borderRadius: (r.value.tileRadius ?? 4) + "px",
861
902
  pointerEvents: "none",
862
903
  zIndex: 5,
863
904
  display: "flex",
@@ -868,60 +909,60 @@ const ct = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
868
909
  color: "rgba(59, 91, 219, 0.8)",
869
910
  userSelect: "none"
870
911
  })
871
- }, qe(G.value.label), 5)) : ne("", !0),
872
- (H(!0), M(we, null, Se(se.value, (e) => {
912
+ }, Fe(L.value.label), 5)) : ie("", !0),
913
+ (k(!0), X(ve, null, me(re.value, (e) => {
873
914
  var t, n, l;
874
- return H(), M("div", {
915
+ return k(), X("div", {
875
916
  key: e.id,
876
917
  "data-griddle-tile": e.id,
877
- class: Ie(["griddle-tile", {
878
- "griddle-dragging": ((t = z.value) == null ? void 0 : t.tileId) === e.id || ((n = D.value) == null ? void 0 : n.tileId) === e.id || P.value !== null && q.value.has(e.id),
879
- "griddle-resizing": ((l = k.value) == null ? void 0 : l.tileId) === e.id,
918
+ class: xe(["griddle-tile", {
919
+ "griddle-dragging": ((t = S.value) == null ? void 0 : t.tileId) === e.id || ((n = D.value) == null ? void 0 : n.tileId) === e.id || R.value !== null && J.value.has(e.id),
920
+ "griddle-resizing": ((l = z.value) == null ? void 0 : l.tileId) === e.id,
880
921
  "griddle-selected": W.value.has(e.id)
881
922
  }]),
882
- style: $(ke(e)),
883
- onPointerdown: (a) => K(a, e),
923
+ style: G(Ie(e)),
924
+ onPointerdown: (a) => B(a, e),
884
925
  ref_for: !0,
885
- ref: (a) => ze(e.id, a)
926
+ ref: (a) => be(e.id, a)
886
927
  }, [
887
- Re(i.$slots, "tile", {
928
+ ye(i.$slots, "tile", {
888
929
  tile: e,
889
930
  selected: W.value.has(e.id)
890
931
  }),
891
- e.resizable !== !1 ? (H(!0), M(we, { key: 0 }, Se(He(e), (a) => (H(), M("div", {
932
+ e.resizable !== !1 ? (k(!0), X(ve, { key: 0 }, me(Se(e), (a) => (k(), X("div", {
892
933
  key: a,
893
934
  "data-griddle-handle": a,
894
- style: $(ie(a)),
895
- onPointerdown: (u) => _(u, e, a)
896
- }, null, 44, ft))), 128)) : ne("", !0)
897
- ], 46, ht);
935
+ style: G(te(a)),
936
+ onPointerdown: (u) => A(u, e, a)
937
+ }, null, 44, vt))), 128)) : ie("", !0)
938
+ ], 46, ct);
898
939
  }), 128))
899
940
  ], 4)
900
941
  ], 38));
901
942
  }
902
943
  });
903
- function Rt(O) {
904
- const I = new dt(O.config, O.tiles ?? []), s = We(I.tiles), w = We(I.config), B = E(0), Y = I.changes.on(() => {
905
- s.value = I.tiles, w.value = I.config, B.value++;
944
+ function yt(_) {
945
+ const C = new ot(_.config, _.tiles ?? []), s = Xe(C.tiles), f = Xe(C.config), O = H(0), Y = C.changes.on(() => {
946
+ s.value = C.tiles, f.value = C.config, O.value++;
906
947
  });
907
- return je(Y), {
908
- grid: I,
948
+ return Ke(Y), {
949
+ grid: C,
909
950
  tiles: s,
910
- config: w,
911
- version: B,
912
- moveTile: (d, g) => I.moveTile(d, g),
913
- resizeTile: (d, g) => I.resizeTile(d, g),
914
- addTile: (d) => I.addTile(d),
915
- removeTile: (d) => I.removeTile(d),
916
- reflow: (d) => I.reflow(d),
917
- updateConfig: (d) => I.updateConfig(d),
918
- toJSON: () => I.toJSON(),
919
- loadJSON: (d) => I.loadJSON(d)
951
+ config: f,
952
+ version: O,
953
+ moveTile: (r, w) => C.moveTile(r, w),
954
+ resizeTile: (r, w) => C.resizeTile(r, w),
955
+ addTile: (r) => C.addTile(r),
956
+ removeTile: (r) => C.removeTile(r),
957
+ reflow: (r) => C.reflow(r),
958
+ updateConfig: (r) => C.updateConfig(r),
959
+ toJSON: () => C.toJSON(),
960
+ loadJSON: (r) => C.loadJSON(r)
920
961
  };
921
962
  }
922
963
  export {
923
- St as GriddleGrid,
924
- wt as GriddleLoopGrid,
925
- Rt as useGriddle
964
+ mt as GriddleGrid,
965
+ ut as GriddleLoopGrid,
966
+ yt as useGriddle
926
967
  };
927
968
  //# sourceMappingURL=index.js.map