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