@griddle/vue 0.1.0 → 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 De, ref as k, computed as w, watch as He, onMounted as Te, 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__ */ De({
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,58 +11,58 @@ 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()), D = 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
  }
@@ -73,152 +74,150 @@ const ot = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
73
74
  }
74
75
  function xe(t, e) {
75
76
  if (!h.value || !T(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))) {
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(D.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
- Te(() => {
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,13 +240,13 @@ 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 && T(t) && D.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",
@@ -256,16 +256,16 @@ const ot = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
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": T(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 && T(o) && D.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 && T(o) && D.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 && T(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: D.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__ */ De({
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,194 +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
- position: "relative",
406
- overflow: "auto",
407
- height: s.height ?? "100%",
408
- touchAction: "none"
409
- })), U = w(() => {
410
- const i = s.showGrid !== !1 ? {
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
+ position: "relative",
407
+ overflow: n ? "auto" : "visible",
408
+ height: n ? s.height ?? "100%" : s.height ?? "auto"
409
+ };
410
+ return n && (o.touchAction = "none"), o;
411
+ }), U = w(() => {
412
+ const o = s.showGrid !== !1 ? {
411
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)",
412
414
  backgroundSize: `${y.value}px ${x.value}px`
413
415
  } : {};
414
416
  return {
415
417
  position: "relative",
416
- width: F.value.width || "100%",
417
- height: F.value.height || "100%",
418
+ width: O.value.width || "100%",
419
+ height: O.value.height || "100%",
418
420
  minWidth: "100%",
419
421
  minHeight: "100%",
420
422
  // Expose tile radius as a CSS variable so user tile content can pick it up.
421
- "--griddle-tile-radius": (u.value.tileRadius ?? 4) + "px",
422
- ...i
423
+ "--griddle-tile-radius": (d.value.tileRadius ?? 4) + "px",
424
+ ...o
423
425
  };
424
- }), 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(() => {
425
427
  var n;
426
- return new Set(((n = Y.value) == null ? void 0 : n.tileIds) ?? []);
428
+ return new Set(((n = W.value) == null ? void 0 : n.tileIds) ?? []);
427
429
  });
428
430
  function Q(n) {
429
- s.selection || (ie.value = n), f("selectionChange", n);
431
+ s.selection || (oe.value = n), f("selectionChange", n);
430
432
  }
431
- const ae = new $e(s.api.grid), C = new Qe(s.api.grid), R = k(null);
432
- let le = 0, re = 0;
433
- const Y = k(null), D = k(null), S = k(null), G = k(null);
434
- function I(n, i) {
435
- if (i.draggable === !1 || n.target.dataset.griddleHandle) return;
436
- const l = u.value.dragIgnoreFrom ?? ut;
437
- 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;
438
440
  const c = n.metaKey || n.ctrlKey;
439
- if (u.value.enablePositioning && et(i)) {
441
+ if (d.value.enablePositioning && tt(o)) {
440
442
  n.currentTarget.setPointerCapture(n.pointerId);
441
443
  const e = We({
442
- tile: i,
443
- config: u.value,
444
+ tile: o,
445
+ config: d.value,
444
446
  scrollX: v.value.scrollX,
445
447
  scrollY: v.value.scrollY,
446
448
  viewportWidth: v.value.width,
447
449
  viewportHeight: v.value.height
448
- }), o = i.position === "fixed" ? { x: e.left - v.value.scrollX, y: e.top - v.value.scrollY } : { x: e.left, y: e.top };
449
- D.value = {
450
- tileId: i.id,
451
- 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,
452
454
  startPointerX: n.clientX,
453
455
  startPointerY: n.clientY
454
- }, f("dragStart", i.id), n.stopPropagation();
456
+ }, f("dragStart", o.id), n.stopPropagation();
455
457
  return;
456
458
  }
457
459
  if (c) {
458
460
  n.preventDefault();
459
- const e = new Set(L.value);
460
- 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();
461
463
  return;
462
464
  }
463
- const d = L.value.has(i.id);
464
- d || Q(/* @__PURE__ */ new Set([i.id])), n.currentTarget.setPointerCapture(n.pointerId);
465
- 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]);
466
468
  if (t.size > 1) {
467
469
  const e = Array.from(t);
468
470
  if (!C.start(e)) return;
469
- le = n.clientX, re = n.clientY, Y.value = {
471
+ ae = n.clientX, re = n.clientY, W.value = {
470
472
  tileIds: e,
471
473
  deltaX: 0,
472
474
  deltaY: 0,
473
475
  committedDcol: 0,
474
476
  committedDrow: 0
475
- }, f("dragStart", i.id), n.stopPropagation();
477
+ }, f("dragStart", o.id), n.stopPropagation();
476
478
  return;
477
479
  }
