@vue-dnd-kit/core 1.2.2 → 1.3.0
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.
|
@@ -14,35 +14,35 @@ k(x, "remove", (e, t) => {
|
|
|
14
14
|
}), k(x, "move", (e, t, r, l) => {
|
|
15
15
|
if (!e || !r || t === void 0 || l === void 0)
|
|
16
16
|
return;
|
|
17
|
-
const
|
|
18
|
-
x.insert(r, l,
|
|
17
|
+
const s = x.remove(e, t);
|
|
18
|
+
x.insert(r, l, s);
|
|
19
19
|
}), k(x, "swap", (e, t, r, l) => {
|
|
20
20
|
if (!e || !r || t === void 0 || l === void 0)
|
|
21
21
|
return;
|
|
22
|
-
const
|
|
23
|
-
e[t] =
|
|
22
|
+
const s = e[t], o = r[l];
|
|
23
|
+
e[t] = o, r[l] = s;
|
|
24
24
|
}), k(x, "copy", (e, t, r, l) => {
|
|
25
25
|
if (!e || t === void 0 || !r || l === void 0)
|
|
26
26
|
return;
|
|
27
|
-
const
|
|
28
|
-
x.insert(r, l,
|
|
27
|
+
const s = e[t];
|
|
28
|
+
x.insert(r, l, s);
|
|
29
29
|
}), k(x, "applyTransfer", (e) => {
|
|
30
|
-
var l,
|
|
30
|
+
var l, s, o, g, i, c, d;
|
|
31
31
|
const t = e.hovered.element.value, r = e.hovered.zone.value;
|
|
32
32
|
if (t) {
|
|
33
|
-
const v = (
|
|
33
|
+
const v = (s = (l = e.elementsMap.value.get(t)) == null ? void 0 : l.data) == null ? void 0 : s.source, a = (g = (o = e.elementsMap.value.get(t)) == null ? void 0 : o.data) == null ? void 0 : g.index, u = e.draggingElements.value.values().next().value, f = (i = u == null ? void 0 : u.data) == null ? void 0 : i.index, m = f !== void 0 && a !== void 0 && f > a ? 1 : -1;
|
|
34
34
|
Array.from(
|
|
35
35
|
e.draggingElements.value.values()
|
|
36
36
|
).sort(
|
|
37
|
-
(E,
|
|
37
|
+
(E, A) => {
|
|
38
38
|
var w, I;
|
|
39
|
-
return m * ((((w = E.data) == null ? void 0 : w.index) || 0) - (((I =
|
|
39
|
+
return m * ((((w = E.data) == null ? void 0 : w.index) || 0) - (((I = A.data) == null ? void 0 : I.index) || 0));
|
|
40
40
|
}
|
|
41
41
|
).forEach(
|
|
42
42
|
(E) => {
|
|
43
|
-
var
|
|
43
|
+
var A, w;
|
|
44
44
|
return x.move(
|
|
45
|
-
(
|
|
45
|
+
(A = E.data) == null ? void 0 : A.source,
|
|
46
46
|
(w = E.data) == null ? void 0 : w.index,
|
|
47
47
|
v,
|
|
48
48
|
a
|
|
@@ -69,10 +69,10 @@ k(x, "remove", (e, t) => {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
}), k(x, "applyCopy", (e) => {
|
|
72
|
-
var l,
|
|
72
|
+
var l, s, o, g, i, c;
|
|
73
73
|
const t = e.hovered.element.value, r = e.hovered.zone.value;
|
|
74
74
|
if (t) {
|
|
75
|
-
const d = (
|
|
75
|
+
const d = (s = (l = e.elementsMap.value.get(t)) == null ? void 0 : l.data) == null ? void 0 : s.source, v = (g = (o = e.elementsMap.value.get(t)) == null ? void 0 : o.data) == null ? void 0 : g.index;
|
|
76
76
|
Array.from(
|
|
77
77
|
e.draggingElements.value.values()
|
|
78
78
|
).sort((u, f) => {
|
|
@@ -109,14 +109,14 @@ k(x, "remove", (e, t) => {
|
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
}), k(x, "applySwap", (e) => {
|
|
112
|
-
var l,
|
|
112
|
+
var l, s, o, g, i, c, d, v;
|
|
113
113
|
const t = e.hovered.element.value, r = e.hovered.zone.value;
|
|
114
114
|
if (t && e.draggingElements.value.size === 1) {
|
|
115
115
|
const a = e.draggingElements.value.values().next().value;
|
|
116
116
|
x.swap(
|
|
117
117
|
(l = a == null ? void 0 : a.data) == null ? void 0 : l.source,
|
|
118
|
-
(
|
|
119
|
-
(g = (
|
|
118
|
+
(s = a == null ? void 0 : a.data) == null ? void 0 : s.index,
|
|
119
|
+
(g = (o = e.elementsMap.value.get(t)) == null ? void 0 : o.data) == null ? void 0 : g.source,
|
|
120
120
|
(c = (i = e.elementsMap.value.get(t)) == null ? void 0 : i.data) == null ? void 0 : c.index
|
|
121
121
|
);
|
|
122
122
|
} else if (r) {
|
|
@@ -124,8 +124,8 @@ k(x, "remove", (e, t) => {
|
|
|
124
124
|
Array.from(
|
|
125
125
|
e.draggingElements.value.values()
|
|
126
126
|
).sort((m, p) => {
|
|
127
|
-
var E,
|
|
128
|
-
return (((E = p.data) == null ? void 0 : E.index) || 0) - (((
|
|
127
|
+
var E, A;
|
|
128
|
+
return (((E = p.data) == null ? void 0 : E.index) || 0) - (((A = m.data) == null ? void 0 : A.index) || 0);
|
|
129
129
|
}).forEach(
|
|
130
130
|
(m) => {
|
|
131
131
|
var p, E;
|
|
@@ -142,17 +142,17 @@ k(x, "remove", (e, t) => {
|
|
|
142
142
|
Array.from(
|
|
143
143
|
e.draggingElements.value.values()
|
|
144
144
|
).sort((r, l) => {
|
|
145
|
-
var
|
|
146
|
-
return (((
|
|
145
|
+
var s, o;
|
|
146
|
+
return (((s = l.data) == null ? void 0 : s.index) || 0) - (((o = r.data) == null ? void 0 : o.index) || 0);
|
|
147
147
|
}).forEach((r) => {
|
|
148
|
-
var l,
|
|
149
|
-
(l = r.data) != null && l.source && ((
|
|
148
|
+
var l, s;
|
|
149
|
+
(l = r.data) != null && l.source && ((s = r.data) == null ? void 0 : s.index) !== void 0 && x.remove(r.data.source, r.data.index);
|
|
150
150
|
});
|
|
151
151
|
}), k(x, "applyInsert", (e, t) => {
|
|
152
|
-
var
|
|
152
|
+
var s, o, g, i, c, d;
|
|
153
153
|
const r = e.hovered.element.value, l = e.hovered.zone.value;
|
|
154
154
|
if (r && t.length > 0) {
|
|
155
|
-
const v = (
|
|
155
|
+
const v = (o = (s = e.elementsMap.value.get(r)) == null ? void 0 : s.data) == null ? void 0 : o.source, a = (i = (g = e.elementsMap.value.get(r)) == null ? void 0 : g.data) == null ? void 0 : i.index;
|
|
156
156
|
t.forEach((u) => {
|
|
157
157
|
x.insert(v, a, u);
|
|
158
158
|
});
|
|
@@ -171,7 +171,7 @@ const K = ce(() => {
|
|
|
171
171
|
component: V(null),
|
|
172
172
|
ref: Y(null),
|
|
173
173
|
options: Y(null)
|
|
174
|
-
}, r = V(/* @__PURE__ */ new Map()), l = V(/* @__PURE__ */ new Set()),
|
|
174
|
+
}, r = V(/* @__PURE__ */ new Map()), l = V(/* @__PURE__ */ new Set()), s = V(/* @__PURE__ */ new Map()), o = V(/* @__PURE__ */ new Set()), g = V(/* @__PURE__ */ new Set()), i = new IntersectionObserver((Z) => {
|
|
175
175
|
Z.forEach(
|
|
176
176
|
(h) => g.value[h.isIntersecting ? "add" : "delete"](
|
|
177
177
|
h.target
|
|
@@ -179,12 +179,12 @@ const K = ce(() => {
|
|
|
179
179
|
);
|
|
180
180
|
}), c = new IntersectionObserver((Z) => {
|
|
181
181
|
Z.forEach(
|
|
182
|
-
(h) =>
|
|
182
|
+
(h) => o.value[h.isIntersecting ? "add" : "delete"](h.target)
|
|
183
183
|
);
|
|
184
184
|
}), d = (Z, h) => {
|
|
185
185
|
Z === "add" ? i.observe(h) : (i.unobserve(h), g.value.delete(h));
|
|
186
186
|
}, v = (Z, h) => {
|
|
187
|
-
Z === "add" ? c.observe(h) : (c.unobserve(h),
|
|
187
|
+
Z === "add" ? c.observe(h) : (c.unobserve(h), o.value.delete(h));
|
|
188
188
|
}, a = {
|
|
189
189
|
start: Y(null),
|
|
190
190
|
current: Y(null),
|
|
@@ -192,7 +192,7 @@ const K = ce(() => {
|
|
|
192
192
|
percent: Y(null),
|
|
193
193
|
pixel: Y(null)
|
|
194
194
|
}
|
|
195
|
-
}, { w: u, s: f, a: m, d: p, ctrl: E, shift:
|
|
195
|
+
}, { w: u, s: f, a: m, d: p, ctrl: E, shift: A, alt: w, meta: I } = Me(), B = {
|
|
196
196
|
zone: Y(null),
|
|
197
197
|
element: Y(null)
|
|
198
198
|
};
|
|
@@ -202,8 +202,8 @@ const K = ce(() => {
|
|
|
202
202
|
activeContainer: t,
|
|
203
203
|
elementsMap: r,
|
|
204
204
|
selectedElements: l,
|
|
205
|
-
zonesMap:
|
|
206
|
-
visibleZones:
|
|
205
|
+
zonesMap: s,
|
|
206
|
+
visibleZones: o,
|
|
207
207
|
visibleElements: g,
|
|
208
208
|
pointerPosition: a,
|
|
209
209
|
keyboard: {
|
|
@@ -212,7 +212,7 @@ const K = ce(() => {
|
|
|
212
212
|
a: m,
|
|
213
213
|
d: p,
|
|
214
214
|
ctrl: E,
|
|
215
|
-
shift:
|
|
215
|
+
shift: A,
|
|
216
216
|
alt: w,
|
|
217
217
|
meta: I
|
|
218
218
|
},
|
|
@@ -220,25 +220,25 @@ const K = ce(() => {
|
|
|
220
220
|
handleDragElementIntersection: d,
|
|
221
221
|
handleDropZoneIntersection: v
|
|
222
222
|
};
|
|
223
|
-
}),
|
|
224
|
-
const e = V(null), { draggingElements: t, pointerPosition: r, isDragging: l, activeContainer:
|
|
223
|
+
}), Ae = (n) => {
|
|
224
|
+
const e = V(null), { draggingElements: t, pointerPosition: r, isDragging: l, activeContainer: s } = K();
|
|
225
225
|
return G(() => {
|
|
226
|
-
|
|
226
|
+
s.ref = e, s.options.value = n ?? null;
|
|
227
227
|
}), fe(() => {
|
|
228
|
-
|
|
228
|
+
s.ref.value = null, s.options.value = null;
|
|
229
229
|
}), {
|
|
230
230
|
elementRef: e,
|
|
231
231
|
draggingElements: t,
|
|
232
232
|
pointerPosition: r,
|
|
233
233
|
isDragging: l
|
|
234
234
|
};
|
|
235
|
-
},
|
|
235
|
+
}, Le = ["innerHTML"], _e = /* @__PURE__ */ ie({
|
|
236
236
|
__name: "DefaultOverlay",
|
|
237
237
|
setup(n) {
|
|
238
|
-
const { elementRef: e, pointerPosition: t, isDragging: r, draggingElements: l } =
|
|
239
|
-
var
|
|
238
|
+
const { elementRef: e, pointerPosition: t, isDragging: r, draggingElements: l } = Ae(), s = T(() => {
|
|
239
|
+
var o, g, i, c;
|
|
240
240
|
return {
|
|
241
|
-
transform: `translate3d(${(((
|
|
241
|
+
transform: `translate3d(${(((o = t.current.value) == null ? void 0 : o.x) ?? 0) - (((g = t.offset.pixel.value) == null ? void 0 : g.x) ?? 0)}px, ${(((i = t.current.value) == null ? void 0 : i.y) ?? 0) - (((c = t.offset.pixel.value) == null ? void 0 : c.y) ?? 0)}px, 0)`,
|
|
242
242
|
zIndex: 1e3,
|
|
243
243
|
position: "fixed",
|
|
244
244
|
top: 0,
|
|
@@ -246,11 +246,11 @@ const K = ce(() => {
|
|
|
246
246
|
transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
|
|
247
247
|
};
|
|
248
248
|
});
|
|
249
|
-
return (
|
|
249
|
+
return (o, g) => y(r) ? (F(), N("div", {
|
|
250
250
|
key: 0,
|
|
251
251
|
ref_key: "elementRef",
|
|
252
252
|
ref: e,
|
|
253
|
-
style: W(
|
|
253
|
+
style: W(s.value)
|
|
254
254
|
}, [
|
|
255
255
|
(F(!0), N(me, null, he(y(l), ([i, c]) => {
|
|
256
256
|
var d, v;
|
|
@@ -261,7 +261,7 @@ const K = ce(() => {
|
|
|
261
261
|
width: `${(d = c.initialRect) == null ? void 0 : d.width}px`,
|
|
262
262
|
height: `${(v = c.initialRect) == null ? void 0 : v.height}px`
|
|
263
263
|
})
|
|
264
|
-
}, null, 12,
|
|
264
|
+
}, null, 12, Le);
|
|
265
265
|
}), 128))
|
|
266
266
|
], 4)) : ge("", !0);
|
|
267
267
|
}
|
|
@@ -309,13 +309,13 @@ const K = ce(() => {
|
|
|
309
309
|
n.component("DragOverlay", re);
|
|
310
310
|
const e = n.mount;
|
|
311
311
|
n.mount = function(r) {
|
|
312
|
-
const l = e.call(this, r),
|
|
313
|
-
if (
|
|
314
|
-
const
|
|
315
|
-
|
|
312
|
+
const l = e.call(this, r), s = typeof r == "string" ? document.querySelector(r) : r;
|
|
313
|
+
if (s && s instanceof Element && !s.querySelector("#vue-dnd-kit-overlay")) {
|
|
314
|
+
const o = document.createElement("div");
|
|
315
|
+
o.id = "vue-dnd-kit-overlay", o.style.pointerEvents = "none", s.appendChild(o);
|
|
316
316
|
const g = ye(re);
|
|
317
|
-
te(g,
|
|
318
|
-
container:
|
|
317
|
+
te(g, o), n.__VUE_DND_KIT_OVERLAY__ = {
|
|
318
|
+
container: o,
|
|
319
319
|
vnode: g
|
|
320
320
|
};
|
|
321
321
|
const i = K();
|
|
@@ -369,16 +369,16 @@ const K = ce(() => {
|
|
|
369
369
|
}, le = (n, e) => {
|
|
370
370
|
const t = e.x - n.x, r = e.y - n.y;
|
|
371
371
|
return Math.sqrt(t * t + r * r);
|
|
372
|
-
},
|
|
372
|
+
}, se = (n, e) => {
|
|
373
373
|
const t = Math.max(
|
|
374
374
|
0,
|
|
375
375
|
Math.min(n.x + n.width, e.x + e.width) - Math.max(n.x, e.x)
|
|
376
376
|
), r = Math.max(
|
|
377
377
|
0,
|
|
378
378
|
Math.min(n.y + n.height, e.y + e.height) - Math.max(n.y, e.y)
|
|
379
|
-
), l = t * r,
|
|
380
|
-
return (l /
|
|
381
|
-
},
|
|
379
|
+
), l = t * r, s = n.width * n.height, o = e.width * e.height;
|
|
380
|
+
return (l / s * 100 + l / o * 100) / 2;
|
|
381
|
+
}, oe = "data-vue-dnd-kit-draggable", z = (n) => {
|
|
382
382
|
n.preventDefault();
|
|
383
383
|
}, Ie = (n) => {
|
|
384
384
|
const {
|
|
@@ -386,17 +386,17 @@ const K = ce(() => {
|
|
|
386
386
|
draggingElements: t,
|
|
387
387
|
hovered: r,
|
|
388
388
|
selectedElements: l,
|
|
389
|
-
isDragging:
|
|
390
|
-
visibleElements:
|
|
389
|
+
isDragging: s,
|
|
390
|
+
visibleElements: o,
|
|
391
391
|
handleDragElementIntersection: g
|
|
392
392
|
} = K(), i = V(null), c = T(
|
|
393
|
-
() =>
|
|
394
|
-
), d = Y((n == null ? void 0 : n.id) || xe()), v = T(() => !i.value || !
|
|
395
|
-
if (!i.value || !
|
|
393
|
+
() => o.value.has(i.value) && r.element.value === i.value
|
|
394
|
+
), d = Y((n == null ? void 0 : n.id) || xe()), v = T(() => !i.value || !o.value.has(i.value) ? !1 : t.value.has(i.value)), a = T(() => {
|
|
395
|
+
if (!i.value || !s.value || !o.value.has(i.value)) return !1;
|
|
396
396
|
const m = e.value.get(i.value);
|
|
397
397
|
return m != null && m.groups.length ? !Array.from(t.value.entries()).some(
|
|
398
398
|
([p, E]) => E.groups.length ? !E.groups.some(
|
|
399
|
-
(
|
|
399
|
+
(A) => m.groups.includes(A)
|
|
400
400
|
) : !1
|
|
401
401
|
) : !0;
|
|
402
402
|
});
|
|
@@ -412,10 +412,10 @@ const K = ce(() => {
|
|
|
412
412
|
events: (n == null ? void 0 : n.events) ?? {},
|
|
413
413
|
data: (n == null ? void 0 : n.data) ?? null,
|
|
414
414
|
id: d.value
|
|
415
|
-
}), g("add", i.value), i.value.addEventListener("dragstart", z), i.value.addEventListener("drag", z), i.value.setAttribute(
|
|
415
|
+
}), g("add", i.value), i.value.addEventListener("dragstart", z), i.value.addEventListener("drag", z), i.value.setAttribute(oe, "true"), i.value.setAttribute("draggable", "false");
|
|
416
416
|
},
|
|
417
417
|
unregisterElement: () => {
|
|
418
|
-
i.value && (e.value.delete(i.value), l.value.delete(i.value), i.value.removeEventListener("dragstart", z), i.value.removeEventListener("drag", z), i.value.removeAttribute(
|
|
418
|
+
i.value && (e.value.delete(i.value), l.value.delete(i.value), i.value.removeEventListener("dragstart", z), i.value.removeEventListener("drag", z), i.value.removeAttribute(oe), i.value.removeAttribute("draggable"));
|
|
419
419
|
},
|
|
420
420
|
isDragging: v,
|
|
421
421
|
isOvered: c,
|
|
@@ -424,12 +424,12 @@ const K = ce(() => {
|
|
|
424
424
|
};
|
|
425
425
|
}, b = (n, e) => n ? e.contains(n) : !1, ze = (n) => {
|
|
426
426
|
var d, v;
|
|
427
|
-
const e = H(n.activeContainer.ref.value), t = q(e), r = ((d = n.pointerPosition.current.value) == null ? void 0 : d.x) ?? 0, l = ((v = n.pointerPosition.current.value) == null ? void 0 : v.y) ?? 0,
|
|
427
|
+
const e = H(n.activeContainer.ref.value), t = q(e), r = ((d = n.pointerPosition.current.value) == null ? void 0 : d.x) ?? 0, l = ((v = n.pointerPosition.current.value) == null ? void 0 : v.y) ?? 0, o = !(e && r >= e.x && r <= e.x + e.width && l >= e.y && l <= e.y + e.height), g = Array.from(n.draggingElements.value.keys()), i = Array.from(n.visibleElements.value.entries()).filter(([a, u]) => {
|
|
428
428
|
if (!a) return !1;
|
|
429
429
|
const f = H(a);
|
|
430
430
|
return f && e && ae(f, e);
|
|
431
431
|
}).map(([a, u]) => {
|
|
432
|
-
const f = H(a), m = q(f), p = r >= f.x && r <= f.x + f.width && l >= f.y && l <= f.y + f.height, E =
|
|
432
|
+
const f = H(a), m = q(f), p = r >= f.x && r <= f.x + f.width && l >= f.y && l <= f.y + f.height, E = se(f, e), A = le(t, m);
|
|
433
433
|
let w = 0;
|
|
434
434
|
for (const [I, B] of n.visibleElements.value.entries())
|
|
435
435
|
I !== a && I && a && b(a, I) && w++;
|
|
@@ -439,10 +439,10 @@ const K = ce(() => {
|
|
|
439
439
|
isPointerInElement: p,
|
|
440
440
|
overlapPercent: E,
|
|
441
441
|
depth: w,
|
|
442
|
-
centerDistance:
|
|
442
|
+
centerDistance: A
|
|
443
443
|
};
|
|
444
444
|
}).sort((a, u) => {
|
|
445
|
-
if (!
|
|
445
|
+
if (!o) {
|
|
446
446
|
if (a.isPointerInElement && u.isPointerInElement)
|
|
447
447
|
return u.depth - a.depth;
|
|
448
448
|
if (a.isPointerInElement !== u.isPointerInElement)
|
|
@@ -457,7 +457,7 @@ const K = ce(() => {
|
|
|
457
457
|
const f = H(a);
|
|
458
458
|
return f && e && ae(f, e);
|
|
459
459
|
}).map(([a, u]) => {
|
|
460
|
-
const f = H(a), m = q(f), p = r >= f.x && r <= f.x + f.width && l >= f.y && l <= f.y + f.height, E =
|
|
460
|
+
const f = H(a), m = q(f), p = r >= f.x && r <= f.x + f.width && l >= f.y && l <= f.y + f.height, E = se(f, e), A = le(t, m);
|
|
461
461
|
let w = 0;
|
|
462
462
|
for (const [I, B] of n.visibleZones.value.entries())
|
|
463
463
|
I !== a && I && a && b(a, I) && w++;
|
|
@@ -467,10 +467,10 @@ const K = ce(() => {
|
|
|
467
467
|
isPointerInElement: p,
|
|
468
468
|
overlapPercent: E,
|
|
469
469
|
depth: w,
|
|
470
|
-
centerDistance:
|
|
470
|
+
centerDistance: A
|
|
471
471
|
};
|
|
472
472
|
}).sort((a, u) => {
|
|
473
|
-
if (!
|
|
473
|
+
if (!o) {
|
|
474
474
|
if (a.isPointerInElement && u.isPointerInElement)
|
|
475
475
|
return u.depth - a.depth;
|
|
476
476
|
if (a.isPointerInElement !== u.isPointerInElement)
|
|
@@ -521,21 +521,21 @@ const K = ce(() => {
|
|
|
521
521
|
}, De = (n) => {
|
|
522
522
|
const e = K();
|
|
523
523
|
return {
|
|
524
|
-
onPointerStart: (
|
|
525
|
-
e.pointerPosition.start.value = { x:
|
|
526
|
-
x:
|
|
527
|
-
y:
|
|
524
|
+
onPointerStart: (s) => {
|
|
525
|
+
e.pointerPosition.start.value = { x: s.clientX, y: s.clientY }, e.pointerPosition.current.value = {
|
|
526
|
+
x: s.clientX,
|
|
527
|
+
y: s.clientY
|
|
528
528
|
};
|
|
529
|
-
const { pixel:
|
|
530
|
-
x:
|
|
531
|
-
y:
|
|
529
|
+
const { pixel: o, percent: g } = Se(n.value, {
|
|
530
|
+
x: s.clientX,
|
|
531
|
+
y: s.clientY
|
|
532
532
|
});
|
|
533
|
-
e.pointerPosition.offset.pixel.value =
|
|
533
|
+
e.pointerPosition.offset.pixel.value = o, e.pointerPosition.offset.percent.value = g;
|
|
534
534
|
},
|
|
535
|
-
onPointerMove: (
|
|
535
|
+
onPointerMove: (s) => {
|
|
536
536
|
e.pointerPosition.current.value = {
|
|
537
|
-
x:
|
|
538
|
-
y:
|
|
537
|
+
x: s.clientX,
|
|
538
|
+
y: s.clientY
|
|
539
539
|
};
|
|
540
540
|
},
|
|
541
541
|
onPointerEnd: () => {
|
|
@@ -544,13 +544,13 @@ const K = ce(() => {
|
|
|
544
544
|
};
|
|
545
545
|
}, ke = (n, e) => {
|
|
546
546
|
var B, Z;
|
|
547
|
-
const t = K(), { onPointerStart: r, onPointerMove: l, onPointerEnd:
|
|
547
|
+
const t = K(), { onPointerStart: r, onPointerMove: l, onPointerEnd: s } = De(n), { onKeyboardStart: o, onKeyboardMove: g, onKeyboardEnd: i } = Ce(
|
|
548
548
|
n,
|
|
549
549
|
e == null ? void 0 : e.keyboard
|
|
550
550
|
);
|
|
551
551
|
let c = null;
|
|
552
552
|
const d = (h) => {
|
|
553
|
-
var D,
|
|
553
|
+
var D, L;
|
|
554
554
|
if (!h) return /* @__PURE__ */ new Map();
|
|
555
555
|
const _ = t.selectedElements.value.has(h);
|
|
556
556
|
if (t.selectedElements.value.size > 0 && _) {
|
|
@@ -572,14 +572,14 @@ const K = ce(() => {
|
|
|
572
572
|
return M.set(h, {
|
|
573
573
|
...P,
|
|
574
574
|
initialHTML: ((D = P.node) == null ? void 0 : D.outerHTML) ?? "",
|
|
575
|
-
initialRect: (
|
|
575
|
+
initialRect: (L = P.node) == null ? void 0 : L.getBoundingClientRect()
|
|
576
576
|
}), M;
|
|
577
577
|
}, v = (h) => {
|
|
578
578
|
if (!h)
|
|
579
579
|
return { element: null, zone: null };
|
|
580
|
-
const _ = Array.isArray(h) ? h : [h], P = Array.from(t.draggingElements.value.keys()), M = _.find((
|
|
581
|
-
if (!t.visibleZones.value.has(
|
|
582
|
-
const S = t.zonesMap.value.get(
|
|
580
|
+
const _ = Array.isArray(h) ? h : [h], P = Array.from(t.draggingElements.value.keys()), M = _.find((L) => {
|
|
581
|
+
if (!t.visibleZones.value.has(L)) return !1;
|
|
582
|
+
const S = t.zonesMap.value.get(L);
|
|
583
583
|
return !(!S || P.some(
|
|
584
584
|
(C) => C && (C === S.node || b(S.node, C))
|
|
585
585
|
) || S.groups.length && !!Array.from(
|
|
@@ -588,22 +588,38 @@ const K = ce(() => {
|
|
|
588
588
|
});
|
|
589
589
|
return M ? {
|
|
590
590
|
element: _.find(
|
|
591
|
-
(
|
|
592
|
-
(S) => S && (S ===
|
|
593
|
-
|
|
591
|
+
(L) => t.visibleElements.value.has(L) && t.elementsMap.value.has(L) && !P.some(
|
|
592
|
+
(S) => S && (S === L || b(
|
|
593
|
+
L,
|
|
594
594
|
S
|
|
595
|
-
) || b(S,
|
|
596
|
-
) && (
|
|
597
|
-
|
|
595
|
+
) || b(S, L))
|
|
596
|
+
) && (L === M || b(
|
|
597
|
+
L,
|
|
598
598
|
M
|
|
599
599
|
))
|
|
600
600
|
) || null,
|
|
601
601
|
zone: M
|
|
602
602
|
} : { element: null, zone: null };
|
|
603
603
|
}, a = ((B = e == null ? void 0 : e.sensor) == null ? void 0 : B.setup) || ze, u = (h) => {
|
|
604
|
-
var M, D,
|
|
604
|
+
var M, D, L, S, C, U, O, R, j, J, X, Q;
|
|
605
605
|
const _ = t.hovered.element.value, P = t.hovered.zone.value;
|
|
606
|
-
t.hovered.element.value = h.element, t.hovered.zone.value = h.zone, _ && t.hovered.element.value !== _ && ((
|
|
606
|
+
t.hovered.element.value = h.element, t.hovered.zone.value = h.zone, _ && t.hovered.element.value !== _ && ((L = (D = (M = t.elementsMap.value.get(_)) == null ? void 0 : M.events) == null ? void 0 : D.onLeave) == null || L.call(
|
|
607
|
+
D,
|
|
608
|
+
t,
|
|
609
|
+
Array.from(t.draggingElements.value.values())
|
|
610
|
+
), t.hovered.element.value && ((U = (C = (S = t.elementsMap.value.get(t.hovered.element.value)) == null ? void 0 : S.events) == null ? void 0 : C.onHover) == null || U.call(
|
|
611
|
+
C,
|
|
612
|
+
t,
|
|
613
|
+
Array.from(t.draggingElements.value.values())
|
|
614
|
+
))), P && t.hovered.zone.value !== P && ((j = (R = (O = t.zonesMap.value.get(P)) == null ? void 0 : O.events) == null ? void 0 : R.onLeave) == null || j.call(
|
|
615
|
+
R,
|
|
616
|
+
t,
|
|
617
|
+
Array.from(t.draggingElements.value.values())
|
|
618
|
+
), t.hovered.zone.value && ((Q = (X = (J = t.zonesMap.value.get(t.hovered.zone.value)) == null ? void 0 : J.events) == null ? void 0 : X.onHover) == null || Q.call(
|
|
619
|
+
X,
|
|
620
|
+
t,
|
|
621
|
+
Array.from(t.draggingElements.value.values())
|
|
622
|
+
)));
|
|
607
623
|
}, f = Pe(() => {
|
|
608
624
|
const h = a(t), _ = v(h);
|
|
609
625
|
u(_);
|
|
@@ -617,29 +633,45 @@ const K = ce(() => {
|
|
|
617
633
|
t.draggingElements.value = d(n.value), t.draggingElements.value.forEach(
|
|
618
634
|
(_) => {
|
|
619
635
|
var P, M;
|
|
620
|
-
return (M = (P = _.events).onStart) == null ? void 0 : M.call(
|
|
636
|
+
return (M = (P = _.events).onStart) == null ? void 0 : M.call(
|
|
637
|
+
P,
|
|
638
|
+
t,
|
|
639
|
+
Array.from(t.draggingElements.value.values())
|
|
640
|
+
);
|
|
621
641
|
}
|
|
622
|
-
), h instanceof PointerEvent ? r(h) :
|
|
642
|
+
), h instanceof PointerEvent ? r(h) : o(h), p();
|
|
623
643
|
},
|
|
624
644
|
track: (h) => {
|
|
625
645
|
t.draggingElements.value.forEach(
|
|
626
646
|
(_) => {
|
|
627
647
|
var P, M;
|
|
628
|
-
return (M = (P = _.events).onMove) == null ? void 0 : M.call(
|
|
648
|
+
return (M = (P = _.events).onMove) == null ? void 0 : M.call(
|
|
649
|
+
P,
|
|
650
|
+
t,
|
|
651
|
+
Array.from(t.draggingElements.value.values())
|
|
652
|
+
);
|
|
629
653
|
}
|
|
630
654
|
), h instanceof KeyboardEvent ? g() : l(h);
|
|
631
655
|
},
|
|
632
656
|
deactivate: (h = !0) => {
|
|
633
657
|
var _, P;
|
|
634
|
-
if (
|
|
658
|
+
if (s(), i(), h) {
|
|
635
659
|
if (t.hovered.zone.value) {
|
|
636
660
|
const M = t.zonesMap.value.get(t.hovered.zone.value);
|
|
637
|
-
(P = M == null ? void 0 : (_ = M.events).onDrop) == null || P.call(
|
|
661
|
+
(P = M == null ? void 0 : (_ = M.events).onDrop) == null || P.call(
|
|
662
|
+
_,
|
|
663
|
+
t,
|
|
664
|
+
Array.from(t.draggingElements.value.values())
|
|
665
|
+
);
|
|
638
666
|
} else
|
|
639
667
|
t.draggingElements.value.forEach(
|
|
640
668
|
(M) => {
|
|
641
|
-
var D,
|
|
642
|
-
return (
|
|
669
|
+
var D, L;
|
|
670
|
+
return (L = (D = M.events).onEnd) == null ? void 0 : L.call(
|
|
671
|
+
D,
|
|
672
|
+
t,
|
|
673
|
+
Array.from(t.draggingElements.value.values())
|
|
674
|
+
);
|
|
643
675
|
}
|
|
644
676
|
);
|
|
645
677
|
t.selectedElements.value.clear();
|
|
@@ -648,7 +680,7 @@ const K = ce(() => {
|
|
|
648
680
|
}
|
|
649
681
|
};
|
|
650
682
|
}, be = ce(() => {
|
|
651
|
-
let n = "", e = "", t = "", r = null, l = null,
|
|
683
|
+
let n = "", e = "", t = "", r = null, l = null, s = null, o = null, g = null;
|
|
652
684
|
const { activeContainer: i } = K(), c = () => {
|
|
653
685
|
const u = document.body;
|
|
654
686
|
n = u.style.userSelect, u.style.userSelect = "none", window.addEventListener("contextmenu", z), window.addEventListener("selectstart", z), window.addEventListener("touchstart", z), window.addEventListener("touchmove", z);
|
|
@@ -656,19 +688,19 @@ const K = ce(() => {
|
|
|
656
688
|
const u = document.body;
|
|
657
689
|
u.style.userSelect = n, u.style.touchAction = e, u.style.overscrollBehavior = t, window.removeEventListener("contextmenu", z), window.removeEventListener("selectstart", z), window.removeEventListener("touchstart", z), window.removeEventListener("touchmove", z);
|
|
658
690
|
}, v = () => {
|
|
659
|
-
r && (document.removeEventListener("pointermove", r), r = null), l && (document.removeEventListener("pointerup", l), l = null),
|
|
691
|
+
r && (document.removeEventListener("pointermove", r), r = null), l && (document.removeEventListener("pointerup", l), l = null), s && (s = null), o && (document.removeEventListener("wheel", o), o = null), g && (document.removeEventListener("keydown", g), document.removeEventListener("keypress", g), document.removeEventListener("keyup", g), g = null);
|
|
660
692
|
};
|
|
661
693
|
return {
|
|
662
694
|
handleDragStart: (u, f, m) => {
|
|
663
695
|
v(), u.target.blur(), m != null && m.container && (i.component.value = we(m.container));
|
|
664
|
-
const { activate: p, track: E, deactivate:
|
|
696
|
+
const { activate: p, track: E, deactivate: A } = ke(f, m);
|
|
665
697
|
l = () => {
|
|
666
|
-
i.component.value = null, d(),
|
|
667
|
-
},
|
|
668
|
-
i.component.value = null, d(),
|
|
669
|
-
}, r = (w) => E(w),
|
|
670
|
-
w.type === "keyup" && (w.code === "Escape" && (
|
|
671
|
-
}, c(), p(u), document.addEventListener("pointermove", r), document.addEventListener("pointerup", l), document.addEventListener("wheel",
|
|
698
|
+
i.component.value = null, d(), A(!0), v();
|
|
699
|
+
}, s = () => {
|
|
700
|
+
i.component.value = null, d(), A(!1), v();
|
|
701
|
+
}, r = (w) => E(w), o = (w) => E(w), g = (w) => {
|
|
702
|
+
w.type === "keyup" && (w.code === "Escape" && (s == null || s()), w.code === "Enter" && (l == null || l())), E(w);
|
|
703
|
+
}, c(), p(u), document.addEventListener("pointermove", r), document.addEventListener("pointerup", l), document.addEventListener("wheel", o), document.addEventListener("keydown", g), document.addEventListener("keypress", g), document.addEventListener("keyup", g);
|
|
672
704
|
}
|
|
673
705
|
};
|
|
674
706
|
}), Ye = (n) => {
|
|
@@ -677,16 +709,16 @@ const K = ce(() => {
|
|
|
677
709
|
elementRef: t,
|
|
678
710
|
isDragging: r,
|
|
679
711
|
isOvered: l,
|
|
680
|
-
isAllowed:
|
|
681
|
-
registerElement:
|
|
712
|
+
isAllowed: s,
|
|
713
|
+
registerElement: o,
|
|
682
714
|
unregisterElement: g
|
|
683
715
|
} = Ie(n), { pointerPosition: i } = K(), { handleDragStart: c } = be(), d = (v) => c(v, t, n);
|
|
684
|
-
return G(
|
|
716
|
+
return G(o), ue(g), {
|
|
685
717
|
pointerPosition: i,
|
|
686
718
|
elementRef: t,
|
|
687
719
|
isDragging: r,
|
|
688
720
|
isOvered: l,
|
|
689
|
-
isAllowed:
|
|
721
|
+
isAllowed: s,
|
|
690
722
|
handleDragStart: d,
|
|
691
723
|
id: e
|
|
692
724
|
};
|
|
@@ -696,28 +728,28 @@ const K = ce(() => {
|
|
|
696
728
|
hovered: t,
|
|
697
729
|
draggingElements: r,
|
|
698
730
|
isDragging: l,
|
|
699
|
-
handleDropZoneIntersection:
|
|
700
|
-
} = K(),
|
|
701
|
-
if (!
|
|
702
|
-
const v = e.value.get(
|
|
731
|
+
handleDropZoneIntersection: s
|
|
732
|
+
} = K(), o = V(null), g = T(() => t.zone.value === o.value), i = T(() => {
|
|
733
|
+
if (!o.value || !l.value) return !1;
|
|
734
|
+
const v = e.value.get(o.value);
|
|
703
735
|
return v != null && v.groups.length ? !Array.from(r.value.values()).some((a) => a.groups.length ? !a.groups.some(
|
|
704
736
|
(u) => v.groups.includes(u)
|
|
705
737
|
) : !1) : !0;
|
|
706
738
|
});
|
|
707
|
-
return { elementRef:
|
|
708
|
-
if (!
|
|
709
|
-
|
|
710
|
-
node:
|
|
739
|
+
return { elementRef: o, registerZone: () => {
|
|
740
|
+
if (!o.value) throw new Error("elementRef is not set");
|
|
741
|
+
s("add", o.value), e.value.set(o.value, {
|
|
742
|
+
node: o.value,
|
|
711
743
|
groups: (n == null ? void 0 : n.groups) ?? [],
|
|
712
744
|
events: (n == null ? void 0 : n.events) ?? {},
|
|
713
745
|
data: (n == null ? void 0 : n.data) ?? void 0
|
|
714
|
-
}),
|
|
746
|
+
}), o.value.setAttribute("data-dnd-droppable", "true");
|
|
715
747
|
}, unregisterZone: () => {
|
|
716
|
-
|
|
748
|
+
o.value && (s("remove", o.value), e.value.delete(o.value));
|
|
717
749
|
}, isOvered: g, isAllowed: i };
|
|
718
750
|
}, Oe = (n) => {
|
|
719
|
-
const { elementRef: e, registerZone: t, unregisterZone: r, isOvered: l, isAllowed:
|
|
720
|
-
return G(t), ue(r), { elementRef: e, isOvered: l, isAllowed:
|
|
751
|
+
const { elementRef: e, registerZone: t, unregisterZone: r, isOvered: l, isAllowed: s } = Te(n);
|
|
752
|
+
return G(t), ue(r), { elementRef: e, isOvered: l, isAllowed: s };
|
|
721
753
|
}, Re = (n) => {
|
|
722
754
|
const { selectedElements: e, elementsMap: t } = K(), r = T(
|
|
723
755
|
() => n.value ? e.value.has(n.value) : !1
|
|
@@ -727,30 +759,30 @@ const K = ce(() => {
|
|
|
727
759
|
if (c && b(c, n.value))
|
|
728
760
|
return !0;
|
|
729
761
|
return !1;
|
|
730
|
-
}),
|
|
762
|
+
}), s = T(() => {
|
|
731
763
|
if (!n.value) return !1;
|
|
732
764
|
for (const c of e.value)
|
|
733
765
|
if (c && b(n.value, c))
|
|
734
766
|
return !0;
|
|
735
767
|
return !1;
|
|
736
|
-
}),
|
|
768
|
+
}), o = () => {
|
|
737
769
|
n.value && e.value.delete(n.value);
|
|
738
770
|
}, g = () => {
|
|
739
771
|
if (!(!n.value || !t.value.get(n.value))) {
|
|
740
772
|
if (l.value)
|
|
741
773
|
for (const d of e.value)
|
|
742
774
|
d && b(d, n.value) && e.value.delete(d);
|
|
743
|
-
if (
|
|
775
|
+
if (s.value)
|
|
744
776
|
for (const d of e.value)
|
|
745
777
|
d && b(n.value, d) && e.value.delete(d);
|
|
746
778
|
e.value.add(n.value);
|
|
747
779
|
}
|
|
748
780
|
};
|
|
749
781
|
return {
|
|
750
|
-
handleUnselect:
|
|
782
|
+
handleUnselect: o,
|
|
751
783
|
handleSelect: g,
|
|
752
784
|
handleToggleSelect: () => {
|
|
753
|
-
n.value && (e.value.has(n.value) ?
|
|
785
|
+
n.value && (e.value.has(n.value) ? o() : g());
|
|
754
786
|
},
|
|
755
787
|
isSelected: r,
|
|
756
788
|
isParentOfSelected: l
|
|
@@ -761,7 +793,7 @@ export {
|
|
|
761
793
|
Ve as default,
|
|
762
794
|
H as getBoundingBox,
|
|
763
795
|
K as useDnDStore,
|
|
764
|
-
|
|
796
|
+
Ae as useDragContainer,
|
|
765
797
|
Ye as useDraggable,
|
|
766
798
|
Oe as useDroppable,
|
|
767
799
|
Re as useSelection
|