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