478
- ae.start(i.id) && (le = n.clientX, re = n.clientY, R.value = {
479
- tileId: i.id,
480
- pickupCol: i.col,
481
- 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,
482
484
  deltaX: 0,
483
485
  deltaY: 0,
484
- indicatorCol: i.col,
485
- indicatorRow: i.row
486
- }, f("dragStart", i.id), n.stopPropagation());
486
+ indicatorCol: o.col,
487
+ indicatorRow: o.row
488
+ }, f("dragStart", o.id), n.stopPropagation());
487
489
  }
488
490
  function he(n) {
489
- if (n.target.closest("[data-griddle-tile]")) return;
491
+ var i;
492
+ if (n.target.closest("[data-griddle-tile]") || ((i = d.value.interactive) == null ? void 0 : i.drawToCreate) === !1) return;
490
493
  Q(/* @__PURE__ */ new Set());
491
- const i = N.value;
492
- if (!i) return;
493
- 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);
494
- 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);
495
498
  }
496
- function fe(n, i, l) {
497
- i.resizable !== !1 && (n.currentTarget.setPointerCapture(n.pointerId), S.value = {
498
- tileId: i.id,
499
- 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,
500
503
  startPointerX: n.clientX,
501
504
  startPointerY: n.clientY,
502
- startW: i.w,
503
- startH: i.h,
504
- startCol: i.col,
505
- startRow: i.row,
506
- previewW: i.w,
507
- previewH: i.h,
508
- previewCol: i.col,
509
- previewRow: i.row
510
- }, 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());
511
514
  }
512
- function _(n) {
515
+ function B(n) {
513
516
  var t, e;
514
- if (G.value) {
515
- const o = N.value;
516
- if (o) {
517
- 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));
518
- 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 };
519
522
  }
520
523
  return;
521
524
  }
522
- const i = D.value, l = Y.value, c = R.value, d = S.value;
523
- if (i) {
524
- 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);
525
- 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);
526
529
  }
527
- if (l) {
528
- 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 });
529
- Y.value = {
530
- ...l,
531
- deltaX: o,
532
- deltaY: a,
533
- committedDcol: ((t = g.indicatorDelta) == null ? void 0 : t.dcol) ?? l.committedDcol,
534
- 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
535
538
  }, g.changed && Z();
536
539
  }
537
540
  if (c) {
538
- 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 });
539
542
  R.value = {
540
543
  ...c,
541
- deltaX: o,
542
- deltaY: a,
544
+ deltaX: i,
545
+ deltaY: l,
543
546
  indicatorCol: g.indicatorCell ? g.indicatorCell.col : null,
544
547
  indicatorRow: g.indicatorCell ? g.indicatorCell.row : null
545
548
  }, g.changed && Z();
546
549
  }
547
- if (d) {
548
- 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;
549
552
  let r = 0, p = 0, g = 0, M = 0;
550
- const E = Math.round(o / y.value), A = Math.round(a / x.value);
551
- (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);
552
- 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;
553
- (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 });
554
557
  }
555
558
  }
556
559
  function Z() {
557
560
  s.api.tiles.value = s.api.grid.tiles, s.api.version.value++;
558
561
  }
