@vue-dnd-kit/core 2.0.7 → 2.0.9
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,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-default-overlay{transform:translate3d(var(--position-x),var(--position-y),0)}.dnd-kit-overlay-container{position:fixed;top:0;left:0;pointer-events:none;cursor:grabbing;z-index:9999}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
import { ref as j, watch as
|
|
2
|
+
import { ref as j, watch as re, shallowRef as te, reactive as q, computed as y, onScopeDispose as Je, onMounted as U, onBeforeUnmount as V, inject as Be, defineComponent as Fe, unref as k, openBlock as C, createElementBlock as J, normalizeStyle as Le, Fragment as he, renderList as Qe, createBlock as ne, resolveDynamicComponent as be, createCommentVNode as et, useTemplateRef as tt, provide as nt, renderSlot as Ce, Teleport as st, createElementVNode as ot, mergeProps as at } from "vue";
|
|
3
3
|
const T = {
|
|
4
4
|
SELECT_AREA: "data-dnd-kit-select-area",
|
|
5
5
|
DRAGGABLE: "data-dnd-kit-draggable",
|
|
@@ -9,7 +9,7 @@ const T = {
|
|
|
9
9
|
SELECT_AREA: `[${T.SELECT_AREA}]`,
|
|
10
10
|
DRAGGABLE: `[${T.DRAGGABLE}]`,
|
|
11
11
|
CONSTRAINT_AREA: `[${T.CONSTRAINT_AREA}]`
|
|
12
|
-
},
|
|
12
|
+
}, we = "VueDnDKitProvider", Ie = (e, t, s, n) => {
|
|
13
13
|
const o = /* @__PURE__ */ new Set();
|
|
14
14
|
return t.forEach((r) => {
|
|
15
15
|
const a = e.get(r), i = n ? n(r) : a?.disabled;
|
|
@@ -22,14 +22,14 @@ const T = {
|
|
|
22
22
|
g[l]((c) => s.value.has(c)) && o.add(r);
|
|
23
23
|
}), o;
|
|
24
24
|
};
|
|
25
|
-
let
|
|
26
|
-
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, K = (e, t) => e !== t && e.contains(t),
|
|
25
|
+
let _e = "", rt = "", it = "";
|
|
26
|
+
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, K = (e, t) => e !== t && e.contains(t), lt = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), ye = () => {
|
|
27
27
|
const e = document.body;
|
|
28
|
-
|
|
29
|
-
},
|
|
28
|
+
_e = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", M), window.addEventListener("selectstart", M), window.addEventListener("touchstart", M), window.addEventListener("touchmove", M);
|
|
29
|
+
}, pe = () => {
|
|
30
30
|
const e = document.body;
|
|
31
|
-
e.style.userSelect =
|
|
32
|
-
}, M = (e) => e.preventDefault(),
|
|
31
|
+
e.style.userSelect = _e, e.style.touchAction = rt, e.style.overscrollBehavior = it, window.removeEventListener("contextmenu", M), window.removeEventListener("selectstart", M), window.removeEventListener("touchstart", M), window.removeEventListener("touchmove", M);
|
|
32
|
+
}, M = (e) => e.preventDefault(), xe = (e, t) => {
|
|
33
33
|
if (t.entities.draggableMap.get(e)?.disabled) return !0;
|
|
34
34
|
for (const n of t.entities.visibleDraggableSet)
|
|
35
35
|
if (t.entities.draggableMap.get(n)?.disabled && K(n, e)) return !0;
|
|
@@ -39,12 +39,12 @@ const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$e
|
|
|
39
39
|
for (const n of t.entities.visibleDroppableSet)
|
|
40
40
|
if (t.entities.droppableMap.get(n)?.disabled && K(n, e)) return !0;
|
|
41
41
|
return !1;
|
|
42
|
-
},
|
|
42
|
+
}, Ae = (e, t) => {
|
|
43
43
|
if (!e.length || !t.length) return !0;
|
|
44
44
|
const s = new Set(t);
|
|
45
45
|
return e.some((n) => s.has(n));
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function ct(e, t, s, n) {
|
|
48
48
|
const o = /* @__PURE__ */ new Set();
|
|
49
49
|
for (const i of t.keys()) {
|
|
50
50
|
const g = s.get(i);
|
|
@@ -53,11 +53,11 @@ function it(e, t, s, n) {
|
|
|
53
53
|
const r = [...o], a = /* @__PURE__ */ new Set();
|
|
54
54
|
for (const i of e) {
|
|
55
55
|
const l = n.get(i)?.groups ?? [];
|
|
56
|
-
|
|
56
|
+
Ae(r, l) && a.add(i);
|
|
57
57
|
}
|
|
58
58
|
return a;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function gt(e, t, s) {
|
|
61
61
|
const n = /* @__PURE__ */ new Set();
|
|
62
62
|
for (const a of t.keys()) {
|
|
63
63
|
const i = s.get(a);
|
|
@@ -66,11 +66,11 @@ function lt(e, t, s) {
|
|
|
66
66
|
const o = [...n], r = /* @__PURE__ */ new Set();
|
|
67
67
|
for (const a of e) {
|
|
68
68
|
const g = s.get(a)?.groups ?? [];
|
|
69
|
-
|
|
69
|
+
Ae(o, g) && r.add(a);
|
|
70
70
|
}
|
|
71
71
|
return r;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const ge = (e) => {
|
|
74
74
|
const t = new IntersectionObserver((s) => {
|
|
75
75
|
s.forEach((n) => {
|
|
76
76
|
const o = n.target;
|
|
@@ -82,7 +82,7 @@ const ce = (e) => {
|
|
|
82
82
|
unobserve: (s) => t.unobserve(s),
|
|
83
83
|
disconnect: () => t.disconnect()
|
|
84
84
|
};
|
|
85
|
-
},
|
|
85
|
+
}, ut = (e) => {
|
|
86
86
|
const t = new ResizeObserver((s) => {
|
|
87
87
|
const n = s[0];
|
|
88
88
|
if (!n) return;
|
|
@@ -94,8 +94,8 @@ const ce = (e) => {
|
|
|
94
94
|
unobserve: (s) => t.unobserve(s),
|
|
95
95
|
disconnect: () => t.disconnect()
|
|
96
96
|
};
|
|
97
|
-
},
|
|
98
|
-
const t = j(null), s =
|
|
97
|
+
}, ft = (e) => {
|
|
98
|
+
const t = j(null), s = ut(t), n = re(
|
|
99
99
|
e,
|
|
100
100
|
(r) => {
|
|
101
101
|
s.disconnect(), r && s.observe(r);
|
|
@@ -108,18 +108,18 @@ const ce = (e) => {
|
|
|
108
108
|
}
|
|
109
109
|
} };
|
|
110
110
|
};
|
|
111
|
-
function
|
|
111
|
+
function Se(e, t = 0, s = 0) {
|
|
112
112
|
return {
|
|
113
113
|
start: { x: e.clientX, y: e.clientY },
|
|
114
114
|
current: { x: e.clientX, y: e.clientY },
|
|
115
115
|
offset: { x: t, y: s }
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function Ge(e, t) {
|
|
119
119
|
const s = t.getBoundingClientRect(), n = s.width > 0 ? (e.clientX - s.left) / s.width : 0.5, o = s.height > 0 ? (e.clientY - s.top) / s.height : 0.5;
|
|
120
120
|
return { x: n, y: o };
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function He(e, t) {
|
|
123
123
|
return {
|
|
124
124
|
...t,
|
|
125
125
|
initialHTML: e.innerHTML,
|
|
@@ -127,34 +127,34 @@ function Ge(e, t) {
|
|
|
127
127
|
initialOuterHTML: e.outerHTML
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function dt(e, t, s) {
|
|
131
131
|
e.forEach((n) => {
|
|
132
132
|
const o = t.get(n);
|
|
133
|
-
s.set(n,
|
|
133
|
+
s.set(n, He(n, o));
|
|
134
134
|
}), e.clear();
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function mt(e, t, s) {
|
|
137
137
|
s.clear();
|
|
138
138
|
const n = t.get(e);
|
|
139
|
-
s.set(e,
|
|
139
|
+
s.set(e, He(e, n));
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
e.entities.initiatingDraggable && (e.state.value = "dragging",
|
|
141
|
+
function se(e) {
|
|
142
|
+
e.entities.initiatingDraggable && (e.state.value = "dragging", ht(
|
|
143
143
|
e.entities.initiatingDraggable,
|
|
144
144
|
e.entities.selectedSet,
|
|
145
145
|
e.entities.draggableMap,
|
|
146
146
|
e.entities.draggingMap
|
|
147
147
|
));
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
t.has(e) ?
|
|
149
|
+
function ht(e, t, s, n) {
|
|
150
|
+
t.has(e) ? dt(t, s, n) : (t.clear(), mt(e, s, n));
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function Ke(e, t, s, n) {
|
|
153
153
|
if (n || !s) return !0;
|
|
154
154
|
const o = e.closest(s);
|
|
155
155
|
return o ? t.contains(o) : !1;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function bt(e, t) {
|
|
158
158
|
if (!e || !t) return 1;
|
|
159
159
|
const s = Math.abs(e.current.x - e.start.x), n = Math.abs(e.current.y - e.start.y);
|
|
160
160
|
if (typeof t == "number") {
|
|
@@ -170,24 +170,24 @@ function mt(e, t) {
|
|
|
170
170
|
const i = o > 0 ? Math.min(s / o, 1) : 1, g = r > 0 ? Math.min(n / r, 1) : 1;
|
|
171
171
|
return a === "both" ? Math.min(i, g) : Math.max(i, g);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function Ze(e, t, s) {
|
|
174
174
|
if (!s) return !0;
|
|
175
175
|
const n = s.distance != null, o = s.delay != null;
|
|
176
176
|
return !n && !o ? !0 : n && !o ? e >= 1 : !n && o ? t >= 1 : (s.condition ?? "both") === "both" ? e >= 1 && t >= 1 : e >= 1 || t >= 1;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function yt(e) {
|
|
179
179
|
if (e.state.value !== "activating" || !e.entities.initiatingDraggable)
|
|
180
180
|
return !1;
|
|
181
181
|
const t = e.entities.draggableMap.get(
|
|
182
182
|
e.entities.initiatingDraggable
|
|
183
183
|
);
|
|
184
|
-
return
|
|
184
|
+
return Ze(
|
|
185
185
|
e.distanceProgress.value,
|
|
186
186
|
e.delay.progress,
|
|
187
187
|
t?.activation
|
|
188
|
-
) ? (
|
|
188
|
+
) ? (se(e), !0) : !1;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function pt(e, t) {
|
|
191
191
|
let s = null;
|
|
192
192
|
const n = () => {
|
|
193
193
|
if (e.state.value !== "activating" || !e.entities.initiatingDraggable) {
|
|
@@ -204,7 +204,7 @@ function bt(e, t) {
|
|
|
204
204
|
e.delay.progress = Math.min(
|
|
205
205
|
(Date.now() - e.delay.startTime) / (r * 1e3),
|
|
206
206
|
1
|
|
207
|
-
),
|
|
207
|
+
), Ze(
|
|
208
208
|
e.distanceProgress.value,
|
|
209
209
|
e.delay.progress,
|
|
210
210
|
o?.activation
|
|
@@ -216,7 +216,7 @@ function bt(e, t) {
|
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function St(e, t) {
|
|
220
220
|
const s = e.closest(
|
|
221
221
|
_.CONSTRAINT_AREA
|
|
222
222
|
);
|
|
@@ -225,10 +225,10 @@ function yt(e, t) {
|
|
|
225
225
|
entity: t.get(s)
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function Dt(e, t, s, n) {
|
|
229
229
|
return s === "x" ? { x: e, y: n.top } : s === "y" ? { x: n.left, y: t } : { x: e, y: t };
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Mt(e, t, s, n, o) {
|
|
232
232
|
let r = e, a = t;
|
|
233
233
|
return s !== "y" && (r = Math.max(
|
|
234
234
|
n.left,
|
|
@@ -238,26 +238,26 @@ function St(e, t, s, n, o) {
|
|
|
238
238
|
Math.min(n.bottom - o.height, t)
|
|
239
239
|
)), { x: r, y: a };
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function vt(e, t, s, n, o) {
|
|
242
242
|
if (!e || !t)
|
|
243
243
|
return { x: 0, y: 0 };
|
|
244
244
|
const r = t.getBoundingClientRect(), a = r.width || o?.width || 0, i = r.height || o?.height || 0;
|
|
245
245
|
let g = e.current.x - a * e.offset.x, l = e.current.y - i * e.offset.y;
|
|
246
246
|
if (!s)
|
|
247
247
|
return { x: g, y: l };
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
248
|
+
const u = St(s, n);
|
|
249
|
+
if (!u)
|
|
250
250
|
return { x: g, y: l };
|
|
251
|
-
const { element: c, entity:
|
|
251
|
+
const { element: c, entity: f } = u, d = c.getBoundingClientRect(), m = s.getBoundingClientRect(), h = Dt(
|
|
252
252
|
g,
|
|
253
253
|
l,
|
|
254
|
-
|
|
254
|
+
f.axis || "both",
|
|
255
255
|
m
|
|
256
256
|
);
|
|
257
|
-
return
|
|
257
|
+
return f.restrictToArea ? Mt(
|
|
258
258
|
h.x,
|
|
259
259
|
h.y,
|
|
260
|
-
|
|
260
|
+
f.axis || "both",
|
|
261
261
|
d,
|
|
262
262
|
r
|
|
263
263
|
) : h;
|
|
@@ -278,8 +278,8 @@ const N = {
|
|
|
278
278
|
],
|
|
279
279
|
forMoveFaster: ["ShiftLeft", "ShiftRight"]
|
|
280
280
|
};
|
|
281
|
-
function
|
|
282
|
-
const s =
|
|
281
|
+
function wt(e, t) {
|
|
282
|
+
const s = te(), n = j(), r = {
|
|
283
283
|
keys: {
|
|
284
284
|
pressedKeys: j(/* @__PURE__ */ new Set()),
|
|
285
285
|
forDrag: [...N.forDrag],
|
|
@@ -299,27 +299,27 @@ function Mt(e, t) {
|
|
|
299
299
|
selectingArea: void 0,
|
|
300
300
|
draggingMap: /* @__PURE__ */ new Map(),
|
|
301
301
|
selectedSet: /* @__PURE__ */ new Set(),
|
|
302
|
-
allowedDroppableSet: y(() => s.value ?
|
|
302
|
+
allowedDroppableSet: y(() => s.value ? ct(
|
|
303
303
|
a.visibleDroppableSet,
|
|
304
304
|
a.draggingMap,
|
|
305
305
|
a.draggableMap,
|
|
306
306
|
a.droppableMap
|
|
307
307
|
) : /* @__PURE__ */ new Set()),
|
|
308
|
-
allowedDraggableSet: y(() => s.value ?
|
|
308
|
+
allowedDraggableSet: y(() => s.value ? gt(
|
|
309
309
|
a.visibleDraggableSet,
|
|
310
310
|
a.draggingMap,
|
|
311
311
|
a.draggableMap
|
|
312
312
|
) : /* @__PURE__ */ new Set()),
|
|
313
|
-
modifiersSelectableAreaSet: y(() =>
|
|
313
|
+
modifiersSelectableAreaSet: y(() => Ie(
|
|
314
314
|
a.selectableAreaMap,
|
|
315
315
|
a.visibleSelectableAreaSet,
|
|
316
316
|
r.keys.pressedKeys
|
|
317
317
|
)),
|
|
318
|
-
modifiersDraggableSet: y(() =>
|
|
318
|
+
modifiersDraggableSet: y(() => Ie(
|
|
319
319
|
a.draggableMap,
|
|
320
320
|
a.visibleDraggableSet,
|
|
321
321
|
r.keys.pressedKeys,
|
|
322
|
-
(w) =>
|
|
322
|
+
(w) => xe(w, { entities: a })
|
|
323
323
|
)),
|
|
324
324
|
visibleDraggableSet: /* @__PURE__ */ new Set(),
|
|
325
325
|
visibleDroppableSet: /* @__PURE__ */ new Set(),
|
|
@@ -328,26 +328,26 @@ function Mt(e, t) {
|
|
|
328
328
|
draggable: /* @__PURE__ */ new Map(),
|
|
329
329
|
droppable: /* @__PURE__ */ new Map()
|
|
330
330
|
}), g = {
|
|
331
|
-
throttle:
|
|
331
|
+
throttle: te(0)
|
|
332
332
|
}, l = q({
|
|
333
333
|
x: window.scrollX,
|
|
334
334
|
y: window.scrollY
|
|
335
|
-
}),
|
|
335
|
+
}), u = q({
|
|
336
336
|
progress: 0,
|
|
337
337
|
startTime: 0
|
|
338
338
|
}), c = y(() => {
|
|
339
339
|
if (!n.value || !a.initiatingDraggable) return 0;
|
|
340
340
|
const w = a.draggableMap.get(a.initiatingDraggable)?.activation?.distance;
|
|
341
|
-
return w ?
|
|
342
|
-
}),
|
|
341
|
+
return w ? bt(n.value, w) : 1;
|
|
342
|
+
}), f = ge(
|
|
343
343
|
a.visibleDraggableSet
|
|
344
|
-
), d =
|
|
344
|
+
), d = ge(
|
|
345
345
|
a.visibleDroppableSet
|
|
346
|
-
), m =
|
|
346
|
+
), m = ge(
|
|
347
347
|
a.visibleSelectableAreaSet
|
|
348
|
-
), { overlaySize: h, overlaySizeObserver: S } =
|
|
348
|
+
), { overlaySize: h, overlaySizeObserver: S } = ft(e), b = j(), v = y(() => {
|
|
349
349
|
const p = a.initiatingDraggable;
|
|
350
|
-
return
|
|
350
|
+
return vt(
|
|
351
351
|
n.value,
|
|
352
352
|
e.value,
|
|
353
353
|
p || null,
|
|
@@ -364,7 +364,7 @@ function Mt(e, t) {
|
|
|
364
364
|
entities: a,
|
|
365
365
|
keyboard: r,
|
|
366
366
|
scrollPosition: l,
|
|
367
|
-
delay:
|
|
367
|
+
delay: u,
|
|
368
368
|
distanceProgress: c,
|
|
369
369
|
hovered: i,
|
|
370
370
|
collision: g,
|
|
@@ -376,7 +376,7 @@ function Mt(e, t) {
|
|
|
376
376
|
to: E
|
|
377
377
|
},
|
|
378
378
|
lib: {
|
|
379
|
-
draggableObserver:
|
|
379
|
+
draggableObserver: f,
|
|
380
380
|
droppableObserver: d,
|
|
381
381
|
selectableAreaObserver: m,
|
|
382
382
|
overlaySizeObserver: S,
|
|
@@ -385,7 +385,7 @@ function Mt(e, t) {
|
|
|
385
385
|
autoScrollViewport: $
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
|
-
const
|
|
388
|
+
const oe = (e) => {
|
|
389
389
|
const t = e.hovered.draggable.keys().next().value;
|
|
390
390
|
if (t) {
|
|
391
391
|
const n = e.entities.draggableMap.get(t);
|
|
@@ -402,17 +402,17 @@ function I(e, t, s) {
|
|
|
402
402
|
const n = Math.max(0, Math.min(t, e.length));
|
|
403
403
|
return [...e.slice(0, n), ...s, ...e.slice(n)];
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function Ee(e, t, s = 1) {
|
|
406
406
|
const n = Math.max(0, Math.min(t, e.length - 1)), o = Math.max(0, Math.min(s, e.length - n));
|
|
407
407
|
return [...e.slice(0, n), ...e.slice(n + o)];
|
|
408
408
|
}
|
|
409
409
|
function H(e, t) {
|
|
410
410
|
const s = [...new Set(t)].filter((o) => o >= 0 && o < e.length).sort((o, r) => r - o);
|
|
411
411
|
let n = e;
|
|
412
|
-
for (const o of s) n =
|
|
412
|
+
for (const o of s) n = Ee(n, o, 1);
|
|
413
413
|
return n;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function Ne(e, t, s) {
|
|
416
416
|
if (t === s || t < 0 || s < 0 || t >= e.length || s >= e.length)
|
|
417
417
|
return e;
|
|
418
418
|
const n = [...e];
|
|
@@ -429,37 +429,37 @@ const R = {
|
|
|
429
429
|
return R.getInsertSide(e, t) === "after" && !e?.center;
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
|
-
function
|
|
432
|
+
function Ye(e, t) {
|
|
433
433
|
const { draggedItems: s, dropZone: n, hoveredDraggable: o } = e;
|
|
434
434
|
if (!s.length) return null;
|
|
435
435
|
const r = o?.placement.center === !0 && n != null && n.items !== o.items, a = r ? n.items : o?.items ?? n?.items;
|
|
436
436
|
if (!a) return null;
|
|
437
|
-
const i = s[0].items, g = s.map((
|
|
438
|
-
let
|
|
437
|
+
const i = s[0].items, g = s.map((f) => f.index), l = a.length;
|
|
438
|
+
let u, c;
|
|
439
439
|
if (o && !r) {
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
440
|
+
const f = o.items === i && g.includes(o.index);
|
|
441
|
+
if (f && s.length === 1) {
|
|
442
442
|
const d = R.isAtZoneStart(n?.placement, t);
|
|
443
|
-
|
|
443
|
+
u = d ? 0 : l, c = d ? "prepend" : "append";
|
|
444
444
|
} else {
|
|
445
|
-
if (
|
|
445
|
+
if (f)
|
|
446
446
|
return null;
|
|
447
447
|
{
|
|
448
448
|
const d = R.getInsertSide(o.placement, t), m = o.index;
|
|
449
|
-
d === "before" ? (
|
|
449
|
+
d === "before" ? (u = Math.max(0, m), c = "insert") : d === "after" ? (u = Math.min(l, m + 1), c = "insert") : (u = l, c = "append");
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
} else {
|
|
453
453
|
if (!n) return null;
|
|
454
|
-
const
|
|
455
|
-
|
|
454
|
+
const f = R.isAtZoneStart(n.placement, t);
|
|
455
|
+
u = f ? 0 : l, c = f ? "prepend" : "append";
|
|
456
456
|
}
|
|
457
|
-
return { targetIndex:
|
|
457
|
+
return { targetIndex: u, mode: c, targetArr: a };
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function xt(e, t = "vertical") {
|
|
460
460
|
const { draggedItems: s } = e;
|
|
461
461
|
if (!s.length) return null;
|
|
462
|
-
const n =
|
|
462
|
+
const n = Ye(e, t);
|
|
463
463
|
if (!n) return null;
|
|
464
464
|
const { targetArr: o, mode: r } = n;
|
|
465
465
|
let { targetIndex: a } = n;
|
|
@@ -467,80 +467,80 @@ function vt(e, t = "vertical") {
|
|
|
467
467
|
if (l === o) {
|
|
468
468
|
const c = i.filter((d) => d < a).length;
|
|
469
469
|
a = Math.max(0, a - c);
|
|
470
|
-
const
|
|
471
|
-
return { sourceItems:
|
|
470
|
+
const f = I(H(l, i), a, g);
|
|
471
|
+
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: i, targetIndex: a, mode: r, sameList: !0 };
|
|
472
472
|
} else {
|
|
473
|
-
const c = H(l, i),
|
|
474
|
-
return { sourceItems: c, targetItems:
|
|
473
|
+
const c = H(l, i), f = I(o, a, g);
|
|
474
|
+
return { sourceItems: c, targetItems: f, draggedItems: g, sourceIndexes: i, targetIndex: a, mode: r, sameList: !1 };
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function At(e) {
|
|
478
478
|
const { draggedItems: t, hoveredDraggable: s } = e;
|
|
479
479
|
if (!t.length || !s) return null;
|
|
480
|
-
const n = t.map((
|
|
480
|
+
const n = t.map((u) => u.index), o = s.index, r = t.map((u) => u.item), a = s.item, i = t[0].items, g = s.items, l = i === g;
|
|
481
481
|
if (l && n.includes(o)) return null;
|
|
482
482
|
if (t.length === 1) {
|
|
483
|
-
const
|
|
483
|
+
const u = n[0];
|
|
484
484
|
if (l) {
|
|
485
|
-
const c =
|
|
485
|
+
const c = Ne(i, u, o);
|
|
486
486
|
return { sourceItems: c, targetItems: c, sourceIndexes: n, targetIndex: o, sameList: !0 };
|
|
487
487
|
} else {
|
|
488
|
-
const c = [...i],
|
|
489
|
-
return c[
|
|
488
|
+
const c = [...i], f = [...g];
|
|
489
|
+
return c[u] = g[o], f[o] = i[u], { sourceItems: c, targetItems: f, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
490
490
|
}
|
|
491
491
|
} else {
|
|
492
|
-
const
|
|
492
|
+
const u = Math.min(...n);
|
|
493
493
|
if (l) {
|
|
494
|
-
const c = n.filter((b) => b < o).length,
|
|
494
|
+
const c = n.filter((b) => b < o).length, f = Math.max(0, o - c), d = n.filter((b) => b < u).length, m = Math.max(0, u - d);
|
|
495
495
|
let h = H(i, n);
|
|
496
|
-
h = I(h,
|
|
497
|
-
const S = m >=
|
|
498
|
-
return h = I(h, S, [a]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex:
|
|
496
|
+
h = I(h, f, r);
|
|
497
|
+
const S = m >= f ? m + r.length : m;
|
|
498
|
+
return h = I(h, S, [a]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex: f, sameList: !0 };
|
|
499
499
|
} else {
|
|
500
|
-
const c = n.filter((h) => h <
|
|
500
|
+
const c = n.filter((h) => h < u).length, f = Math.max(0, u - c);
|
|
501
501
|
let d = H(i, n);
|
|
502
|
-
d = I(d,
|
|
503
|
-
let m =
|
|
502
|
+
d = I(d, f, [a]);
|
|
503
|
+
let m = Ee(g, o);
|
|
504
504
|
return m = I(m, o, r), { sourceItems: d, targetItems: m, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function Et(e, t = "vertical") {
|
|
509
509
|
const { draggedItems: s } = e;
|
|
510
510
|
if (!s.length) return null;
|
|
511
|
-
const n =
|
|
511
|
+
const n = Ye(e, t);
|
|
512
512
|
if (!n) return null;
|
|
513
513
|
const { targetArr: o, targetIndex: r, mode: a } = n, i = s.map((l) => l.item);
|
|
514
514
|
return { targetItems: I(o, r, i), copiedItems: i, targetIndex: r, mode: a };
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function Lt(e) {
|
|
517
517
|
const { draggedItems: t } = e;
|
|
518
518
|
if (!t.length) return null;
|
|
519
519
|
const s = t.map((a) => a.index), n = t.map((a) => a.item), o = t[0].items;
|
|
520
520
|
return { sourceItems: H(o, s), removedItems: n, sourceIndexes: s };
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function Ct(e) {
|
|
523
523
|
return {
|
|
524
524
|
// Low-level array ops
|
|
525
525
|
insertAt: I,
|
|
526
|
-
removeAt:
|
|
526
|
+
removeAt: Ee,
|
|
527
527
|
removeIndexes: H,
|
|
528
|
-
swapAt:
|
|
528
|
+
swapAt: Ne,
|
|
529
529
|
// Placement helpers
|
|
530
530
|
getInsertSide: (t, s) => R.getInsertSide(t, s),
|
|
531
531
|
isAtZoneStart: (t, s) => R.isAtZoneStart(t, s),
|
|
532
532
|
isAtZoneEnd: (t, s) => R.isAtZoneEnd(t, s),
|
|
533
533
|
// High-level (event-bound)
|
|
534
|
-
suggestSort: (t) =>
|
|
535
|
-
suggestSwap: () =>
|
|
536
|
-
suggestCopy: (t) =>
|
|
537
|
-
suggestRemove: () =>
|
|
534
|
+
suggestSort: (t) => xt(e, t),
|
|
535
|
+
suggestSwap: () => At(e),
|
|
536
|
+
suggestCopy: (t) => Et(e, t),
|
|
537
|
+
suggestRemove: () => Lt(e)
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
|
-
const P = (e) => e.keys().next().value,
|
|
540
|
+
const P = (e) => e.keys().next().value, It = (e) => e.target.closest(
|
|
541
541
|
_.DRAGGABLE
|
|
542
542
|
);
|
|
543
|
-
function
|
|
543
|
+
function Rt(e) {
|
|
544
544
|
const t = e.entities.initiatingDraggable;
|
|
545
545
|
if (!t) return [];
|
|
546
546
|
const s = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t), n = s?.payload;
|
|
@@ -554,8 +554,8 @@ function Ct(e) {
|
|
|
554
554
|
item: g[i],
|
|
555
555
|
items: g,
|
|
556
556
|
data: s?.data?.()
|
|
557
|
-
}), e.entities.draggingMap.forEach((
|
|
558
|
-
const
|
|
557
|
+
}), e.entities.draggingMap.forEach((u, c) => {
|
|
558
|
+
const f = e.entities.draggableMap.get(c), d = f?.payload;
|
|
559
559
|
if (!d) return;
|
|
560
560
|
const m = d();
|
|
561
561
|
if (!Array.isArray(m) || m.length < 2) return;
|
|
@@ -566,12 +566,12 @@ function Ct(e) {
|
|
|
566
566
|
index: b,
|
|
567
567
|
item: S[b],
|
|
568
568
|
items: g,
|
|
569
|
-
data:
|
|
569
|
+
data: f?.data?.()
|
|
570
570
|
});
|
|
571
|
-
}), [...l.values()].sort((
|
|
571
|
+
}), [...l.values()].sort((u, c) => u.index - c.index);
|
|
572
572
|
}
|
|
573
573
|
const A = (e, t) => {
|
|
574
|
-
const s =
|
|
574
|
+
const s = Rt(e);
|
|
575
575
|
let n, o;
|
|
576
576
|
if (t) {
|
|
577
577
|
const r = e.entities.droppableMap.get(t);
|
|
@@ -585,14 +585,14 @@ const A = (e, t) => {
|
|
|
585
585
|
}
|
|
586
586
|
const a = P(e.hovered.draggable);
|
|
587
587
|
if (a && (a === t || t.contains(a)) && a) {
|
|
588
|
-
const g = e.entities.draggableMap.get(a), l = g?.payload,
|
|
588
|
+
const g = e.entities.draggableMap.get(a), l = g?.payload, u = e.hovered.draggable.get(a), c = { top: !1, right: !1, bottom: !1, left: !1, center: !1 };
|
|
589
589
|
if (l) {
|
|
590
|
-
const
|
|
591
|
-
if (Array.isArray(
|
|
592
|
-
const [d, m] =
|
|
590
|
+
const f = l();
|
|
591
|
+
if (Array.isArray(f) && f.length >= 2) {
|
|
592
|
+
const [d, m] = f, h = Number(d);
|
|
593
593
|
o = {
|
|
594
594
|
element: a,
|
|
595
|
-
placement:
|
|
595
|
+
placement: u ?? c,
|
|
596
596
|
index: h,
|
|
597
597
|
item: m[h],
|
|
598
598
|
items: m,
|
|
@@ -601,7 +601,7 @@ const A = (e, t) => {
|
|
|
601
601
|
}
|
|
602
602
|
} else g?.data && (o = {
|
|
603
603
|
element: a,
|
|
604
|
-
placement:
|
|
604
|
+
placement: u ?? c,
|
|
605
605
|
index: -1,
|
|
606
606
|
item: void 0,
|
|
607
607
|
items: [],
|
|
@@ -614,7 +614,7 @@ const A = (e, t) => {
|
|
|
614
614
|
dropZone: n,
|
|
615
615
|
hoveredDraggable: o,
|
|
616
616
|
provider: e,
|
|
617
|
-
helpers:
|
|
617
|
+
helpers: Ct({ draggedItems: s, dropZone: n, hoveredDraggable: o })
|
|
618
618
|
};
|
|
619
619
|
}, F = (e, t, s) => {
|
|
620
620
|
if (!t) return;
|
|
@@ -625,7 +625,7 @@ const A = (e, t) => {
|
|
|
625
625
|
e.entities.draggingMap.forEach((n) => {
|
|
626
626
|
n.disabled || n.events?.[t]?.(s);
|
|
627
627
|
});
|
|
628
|
-
},
|
|
628
|
+
}, kt = (e, t, s) => {
|
|
629
629
|
if (t !== s) {
|
|
630
630
|
if (t && !G(t, e)) {
|
|
631
631
|
const n = A(e, t);
|
|
@@ -636,7 +636,7 @@ const A = (e, t) => {
|
|
|
636
636
|
e.entities.droppableMap.get(s)?.events?.onEnter?.(n);
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
|
-
},
|
|
639
|
+
}, Pt = (e, t, s) => {
|
|
640
640
|
if (t !== s) {
|
|
641
641
|
const n = A(e);
|
|
642
642
|
if (t) {
|
|
@@ -648,61 +648,61 @@ const A = (e, t) => {
|
|
|
648
648
|
o && !o.disabled && o.events?.onHover?.(n);
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
},
|
|
652
|
-
const n =
|
|
651
|
+
}, ue = (e, t, s) => {
|
|
652
|
+
const n = It(t);
|
|
653
653
|
!n || !e.entities.draggingMap.has(n) || e.entities.draggingMap.get(n)?.events?.[s]?.(A(e));
|
|
654
|
-
},
|
|
654
|
+
}, Tt = (e, t) => {
|
|
655
655
|
const s = P(t.droppable);
|
|
656
656
|
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
657
|
-
},
|
|
657
|
+
}, Xe = (e, t) => {
|
|
658
658
|
const s = P(t.droppable);
|
|
659
659
|
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
660
660
|
};
|
|
661
|
-
function
|
|
661
|
+
function zt(e) {
|
|
662
662
|
return e.parentElement?.closest(_.SELECT_AREA) ?? null;
|
|
663
663
|
}
|
|
664
|
-
const
|
|
664
|
+
const Ot = (e, t, s) => {
|
|
665
665
|
if (!s) return {};
|
|
666
|
-
const n = s.getBoundingClientRect(), o = Math.max(n.left, Math.min(e.x, t.x)), r = Math.max(n.top, Math.min(e.y, t.y)), a = Math.min(n.right, Math.max(e.x, t.x)), i = Math.min(n.bottom, Math.max(e.y, t.y)), g = Math.max(0, a - o), l = Math.max(0, i - r);
|
|
666
|
+
const n = s.getBoundingClientRect(), o = Math.max(n.left, Math.min(e.x, t.x)), r = Math.max(n.top, Math.min(e.y, t.y)), a = Math.min(n.right, Math.max(e.x, t.x)), i = Math.min(n.bottom, Math.max(e.y, t.y)), g = Math.max(0, a - o), l = Math.max(0, i - r), u = o - n.left + s.scrollLeft, c = r - n.top + s.scrollTop;
|
|
667
667
|
return {
|
|
668
|
-
|
|
669
|
-
|
|
668
|
+
position: "absolute",
|
|
669
|
+
left: `${u}px`,
|
|
670
|
+
top: `${c}px`,
|
|
670
671
|
width: `${g}px`,
|
|
671
672
|
height: `${l}px`,
|
|
672
|
-
position: "fixed",
|
|
673
673
|
pointerEvents: "none",
|
|
674
674
|
border: "1px solid #3b82f6",
|
|
675
675
|
backgroundColor: "#3b82f61a"
|
|
676
676
|
};
|
|
677
|
-
},
|
|
677
|
+
}, Ue = (e) => {
|
|
678
678
|
if (!e.pointer.value || !e.entities.selectingArea) return;
|
|
679
|
-
const { selectingArea: t } = e.entities, s =
|
|
679
|
+
const { selectingArea: t } = e.entities, s = Bt(
|
|
680
680
|
e.pointer.value.start,
|
|
681
681
|
e.pointer.value.current
|
|
682
682
|
), n = e.entities.selectableAreaMap.get(t)?.groups ?? [], o = e.lib.rectCache;
|
|
683
683
|
e.entities.visibleDraggableSet.forEach((r) => {
|
|
684
684
|
if (r === t || !t.contains(r)) return;
|
|
685
|
-
const a =
|
|
685
|
+
const a = zt(r);
|
|
686
686
|
if (a && a !== t) {
|
|
687
687
|
e.entities.selectedSet.delete(r);
|
|
688
688
|
return;
|
|
689
689
|
}
|
|
690
|
-
if (
|
|
690
|
+
if (xe(r, e)) {
|
|
691
691
|
e.entities.selectedSet.delete(r);
|
|
692
692
|
return;
|
|
693
693
|
}
|
|
694
694
|
const g = e.entities.draggableMap.get(r)?.groups ?? [];
|
|
695
|
-
if (!
|
|
695
|
+
if (!Ae(n, g)) {
|
|
696
696
|
e.entities.selectedSet.delete(r);
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
699
|
let l = o.get(r);
|
|
700
|
-
l || (l = r.getBoundingClientRect(), o.set(r, l)),
|
|
700
|
+
l || (l = r.getBoundingClientRect(), o.set(r, l)), lt(s, l) ? e.entities.selectedSet.add(r) : e.entities.selectedSet.delete(r);
|
|
701
701
|
});
|
|
702
|
-
},
|
|
702
|
+
}, Bt = (e, t) => {
|
|
703
703
|
const s = Math.min(e.x, t.x), n = Math.min(e.y, t.y), o = Math.max(e.x, t.x), r = Math.max(e.y, t.y), a = o - s, i = r - n;
|
|
704
704
|
return new DOMRect(s, n, a, i);
|
|
705
|
-
},
|
|
705
|
+
}, Ft = (e, t, s = 5) => {
|
|
706
706
|
const n = s / 2;
|
|
707
707
|
return {
|
|
708
708
|
left: e - n,
|
|
@@ -710,14 +710,14 @@ const Tt = (e, t, s) => {
|
|
|
710
710
|
width: s,
|
|
711
711
|
height: s
|
|
712
712
|
};
|
|
713
|
-
},
|
|
713
|
+
}, _t = (e) => {
|
|
714
714
|
const t = e.pointer.value?.current, s = t?.x ?? 0, n = t?.y ?? 0;
|
|
715
|
-
return
|
|
715
|
+
return Ft(s, n, 5);
|
|
716
716
|
}, O = (e, t, s) => {
|
|
717
717
|
const n = e.left + e.width / 2, o = e.top + e.height / 2;
|
|
718
718
|
if (s) {
|
|
719
|
-
const i = s.top ?? 0, g = s.right ?? 0, l = s.bottom ?? 0,
|
|
720
|
-
if (c <
|
|
719
|
+
const i = s.top ?? 0, g = s.right ?? 0, l = s.bottom ?? 0, u = s.left ?? 0, c = t.left + u, f = t.right - g, d = t.top + i, m = t.bottom - l;
|
|
720
|
+
if (c < f && d < m && n >= c && n <= f && o >= d && o <= m)
|
|
721
721
|
return {
|
|
722
722
|
top: !1,
|
|
723
723
|
right: !1,
|
|
@@ -734,28 +734,28 @@ const Tt = (e, t, s) => {
|
|
|
734
734
|
right: n > r,
|
|
735
735
|
center: !1
|
|
736
736
|
};
|
|
737
|
-
},
|
|
737
|
+
}, Gt = (e) => ({
|
|
738
738
|
x: e.left + e.width / 2,
|
|
739
739
|
y: e.top + e.height / 2
|
|
740
|
-
}),
|
|
741
|
-
const s =
|
|
740
|
+
}), Re = (e, t) => {
|
|
741
|
+
const s = Gt(t);
|
|
742
742
|
return Math.hypot(e.x - s.x, e.y - s.y);
|
|
743
743
|
};
|
|
744
|
-
function
|
|
744
|
+
function Ht(e, t) {
|
|
745
745
|
return e === t ? !0 : !e || !t ? !1 : e.top === t.top && e.right === t.right && e.bottom === t.bottom && e.left === t.left && e.center === t.center;
|
|
746
746
|
}
|
|
747
747
|
function W(e, t) {
|
|
748
|
-
|
|
748
|
+
Ht(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
749
749
|
}
|
|
750
|
-
const
|
|
750
|
+
const Kt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
751
751
|
const n = P(t.droppable), o = P(t.draggable);
|
|
752
752
|
o && t.draggable.delete(o), n && t.droppable.delete(n);
|
|
753
|
-
const r =
|
|
753
|
+
const r = _t(e), a = s.zones[0], i = s.elements[0];
|
|
754
754
|
if (a && i && a === i && e.entities.droppableMap.has(a) && a) {
|
|
755
|
-
const c = a.getBoundingClientRect(),
|
|
755
|
+
const c = a.getBoundingClientRect(), f = e.entities.draggableMap.get(a)?.placementMargins, d = O(r, c, f);
|
|
756
756
|
if (d.center) {
|
|
757
757
|
t.droppable.set(a, d);
|
|
758
|
-
const m =
|
|
758
|
+
const m = Kt(s.elements, a);
|
|
759
759
|
if (m) {
|
|
760
760
|
const h = m.getBoundingClientRect();
|
|
761
761
|
t.draggable.set(
|
|
@@ -773,14 +773,14 @@ const Ht = (e, t) => e.find((s) => s !== t && K(t, s)), oe = (e, t, s) => {
|
|
|
773
773
|
if (i)
|
|
774
774
|
if (a)
|
|
775
775
|
if (K(a, i)) {
|
|
776
|
-
const c = i.getBoundingClientRect(),
|
|
776
|
+
const c = i.getBoundingClientRect(), f = e.entities.draggableMap.get(i)?.placementMargins;
|
|
777
777
|
t.draggable.set(
|
|
778
778
|
i,
|
|
779
|
-
O(r, c,
|
|
779
|
+
O(r, c, f)
|
|
780
780
|
);
|
|
781
781
|
} else {
|
|
782
|
-
const c = e.pointer.value?.current ?? { x: 0, y: 0 },
|
|
783
|
-
if (
|
|
782
|
+
const c = e.pointer.value?.current ?? { x: 0, y: 0 }, f = a.getBoundingClientRect(), d = i.getBoundingClientRect(), m = Re(c, f);
|
|
783
|
+
if (Re(c, d) < m) {
|
|
784
784
|
t.droppable.clear();
|
|
785
785
|
const S = e.entities.draggableMap.get(i)?.placementMargins;
|
|
786
786
|
t.draggable.set(
|
|
@@ -790,15 +790,15 @@ const Ht = (e, t) => e.find((s) => s !== t && K(t, s)), oe = (e, t, s) => {
|
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
792
|
else {
|
|
793
|
-
const c = i.getBoundingClientRect(),
|
|
793
|
+
const c = i.getBoundingClientRect(), f = e.entities.draggableMap.get(i)?.placementMargins;
|
|
794
794
|
t.draggable.set(
|
|
795
795
|
i,
|
|
796
|
-
O(r, c,
|
|
796
|
+
O(r, c, f)
|
|
797
797
|
);
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
const l = P(t.droppable),
|
|
801
|
-
if (o && o !==
|
|
800
|
+
const l = P(t.droppable), u = P(t.draggable);
|
|
801
|
+
if (o && o !== u) {
|
|
802
802
|
const c = e.entities.draggableMap.get(o);
|
|
803
803
|
c && W(c, void 0);
|
|
804
804
|
}
|
|
@@ -806,16 +806,16 @@ const Ht = (e, t) => e.find((s) => s !== t && K(t, s)), oe = (e, t, s) => {
|
|
|
806
806
|
const c = e.entities.droppableMap.get(n);
|
|
807
807
|
c && W(c, void 0);
|
|
808
808
|
}
|
|
809
|
-
if (
|
|
810
|
-
const c = e.entities.draggableMap.get(
|
|
811
|
-
c && W(c, t.draggable.get(
|
|
809
|
+
if (u) {
|
|
810
|
+
const c = e.entities.draggableMap.get(u);
|
|
811
|
+
c && W(c, t.draggable.get(u));
|
|
812
812
|
}
|
|
813
813
|
if (l) {
|
|
814
814
|
const c = e.entities.droppableMap.get(l);
|
|
815
815
|
c && W(c, t.droppable.get(l));
|
|
816
816
|
}
|
|
817
|
-
|
|
818
|
-
},
|
|
817
|
+
kt(e, n, l), Pt(e, o, u);
|
|
818
|
+
}, fe = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, X = (e) => {
|
|
819
819
|
if (!e)
|
|
820
820
|
return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
|
|
821
821
|
const t = e.getBoundingClientRect();
|
|
@@ -832,7 +832,7 @@ const Ht = (e, t) => e.find((s) => s !== t && K(t, s)), oe = (e, t, s) => {
|
|
|
832
832
|
}, Y = (e) => ({
|
|
833
833
|
x: e.x + e.width / 2,
|
|
834
834
|
y: e.y + e.height / 2
|
|
835
|
-
}),
|
|
835
|
+
}), Zt = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), Q = (e, t) => {
|
|
836
836
|
const s = Math.max(
|
|
837
837
|
0,
|
|
838
838
|
Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)
|
|
@@ -841,7 +841,7 @@ const Ht = (e, t) => e.find((s) => s !== t && K(t, s)), oe = (e, t, s) => {
|
|
|
841
841
|
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
|
|
842
842
|
), o = s * n, r = e.width * e.height, a = t.width * t.height;
|
|
843
843
|
return r === 0 || a === 0 ? 0 : (o / r * 100 + o / a * 100) / 2;
|
|
844
|
-
},
|
|
844
|
+
}, Nt = (e, t, s) => t >= e.x && t <= e.x + e.width && s >= e.y && s <= e.y + e.height, Yt = (e) => e.overlay.ref?.value ?? null, ke = (e) => {
|
|
845
845
|
const t = e.overlay.position?.value ?? { x: 0, y: 0 }, { x: s, y: n } = t, o = e.overlay.size?.value;
|
|
846
846
|
let r, a;
|
|
847
847
|
if (o)
|
|
@@ -860,9 +860,9 @@ const Ht = (e, t) => e.find((s) => s !== t && K(t, s)), oe = (e, t, s) => {
|
|
|
860
860
|
right: s + r,
|
|
861
861
|
bottom: n + a
|
|
862
862
|
};
|
|
863
|
-
},
|
|
863
|
+
}, De = (e) => e.entities.allowedDraggableSet, Ve = (e) => e.entities.allowedDroppableSet, Xt = (e, t) => !t.entities.draggingMap.has(e), Ut = (e, t) => ![...t.entities.draggingMap.keys()].some(
|
|
864
864
|
(s) => K(s, e)
|
|
865
|
-
), Vt = (e, t) => t.entities.draggableMap.has(e) ? !
|
|
865
|
+
), Vt = (e, t) => t.entities.draggableMap.has(e) ? !xe(e, t) : t.entities.droppableMap.has(e) ? !G(e, t) : !0, ee = (e, t) => Xt(e, t) && Ut(e, t) && Vt(e, t), de = 10;
|
|
866
866
|
function B(e, t) {
|
|
867
867
|
return Math.hypot(
|
|
868
868
|
t.x - (e.x + e.width / 2),
|
|
@@ -872,52 +872,56 @@ function B(e, t) {
|
|
|
872
872
|
function $t(e) {
|
|
873
873
|
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, s = document.elementFromPoint(t.x, t.y);
|
|
874
874
|
if (!s) return null;
|
|
875
|
-
const n =
|
|
875
|
+
const n = De(e), o = Ve(e), r = [], a = [];
|
|
876
876
|
let i = s;
|
|
877
877
|
for (; i; )
|
|
878
|
-
(n.has(i) || o.has(i)) &&
|
|
878
|
+
(n.has(i) || o.has(i)) && ee(i, e) && (n.has(i) && r.push(i), o.has(i) && a.push(i)), i = i.parentElement;
|
|
879
879
|
return r.length === 0 && a.length === 0 ? null : { elements: r, zones: a };
|
|
880
880
|
}
|
|
881
|
-
const
|
|
882
|
-
if (!
|
|
881
|
+
const Me = (e) => {
|
|
882
|
+
if (!Yt(e)) return { elements: [], zones: [] };
|
|
883
883
|
const s = e.pointer.value?.current ?? { x: 0, y: 0 }, n = $t(e);
|
|
884
884
|
if (n) {
|
|
885
885
|
if (n.elements.length > 0) return n;
|
|
886
886
|
const l = n.zones[0];
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
887
|
+
if (!l) return n;
|
|
888
|
+
const u = ke(e);
|
|
889
|
+
return { elements: [...De(e)].filter(
|
|
890
|
+
(d) => l.contains(d) && ee(d, e)
|
|
891
|
+
).map((d) => ({ el: d, box: X(d) })).filter(
|
|
892
|
+
({ box: d }) => fe(d, u) && Q(d, u) >= de
|
|
893
|
+
).sort((d, m) => B(d.box, s) - B(m.box, s)).map(({ el: d }) => d), zones: n.zones };
|
|
890
894
|
}
|
|
891
|
-
const o =
|
|
892
|
-
(l) =>
|
|
893
|
-
), a = [...
|
|
894
|
-
(l) =>
|
|
895
|
+
const o = ke(e), r = [...De(e)].filter(
|
|
896
|
+
(l) => ee(l, e)
|
|
897
|
+
), a = [...Ve(e)].filter(
|
|
898
|
+
(l) => ee(l, e)
|
|
895
899
|
), i = r.map((l) => ({ n: l, box: X(l) })).filter(
|
|
896
|
-
({ box: l }) =>
|
|
897
|
-
).sort((l,
|
|
898
|
-
({ box: l }) =>
|
|
899
|
-
).sort((l,
|
|
900
|
+
({ box: l }) => fe(l, o) && Q(l, o) >= de
|
|
901
|
+
).sort((l, u) => B(l.box, s) - B(u.box, s)).map(({ n: l }) => l), g = a.map((l) => ({ n: l, box: X(l) })).filter(
|
|
902
|
+
({ box: l }) => fe(l, o) && Q(l, o) >= de
|
|
903
|
+
).sort((l, u) => B(l.box, s) - B(u.box, s)).map(({ n: l }) => l);
|
|
900
904
|
return { elements: i, zones: g };
|
|
901
905
|
};
|
|
902
|
-
function
|
|
906
|
+
function ve(e) {
|
|
903
907
|
if (e.collision?.run) {
|
|
904
908
|
const s = e.collision.run(e);
|
|
905
|
-
|
|
909
|
+
ae(e, e.hovered, s);
|
|
906
910
|
return;
|
|
907
911
|
}
|
|
908
|
-
const t =
|
|
909
|
-
|
|
912
|
+
const t = Me(e);
|
|
913
|
+
ae(e, e.hovered, t);
|
|
910
914
|
}
|
|
911
915
|
function qt(e, t) {
|
|
912
916
|
const s = e.collision?.throttle?.value ?? 0;
|
|
913
917
|
if (s <= 0) {
|
|
914
|
-
|
|
918
|
+
ve(e);
|
|
915
919
|
return;
|
|
916
920
|
}
|
|
917
921
|
const n = Date.now();
|
|
918
|
-
n - t.value >= s && (t.value = n,
|
|
922
|
+
n - t.value >= s && (t.value = n, ve(e));
|
|
919
923
|
}
|
|
920
|
-
async function
|
|
924
|
+
async function $e(e) {
|
|
921
925
|
const t = e.hovered.droppable.keys().next().value;
|
|
922
926
|
if (!t || G(t, e)) return "accept";
|
|
923
927
|
const s = e.entities.droppableMap.get(t), n = A(e, t), o = s?.events?.onDrop?.(n);
|
|
@@ -928,15 +932,15 @@ async function Ue(e) {
|
|
|
928
932
|
a = await o;
|
|
929
933
|
} catch {
|
|
930
934
|
const i = e.entities.initiatingDraggable;
|
|
931
|
-
return F(e, i, "onSelfDragCancel"), x(e, "onDragCancel"),
|
|
935
|
+
return F(e, i, "onSelfDragCancel"), x(e, "onDragCancel"), Xe(e, e.hovered), "cancel";
|
|
932
936
|
}
|
|
933
937
|
return a === !1 ? (e.state.value = "dragging", "decline") : "accept";
|
|
934
938
|
}
|
|
935
939
|
return o === !1 ? "decline" : "accept";
|
|
936
940
|
}
|
|
937
|
-
function
|
|
941
|
+
function qe(e) {
|
|
938
942
|
const t = e.entities.initiatingDraggable;
|
|
939
|
-
F(e, t, "onSelfDragEnd"), x(e, "onDragEnd"),
|
|
943
|
+
F(e, t, "onSelfDragEnd"), x(e, "onDragEnd"), Tt(e, e.hovered);
|
|
940
944
|
}
|
|
941
945
|
function Wt(e) {
|
|
942
946
|
const t = e.entities.selectingArea;
|
|
@@ -948,21 +952,21 @@ const jt = (e) => {
|
|
|
948
952
|
const t = {
|
|
949
953
|
current: null
|
|
950
954
|
}, s = { value: 0 }, n = async () => {
|
|
951
|
-
|
|
955
|
+
pe(), t.current?.cancel(), t.current = null;
|
|
952
956
|
const i = e.state.value;
|
|
953
957
|
if (i === "dragging") {
|
|
954
|
-
const g = await
|
|
955
|
-
if (g === "accept" &&
|
|
956
|
-
|
|
958
|
+
const g = await $e(e);
|
|
959
|
+
if (g === "accept" && qe(e), g === "accept" || g === "cancel") {
|
|
960
|
+
oe(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
957
961
|
return;
|
|
958
962
|
}
|
|
959
963
|
return;
|
|
960
964
|
} else i === "selecting" && Wt(e);
|
|
961
|
-
|
|
965
|
+
oe(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
962
966
|
}, o = (i) => {
|
|
963
967
|
if (e.pointer.value) {
|
|
964
|
-
if (e.pointer.value.current = { x: i.clientX, y: i.clientY },
|
|
965
|
-
|
|
968
|
+
if (e.pointer.value.current = { x: i.clientX, y: i.clientY }, yt(e)) {
|
|
969
|
+
ue(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
966
970
|
return;
|
|
967
971
|
}
|
|
968
972
|
if (e.state.value === "dragging") {
|
|
@@ -970,29 +974,29 @@ const jt = (e) => {
|
|
|
970
974
|
const g = e.entities.initiatingDraggable;
|
|
971
975
|
F(e, g, "onSelfDragMove"), x(e, "onDragMove");
|
|
972
976
|
}
|
|
973
|
-
e.state.value === "selecting" &&
|
|
977
|
+
e.state.value === "selecting" && Ue(e);
|
|
974
978
|
}
|
|
975
979
|
};
|
|
976
980
|
return { pointerDown: (i) => {
|
|
977
981
|
document.addEventListener("pointerup", n), document.addEventListener("pointermove", o);
|
|
978
982
|
const g = i.target, l = g.closest(
|
|
979
983
|
_.SELECT_AREA
|
|
980
|
-
),
|
|
984
|
+
), u = g.closest(
|
|
981
985
|
_.DRAGGABLE
|
|
982
986
|
);
|
|
983
987
|
if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(l)) {
|
|
984
|
-
|
|
988
|
+
ye(), e.pointer.value = Se(i), e.state.value = "selecting", e.entities.selectingArea = l;
|
|
985
989
|
return;
|
|
986
990
|
}
|
|
987
|
-
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(
|
|
988
|
-
const c = e.entities.draggableMap.get(
|
|
989
|
-
if (!
|
|
991
|
+
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(u)) {
|
|
992
|
+
const c = e.entities.draggableMap.get(u);
|
|
993
|
+
if (!Ke(g, u, c?.dragHandle))
|
|
990
994
|
return;
|
|
991
|
-
|
|
992
|
-
const
|
|
993
|
-
e.pointer.value =
|
|
994
|
-
|
|
995
|
-
}))) : (
|
|
995
|
+
ye(), e.entities.initiatingDraggable = u;
|
|
996
|
+
const f = Ge(i, u);
|
|
997
|
+
e.pointer.value = Se(i, f.x, f.y), c?.activation?.distance || c?.activation?.delay ? (e.state.value = "activating", c?.activation?.delay && (e.delay.startTime = Date.now(), t.current = pt(e, () => {
|
|
998
|
+
se(e), ue(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
999
|
+
}))) : (se(e), ue(e, i, "onSelfDragStart"), x(e, "onDragStart"));
|
|
996
1000
|
}
|
|
997
1001
|
}, pointerUp: n, pointerMove: o, cleanup: () => {
|
|
998
1002
|
t.current?.cancel(), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o), e.lib.draggableObserver.disconnect(), e.lib.droppableObserver.disconnect(), e.lib.selectableAreaObserver.disconnect(), e.lib.overlaySizeObserver.disconnect();
|
|
@@ -1010,15 +1014,15 @@ const jt = (e) => {
|
|
|
1010
1014
|
const { keys: s } = e.keyboard;
|
|
1011
1015
|
if (s.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1012
1016
|
if (s.forCancel.includes(t.code)) {
|
|
1013
|
-
t.preventDefault(),
|
|
1017
|
+
t.preventDefault(), pe(), F(
|
|
1014
1018
|
e,
|
|
1015
1019
|
e.entities.initiatingDraggable,
|
|
1016
1020
|
"onSelfDragCancel"
|
|
1017
|
-
), x(e, "onDragCancel"),
|
|
1021
|
+
), x(e, "onDragCancel"), Xe(e, e.hovered), oe(e);
|
|
1018
1022
|
return;
|
|
1019
1023
|
}
|
|
1020
1024
|
if (s.forDrop.includes(t.code)) {
|
|
1021
|
-
t.preventDefault(), (async () => (await
|
|
1025
|
+
t.preventDefault(), (async () => (await $e(e) && qe(e), pe(), oe(e)))();
|
|
1022
1026
|
return;
|
|
1023
1027
|
}
|
|
1024
1028
|
const o = Jt[t.code];
|
|
@@ -1031,8 +1035,8 @@ const jt = (e) => {
|
|
|
1031
1035
|
x: e.pointer.value.current.x + o.dx * a,
|
|
1032
1036
|
y: e.pointer.value.current.y + o.dy * a
|
|
1033
1037
|
};
|
|
1034
|
-
const g = (e.collision?.run ??
|
|
1035
|
-
|
|
1038
|
+
const g = (e.collision?.run ?? Me)(e);
|
|
1039
|
+
ae(e, e.hovered, g), F(
|
|
1036
1040
|
e,
|
|
1037
1041
|
e.entities.initiatingDraggable,
|
|
1038
1042
|
"onSelfDragMove"
|
|
@@ -1050,34 +1054,43 @@ const jt = (e) => {
|
|
|
1050
1054
|
if (!r || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(r))
|
|
1051
1055
|
return;
|
|
1052
1056
|
const a = e.entities.draggableMap.get(r);
|
|
1053
|
-
if (!
|
|
1057
|
+
if (!Ke(o, r, a?.dragHandle, !0))
|
|
1054
1058
|
return;
|
|
1055
|
-
t.preventDefault(),
|
|
1056
|
-
const i = r.getBoundingClientRect(), g = i.left + i.width / 2, l = i.top + i.height / 2,
|
|
1059
|
+
t.preventDefault(), ye();
|
|
1060
|
+
const i = r.getBoundingClientRect(), g = i.left + i.width / 2, l = i.top + i.height / 2, u = {
|
|
1057
1061
|
clientX: g,
|
|
1058
1062
|
clientY: l
|
|
1059
1063
|
};
|
|
1060
1064
|
e.entities.initiatingDraggable = r;
|
|
1061
|
-
const c =
|
|
1062
|
-
e.pointer.value =
|
|
1063
|
-
|
|
1065
|
+
const c = Ge(u, r);
|
|
1066
|
+
e.pointer.value = Se(
|
|
1067
|
+
u,
|
|
1064
1068
|
c.x,
|
|
1065
1069
|
c.y
|
|
1066
|
-
),
|
|
1067
|
-
const d = (e.collision?.run ??
|
|
1068
|
-
|
|
1070
|
+
), se(e);
|
|
1071
|
+
const d = (e.collision?.run ?? Me)(e);
|
|
1072
|
+
ae(e, e.hovered, d), F(e, r, "onSelfDragStart"), x(e, "onDragStart");
|
|
1069
1073
|
}
|
|
1070
1074
|
}, en = (e) => (t) => {
|
|
1071
1075
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
1072
1076
|
}, tn = (e) => () => {
|
|
1073
1077
|
e.keyboard.keys.pressedKeys.value.clear();
|
|
1074
|
-
},
|
|
1078
|
+
}, me = {
|
|
1075
1079
|
keyDown: Qt,
|
|
1076
1080
|
keyUp: en,
|
|
1077
1081
|
clear: tn
|
|
1078
1082
|
}, nn = (e) => () => {
|
|
1079
|
-
|
|
1080
|
-
|
|
1083
|
+
if (!e.state.value) return;
|
|
1084
|
+
const t = e.scrollPosition.x, s = e.scrollPosition.y;
|
|
1085
|
+
if (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging") {
|
|
1086
|
+
ve(e);
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
if (e.state.value === "selecting" && e.pointer.value) {
|
|
1090
|
+
const n = window.scrollX - t, o = window.scrollY - s;
|
|
1091
|
+
e.pointer.value.start.x -= n, e.pointer.value.start.y -= o, Ue(e);
|
|
1092
|
+
}
|
|
1093
|
+
}, L = 50, sn = 144, Pe = 1e3 / sn;
|
|
1081
1094
|
function on(e) {
|
|
1082
1095
|
return e == null ? {
|
|
1083
1096
|
top: L,
|
|
@@ -1107,9 +1120,9 @@ const an = {
|
|
|
1107
1120
|
e.scrollTop = t, e.scrollLeft = s;
|
|
1108
1121
|
}
|
|
1109
1122
|
};
|
|
1110
|
-
function
|
|
1123
|
+
function We(e, t, s, n = an, o) {
|
|
1111
1124
|
const { speed: r = 10, disabled: a = !1 } = t, i = on(t.threshold);
|
|
1112
|
-
let g = null, l = null,
|
|
1125
|
+
let g = null, l = null, u = null, c = 0, f = 0;
|
|
1113
1126
|
const d = (b) => {
|
|
1114
1127
|
o && (o.value = b);
|
|
1115
1128
|
}, m = (b) => {
|
|
@@ -1120,21 +1133,21 @@ function $e(e, t, s, n = an, o) {
|
|
|
1120
1133
|
}
|
|
1121
1134
|
l || (l = b);
|
|
1122
1135
|
const $ = b - l;
|
|
1123
|
-
if ($ <
|
|
1136
|
+
if ($ < Pe) {
|
|
1124
1137
|
g = requestAnimationFrame(m);
|
|
1125
1138
|
return;
|
|
1126
1139
|
}
|
|
1127
|
-
const p = r * ($ /
|
|
1140
|
+
const p = r * ($ / Pe);
|
|
1128
1141
|
l = b;
|
|
1129
1142
|
const { scrollTop: w, scrollLeft: Z } = n.getScrollState(v);
|
|
1130
|
-
(!
|
|
1131
|
-
let z = !1,
|
|
1132
|
-
i.top > 0 && E.y -
|
|
1143
|
+
(!u || c !== w || f !== Z) && (u = n.getRect ? n.getRect(v) : v.getBoundingClientRect(), c = w, f = Z);
|
|
1144
|
+
let z = !1, le = w, ce = Z;
|
|
1145
|
+
i.top > 0 && E.y - u.top < i.top ? (le = w - p, z = !0) : i.bottom > 0 && u.bottom - E.y < i.bottom && (le = w + p, z = !0), i.left > 0 && E.x - u.left < i.left ? (ce = Z - p, z = !0) : i.right > 0 && u.right - E.x < i.right && (ce = Z + p, z = !0), z && n.setScroll(v, le, ce), d(z), g = requestAnimationFrame(m);
|
|
1133
1146
|
};
|
|
1134
1147
|
return { run: () => {
|
|
1135
1148
|
l = null, g = requestAnimationFrame(m);
|
|
1136
1149
|
}, stop: () => {
|
|
1137
|
-
g && (cancelAnimationFrame(g), g = null),
|
|
1150
|
+
g && (cancelAnimationFrame(g), g = null), u = null, c = 0, f = 0, l = null, d(!1);
|
|
1138
1151
|
} };
|
|
1139
1152
|
}
|
|
1140
1153
|
const rn = {
|
|
@@ -1156,7 +1169,7 @@ const rn = {
|
|
|
1156
1169
|
}
|
|
1157
1170
|
};
|
|
1158
1171
|
function cn(e, t) {
|
|
1159
|
-
const s =
|
|
1172
|
+
const s = te(!1), o = We(
|
|
1160
1173
|
ln,
|
|
1161
1174
|
t ?? {},
|
|
1162
1175
|
() => {
|
|
@@ -1169,7 +1182,7 @@ function cn(e, t) {
|
|
|
1169
1182
|
},
|
|
1170
1183
|
rn,
|
|
1171
1184
|
s
|
|
1172
|
-
), r =
|
|
1185
|
+
), r = re(
|
|
1173
1186
|
() => e.state.value,
|
|
1174
1187
|
(i) => {
|
|
1175
1188
|
i === "dragging" ? o.run() : o.stop();
|
|
@@ -1177,12 +1190,12 @@ function cn(e, t) {
|
|
|
1177
1190
|
), a = () => {
|
|
1178
1191
|
r(), o.stop();
|
|
1179
1192
|
};
|
|
1180
|
-
return
|
|
1193
|
+
return Je(a), { isScrolling: s, stop: a };
|
|
1181
1194
|
}
|
|
1182
1195
|
const gn = (e) => {
|
|
1183
|
-
const t = jt(e), s =
|
|
1196
|
+
const t = jt(e), s = me.keyDown(e), n = me.keyUp(e), o = me.clear(e), r = nn(e);
|
|
1184
1197
|
let a = null;
|
|
1185
|
-
|
|
1198
|
+
re(
|
|
1186
1199
|
e.autoScrollViewport,
|
|
1187
1200
|
(i) => {
|
|
1188
1201
|
a?.(), a = null, (i === !0 || i && typeof i == "object") && (a = cn(
|
|
@@ -1196,12 +1209,12 @@ const gn = (e) => {
|
|
|
1196
1209
|
}), V(() => {
|
|
1197
1210
|
document.removeEventListener("pointerdown", t.pointerDown), document.removeEventListener("pointerup", t.pointerUp), document.removeEventListener("pointermove", t.pointerMove), document.removeEventListener("keydown", s), document.removeEventListener("keyup", n), document.removeEventListener("blur", o), document.removeEventListener("scroll", r, !0), a?.(), t.cleanup();
|
|
1198
1211
|
});
|
|
1199
|
-
},
|
|
1200
|
-
const e =
|
|
1212
|
+
}, ie = () => {
|
|
1213
|
+
const e = Be(we);
|
|
1201
1214
|
if (!e) throw Error("DnD provider not found");
|
|
1202
1215
|
return e;
|
|
1203
|
-
},
|
|
1204
|
-
const e =
|
|
1216
|
+
}, je = () => {
|
|
1217
|
+
const e = ie();
|
|
1205
1218
|
return {
|
|
1206
1219
|
overlay: e.overlay,
|
|
1207
1220
|
delay: e.delay,
|
|
@@ -1215,31 +1228,31 @@ const gn = (e) => {
|
|
|
1215
1228
|
collision: e.collision,
|
|
1216
1229
|
autoScrollViewport: e.autoScrollViewport
|
|
1217
1230
|
};
|
|
1218
|
-
}, un = /* @__PURE__ */
|
|
1231
|
+
}, un = /* @__PURE__ */ Fe({
|
|
1219
1232
|
__name: "DefaultOverlay",
|
|
1220
1233
|
setup(e) {
|
|
1221
|
-
const { entities: t, state: s, overlay: n } =
|
|
1234
|
+
const { entities: t, state: s, overlay: n } = je();
|
|
1222
1235
|
return (o, r) => k(s) === "dragging" ? (C(), J("div", {
|
|
1223
1236
|
key: 0,
|
|
1224
1237
|
class: "dnd-kit-default-overlay",
|
|
1225
|
-
style:
|
|
1238
|
+
style: Le({
|
|
1226
1239
|
"--position-x": k(n).position.value.x + "px",
|
|
1227
1240
|
"--position-y": k(n).position.value.y + "px"
|
|
1228
1241
|
})
|
|
1229
1242
|
}, [
|
|
1230
|
-
(C(!0), J(
|
|
1231
|
-
k(t).draggableMap.get(a)?.render ? (C(),
|
|
1243
|
+
(C(!0), J(he, null, Qe(k(t).draggingMap, ([a, i]) => (C(), J(he, null, [
|
|
1244
|
+
k(t).draggableMap.get(a)?.render ? (C(), ne(be(k(t).draggableMap.get(a)?.render), { key: 0 })) : (C(), ne(be(a.tagName), {
|
|
1232
1245
|
key: 1,
|
|
1233
1246
|
innerHTML: i.initialOuterHTML,
|
|
1234
|
-
style:
|
|
1247
|
+
style: Le({
|
|
1235
1248
|
width: i.initialRect.width + "px",
|
|
1236
1249
|
height: i.initialRect.height + "px"
|
|
1237
1250
|
})
|
|
1238
1251
|
}, null, 8, ["innerHTML", "style"]))
|
|
1239
1252
|
], 64))), 256))
|
|
1240
|
-
], 4)) :
|
|
1253
|
+
], 4)) : et("", !0);
|
|
1241
1254
|
}
|
|
1242
|
-
}), hn = /* @__PURE__ */
|
|
1255
|
+
}), hn = /* @__PURE__ */ Fe({
|
|
1243
1256
|
__name: "DnDProvider",
|
|
1244
1257
|
props: {
|
|
1245
1258
|
autoScrollViewport: { type: [Object, Boolean, null] },
|
|
@@ -1248,23 +1261,23 @@ const gn = (e) => {
|
|
|
1248
1261
|
class: {}
|
|
1249
1262
|
},
|
|
1250
1263
|
setup(e) {
|
|
1251
|
-
const t = e, s =
|
|
1264
|
+
const t = e, s = tt("overlayRef"), n = wt(s, t);
|
|
1252
1265
|
gn(n);
|
|
1253
1266
|
const o = y(
|
|
1254
1267
|
() => n.overlay.render.value ?? un
|
|
1255
1268
|
);
|
|
1256
|
-
return
|
|
1257
|
-
|
|
1258
|
-
(C(),
|
|
1269
|
+
return nt(we, n), (r, a) => (C(), J(he, null, [
|
|
1270
|
+
Ce(r.$slots, "default"),
|
|
1271
|
+
(C(), ne(st, {
|
|
1259
1272
|
to: k(n).overlay.to.value || "body"
|
|
1260
1273
|
}, [
|
|
1261
|
-
|
|
1274
|
+
ot("div", at({
|
|
1262
1275
|
ref_key: "overlayRef",
|
|
1263
1276
|
ref: s,
|
|
1264
1277
|
class: "dnd-kit-overlay-container"
|
|
1265
1278
|
}, t), [
|
|
1266
|
-
|
|
1267
|
-
(C(),
|
|
1279
|
+
Ce(r.$slots, "overlay", { overlay: o.value }, () => [
|
|
1280
|
+
(C(), ne(be(o.value)))
|
|
1268
1281
|
])
|
|
1269
1282
|
], 16)
|
|
1270
1283
|
], 8, ["to"]))
|
|
@@ -1272,7 +1285,7 @@ const gn = (e) => {
|
|
|
1272
1285
|
}
|
|
1273
1286
|
});
|
|
1274
1287
|
function bn(e, t, s) {
|
|
1275
|
-
const n =
|
|
1288
|
+
const n = ie();
|
|
1276
1289
|
let o, r, a;
|
|
1277
1290
|
typeof t == "function" ? (o = {}, r = t) : (o = t ?? {}, r = s);
|
|
1278
1291
|
const i = y({
|
|
@@ -1281,8 +1294,8 @@ function bn(e, t, s) {
|
|
|
1281
1294
|
return c ? n.entities.selectedSet.has(c) : !1;
|
|
1282
1295
|
},
|
|
1283
1296
|
set(c) {
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1297
|
+
const f = D(e);
|
|
1298
|
+
f && n.entities.selectedSet[c ? "add" : "delete"](f);
|
|
1286
1299
|
}
|
|
1287
1300
|
}), g = y(() => {
|
|
1288
1301
|
const c = D(e);
|
|
@@ -1290,7 +1303,7 @@ function bn(e, t, s) {
|
|
|
1290
1303
|
}), l = y(() => {
|
|
1291
1304
|
const c = D(e);
|
|
1292
1305
|
return c ? n.entities.allowedDraggableSet.has(c) : !1;
|
|
1293
|
-
}),
|
|
1306
|
+
}), u = y(() => {
|
|
1294
1307
|
const c = D(e);
|
|
1295
1308
|
if (c)
|
|
1296
1309
|
return n.entities.draggableMap.get(c)?.hoveredPlacement;
|
|
@@ -1315,11 +1328,11 @@ function bn(e, t, s) {
|
|
|
1315
1328
|
selected: i,
|
|
1316
1329
|
isDragging: g,
|
|
1317
1330
|
isAllowed: l,
|
|
1318
|
-
isDragOver:
|
|
1331
|
+
isDragOver: u
|
|
1319
1332
|
};
|
|
1320
1333
|
}
|
|
1321
1334
|
const yn = (e, t) => {
|
|
1322
|
-
const s =
|
|
1335
|
+
const s = ie(), n = y(() => e.value === s.entities.selectingArea);
|
|
1323
1336
|
let o = null;
|
|
1324
1337
|
U(() => {
|
|
1325
1338
|
o = D(e), o && (o.setAttribute(T.SELECT_AREA, ""), s.lib.selectableAreaObserver.observe(o), s.entities.selectableAreaMap.set(o, {
|
|
@@ -1337,7 +1350,7 @@ const yn = (e, t) => {
|
|
|
1337
1350
|
const r = y(() => {
|
|
1338
1351
|
s.scrollPosition.x, s.scrollPosition.y;
|
|
1339
1352
|
const a = s.pointer.value;
|
|
1340
|
-
return !a || s.state.value !== "selecting" || !o || !n.value ? {} :
|
|
1353
|
+
return !a || s.state.value !== "selecting" || !o || !n.value ? {} : Ot(a.start, a.current, o);
|
|
1341
1354
|
});
|
|
1342
1355
|
return {
|
|
1343
1356
|
isSelecting: n,
|
|
@@ -1345,7 +1358,7 @@ const yn = (e, t) => {
|
|
|
1345
1358
|
};
|
|
1346
1359
|
};
|
|
1347
1360
|
function pn(e, t) {
|
|
1348
|
-
const s =
|
|
1361
|
+
const s = Be(we);
|
|
1349
1362
|
if (!s) throw Error("DnD provider not found");
|
|
1350
1363
|
let n = null;
|
|
1351
1364
|
return U(() => {
|
|
@@ -1358,7 +1371,7 @@ function pn(e, t) {
|
|
|
1358
1371
|
}), {};
|
|
1359
1372
|
}
|
|
1360
1373
|
function Sn(e, t, s) {
|
|
1361
|
-
const n =
|
|
1374
|
+
const n = ie();
|
|
1362
1375
|
let o = null, r, a;
|
|
1363
1376
|
typeof t == "function" ? (r = {}, a = t) : (r = t ?? {}, a = s);
|
|
1364
1377
|
const i = y(() => {
|
|
@@ -1386,7 +1399,7 @@ function Sn(e, t, s) {
|
|
|
1386
1399
|
};
|
|
1387
1400
|
}
|
|
1388
1401
|
const Dn = (e, t) => {
|
|
1389
|
-
const s =
|
|
1402
|
+
const s = je(), n = te(!1), r = We(
|
|
1390
1403
|
e,
|
|
1391
1404
|
t ?? {},
|
|
1392
1405
|
() => {
|
|
@@ -1400,14 +1413,14 @@ const Dn = (e, t) => {
|
|
|
1400
1413
|
void 0,
|
|
1401
1414
|
n
|
|
1402
1415
|
);
|
|
1403
|
-
return
|
|
1416
|
+
return re(
|
|
1404
1417
|
() => s.state.value,
|
|
1405
1418
|
(a) => {
|
|
1406
1419
|
a === "dragging" ? r.run() : r.stop();
|
|
1407
1420
|
}
|
|
1408
1421
|
), { isScrolling: n };
|
|
1409
1422
|
};
|
|
1410
|
-
function
|
|
1423
|
+
function Te(e, t) {
|
|
1411
1424
|
return t <= 0 ? e : Math.round(e / t) * t;
|
|
1412
1425
|
}
|
|
1413
1426
|
function Mn(e, t) {
|
|
@@ -1415,38 +1428,38 @@ function Mn(e, t) {
|
|
|
1415
1428
|
return y(() => {
|
|
1416
1429
|
const { x: r, y: a } = e.value;
|
|
1417
1430
|
return {
|
|
1418
|
-
x:
|
|
1419
|
-
y:
|
|
1431
|
+
x: Te(r, n),
|
|
1432
|
+
y: Te(a, o)
|
|
1420
1433
|
};
|
|
1421
1434
|
});
|
|
1422
1435
|
}
|
|
1423
|
-
const
|
|
1436
|
+
const ze = () => !0, Oe = () => 0, fn = "separate", dn = () => {
|
|
1424
1437
|
const e = {
|
|
1425
|
-
filterElements:
|
|
1426
|
-
filterZones:
|
|
1427
|
-
sortElements:
|
|
1428
|
-
sortZones:
|
|
1438
|
+
filterElements: ze,
|
|
1439
|
+
filterZones: ze,
|
|
1440
|
+
sortElements: Oe,
|
|
1441
|
+
sortZones: Oe,
|
|
1429
1442
|
mergeStrategy: fn,
|
|
1430
1443
|
pickClosestBetweenFirst: !1
|
|
1431
1444
|
}, t = (n, o, r, a, i, g, l) => {
|
|
1432
|
-
const
|
|
1433
|
-
for (const m of
|
|
1445
|
+
const u = a instanceof Set ? a : new Set(a), c = { containerBox: o, pointer: r }, f = e.minOverlapPercent, d = [];
|
|
1446
|
+
for (const m of u) {
|
|
1434
1447
|
if (!i(m, n)) continue;
|
|
1435
1448
|
const h = X(m);
|
|
1436
1449
|
if (!l(h, c)) continue;
|
|
1437
|
-
const S =
|
|
1438
|
-
if (
|
|
1450
|
+
const S = Q(h, o);
|
|
1451
|
+
if (f !== void 0 && S < f) continue;
|
|
1439
1452
|
let b = 0;
|
|
1440
|
-
for (const v of
|
|
1453
|
+
for (const v of u)
|
|
1441
1454
|
v !== m && K(v, m) && b++;
|
|
1442
1455
|
d.push({
|
|
1443
1456
|
node: m,
|
|
1444
1457
|
box: h,
|
|
1445
1458
|
meta: {
|
|
1446
|
-
isPointerInElement:
|
|
1459
|
+
isPointerInElement: Nt(h, r.x, r.y),
|
|
1447
1460
|
overlapPercent: S,
|
|
1448
1461
|
depth: b,
|
|
1449
|
-
centerDistance:
|
|
1462
|
+
centerDistance: Zt(
|
|
1450
1463
|
Y(o),
|
|
1451
1464
|
Y(h)
|
|
1452
1465
|
)
|
|
@@ -1518,46 +1531,46 @@ const Te = () => !0, ze = () => 0, fn = "separate", dn = () => {
|
|
|
1518
1531
|
n.collision
|
|
1519
1532
|
);
|
|
1520
1533
|
if (n.mergeStrategy === "unified-closest") {
|
|
1521
|
-
const
|
|
1522
|
-
...g.map((
|
|
1523
|
-
node:
|
|
1524
|
-
box:
|
|
1534
|
+
const u = [
|
|
1535
|
+
...g.map((f) => ({
|
|
1536
|
+
node: f.node,
|
|
1537
|
+
box: f.box,
|
|
1525
1538
|
isZone: !1,
|
|
1526
1539
|
distance: 0
|
|
1527
1540
|
})),
|
|
1528
|
-
...l.map((
|
|
1529
|
-
node:
|
|
1530
|
-
box:
|
|
1541
|
+
...l.map((f) => ({
|
|
1542
|
+
node: f.node,
|
|
1543
|
+
box: f.box,
|
|
1531
1544
|
isZone: !0,
|
|
1532
1545
|
distance: 0
|
|
1533
1546
|
}))
|
|
1534
1547
|
];
|
|
1535
|
-
if (
|
|
1536
|
-
for (const
|
|
1537
|
-
const d = Y(
|
|
1538
|
-
|
|
1548
|
+
if (u.length === 0) return { elements: [], zones: [] };
|
|
1549
|
+
for (const f of u) {
|
|
1550
|
+
const d = Y(f.box);
|
|
1551
|
+
f.distance = Math.hypot(
|
|
1539
1552
|
i.x - d.x,
|
|
1540
1553
|
i.y - d.y
|
|
1541
1554
|
);
|
|
1542
1555
|
}
|
|
1543
|
-
const c =
|
|
1544
|
-
(
|
|
1556
|
+
const c = u.reduce(
|
|
1557
|
+
(f, d) => d.distance < f.distance ? d : f
|
|
1545
1558
|
);
|
|
1546
1559
|
return c.isZone ? { elements: [], zones: [c.node] } : { elements: [c.node], zones: [] };
|
|
1547
1560
|
}
|
|
1548
1561
|
if (n.pickClosestBetweenFirst && g[0] && l[0]) {
|
|
1549
|
-
const
|
|
1550
|
-
i.x -
|
|
1551
|
-
i.y -
|
|
1562
|
+
const u = Y(l[0].box), c = Y(g[0].box), f = Math.hypot(
|
|
1563
|
+
i.x - u.x,
|
|
1564
|
+
i.y - u.y
|
|
1552
1565
|
);
|
|
1553
1566
|
return Math.hypot(
|
|
1554
1567
|
i.x - c.x,
|
|
1555
1568
|
i.y - c.y
|
|
1556
|
-
) <
|
|
1569
|
+
) < f ? { elements: g.map((m) => m.node), zones: [] } : { elements: [], zones: l.map((m) => m.node) };
|
|
1557
1570
|
}
|
|
1558
1571
|
return {
|
|
1559
|
-
elements: g.map((
|
|
1560
|
-
zones: l.map((
|
|
1572
|
+
elements: g.map((u) => u.node),
|
|
1573
|
+
zones: l.map((u) => u.node)
|
|
1561
1574
|
};
|
|
1562
1575
|
};
|
|
1563
1576
|
}
|
|
@@ -1567,12 +1580,12 @@ const Te = () => !0, ze = () => 0, fn = "separate", dn = () => {
|
|
|
1567
1580
|
export {
|
|
1568
1581
|
hn as DnDProvider,
|
|
1569
1582
|
vn as createSensor,
|
|
1570
|
-
|
|
1583
|
+
Me as defaultCollisionDetection,
|
|
1571
1584
|
Dn as makeAutoScroll,
|
|
1572
1585
|
pn as makeConstraintArea,
|
|
1573
1586
|
bn as makeDraggable,
|
|
1574
1587
|
Sn as makeDroppable,
|
|
1575
1588
|
yn as makeSelectionArea,
|
|
1576
1589
|
Mn as makeSnappedOverlayPosition,
|
|
1577
|
-
|
|
1590
|
+
je as useDnDProvider
|
|
1578
1591
|
};
|