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