559
562
  function T() {
560
- if (G.value) {
561
- 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);
562
- G.value = null, f("drawCreate", { col: l, row: c, w: d, h: 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 });
563
566
  return;
564
567
  }
565
- if (D.value) {
566
- const i = D.value.tileId;
567
- D.value = null, f("dragEnd", i, !0);
568
- }
569
568
  if (Y.value) {
570
- const i = Y.value.tileIds, { committed: l } = C.end();
571
- Y.value = null, Z();
572
- const c = i[0];
573
- 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);
574
577
  }
575
578
  if (R.value) {
576
- const i = R.value.tileId, { committed: l } = ae.end();
577
- 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);
578
581
  }
579
- const n = S.value;
582
+ const n = z.value;
580
583
  if (n) {
581
- const i = s.api.grid.getTile(n.tileId);
582
- let l = !1;
583
- 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);
584
587
  }
585
588
  }
586
589
  function ee() {
587
- const n = N.value;
590
+ const n = $.value;
588
591
  n && (v.value = {
589
592
  scrollX: n.scrollLeft,
590
593
  scrollY: n.scrollTop,
@@ -596,97 +599,95 @@ const ot = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
596
599
  n.key === "Escape" && Q(/* @__PURE__ */ new Set());
597
600
  }
598
601
  let te = null;
599
- Te(() => {
602
+ De(() => {
600
603
  ee();
601
- const n = N.value;
602
- n && (n.addEventListener("scroll", ee, { passive: !0 }), te = new ResizeObserver(ee), te.observe(n)), window.addEventListener("pointermove", _), window.addEventListener("pointerup", T), window.addEventListener("pointercancel", T), 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);
603
606
  }), Me(() => {
604
- const n = N.value;
605
- n && n.removeEventListener("scroll", ee), te == null || te.disconnect(), window.removeEventListener("pointermove", _), window.removeEventListener("pointerup", T), window.removeEventListener("pointercancel", T), 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);
606
609
  });
607
610
  const se = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
608
- function me(n, i) {
609
- i ? se.set(n, i) : se.delete(n);
611
+ function me(n, o) {
612
+ o ? se.set(n, o) : se.delete(n);
610
613
  }
611
614
  He(() => s.api.version.value, async () => {
612
- var l;
615
+ var a;
613
616
  await Le();
614
- 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;
615
618
  for (const c of s.api.tiles.value) {
616
- const d = c.col * y.value + m.value, t = c.row * x.value + m.value;
617
- if (c.id === n || i.has(c.id)) {
618
- 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 });
619
622
  continue;
620
623
  }
621
- const e = V.get(c.id), o = se.get(c.id);
622
- if (e && o) {
623
- const a = e.x - d, r = e.y - t;
624
- (a !== 0 || r !== 0) && (o.style.transition = "none", o.style.transform = `translate(${a}px, ${r}px)`, requestAnimationFrame(() => {
625
- o.style.transition = "transform 220ms cubic-bezier(.2,.7,.2,1)", o.style.transform = "translate(0,0)";
626
- }));
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);
627
628
  }
628
- V.set(c.id, { x: d, y: t });
629
+ V.set(c.id, { x: u, y: t });
629
630
  }
630
631
  });
