@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, L, p;
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
- (p = (L = (h = e.zonesMap.value.get(r)) == null ? void 0 : h.data) == null ? void 0 : L.source) == null ? void 0 : p.length
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: L, ctrl: p, shift: _, alt: M, meta: A } = Me(), R = {
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: L,
173
- ctrl: p,
172
+ d: z,
173
+ ctrl: w,
174
174
  shift: _,
175
- alt: M,
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
- ([L, p]) => p.groups.length ? !p.groups.some(
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 && (c("remove", 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"));
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), L = r >= m.x && r <= m.x + m.width && a >= m.y && a <= m.y + m.height, p = le(m, e), _ = ae(t, h);
359
- let M = 0;
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) && M++;
361
+ A !== v && A && v && k(v, A) && P++;
362
362
  return {
363
363
  element: g,
364
364
  node: v,
365
- isPointerInElement: L,
366
- overlapPercent: p,
367
- depth: M,
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), L = r >= m.x && r <= m.x + m.width && a >= m.y && a <= m.y + m.height, p = le(m, e), _ = ae(t, h);
387
- let M = 0;
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) && M++;
389
+ A !== v && A && v && k(v, A) && P++;
390
390
  return {
391
391
  zone: g,
392
392
  node: v,
393
- isPointerInElement: L,
394
- overlapPercent: p,
395
- depth: M,
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, E;
479
+ var D, M;
480
480
  if (!f) return /* @__PURE__ */ new Map();
481
- const z = t.selectedElementsMap.value.has(f);
482
- if (t.selectedElementsMap.value.size > 0 && z) {
483
- const P = /* @__PURE__ */ new Map();
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
- P.set(I, {
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
- ), P;
493
+ ), L;
494
494
  }
495
495
  t.selectedElementsMap.value.clear();
496
- const x = t.elementsMap.value.get(f);
497
- if (!x) return /* @__PURE__ */ new Map();
498
- const w = /* @__PURE__ */ new Map();
499
- return w.set(f, {
500
- ...x,
501
- initialHTML: ((D = x.node) == null ? void 0 : D.outerHTML) ?? "",
502
- initialRect: (E = x.node) == null ? void 0 : E.getBoundingClientRect()
503
- }), w;
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 z = Array.isArray(f) ? f : [f], x = Array.from(t.draggingElements.value.keys()), w = z.find((E) => {
508
- if (!t.visibleZones.value.has(E)) return !1;
509
- const P = t.zonesMap.value.get(E);
510
- return !(!P || x.some(
511
- (I) => I && (I === P.node || k(P.node, I))
512
- ) || P.groups.length && !!Array.from(
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) => P.groups.includes(V)) : !1));
514
+ ).some((Y) => Y.groups.length ? !Y.groups.some((V) => L.groups.includes(V)) : !1));
515
515
  });
516
- return w ? {
517
- element: z.find(
518
- (E) => t.visibleElements.value.has(E) && t.elementsMap.value.has(E) && !x.some(
519
- (P) => P && (P === E || k(
520
- E,
521
- P
522
- ) || k(P, E))
523
- ) && (E === w || k(
524
- E,
525
- w
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: w
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 w, D, E, P, I, Y, V, H, j, J, X, Q;
532
- const z = t.hovered.element.value, x = t.hovered.zone.value;
533
- t.hovered.element.value = f.element, t.hovered.zone.value = f.zone, z && t.hovered.element.value !== z && ((E = (D = (w = t.elementsMap.value.get(z)) == null ? void 0 : w.events) == null ? void 0 : D.onLeave) == null || E.call(D, t), t.hovered.element.value && ((Y = (I = (P = t.elementsMap.value.get(t.hovered.element.value)) == null ? void 0 : P.events) == null ? void 0 : I.onHover) == null || Y.call(I, t))), x && t.hovered.zone.value !== x && ((j = (H = (V = t.zonesMap.value.get(x)) == 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)));
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), z = d(f);
536
- g(z);
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
- }, L = () => h(), p = () => {
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), f instanceof PointerEvent ? r(f) : l(f), L();
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
- f instanceof KeyboardEvent ? c() : a(f);
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 z, x;
560
+ var x, p;
551
561
  if (o(), s(), f) {
552
562
  if (t.hovered.zone.value) {
553
- const w = t.zonesMap.value.get(t.hovered.zone.value);
554
- (x = w == null ? void 0 : (z = w.events).onDrop) == null || x.call(z, t);
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
- Array.from(t.draggingElements.value.values()).forEach(
557
- (w) => {
558
- var D, E;
559
- return (E = (D = w.events).onEnd) == null ? void 0 : E.call(D, t);
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, p();
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: L, track: p, deactivate: _ } = be(m, h);
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 = (M) => p(M), l = (M) => p(M), c = (M) => {
587
- M.type === "keyup" && (M.code === "Escape" && (o == null || o()), M.code === "Enter" && (a == null || a())), p(M);
588
- }, i(), L(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);
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