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