631
632
  const ce = w(() => {
632
- var d, t;
633
- 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;
634
635
  for (const e of ue.value) {
635
- let o;
636
- if (((d = S.value) == null ? void 0 : d.tileId) === e.id) {
637
- const a = S.value.previewW, r = S.value.previewH;
638
- o = {
639
- left: S.value.previewCol * y.value + m.value,
640
- top: S.value.previewRow * x.value + m.value,
641
- width: a * u.value.unitWidth + (a - 1) * h.value,
642
- 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,
643
644
  zIndex: 10,
644
645
  effective: "static"
645
646
  };
646
647
  } else if (((t = R.value) == null ? void 0 : t.tileId) === e.id) {
647
- const a = R.value;
648
- o = {
649
- left: a.pickupCol * y.value + m.value,
650
- top: a.pickupRow * x.value + m.value,
651
- width: e.w * u.value.unitWidth + (e.w - 1) * h.value,
652
- height: e.h * u.value.unitHeight + (e.h - 1) * h.value,
653
- 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)`,
654
655
  zIndex: 20,
655
656
  effective: "static"
656
657
  };
657
- } else if (l && c.has(e.id)) {
658
- 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;
659
- 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 = {
660
661
  left: r,
661
662
  top: p,
662
- width: e.w * u.value.unitWidth + (e.w - 1) * h.value,
663
- height: e.h * u.value.unitHeight + (e.h - 1) * h.value,
664
- 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)`,
665
666
  zIndex: 20,
666
667
  effective: "static"
667
668
  };
668
669
  } else
669
- o = We({
670
+ i = We({
670
671
  tile: e,
671
- config: u.value,
672
+ config: d.value,
672
673
  scrollX: v.value.scrollX,
673
674
  scrollY: v.value.scrollY,
674
675
  viewportWidth: v.value.width,
675
676
  viewportHeight: v.value.height
676
- }), o.effective === "sticky" && i.push({ tile: e, layout: o });
677
- n.set(e.id, o);
677
+ }), i.effective === "sticky" && o.push({ tile: e, layout: i });
678
+ n.set(e.id, i);
678
679
  }
679
- return i.length > 1 && Ze(i), n;
680
+ return o.length > 1 && et(o), n;
680
681
  });
681
682
  function de(n) {
682
- var a, r, p;
683
- const i = ((a = R.value) == null ? void 0 : a.tileId) === n.id, l = j.value.has(n.id) && Y.value !== null, c = ((r = D.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) ?? {
684
685
  left: 0,
685
686
  top: 0,
686
687
  width: 0,
687
688
  height: 0,
688
689
  zIndex: 1
689
- }, o = i || c || l;
690
+ }, i = o || c || a;
690
691
  return {
691
692
  position: "absolute",
692
693
  left: e.left + "px",
@@ -694,45 +695,45 @@ const ot = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
694
695
  width: e.width + "px",
695
696
  height: e.height + "px",
696
697
  boxSizing: "border-box",
697
- cursor: o ? "grabbing" : "grab",
698
+ cursor: i ? "grabbing" : "grab",
698
699
  userSelect: "none",
699
700
  zIndex: e.zIndex,
700
- opacity: o || d ? 0.85 : 1,
701
- willChange: "transform",
701
+ opacity: i || u ? 0.85 : 1,
702
+ willChange: "transform, translate",
702
703
  transform: e.transform ?? "",
703
- filter: o ? "drop-shadow(0 8px 16px rgba(0,0,0,0.18))" : "",
704
- 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) : "",
705
706
  boxShadow: t ? "0 0 0 3px rgba(59, 91, 219, 0.85), inset 0 0 0 1px rgba(59, 91, 219, 0.3)" : "",
706
- borderRadius: (u.value.tileRadius ?? 4) + "px"
707
+ borderRadius: (d.value.tileRadius ?? 4) + "px"
707
708
  };
708
709
  }
