@vue-dnd-kit/core 1.1.6 → 1.1.8

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