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