709
710
  const ne = w(() => {
710
711
  const n = R.value;
711
712
  if (!n || n.indicatorCol === null || n.indicatorRow === null) return null;
712
- const i = s.api.grid.getTile(n.tileId);
713
- return i ? {
713
+ const o = s.api.grid.getTile(n.tileId);
714
+ return o ? {
714
715
  left: n.indicatorCol * y.value + m.value,
715
716
  top: n.indicatorRow * x.value + m.value,
716
- width: i.w * u.value.unitWidth + (i.w - 1) * h.value,
717
- 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
718
719
  } : null;
719
- }), q = w(() => {
720
- const n = G.value;
720
+ }), J = w(() => {
721
+ const n = L.value;
721
722
  if (!n) return null;
722
- 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);
723
724
  return {
724
- left: i * y.value + m.value,
725
- top: l * x.value + m.value,
726
- width: c * u.value.unitWidth + (c - 1) * h.value,
727
- height: d * u.value.unitHeight + (d - 1) * h.value,
728
- 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}`
729
730
  };
730
731
  });
731
- function Se(n) {
732
- return n.resizeHandles ?? u.value.resizeHandles ?? ["se"];
732
+ function ze(n) {
733
+ return n.resizeHandles ?? d.value.resizeHandles ?? ["se"];
733
734
  }
734
735
  function Re(n) {
735
- const l = {
736
+ const a = {
736
737
  position: "absolute",
737
738
  width: "12px",
738
739
  height: "12px",
@@ -742,42 +743,42 @@ const ot = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
742
743
  cursor: `${n}-resize`,
743
744
  touchAction: "none"
744
745
  };
745
- 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" };
746
747
  }
747
- const J = w(() => s.className ?? "");
748
- return (n, i) => K.value ? (P(), Ne(rt, {
748
+ const q = w(() => s.className ?? "");
749
+ return (n, o) => K.value ? (P(), Ae(dt, {
749
750
  key: 0,
750
- api: B.api,
751
- "class-name": J.value,
752
- height: B.height,
753
- "show-grid": B.showGrid,
751
+ api: F.api,
752
+ "class-name": q.value,
753
+ height: F.height,
754
+ "show-grid": F.showGrid,
754
755
  selection: s.selection,
755
- onSelectionChange: i[0] || (i[0] = (l) => f("selectionChange", l)),
756
- onDragStart: i[1] || (i[1] = (l) => f("dragStart", l)),
757
- onDragEnd: i[2] || (i[2] = (l, c) => f("dragEnd", l, c)),
758
- onResizeStart: i[3] || (i[3] = (l) => f("resizeStart", l)),
759
- onResizeEnd: i[4] || (i[4] = (l, c) => f("resizeEnd", l, c)),
760
- 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))
761
762
  }, {
762
- tile: Ae((l) => [
763
- ze(n.$slots, "tile", Fe(Oe(l)))
763
+ tile: Oe((a) => [
764
+ Se(n.$slots, "tile", _e(Be(a)))
764
765
  ]),
765
766
  _: 3
766
767
  }, 8, ["api", "class-name", "height", "show-grid", "selection"])) : (P(), H("div", {
767
768
  key: 1,
768
769
  ref_key: "scrollEl",
769
- ref: N,
770
- class: be(J.value),
771
- style: $(O.value),
770
+ ref: $,
771
+ class: be(q.value),
772
+ style: G(_.value),
772
773
  onPointerdown: he
773
774
  }, [
774
775
  Ge("div", {
775
- style: $(U.value)
776
+ style: G(U.value)
776
777
  }, [
777
778
  ne.value ? (P(), H("div", {
778
779
  key: 0,
779
780
  class: "griddle-drop-indicator",
780
- style: $({
781
+ style: G({
781
782
  position: "absolute",
782
783
  left: ne.value.left + "px",
783
784
  top: ne.value.top + "px",
@@ -786,24 +787,24 @@ const ot = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
786
787
  boxSizing: "border-box",
787
788
  border: "2px dashed rgba(59, 91, 219, 0.55)",
788
789
  background: "rgba(59, 91, 219, 0.08)",
789
- borderRadius: (u.value.tileRadius ?? 4) + "px",
790
+ borderRadius: (d.value.tileRadius ?? 4) + "px",
790
791
  pointerEvents: "none",
791
792
  zIndex: 5
792
793
  })
793
- }, null, 4)) : oe("", !0),
794
- q.value ? (P(), H("div", {
794
+ }, null, 4)) : ie("", !0),
795
+ J.value ? (P(), H("div", {
795
796
  key: 1,
796
797
  class: "griddle-draw-ghost",
797
- style: $({
798
+ style: G({
798
799
  position: "absolute",
799
- left: q.value.left + "px",
800
- top: q.value.top + "px",
801
- width: q.value.width + "px",
802
- 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",
803
804
  boxSizing: "border-box",
804
805
  border: "2px dashed rgba(59, 91, 219, 0.55)",
805
806
  background: "rgba(59, 91, 219, 0.08)",
806
- borderRadius: (u.value.tileRadius ?? 4) + "px",
807
+ borderRadius: (d.value.tileRadius ?? 4) + "px",
807
808
  pointerEvents: "none",
808
809
  zIndex: 5,
809
810
  display: "flex",
@@ -814,59 +815,59 @@ const ot = ["data-griddle-tile", "data-griddle-instance", "data-griddle-ghost",
814
815
  color: "rgba(59, 91, 219, 0.8)",
815
816
  userSelect: "none"
816
817
  })
817
- }, _e(q.value.label), 5)) : oe("", !0),
818
- (P(!0), H(we, null, Ce(ue.value, (l) => {
819
- 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;
820
821
  return P(), H("div", {
821
- key: l.id,
822
- "data-griddle-tile": l.id,
822
+ key: a.id,
823
+ "data-griddle-tile": a.id,
823
824
  class: be(["griddle-tile", {
824
- "griddle-dragging": ((c = R.value) == null ? void 0 : c.tileId) === l.id || ((d = D.value) == null ? void 0 : d.tileId) === l.id || Y.value !== null && j.value.has(l.id),
825
- "griddle-resizing": ((t = S.value) == null ? void 0 : t.tileId) === l.id,
826
- "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)
827
828
  }]),
828
- style: $(de(l)),
829
- onPointerdown: (e) => I(e, l),
829
+ style: G(de(a)),
830
+ onPointerdown: (e) => I(e, a),
830
831
  ref_for: !0,
831
- ref: (e) => me(l.id, e)
832
+ ref: (e) => me(a.id, e)
832
833
  }, [
833
- ze(n.$slots, "tile", {
834
- tile: l,
835
- selected: L.value.has(l.id)
834
+ Se(n.$slots, "tile", {
835
+ tile: a,
836
+ selected: D.value.has(a.id)
836
837
  }),
837
- 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", {
838
839
  key: e,
839
840
  "data-griddle-handle": e,
840
- style: $(Re(e)),
841
- onPointerdown: (o) => fe(o, l, e)
842
- }, null, 44, dt))), 128)) : oe("", !0)
843
- ], 46, st);
841
+ style: G(Re(e)),
842
+ onPointerdown: (i) => fe(i, a, e)
843
+ }, null, 44, ct))), 128)) : ie("", !0)
844
+ ], 46, ut);
844
845
  }), 128))
845
846
  ], 4)
846
847
  ], 38));
847
848
  }
848
849
  });
849
- function gt(B) {
850
- const z = new nt(B.config, B.tiles ?? []), s = Xe(z.tiles), f = Xe(z.config), K = k(0), N = z.changes.on(() => {
851
- 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++;
852
853
  });
853
- return Me(N), {
854
- grid: z,
854
+ return Me($), {
855
+ grid: S,
855
856
  tiles: s,
856
857
  config: f,
857
858
  version: K,
858
- moveTile: (u, h) => z.moveTile(u, h),
859
- resizeTile: (u, h) => z.resizeTile(u, h),
860
- addTile: (u) => z.addTile(u),
861
- removeTile: (u) => z.removeTile(u),
862
- updateConfig: (u) => z.updateConfig(u),
863
- toJSON: () => z.toJSON(),
864
- 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)
865
866
  };
866
867
  }
867
868
  export {
868
- pt as GriddleGrid,
869
- rt as GriddleLoopGrid,
870
- gt as useGriddle
869
+ ht as GriddleGrid,
870
+ dt as GriddleLoopGrid,
871
+ ft as useGriddle
871
872
  };
872
873
  //# sourceMappingURL=index.js.map