@vue-dnd-kit/core 1.0.1 → 1.1.1
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.
|
@@ -85,12 +85,12 @@ b(y, "remove", (e, t) => {
|
|
|
85
85
|
);
|
|
86
86
|
} else r && e.draggingElements.value.forEach(
|
|
87
87
|
(u) => {
|
|
88
|
-
var d, v, g, m, h,
|
|
88
|
+
var d, v, g, m, h, z, w;
|
|
89
89
|
return y.move(
|
|
90
90
|
(d = u.data) == null ? void 0 : d.source,
|
|
91
91
|
(v = u.data) == null ? void 0 : v.index,
|
|
92
92
|
(m = (g = e.zonesMap.value.get(r)) == null ? void 0 : g.data) == null ? void 0 : m.source,
|
|
93
|
-
(
|
|
93
|
+
(w = (z = (h = e.zonesMap.value.get(r)) == null ? void 0 : h.data) == null ? void 0 : z.source) == null ? void 0 : w.length
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
);
|
|
@@ -151,7 +151,7 @@ const T = ie(() => {
|
|
|
151
151
|
percent: U(null),
|
|
152
152
|
pixel: U(null)
|
|
153
153
|
}
|
|
154
|
-
}, { w: g, s: m, a: h, d:
|
|
154
|
+
}, { w: g, s: m, a: h, d: z, ctrl: w, shift: _, alt: P, meta: A } = Me(), R = {
|
|
155
155
|
zone: U(null),
|
|
156
156
|
element: U(null)
|
|
157
157
|
};
|
|
@@ -169,10 +169,10 @@ const T = ie(() => {
|
|
|
169
169
|
w: g,
|
|
170
170
|
s: m,
|
|
171
171
|
a: h,
|
|
172
|
-
d:
|
|
173
|
-
ctrl:
|
|
172
|
+
d: z,
|
|
173
|
+
ctrl: w,
|
|
174
174
|
shift: _,
|
|
175
|
-
alt:
|
|
175
|
+
alt: P,
|
|
176
176
|
meta: A
|
|
177
177
|
},
|
|
178
178
|
hovered: R,
|
|
@@ -321,7 +321,7 @@ const T = ie(() => {
|
|
|
321
321
|
if (!s.value || !o.value || !l.value.has(s.value)) return !1;
|
|
322
322
|
const h = e.value.get(s.value);
|
|
323
323
|
return h != null && h.groups.length ? !Array.from(t.value.entries()).some(
|
|
324
|
-
([
|
|
324
|
+
([z, w]) => w.groups.length ? !w.groups.some(
|
|
325
325
|
(_) => h.groups.includes(_)
|
|
326
326
|
) : !1
|
|
327
327
|
) : !0;
|
|
@@ -341,7 +341,7 @@ const T = ie(() => {
|
|
|
341
341
|
}), c("add", s.value), s.value.addEventListener("dragstart", S), s.value.addEventListener("drag", S), s.value.setAttribute(se, "true"), s.value.setAttribute("draggable", "false");
|
|
342
342
|
},
|
|
343
343
|
unregisterElement: () => {
|
|
344
|
-
s.value && (
|
|
344
|
+
s.value && (e.value.delete(s.value), a.value.delete(s.value), s.value.removeEventListener("dragstart", S), s.value.removeEventListener("drag", S), s.value.removeAttribute(se), s.value.removeAttribute("draggable"));
|
|
345
345
|
},
|
|
346
346
|
isDragging: d,
|
|
347
347
|
isOvered: i,
|
|
@@ -355,16 +355,16 @@ const T = ie(() => {
|
|
|
355
355
|
const m = O(v);
|
|
356
356
|
return m && e && re(m, e);
|
|
357
357
|
}).map(([v, g]) => {
|
|
358
|
-
const m = O(v), h = $(m),
|
|
359
|
-
let
|
|
358
|
+
const m = O(v), h = $(m), z = r >= m.x && r <= m.x + m.width && a >= m.y && a <= m.y + m.height, w = le(m, e), _ = ae(t, h);
|
|
359
|
+
let P = 0;
|
|
360
360
|
for (const [A, R] of n.visibleElements.value.entries())
|
|
361
|
-
A !== v && A && v && k(v, A) &&
|
|
361
|
+
A !== v && A && v && k(v, A) && P++;
|
|
362
362
|
return {
|
|
363
363
|
element: g,
|
|
364
364
|
node: v,
|
|
365
|
-
isPointerInElement:
|
|
366
|
-
overlapPercent:
|
|
367
|
-
depth:
|
|
365
|
+
isPointerInElement: z,
|
|
366
|
+
overlapPercent: w,
|
|
367
|
+
depth: P,
|
|
368
368
|
centerDistance: _
|
|
369
369
|
};
|
|
370
370
|
}).sort((v, g) => {
|
|
@@ -383,16 +383,16 @@ const T = ie(() => {
|
|
|
383
383
|
const m = O(v);
|
|
384
384
|
return m && e && re(m, e);
|
|
385
385
|
}).map(([v, g]) => {
|
|
386
|
-
const m = O(v), h = $(m),
|
|
387
|
-
let
|
|
386
|
+
const m = O(v), h = $(m), z = r >= m.x && r <= m.x + m.width && a >= m.y && a <= m.y + m.height, w = le(m, e), _ = ae(t, h);
|
|
387
|
+
let P = 0;
|
|
388
388
|
for (const [A, R] of n.visibleZones.value.entries())
|
|
389
|
-
A !== v && A && v && k(v, A) &&
|
|
389
|
+
A !== v && A && v && k(v, A) && P++;
|
|
390
390
|
return {
|
|
391
391
|
zone: g,
|
|
392
392
|
node: v,
|
|
393
|
-
isPointerInElement:
|
|
394
|
-
overlapPercent:
|
|
395
|
-
depth:
|
|
393
|
+
isPointerInElement: z,
|
|
394
|
+
overlapPercent: w,
|
|
395
|
+
depth: P,
|
|
396
396
|
centerDistance: _
|
|
397
397
|
};
|
|
398
398
|
}).sort((v, g) => {
|
|
@@ -476,92 +476,102 @@ const T = ie(() => {
|
|
|
476
476
|
);
|
|
477
477
|
let i = null;
|
|
478
478
|
const u = (f) => {
|
|
479
|
-
var D,
|
|
479
|
+
var D, M;
|
|
480
480
|
if (!f) return /* @__PURE__ */ new Map();
|
|
481
|
-
const
|
|
482
|
-
if (t.selectedElementsMap.value.size > 0 &&
|
|
483
|
-
const
|
|
481
|
+
const x = t.selectedElementsMap.value.has(f);
|
|
482
|
+
if (t.selectedElementsMap.value.size > 0 && x) {
|
|
483
|
+
const L = /* @__PURE__ */ new Map();
|
|
484
484
|
return Array.from(t.selectedElementsMap.value.entries()).forEach(
|
|
485
485
|
([I, Y]) => {
|
|
486
486
|
var V, H;
|
|
487
|
-
|
|
487
|
+
L.set(I, {
|
|
488
488
|
...Y,
|
|
489
489
|
initialHTML: ((V = Y.node) == null ? void 0 : V.outerHTML) ?? "",
|
|
490
490
|
initialRect: (H = Y.node) == null ? void 0 : H.getBoundingClientRect()
|
|
491
491
|
});
|
|
492
492
|
}
|
|
493
|
-
),
|
|
493
|
+
), L;
|
|
494
494
|
}
|
|
495
495
|
t.selectedElementsMap.value.clear();
|
|
496
|
-
const
|
|
497
|
-
if (!
|
|
498
|
-
const
|
|
499
|
-
return
|
|
500
|
-
...
|
|
501
|
-
initialHTML: ((D =
|
|
502
|
-
initialRect: (
|
|
503
|
-
}),
|
|
496
|
+
const p = t.elementsMap.value.get(f);
|
|
497
|
+
if (!p) return /* @__PURE__ */ new Map();
|
|
498
|
+
const E = /* @__PURE__ */ new Map();
|
|
499
|
+
return E.set(f, {
|
|
500
|
+
...p,
|
|
501
|
+
initialHTML: ((D = p.node) == null ? void 0 : D.outerHTML) ?? "",
|
|
502
|
+
initialRect: (M = p.node) == null ? void 0 : M.getBoundingClientRect()
|
|
503
|
+
}), E;
|
|
504
504
|
}, d = (f) => {
|
|
505
505
|
if (!f)
|
|
506
506
|
return { element: null, zone: null };
|
|
507
|
-
const
|
|
508
|
-
if (!t.visibleZones.value.has(
|
|
509
|
-
const
|
|
510
|
-
return !(!
|
|
511
|
-
(I) => I && (I ===
|
|
512
|
-
) ||
|
|
507
|
+
const x = Array.isArray(f) ? f : [f], p = Array.from(t.draggingElements.value.keys()), E = x.find((M) => {
|
|
508
|
+
if (!t.visibleZones.value.has(M)) return !1;
|
|
509
|
+
const L = t.zonesMap.value.get(M);
|
|
510
|
+
return !(!L || p.some(
|
|
511
|
+
(I) => I && (I === L.node || k(L.node, I))
|
|
512
|
+
) || L.groups.length && !!Array.from(
|
|
513
513
|
t.draggingElements.value.values()
|
|
514
|
-
).some((Y) => Y.groups.length ? !Y.groups.some((V) =>
|
|
514
|
+
).some((Y) => Y.groups.length ? !Y.groups.some((V) => L.groups.includes(V)) : !1));
|
|
515
515
|
});
|
|
516
|
-
return
|
|
517
|
-
element:
|
|
518
|
-
(
|
|
519
|
-
(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
) || k(
|
|
523
|
-
) && (
|
|
524
|
-
|
|
525
|
-
|
|
516
|
+
return E ? {
|
|
517
|
+
element: x.find(
|
|
518
|
+
(M) => t.visibleElements.value.has(M) && t.elementsMap.value.has(M) && !p.some(
|
|
519
|
+
(L) => L && (L === M || k(
|
|
520
|
+
M,
|
|
521
|
+
L
|
|
522
|
+
) || k(L, M))
|
|
523
|
+
) && (M === E || k(
|
|
524
|
+
M,
|
|
525
|
+
E
|
|
526
526
|
))
|
|
527
527
|
) || null,
|
|
528
|
-
zone:
|
|
528
|
+
zone: E
|
|
529
529
|
} : { element: null, zone: null };
|
|
530
530
|
}, v = ((R = e == null ? void 0 : e.sensor) == null ? void 0 : R.setup) || _e, g = (f) => {
|
|
531
|
-
var
|
|
532
|
-
const
|
|
533
|
-
t.hovered.element.value = f.element, t.hovered.zone.value = f.zone,
|
|
531
|
+
var E, D, M, L, I, Y, V, H, j, J, X, Q;
|
|
532
|
+
const x = t.hovered.element.value, p = t.hovered.zone.value;
|
|
533
|
+
t.hovered.element.value = f.element, t.hovered.zone.value = f.zone, x && t.hovered.element.value !== x && ((M = (D = (E = t.elementsMap.value.get(x)) == null ? void 0 : E.events) == null ? void 0 : D.onLeave) == null || M.call(D, t), t.hovered.element.value && ((Y = (I = (L = t.elementsMap.value.get(t.hovered.element.value)) == null ? void 0 : L.events) == null ? void 0 : I.onHover) == null || Y.call(I, t))), p && t.hovered.zone.value !== p && ((j = (H = (V = t.zonesMap.value.get(p)) == null ? void 0 : V.events) == null ? void 0 : H.onLeave) == null || j.call(H, t), 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(X, t)));
|
|
534
534
|
}, m = we(() => {
|
|
535
|
-
const f = v(t),
|
|
536
|
-
g(
|
|
535
|
+
const f = v(t), x = d(f);
|
|
536
|
+
g(x);
|
|
537
537
|
}, ((Z = e == null ? void 0 : e.sensor) == null ? void 0 : Z.throttle) ?? 0), h = () => {
|
|
538
538
|
m(), i = requestAnimationFrame(h);
|
|
539
|
-
},
|
|
539
|
+
}, z = () => h(), w = () => {
|
|
540
540
|
i !== null && (cancelAnimationFrame(i), i = null);
|
|
541
541
|
};
|
|
542
542
|
return {
|
|
543
543
|
activate: (f) => {
|
|
544
|
-
t.draggingElements.value = u(n.value),
|
|
544
|
+
t.draggingElements.value = u(n.value), t.draggingElements.value.forEach(
|
|
545
|
+
(x) => {
|
|
546
|
+
var p, E;
|
|
547
|
+
return (E = (p = x.events).onStart) == null ? void 0 : E.call(p, t);
|
|
548
|
+
}
|
|
549
|
+
), f instanceof PointerEvent ? r(f) : l(f), z();
|
|
545
550
|
},
|
|
546
551
|
track: (f) => {
|
|
547
|
-
|
|
552
|
+
t.draggingElements.value.forEach(
|
|
553
|
+
(x) => {
|
|
554
|
+
var p, E;
|
|
555
|
+
return (E = (p = x.events).onMove) == null ? void 0 : E.call(p, t);
|
|
556
|
+
}
|
|
557
|
+
), f instanceof KeyboardEvent ? c() : a(f);
|
|
548
558
|
},
|
|
549
559
|
deactivate: (f = !0) => {
|
|
550
|
-
var
|
|
560
|
+
var x, p;
|
|
551
561
|
if (o(), s(), f) {
|
|
552
562
|
if (t.hovered.zone.value) {
|
|
553
|
-
const
|
|
554
|
-
(
|
|
563
|
+
const E = t.zonesMap.value.get(t.hovered.zone.value);
|
|
564
|
+
(p = E == null ? void 0 : (x = E.events).onDrop) == null || p.call(x, t);
|
|
555
565
|
} else
|
|
556
|
-
|
|
557
|
-
(
|
|
558
|
-
var D,
|
|
559
|
-
return (
|
|
566
|
+
t.draggingElements.value.forEach(
|
|
567
|
+
(E) => {
|
|
568
|
+
var D, M;
|
|
569
|
+
return (M = (D = E.events).onEnd) == null ? void 0 : M.call(D, t);
|
|
560
570
|
}
|
|
561
571
|
);
|
|
562
572
|
t.selectedElementsMap.value.clear();
|
|
563
573
|
}
|
|
564
|
-
t.draggingElements.value.clear(), t.hovered.zone.value = null, t.hovered.element.value = null,
|
|
574
|
+
t.draggingElements.value.clear(), t.hovered.zone.value = null, t.hovered.element.value = null, w();
|
|
565
575
|
}
|
|
566
576
|
};
|
|
567
577
|
}, ke = ie(() => {
|
|
@@ -578,14 +588,14 @@ const T = ie(() => {
|
|
|
578
588
|
return {
|
|
579
589
|
handleDragStart: (g, m, h) => {
|
|
580
590
|
d(), g.target.blur(), h != null && h.container && (s.component.value = pe(h.container));
|
|
581
|
-
const { activate:
|
|
591
|
+
const { activate: z, track: w, deactivate: _ } = be(m, h);
|
|
582
592
|
a = () => {
|
|
583
593
|
s.component.value = null, u(), _(!0), d();
|
|
584
594
|
}, o = () => {
|
|
585
595
|
s.component.value = null, u(), _(!1), d();
|
|
586
|
-
}, r = (
|
|
587
|
-
|
|
588
|
-
}, i(),
|
|
596
|
+
}, r = (P) => w(P), l = (P) => w(P), c = (P) => {
|
|
597
|
+
P.type === "keyup" && (P.code === "Escape" && (o == null || o()), P.code === "Enter" && (a == null || a())), w(P);
|
|
598
|
+
}, i(), z(g), document.addEventListener("pointermove", r), document.addEventListener("pointerup", a), document.addEventListener("wheel", l), document.addEventListener("keydown", c), document.addEventListener("keypress", c), document.addEventListener("keyup", c);
|
|
589
599
|
}
|
|
590
600
|
};
|
|
591
601
|
}), Ye = (n) => {
|
|
@@ -680,6 +690,7 @@ export {
|
|
|
680
690
|
Te as default,
|
|
681
691
|
O as getBoundingBox,
|
|
682
692
|
T as useDnDStore,
|
|
693
|
+
Pe as useDragContainer,
|
|
683
694
|
Ye as useDraggable,
|
|
684
695
|
Ue as useDroppable,
|
|
685
696
|
Ve as useSelection
|