@vue-dnd-kit/core 0.5.5 → 0.5.7

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,333 +1,203 @@
1
1
  var ue = Object.defineProperty;
2
2
  var ce = (n, e, t) => e in n ? ue(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var I = (n, e, t) => ce(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { effectScope as de, isRef as ve, watch as fe, getCurrentScope as ge, onScopeDispose as me, toValue as V, reactive as J, computed as C, shallowRef as O, unref as W, ref as R, onMounted as G, onBeforeUnmount as B, defineComponent as ae, createElementBlock as X, createCommentVNode as he, openBlock as F, normalizeStyle as Q, Fragment as ye, renderList as Ee, createBlock as pe, resolveDynamicComponent as we, createVNode as Pe, render as Z, markRaw as xe } from "vue";
5
- const p = class p {
3
+ var b = (n, e, t) => ce(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ref as K, computed as C, shallowRef as U, onUnmounted as ve, onMounted as q, onBeforeUnmount as G, defineComponent as oe, createElementBlock as F, createCommentVNode as de, unref as W, openBlock as N, normalizeStyle as B, Fragment as ge, renderList as fe, createBlock as me, resolveDynamicComponent as he, createVNode as ye, render as ee, useId as Ee, markRaw as pe } from "vue";
5
+ import { createGlobalState as ie, useMagicKeys as Me, useThrottleFn as we } from "@vueuse/core";
6
+ const y = class y {
6
7
  };
7
- I(p, "remove", (e, t) => {
8
+ b(y, "remove", (e, t) => {
8
9
  if (!e || t === void 0) return;
9
10
  const [r] = e.splice(t, 1);
10
11
  return r;
11
- }), I(p, "insert", (e, t, r) => {
12
+ }), b(y, "insert", (e, t, r) => {
12
13
  !e || t === void 0 || e.splice(t, 0, r);
13
- }), I(p, "move", (e, t, r, l) => {
14
- if (!e || !r || t === void 0 || l === void 0)
14
+ }), b(y, "move", (e, t, r, a) => {
15
+ if (!e || !r || t === void 0 || a === void 0)
15
16
  return;
16
- const a = p.remove(e, t);
17
- p.insert(r, l, a);
18
- }), I(p, "swap", (e, t, r, l) => {
19
- if (!e || !r || t === void 0 || l === void 0)
17
+ const o = y.remove(e, t);
18
+ y.insert(r, a, o);
19
+ }), b(y, "swap", (e, t, r, a) => {
20
+ if (!e || !r || t === void 0 || a === void 0)
20
21
  return;
21
- const a = e[t], o = r[l];
22
- e[t] = o, r[l] = a;
23
- }), I(p, "copy", (e, t, r, l) => {
24
- if (!e || t === void 0 || !r || l === void 0)
22
+ const o = e[t], l = r[a];
23
+ e[t] = l, r[a] = o;
24
+ }), b(y, "copy", (e, t, r, a) => {
25
+ if (!e || t === void 0 || !r || a === void 0)
25
26
  return;
26
- const a = e[t];
27
- p.insert(r, l, a);
28
- }), I(p, "applyTransfer", (e) => {
27
+ const o = e[t];
28
+ y.insert(r, a, o);
29
+ }), b(y, "applyTransfer", (e) => {
29
30
  const t = e.hovered.element.value, r = e.hovered.zone.value;
30
31
  t ? e.draggingElements.value.forEach(
31
- (l) => {
32
- var a, o, i, s;
33
- return p.move(
34
- (a = l.data) == null ? void 0 : a.source,
35
- (o = l.data) == null ? void 0 : o.index,
36
- (i = t.data) == null ? void 0 : i.source,
37
- (s = t.data) == null ? void 0 : s.index
32
+ (a) => {
33
+ var o, l, c, s, i, u;
34
+ return y.move(
35
+ (o = a.data) == null ? void 0 : o.source,
36
+ (l = a.data) == null ? void 0 : l.index,
37
+ (s = (c = e.elementsMap.value.get(t)) == null ? void 0 : c.data) == null ? void 0 : s.source,
38
+ (u = (i = e.elementsMap.value.get(t)) == null ? void 0 : i.data) == null ? void 0 : u.index
38
39
  );
39
40
  }
40
- ) : e.draggingElements.value.forEach(
41
- (l) => {
42
- var a, o, i, s, v;
43
- return p.move(
44
- (a = l.data) == null ? void 0 : a.source,
45
- (o = l.data) == null ? void 0 : o.index,
46
- (i = r == null ? void 0 : r.data) == null ? void 0 : i.source,
47
- (v = (s = r == null ? void 0 : r.data) == null ? void 0 : s.source) == null ? void 0 : v.length
41
+ ) : r && e.draggingElements.value.forEach(
42
+ (a) => {
43
+ var o, l, c, s, i, u, d;
44
+ return y.move(
45
+ (o = a.data) == null ? void 0 : o.source,
46
+ (l = a.data) == null ? void 0 : l.index,
47
+ (s = (c = e.zonesMap.value.get(r)) == null ? void 0 : c.data) == null ? void 0 : s.source,
48
+ (d = (u = (i = e.zonesMap.value.get(r)) == null ? void 0 : i.data) == null ? void 0 : u.source) == null ? void 0 : d.length
48
49
  );
49
50
  }
50
51
  );
51
- }), I(p, "applyCopy", (e) => {
52
+ }), b(y, "applyCopy", (e) => {
52
53
  const t = e.hovered.element.value, r = e.hovered.zone.value;
53
54
  t ? e.draggingElements.value.forEach(
54
- (l) => {
55
- var a, o, i, s;
56
- return p.copy(
57
- (a = l.data) == null ? void 0 : a.source,
58
- (o = l.data) == null ? void 0 : o.index,
59
- (i = t.data) == null ? void 0 : i.source,
60
- (s = t.data) == null ? void 0 : s.index
55
+ (a) => {
56
+ var o, l, c, s, i, u;
57
+ return y.copy(
58
+ (o = a.data) == null ? void 0 : o.source,
59
+ (l = a.data) == null ? void 0 : l.index,
60
+ (s = (c = e.elementsMap.value.get(t)) == null ? void 0 : c.data) == null ? void 0 : s.source,
61
+ (u = (i = e.elementsMap.value.get(t)) == null ? void 0 : i.data) == null ? void 0 : u.index
61
62
  );
62
63
  }
63
- ) : e.draggingElements.value.forEach(
64
- (l) => {
65
- var a, o, i, s, v;
66
- return p.copy(
67
- (a = l.data) == null ? void 0 : a.source,
68
- (o = l.data) == null ? void 0 : o.index,
69
- (i = r == null ? void 0 : r.data) == null ? void 0 : i.source,
70
- (v = (s = r == null ? void 0 : r.data) == null ? void 0 : s.source) == null ? void 0 : v.length
64
+ ) : r && e.draggingElements.value.forEach(
65
+ (a) => {
66
+ var o, l, c, s, i, u, d;
67
+ return y.copy(
68
+ (o = a.data) == null ? void 0 : o.source,
69
+ (l = a.data) == null ? void 0 : l.index,
70
+ (s = (c = e.zonesMap.value.get(r)) == null ? void 0 : c.data) == null ? void 0 : s.source,
71
+ (d = (u = (i = e.zonesMap.value.get(r)) == null ? void 0 : i.data) == null ? void 0 : u.source) == null ? void 0 : d.length
71
72
  );
72
73
  }
73
74
  );
74
- }), I(p, "applySwap", (e) => {
75
- var l, a, o, i;
75
+ }), b(y, "applySwap", (e) => {
76
+ var a, o, l, c, s, i;
76
77
  const t = e.hovered.element.value, r = e.hovered.zone.value;
77
- if (t && e.draggingElements.value.length === 1) {
78
- const s = e.draggingElements.value[0];
79
- p.swap(
80
- (l = s.data) == null ? void 0 : l.source,
81
- (a = s.data) == null ? void 0 : a.index,
82
- (o = t.data) == null ? void 0 : o.source,
83
- (i = t.data) == null ? void 0 : i.index
78
+ if (t && e.draggingElements.value.size === 1) {
79
+ const u = e.draggingElements.value.values().next().value;
80
+ y.swap(
81
+ (a = u == null ? void 0 : u.data) == null ? void 0 : a.source,
82
+ (o = u == null ? void 0 : u.data) == null ? void 0 : o.index,
83
+ (c = (l = e.elementsMap.value.get(t)) == null ? void 0 : l.data) == null ? void 0 : c.source,
84
+ (i = (s = e.elementsMap.value.get(t)) == null ? void 0 : s.data) == null ? void 0 : i.index
84
85
  );
85
- } else
86
- e.draggingElements.value.forEach(
87
- (s) => {
88
- var v, d, g, u, c;
89
- return p.move(
90
- (v = s.data) == null ? void 0 : v.source,
91
- (d = s.data) == null ? void 0 : d.index,
92
- (g = r == null ? void 0 : r.data) == null ? void 0 : g.source,
93
- (c = (u = r == null ? void 0 : r.data) == null ? void 0 : u.source) == null ? void 0 : c.length
94
- );
95
- }
96
- );
97
- }), I(p, "applyRemove", (e) => {
86
+ } else r && e.draggingElements.value.forEach(
87
+ (u) => {
88
+ var d, v, g, m, h, L, p;
89
+ return y.move(
90
+ (d = u.data) == null ? void 0 : d.source,
91
+ (v = u.data) == null ? void 0 : v.index,
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
94
+ );
95
+ }
96
+ );
97
+ }), b(y, "applyRemove", (e) => {
98
98
  e.draggingElements.value.forEach((t) => {
99
- var r, l;
100
- (r = t.data) != null && r.source && ((l = t.data) == null ? void 0 : l.index) !== void 0 && p.remove(t.data.source, t.data.index);
99
+ var r, a;
100
+ (r = t.data) != null && r.source && ((a = t.data) == null ? void 0 : a.index) !== void 0 && y.remove(t.data.source, t.data.index);
101
101
  });
102
- }), I(p, "applyInsert", (e, t) => {
103
- const r = e.hovered.element.value, l = e.hovered.zone.value;
104
- r && t.length > 0 ? t.forEach((a) => {
105
- var o, i;
106
- p.insert(
107
- (o = r.data) == null ? void 0 : o.source,
108
- (i = r.data) == null ? void 0 : i.index,
109
- a
102
+ }), b(y, "applyInsert", (e, t) => {
103
+ const r = e.hovered.element.value, a = e.hovered.zone.value;
104
+ r && t.length > 0 ? t.forEach((o) => {
105
+ var l, c, s, i;
106
+ y.insert(
107
+ (c = (l = e.elementsMap.value.get(r)) == null ? void 0 : l.data) == null ? void 0 : c.source,
108
+ (i = (s = e.elementsMap.value.get(r)) == null ? void 0 : s.data) == null ? void 0 : i.index,
109
+ o
110
110
  );
111
- }) : t.forEach((a) => {
112
- var o, i, s;
113
- p.insert(
114
- (o = l == null ? void 0 : l.data) == null ? void 0 : o.source,
115
- (s = (i = l == null ? void 0 : l.data) == null ? void 0 : i.source) == null ? void 0 : s.length,
116
- a
111
+ }) : a && t.forEach((o) => {
112
+ var l, c, s, i, u;
113
+ y.insert(
114
+ (c = (l = e.zonesMap.value.get(a)) == null ? void 0 : l.data) == null ? void 0 : c.source,
115
+ (u = (i = (s = e.zonesMap.value.get(a)) == null ? void 0 : s.data) == null ? void 0 : i.source) == null ? void 0 : u.length,
116
+ o
117
117
  );
118
118
  });
119
119
  });
120
- let ee = p;
121
- function Le(n) {
122
- return ge() ? (me(n), !0) : !1;
123
- }
124
- function ie(n) {
125
- let e = !1, t;
126
- const r = de(!0);
127
- return (...l) => (e || (t = r.run(() => n(...l)), e = !0), t);
128
- }
129
- const Se = typeof window < "u" && typeof document < "u";
130
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
131
- const Me = Object.prototype.toString, Ce = (n) => Me.call(n) === "[object Object]", q = () => {
132
- };
133
- function De(n, e) {
134
- function t(...r) {
135
- return new Promise((l, a) => {
136
- Promise.resolve(n(() => e.apply(this, r), { fn: e, thisArg: this, args: r })).then(l).catch(a);
137
- });
138
- }
139
- return t;
140
- }
141
- function ke(...n) {
142
- let e = 0, t, r = !0, l = q, a, o, i, s, v;
143
- !ve(n[0]) && typeof n[0] == "object" ? { delay: o, trailing: i = !0, leading: s = !0, rejectOnCancel: v = !1 } = n[0] : [o, i = !0, s = !0, v = !1] = n;
144
- const d = () => {
145
- t && (clearTimeout(t), t = void 0, l(), l = q);
146
- };
147
- return (u) => {
148
- const c = V(o), y = Date.now() - e, f = () => a = u();
149
- return d(), c <= 0 ? (e = Date.now(), f()) : (y > c && (s || !r) ? (e = Date.now(), f()) : i && (a = new Promise((m, P) => {
150
- l = v ? P : m, t = setTimeout(() => {
151
- e = Date.now(), r = !0, m(f()), d();
152
- }, Math.max(0, c - y));
153
- })), !s && !t && (t = setTimeout(() => r = !0, c)), r = !1, a);
154
- };
155
- }
156
- function N(n) {
157
- return Array.isArray(n) ? n : [n];
158
- }
159
- function Ie(n, e = 200, t = !1, r = !0, l = !1) {
160
- return De(
161
- ke(e, t, r, l),
162
- n
163
- );
164
- }
165
- function _e(n, e, t) {
166
- return fe(
167
- n,
168
- e,
169
- {
170
- ...t,
171
- immediate: !0
172
- }
173
- );
174
- }
175
- const se = Se ? window : void 0;
176
- function be(n) {
177
- var e;
178
- const t = V(n);
179
- return (e = t == null ? void 0 : t.$el) != null ? e : t;
180
- }
181
- function j(...n) {
182
- const e = [], t = () => {
183
- e.forEach((i) => i()), e.length = 0;
184
- }, r = (i, s, v, d) => (i.addEventListener(s, v, d), () => i.removeEventListener(s, v, d)), l = C(() => {
185
- const i = N(V(n[0])).filter((s) => s != null);
186
- return i.every((s) => typeof s != "string") ? i : void 0;
187
- }), a = _e(
188
- () => {
189
- var i, s;
190
- return [
191
- (s = (i = l.value) == null ? void 0 : i.map((v) => be(v))) != null ? s : [se].filter((v) => v != null),
192
- N(V(l.value ? n[1] : n[0])),
193
- N(W(l.value ? n[2] : n[1])),
194
- // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
195
- V(l.value ? n[3] : n[2])
196
- ];
197
- },
198
- ([i, s, v, d]) => {
199
- if (t(), !(i != null && i.length) || !(s != null && s.length) || !(v != null && v.length))
200
- return;
201
- const g = Ce(d) ? { ...d } : d;
202
- e.push(
203
- ...i.flatMap(
204
- (u) => s.flatMap(
205
- (c) => v.map((y) => r(u, c, y, g))
206
- )
207
- )
208
- );
209
- },
210
- { flush: "post" }
211
- ), o = () => {
212
- a(), t();
213
- };
214
- return Le(t), o;
215
- }
216
- const Re = {
217
- ctrl: "control",
218
- command: "meta",
219
- cmd: "meta",
220
- option: "alt",
221
- up: "arrowup",
222
- down: "arrowdown",
223
- left: "arrowleft",
224
- right: "arrowright"
225
- };
226
- function Te(n = {}) {
227
- const {
228
- reactive: e = !1,
229
- target: t = se,
230
- aliasMap: r = Re,
231
- passive: l = !0,
232
- onEventFired: a = q
233
- } = n, o = J(/* @__PURE__ */ new Set()), i = {
234
- toJSON() {
235
- return {};
236
- },
237
- current: o
238
- }, s = e ? J(i) : i, v = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
239
- function g(f, m) {
240
- f in s && (e ? s[f] = m : s[f].value = m);
241
- }
242
- function u() {
243
- o.clear();
244
- for (const f of d)
245
- g(f, !1);
246
- }
247
- function c(f, m) {
248
- var P, L;
249
- const E = (P = f.key) == null ? void 0 : P.toLowerCase(), U = [(L = f.code) == null ? void 0 : L.toLowerCase(), E].filter(Boolean);
250
- E && (m ? o.add(E) : o.delete(E));
251
- for (const _ of U)
252
- d.add(_), g(_, m);
253
- E === "meta" && !m ? (v.forEach((_) => {
254
- o.delete(_), g(_, !1);
255
- }), v.clear()) : typeof f.getModifierState == "function" && f.getModifierState("Meta") && m && [...o, ...U].forEach((_) => v.add(_));
256
- }
257
- j(t, "keydown", (f) => (c(f, !0), a(f)), { passive: l }), j(t, "keyup", (f) => (c(f, !1), a(f)), { passive: l }), j("blur", u, { passive: l }), j("focus", u, { passive: l });
258
- const y = new Proxy(
259
- s,
260
- {
261
- get(f, m, P) {
262
- if (typeof m != "string")
263
- return Reflect.get(f, m, P);
264
- if (m = m.toLowerCase(), m in r && (m = r[m]), !(m in s))
265
- if (/[+_-]/.test(m)) {
266
- const E = m.split(/[+_-]/g).map((Y) => Y.trim());
267
- s[m] = C(() => E.map((Y) => V(y[Y])).every(Boolean));
268
- } else
269
- s[m] = O(!1);
270
- const L = Reflect.get(f, m, P);
271
- return e ? V(L) : L;
272
- }
273
- }
274
- );
275
- return y;
276
- }
120
+ let te = y;
277
121
  const T = ie(() => {
278
- const n = R([]), e = C(() => n.value.length > 0), t = {
279
- component: R(null),
280
- ref: O(null)
281
- }, r = R([]), l = R([]), a = R([]), o = {
282
- zone: R(null),
283
- element: R(null)
284
- }, i = {
285
- current: O(null),
286
- start: O(null),
122
+ const n = K(
123
+ /* @__PURE__ */ new Map()
124
+ ), e = C(() => n.value.size > 0), t = {
125
+ component: K(null),
126
+ ref: U(null)
127
+ }, r = K(/* @__PURE__ */ new Map()), a = K(
128
+ /* @__PURE__ */ new Map()
129
+ ), o = K(/* @__PURE__ */ new Map()), l = K(/* @__PURE__ */ new Set()), c = K(/* @__PURE__ */ new Set()), s = new IntersectionObserver((Z) => {
130
+ Z.forEach(
131
+ (f) => c.value[f.isIntersecting ? "add" : "delete"](
132
+ f.target
133
+ )
134
+ );
135
+ }), i = new IntersectionObserver((Z) => {
136
+ Z.forEach(
137
+ (f) => l.value[f.isIntersecting ? "add" : "delete"](f.target)
138
+ );
139
+ }), u = (Z, f) => {
140
+ Z === "add" ? s.observe(f) : (s.unobserve(f), c.value.delete(f));
141
+ }, d = (Z, f) => {
142
+ Z === "add" ? i.observe(f) : (i.unobserve(f), l.value.delete(f));
143
+ };
144
+ ve(() => {
145
+ s.disconnect(), i.disconnect();
146
+ });
147
+ const v = {
148
+ start: U(null),
149
+ current: U(null),
287
150
  offset: {
288
- percent: O(null),
289
- pixel: O(null)
151
+ percent: U(null),
152
+ pixel: U(null)
290
153
  }
291
- }, { w: s, s: v, a: d, d: g, ctrl: u, shift: c, alt: y, meta: f } = Te();
154
+ }, { w: g, s: m, a: h, d: L, ctrl: p, shift: _, alt: M, meta: A } = Me(), R = {
155
+ zone: U(null),
156
+ element: U(null)
157
+ };
292
158
  return {
159
+ draggingElements: n,
293
160
  isDragging: e,
294
161
  activeContainer: t,
295
- elements: r,
296
- draggingElements: n,
297
- selectedElements: l,
298
- zones: a,
299
- hovered: o,
300
- pointerPosition: i,
162
+ elementsMap: r,
163
+ selectedElementsMap: a,
164
+ zonesMap: o,
165
+ visibleZones: l,
166
+ visibleElements: c,
167
+ pointerPosition: v,
301
168
  keyboard: {
302
- w: s,
303
- s: v,
304
- a: d,
305
- d: g,
306
- ctrl: u,
307
- shift: c,
308
- alt: y,
309
- meta: f
310
- }
169
+ w: g,
170
+ s: m,
171
+ a: h,
172
+ d: L,
173
+ ctrl: p,
174
+ shift: _,
175
+ alt: M,
176
+ meta: A
177
+ },
178
+ hovered: R,
179
+ handleDragElementIntersection: u,
180
+ handleDropZoneIntersection: d
311
181
  };
312
- }), Ke = () => {
313
- const n = R(null), { draggingElements: e, pointerPosition: t, isDragging: r, activeContainer: l } = T();
314
- return G(() => {
315
- l.ref = n;
316
- }), B(() => {
317
- l.ref.value = null;
182
+ }), Pe = () => {
183
+ const n = K(null), { draggingElements: e, pointerPosition: t, isDragging: r, activeContainer: a } = T();
184
+ return q(() => {
185
+ a.ref = n;
186
+ }), G(() => {
187
+ a.ref.value = null;
318
188
  }), {
319
189
  elementRef: n,
320
190
  draggingElements: e,
321
191
  pointerPosition: t,
322
192
  isDragging: r
323
193
  };
324
- }, Ae = ["innerHTML"], ze = /* @__PURE__ */ ae({
194
+ }, xe = ["innerHTML"], Le = /* @__PURE__ */ oe({
325
195
  __name: "DefaultOverlay",
326
196
  setup(n) {
327
- const { elementRef: e, pointerPosition: t, isDragging: r, draggingElements: l } = Ke(), a = C(() => {
328
- var o, i, s, v;
197
+ const { elementRef: e, pointerPosition: t, isDragging: r, draggingElements: a } = Pe(), o = C(() => {
198
+ var l, c, s, i;
329
199
  return {
330
- transform: `translate3d(${(((o = t.current.value) == null ? void 0 : o.x) ?? 0) - (((i = t.offset.pixel.value) == null ? void 0 : i.x) ?? 0)}px, ${(((s = t.current.value) == null ? void 0 : s.y) ?? 0) - (((v = t.offset.pixel.value) == null ? void 0 : v.y) ?? 0)}px, 0)`,
200
+ transform: `translate3d(${(((l = t.current.value) == null ? void 0 : l.x) ?? 0) - (((c = t.offset.pixel.value) == null ? void 0 : c.x) ?? 0)}px, ${(((s = t.current.value) == null ? void 0 : s.y) ?? 0) - (((i = t.offset.pixel.value) == null ? void 0 : i.y) ?? 0)}px, 0)`,
331
201
  zIndex: 1e3,
332
202
  position: "fixed",
333
203
  top: 0,
@@ -335,56 +205,56 @@ const T = ie(() => {
335
205
  transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
336
206
  };
337
207
  });
338
- return (o, i) => W(r) ? (F(), X("div", {
208
+ return (l, c) => W(r) ? (N(), F("div", {
339
209
  key: 0,
340
210
  ref_key: "elementRef",
341
211
  ref: e,
342
- style: Q(a.value)
212
+ style: B(o.value)
343
213
  }, [
344
- (F(!0), X(ye, null, Ee(W(l), (s, v) => {
345
- var d, g;
346
- return F(), X("div", {
347
- key: v,
348
- innerHTML: s.initialHTML,
349
- style: Q({
350
- width: `${(d = s.initialRect) == null ? void 0 : d.width}px`,
351
- height: `${(g = s.initialRect) == null ? void 0 : g.height}px`
214
+ (N(!0), F(ge, null, fe(W(a), ([s, i]) => {
215
+ var u, d;
216
+ return N(), F("div", {
217
+ key: i.id,
218
+ innerHTML: i.initialHTML,
219
+ style: B({
220
+ width: `${(u = i.initialRect) == null ? void 0 : u.width}px`,
221
+ height: `${(d = i.initialRect) == null ? void 0 : d.height}px`
352
222
  })
353
- }, null, 12, Ae);
223
+ }, null, 12, xe);
354
224
  }), 128))
355
- ], 4)) : he("", !0);
225
+ ], 4)) : de("", !0);
356
226
  }
357
- }), te = /* @__PURE__ */ ae({
227
+ }), ne = /* @__PURE__ */ oe({
358
228
  __name: "DragOverlay",
359
229
  setup(n) {
360
230
  const { activeContainer: e } = T(), t = C(
361
- () => e.component.value ?? ze
231
+ () => e.component.value ?? Le
362
232
  );
363
- return (r, l) => (F(), pe(we(t.value)));
233
+ return (r, a) => (N(), me(he(t.value)));
364
234
  }
365
- }), We = {
235
+ }), Te = {
366
236
  install(n) {
367
- n.component("DragOverlay", te);
237
+ n.component("DragOverlay", ne);
368
238
  const e = n.mount;
369
239
  n.mount = function(r) {
370
- const l = e.call(this, r), a = typeof r == "string" ? document.querySelector(r) : r;
371
- if (a && a instanceof Element && !a.querySelector("#vue-dnd-kit-overlay")) {
372
- const o = document.createElement("div");
373
- o.id = "vue-dnd-kit-overlay", o.style.pointerEvents = "none", a.appendChild(o);
374
- const i = Pe(te);
375
- Z(i, o), n.__VUE_DND_KIT_OVERLAY__ = {
376
- container: o,
377
- vnode: i
240
+ const a = e.call(this, r), o = typeof r == "string" ? document.querySelector(r) : r;
241
+ if (o && o instanceof Element && !o.querySelector("#vue-dnd-kit-overlay")) {
242
+ const l = document.createElement("div");
243
+ l.id = "vue-dnd-kit-overlay", l.style.pointerEvents = "none", o.appendChild(l);
244
+ const c = ye(ne);
245
+ ee(c, l), n.__VUE_DND_KIT_OVERLAY__ = {
246
+ container: l,
247
+ vnode: c
378
248
  };
379
249
  }
380
- return l;
250
+ return a;
381
251
  };
382
252
  const t = n.unmount;
383
253
  n.unmount = function() {
384
- return n.__VUE_DND_KIT_OVERLAY__ && (Z(null, n.__VUE_DND_KIT_OVERLAY__.container), delete n.__VUE_DND_KIT_OVERLAY__), t.call(this);
254
+ return n.__VUE_DND_KIT_OVERLAY__ && (ee(null, n.__VUE_DND_KIT_OVERLAY__.container), delete n.__VUE_DND_KIT_OVERLAY__), t.call(this);
385
255
  };
386
256
  }
387
- }, ne = (n, e) => n.x < e.x + e.width && n.x + n.width > e.x && n.y < e.y + e.height && n.y + n.height > e.y, z = (n) => {
257
+ }, re = (n, e) => n.x < e.x + e.width && n.x + n.width > e.x && n.y < e.y + e.height && n.y + n.height > e.y, O = (n) => {
388
258
  if (!n)
389
259
  return {
390
260
  x: 0,
@@ -410,8 +280,8 @@ const T = ie(() => {
410
280
  }, $ = (n) => ({
411
281
  x: n.x + n.width / 2,
412
282
  y: n.y + n.height / 2
413
- }), Ve = (n, e) => {
414
- const t = z(n);
283
+ }), ze = (n, e) => {
284
+ const t = O(n);
415
285
  return {
416
286
  pixel: {
417
287
  x: e.x - t.x,
@@ -422,7 +292,7 @@ const T = ie(() => {
422
292
  y: (e.y - t.y) / t.height * 100
423
293
  }
424
294
  };
425
- }, re = (n, e) => {
295
+ }, ae = (n, e) => {
426
296
  const t = e.x - n.x, r = e.y - n.y;
427
297
  return Math.sqrt(t * t + r * r);
428
298
  }, le = (n, e) => {
@@ -432,137 +302,130 @@ const T = ie(() => {
432
302
  ), r = Math.max(
433
303
  0,
434
304
  Math.min(n.y + n.height, e.y + e.height) - Math.max(n.y, e.y)
435
- ), l = t * r, a = n.width * n.height, o = e.width * e.height;
436
- return (l / a * 100 + l / o * 100) / 2;
437
- }, oe = "data-vue-dnd-kit-draggable", D = (n) => {
305
+ ), a = t * r, o = n.width * n.height, l = e.width * e.height;
306
+ return (a / o * 100 + a / l * 100) / 2;
307
+ }, se = "data-vue-dnd-kit-draggable", S = (n) => {
438
308
  n.preventDefault();
439
- }, He = (n) => {
309
+ }, Se = (n) => {
440
310
  const {
441
- elements: e,
311
+ elementsMap: e,
442
312
  draggingElements: t,
443
313
  hovered: r,
444
- selectedElements: l,
445
- isDragging: a
446
- } = T(), o = R(null), i = C(
447
- () => {
448
- var u;
449
- return ((u = r.element.value) == null ? void 0 : u.node) === o.value;
450
- }
451
- ), s = C(
452
- () => t.value.some((u) => u.node === o.value)
453
- ), v = C(() => {
454
- if (!o.value || !a.value) return !1;
455
- const u = e.value.find(
456
- (c) => c.node === o.value
457
- );
458
- return u != null && u.groups.length ? !t.value.some((c) => c.groups.length ? !c.groups.some(
459
- (y) => u.groups.includes(y)
460
- ) : !1) : !0;
314
+ selectedElementsMap: a,
315
+ isDragging: o,
316
+ visibleElements: l,
317
+ handleDragElementIntersection: c
318
+ } = T(), s = K(null), i = C(
319
+ () => l.value.has(s.value) && r.element.value === s.value
320
+ ), u = U((n == null ? void 0 : n.id) || Ee()), d = C(() => !s.value || !l.value.has(s.value) ? !1 : t.value.has(s.value)), v = C(() => {
321
+ if (!s.value || !o.value || !l.value.has(s.value)) return !1;
322
+ const h = e.value.get(s.value);
323
+ return h != null && h.groups.length ? !Array.from(t.value.entries()).some(
324
+ ([L, p]) => p.groups.length ? !p.groups.some(
325
+ (_) => h.groups.includes(_)
326
+ ) : !1
327
+ ) : !0;
461
328
  });
462
329
  return {
463
- elementRef: o,
330
+ elementRef: s,
464
331
  registerElement: () => {
465
- if (!o.value) throw new Error("ElementRef is not set");
466
- e.value.push({
467
- node: o.value,
332
+ if (!s.value) throw new Error("ElementRef is not set");
333
+ e.value.set(s.value, {
334
+ node: s.value,
468
335
  groups: (n == null ? void 0 : n.groups) ?? [],
469
336
  layer: (n == null ? void 0 : n.layer) ?? null,
470
337
  defaultLayer: (n == null ? void 0 : n.layer) ?? null,
471
338
  events: (n == null ? void 0 : n.events) ?? {},
472
- data: (n == null ? void 0 : n.data) ?? null
473
- }), o.value.addEventListener("dragstart", D), o.value.addEventListener("drag", D), o.value.setAttribute(oe, "true"), o.value.setAttribute("draggable", "false");
339
+ data: (n == null ? void 0 : n.data) ?? null,
340
+ id: u.value
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");
474
342
  },
475
343
  unregisterElement: () => {
476
- var y, f, m, P;
477
- const u = e.value.findIndex(
478
- (L) => L.node === o.value
479
- );
480
- u !== -1 && e.value.splice(u, 1);
481
- const c = l.value.findIndex(
482
- (L) => L.node === o.value
483
- );
484
- c !== -1 && l.value.splice(c, 1), (y = o.value) == null || y.removeEventListener("dragstart", D), (f = o.value) == null || f.removeEventListener("drag", D), (m = o.value) == null || m.removeAttribute(oe), (P = o.value) == null || P.removeAttribute("draggable");
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"));
485
345
  },
486
- isDragging: s,
346
+ isDragging: d,
487
347
  isOvered: i,
488
- isAllowed: v
348
+ isAllowed: v,
349
+ id: u
489
350
  };
490
- }, A = (n, e) => n ? e.contains(n) : !1, Oe = (n) => {
491
- var d, g;
492
- const e = z(n.activeContainer.ref.value), t = $(e), r = ((d = n.pointerPosition.current.value) == null ? void 0 : d.x) ?? 0, l = ((g = n.pointerPosition.current.value) == null ? void 0 : g.y) ?? 0, o = !(e && r >= e.x && r <= e.x + e.width && l >= e.y && l <= e.y + e.height), i = n.draggingElements.value.map((u) => u.node), s = n.elements.value.filter((u) => {
493
- if (!u.node) return !1;
494
- const c = z(u.node);
495
- return c && e && ne(c, e);
496
- }).map((u) => {
497
- const c = z(u.node), y = $(c), f = r >= c.x && r <= c.x + c.width && l >= c.y && l <= c.y + c.height, m = le(c, e), P = re(t, y), L = n.elements.value.filter(
498
- (E) => E !== u && E.node && u.node && A(u.node, E.node)
499
- ).length;
351
+ }, k = (n, e) => n ? e.contains(n) : !1, _e = (n) => {
352
+ var u, d;
353
+ const e = O(n.activeContainer.ref.value), t = $(e), r = ((u = n.pointerPosition.current.value) == null ? void 0 : u.x) ?? 0, a = ((d = n.pointerPosition.current.value) == null ? void 0 : d.y) ?? 0, l = !(e && r >= e.x && r <= e.x + e.width && a >= e.y && a <= e.y + e.height), c = Array.from(n.draggingElements.value.keys()), s = Array.from(n.visibleElements.value.entries()).filter(([v, g]) => {
354
+ if (!v) return !1;
355
+ const m = O(v);
356
+ return m && e && re(m, e);
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;
360
+ for (const [A, R] of n.visibleElements.value.entries())
361
+ A !== v && A && v && k(v, A) && M++;
500
362
  return {
501
- element: u,
502
- node: u.node,
503
- isPointerInElement: f,
504
- overlapPercent: m,
505
- depth: L,
506
- centerDistance: P
363
+ element: g,
364
+ node: v,
365
+ isPointerInElement: L,
366
+ overlapPercent: p,
367
+ depth: M,
368
+ centerDistance: _
507
369
  };
508
- }).sort((u, c) => {
509
- if (!o) {
510
- if (u.isPointerInElement && c.isPointerInElement)
511
- return c.depth - u.depth;
512
- if (u.isPointerInElement !== c.isPointerInElement)
513
- return u.isPointerInElement ? -1 : 1;
370
+ }).sort((v, g) => {
371
+ if (!l) {
372
+ if (v.isPointerInElement && g.isPointerInElement)
373
+ return g.depth - v.depth;
374
+ if (v.isPointerInElement !== g.isPointerInElement)
375
+ return v.isPointerInElement ? -1 : 1;
514
376
  }
515
- return Math.abs(u.overlapPercent - c.overlapPercent) <= 1 ? u.centerDistance - c.centerDistance : c.overlapPercent - u.overlapPercent;
516
- }), v = n.zones.value.filter((u) => {
517
- if (!u.node || i.some(
518
- (y) => y && A(u.node, y)
377
+ return Math.abs(v.overlapPercent - g.overlapPercent) <= 1 ? v.centerDistance - g.centerDistance : g.overlapPercent - v.overlapPercent;
378
+ }), i = Array.from(n.visibleZones.value.entries()).filter(([v, g]) => {
379
+ if (!v || c.some(
380
+ (h) => h && k(v, h)
519
381
  ))
520
382
  return !1;
521
- const c = z(u.node);
522
- return c && e && ne(c, e);
523
- }).map((u) => {
524
- const c = z(u.node), y = $(c), f = r >= c.x && r <= c.x + c.width && l >= c.y && l <= c.y + c.height, m = le(c, e), P = re(t, y), L = n.zones.value.filter(
525
- (E) => E !== u && E.node && u.node && A(u.node, E.node)
526
- ).length;
383
+ const m = O(v);
384
+ return m && e && re(m, e);
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;
388
+ for (const [A, R] of n.visibleZones.value.entries())
389
+ A !== v && A && v && k(v, A) && M++;
527
390
  return {
528
- zone: u,
529
- node: u.node,
530
- isPointerInElement: f,
531
- overlapPercent: m,
532
- depth: L,
533
- centerDistance: P
391
+ zone: g,
392
+ node: v,
393
+ isPointerInElement: L,
394
+ overlapPercent: p,
395
+ depth: M,
396
+ centerDistance: _
534
397
  };
535
- }).sort((u, c) => {
536
- if (!o) {
537
- if (u.isPointerInElement && c.isPointerInElement)
538
- return c.depth - u.depth;
539
- if (u.isPointerInElement !== c.isPointerInElement)
540
- return u.isPointerInElement ? -1 : 1;
398
+ }).sort((v, g) => {
399
+ if (!l) {
400
+ if (v.isPointerInElement && g.isPointerInElement)
401
+ return g.depth - v.depth;
402
+ if (v.isPointerInElement !== g.isPointerInElement)
403
+ return v.isPointerInElement ? -1 : 1;
541
404
  }
542
- return Math.abs(u.overlapPercent - c.overlapPercent) <= 1 ? u.centerDistance - c.centerDistance : c.overlapPercent - u.overlapPercent;
405
+ return Math.abs(v.overlapPercent - g.overlapPercent) <= 1 ? v.centerDistance - g.centerDistance : g.overlapPercent - v.overlapPercent;
543
406
  });
544
407
  return [
545
- ...s.map((u) => u.node),
546
- ...v.map((u) => u.node)
408
+ ...s.map((v) => v.node),
409
+ ...i.map((v) => v.node)
547
410
  ];
548
- }, Ye = (n, e) => {
549
- const { pointerPosition: t, keyboard: r } = T(), l = (e == null ? void 0 : e.moveStep) || 10;
411
+ }, De = (n, e) => {
412
+ const { pointerPosition: t, keyboard: r } = T(), a = (e == null ? void 0 : e.moveStep) || 10;
550
413
  return {
551
414
  onKeyboardStart: (s) => {
552
- var u;
553
- D(s);
554
- const v = z(n.value);
555
- (u = n.value) == null || u.blur();
556
- const d = v.x + v.width / 2, g = v.y + v.height / 2;
415
+ var v;
416
+ S(s);
417
+ const i = O(n.value);
418
+ (v = n.value) == null || v.blur();
419
+ const u = i.x + i.width / 2, d = i.y + i.height / 2;
557
420
  t.start.value = {
558
- x: d,
559
- y: g
421
+ x: u,
422
+ y: d
560
423
  }, t.current.value = {
561
- x: d,
562
- y: g
424
+ x: u,
425
+ y: d
563
426
  }, t.offset.pixel.value = {
564
- x: v.width / 2,
565
- y: v.height / 2
427
+ x: i.width / 2,
428
+ y: i.height / 2
566
429
  }, t.offset.percent.value = {
567
430
  x: 50,
568
431
  y: 50
@@ -570,247 +433,255 @@ const T = ie(() => {
570
433
  },
571
434
  onKeyboardMove: () => {
572
435
  if (!t.current.value) return;
573
- const s = t.current.value.x, v = t.current.value.y;
574
- let d = s, g = v;
575
- r.w.value && (g -= l), r.s.value && (g += l), r.a.value && (d -= l), r.d.value && (d += l), t.current.value = {
576
- x: d,
577
- y: g
436
+ const s = t.current.value.x, i = t.current.value.y;
437
+ let u = s, d = i;
438
+ r.w.value && (d -= a), r.s.value && (d += a), r.a.value && (u -= a), r.d.value && (u += a), t.current.value = {
439
+ x: u,
440
+ y: d
578
441
  };
579
442
  },
580
443
  onKeyboardEnd: () => {
581
444
  t.current.value = null, t.start.value = null, t.offset.pixel.value = null, t.offset.percent.value = null;
582
445
  }
583
446
  };
584
- }, Ue = (n) => {
447
+ }, Ie = (n) => {
585
448
  const e = T();
586
449
  return {
587
- onPointerStart: (a) => {
588
- e.pointerPosition.start.value = { x: a.clientX, y: a.clientY }, e.pointerPosition.current.value = {
589
- x: a.clientX,
590
- y: a.clientY
450
+ onPointerStart: (o) => {
451
+ e.pointerPosition.start.value = { x: o.clientX, y: o.clientY }, e.pointerPosition.current.value = {
452
+ x: o.clientX,
453
+ y: o.clientY
591
454
  };
592
- const { pixel: o, percent: i } = Ve(n.value, {
593
- x: a.clientX,
594
- y: a.clientY
455
+ const { pixel: l, percent: c } = ze(n.value, {
456
+ x: o.clientX,
457
+ y: o.clientY
595
458
  });
596
- e.pointerPosition.offset.pixel.value = o, e.pointerPosition.offset.percent.value = i;
459
+ e.pointerPosition.offset.pixel.value = l, e.pointerPosition.offset.percent.value = c;
597
460
  },
598
- onPointerMove: (a) => {
461
+ onPointerMove: (o) => {
599
462
  e.pointerPosition.current.value = {
600
- x: a.clientX,
601
- y: a.clientY
463
+ x: o.clientX,
464
+ y: o.clientY
602
465
  };
603
466
  },
604
467
  onPointerEnd: () => {
605
468
  e.pointerPosition.current.value = null, e.pointerPosition.start.value = null, e.pointerPosition.offset.pixel.value = null, e.pointerPosition.offset.percent.value = null;
606
469
  }
607
470
  };
608
- }, je = (n, e) => {
609
- var U, _;
610
- const t = T(), { onPointerStart: r, onPointerMove: l, onPointerEnd: a } = Ue(n), { onKeyboardStart: o, onKeyboardMove: i, onKeyboardEnd: s } = Ye(
471
+ }, be = (n, e) => {
472
+ var R, Z;
473
+ const t = T(), { onPointerStart: r, onPointerMove: a, onPointerEnd: o } = Ie(n), { onKeyboardStart: l, onKeyboardMove: c, onKeyboardEnd: s } = De(
611
474
  n,
612
475
  e == null ? void 0 : e.keyboard
613
476
  );
614
- let v = null;
615
- const d = (w) => {
616
- var K, b;
617
- const M = t.selectedElements.value.some(
618
- (h) => h.node === w
619
- );
620
- if (t.selectedElements.value.length && M)
621
- return t.selectedElements.value.map((h) => {
622
- var x, k;
623
- return {
624
- ...h,
625
- initialHTML: ((x = h.node) == null ? void 0 : x.outerHTML) ?? "",
626
- initialRect: (k = h.node) == null ? void 0 : k.getBoundingClientRect()
627
- };
628
- });
629
- t.selectedElements.value = [];
630
- const S = t.elements.value.find(
631
- (h) => h.node === w
632
- );
633
- return S ? [
634
- {
635
- ...S,
636
- initialHTML: ((K = S.node) == null ? void 0 : K.outerHTML) ?? "",
637
- initialRect: (b = S.node) == null ? void 0 : b.getBoundingClientRect()
638
- }
639
- ] : [];
640
- }, g = (w) => {
641
- if (!w)
477
+ let i = null;
478
+ const u = (f) => {
479
+ var D, E;
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();
484
+ return Array.from(t.selectedElementsMap.value.entries()).forEach(
485
+ ([I, Y]) => {
486
+ var V, H;
487
+ P.set(I, {
488
+ ...Y,
489
+ initialHTML: ((V = Y.node) == null ? void 0 : V.outerHTML) ?? "",
490
+ initialRect: (H = Y.node) == null ? void 0 : H.getBoundingClientRect()
491
+ });
492
+ }
493
+ ), P;
494
+ }
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;
504
+ }, d = (f) => {
505
+ if (!f)
642
506
  return { element: null, zone: null };
643
- const M = Array.isArray(w) ? w : [w], S = t.draggingElements.value.map(
644
- (h) => h.node
645
- ), K = M.map(
646
- (h) => t.elements.value.find((x) => x.node === h)
647
- ).filter((h) => !h || S.some(
648
- (x) => x && (x === h.node || A(
649
- h.node,
650
- x
651
- ))
652
- ) ? !1 : h.groups.length ? !t.draggingElements.value.some(
653
- (k) => k.groups.length ? !k.groups.some(
654
- (H) => h.groups.includes(H)
655
- ) : !1
656
- ) : !0), b = M.map(
657
- (h) => t.zones.value.find((x) => x.node === h)
658
- ).filter((h) => !h || S.some(
659
- (x) => x && (x === h.node || A(h.node, x))
660
- ) ? !1 : h.groups.length && !!t.draggingElements.value.some((k) => k.groups.length ? !k.groups.some((H) => h.groups.includes(H)) : !1) ? null : !0);
661
- return {
662
- element: K[0] ?? null,
663
- zone: b[0] ?? null
664
- };
665
- }, u = ((U = e == null ? void 0 : e.sensor) == null ? void 0 : U.setup) || Oe, c = (w) => {
666
- var K, b, h, x, k, H;
667
- const M = t.hovered.element.value, S = t.hovered.zone.value;
668
- t.hovered.element.value = w.element, t.hovered.zone.value = w.zone, t.hovered.element.value !== M && ((K = M == null ? void 0 : M.events) != null && K.onLeave && M.events.onLeave(t), (h = (b = t.hovered.element.value) == null ? void 0 : b.events) != null && h.onHover && t.hovered.element.value.events.onHover(t)), t.hovered.zone.value !== S && ((x = S == null ? void 0 : S.events) != null && x.onLeave && S.events.onLeave(t), (H = (k = t.hovered.zone.value) == null ? void 0 : k.events) != null && H.onHover && t.hovered.zone.value.events.onHover(t));
669
- }, y = Ie(() => {
670
- const w = u(t), M = g(w);
671
- c(M);
672
- }, ((_ = e == null ? void 0 : e.sensor) == null ? void 0 : _.throttle) ?? 0), f = () => {
673
- y(), v = requestAnimationFrame(f);
674
- }, m = () => f(), P = () => {
675
- v !== null && (cancelAnimationFrame(v), v = 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(
513
+ t.draggingElements.value.values()
514
+ ).some((Y) => Y.groups.length ? !Y.groups.some((V) => P.groups.includes(V)) : !1));
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
526
+ ))
527
+ ) || null,
528
+ zone: w
529
+ } : { element: null, zone: null };
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)));
534
+ }, m = we(() => {
535
+ const f = v(t), z = d(f);
536
+ g(z);
537
+ }, ((Z = e == null ? void 0 : e.sensor) == null ? void 0 : Z.throttle) ?? 0), h = () => {
538
+ m(), i = requestAnimationFrame(h);
539
+ }, L = () => h(), p = () => {
540
+ i !== null && (cancelAnimationFrame(i), i = null);
676
541
  };
677
542
  return {
678
- activate: (w) => {
679
- t.draggingElements.value = d(n.value), w instanceof PointerEvent ? r(w) : o(w), m();
543
+ activate: (f) => {
544
+ t.draggingElements.value = u(n.value), f instanceof PointerEvent ? r(f) : l(f), L();
680
545
  },
681
- track: (w) => {
682
- w instanceof KeyboardEvent ? i() : l(w);
546
+ track: (f) => {
547
+ f instanceof KeyboardEvent ? c() : a(f);
683
548
  },
684
- deactivate: (w = !0) => {
685
- var M, S;
686
- a(), s(), w && (t.hovered.zone.value ? (S = (M = t.hovered.zone.value.events).onDrop) == null || S.call(M, t) : t.draggingElements.value.forEach(
687
- (K) => {
688
- var b, h;
689
- return (h = (b = K.events).onEnd) == null ? void 0 : h.call(b, t);
690
- }
691
- ), t.selectedElements.value = []), t.draggingElements.value = [], t.hovered.zone.value = null, t.hovered.element.value = null, P();
549
+ deactivate: (f = !0) => {
550
+ var z, x;
551
+ if (o(), s(), f) {
552
+ 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);
555
+ } 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);
560
+ }
561
+ );
562
+ t.selectedElementsMap.value.clear();
563
+ }
564
+ t.draggingElements.value.clear(), t.hovered.zone.value = null, t.hovered.element.value = null, p();
692
565
  }
693
566
  };
694
- }, Fe = ie(() => {
695
- let n = "", e = "", t = "", r = null, l = null, a = null, o = null, i = null;
696
- const { activeContainer: s } = T(), v = () => {
697
- const c = document.body;
698
- n = c.style.userSelect, c.style.userSelect = "none", window.addEventListener("contextmenu", D), window.addEventListener("selectstart", D), window.addEventListener("touchstart", D), window.addEventListener("touchmove", D);
567
+ }, ke = ie(() => {
568
+ let n = "", e = "", t = "", r = null, a = null, o = null, l = null, c = null;
569
+ const { activeContainer: s } = T(), i = () => {
570
+ const g = document.body;
571
+ n = g.style.userSelect, g.style.userSelect = "none", window.addEventListener("contextmenu", S), window.addEventListener("selectstart", S), window.addEventListener("touchstart", S), window.addEventListener("touchmove", S);
572
+ }, u = () => {
573
+ const g = document.body;
574
+ g.style.userSelect = n, g.style.touchAction = e, g.style.overscrollBehavior = t, window.removeEventListener("contextmenu", S), window.removeEventListener("selectstart", S), window.removeEventListener("touchstart", S), window.removeEventListener("touchmove", S);
699
575
  }, d = () => {
700
- const c = document.body;
701
- c.style.userSelect = n, c.style.touchAction = e, c.style.overscrollBehavior = t, window.removeEventListener("contextmenu", D), window.removeEventListener("selectstart", D), window.removeEventListener("touchstart", D), window.removeEventListener("touchmove", D);
702
- }, g = () => {
703
- r && (document.removeEventListener("pointermove", r), r = null), l && (document.removeEventListener("pointerup", l), l = null), a && (a = null), o && (document.removeEventListener("wheel", o), o = null), i && (document.removeEventListener("keydown", i), document.removeEventListener("keypress", i), document.removeEventListener("keyup", i), i = null);
576
+ r && (document.removeEventListener("pointermove", r), r = null), a && (document.removeEventListener("pointerup", a), a = null), o && (o = null), l && (document.removeEventListener("wheel", l), l = null), c && (document.removeEventListener("keydown", c), document.removeEventListener("keypress", c), document.removeEventListener("keyup", c), c = null);
704
577
  };
705
578
  return {
706
- handleDragStart: (c, y, f) => {
707
- g(), c.target.blur(), f != null && f.container && (s.component.value = xe(f.container));
708
- const { activate: m, track: P, deactivate: L } = je(y, f);
709
- l = () => {
710
- s.component.value = null, d(), L(!0), g();
711
- }, a = () => {
712
- s.component.value = null, d(), L(!1), g();
713
- }, r = (E) => P(E), o = (E) => P(E), i = (E) => {
714
- E.type === "keyup" && (E.code === "Escape" && (a == null || a()), E.code === "Enter" && (l == null || l())), P(E);
715
- }, v(), m(c), document.addEventListener("pointermove", r), document.addEventListener("pointerup", l), document.addEventListener("wheel", o), document.addEventListener("keydown", i), document.addEventListener("keypress", i), document.addEventListener("keyup", i);
579
+ handleDragStart: (g, m, h) => {
580
+ d(), g.target.blur(), h != null && h.container && (s.component.value = pe(h.container));
581
+ const { activate: L, track: p, deactivate: _ } = be(m, h);
582
+ a = () => {
583
+ s.component.value = null, u(), _(!0), d();
584
+ }, o = () => {
585
+ 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);
716
589
  }
717
590
  };
718
- }), qe = (n) => {
591
+ }), Ye = (n) => {
719
592
  const {
720
- elementRef: e,
721
- registerElement: t,
722
- unregisterElement: r,
723
- isDragging: l,
593
+ id: e,
594
+ elementRef: t,
595
+ isDragging: r,
724
596
  isOvered: a,
725
- isAllowed: o
726
- } = He(n), { pointerPosition: i } = T(), { handleDragStart: s } = Fe(), v = (d) => s(d, e, n);
727
- return G(t), B(r), {
728
- pointerPosition: i,
729
- elementRef: e,
730
- isDragging: l,
597
+ isAllowed: o,
598
+ registerElement: l,
599
+ unregisterElement: c
600
+ } = Se(n), { pointerPosition: s } = T(), { handleDragStart: i } = ke(), u = (d) => i(d, t, n);
601
+ return q(l), G(c), {
602
+ pointerPosition: s,
603
+ elementRef: t,
604
+ isDragging: r,
731
605
  isOvered: a,
732
606
  isAllowed: o,
733
- handleDragStart: v
607
+ handleDragStart: u,
608
+ id: e
734
609
  };
735
- }, Xe = (n) => {
736
- const { zones: e, hovered: t, draggingElements: r, isDragging: l } = T(), a = R(null), o = C(() => {
737
- var d;
738
- return ((d = t.zone.value) == null ? void 0 : d.node) === a.value;
739
- }), i = C(() => {
740
- if (!a.value || !l.value) return !1;
741
- const d = e.value.find(
742
- (g) => g.node === a.value
743
- );
744
- return d != null && d.groups.length ? !r.value.some((g) => g.groups.length ? !g.groups.some(
745
- (u) => d.groups.includes(u)
610
+ }, Ce = (n) => {
611
+ const {
612
+ zonesMap: e,
613
+ hovered: t,
614
+ draggingElements: r,
615
+ isDragging: a,
616
+ handleDropZoneIntersection: o
617
+ } = T(), l = K(null), c = C(() => t.zone.value === l.value), s = C(() => {
618
+ if (!l.value || !a.value) return !1;
619
+ const d = e.value.get(l.value);
620
+ return d != null && d.groups.length ? !Array.from(r.value.values()).some((v) => v.groups.length ? !v.groups.some(
621
+ (g) => d.groups.includes(g)
746
622
  ) : !1) : !0;
747
623
  });
748
- return { elementRef: a, registerZone: () => {
749
- if (!a.value) throw new Error("elementRef is not set");
750
- e.value.push({
751
- node: a.value,
624
+ return { elementRef: l, registerZone: () => {
625
+ if (!l.value) throw new Error("elementRef is not set");
626
+ o("add", l.value), e.value.set(l.value, {
627
+ node: l.value,
752
628
  groups: (n == null ? void 0 : n.groups) ?? [],
753
629
  events: (n == null ? void 0 : n.events) ?? {},
754
630
  data: (n == null ? void 0 : n.data) ?? void 0
755
- }), a.value.setAttribute("data-dnd-droppable", "true");
631
+ }), l.value.setAttribute("data-dnd-droppable", "true");
756
632
  }, unregisterZone: () => {
757
- if (!a.value) throw new Error("elementRef is not set");
758
- const d = e.value.findIndex(
759
- (g) => g.node === a.value
760
- );
761
- d !== -1 && e.value.splice(d, 1);
762
- }, isOvered: o, isAllowed: i };
763
- }, Ge = (n) => {
764
- const { elementRef: e, registerZone: t, unregisterZone: r, isOvered: l, isAllowed: a } = Xe(n);
765
- return G(t), B(r), { elementRef: e, isOvered: l, isAllowed: a };
766
- }, Be = (n) => {
767
- const { selectedElements: e, elements: t } = T(), r = C(
768
- () => t.value.find((d) => d.node === n.value)
769
- ), l = C(
770
- () => e.value.some((d) => d.node === n.value)
771
- ), a = C(() => n.value ? e.value.some(
772
- (d) => d.node && A(
773
- d.node,
774
- n.value
775
- )
776
- ) : !1), o = C(() => n.value ? e.value.some(
777
- (d) => d.node && A(
778
- n.value,
779
- d.node
780
- )
781
- ) : !1), i = () => {
782
- r.value && (e.value = e.value.filter(
783
- (d) => d.node !== n.value
784
- ));
785
- }, s = () => {
786
- r.value && (a.value && (e.value = e.value.filter(
787
- (d) => d.node && !A(
788
- d.node,
789
- n.value
790
- )
791
- )), o.value && (e.value = e.value.filter(
792
- (d) => d.node && !A(
793
- n.value,
794
- d.node
795
- )
796
- )), e.value.push(r.value));
633
+ l.value && (o("remove", l.value), e.value.delete(l.value));
634
+ }, isOvered: c, isAllowed: s };
635
+ }, Ue = (n) => {
636
+ const { elementRef: e, registerZone: t, unregisterZone: r, isOvered: a, isAllowed: o } = Ce(n);
637
+ return q(t), G(r), { elementRef: e, isOvered: a, isAllowed: o };
638
+ }, Ve = (n) => {
639
+ const { selectedElementsMap: e, elementsMap: t } = T(), r = C(
640
+ () => n.value ? e.value.has(n.value) : !1
641
+ ), a = C(() => {
642
+ if (!n.value) return !1;
643
+ for (const [i, u] of e.value.entries())
644
+ if (i && k(i, n.value))
645
+ return !0;
646
+ return !1;
647
+ }), o = C(() => {
648
+ if (!n.value) return !1;
649
+ for (const [i, u] of e.value.entries())
650
+ if (i && k(n.value, i))
651
+ return !0;
652
+ return !1;
653
+ }), l = () => {
654
+ n.value && e.value.delete(n.value);
655
+ }, c = () => {
656
+ if (!n.value) return;
657
+ const i = t.value.get(n.value);
658
+ if (i) {
659
+ if (a.value)
660
+ for (const [u, d] of [...e.value.entries()])
661
+ u && k(u, n.value) && e.value.delete(u);
662
+ if (o.value)
663
+ for (const [u, d] of [...e.value.entries()])
664
+ u && k(n.value, u) && e.value.delete(u);
665
+ e.value.set(n.value, i);
666
+ }
797
667
  };
798
668
  return {
799
- handleUnselect: i,
800
- handleSelect: s,
669
+ handleUnselect: l,
670
+ handleSelect: c,
801
671
  handleToggleSelect: () => {
802
- r.value && (e.value.some((d) => d.node === n.value) ? i() : s());
672
+ n.value && (e.value.has(n.value) ? l() : c());
803
673
  },
804
- isSelected: l,
674
+ isSelected: r,
805
675
  isParentOfSelected: a
806
676
  };
807
677
  };
808
678
  export {
809
- ee as DnDOperations,
810
- We as default,
811
- z as getBoundingBox,
679
+ te as DnDOperations,
680
+ Te as default,
681
+ O as getBoundingBox,
812
682
  T as useDnDStore,
813
- qe as useDraggable,
814
- Ge as useDroppable,
815
- Be as useSelection
683
+ Ye as useDraggable,
684
+ Ue as useDroppable,
685
+ Ve as useSelection
816
686
  };
687
+ //# sourceMappingURL=vue-dnd-kit-core.es.js.map