@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.
- package/LICENSE +21 -21
- package/README.md +260 -274
- package/dist/index.d.ts +2020 -9
- package/dist/vue-dnd-kit-core.cjs.js +2 -1
- package/dist/vue-dnd-kit-core.cjs.js.map +1 -0
- package/dist/vue-dnd-kit-core.es.js +472 -601
- package/dist/vue-dnd-kit-core.es.js.map +1 -0
- package/package.json +73 -73
- package/dist/composables/useDnDStore.d.ts +0 -2347
- package/dist/composables/useDragContainer.d.ts +0 -606
- package/dist/composables/useDraggable.d.ts +0 -17
- package/dist/composables/useDroppable.d.ts +0 -91
- package/dist/composables/useKeyboard.d.ts +0 -10
- package/dist/composables/usePointer.d.ts +0 -7
- package/dist/composables/useSelection.d.ts +0 -9
- package/dist/composables/useSensor.d.ts +0 -8
- package/dist/managers/useElementManager.d.ts +0 -10
- package/dist/managers/useEventManager.d.ts +0 -6
- package/dist/managers/useZoneManager.d.ts +0 -9
- package/dist/plugin.d.ts +0 -13
- package/dist/types/index.d.ts +0 -143
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/events.d.ts +0 -1
- package/dist/utils/geometry.d.ts +0 -17
- package/dist/utils/namespaces.d.ts +0 -2
- package/dist/utils/operations.d.ts +0 -14
- package/dist/utils/sensor.d.ts +0 -3
- package/dist/vue-shims.d.ts +0 -5
|
@@ -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
|
|
4
|
-
import {
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
}),
|
|
12
|
+
}), b(y, "insert", (e, t, r) => {
|
|
12
13
|
!e || t === void 0 || e.splice(t, 0, r);
|
|
13
|
-
}),
|
|
14
|
-
if (!e || !r || t === 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
|
|
17
|
-
|
|
18
|
-
}),
|
|
19
|
-
if (!e || !r || t === 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
|
|
22
|
-
e[t] =
|
|
23
|
-
}),
|
|
24
|
-
if (!e || t === void 0 || !r ||
|
|
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
|
|
27
|
-
|
|
28
|
-
}),
|
|
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
|
-
(
|
|
32
|
-
var
|
|
33
|
-
return
|
|
34
|
-
(
|
|
35
|
-
(
|
|
36
|
-
(
|
|
37
|
-
(
|
|
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
|
-
(
|
|
42
|
-
var
|
|
43
|
-
return
|
|
44
|
-
(
|
|
45
|
-
(
|
|
46
|
-
(
|
|
47
|
-
(
|
|
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
|
-
}),
|
|
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
|
-
(
|
|
55
|
-
var
|
|
56
|
-
return
|
|
57
|
-
(
|
|
58
|
-
(
|
|
59
|
-
(
|
|
60
|
-
(
|
|
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
|
-
(
|
|
65
|
-
var
|
|
66
|
-
return
|
|
67
|
-
(
|
|
68
|
-
(
|
|
69
|
-
(
|
|
70
|
-
(
|
|
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
|
-
}),
|
|
75
|
-
var l,
|
|
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.
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
(
|
|
81
|
-
(
|
|
82
|
-
(
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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,
|
|
100
|
-
(r = t.data) != null && r.source && ((
|
|
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
|
-
}),
|
|
103
|
-
const r = e.hovered.element.value,
|
|
104
|
-
r && t.length > 0 ? t.forEach((
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
(
|
|
108
|
-
(i = r.data) == null ? void 0 : i.index,
|
|
109
|
-
|
|
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((
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
(
|
|
115
|
-
(
|
|
116
|
-
|
|
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
|
|
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 =
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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:
|
|
289
|
-
pixel:
|
|
151
|
+
percent: U(null),
|
|
152
|
+
pixel: U(null)
|
|
290
153
|
}
|
|
291
|
-
}, { w:
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
pointerPosition:
|
|
162
|
+
elementsMap: r,
|
|
163
|
+
selectedElementsMap: a,
|
|
164
|
+
zonesMap: o,
|
|
165
|
+
visibleZones: l,
|
|
166
|
+
visibleElements: c,
|
|
167
|
+
pointerPosition: v,
|
|
301
168
|
keyboard: {
|
|
302
|
-
w:
|
|
303
|
-
s:
|
|
304
|
-
a:
|
|
305
|
-
d:
|
|
306
|
-
ctrl:
|
|
307
|
-
shift:
|
|
308
|
-
alt:
|
|
309
|
-
meta:
|
|
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
|
-
}),
|
|
313
|
-
const n =
|
|
314
|
-
return
|
|
315
|
-
|
|
316
|
-
}),
|
|
317
|
-
|
|
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
|
-
},
|
|
194
|
+
}, xe = ["innerHTML"], Le = /* @__PURE__ */ oe({
|
|
325
195
|
__name: "DefaultOverlay",
|
|
326
196
|
setup(n) {
|
|
327
|
-
const { elementRef: e, pointerPosition: t, isDragging: r, draggingElements:
|
|
328
|
-
var
|
|
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(${(((
|
|
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 (
|
|
208
|
+
return (l, c) => W(r) ? (N(), F("div", {
|
|
339
209
|
key: 0,
|
|
340
210
|
ref_key: "elementRef",
|
|
341
211
|
ref: e,
|
|
342
|
-
style:
|
|
212
|
+
style: B(o.value)
|
|
343
213
|
}, [
|
|
344
|
-
(
|
|
345
|
-
var
|
|
346
|
-
return
|
|
347
|
-
key:
|
|
348
|
-
innerHTML:
|
|
349
|
-
style:
|
|
350
|
-
width: `${(
|
|
351
|
-
height: `${(
|
|
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,
|
|
223
|
+
}, null, 12, xe);
|
|
354
224
|
}), 128))
|
|
355
|
-
], 4)) :
|
|
225
|
+
], 4)) : de("", !0);
|
|
356
226
|
}
|
|
357
|
-
}),
|
|
227
|
+
}), ne = /* @__PURE__ */ oe({
|
|
358
228
|
__name: "DragOverlay",
|
|
359
229
|
setup(n) {
|
|
360
230
|
const { activeContainer: e } = T(), t = C(
|
|
361
|
-
() => e.component.value ??
|
|
231
|
+
() => e.component.value ?? Le
|
|
362
232
|
);
|
|
363
|
-
return (r,
|
|
233
|
+
return (r, a) => (N(), me(he(t.value)));
|
|
364
234
|
}
|
|
365
|
-
}),
|
|
235
|
+
}), Te = {
|
|
366
236
|
install(n) {
|
|
367
|
-
n.component("DragOverlay",
|
|
237
|
+
n.component("DragOverlay", ne);
|
|
368
238
|
const e = n.mount;
|
|
369
239
|
n.mount = function(r) {
|
|
370
|
-
const
|
|
371
|
-
if (
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
container:
|
|
377
|
-
vnode:
|
|
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
|
|
250
|
+
return a;
|
|
381
251
|
};
|
|
382
252
|
const t = n.unmount;
|
|
383
253
|
n.unmount = function() {
|
|
384
|
-
return n.__VUE_DND_KIT_OVERLAY__ && (
|
|
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
|
-
},
|
|
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
|
-
}),
|
|
414
|
-
const t =
|
|
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
|
-
},
|
|
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
|
-
),
|
|
436
|
-
return (
|
|
437
|
-
},
|
|
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
|
-
},
|
|
309
|
+
}, Se = (n) => {
|
|
440
310
|
const {
|
|
441
|
-
|
|
311
|
+
elementsMap: e,
|
|
442
312
|
draggingElements: t,
|
|
443
313
|
hovered: r,
|
|
444
|
-
|
|
445
|
-
isDragging:
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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:
|
|
330
|
+
elementRef: s,
|
|
464
331
|
registerElement: () => {
|
|
465
|
-
if (!
|
|
466
|
-
e.value.
|
|
467
|
-
node:
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
346
|
+
isDragging: d,
|
|
487
347
|
isOvered: i,
|
|
488
|
-
isAllowed: v
|
|
348
|
+
isAllowed: v,
|
|
349
|
+
id: u
|
|
489
350
|
};
|
|
490
|
-
},
|
|
491
|
-
var
|
|
492
|
-
const e =
|
|
493
|
-
if (!
|
|
494
|
-
const
|
|
495
|
-
return
|
|
496
|
-
}).map((
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
)
|
|
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:
|
|
502
|
-
node:
|
|
503
|
-
isPointerInElement:
|
|
504
|
-
overlapPercent:
|
|
505
|
-
depth:
|
|
506
|
-
centerDistance:
|
|
363
|
+
element: g,
|
|
364
|
+
node: v,
|
|
365
|
+
isPointerInElement: L,
|
|
366
|
+
overlapPercent: p,
|
|
367
|
+
depth: M,
|
|
368
|
+
centerDistance: _
|
|
507
369
|
};
|
|
508
|
-
}).sort((
|
|
509
|
-
if (!
|
|
510
|
-
if (
|
|
511
|
-
return
|
|
512
|
-
if (
|
|
513
|
-
return
|
|
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(
|
|
516
|
-
}),
|
|
517
|
-
if (!
|
|
518
|
-
(
|
|
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
|
|
522
|
-
return
|
|
523
|
-
}).map((
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
)
|
|
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:
|
|
529
|
-
node:
|
|
530
|
-
isPointerInElement:
|
|
531
|
-
overlapPercent:
|
|
532
|
-
depth:
|
|
533
|
-
centerDistance:
|
|
391
|
+
zone: g,
|
|
392
|
+
node: v,
|
|
393
|
+
isPointerInElement: L,
|
|
394
|
+
overlapPercent: p,
|
|
395
|
+
depth: M,
|
|
396
|
+
centerDistance: _
|
|
534
397
|
};
|
|
535
|
-
}).sort((
|
|
536
|
-
if (!
|
|
537
|
-
if (
|
|
538
|
-
return
|
|
539
|
-
if (
|
|
540
|
-
return
|
|
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(
|
|
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((
|
|
546
|
-
...
|
|
408
|
+
...s.map((v) => v.node),
|
|
409
|
+
...i.map((v) => v.node)
|
|
547
410
|
];
|
|
548
|
-
},
|
|
549
|
-
const { pointerPosition: t, keyboard: r } = T(),
|
|
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
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
(
|
|
556
|
-
const
|
|
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:
|
|
559
|
-
y:
|
|
421
|
+
x: u,
|
|
422
|
+
y: d
|
|
560
423
|
}, t.current.value = {
|
|
561
|
-
x:
|
|
562
|
-
y:
|
|
424
|
+
x: u,
|
|
425
|
+
y: d
|
|
563
426
|
}, t.offset.pixel.value = {
|
|
564
|
-
x:
|
|
565
|
-
y:
|
|
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,
|
|
574
|
-
let
|
|
575
|
-
r.w.value && (
|
|
576
|
-
x:
|
|
577
|
-
y:
|
|
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
|
-
},
|
|
447
|
+
}, Ie = (n) => {
|
|
585
448
|
const e = T();
|
|
586
449
|
return {
|
|
587
|
-
onPointerStart: (
|
|
588
|
-
e.pointerPosition.start.value = { x:
|
|
589
|
-
x:
|
|
590
|
-
y:
|
|
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:
|
|
593
|
-
x:
|
|
594
|
-
y:
|
|
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 =
|
|
459
|
+
e.pointerPosition.offset.pixel.value = l, e.pointerPosition.offset.percent.value = c;
|
|
597
460
|
},
|
|
598
|
-
onPointerMove: (
|
|
461
|
+
onPointerMove: (o) => {
|
|
599
462
|
e.pointerPosition.current.value = {
|
|
600
|
-
x:
|
|
601
|
-
y:
|
|
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
|
-
},
|
|
609
|
-
var
|
|
610
|
-
const t = T(), { onPointerStart: r, onPointerMove:
|
|
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
|
|
615
|
-
const
|
|
616
|
-
var
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
)
|
|
620
|
-
|
|
621
|
-
return t.
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
);
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
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
|
|
644
|
-
(
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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: (
|
|
679
|
-
t.draggingElements.value =
|
|
543
|
+
activate: (f) => {
|
|
544
|
+
t.draggingElements.value = u(n.value), f instanceof PointerEvent ? r(f) : l(f), L();
|
|
680
545
|
},
|
|
681
|
-
track: (
|
|
682
|
-
|
|
546
|
+
track: (f) => {
|
|
547
|
+
f instanceof KeyboardEvent ? c() : a(f);
|
|
683
548
|
},
|
|
684
|
-
deactivate: (
|
|
685
|
-
var
|
|
686
|
-
|
|
687
|
-
(
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
|
|
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
|
-
},
|
|
695
|
-
let n = "", e = "", t = "", r = null,
|
|
696
|
-
const { activeContainer: s } = T(),
|
|
697
|
-
const
|
|
698
|
-
n =
|
|
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
|
-
|
|
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: (
|
|
707
|
-
|
|
708
|
-
const { activate:
|
|
709
|
-
|
|
710
|
-
s.component.value = null,
|
|
711
|
-
},
|
|
712
|
-
s.component.value = null,
|
|
713
|
-
}, r = (
|
|
714
|
-
|
|
715
|
-
},
|
|
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
|
-
}),
|
|
591
|
+
}), Ye = (n) => {
|
|
719
592
|
const {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
isDragging: l,
|
|
593
|
+
id: e,
|
|
594
|
+
elementRef: t,
|
|
595
|
+
isDragging: r,
|
|
724
596
|
isOvered: a,
|
|
725
|
-
isAllowed: o
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
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:
|
|
607
|
+
handleDragStart: u,
|
|
608
|
+
id: e
|
|
734
609
|
};
|
|
735
|
-
},
|
|
736
|
-
const {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
);
|
|
744
|
-
|
|
745
|
-
|
|
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:
|
|
749
|
-
if (!
|
|
750
|
-
e.value.
|
|
751
|
-
node:
|
|
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
|
-
}),
|
|
631
|
+
}), l.value.setAttribute("data-dnd-droppable", "true");
|
|
756
632
|
}, unregisterZone: () => {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
),
|
|
772
|
-
(
|
|
773
|
-
|
|
774
|
-
n.value
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
)
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
(
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
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:
|
|
800
|
-
handleSelect:
|
|
669
|
+
handleUnselect: l,
|
|
670
|
+
handleSelect: c,
|
|
801
671
|
handleToggleSelect: () => {
|
|
802
|
-
|
|
672
|
+
n.value && (e.value.has(n.value) ? l() : c());
|
|
803
673
|
},
|
|
804
|
-
isSelected:
|
|
674
|
+
isSelected: r,
|
|
805
675
|
isParentOfSelected: a
|
|
806
676
|
};
|
|
807
677
|
};
|
|
808
678
|
export {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
679
|
+
te as DnDOperations,
|
|
680
|
+
Te as default,
|
|
681
|
+
O as getBoundingBox,
|
|
812
682
|
T as useDnDStore,
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
683
|
+
Ye as useDraggable,
|
|
684
|
+
Ue as useDroppable,
|
|
685
|
+
Ve as useSelection
|
|
816
686
|
};
|
|
687
|
+
//# sourceMappingURL=vue-dnd-kit-core.es.js.map
|