@griddle/vue 0.1.6 → 0.1.8

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