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