@griddle/vue 0.1.1 → 0.1.2

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