@griddle/vue 0.1.5 → 0.1.7

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