@vue-dnd-kit/core 0.0.25-beta → 0.0.27-beta

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,65 +1,154 @@
1
- import { effectScope as ie, ref as p, computed as w, onMounted as F, onBeforeUnmount as U, defineComponent as N, createElementBlock as $, createCommentVNode as se, unref as ee, openBlock as R, normalizeStyle as te, Fragment as ae, renderList as ue, createBlock as ce, resolveDynamicComponent as ve, renderSlot as de, createVNode as ge, markRaw as he } from "vue";
2
- let ne = !1, X;
3
- const I = () => (ne || (X = ie(!0).run(() => ({
4
- /** Whether any drag operation is currently active */
5
- isDragging: w(
6
- () => X.draggingElements.value.length > 0
7
- ),
8
- /** Active container where dragging occurs */
9
- activeContainer: {
10
- /** Component instance of active container */
11
- component: p(null),
12
- /** DOM reference of active container */
13
- ref: p(null)
14
- },
15
- /** All registered draggable elements */
16
- elements: p([]),
17
- /** Elements currently being dragged */
18
- draggingElements: p([]),
19
- /** Elements currently selected (for multi-drag) */
20
- selectedElements: p([]),
21
- /** All registered drop zones */
22
- zones: p([]),
23
- /** Current hover states */
24
- hovered: {
25
- /** Currently hovered drop zone */
26
- zone: p(null),
27
- /** Currently hovered draggable element */
28
- element: p(null)
29
- },
30
- /** Pointer position tracking */
31
- pointerPosition: {
32
- /** Current pointer coordinates */
33
- current: p(null),
34
- /** Initial coordinates when drag started */
35
- start: p(null),
36
- /** Offset from start position */
1
+ import { effectScope as ce, watch as se, nextTick as ve, getCurrentScope as de, onScopeDispose as ge, shallowRef as F, toValue as U, computed as w, getCurrentInstance as fe, onMounted as A, ref as E, onBeforeUnmount as W, defineComponent as ie, createElementBlock as $, createCommentVNode as he, unref as ne, openBlock as R, normalizeStyle as re, Fragment as me, renderList as pe, createBlock as ye, resolveDynamicComponent as Ee, markRaw as we } from "vue";
2
+ function Pe(t) {
3
+ return de() ? (ge(t), !0) : !1;
4
+ }
5
+ function xe(t) {
6
+ let e = !1, n;
7
+ const u = ce(!0);
8
+ return (...c) => (e || (n = u.run(() => t(...c)), e = !0), n);
9
+ }
10
+ const De = typeof window < "u" && typeof document < "u";
11
+ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
12
+ const Ie = (t) => t != null, X = () => {
13
+ };
14
+ function Se(t) {
15
+ return Array.isArray(t) ? t : [t];
16
+ }
17
+ function Me(t, e, n) {
18
+ const u = se(t, (...c) => (ve(() => u()), e(...c)), n);
19
+ return u;
20
+ }
21
+ const ae = De ? window : void 0;
22
+ function Y(t) {
23
+ var e;
24
+ const n = U(t);
25
+ return (e = n == null ? void 0 : n.$el) != null ? e : n;
26
+ }
27
+ function Ce() {
28
+ const t = F(!1), e = fe();
29
+ return e && A(() => {
30
+ t.value = !0;
31
+ }, e), t;
32
+ }
33
+ function Le(t) {
34
+ const e = Ce();
35
+ return w(() => (e.value, !!t()));
36
+ }
37
+ function _e(t, e, n = {}) {
38
+ const {
39
+ root: u,
40
+ rootMargin: c = "0px",
41
+ threshold: r = 0,
42
+ window: s = ae,
43
+ immediate: v = !0
44
+ } = n, f = Le(() => s && "IntersectionObserver" in s), p = w(() => {
45
+ const o = U(t);
46
+ return Se(o).map(Y).filter(Ie);
47
+ });
48
+ let l = X;
49
+ const g = F(v), x = f.value ? se(
50
+ () => [p.value, Y(u), g.value],
51
+ ([o, d]) => {
52
+ if (l(), !g.value || !o.length)
53
+ return;
54
+ const m = new IntersectionObserver(
55
+ e,
56
+ {
57
+ root: Y(d),
58
+ rootMargin: c,
59
+ threshold: r
60
+ }
61
+ );
62
+ o.forEach((h) => h && m.observe(h)), l = () => {
63
+ m.disconnect(), l = X;
64
+ };
65
+ },
66
+ { immediate: v, flush: "post" }
67
+ ) : X, y = () => {
68
+ l(), x(), g.value = !1;
69
+ };
70
+ return Pe(y), {
71
+ isSupported: f,
72
+ isActive: g,
73
+ pause() {
74
+ l(), g.value = !1;
75
+ },
76
+ resume() {
77
+ g.value = !0;
78
+ },
79
+ stop: y
80
+ };
81
+ }
82
+ function Oe(t, e = {}) {
83
+ const {
84
+ window: n = ae,
85
+ scrollTarget: u,
86
+ threshold: c = 0,
87
+ rootMargin: r,
88
+ once: s = !1
89
+ } = e, v = F(!1), { stop: f } = _e(
90
+ t,
91
+ (p) => {
92
+ let l = v.value, g = 0;
93
+ for (const x of p)
94
+ x.time >= g && (g = x.time, l = x.isIntersecting);
95
+ v.value = l, s && Me(v, () => {
96
+ f();
97
+ });
98
+ },
99
+ {
100
+ root: u,
101
+ window: n,
102
+ threshold: c,
103
+ rootMargin: U(r)
104
+ }
105
+ );
106
+ return v;
107
+ }
108
+ const C = xe(() => {
109
+ const t = E([]), e = w(() => t.value.length > 0), n = {
110
+ component: E(null),
111
+ ref: E(null)
112
+ }, u = E([]), c = E([]), r = E([]), s = {
113
+ zone: E(null),
114
+ element: E(null)
115
+ }, v = {
116
+ current: E(null),
117
+ start: E(null),
37
118
  offset: {
38
- /** Offset as percentage of container */
39
- percent: p(null),
40
- /** Offset in pixels */
41
- pixel: p(null)
119
+ percent: E(null),
120
+ pixel: E(null)
42
121
  }
43
- }
44
- })), ne = !0), X), fe = () => {
45
- const t = p(null), { draggingElements: e, pointerPosition: i, isDragging: u, activeContainer: c } = I();
46
- return F(() => {
122
+ };
123
+ return {
124
+ isDragging: e,
125
+ activeContainer: n,
126
+ elements: u,
127
+ draggingElements: t,
128
+ selectedElements: c,
129
+ zones: r,
130
+ hovered: s,
131
+ pointerPosition: v
132
+ };
133
+ }), ke = () => {
134
+ const t = E(null), { draggingElements: e, pointerPosition: n, isDragging: u, activeContainer: c } = C();
135
+ return A(() => {
47
136
  c.ref = t;
48
- }), U(() => {
137
+ }), W(() => {
49
138
  c.ref.value = null;
50
139
  }), {
51
140
  elementRef: t,
52
141
  draggingElements: e,
53
- pointerPosition: i,
142
+ pointerPosition: n,
54
143
  isDragging: u
55
144
  };
56
- }, me = ["innerHTML"], pe = /* @__PURE__ */ N({
145
+ }, Te = ["innerHTML"], ze = /* @__PURE__ */ ie({
57
146
  __name: "DefaultOverlay",
58
147
  setup(t) {
59
- const { elementRef: e, pointerPosition: i, isDragging: u, draggingElements: c } = fe(), n = w(() => {
60
- var s, h, f, y;
148
+ const { elementRef: e, pointerPosition: n, isDragging: u, draggingElements: c } = ke(), r = w(() => {
149
+ var s, v, f, p;
61
150
  return {
62
- transform: `translate3d(${(((s = i.current.value) == null ? void 0 : s.x) ?? 0) - (((h = i.offset.pixel.value) == null ? void 0 : h.x) ?? 0)}px, ${(((f = i.current.value) == null ? void 0 : f.y) ?? 0) - (((y = i.offset.pixel.value) == null ? void 0 : y.y) ?? 0)}px, 0)`,
151
+ transform: `translate3d(${(((s = n.current.value) == null ? void 0 : s.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((f = n.current.value) == null ? void 0 : f.y) ?? 0) - (((p = n.offset.pixel.value) == null ? void 0 : p.y) ?? 0)}px, 0)`,
63
152
  zIndex: 1e3,
64
153
  position: "fixed",
65
154
  top: 0,
@@ -67,66 +156,54 @@ const I = () => (ne || (X = ie(!0).run(() => ({
67
156
  transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
68
157
  };
69
158
  });
70
- return (s, h) => ee(u) ? (R(), $("div", {
159
+ return (s, v) => ne(u) ? (R(), $("div", {
71
160
  key: 0,
72
161
  ref_key: "elementRef",
73
162
  ref: e,
74
- style: te(n.value)
163
+ style: re(r.value)
75
164
  }, [
76
- (R(!0), $(ae, null, ue(ee(c), (f, y) => {
77
- var l, E;
165
+ (R(!0), $(me, null, pe(ne(c), (f, p) => {
166
+ var l, g;
78
167
  return R(), $("div", {
79
- key: y,
168
+ key: p,
80
169
  innerHTML: f.initialHTML,
81
- style: te({
170
+ style: re({
82
171
  width: `${(l = f.initialRect) == null ? void 0 : l.width}px`,
83
- height: `${(E = f.initialRect) == null ? void 0 : E.height}px`
172
+ height: `${(g = f.initialRect) == null ? void 0 : g.height}px`
84
173
  })
85
- }, null, 12, me);
174
+ }, null, 12, Te);
86
175
  }), 128))
87
- ], 4)) : se("", !0);
176
+ ], 4)) : he("", !0);
88
177
  }
89
- }), ye = /* @__PURE__ */ N({
178
+ }), be = /* @__PURE__ */ ie({
90
179
  __name: "DragOverlay",
91
180
  setup(t) {
92
- const { activeContainer: e } = I(), i = w(
93
- () => e.component.value ?? pe
181
+ const { activeContainer: e } = C(), n = w(
182
+ () => e.component.value ?? ze
94
183
  );
95
- return (u, c) => (R(), ce(ve(i.value)));
96
- }
97
- }), Ie = /* @__PURE__ */ N({
98
- __name: "DnDContext",
99
- setup(t) {
100
- const e = p(null);
101
- return (i, u) => (R(), $("div", {
102
- ref_key: "contextRef",
103
- ref: e
104
- }, [
105
- de(i.$slots, "default"),
106
- ge(ye)
107
- ], 512));
184
+ return (u, c) => (R(), ye(Ee(n.value)));
108
185
  }
109
- }), Ee = "data-dnd-draggable", Pe = (t) => {
186
+ }), He = "data-dnd-draggable", Re = (t) => {
110
187
  const {
111
188
  elements: e,
112
- draggingElements: i,
189
+ draggingElements: n,
113
190
  hovered: u,
114
191
  selectedElements: c,
115
- isDragging: n
116
- } = I(), s = p(null), h = w(
192
+ isDragging: r
193
+ } = C(), s = E(null), v = w(
117
194
  () => {
118
- var m;
119
- return ((m = u.element.value) == null ? void 0 : m.node) === s.value;
195
+ var y;
196
+ return ((y = u.element.value) == null ? void 0 : y.node) === s.value;
120
197
  }
121
- ), f = w(
122
- () => i.value.some((m) => m.node === s.value)
123
- ), y = w(() => {
124
- if (!s.value || !n.value) return !1;
125
- const m = e.value.find(
126
- (D) => D.node === s.value
198
+ ), f = Oe(s), p = w(
199
+ () => n.value.some((y) => y.node === s.value)
200
+ ), l = w(() => {
201
+ if (!s.value || !r.value) return !1;
202
+ const y = e.value.find(
203
+ (o) => o.node === s.value
127
204
  );
128
- return m != null && m.groups.length ? !i.value.some((D) => D.groups.length ? !D.groups.some(
129
- (r) => m.groups.includes(r)
205
+ return y != null && y.groups.length ? !n.value.some((o) => o.groups.length ? !o.groups.some(
206
+ (d) => y.groups.includes(d)
130
207
  ) : !1) : !0;
131
208
  });
132
209
  return {
@@ -139,37 +216,39 @@ const I = () => (ne || (X = ie(!0).run(() => ({
139
216
  layer: (t == null ? void 0 : t.layer) ?? null,
140
217
  defaultLayer: (t == null ? void 0 : t.layer) ?? null,
141
218
  events: (t == null ? void 0 : t.events) ?? {},
142
- data: (t == null ? void 0 : t.data) ?? void 0
143
- }), s.value.setAttribute(Ee, "true");
219
+ data: (t == null ? void 0 : t.data) ?? void 0,
220
+ isVisible: f.value
221
+ }), s.value.setAttribute(He, "true");
144
222
  },
145
223
  unregisterElement: () => {
146
- const m = e.value.findIndex(
147
- (r) => r.node === s.value
224
+ const y = e.value.findIndex(
225
+ (d) => d.node === s.value
148
226
  );
149
- m !== -1 && e.value.splice(m, 1);
150
- const D = c.value.findIndex(
151
- (r) => r.node === s.value
227
+ y !== -1 && e.value.splice(y, 1);
228
+ const o = c.value.findIndex(
229
+ (d) => d.node === s.value
152
230
  );
153
- D !== -1 && c.value.splice(D, 1);
231
+ o !== -1 && c.value.splice(o, 1);
154
232
  },
155
- isDragging: f,
156
- isOvered: h,
157
- isAllowed: y
233
+ isDragging: p,
234
+ isOvered: v,
235
+ isAllowed: l,
236
+ isVisible: f
158
237
  };
159
- }, we = () => {
160
- let t = "", e = "", i = "";
238
+ }, Ae = () => {
239
+ let t = "", e = "", n = "";
161
240
  const u = () => {
162
241
  const s = document.body;
163
- t = s.style.userSelect, e = s.style.touchAction, i = s.style.overscrollBehavior, s.style.userSelect = "none", s.style.touchAction = "none", s.style.overscrollBehavior = "none", window.addEventListener("contextmenu", n), window.addEventListener("selectstart", n), window.addEventListener("touchstart", n), window.addEventListener("touchmove", n);
242
+ t = s.style.userSelect, e = s.style.touchAction, n = s.style.overscrollBehavior, s.style.userSelect = "none", s.style.touchAction = "none", s.style.overscrollBehavior = "none", window.addEventListener("contextmenu", r), window.addEventListener("selectstart", r), window.addEventListener("touchstart", r), window.addEventListener("touchmove", r);
164
243
  }, c = () => {
165
244
  const s = document.body;
166
- s.style.userSelect = t, s.style.touchAction = e, s.style.overscrollBehavior = i, window.removeEventListener("contextmenu", n), window.removeEventListener("selectstart", n), window.removeEventListener("touchstart", n), window.removeEventListener("touchmove", n);
167
- }, n = (s) => s.preventDefault();
245
+ s.style.userSelect = t, s.style.touchAction = e, s.style.overscrollBehavior = n, window.removeEventListener("contextmenu", r), window.removeEventListener("selectstart", r), window.removeEventListener("touchstart", r), window.removeEventListener("touchmove", r);
246
+ }, r = (s) => s.preventDefault();
168
247
  return {
169
248
  disableInteractions: u,
170
249
  enableInteractions: c
171
250
  };
172
- }, re = (t, e) => t.x < e.x + e.width && t.x + t.width > e.x && t.y < e.y + e.height && t.y + t.height > e.y, k = (t) => {
251
+ }, oe = (t, e) => t.x < e.x + e.width && t.x + t.width > e.x && t.y < e.y + e.height && t.y + t.height > e.y, k = (t) => {
173
252
  if (!t)
174
253
  return {
175
254
  x: 0,
@@ -192,274 +271,273 @@ const I = () => (ne || (X = ie(!0).run(() => ({
192
271
  width: e.width,
193
272
  height: e.height
194
273
  };
195
- }, Y = (t) => ({
274
+ }, b = (t) => ({
196
275
  x: t.x + t.width / 2,
197
276
  y: t.y + t.height / 2
198
- }), xe = (t, e) => {
199
- const i = k(t);
277
+ }), Ve = (t, e) => {
278
+ const n = k(t);
200
279
  return {
201
280
  pixel: {
202
- x: e.x - i.x,
203
- y: e.y - i.y
281
+ x: e.x - n.x,
282
+ y: e.y - n.y
204
283
  },
205
284
  percent: {
206
- x: (e.x - i.x) / i.width * 100,
207
- y: (e.y - i.y) / i.height * 100
285
+ x: (e.x - n.x) / n.width * 100,
286
+ y: (e.y - n.y) / n.height * 100
208
287
  }
209
288
  };
210
- }, oe = (t, e) => {
211
- const i = e.x - t.x, u = e.y - t.y;
212
- return Math.sqrt(i * i + u * u);
213
- }, _ = (t, e) => t ? e.contains(t) : !1, De = (t) => {
214
- const e = I();
289
+ }, le = (t, e) => {
290
+ const n = e.x - t.x, u = e.y - t.y;
291
+ return Math.sqrt(n * n + u * u);
292
+ }, M = (t, e) => t ? e.contains(t) : !1, Ze = (t) => {
293
+ const e = C();
215
294
  return {
216
- onPointerStart: (n) => {
217
- e.pointerPosition.start.value = { x: n.clientX, y: n.clientY }, e.pointerPosition.current.value = {
218
- x: n.clientX,
219
- y: n.clientY
295
+ onPointerStart: (r) => {
296
+ e.pointerPosition.start.value = { x: r.clientX, y: r.clientY }, e.pointerPosition.current.value = {
297
+ x: r.clientX,
298
+ y: r.clientY
220
299
  };
221
- const { pixel: s, percent: h } = xe(t.value, {
222
- x: n.clientX,
223
- y: n.clientY
300
+ const { pixel: s, percent: v } = Ve(t.value, {
301
+ x: r.clientX,
302
+ y: r.clientY
224
303
  });
225
- e.pointerPosition.offset.pixel.value = s, e.pointerPosition.offset.percent.value = h;
304
+ e.pointerPosition.offset.pixel.value = s, e.pointerPosition.offset.percent.value = v;
226
305
  },
227
- onPointerMove: (n) => {
306
+ onPointerMove: (r) => {
228
307
  e.pointerPosition.current.value = {
229
- x: n.clientX,
230
- y: n.clientY
308
+ x: r.clientX,
309
+ y: r.clientY
231
310
  };
232
311
  },
233
312
  onPointerEnd: () => {
234
313
  e.pointerPosition.current.value = null, e.pointerPosition.start.value = null, e.pointerPosition.offset.pixel.value = null, e.pointerPosition.offset.percent.value = null;
235
314
  }
236
315
  };
237
- }, Ce = (t) => {
238
- const e = I(), { onPointerStart: i, onPointerMove: u, onPointerEnd: c } = De(t);
239
- let n = null;
240
- const s = (r) => {
241
- var v, C;
316
+ }, $e = (t) => {
317
+ const e = C(), { onPointerStart: n, onPointerMove: u, onPointerEnd: c } = Ze(t);
318
+ let r = null;
319
+ const s = (o) => {
320
+ var h, I;
242
321
  const d = e.selectedElements.value.some(
243
- (P) => P.node === r
322
+ (P) => P.node === o
244
323
  );
245
324
  if (e.selectedElements.value.length && d)
246
325
  return e.selectedElements.value.map((P) => {
247
- var M, T;
326
+ var L, H;
248
327
  return {
249
328
  ...P,
250
- initialHTML: ((M = P.node) == null ? void 0 : M.outerHTML) ?? "",
251
- initialRect: (T = P.node) == null ? void 0 : T.getBoundingClientRect()
329
+ initialHTML: ((L = P.node) == null ? void 0 : L.outerHTML) ?? "",
330
+ initialRect: (H = P.node) == null ? void 0 : H.getBoundingClientRect()
252
331
  };
253
332
  });
254
333
  e.selectedElements.value = [];
255
- const g = e.elements.value.find(
256
- (P) => P.node === r
334
+ const m = e.elements.value.find(
335
+ (P) => P.node === o
257
336
  );
258
- return g ? [
337
+ return m ? [
259
338
  {
260
- ...g,
261
- initialHTML: ((v = g.node) == null ? void 0 : v.outerHTML) ?? "",
262
- initialRect: (C = g.node) == null ? void 0 : C.getBoundingClientRect()
339
+ ...m,
340
+ initialHTML: ((h = m.node) == null ? void 0 : h.outerHTML) ?? "",
341
+ initialRect: (I = m.node) == null ? void 0 : I.getBoundingClientRect()
263
342
  }
264
343
  ] : [];
265
- }, h = (r, d) => {
266
- const g = Math.max(
344
+ }, v = (o, d) => {
345
+ const m = Math.max(
267
346
  0,
268
- Math.min(r.x + r.width, d.x + d.width) - Math.max(r.x, d.x)
269
- ), v = Math.max(
347
+ Math.min(o.x + o.width, d.x + d.width) - Math.max(o.x, d.x)
348
+ ), h = Math.max(
270
349
  0,
271
- Math.min(r.y + r.height, d.y + d.height) - Math.max(r.y, d.y)
272
- ), C = g * v, P = r.width * r.height, M = d.width * d.height;
273
- return (C / P * 100 + C / M * 100) / 2;
350
+ Math.min(o.y + o.height, d.y + d.height) - Math.max(o.y, d.y)
351
+ ), I = m * h, P = o.width * o.height, L = d.width * d.height;
352
+ return (I / P * 100 + I / L * 100) / 2;
274
353
  }, f = () => {
275
- var q, V, B, j, G, J, K, Q, W, b;
276
- const r = k(e.activeContainer.ref.value), d = Y(r), g = ((q = e.pointerPosition.current.value) == null ? void 0 : q.x) ?? 0, v = ((V = e.pointerPosition.current.value) == null ? void 0 : V.y) ?? 0, P = !(r && g >= r.x && g <= r.x + r.width && v >= r.y && v <= r.y + r.height), M = e.draggingElements.value.map((o) => o.node), T = e.elements.value.filter((o) => {
277
- if (!o.node || M.some(
278
- (x) => x && _(o.node, x)
279
- ) || o.groups.length && !!e.draggingElements.value.some(
280
- (L) => L.groups.length ? !L.groups.some(
281
- (S) => o.groups.includes(S)
354
+ var G, N, q, B, j, J, K, Q, ee, te;
355
+ const o = k(e.activeContainer.ref.value), d = b(o), m = ((G = e.pointerPosition.current.value) == null ? void 0 : G.x) ?? 0, h = ((N = e.pointerPosition.current.value) == null ? void 0 : N.y) ?? 0, P = !(o && m >= o.x && m <= o.x + o.width && h >= o.y && h <= o.y + o.height), L = e.draggingElements.value.map((i) => i.node), H = e.elements.value.filter((i) => {
356
+ if (!i.node || L.some(
357
+ (D) => D && M(i.node, D)
358
+ ) || i.groups.length && !!e.draggingElements.value.some(
359
+ (S) => S.groups.length ? !S.groups.some(
360
+ (_) => i.groups.includes(_)
282
361
  ) : !1
283
362
  ))
284
363
  return !1;
285
- const a = k(o.node);
286
- return a && r && re(a, r);
287
- }).map((o) => {
288
- const a = k(o.node), x = Y(a), L = g >= a.x && g <= a.x + a.width && v >= a.y && v <= a.y + a.height, S = h(a, r), Z = oe(d, x), A = e.elements.value.filter(
289
- (O) => O !== o && O.node && o.node && _(
290
- o.node,
364
+ const a = k(i.node);
365
+ return a && o && oe(a, o);
366
+ }).map((i) => {
367
+ const a = k(i.node), D = b(a), S = m >= a.x && m <= a.x + a.width && h >= a.y && h <= a.y + a.height, _ = v(a, o), V = le(d, D), Z = e.elements.value.filter(
368
+ (O) => O !== i && O.node && i.node && M(
369
+ i.node,
291
370
  O.node
292
371
  )
293
372
  ).length;
294
373
  return {
295
- element: o,
296
- isPointerInElement: L,
297
- overlapPercent: S,
298
- depth: A,
299
- centerDistance: Z
374
+ element: i,
375
+ isPointerInElement: S,
376
+ overlapPercent: _,
377
+ depth: Z,
378
+ centerDistance: V
300
379
  };
301
- }).sort((o, a) => {
380
+ }).sort((i, a) => {
302
381
  if (!P) {
303
- if (o.isPointerInElement && a.isPointerInElement)
304
- return a.depth - o.depth;
305
- if (o.isPointerInElement !== a.isPointerInElement)
306
- return o.isPointerInElement ? -1 : 1;
382
+ if (i.isPointerInElement && a.isPointerInElement)
383
+ return a.depth - i.depth;
384
+ if (i.isPointerInElement !== a.isPointerInElement)
385
+ return i.isPointerInElement ? -1 : 1;
307
386
  }
308
- return Math.abs(o.overlapPercent - a.overlapPercent) <= 1 ? o.centerDistance - a.centerDistance : a.overlapPercent - o.overlapPercent;
309
- }), le = e.zones.value.filter((o) => {
310
- if (!o.node || M.some(
311
- (x) => x && _(o.node, x)
312
- ) || o.groups.length && !!e.draggingElements.value.some((L) => L.groups.length ? !L.groups.some((S) => o.groups.includes(S)) : !1))
387
+ return Math.abs(i.overlapPercent - a.overlapPercent) <= 1 ? i.centerDistance - a.centerDistance : a.overlapPercent - i.overlapPercent;
388
+ }), ue = e.zones.value.filter((i) => {
389
+ if (!i.node || L.some(
390
+ (D) => D && M(i.node, D)
391
+ ) || i.groups.length && !!e.draggingElements.value.some((S) => S.groups.length ? !S.groups.some((_) => i.groups.includes(_)) : !1))
313
392
  return !1;
314
- const a = k(o.node);
315
- return a && r && re(a, r);
316
- }).map((o) => {
317
- const a = k(o.node), x = Y(a), L = g >= a.x && g <= a.x + a.width && v >= a.y && v <= a.y + a.height, S = h(a, r), Z = oe(d, x), A = e.zones.value.filter(
318
- (O) => O !== o && O.node && o.node && _(o.node, O.node)
393
+ const a = k(i.node);
394
+ return a && o && oe(a, o);
395
+ }).map((i) => {
396
+ const a = k(i.node), D = b(a), S = m >= a.x && m <= a.x + a.width && h >= a.y && h <= a.y + a.height, _ = v(a, o), V = le(d, D), Z = e.zones.value.filter(
397
+ (O) => O !== i && O.node && i.node && M(i.node, O.node)
319
398
  ).length;
320
399
  return {
321
- zone: o,
322
- isPointerInElement: L,
323
- overlapPercent: S,
324
- depth: A,
325
- centerDistance: Z
400
+ zone: i,
401
+ isPointerInElement: S,
402
+ overlapPercent: _,
403
+ depth: Z,
404
+ centerDistance: V
326
405
  };
327
- }).sort((o, a) => {
406
+ }).sort((i, a) => {
328
407
  if (!P) {
329
- if (o.isPointerInElement && a.isPointerInElement)
330
- return a.depth - o.depth;
331
- if (o.isPointerInElement !== a.isPointerInElement)
332
- return o.isPointerInElement ? -1 : 1;
408
+ if (i.isPointerInElement && a.isPointerInElement)
409
+ return a.depth - i.depth;
410
+ if (i.isPointerInElement !== a.isPointerInElement)
411
+ return i.isPointerInElement ? -1 : 1;
333
412
  }
334
- return Math.abs(o.overlapPercent - a.overlapPercent) <= 1 ? o.centerDistance - a.centerDistance : a.overlapPercent - o.overlapPercent;
335
- }), z = e.hovered.element.value, H = e.hovered.zone.value;
336
- e.hovered.element.value = ((B = T[0]) == null ? void 0 : B.element) ?? null, e.hovered.zone.value = ((j = le[0]) == null ? void 0 : j.zone) ?? null, e.hovered.element.value !== z && ((G = z == null ? void 0 : z.events) != null && G.onLeave && z.events.onLeave(e), (K = (J = e.hovered.element.value) == null ? void 0 : J.events) != null && K.onHover && e.hovered.element.value.events.onHover(e)), e.hovered.zone.value !== H && ((Q = H == null ? void 0 : H.events) != null && Q.onLeave && H.events.onLeave(e), (b = (W = e.hovered.zone.value) == null ? void 0 : W.events) != null && b.onHover && e.hovered.zone.value.events.onHover(e)), n = requestAnimationFrame(f);
337
- }, y = () => {
413
+ return Math.abs(i.overlapPercent - a.overlapPercent) <= 1 ? i.centerDistance - a.centerDistance : a.overlapPercent - i.overlapPercent;
414
+ }), T = e.hovered.element.value, z = e.hovered.zone.value;
415
+ e.hovered.element.value = ((q = H[0]) == null ? void 0 : q.element) ?? null, e.hovered.zone.value = ((B = ue[0]) == null ? void 0 : B.zone) ?? null, e.hovered.element.value !== T && ((j = T == null ? void 0 : T.events) != null && j.onLeave && T.events.onLeave(e), (K = (J = e.hovered.element.value) == null ? void 0 : J.events) != null && K.onHover && e.hovered.element.value.events.onHover(e)), e.hovered.zone.value !== z && ((Q = z == null ? void 0 : z.events) != null && Q.onLeave && z.events.onLeave(e), (te = (ee = e.hovered.zone.value) == null ? void 0 : ee.events) != null && te.onHover && e.hovered.zone.value.events.onHover(e)), r = requestAnimationFrame(f);
416
+ }, p = () => {
338
417
  f();
339
418
  }, l = () => {
340
- n !== null && (cancelAnimationFrame(n), n = null);
419
+ r !== null && (cancelAnimationFrame(r), r = null);
341
420
  };
342
421
  return {
343
- activate: (r) => {
344
- e.draggingElements.value = s(t.value), i(r), y();
422
+ activate: (o) => {
423
+ e.draggingElements.value = s(t.value), n(o), p();
345
424
  },
346
- track: (r) => {
347
- u(r);
425
+ track: (o) => {
426
+ u(o);
348
427
  },
349
428
  deactivate: () => {
350
- var r, d;
351
- c(), e.hovered.zone.value ? (d = (r = e.hovered.zone.value.events).onDrop) == null || d.call(r, e) : e.draggingElements.value.forEach(
352
- (g) => {
353
- var v, C;
354
- return (C = (v = g.events).onEnd) == null ? void 0 : C.call(v, e);
429
+ var o, d;
430
+ c(), e.hovered.zone.value ? (d = (o = e.hovered.zone.value.events).onDrop) == null || d.call(o, e) : e.draggingElements.value.forEach(
431
+ (m) => {
432
+ var h, I;
433
+ return (I = (h = m.events).onEnd) == null ? void 0 : I.call(h, e);
355
434
  }
356
435
  ), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, l();
357
436
  }
358
437
  };
359
- }, Me = (t) => {
438
+ }, Fe = (t) => {
360
439
  const {
361
440
  elementRef: e,
362
- registerElement: i,
441
+ registerElement: n,
363
442
  unregisterElement: u,
364
443
  isDragging: c,
365
- isOvered: n,
444
+ isOvered: r,
366
445
  isAllowed: s
367
- } = Pe(t), { disableInteractions: h, enableInteractions: f } = we(), y = I(), { activate: l, track: E, deactivate: m } = Ce(e), D = (v) => {
368
- t != null && t.container && (y.activeContainer.component.value = he(t.container)), h(), l(v), document.addEventListener("pointermove", r), document.addEventListener("pointerup", g), document.addEventListener("wheel", d);
369
- }, r = (v) => {
370
- E(v);
371
- }, d = (v) => {
372
- E(v);
373
- }, g = () => {
374
- y.activeContainer.component.value = null, f(), m(), document.removeEventListener("pointermove", r), document.removeEventListener("pointerup", g), document.removeEventListener("wheel", d);
446
+ } = Re(t), { disableInteractions: v, enableInteractions: f } = Ae(), p = C(), { activate: l, track: g, deactivate: x } = $e(e), y = (h) => {
447
+ t != null && t.container && (p.activeContainer.component.value = we(t.container)), v(), l(h), document.addEventListener("pointermove", o), document.addEventListener("pointerup", m), document.addEventListener("wheel", d);
448
+ }, o = (h) => {
449
+ g(h);
450
+ }, d = (h) => {
451
+ g(h);
452
+ }, m = () => {
453
+ p.activeContainer.component.value = null, f(), x(), document.removeEventListener("pointermove", o), document.removeEventListener("pointerup", m), document.removeEventListener("wheel", d);
375
454
  };
376
- return F(i), U(u), {
377
- pointerPosition: y.pointerPosition,
455
+ return A(n), W(u), {
456
+ pointerPosition: p.pointerPosition,
378
457
  elementRef: e,
379
458
  isDragging: c,
380
- isOvered: n,
459
+ isOvered: r,
381
460
  isAllowed: s,
382
- handleDragStart: D
461
+ handleDragStart: y
383
462
  };
384
- }, Le = (t) => {
385
- const { zones: e, hovered: i, draggingElements: u, isDragging: c } = I(), n = p(null), s = w(() => {
463
+ }, Xe = (t) => {
464
+ const { zones: e, hovered: n, draggingElements: u, isDragging: c } = C(), r = E(null), s = w(() => {
386
465
  var l;
387
- return ((l = i.zone.value) == null ? void 0 : l.node) === n.value;
388
- }), h = w(() => {
389
- if (!n.value || !c.value) return !1;
466
+ return ((l = n.zone.value) == null ? void 0 : l.node) === r.value;
467
+ }), v = w(() => {
468
+ if (!r.value || !c.value) return !1;
390
469
  const l = e.value.find(
391
- (E) => E.node === n.value
470
+ (g) => g.node === r.value
392
471
  );
393
- return l != null && l.groups.length ? !u.value.some((E) => E.groups.length ? !E.groups.some(
394
- (m) => l.groups.includes(m)
472
+ return l != null && l.groups.length ? !u.value.some((g) => g.groups.length ? !g.groups.some(
473
+ (x) => l.groups.includes(x)
395
474
  ) : !1) : !0;
396
475
  });
397
- return { elementRef: n, registerZone: () => {
398
- if (!n.value) throw new Error("elementRef is not set");
476
+ return { elementRef: r, registerZone: () => {
477
+ if (!r.value) throw new Error("elementRef is not set");
399
478
  e.value.push({
400
- node: n.value,
479
+ node: r.value,
401
480
  groups: (t == null ? void 0 : t.groups) ?? [],
402
481
  events: (t == null ? void 0 : t.events) ?? {},
403
482
  data: (t == null ? void 0 : t.data) ?? void 0
404
- }), n.value.setAttribute("data-dnd-droppable", "true");
483
+ }), r.value.setAttribute("data-dnd-droppable", "true");
405
484
  }, unregisterZone: () => {
406
- if (!n.value) throw new Error("elementRef is not set");
485
+ if (!r.value) throw new Error("elementRef is not set");
407
486
  const l = e.value.findIndex(
408
- (E) => E.node === n.value
487
+ (g) => g.node === r.value
409
488
  );
410
489
  l !== -1 && e.value.splice(l, 1);
411
- }, isOvered: s, isAllowed: h };
412
- }, Se = (t) => {
413
- const { elementRef: e, registerZone: i, unregisterZone: u, isOvered: c, isAllowed: n } = Le(t);
414
- return F(i), U(u), { elementRef: e, isOvered: c, isAllowed: n };
415
- }, Oe = (t) => {
416
- const { selectedElements: e, elements: i } = I(), u = w(
417
- () => i.value.find((l) => l.node === t.value)
490
+ }, isOvered: s, isAllowed: v };
491
+ }, Ue = (t) => {
492
+ const { elementRef: e, registerZone: n, unregisterZone: u, isOvered: c, isAllowed: r } = Xe(t);
493
+ return A(n), W(u), { elementRef: e, isOvered: c, isAllowed: r };
494
+ }, We = (t) => {
495
+ const { selectedElements: e, elements: n } = C(), u = w(
496
+ () => n.value.find((l) => l.node === t.value)
418
497
  ), c = w(
419
498
  () => e.value.some((l) => l.node === t.value)
420
- ), n = w(() => t.value ? e.value.some(
421
- (l) => l.node && _(
499
+ ), r = w(() => t.value ? e.value.some(
500
+ (l) => l.node && M(
422
501
  l.node,
423
502
  t.value
424
503
  )
425
504
  ) : !1), s = w(() => t.value ? e.value.some(
426
- (l) => l.node && _(
505
+ (l) => l.node && M(
427
506
  t.value,
428
507
  l.node
429
508
  )
430
- ) : !1), h = () => {
509
+ ) : !1), v = () => {
431
510
  u.value && (e.value = e.value.filter(
432
511
  (l) => l.node !== t.value
433
512
  ));
434
513
  }, f = () => {
435
- u.value && (n.value && (e.value = e.value.filter(
436
- (l) => l.node && !_(
514
+ u.value && (r.value && (e.value = e.value.filter(
515
+ (l) => l.node && !M(
437
516
  l.node,
438
517
  t.value
439
518
  )
440
519
  )), s.value && (e.value = e.value.filter(
441
- (l) => l.node && !_(
520
+ (l) => l.node && !M(
442
521
  t.value,
443
522
  l.node
444
523
  )
445
524
  )), e.value.push(u.value));
446
525
  };
447
526
  return {
448
- handleUnselect: h,
527
+ handleUnselect: v,
449
528
  handleSelect: f,
450
529
  handleToggleSelect: () => {
451
- u.value && (e.value.some((l) => l.node === t.value) ? h() : f());
530
+ u.value && (e.value.some((l) => l.node === t.value) ? v() : f());
452
531
  },
453
532
  isSelected: c,
454
- isParentOfSelected: n
533
+ isParentOfSelected: r
455
534
  };
456
535
  };
457
536
  export {
458
- Ie as DnDContext,
459
- ye as DragOverlay,
537
+ be as DragOverlay,
460
538
  k as getBoundingBox,
461
- I as useDnDStore,
462
- Me as useDraggable,
463
- Se as useDroppable,
464
- Oe as useSelection
539
+ C as useDnDStore,
540
+ Fe as useDraggable,
541
+ Ue as useDroppable,
542
+ We as useSelection
465
543
  };