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