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