@vue-dnd-kit/core 2.0.0-alpha3 → 2.0.0-alpha4

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.
@@ -1,14 +1,14 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-default-overlay{transform:translate3d(var(--position-x),var(--position-y),0)}.dnd-kit-overlay-container{position:fixed;top:0;left:0;pointer-events:none;cursor:grabbing}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { ref as F, watch as Ae, shallowRef as ne, reactive as _, computed as E, onMounted as R, onBeforeUnmount as P, inject as de, defineComponent as ye, unref as A, openBlock as p, createElementBlock as K, normalizeStyle as se, Fragment as X, renderList as we, createBlock as V, resolveDynamicComponent as q, createCommentVNode as xe, useTemplateRef as Le, provide as Ce, renderSlot as ie, createElementVNode as ke } from "vue";
3
- const v = {
2
+ import { ref as I, watch as Se, shallowRef as ne, reactive as _, computed as E, onMounted as R, onBeforeUnmount as P, inject as de, defineComponent as ye, unref as A, openBlock as v, createElementBlock as K, normalizeStyle as se, Fragment as Z, renderList as Ae, createBlock as V, resolveDynamicComponent as q, createCommentVNode as we, useTemplateRef as xe, provide as Le, renderSlot as ie, createElementVNode as Ce } from "vue";
3
+ const M = {
4
4
  SELECT_AREA: "data-dnd-kit-select-area",
5
5
  DRAGGABLE: "data-dnd-kit-draggable",
6
6
  DROPPABLE: "data-dnd-kit-droppable",
7
7
  CONSTRAINT_AREA: "data-dnd-kit-constraint-area"
8
8
  }, k = {
9
- SELECT_AREA: `[${v.SELECT_AREA}]`,
10
- DRAGGABLE: `[${v.DRAGGABLE}]`,
11
- CONSTRAINT_AREA: `[${v.CONSTRAINT_AREA}]`
9
+ SELECT_AREA: `[${M.SELECT_AREA}]`,
10
+ DRAGGABLE: `[${M.DRAGGABLE}]`,
11
+ CONSTRAINT_AREA: `[${M.CONSTRAINT_AREA}]`
12
12
  }, te = "VueDnDKitProvider", ae = (e, t, n, s) => {
13
13
  const i = /* @__PURE__ */ new Set();
14
14
  return t.forEach((a) => {
@@ -22,14 +22,14 @@ const v = {
22
22
  l[c]((u) => n.value.has(u)) && i.add(a);
23
23
  }), i;
24
24
  };
25
- let be = "", Re = "", Pe = "";
26
- const N = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, B = (e, t) => e !== t && e.contains(t), Be = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), W = () => {
25
+ let be = "", ke = "", Re = "";
26
+ const N = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, B = (e, t) => e !== t && e.contains(t), Pe = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), W = () => {
27
27
  const e = document.body;
28
28
  be = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", m), window.addEventListener("selectstart", m), window.addEventListener("touchstart", m), window.addEventListener("touchmove", m);
29
29
  }, j = () => {
30
30
  const e = document.body;
31
- e.style.userSelect = be, e.style.touchAction = Re, e.style.overscrollBehavior = Pe, window.removeEventListener("contextmenu", m), window.removeEventListener("selectstart", m), window.removeEventListener("touchstart", m), window.removeEventListener("touchmove", m);
32
- }, m = (e) => e.preventDefault(), M = (e, t) => {
31
+ e.style.userSelect = be, e.style.touchAction = ke, e.style.overscrollBehavior = Re, window.removeEventListener("contextmenu", m), window.removeEventListener("selectstart", m), window.removeEventListener("touchstart", m), window.removeEventListener("touchmove", m);
32
+ }, m = (e) => e.preventDefault(), S = (e, t) => {
33
33
  if (t.entities.draggableMap.get(e)?.disabled) return !0;
34
34
  for (const [s, i] of t.entities.draggableMap)
35
35
  if (i.disabled && B(s, e)) return !0;
@@ -51,7 +51,7 @@ const N = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$e
51
51
  unobserve: (n) => t.unobserve(n),
52
52
  disconnect: () => t.disconnect()
53
53
  };
54
- }, Oe = (e) => {
54
+ }, Be = (e) => {
55
55
  const t = new ResizeObserver((n) => {
56
56
  const s = n[0];
57
57
  if (!s) return;
@@ -63,8 +63,8 @@ const N = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$e
63
63
  unobserve: (n) => t.unobserve(n),
64
64
  disconnect: () => t.disconnect()
65
65
  };
66
- }, Te = (e) => {
67
- const t = F(null), n = Oe(t), s = Ae(
66
+ }, Oe = (e) => {
67
+ const t = I(null), n = Be(t), s = Se(
68
68
  e,
69
69
  (a) => {
70
70
  n.disconnect(), a && n.observe(a);
@@ -92,30 +92,31 @@ function he(e, t) {
92
92
  return {
93
93
  ...t,
94
94
  initialHTML: e.innerHTML,
95
- initialRect: e.getBoundingClientRect()
95
+ initialRect: e.getBoundingClientRect(),
96
+ initialOuterHTML: e.outerHTML
96
97
  };
97
98
  }
98
- function ze(e, t, n) {
99
+ function Te(e, t, n) {
99
100
  e.forEach((s) => {
100
101
  const i = t.get(s);
101
102
  n.set(s, he(s, i));
102
103
  }), e.clear();
103
104
  }
104
- function _e(e, t, n) {
105
+ function ze(e, t, n) {
105
106
  n.clear();
106
107
  const s = t.get(e);
107
108
  n.set(e, he(e, s));
108
109
  }
109
- function G(e) {
110
- e.entities.initiatingDraggable && (e.state.value = "dragging", Ie(
110
+ function H(e) {
111
+ e.entities.initiatingDraggable && (e.state.value = "dragging", _e(
111
112
  e.entities.initiatingDraggable,
112
113
  e.entities.selectedSet,
113
114
  e.entities.draggableMap,
114
115
  e.entities.draggingMap
115
116
  ));
116
117
  }
117
- function Ie(e, t, n, s) {
118
- t.has(e) ? ze(t, n, s) : (t.clear(), _e(e, n, s));
118
+ function _e(e, t, n, s) {
119
+ t.has(e) ? Te(t, n, s) : (t.clear(), ze(e, n, s));
119
120
  }
120
121
  function De(e, t, n, s) {
121
122
  if (s || !n) return !0;
@@ -143,7 +144,7 @@ function pe(e, t, n) {
143
144
  const s = n.distance != null, i = n.delay != null;
144
145
  return !s && !i ? !0 : s && !i ? e >= 1 : !s && i ? t >= 1 : (n.condition ?? "both") === "both" ? e >= 1 && t >= 1 : e >= 1 || t >= 1;
145
146
  }
146
- function Ke(e) {
147
+ function Ie(e) {
147
148
  if (e.state.value !== "activating" || !e.entities.initiatingDraggable)
148
149
  return !1;
149
150
  const t = e.entities.draggableMap.get(
@@ -153,9 +154,9 @@ function Ke(e) {
153
154
  e.distanceProgress.value,
154
155
  e.delay.progress,
155
156
  t?.activation
156
- ) ? (G(e), !0) : !1;
157
+ ) ? (H(e), !0) : !1;
157
158
  }
158
- function Ge(e, t) {
159
+ function Ke(e, t) {
159
160
  let n = null;
160
161
  const s = () => {
161
162
  if (e.state.value !== "activating" || !e.entities.initiatingDraggable) {
@@ -193,10 +194,10 @@ function He(e, t) {
193
194
  entity: t.get(n)
194
195
  };
195
196
  }
196
- function Ne(e, t, n, s) {
197
+ function Ge(e, t, n, s) {
197
198
  return n === "x" ? { x: e, y: s.top } : n === "y" ? { x: s.left, y: t } : { x: e, y: t };
198
199
  }
199
- function Ue(e, t, n, s, i) {
200
+ function Ne(e, t, n, s, i) {
200
201
  let a = e, o = t;
201
202
  return n !== "y" && (a = Math.max(
202
203
  s.left,
@@ -206,7 +207,7 @@ function Ue(e, t, n, s, i) {
206
207
  Math.min(s.bottom - i.height, t)
207
208
  )), { x: a, y: o };
208
209
  }
209
- function Ye(e, t, n, s, i) {
210
+ function Ue(e, t, n, s, i) {
210
211
  if (!e || !t)
211
212
  return { x: 0, y: 0 };
212
213
  const a = t.getBoundingClientRect(), o = a.width || i?.width || 0, r = a.height || i?.height || 0;
@@ -216,13 +217,13 @@ function Ye(e, t, n, s, i) {
216
217
  const f = He(n, s);
217
218
  if (!f)
218
219
  return { x: l, y: c };
219
- const { element: u, entity: d } = f, g = u.getBoundingClientRect(), y = n.getBoundingClientRect(), b = Ne(
220
+ const { element: u, entity: d } = f, g = u.getBoundingClientRect(), y = n.getBoundingClientRect(), b = Ge(
220
221
  l,
221
222
  c,
222
223
  d.axis || "both",
223
224
  y
224
225
  );
225
- return d.restrictToArea ? Ue(
226
+ return d.restrictToArea ? Ne(
226
227
  b.x,
227
228
  b.y,
228
229
  d.axis || "both",
@@ -246,10 +247,10 @@ const C = {
246
247
  ],
247
248
  forMoveFaster: ["ShiftLeft", "ShiftRight"]
248
249
  };
249
- function Ze(e) {
250
- const t = ne(), n = F(), i = {
250
+ function Ye(e) {
251
+ const t = ne(), n = I(), i = {
251
252
  keys: {
252
- pressedKeys: F(/* @__PURE__ */ new Set()),
253
+ pressedKeys: I(/* @__PURE__ */ new Set()),
253
254
  forDrag: [...C.forDrag],
254
255
  forCancel: [...C.forCancel],
255
256
  forDrop: [...C.forDrop],
@@ -276,7 +277,7 @@ function Ze(e) {
276
277
  a.draggableMap,
277
278
  a.visibleDraggableSet,
278
279
  i.keys.pressedKeys,
279
- (z) => M(z, { entities: a })
280
+ (z) => S(z, { entities: a })
280
281
  )),
281
282
  visibleDraggableSet: /* @__PURE__ */ new Set(),
282
283
  visibleDroppableSet: /* @__PURE__ */ new Set(),
@@ -297,15 +298,15 @@ function Ze(e) {
297
298
  a.visibleDroppableSet
298
299
  ), u = Y(
299
300
  a.visibleSelectableAreaSet
300
- ), { overlaySize: d, overlaySizeObserver: g } = Te(e), y = F(), b = _({
301
+ ), { overlaySize: d, overlaySizeObserver: g } = Oe(e), y = I(), b = _({
301
302
  draggable: /* @__PURE__ */ new Map(),
302
303
  droppable: /* @__PURE__ */ new Map()
303
- }), D = {
304
+ }), p = {
304
305
  throttle: ne(0)
305
306
  }, O = E(() => {
306
307
  o.y, o.x;
307
308
  const T = a.initiatingDraggable;
308
- return Ye(
309
+ return Ue(
309
310
  n.value,
310
311
  e.value,
311
312
  T || null,
@@ -322,7 +323,7 @@ function Ze(e) {
322
323
  delay: r,
323
324
  distanceProgress: l,
324
325
  hovered: b,
325
- collision: D,
326
+ collision: p,
326
327
  overlay: {
327
328
  size: d,
328
329
  style: O,
@@ -337,9 +338,9 @@ function Ze(e) {
337
338
  }
338
339
  };
339
340
  }
340
- const H = (e) => {
341
+ const G = (e) => {
341
342
  e.pointer.value = void 0, e.state.value = void 0, e.entities.selectingArea = void 0, e.entities.initiatingDraggable = void 0, e.delay.progress = 0, e.delay.startTime = 0, e.entities.draggingMap.clear(), e.hovered.draggable.clear(), e.hovered.droppable.clear();
342
- }, Ee = (e) => {
343
+ }, $e = (e) => {
343
344
  const t = e.entities.initiatingDraggable;
344
345
  if (!t) return;
345
346
  const s = e.entities.draggableMap.get(t)?.payload;
@@ -352,46 +353,65 @@ const H = (e) => {
352
353
  items: Array.isArray(o) ? o : [],
353
354
  dropData: r
354
355
  };
355
- }, w = (e) => e.keys().next().value, $e = (e) => e.target.closest(k.DRAGGABLE), S = (e) => ({
356
- payload: Ee(e),
357
- provider: e
358
- }), Z = (e, t, n) => {
359
- const s = $e(t);
356
+ }, Xe = (e, t) => {
357
+ const s = e.entities.droppableMap.get(t)?.payload;
358
+ if (!s) return;
359
+ const i = s();
360
+ if (!Array.isArray(i) || i.length < 1) return;
361
+ const [a, o] = i;
362
+ return {
363
+ items: Array.isArray(a) ? a : [],
364
+ userData: o
365
+ };
366
+ }, w = (e) => e.keys().next().value, Ze = (e) => e.target.closest(k.DRAGGABLE), D = (e, t) => {
367
+ const n = {
368
+ payload: $e(e),
369
+ provider: e
370
+ };
371
+ return t && (n.dropZonePayload = Xe(e, t)), n;
372
+ }, $ = (e, t, n) => {
373
+ const s = Ze(t);
360
374
  if (!s || !e.entities.draggingMap.has(s)) return;
361
- const i = S(e);
375
+ const i = D(e);
362
376
  e.entities.draggingMap.get(s)?.events?.[n]?.(i);
363
377
  }, x = (e, t, n) => {
364
- if (!t || M(t, e)) return;
365
- const s = S(e);
378
+ if (!t || S(t, e)) return;
379
+ const s = D(e);
366
380
  e.entities.draggableMap.get(t)?.events?.[n]?.(s);
367
381
  }, h = (e, t) => {
368
- const n = S(e);
382
+ const n = D(e);
369
383
  e.entities.draggableMap.forEach((s, i) => {
370
- M(i, e) || s.events?.[t]?.(n);
384
+ S(i, e) || s.events?.[t]?.(n);
371
385
  });
372
- }, Xe = (e, t, n) => {
386
+ }, Ve = (e, t, n) => {
373
387
  if (t !== n) {
374
- const s = S(e);
375
- t && !L(t, e) && e.entities.droppableMap.get(t)?.events?.onLeave?.(s), n && !L(n, e) && e.entities.droppableMap.get(n)?.events?.onEnter?.(s);
388
+ if (t && !L(t, e)) {
389
+ const s = D(e, t);
390
+ e.entities.droppableMap.get(t)?.events?.onLeave?.(s);
391
+ }
392
+ if (n && !L(n, e)) {
393
+ const s = D(e, n);
394
+ e.entities.droppableMap.get(n)?.events?.onEnter?.(s);
395
+ }
376
396
  }
377
- }, Ve = (e, t, n) => {
397
+ }, qe = (e, t, n) => {
378
398
  if (t !== n) {
379
- const s = S(e);
380
- t && !M(t, e) && e.entities.draggableMap.get(t)?.events?.onLeave?.(s), n && !M(n, e) && e.entities.draggableMap.get(n)?.events?.onHover?.(s);
399
+ const s = D(e);
400
+ t && !S(t, e) && e.entities.draggableMap.get(t)?.events?.onLeave?.(s), n && !S(n, e) && e.entities.draggableMap.get(n)?.events?.onHover?.(s);
381
401
  }
382
- }, qe = (e, t) => {
402
+ }, We = (e, t) => {
383
403
  const n = w(t.droppable);
384
404
  if (n && !L(n, e)) {
385
- const s = S(e);
405
+ const s = D(e, n);
386
406
  e.entities.droppableMap.get(n)?.events?.onLeave?.(s);
387
407
  }
388
408
  }, ve = (e, t) => {
389
409
  const n = w(t.droppable);
390
410
  if (n && !L(n, e)) {
391
- const s = S(e);
411
+ const s = D(e, n);
392
412
  e.entities.droppableMap.get(n)?.events?.onLeave?.(s);
393
413
  }
394
- }, We = (e, t) => !e.length || !t.length ? !0 : e.some((n) => t.includes(n)), je = (e, t, n) => {
414
+ }, je = (e, t) => !e.length || !t.length ? !0 : e.some((n) => t.includes(n)), Je = (e, t, n) => {
395
415
  if (!n) return {};
396
416
  const s = n.getBoundingClientRect(), i = Math.max(s.left, Math.min(e.x, t.x)), a = Math.max(s.top, Math.min(e.y, t.y)), o = Math.min(s.right, Math.max(e.x, t.x)), r = Math.min(s.bottom, Math.max(e.y, t.y)), l = Math.max(0, o - i), c = Math.max(0, r - a);
397
417
  return {
@@ -404,29 +424,29 @@ const H = (e) => {
404
424
  border: "1px solid #3b82f6",
405
425
  backgroundColor: "#3b82f61a"
406
426
  };
407
- }, Je = (e) => {
427
+ }, Qe = (e) => {
408
428
  if (!e.pointer.value || !e.entities.selectingArea) return;
409
- const { selectingArea: t } = e.entities, n = Qe(
429
+ const { selectingArea: t } = e.entities, n = et(
410
430
  e.pointer.value.start,
411
431
  e.pointer.value.current
412
432
  ), s = e.entities.selectableAreaMap.get(t)?.groups ?? [];
413
433
  e.entities.visibleDraggableSet.forEach((i) => {
414
434
  if (!t.contains(i)) return;
415
- if (M(i, e)) {
435
+ if (S(i, e)) {
416
436
  e.entities.selectedSet.delete(i);
417
437
  return;
418
438
  }
419
439
  const o = e.entities.draggableMap.get(i)?.groups ?? [];
420
- if (!We(s, o)) {
440
+ if (!je(s, o)) {
421
441
  e.entities.selectedSet.delete(i);
422
442
  return;
423
443
  }
424
- Be(n, i.getBoundingClientRect()) ? e.entities.selectedSet.add(i) : e.entities.selectedSet.delete(i);
444
+ Pe(n, i.getBoundingClientRect()) ? e.entities.selectedSet.add(i) : e.entities.selectedSet.delete(i);
425
445
  });
426
- }, Qe = (e, t) => {
446
+ }, et = (e, t) => {
427
447
  const n = Math.min(e.x, t.x), s = Math.min(e.y, t.y), i = Math.max(e.x, t.x), a = Math.max(e.y, t.y), o = i - n, r = a - s;
428
448
  return new DOMRect(n, s, o, r);
429
- }, et = (e, t, n = 5) => {
449
+ }, tt = (e, t, n = 5) => {
430
450
  const s = n / 2;
431
451
  return {
432
452
  left: e - s,
@@ -434,14 +454,14 @@ const H = (e) => {
434
454
  width: n,
435
455
  height: n
436
456
  };
437
- }, tt = (e) => {
457
+ }, nt = (e) => {
438
458
  const t = e.pointer.value?.current, n = t?.x ?? 0, s = t?.y ?? 0;
439
- return et(n, s, 5);
440
- }, I = (e, t, n) => {
459
+ return tt(n, s, 5);
460
+ }, F = (e, t, n) => {
441
461
  const s = e.left + e.width / 2, i = e.top + e.height / 2;
442
462
  if (n) {
443
- const f = n.top ?? 0, u = n.right ?? 0, d = n.bottom ?? 0, g = n.left ?? 0, y = t.left + g, b = t.right - u, D = t.top + f, O = t.bottom - d;
444
- if (y < b && D < O && s >= y && s <= b && i >= D && i <= O)
463
+ const f = n.top ?? 0, u = n.right ?? 0, d = n.bottom ?? 0, g = n.left ?? 0, y = t.left + g, b = t.right - u, p = t.top + f, O = t.bottom - d;
464
+ if (y < b && p < O && s >= y && s <= b && i >= p && i <= O)
445
465
  return { top: !1, right: !1, bottom: !1, left: !1, center: !0 };
446
466
  }
447
467
  const a = i - t.top, o = t.bottom - i, r = s - t.left, l = t.right - s, c = Math.min(a, o, r, l);
@@ -451,20 +471,20 @@ const H = (e) => {
451
471
  left: r === c,
452
472
  right: l === c
453
473
  };
454
- }, nt = (e, t) => e.find((n) => n !== t && B(t, n)), Q = (e, t, n) => {
474
+ }, st = (e, t) => e.find((n) => n !== t && B(t, n)), Q = (e, t, n) => {
455
475
  const s = w(t.droppable), i = w(t.draggable);
456
476
  t.draggable.clear(), t.droppable.clear();
457
- const a = tt(e), o = n.zones[0], r = n.elements[0];
477
+ const a = nt(e), o = n.zones[0], r = n.elements[0];
458
478
  if (o && r && o === r && e.entities.droppableMap.has(o) && o) {
459
- const u = o.getBoundingClientRect(), d = e.entities.draggableMap.get(o)?.placementMargins, g = I(a, u, d);
479
+ const u = o.getBoundingClientRect(), d = e.entities.draggableMap.get(o)?.placementMargins, g = F(a, u, d);
460
480
  if (g.center) {
461
481
  t.droppable.set(o, g);
462
- const y = nt(n.elements, o);
482
+ const y = st(n.elements, o);
463
483
  if (y) {
464
484
  const b = y.getBoundingClientRect();
465
485
  t.draggable.set(
466
486
  y,
467
- I(a, b, void 0)
487
+ F(a, b, void 0)
468
488
  );
469
489
  }
470
490
  } else
@@ -472,19 +492,19 @@ const H = (e) => {
472
492
  } else {
473
493
  if (o) {
474
494
  const u = o.getBoundingClientRect();
475
- t.droppable.set(o, I(a, u));
495
+ t.droppable.set(o, F(a, u));
476
496
  }
477
497
  if (r) {
478
498
  const u = r.getBoundingClientRect(), d = e.entities.draggableMap.get(r)?.placementMargins;
479
499
  t.draggable.set(
480
500
  r,
481
- I(a, u, d)
501
+ F(a, u, d)
482
502
  );
483
503
  }
484
504
  }
485
505
  const c = w(t.droppable), f = w(t.draggable);
486
- Xe(e, s, c), Ve(e, i, f);
487
- }, st = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, oe = (e) => {
506
+ Ve(e, s, c), qe(e, i, f);
507
+ }, it = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, oe = (e) => {
488
508
  if (!e)
489
509
  return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
490
510
  const t = e.getBoundingClientRect();
@@ -501,7 +521,7 @@ const H = (e) => {
501
521
  }, re = (e) => ({
502
522
  x: e.x + e.width / 2,
503
523
  y: e.y + e.height / 2
504
- }), it = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), at = (e, t) => {
524
+ }), at = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), ot = (e, t) => {
505
525
  const n = Math.max(
506
526
  0,
507
527
  Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)
@@ -510,7 +530,7 @@ const H = (e) => {
510
530
  Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
511
531
  ), i = n * s, a = e.width * e.height, o = t.width * t.height;
512
532
  return a === 0 || o === 0 ? 0 : (i / a * 100 + i / o * 100) / 2;
513
- }, ot = (e, t, n) => t >= e.x && t <= e.x + e.width && n >= e.y && n <= e.y + e.height, le = () => !0, ce = () => 0, rt = () => {
533
+ }, rt = (e, t, n) => t >= e.x && t <= e.x + e.width && n >= e.y && n <= e.y + e.height, le = () => !0, ce = () => 0, lt = () => {
514
534
  const e = {
515
535
  filterElements: le,
516
536
  filterZones: le,
@@ -521,16 +541,16 @@ const H = (e) => {
521
541
  const y = oe(g);
522
542
  if (!c(y, u)) return null;
523
543
  let b = 0;
524
- for (const D of f)
525
- D !== g && B(D, g) && b++;
544
+ for (const p of f)
545
+ p !== g && B(p, g) && b++;
526
546
  return {
527
547
  node: g,
528
548
  box: y,
529
549
  meta: {
530
- isPointerInElement: ot(y, a.x, a.y),
531
- overlapPercent: at(y, i),
550
+ isPointerInElement: rt(y, a.x, a.y),
551
+ overlapPercent: ot(y, i),
532
552
  depth: b,
533
- centerDistance: it(re(i), re(y))
553
+ centerDistance: at(re(i), re(y))
534
554
  }
535
555
  };
536
556
  }).filter((g) => g !== null);
@@ -595,7 +615,7 @@ const H = (e) => {
595
615
  }
596
616
  };
597
617
  return n;
598
- }, lt = () => rt(), ct = (e) => e.overlay.ref?.value ?? null, gt = (e) => {
618
+ }, ct = () => lt(), gt = (e) => e.overlay.ref?.value ?? null, ut = (e) => {
599
619
  const t = e.overlay.style?.value ?? { x: 0, y: 0 }, n = e.overlay.size?.value ?? null, { x: s, y: i } = t, a = n?.width ?? 0, o = n?.height ?? 0;
600
620
  return {
601
621
  x: s,
@@ -607,9 +627,9 @@ const H = (e) => {
607
627
  right: s + a,
608
628
  bottom: i + o
609
629
  };
610
- }, ut = (e) => e.entities.visibleDraggableSet, ft = (e) => e.entities.visibleDroppableSet, dt = (e, t) => !t.entities.draggingMap.has(e), yt = (e, t) => ![...t.entities.draggingMap.keys()].some(
630
+ }, ft = (e) => e.entities.visibleDraggableSet, dt = (e) => e.entities.visibleDroppableSet, yt = (e, t) => !t.entities.draggingMap.has(e), bt = (e, t) => ![...t.entities.draggingMap.keys()].some(
611
631
  (n) => B(n, e)
612
- ), bt = (e, t) => t.entities.draggableMap.has(e) ? !M(e, t) : t.entities.droppableMap.has(e) ? !L(e, t) : !0, ge = (e, t) => dt(e, t) && yt(e, t) && bt(e, t), mt = (e, t) => st(e, t.containerBox), ue = (e, t, n) => {
632
+ ), mt = (e, t) => t.entities.draggableMap.has(e) ? !S(e, t) : t.entities.droppableMap.has(e) ? !L(e, t) : !0, ge = (e, t) => yt(e, t) && bt(e, t) && mt(e, t), ht = (e, t) => it(e, t.containerBox), ue = (e, t, n) => {
613
633
  if (n.pointer.x >= n.containerBox.x && n.pointer.x <= n.containerBox.x + n.containerBox.width && n.pointer.y >= n.containerBox.y && n.pointer.y <= n.containerBox.y + n.containerBox.height) {
614
634
  if (e.meta.isPointerInElement && t.meta.isPointerInElement)
615
635
  return t.meta.depth - e.meta.depth;
@@ -617,12 +637,12 @@ const H = (e) => {
617
637
  return e.meta.isPointerInElement ? -1 : 1;
618
638
  }
619
639
  return Math.abs(e.meta.overlapPercent - t.meta.overlapPercent) <= 1 ? e.meta.centerDistance - t.meta.centerDistance : t.meta.overlapPercent - e.meta.overlapPercent;
620
- }, ee = lt().container(ct).containerBox(gt).elements(ut).zones(ft).filterElements(ge).filterZones(ge).collision(mt).sortElements(ue).sortZones(ue).build();
640
+ }, ee = ct().container(gt).containerBox(ut).elements(ft).zones(dt).filterElements(ge).filterZones(ge).collision(ht).sortElements(ue).sortZones(ue).build();
621
641
  function fe(e) {
622
642
  const n = (e.collision?.run ?? ee)(e);
623
643
  Q(e, e.hovered, n);
624
644
  }
625
- function ht(e, t) {
645
+ function Dt(e, t) {
626
646
  const n = e.collision?.throttle?.value ?? 0;
627
647
  if (n <= 0) {
628
648
  fe(e);
@@ -631,13 +651,10 @@ function ht(e, t) {
631
651
  const s = Date.now();
632
652
  s - t.value >= n && (t.value = s, fe(e));
633
653
  }
634
- async function Me(e) {
654
+ async function Ee(e) {
635
655
  const t = e.hovered.droppable.keys().next().value;
636
656
  if (!t || L(t, e)) return !0;
637
- const n = e.entities.droppableMap.get(t), s = {
638
- payload: Ee(e),
639
- provider: e
640
- }, i = n?.events?.onDrop?.(s);
657
+ const n = e.entities.droppableMap.get(t), s = D(e, t), i = n?.events?.onDrop?.(s);
641
658
  if (i != null && typeof i.then == "function")
642
659
  try {
643
660
  return await i, !0;
@@ -647,42 +664,42 @@ async function Me(e) {
647
664
  }
648
665
  return !0;
649
666
  }
650
- function Se(e) {
667
+ function Me(e) {
651
668
  const t = e.entities.initiatingDraggable;
652
- x(e, t, "onSelfDragEnd"), h(e, "onDragEnd"), qe(e, e.hovered);
669
+ x(e, t, "onSelfDragEnd"), h(e, "onDragEnd"), We(e, e.hovered);
653
670
  }
654
- function Dt(e) {
671
+ function pt(e) {
655
672
  const t = e.entities.selectingArea;
656
673
  if (!t) return;
657
674
  const n = e.entities.selectableAreaMap.get(t), s = [...e.entities.selectedSet];
658
675
  n?.events?.onSelected?.(s);
659
676
  }
660
- const pt = (e) => {
677
+ const vt = (e) => {
661
678
  const t = {
662
679
  current: null
663
680
  }, n = { value: 0 }, s = async () => {
664
681
  j(), t.current?.cancel(), t.current = null;
665
682
  const r = e.state.value;
666
683
  if (r === "dragging") {
667
- if (!await Me(e)) {
668
- H(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i);
684
+ if (!await Ee(e)) {
685
+ G(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i);
669
686
  return;
670
687
  }
671
- Se(e);
672
- } else r === "selecting" && Dt(e);
673
- H(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i);
688
+ Me(e);
689
+ } else r === "selecting" && pt(e);
690
+ G(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i);
674
691
  }, i = (r) => {
675
692
  if (e.pointer.value) {
676
- if (e.pointer.value.current = { x: r.clientX, y: r.clientY }, Ke(e)) {
677
- Z(e, r, "onSelfDragStart"), h(e, "onDragStart");
693
+ if (e.pointer.value.current = { x: r.clientX, y: r.clientY }, Ie(e)) {
694
+ $(e, r, "onSelfDragStart"), h(e, "onDragStart");
678
695
  return;
679
696
  }
680
697
  if (e.state.value === "dragging") {
681
- ht(e, n);
698
+ Dt(e, n);
682
699
  const l = e.entities.initiatingDraggable;
683
700
  x(e, l, "onSelfDragMove"), h(e, "onDragMove");
684
701
  }
685
- e.state.value === "selecting" && Je(e);
702
+ e.state.value === "selecting" && Qe(e);
686
703
  }
687
704
  };
688
705
  return { pointerDown: (r) => {
@@ -702,9 +719,9 @@ const pt = (e) => {
702
719
  return;
703
720
  W(), e.entities.initiatingDraggable = f;
704
721
  const d = me(r, f);
705
- e.pointer.value = J(r, d.x, d.y), u?.activation?.distance || u?.activation?.delay ? (e.state.value = "activating", u?.activation?.delay && (e.delay.startTime = Date.now(), t.current = Ge(e, () => {
706
- G(e), Z(e, r, "onSelfDragStart"), h(e, "onDragStart");
707
- }))) : (G(e), Z(e, r, "onSelfDragStart"), h(e, "onDragStart"));
722
+ e.pointer.value = J(r, d.x, d.y), u?.activation?.distance || u?.activation?.delay ? (e.state.value = "activating", u?.activation?.delay && (e.delay.startTime = Date.now(), t.current = Ke(e, () => {
723
+ H(e), $(e, r, "onSelfDragStart"), h(e, "onDragStart");
724
+ }))) : (H(e), $(e, r, "onSelfDragStart"), h(e, "onDragStart"));
708
725
  }
709
726
  }, pointerUp: s, pointerMove: i, cleanup: () => {
710
727
  t.current?.cancel(), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i), e.lib.draggableObserver.disconnect(), e.lib.droppableObserver.disconnect(), e.lib.selectableAreaObserver.disconnect(), e.lib.overlaySizeObserver.disconnect();
@@ -718,15 +735,15 @@ const pt = (e) => {
718
735
  KeyA: { dx: -1, dy: 0 },
719
736
  KeyS: { dx: 0, dy: 1 },
720
737
  KeyD: { dx: 1, dy: 0 }
721
- }, vt = (e) => (t) => {
738
+ }, Mt = (e) => (t) => {
722
739
  const { keys: n } = e.keyboard;
723
740
  if (n.pressedKeys.value.add(t.code), e.state.value === "dragging") {
724
741
  if (n.forCancel.includes(t.code)) {
725
- t.preventDefault(), j(), x(e, e.entities.initiatingDraggable, "onSelfDragCancel"), h(e, "onDragCancel"), ve(e, e.hovered), H(e);
742
+ t.preventDefault(), j(), x(e, e.entities.initiatingDraggable, "onSelfDragCancel"), h(e, "onDragCancel"), ve(e, e.hovered), G(e);
726
743
  return;
727
744
  }
728
745
  if (n.forDrop.includes(t.code)) {
729
- t.preventDefault(), (async () => (await Me(e) && Se(e), j(), H(e)))();
746
+ t.preventDefault(), (async () => (await Ee(e) && Me(e), j(), G(e)))();
730
747
  return;
731
748
  }
732
749
  const i = Et[t.code];
@@ -758,22 +775,22 @@ const pt = (e) => {
758
775
  };
759
776
  e.entities.initiatingDraggable = a;
760
777
  const u = me(f, a);
761
- e.pointer.value = J(f, u.x, u.y), G(e);
778
+ e.pointer.value = J(f, u.x, u.y), H(e);
762
779
  const g = (e.collision?.run ?? ee)(e);
763
780
  Q(e, e.hovered, g), x(e, a, "onSelfDragStart"), h(e, "onDragStart");
764
781
  }
765
- }, Mt = (e) => (t) => {
782
+ }, St = (e) => (t) => {
766
783
  e.keyboard.keys.pressedKeys.value.delete(t.code);
767
- }, St = (e) => () => {
768
- e.keyboard.keys.pressedKeys.value.clear();
769
- }, $ = {
770
- keyDown: vt,
771
- keyUp: Mt,
772
- clear: St
773
784
  }, At = (e) => () => {
785
+ e.keyboard.keys.pressedKeys.value.clear();
786
+ }, X = {
787
+ keyDown: Mt,
788
+ keyUp: St,
789
+ clear: At
790
+ }, wt = (e) => () => {
774
791
  e.state.value && (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY);
775
- }, wt = (e) => {
776
- const t = pt(e), n = $.keyDown(e), s = $.keyUp(e), i = $.clear(e), a = At(e);
792
+ }, xt = (e) => {
793
+ const t = vt(e), n = X.keyDown(e), s = X.keyUp(e), i = X.clear(e), a = wt(e);
777
794
  R(() => {
778
795
  document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", n), document.addEventListener("keyup", s), document.addEventListener("blur", i), document.addEventListener("scroll", a, !0);
779
796
  }), P(() => {
@@ -783,7 +800,7 @@ const pt = (e) => {
783
800
  const e = de(te);
784
801
  if (!e) throw Error("DnD provider not found");
785
802
  return e;
786
- }, xt = () => {
803
+ }, Lt = () => {
787
804
  const e = U();
788
805
  return {
789
806
  overlay: e.overlay,
@@ -797,11 +814,11 @@ const pt = (e) => {
797
814
  hovered: e.hovered,
798
815
  collision: e.collision
799
816
  };
800
- }, Lt = /* @__PURE__ */ ye({
817
+ }, Ct = /* @__PURE__ */ ye({
801
818
  __name: "DefaultOverlay",
802
819
  setup(e) {
803
- const { entities: t, state: n, overlay: s } = xt();
804
- return (i, a) => A(n) === "dragging" ? (p(), K("div", {
820
+ const { entities: t, state: n, overlay: s } = Lt();
821
+ return (i, a) => A(n) === "dragging" ? (v(), K("div", {
805
822
  key: 0,
806
823
  class: "dnd-kit-default-overlay",
807
824
  style: se({
@@ -809,13 +826,13 @@ const pt = (e) => {
809
826
  "--position-y": A(s).style.value.y + "px"
810
827
  })
811
828
  }, [
812
- (p(!0), K(X, null, we(A(t).draggingMap, ([o, r]) => (p(), K(X, null, [
813
- A(t).draggableMap.get(o)?.render ? (p(), V(q(A(t).draggableMap.get(o)?.render), {
829
+ (v(!0), K(Z, null, Ae(A(t).draggingMap, ([o, r]) => (v(), K(Z, null, [
830
+ A(t).draggableMap.get(o)?.render ? (v(), V(q(A(t).draggableMap.get(o)?.render), {
814
831
  key: 0,
815
832
  class: "test"
816
- })) : (p(), V(q(o.tagName), {
833
+ })) : (v(), V(q(o.tagName), {
817
834
  key: 1,
818
- innerHTML: r.initialHTML,
835
+ innerHTML: r.initialOuterHTML,
819
836
  class: "test",
820
837
  style: se({
821
838
  width: r.initialRect.width + "px",
@@ -823,35 +840,35 @@ const pt = (e) => {
823
840
  })
824
841
  }, null, 8, ["innerHTML", "style"]))
825
842
  ], 64))), 256))
826
- ], 4)) : xe("", !0);
843
+ ], 4)) : we("", !0);
827
844
  }
828
- }), kt = /* @__PURE__ */ ye({
845
+ }), Rt = /* @__PURE__ */ ye({
829
846
  __name: "DnDProvider",
830
847
  setup(e) {
831
- const t = Le("overlayRef"), n = Ze(t);
832
- wt(n);
848
+ const t = xe("overlayRef"), n = Ye(t);
849
+ xt(n);
833
850
  const s = E(
834
- () => n.overlay.render.value ?? Lt
851
+ () => n.overlay.render.value ?? Ct
835
852
  );
836
- return Ce(te, n), (i, a) => (p(), K(X, null, [
853
+ return Le(te, n), (i, a) => (v(), K(Z, null, [
837
854
  ie(i.$slots, "default"),
838
- ke("div", {
855
+ Ce("div", {
839
856
  ref_key: "overlayRef",
840
857
  ref: t,
841
858
  class: "dnd-kit-overlay-container"
842
859
  }, [
843
860
  ie(i.$slots, "overlay", { overlay: s.value }, () => [
844
- (p(), V(q(s.value)))
861
+ (v(), V(q(s.value)))
845
862
  ])
846
863
  ], 512)
847
864
  ], 64));
848
865
  }
849
866
  });
850
- function Rt(e, t, n) {
867
+ function Pt(e, t, n) {
851
868
  const s = U();
852
869
  let i, a, o;
853
870
  return typeof t == "function" ? (i = {}, a = t) : (i = t ?? {}, a = n), R(() => {
854
- o = N(e), o && (o.addEventListener("dragstart", m), o.addEventListener("drag", m), o.addEventListener("dragend", m), o.setAttribute(v.DRAGGABLE, ""), s.lib.draggableObserver.observe(o), s.entities.draggableMap.set(o, {
871
+ o = N(e), o && (o.addEventListener("dragstart", m), o.addEventListener("drag", m), o.addEventListener("dragend", m), o.setAttribute(M.DRAGGABLE, ""), s.lib.draggableObserver.observe(o), s.entities.draggableMap.set(o, {
855
872
  render: i.render,
856
873
  disabled: i.disabled ?? !1,
857
874
  groups: i.groups ?? [],
@@ -866,11 +883,11 @@ function Rt(e, t, n) {
866
883
  o && (s.lib.draggableObserver.unobserve(o), s.entities.visibleDraggableSet.delete(o), s.entities.draggableMap.delete(o), s.entities.modifiersDraggableSet.delete(o));
867
884
  }), {};
868
885
  }
869
- const Pt = (e, t) => {
886
+ const Bt = (e, t) => {
870
887
  const n = U(), s = E(() => e.value === n.entities.selectingArea);
871
888
  let i = null;
872
889
  R(() => {
873
- i = N(e), i && (i.setAttribute(v.SELECT_AREA, ""), n.lib.selectableAreaObserver.observe(i), n.entities.selectableAreaMap.set(i, {
890
+ i = N(e), i && (i.setAttribute(M.SELECT_AREA, ""), n.lib.selectableAreaObserver.observe(i), n.entities.selectableAreaMap.set(i, {
874
891
  modifier: t?.modifier ?? {
875
892
  keys: ["ControlLeft"],
876
893
  method: "every"
@@ -885,19 +902,19 @@ const Pt = (e, t) => {
885
902
  const a = E(() => {
886
903
  n.scrollPosition.x, n.scrollPosition.y;
887
904
  const o = n.pointer.value;
888
- return !o || n.state.value !== "selecting" || !i ? {} : je(o.start, o.current, i);
905
+ return !o || n.state.value !== "selecting" || !i ? {} : Je(o.start, o.current, i);
889
906
  });
890
907
  return {
891
908
  isSelecting: s,
892
909
  style: a
893
910
  };
894
911
  };
895
- function Bt(e, t) {
912
+ function Ot(e, t) {
896
913
  const n = de(te);
897
914
  if (!n) throw Error("DnD provider not found");
898
915
  let s = null;
899
916
  return R(() => {
900
- s = N(e), s && (s.setAttribute(v.CONSTRAINT_AREA, ""), n.entities.constraintsAreaMap.set(s, {
917
+ s = N(e), s && (s.setAttribute(M.CONSTRAINT_AREA, ""), n.entities.constraintsAreaMap.set(s, {
901
918
  axis: t?.axis || "both",
902
919
  restrictToArea: t?.restrictToArea || !1
903
920
  }));
@@ -905,25 +922,25 @@ function Bt(e, t) {
905
922
  s && n.entities.constraintsAreaMap.delete(s);
906
923
  }), {};
907
924
  }
908
- function Ot(e, t = {}) {
909
- const n = U();
910
- let s = null;
911
- R(() => {
912
- s = N(e), s && (s.setAttribute(v.DROPPABLE, ""), n.lib.droppableObserver.observe(s), n.entities.droppableMap.set(s, {
913
- disabled: t.disabled ?? !1,
914
- groups: t.groups ?? [],
915
- events: t.events
925
+ function Tt(e, t, n) {
926
+ const s = U();
927
+ let i = null, a, o;
928
+ typeof t == "function" ? (a = {}, o = t) : (a = t ?? {}, o = n), R(() => {
929
+ i = N(e), i && (i.setAttribute(M.DROPPABLE, ""), s.lib.droppableObserver.observe(i), s.entities.droppableMap.set(i, {
930
+ disabled: a.disabled ?? !1,
931
+ groups: a.groups ?? [],
932
+ events: a.events,
933
+ payload: o
916
934
  }));
917
935
  }), P(() => {
918
- s && (n.lib.droppableObserver.unobserve(s), n.entities.visibleDroppableSet.delete(s), n.entities.droppableMap.delete(s));
936
+ i && (s.lib.droppableObserver.unobserve(i), s.entities.visibleDroppableSet.delete(i), s.entities.droppableMap.delete(i));
919
937
  });
920
938
  }
921
939
  export {
922
- kt as DnDProvider,
923
- Bt as makeBoundingBox,
924
- Rt as makeDraggable,
925
- Ot as makeDroppable,
926
- Pt as makeSelectableArea,
927
- xt as useDnDProvider
940
+ Rt as DnDProvider,
941
+ Ot as makeConstraintArea,
942
+ Pt as makeDraggable,
943
+ Tt as makeDroppable,
944
+ Bt as makeSelectionArea,
945
+ Lt as useDnDProvider
928
946
  };
929
- //# sourceMappingURL=vue-dnd-kit-core.es.js.map