@vue-dnd-kit/core 2.1.1 → 2.1.2
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/external/index.d.ts +0 -1
- package/dist/vue-dnd-kit-core.cjs.js +1 -1
- package/dist/vue-dnd-kit-core.es.js +348 -335
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
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 q, watch as ne, shallowRef as J, reactive as U, computed as b, onScopeDispose as qe, onMounted as
|
|
3
|
-
const
|
|
2
|
+
import { ref as q, watch as ne, shallowRef as J, reactive as U, computed as b, onScopeDispose as qe, onMounted as Y, onBeforeUnmount as Z, inject as Pe, defineComponent as Be, unref as V, openBlock as L, createElementBlock as W, normalizeStyle as Le, Fragment as me, renderList as We, createBlock as Q, resolveDynamicComponent as he, createCommentVNode as je, useTemplateRef as Je, provide as Qe, renderSlot as Ce, Teleport as et, createElementVNode as tt, mergeProps as nt } from "vue";
|
|
3
|
+
const P = {
|
|
4
4
|
SELECT_AREA: "data-dnd-kit-select-area",
|
|
5
5
|
DRAGGABLE: "data-dnd-kit-draggable",
|
|
6
6
|
DROPPABLE: "data-dnd-kit-droppable",
|
|
7
7
|
CONSTRAINT_AREA: "data-dnd-kit-constraint-area"
|
|
8
|
-
},
|
|
9
|
-
SELECT_AREA: `[${
|
|
10
|
-
DRAGGABLE: `[${
|
|
11
|
-
CONSTRAINT_AREA: `[${
|
|
12
|
-
}, Ae = "VueDnDKitProvider",
|
|
8
|
+
}, _ = {
|
|
9
|
+
SELECT_AREA: `[${P.SELECT_AREA}]`,
|
|
10
|
+
DRAGGABLE: `[${P.DRAGGABLE}]`,
|
|
11
|
+
CONSTRAINT_AREA: `[${P.CONSTRAINT_AREA}]`
|
|
12
|
+
}, Ae = "VueDnDKitProvider", Ie = (e, t, n, s) => {
|
|
13
13
|
const a = /* @__PURE__ */ new Set();
|
|
14
|
-
return t.forEach((
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
const g =
|
|
14
|
+
return t.forEach((o) => {
|
|
15
|
+
const i = e.get(o), r = s ? s(o) : i?.disabled;
|
|
16
|
+
if (!i || r) return;
|
|
17
|
+
const g = i.modifier?.keys, c = i.modifier?.method;
|
|
18
18
|
if (!g || !c || g.length === 0) {
|
|
19
|
-
a.add(
|
|
19
|
+
a.add(o);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
g[c]((l) => n.value.has(l)) && a.add(
|
|
22
|
+
g[c]((l) => n.value.has(l)) && a.add(o);
|
|
23
23
|
}), a;
|
|
24
24
|
};
|
|
25
25
|
let Oe = "", st = "", at = "";
|
|
26
|
-
const S = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null,
|
|
26
|
+
const S = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, F = (e, t) => e !== t && e.contains(t), it = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), be = () => {
|
|
27
27
|
const e = document.body;
|
|
28
28
|
Oe = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", D), window.addEventListener("selectstart", D), window.addEventListener("touchstart", D), window.addEventListener("touchmove", D);
|
|
29
29
|
}, ye = () => {
|
|
@@ -32,43 +32,43 @@ const S = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$e
|
|
|
32
32
|
}, D = (e) => e.preventDefault(), xe = (e, t) => {
|
|
33
33
|
if (t.entities.draggableMap.get(e)?.disabled) return !0;
|
|
34
34
|
for (const s of t.entities.visibleDraggableSet)
|
|
35
|
-
if (t.entities.draggableMap.get(s)?.disabled &&
|
|
35
|
+
if (t.entities.draggableMap.get(s)?.disabled && F(s, e)) return !0;
|
|
36
36
|
return !1;
|
|
37
|
-
},
|
|
37
|
+
}, H = (e, t) => {
|
|
38
38
|
if (t.entities.droppableMap.get(e)?.disabled) return !0;
|
|
39
39
|
for (const s of t.entities.visibleDroppableSet)
|
|
40
|
-
if (t.entities.droppableMap.get(s)?.disabled &&
|
|
40
|
+
if (t.entities.droppableMap.get(s)?.disabled && F(s, e)) return !0;
|
|
41
41
|
return !1;
|
|
42
42
|
}, se = (e, t) => {
|
|
43
43
|
if (!e.length || !t.length) return !0;
|
|
44
44
|
const n = new Set(t);
|
|
45
45
|
return e.some((s) => n.has(s));
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function ot(e, t, n, s) {
|
|
48
48
|
const a = [];
|
|
49
|
-
for (const
|
|
50
|
-
const r = n.get(
|
|
49
|
+
for (const i of t.keys()) {
|
|
50
|
+
const r = n.get(i);
|
|
51
51
|
a.push({ groups: r?.groups ?? [] });
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
for (const
|
|
55
|
-
const r = s.get(
|
|
56
|
-
(!a.length || a[c]((l) => se(l.groups, g))) &&
|
|
53
|
+
const o = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const i of e) {
|
|
55
|
+
const r = s.get(i), g = r?.groups ?? [], c = r?.groupMatch ?? "every";
|
|
56
|
+
(!a.length || a[c]((l) => se(l.groups, g))) && o.add(i);
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return o;
|
|
59
59
|
}
|
|
60
60
|
function rt(e, t, n) {
|
|
61
61
|
const s = /* @__PURE__ */ new Set();
|
|
62
|
-
for (const
|
|
63
|
-
const r = n.get(
|
|
62
|
+
for (const i of t.keys()) {
|
|
63
|
+
const r = n.get(i);
|
|
64
64
|
for (const g of r?.groups ?? []) s.add(g);
|
|
65
65
|
}
|
|
66
|
-
const a = [...s],
|
|
67
|
-
for (const
|
|
68
|
-
const g = n.get(
|
|
69
|
-
se(a, g) &&
|
|
66
|
+
const a = [...s], o = /* @__PURE__ */ new Set();
|
|
67
|
+
for (const i of e) {
|
|
68
|
+
const g = n.get(i)?.groups ?? [];
|
|
69
|
+
se(a, g) && o.add(i);
|
|
70
70
|
}
|
|
71
|
-
return
|
|
71
|
+
return o;
|
|
72
72
|
}
|
|
73
73
|
const re = (e) => {
|
|
74
74
|
const t = new IntersectionObserver((n) => {
|
|
@@ -86,8 +86,8 @@ const re = (e) => {
|
|
|
86
86
|
const t = new ResizeObserver((n) => {
|
|
87
87
|
const s = n[0];
|
|
88
88
|
if (!s) return;
|
|
89
|
-
const { width: a, height:
|
|
90
|
-
e.value = { width: a, height:
|
|
89
|
+
const { width: a, height: o } = s.contentRect;
|
|
90
|
+
e.value = { width: a, height: o };
|
|
91
91
|
});
|
|
92
92
|
return {
|
|
93
93
|
observe: (n) => t.observe(n),
|
|
@@ -97,8 +97,8 @@ const re = (e) => {
|
|
|
97
97
|
}, ct = (e) => {
|
|
98
98
|
const t = q(null), n = lt(t), s = ne(
|
|
99
99
|
e,
|
|
100
|
-
(
|
|
101
|
-
n.disconnect(),
|
|
100
|
+
(o) => {
|
|
101
|
+
n.disconnect(), o && n.observe(o);
|
|
102
102
|
},
|
|
103
103
|
{ immediate: !0 }
|
|
104
104
|
);
|
|
@@ -115,11 +115,11 @@ function pe(e, t = 0, n = 0) {
|
|
|
115
115
|
offset: { x: t, y: n }
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function ze(e, t) {
|
|
119
119
|
const n = t.getBoundingClientRect(), s = n.width > 0 ? (e.clientX - n.left) / n.width : 0.5, a = n.height > 0 ? (e.clientY - n.top) / n.height : 0.5;
|
|
120
120
|
return { x: s, y: a };
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function _e(e, t) {
|
|
123
123
|
return {
|
|
124
124
|
...t,
|
|
125
125
|
initialHTML: e.innerHTML,
|
|
@@ -130,13 +130,13 @@ function ze(e, t) {
|
|
|
130
130
|
function gt(e, t, n) {
|
|
131
131
|
e.forEach((s) => {
|
|
132
132
|
const a = t.get(s);
|
|
133
|
-
n.set(s,
|
|
133
|
+
n.set(s, _e(s, a));
|
|
134
134
|
}), e.clear();
|
|
135
135
|
}
|
|
136
136
|
function ut(e, t, n) {
|
|
137
137
|
n.clear();
|
|
138
138
|
const s = t.get(e);
|
|
139
|
-
n.set(e,
|
|
139
|
+
n.set(e, _e(e, s));
|
|
140
140
|
}
|
|
141
141
|
function ee(e) {
|
|
142
142
|
e.entities.initiatingDraggable && (e.state.value = "dragging", ft(
|
|
@@ -163,12 +163,12 @@ function dt(e, t) {
|
|
|
163
163
|
}
|
|
164
164
|
const {
|
|
165
165
|
x: a = 0,
|
|
166
|
-
y:
|
|
167
|
-
condition:
|
|
166
|
+
y: o = 0,
|
|
167
|
+
condition: i = "any"
|
|
168
168
|
} = t;
|
|
169
|
-
if (a === 0 &&
|
|
170
|
-
const r = a > 0 ? Math.min(n / a, 1) : 1, g =
|
|
171
|
-
return
|
|
169
|
+
if (a === 0 && o === 0) return 1;
|
|
170
|
+
const r = a > 0 ? Math.min(n / a, 1) : 1, g = o > 0 ? Math.min(s / o, 1) : 1;
|
|
171
|
+
return i === "both" ? Math.min(r, g) : Math.max(r, g);
|
|
172
172
|
}
|
|
173
173
|
function He(e, t, n) {
|
|
174
174
|
if (!n) return !0;
|
|
@@ -196,13 +196,13 @@ function ht(e, t) {
|
|
|
196
196
|
}
|
|
197
197
|
const a = e.entities.draggableMap.get(
|
|
198
198
|
e.entities.initiatingDraggable
|
|
199
|
-
),
|
|
200
|
-
if (!
|
|
199
|
+
), o = a?.activation?.delay;
|
|
200
|
+
if (!o) {
|
|
201
201
|
n = null;
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
e.delay.progress = Math.min(
|
|
205
|
-
(Date.now() - e.delay.startTime) / (
|
|
205
|
+
(Date.now() - e.delay.startTime) / (o * 1e3),
|
|
206
206
|
1
|
|
207
207
|
), He(
|
|
208
208
|
e.distanceProgress.value,
|
|
@@ -218,7 +218,7 @@ function ht(e, t) {
|
|
|
218
218
|
}
|
|
219
219
|
function bt(e, t) {
|
|
220
220
|
const n = e.closest(
|
|
221
|
-
|
|
221
|
+
_.CONSTRAINT_AREA
|
|
222
222
|
);
|
|
223
223
|
return !n || !t.has(n) ? null : {
|
|
224
224
|
element: n,
|
|
@@ -229,20 +229,20 @@ function yt(e, t, n, s) {
|
|
|
229
229
|
return n === "x" ? { x: e, y: s.top } : n === "y" ? { x: s.left, y: t } : { x: e, y: t };
|
|
230
230
|
}
|
|
231
231
|
function pt(e, t, n, s, a) {
|
|
232
|
-
let
|
|
233
|
-
return n !== "y" && (
|
|
232
|
+
let o = e, i = t;
|
|
233
|
+
return n !== "y" && (o = Math.max(
|
|
234
234
|
s.left,
|
|
235
235
|
Math.min(s.right - a.width, e)
|
|
236
|
-
)), n !== "x" && (
|
|
236
|
+
)), n !== "x" && (i = Math.max(
|
|
237
237
|
s.top,
|
|
238
238
|
Math.min(s.bottom - a.height, t)
|
|
239
|
-
)), { x:
|
|
239
|
+
)), { x: o, y: i };
|
|
240
240
|
}
|
|
241
241
|
function St(e, t, n, s, a) {
|
|
242
242
|
if (!e || !t)
|
|
243
243
|
return { x: 0, y: 0 };
|
|
244
|
-
const
|
|
245
|
-
let g = e.current.x -
|
|
244
|
+
const o = t.getBoundingClientRect(), i = o.width || a?.width || 0, r = o.height || a?.height || 0;
|
|
245
|
+
let g = e.current.x - i * e.offset.x, c = e.current.y - r * e.offset.y;
|
|
246
246
|
if (!n)
|
|
247
247
|
return { x: g, y: c };
|
|
248
248
|
const u = bt(n, s);
|
|
@@ -259,10 +259,10 @@ function St(e, t, n, s, a) {
|
|
|
259
259
|
h.y,
|
|
260
260
|
f.axis || "both",
|
|
261
261
|
d,
|
|
262
|
-
|
|
262
|
+
o
|
|
263
263
|
) : h;
|
|
264
264
|
}
|
|
265
|
-
const
|
|
265
|
+
const N = {
|
|
266
266
|
forDrag: ["Enter", "Space"],
|
|
267
267
|
forCancel: ["Escape"],
|
|
268
268
|
forDrop: ["Enter", "Space"],
|
|
@@ -279,18 +279,18 @@ const K = {
|
|
|
279
279
|
forMoveFaster: ["ShiftLeft", "ShiftRight"]
|
|
280
280
|
};
|
|
281
281
|
function Dt(e, t) {
|
|
282
|
-
const n = J(), s = q(),
|
|
282
|
+
const n = J(), s = q(), o = {
|
|
283
283
|
keys: {
|
|
284
284
|
pressedKeys: q(/* @__PURE__ */ new Set()),
|
|
285
|
-
forDrag: [...
|
|
286
|
-
forCancel: [...
|
|
287
|
-
forDrop: [...
|
|
288
|
-
forMove: [...
|
|
289
|
-
forMoveFaster: [...
|
|
285
|
+
forDrag: [...N.forDrag],
|
|
286
|
+
forCancel: [...N.forCancel],
|
|
287
|
+
forDrop: [...N.forDrop],
|
|
288
|
+
forMove: [...N.forMove],
|
|
289
|
+
forMoveFaster: [...N.forMoveFaster]
|
|
290
290
|
},
|
|
291
291
|
step: 8,
|
|
292
292
|
moveFaster: 4
|
|
293
|
-
},
|
|
293
|
+
}, i = U({
|
|
294
294
|
draggableMap: /* @__PURE__ */ new Map(),
|
|
295
295
|
droppableMap: /* @__PURE__ */ new Map(),
|
|
296
296
|
selectableAreaMap: /* @__PURE__ */ new Map(),
|
|
@@ -300,27 +300,27 @@ function Dt(e, t) {
|
|
|
300
300
|
draggingMap: /* @__PURE__ */ new Map(),
|
|
301
301
|
selectedSet: /* @__PURE__ */ new Set(),
|
|
302
302
|
selectionBase: /* @__PURE__ */ new Set(),
|
|
303
|
-
allowedDroppableSet: b(() => n.value ?
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
allowedDroppableSet: b(() => n.value ? ot(
|
|
304
|
+
i.visibleDroppableSet,
|
|
305
|
+
i.draggingMap,
|
|
306
|
+
i.draggableMap,
|
|
307
|
+
i.droppableMap
|
|
308
308
|
) : /* @__PURE__ */ new Set()),
|
|
309
309
|
allowedDraggableSet: b(() => n.value ? rt(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
310
|
+
i.visibleDraggableSet,
|
|
311
|
+
i.draggingMap,
|
|
312
|
+
i.draggableMap
|
|
313
313
|
) : /* @__PURE__ */ new Set()),
|
|
314
|
-
modifiersSelectableAreaSet: b(() =>
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
314
|
+
modifiersSelectableAreaSet: b(() => Ie(
|
|
315
|
+
i.selectableAreaMap,
|
|
316
|
+
i.visibleSelectableAreaSet,
|
|
317
|
+
o.keys.pressedKeys
|
|
318
318
|
)),
|
|
319
|
-
modifiersDraggableSet: b(() =>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
(
|
|
319
|
+
modifiersDraggableSet: b(() => Ie(
|
|
320
|
+
i.draggableMap,
|
|
321
|
+
i.visibleDraggableSet,
|
|
322
|
+
o.keys.pressedKeys,
|
|
323
|
+
(M) => xe(M, { entities: i })
|
|
324
324
|
)),
|
|
325
325
|
visibleDraggableSet: /* @__PURE__ */ new Set(),
|
|
326
326
|
visibleDroppableSet: /* @__PURE__ */ new Set(),
|
|
@@ -337,33 +337,34 @@ function Dt(e, t) {
|
|
|
337
337
|
progress: 0,
|
|
338
338
|
startTime: 0
|
|
339
339
|
}), l = b(() => {
|
|
340
|
-
if (!s.value || !
|
|
341
|
-
const
|
|
342
|
-
return
|
|
340
|
+
if (!s.value || !i.initiatingDraggable) return 0;
|
|
341
|
+
const M = i.draggableMap.get(i.initiatingDraggable)?.activation?.distance;
|
|
342
|
+
return M ? dt(s.value, M) : 1;
|
|
343
343
|
}), f = re(
|
|
344
|
-
|
|
344
|
+
i.visibleDraggableSet
|
|
345
345
|
), d = re(
|
|
346
|
-
|
|
346
|
+
i.visibleDroppableSet
|
|
347
347
|
), m = re(
|
|
348
|
-
|
|
348
|
+
i.visibleSelectableAreaSet
|
|
349
349
|
), { overlaySize: h, overlaySizeObserver: w } = ct(e), y = q(), R = b(() => {
|
|
350
|
-
|
|
350
|
+
c.x, c.y;
|
|
351
|
+
const p = i.initiatingDraggable;
|
|
351
352
|
return St(
|
|
352
353
|
s.value,
|
|
353
354
|
e.value,
|
|
354
355
|
p || null,
|
|
355
|
-
|
|
356
|
+
i.constraintsAreaMap,
|
|
356
357
|
h.value
|
|
357
358
|
);
|
|
358
359
|
}), x = b({
|
|
359
360
|
get: () => t?.overlayTo,
|
|
360
361
|
set: (p) => x.value = p
|
|
361
|
-
}),
|
|
362
|
+
}), X = b(() => t?.autoScrollViewport);
|
|
362
363
|
return {
|
|
363
364
|
state: n,
|
|
364
365
|
pointer: s,
|
|
365
|
-
entities:
|
|
366
|
-
keyboard:
|
|
366
|
+
entities: i,
|
|
367
|
+
keyboard: o,
|
|
367
368
|
scrollPosition: c,
|
|
368
369
|
delay: u,
|
|
369
370
|
distanceProgress: l,
|
|
@@ -383,7 +384,7 @@ function Dt(e, t) {
|
|
|
383
384
|
overlaySizeObserver: w,
|
|
384
385
|
rectCache: /* @__PURE__ */ new Map()
|
|
385
386
|
},
|
|
386
|
-
autoScrollViewport:
|
|
387
|
+
autoScrollViewport: X
|
|
387
388
|
};
|
|
388
389
|
}
|
|
389
390
|
const te = (e) => {
|
|
@@ -399,12 +400,12 @@ const te = (e) => {
|
|
|
399
400
|
}
|
|
400
401
|
e.lib.rectCache.clear(), e.pointer.value = void 0, e.state.value = void 0, e.entities.selectingArea = void 0, e.entities.selectionBase.clear(), e.entities.initiatingDraggable = void 0, e.delay.progress = 0, e.delay.startTime = 0, e.entities.draggingMap.clear(), e.hovered.draggable.clear(), e.hovered.droppable.clear();
|
|
401
402
|
};
|
|
402
|
-
function
|
|
403
|
-
return e.parentElement?.closest(
|
|
403
|
+
function Mt(e) {
|
|
404
|
+
return e.parentElement?.closest(_.SELECT_AREA) ?? null;
|
|
404
405
|
}
|
|
405
|
-
const
|
|
406
|
+
const vt = (e, t, n) => {
|
|
406
407
|
if (!n) return {};
|
|
407
|
-
const s = n.getBoundingClientRect(), a = Math.max(s.left, Math.min(e.x, t.x)),
|
|
408
|
+
const s = n.getBoundingClientRect(), a = Math.max(s.left, Math.min(e.x, t.x)), o = Math.max(s.top, Math.min(e.y, t.y)), i = Math.min(s.right, Math.max(e.x, t.x)), r = Math.min(s.bottom, Math.max(e.y, t.y)), g = Math.max(0, i - a), c = Math.max(0, r - o), u = a - s.left + n.scrollLeft, l = o - s.top + n.scrollTop;
|
|
408
409
|
return {
|
|
409
410
|
position: "absolute",
|
|
410
411
|
left: `${u}px`,
|
|
@@ -421,32 +422,32 @@ const Mt = (e, t, n) => {
|
|
|
421
422
|
e.pointer.value.start,
|
|
422
423
|
e.pointer.value.current
|
|
423
424
|
), s = e.entities.selectableAreaMap.get(t)?.groups ?? [], a = e.lib.rectCache;
|
|
424
|
-
e.entities.visibleDraggableSet.forEach((
|
|
425
|
-
if (
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
428
|
-
e.entities.selectedSet.delete(
|
|
425
|
+
e.entities.visibleDraggableSet.forEach((o) => {
|
|
426
|
+
if (o === t || !t.contains(o)) return;
|
|
427
|
+
const i = Mt(o);
|
|
428
|
+
if (i && i !== t) {
|
|
429
|
+
e.entities.selectedSet.delete(o);
|
|
429
430
|
return;
|
|
430
431
|
}
|
|
431
|
-
if (xe(
|
|
432
|
-
e.entities.selectedSet.delete(
|
|
432
|
+
if (xe(o, e)) {
|
|
433
|
+
e.entities.selectedSet.delete(o);
|
|
433
434
|
return;
|
|
434
435
|
}
|
|
435
|
-
const g = e.entities.draggableMap.get(
|
|
436
|
+
const g = e.entities.draggableMap.get(o)?.groups ?? [];
|
|
436
437
|
if (!se(s, g)) {
|
|
437
|
-
e.entities.selectedSet.delete(
|
|
438
|
+
e.entities.selectedSet.delete(o);
|
|
438
439
|
return;
|
|
439
440
|
}
|
|
440
|
-
let c = a.get(
|
|
441
|
-
c || (c =
|
|
442
|
-
const u = e.entities.selectionBase.has(
|
|
443
|
-
|
|
441
|
+
let c = a.get(o);
|
|
442
|
+
c || (c = o.getBoundingClientRect(), a.set(o, c));
|
|
443
|
+
const u = e.entities.selectionBase.has(o);
|
|
444
|
+
it(n, c) ? u ? e.entities.selectedSet.delete(o) : e.entities.selectedSet.add(o) : u ? e.entities.selectedSet.add(o) : e.entities.selectedSet.delete(o);
|
|
444
445
|
});
|
|
445
446
|
}, wt = (e, t) => {
|
|
446
|
-
const n = Math.min(e.x, t.x), s = Math.min(e.y, t.y), a = Math.max(e.x, t.x),
|
|
447
|
-
return new DOMRect(n, s,
|
|
447
|
+
const n = Math.min(e.x, t.x), s = Math.min(e.y, t.y), a = Math.max(e.x, t.x), o = Math.max(e.y, t.y), i = a - n, r = o - s;
|
|
448
|
+
return new DOMRect(n, s, i, r);
|
|
448
449
|
};
|
|
449
|
-
function
|
|
450
|
+
function C(e, t, n) {
|
|
450
451
|
const s = Math.max(0, Math.min(t, e.length));
|
|
451
452
|
return [...e.slice(0, s), ...n, ...e.slice(s)];
|
|
452
453
|
}
|
|
@@ -454,8 +455,8 @@ function Ee(e, t, n = 1) {
|
|
|
454
455
|
const s = Math.max(0, Math.min(t, e.length - 1)), a = Math.max(0, Math.min(n, e.length - s));
|
|
455
456
|
return [...e.slice(0, s), ...e.slice(s + a)];
|
|
456
457
|
}
|
|
457
|
-
function
|
|
458
|
-
const n = [...new Set(t)].filter((a) => a >= 0 && a < e.length).sort((a,
|
|
458
|
+
function G(e, t) {
|
|
459
|
+
const n = [...new Set(t)].filter((a) => a >= 0 && a < e.length).sort((a, o) => o - a);
|
|
459
460
|
let s = e;
|
|
460
461
|
for (const a of n) s = Ee(s, a, 1);
|
|
461
462
|
return s;
|
|
@@ -466,66 +467,66 @@ function Ke(e, t, n) {
|
|
|
466
467
|
const s = [...e];
|
|
467
468
|
return [s[t], s[n]] = [s[n], s[t]], s;
|
|
468
469
|
}
|
|
469
|
-
const
|
|
470
|
+
const I = {
|
|
470
471
|
getInsertSide(e, t) {
|
|
471
472
|
return e ? t === "vertical" ? e.top && !e.bottom ? "before" : e.bottom && !e.top ? "after" : e.top ? "before" : null : e.left && !e.right ? "before" : e.right && !e.left ? "after" : e.left ? "before" : null : null;
|
|
472
473
|
},
|
|
473
474
|
isAtZoneStart(e, t) {
|
|
474
|
-
return
|
|
475
|
+
return I.getInsertSide(e, t) === "before" && !e?.center;
|
|
475
476
|
},
|
|
476
477
|
isAtZoneEnd(e, t) {
|
|
477
|
-
return
|
|
478
|
+
return I.getInsertSide(e, t) === "after" && !e?.center;
|
|
478
479
|
}
|
|
479
480
|
};
|
|
480
481
|
function Ne(e, t) {
|
|
481
482
|
const { draggedItems: n, dropZone: s, hoveredDraggable: a } = e;
|
|
482
483
|
if (!n.length) return null;
|
|
483
|
-
const
|
|
484
|
-
if (!
|
|
485
|
-
const r = n[0].items, g = n.map((f) => f.index), c =
|
|
484
|
+
const o = a?.placement.center === !0 && s != null && s.items !== a.items, i = o ? s.items : a?.items ?? s?.items;
|
|
485
|
+
if (!i) return null;
|
|
486
|
+
const r = n[0].items, g = n.map((f) => f.index), c = i.length;
|
|
486
487
|
let u, l;
|
|
487
|
-
if (a && !
|
|
488
|
+
if (a && !o) {
|
|
488
489
|
const f = a.items === r && g.includes(a.index);
|
|
489
490
|
if (f && n.length === 1) {
|
|
490
|
-
const d =
|
|
491
|
+
const d = I.isAtZoneStart(s?.placement, t);
|
|
491
492
|
u = d ? 0 : c, l = d ? "prepend" : "append";
|
|
492
493
|
} else {
|
|
493
494
|
if (f)
|
|
494
495
|
return null;
|
|
495
496
|
{
|
|
496
|
-
const d =
|
|
497
|
+
const d = I.getInsertSide(a.placement, t), m = a.index;
|
|
497
498
|
d === "before" ? (u = Math.max(0, m), l = "insert") : d === "after" ? (u = Math.min(c, m + 1), l = "insert") : (u = c, l = "append");
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
} else {
|
|
501
502
|
if (!s) return null;
|
|
502
|
-
const f =
|
|
503
|
+
const f = I.isAtZoneStart(s.placement, t);
|
|
503
504
|
u = f ? 0 : c, l = f ? "prepend" : "append";
|
|
504
505
|
}
|
|
505
|
-
return { targetIndex: u, mode: l, targetArr:
|
|
506
|
+
return { targetIndex: u, mode: l, targetArr: i };
|
|
506
507
|
}
|
|
507
508
|
function At(e, t = "vertical") {
|
|
508
509
|
const { draggedItems: n } = e;
|
|
509
510
|
if (!n.length) return null;
|
|
510
511
|
const s = Ne(e, t);
|
|
511
512
|
if (!s) return null;
|
|
512
|
-
const { targetArr: a, mode:
|
|
513
|
-
let { targetIndex:
|
|
513
|
+
const { targetArr: a, mode: o } = s;
|
|
514
|
+
let { targetIndex: i } = s;
|
|
514
515
|
const r = n.map((l) => l.index), g = n.map((l) => l.item), c = n[0].items;
|
|
515
516
|
if (c === a) {
|
|
516
|
-
const l = r.filter((d) => d <
|
|
517
|
-
|
|
518
|
-
const f =
|
|
519
|
-
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex:
|
|
517
|
+
const l = r.filter((d) => d < i).length;
|
|
518
|
+
i = Math.max(0, i - l);
|
|
519
|
+
const f = C(G(c, r), i, g);
|
|
520
|
+
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: i, mode: o, sameList: !0 };
|
|
520
521
|
} else {
|
|
521
|
-
const l =
|
|
522
|
-
return { sourceItems: l, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex:
|
|
522
|
+
const l = G(c, r), f = C(a, i, g);
|
|
523
|
+
return { sourceItems: l, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: i, mode: o, sameList: !1 };
|
|
523
524
|
}
|
|
524
525
|
}
|
|
525
526
|
function xt(e) {
|
|
526
527
|
const { draggedItems: t, hoveredDraggable: n } = e;
|
|
527
528
|
if (!t.length || !n) return null;
|
|
528
|
-
const s = t.map((u) => u.index), a = n.index,
|
|
529
|
+
const s = t.map((u) => u.index), a = n.index, o = t.map((u) => u.item), i = n.item, r = t[0].items, g = n.items, c = r === g;
|
|
529
530
|
if (c && s.includes(a)) return null;
|
|
530
531
|
if (t.length === 1) {
|
|
531
532
|
const u = s[0];
|
|
@@ -540,16 +541,16 @@ function xt(e) {
|
|
|
540
541
|
const u = Math.min(...s);
|
|
541
542
|
if (c) {
|
|
542
543
|
const l = s.filter((y) => y < a).length, f = Math.max(0, a - l), d = s.filter((y) => y < u).length, m = Math.max(0, u - d);
|
|
543
|
-
let h =
|
|
544
|
-
h =
|
|
545
|
-
const w = m >= f ? m +
|
|
546
|
-
return h =
|
|
544
|
+
let h = G(r, s);
|
|
545
|
+
h = C(h, f, o);
|
|
546
|
+
const w = m >= f ? m + o.length : m;
|
|
547
|
+
return h = C(h, w, [i]), { sourceItems: h, targetItems: h, sourceIndexes: s, targetIndex: f, sameList: !0 };
|
|
547
548
|
} else {
|
|
548
549
|
const l = s.filter((h) => h < u).length, f = Math.max(0, u - l);
|
|
549
|
-
let d =
|
|
550
|
-
d =
|
|
550
|
+
let d = G(r, s);
|
|
551
|
+
d = C(d, f, [i]);
|
|
551
552
|
let m = Ee(g, a);
|
|
552
|
-
return m =
|
|
553
|
+
return m = C(m, a, o), { sourceItems: d, targetItems: m, sourceIndexes: s, targetIndex: a, sameList: !1 };
|
|
553
554
|
}
|
|
554
555
|
}
|
|
555
556
|
}
|
|
@@ -558,26 +559,26 @@ function Et(e, t = "vertical") {
|
|
|
558
559
|
if (!n.length) return null;
|
|
559
560
|
const s = Ne(e, t);
|
|
560
561
|
if (!s) return null;
|
|
561
|
-
const { targetArr: a, targetIndex:
|
|
562
|
-
return { targetItems:
|
|
562
|
+
const { targetArr: a, targetIndex: o, mode: i } = s, r = n.map((c) => c.item);
|
|
563
|
+
return { targetItems: C(a, o, r), copiedItems: r, targetIndex: o, mode: i };
|
|
563
564
|
}
|
|
564
565
|
function Lt(e) {
|
|
565
566
|
const { draggedItems: t } = e;
|
|
566
567
|
if (!t.length) return null;
|
|
567
|
-
const n = t.map((
|
|
568
|
-
return { sourceItems:
|
|
568
|
+
const n = t.map((i) => i.index), s = t.map((i) => i.item), a = t[0].items;
|
|
569
|
+
return { sourceItems: G(a, n), removedItems: s, sourceIndexes: n };
|
|
569
570
|
}
|
|
570
571
|
function Ve(e) {
|
|
571
572
|
return {
|
|
572
573
|
// Low-level array ops
|
|
573
|
-
insertAt:
|
|
574
|
+
insertAt: C,
|
|
574
575
|
removeAt: Ee,
|
|
575
|
-
removeIndexes:
|
|
576
|
+
removeIndexes: G,
|
|
576
577
|
swapAt: Ke,
|
|
577
578
|
// Placement helpers
|
|
578
|
-
getInsertSide: (t, n) =>
|
|
579
|
-
isAtZoneStart: (t, n) =>
|
|
580
|
-
isAtZoneEnd: (t, n) =>
|
|
579
|
+
getInsertSide: (t, n) => I.getInsertSide(t, n),
|
|
580
|
+
isAtZoneStart: (t, n) => I.isAtZoneStart(t, n),
|
|
581
|
+
isAtZoneEnd: (t, n) => I.isAtZoneEnd(t, n),
|
|
581
582
|
// High-level (event-bound)
|
|
582
583
|
suggestSort: (t) => At(e, t),
|
|
583
584
|
suggestSwap: () => xt(e),
|
|
@@ -585,10 +586,10 @@ function Ve(e) {
|
|
|
585
586
|
suggestRemove: () => Lt(e)
|
|
586
587
|
};
|
|
587
588
|
}
|
|
588
|
-
const
|
|
589
|
-
|
|
589
|
+
const k = (e) => e.keys().next().value, Ct = (e) => e.target.closest(
|
|
590
|
+
_.DRAGGABLE
|
|
590
591
|
);
|
|
591
|
-
function
|
|
592
|
+
function It(e) {
|
|
592
593
|
const t = e.entities.initiatingDraggable;
|
|
593
594
|
if (!t) return [];
|
|
594
595
|
const n = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t), s = n?.payload;
|
|
@@ -596,7 +597,7 @@ function Ct(e) {
|
|
|
596
597
|
return n?.data ? [{ index: -1, item: void 0, items: [], data: n.data() }] : [];
|
|
597
598
|
const a = s();
|
|
598
599
|
if (!Array.isArray(a) || a.length < 2) return [];
|
|
599
|
-
const [
|
|
600
|
+
const [o, i] = a, r = Number(o), g = i, c = /* @__PURE__ */ new Map();
|
|
600
601
|
return c.set(r, {
|
|
601
602
|
index: r,
|
|
602
603
|
item: g[r],
|
|
@@ -619,27 +620,27 @@ function Ct(e) {
|
|
|
619
620
|
}), [...c.values()].sort((u, l) => u.index - l.index);
|
|
620
621
|
}
|
|
621
622
|
const A = (e, t) => {
|
|
622
|
-
const n =
|
|
623
|
+
const n = It(e);
|
|
623
624
|
let s, a;
|
|
624
625
|
if (t) {
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
627
|
-
const g =
|
|
626
|
+
const o = e.entities.droppableMap.get(t);
|
|
627
|
+
if (o) {
|
|
628
|
+
const g = o.payload;
|
|
628
629
|
s = {
|
|
629
630
|
items: g ? g() : [],
|
|
630
631
|
placement: e.hovered.droppable.get(t),
|
|
631
|
-
data:
|
|
632
|
+
data: o.data?.()
|
|
632
633
|
};
|
|
633
634
|
}
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
636
|
-
const g = e.entities.draggableMap.get(
|
|
635
|
+
const i = k(e.hovered.draggable);
|
|
636
|
+
if (i && (i === t || t.contains(i)) && i) {
|
|
637
|
+
const g = e.entities.draggableMap.get(i), c = g?.payload, u = e.hovered.draggable.get(i), l = { top: !1, right: !1, bottom: !1, left: !1, center: !1 };
|
|
637
638
|
if (c) {
|
|
638
639
|
const f = c();
|
|
639
640
|
if (Array.isArray(f) && f.length >= 2) {
|
|
640
641
|
const [d, m] = f, h = Number(d);
|
|
641
642
|
a = {
|
|
642
|
-
element:
|
|
643
|
+
element: i,
|
|
643
644
|
placement: u ?? l,
|
|
644
645
|
index: h,
|
|
645
646
|
item: m[h],
|
|
@@ -648,7 +649,7 @@ const A = (e, t) => {
|
|
|
648
649
|
};
|
|
649
650
|
}
|
|
650
651
|
} else g?.data && (a = {
|
|
651
|
-
element:
|
|
652
|
+
element: i,
|
|
652
653
|
placement: u ?? l,
|
|
653
654
|
index: -1,
|
|
654
655
|
item: void 0,
|
|
@@ -664,22 +665,22 @@ const A = (e, t) => {
|
|
|
664
665
|
provider: e,
|
|
665
666
|
helpers: Ve({ draggedItems: n, dropZone: s, hoveredDraggable: a })
|
|
666
667
|
};
|
|
667
|
-
},
|
|
668
|
+
}, B = (e, t, n) => {
|
|
668
669
|
if (!t) return;
|
|
669
670
|
const s = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t);
|
|
670
671
|
!s || s.disabled || s.events?.[n]?.(A(e));
|
|
671
|
-
},
|
|
672
|
+
}, v = (e, t) => {
|
|
672
673
|
const n = A(e);
|
|
673
674
|
e.entities.draggingMap.forEach((s) => {
|
|
674
675
|
s.disabled || s.events?.[t]?.(n);
|
|
675
676
|
});
|
|
676
677
|
}, Rt = (e, t, n) => {
|
|
677
678
|
if (t !== n) {
|
|
678
|
-
if (t && !
|
|
679
|
+
if (t && !H(t, e)) {
|
|
679
680
|
const s = A(e, t);
|
|
680
681
|
e.entities.droppableMap.get(t)?.events?.onLeave?.(s);
|
|
681
682
|
}
|
|
682
|
-
if (n && !
|
|
683
|
+
if (n && !H(n, e)) {
|
|
683
684
|
const s = A(e, n);
|
|
684
685
|
e.entities.droppableMap.get(n)?.events?.onEnter?.(s);
|
|
685
686
|
}
|
|
@@ -697,14 +698,14 @@ const A = (e, t) => {
|
|
|
697
698
|
}
|
|
698
699
|
}
|
|
699
700
|
}, le = (e, t, n) => {
|
|
700
|
-
const s =
|
|
701
|
+
const s = Ct(t);
|
|
701
702
|
!s || !e.entities.draggingMap.has(s) || e.entities.draggingMap.get(s)?.events?.[n]?.(A(e));
|
|
702
703
|
}, kt = (e, t) => {
|
|
703
|
-
const n =
|
|
704
|
-
n && !
|
|
704
|
+
const n = k(t.droppable);
|
|
705
|
+
n && !H(n, e) && e.entities.droppableMap.get(n)?.events?.onLeave?.(A(e, n));
|
|
705
706
|
}, Se = (e, t) => {
|
|
706
|
-
const n =
|
|
707
|
-
n && !
|
|
707
|
+
const n = k(t.droppable);
|
|
708
|
+
n && !H(n, e) && e.entities.droppableMap.get(n)?.events?.onLeave?.(A(e, n));
|
|
708
709
|
}, Pt = (e, t, n = 5) => {
|
|
709
710
|
const s = n / 2;
|
|
710
711
|
return {
|
|
@@ -716,7 +717,7 @@ const A = (e, t) => {
|
|
|
716
717
|
}, Bt = (e) => {
|
|
717
718
|
const t = e.pointer.value?.current, n = t?.x ?? 0, s = t?.y ?? 0;
|
|
718
719
|
return Pt(n, s, 5);
|
|
719
|
-
},
|
|
720
|
+
}, T = (e, t, n) => {
|
|
720
721
|
const s = e.left + e.width / 2, a = e.top + e.height / 2;
|
|
721
722
|
if (n) {
|
|
722
723
|
const r = n.top ?? 0, g = n.right ?? 0, c = n.bottom ?? 0, u = n.left ?? 0, l = t.left + u, f = t.right - g, d = t.top + r, m = t.bottom - c;
|
|
@@ -729,12 +730,12 @@ const A = (e, t) => {
|
|
|
729
730
|
center: !0
|
|
730
731
|
};
|
|
731
732
|
}
|
|
732
|
-
const
|
|
733
|
+
const o = t.left + t.width / 2, i = t.top + t.height / 2;
|
|
733
734
|
return {
|
|
734
|
-
top: a <=
|
|
735
|
-
bottom: a >
|
|
736
|
-
left: s <=
|
|
737
|
-
right: s >
|
|
735
|
+
top: a <= i,
|
|
736
|
+
bottom: a > i,
|
|
737
|
+
left: s <= o,
|
|
738
|
+
right: s > o,
|
|
738
739
|
center: !1
|
|
739
740
|
};
|
|
740
741
|
}, Ot = (e) => ({
|
|
@@ -744,51 +745,60 @@ const A = (e, t) => {
|
|
|
744
745
|
const n = Ot(t);
|
|
745
746
|
return Math.hypot(e.x - n.x, e.y - n.y);
|
|
746
747
|
};
|
|
747
|
-
function
|
|
748
|
+
function zt(e, t) {
|
|
748
749
|
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;
|
|
749
750
|
}
|
|
750
751
|
function $(e, t) {
|
|
751
|
-
|
|
752
|
+
zt(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
752
753
|
}
|
|
753
|
-
const
|
|
754
|
-
const s =
|
|
754
|
+
const _t = (e, t) => e.find((n) => n !== t && F(t, n)), De = (e, t, n) => {
|
|
755
|
+
const s = k(t.droppable), a = k(t.draggable);
|
|
755
756
|
a && t.draggable.delete(a), s && t.droppable.delete(s);
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
const l =
|
|
757
|
+
const o = Bt(e), i = n.zones[0], r = n.elements[0];
|
|
758
|
+
if (i && r && i === r && e.entities.droppableMap.has(i) && i) {
|
|
759
|
+
const l = i.getBoundingClientRect(), f = e.entities.draggableMap.get(i)?.placementMargins, d = T(o, l, f);
|
|
759
760
|
if (d.center) {
|
|
760
|
-
t.droppable.set(
|
|
761
|
-
const m =
|
|
761
|
+
t.droppable.set(i, d);
|
|
762
|
+
const m = _t(n.elements, i);
|
|
762
763
|
if (m) {
|
|
763
764
|
const h = m.getBoundingClientRect();
|
|
764
765
|
t.draggable.set(
|
|
765
766
|
m,
|
|
766
|
-
|
|
767
|
+
T(o, h, void 0)
|
|
767
768
|
);
|
|
768
769
|
}
|
|
769
|
-
} else
|
|
770
|
+
} else {
|
|
770
771
|
t.draggable.set(r, d);
|
|
772
|
+
const m = n.zones.find((h) => h !== i);
|
|
773
|
+
if (m) {
|
|
774
|
+
const h = m.getBoundingClientRect();
|
|
775
|
+
t.droppable.set(
|
|
776
|
+
m,
|
|
777
|
+
T(o, h)
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
771
781
|
} else {
|
|
772
|
-
if (
|
|
773
|
-
const l =
|
|
774
|
-
t.droppable.set(
|
|
782
|
+
if (i) {
|
|
783
|
+
const l = i.getBoundingClientRect();
|
|
784
|
+
t.droppable.set(i, T(o, l));
|
|
775
785
|
}
|
|
776
786
|
if (r)
|
|
777
|
-
if (
|
|
778
|
-
if (
|
|
787
|
+
if (i)
|
|
788
|
+
if (F(i, r)) {
|
|
779
789
|
const l = r.getBoundingClientRect(), f = e.entities.draggableMap.get(r)?.placementMargins;
|
|
780
790
|
t.draggable.set(
|
|
781
791
|
r,
|
|
782
|
-
|
|
792
|
+
T(o, l, f)
|
|
783
793
|
);
|
|
784
794
|
} else {
|
|
785
|
-
const l = e.pointer.value?.current ?? { x: 0, y: 0 }, f =
|
|
795
|
+
const l = e.pointer.value?.current ?? { x: 0, y: 0 }, f = i.getBoundingClientRect(), d = r.getBoundingClientRect(), m = Re(l, f);
|
|
786
796
|
if (Re(l, d) < m) {
|
|
787
797
|
t.droppable.clear();
|
|
788
798
|
const w = e.entities.draggableMap.get(r)?.placementMargins;
|
|
789
799
|
t.draggable.set(
|
|
790
800
|
r,
|
|
791
|
-
|
|
801
|
+
T(o, d, w)
|
|
792
802
|
);
|
|
793
803
|
}
|
|
794
804
|
}
|
|
@@ -796,11 +806,11 @@ const zt = (e, t) => e.find((n) => n !== t && X(t, n)), De = (e, t, n) => {
|
|
|
796
806
|
const l = r.getBoundingClientRect(), f = e.entities.draggableMap.get(r)?.placementMargins;
|
|
797
807
|
t.draggable.set(
|
|
798
808
|
r,
|
|
799
|
-
|
|
809
|
+
T(o, l, f)
|
|
800
810
|
);
|
|
801
811
|
}
|
|
802
812
|
}
|
|
803
|
-
const c =
|
|
813
|
+
const c = k(t.droppable), u = k(t.draggable);
|
|
804
814
|
if (a && a !== u) {
|
|
805
815
|
const l = e.entities.draggableMap.get(a);
|
|
806
816
|
l && $(l, void 0);
|
|
@@ -839,31 +849,35 @@ const zt = (e, t) => e.find((n) => n !== t && X(t, n)), De = (e, t, n) => {
|
|
|
839
849
|
), s = Math.max(
|
|
840
850
|
0,
|
|
841
851
|
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
|
|
842
|
-
), a = n * s,
|
|
843
|
-
return
|
|
852
|
+
), a = n * s, o = e.width * e.height, i = t.width * t.height;
|
|
853
|
+
return o === 0 || i === 0 ? 0 : (a / o * 100 + a / i * 100) / 2;
|
|
844
854
|
}, Ft = (e) => e.overlay.ref?.value ?? null, Te = (e) => {
|
|
845
855
|
const t = e.overlay.position?.value ?? { x: 0, y: 0 }, { x: n, y: s } = t, a = e.overlay.size?.value;
|
|
846
|
-
let
|
|
856
|
+
let o, i;
|
|
847
857
|
if (a)
|
|
848
|
-
|
|
858
|
+
o = a.width, i = a.height;
|
|
849
859
|
else {
|
|
850
860
|
const r = e.overlay.ref?.value?.getBoundingClientRect();
|
|
851
|
-
|
|
861
|
+
o = r?.width ?? 0, i = r?.height ?? 0;
|
|
852
862
|
}
|
|
853
863
|
return {
|
|
854
864
|
x: n,
|
|
855
865
|
y: s,
|
|
856
|
-
width:
|
|
857
|
-
height:
|
|
866
|
+
width: o,
|
|
867
|
+
height: i,
|
|
858
868
|
top: s,
|
|
859
869
|
left: n,
|
|
860
|
-
right: n +
|
|
861
|
-
bottom: s +
|
|
870
|
+
right: n + o,
|
|
871
|
+
bottom: s + i
|
|
862
872
|
};
|
|
863
|
-
},
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
873
|
+
}, Me = (e) => e.entities.allowedDraggableSet, Ye = (e) => e.entities.allowedDroppableSet, Ht = (e, t) => !t.entities.draggingMap.has(e), Gt = (e, t) => ![...t.entities.draggingMap.keys()].some((n) => {
|
|
874
|
+
if (F(n, e)) return !0;
|
|
875
|
+
const s = n.parentElement;
|
|
876
|
+
return !!(s && e !== n && !t.entities.draggableMap.has(s) && !t.entities.droppableMap.has(s) && F(s, e) && [
|
|
877
|
+
...t.entities.draggableMap.keys()
|
|
878
|
+
].filter((o) => o.parentElement === s).length === 1);
|
|
879
|
+
}), Kt = (e, t) => t.entities.draggableMap.has(e) ? !xe(e, t) : t.entities.droppableMap.has(e) ? !H(e, t) : !0, j = (e, t) => Ht(e, t) && Gt(e, t) && Kt(e, t), fe = 10;
|
|
880
|
+
function z(e, t) {
|
|
867
881
|
return Math.hypot(
|
|
868
882
|
t.x - (e.x + e.width / 2),
|
|
869
883
|
t.y - (e.y + e.height / 2)
|
|
@@ -872,13 +886,13 @@ function _(e, t) {
|
|
|
872
886
|
function Nt(e) {
|
|
873
887
|
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, n = document.elementFromPoint(t.x, t.y);
|
|
874
888
|
if (!n) return null;
|
|
875
|
-
const s =
|
|
889
|
+
const s = Me(e), a = Ye(e), o = [], i = [];
|
|
876
890
|
let r = n;
|
|
877
891
|
for (; r; )
|
|
878
|
-
(s.has(r) || a.has(r)) && j(r, e) && (s.has(r) &&
|
|
879
|
-
return
|
|
892
|
+
(s.has(r) || a.has(r)) && j(r, e) && (s.has(r) && o.push(r), a.has(r) && i.push(r)), r = r.parentElement;
|
|
893
|
+
return o.length === 0 && i.length === 0 ? null : { elements: o, zones: i };
|
|
880
894
|
}
|
|
881
|
-
const
|
|
895
|
+
const ve = (e) => {
|
|
882
896
|
if (!Ft(e)) return { elements: [], zones: [] };
|
|
883
897
|
const n = e.pointer.value?.current ?? { x: 0, y: 0 }, s = Nt(e);
|
|
884
898
|
if (s) {
|
|
@@ -886,25 +900,25 @@ const Me = (e) => {
|
|
|
886
900
|
const c = s.zones[0];
|
|
887
901
|
if (!c) return s;
|
|
888
902
|
const u = Te(e);
|
|
889
|
-
return { elements: [...
|
|
903
|
+
return { elements: [...Me(e)].filter(
|
|
890
904
|
(d) => c.contains(d) && j(d, e)
|
|
891
905
|
).map((d) => ({ el: d, box: ge(d) })).filter(
|
|
892
906
|
({ box: d }) => ce(d, u) && ue(d, u) >= fe
|
|
893
|
-
).sort((d, m) =>
|
|
907
|
+
).sort((d, m) => z(d.box, n) - z(m.box, n)).map(({ el: d }) => d), zones: s.zones };
|
|
894
908
|
}
|
|
895
|
-
const a = Te(e),
|
|
909
|
+
const a = Te(e), o = [...Me(e)].filter(
|
|
896
910
|
(c) => j(c, e)
|
|
897
|
-
),
|
|
911
|
+
), i = [...Ye(e)].filter(
|
|
898
912
|
(c) => j(c, e)
|
|
899
|
-
), r =
|
|
913
|
+
), r = o.map((c) => ({ n: c, box: ge(c) })).filter(
|
|
900
914
|
({ box: c }) => ce(c, a) && ue(c, a) >= fe
|
|
901
|
-
).sort((c, u) =>
|
|
915
|
+
).sort((c, u) => z(c.box, n) - z(u.box, n)).map(({ n: c }) => c), g = i.map((c) => ({ n: c, box: ge(c) })).filter(
|
|
902
916
|
({ box: c }) => ce(c, a) && ue(c, a) >= fe
|
|
903
|
-
).sort((c, u) =>
|
|
917
|
+
).sort((c, u) => z(c.box, n) - z(u.box, n)).map(({ n: c }) => c);
|
|
904
918
|
return { elements: r, zones: g };
|
|
905
919
|
};
|
|
906
920
|
function we(e) {
|
|
907
|
-
const t =
|
|
921
|
+
const t = ve(e);
|
|
908
922
|
De(e, e.hovered, t);
|
|
909
923
|
}
|
|
910
924
|
function Vt(e, t) {
|
|
@@ -916,9 +930,9 @@ function Vt(e, t) {
|
|
|
916
930
|
const s = Date.now();
|
|
917
931
|
s - t.value >= n && (t.value = s, we(e));
|
|
918
932
|
}
|
|
919
|
-
async function
|
|
933
|
+
async function Ze(e) {
|
|
920
934
|
const t = e.hovered.droppable.keys().next().value;
|
|
921
|
-
if (!t ||
|
|
935
|
+
if (!t || H(t, e)) return "accept";
|
|
922
936
|
const n = e.entities.droppableMap.get(t), s = A(e, t);
|
|
923
937
|
let a = s;
|
|
924
938
|
if (n?.groupMatch === "some" && (n.groups?.length ?? 0) > 0) {
|
|
@@ -952,7 +966,7 @@ async function Xe(e) {
|
|
|
952
966
|
d = await l;
|
|
953
967
|
} catch {
|
|
954
968
|
const h = e.entities.initiatingDraggable;
|
|
955
|
-
return
|
|
969
|
+
return B(e, h, "onSelfDragCancel"), v(e, "onDragCancel"), Se(e, e.hovered), "cancel";
|
|
956
970
|
}
|
|
957
971
|
} else
|
|
958
972
|
d = l;
|
|
@@ -967,23 +981,23 @@ async function Xe(e) {
|
|
|
967
981
|
}
|
|
968
982
|
}
|
|
969
983
|
}
|
|
970
|
-
const
|
|
971
|
-
if (
|
|
984
|
+
const o = n?.events?.onDrop?.(a);
|
|
985
|
+
if (o != null && typeof o.then == "function") {
|
|
972
986
|
e.state.value = "pending";
|
|
973
987
|
let r;
|
|
974
988
|
try {
|
|
975
|
-
r = await
|
|
989
|
+
r = await o;
|
|
976
990
|
} catch {
|
|
977
991
|
const g = e.entities.initiatingDraggable;
|
|
978
|
-
return
|
|
992
|
+
return B(e, g, "onSelfDragCancel"), v(e, "onDragCancel"), Se(e, e.hovered), "cancel";
|
|
979
993
|
}
|
|
980
994
|
return r === !1 ? (e.state.value = "dragging", "decline") : "accept";
|
|
981
995
|
}
|
|
982
|
-
return
|
|
996
|
+
return o === !1 ? "decline" : "accept";
|
|
983
997
|
}
|
|
984
|
-
function
|
|
998
|
+
function Xe(e) {
|
|
985
999
|
const t = e.entities.initiatingDraggable;
|
|
986
|
-
|
|
1000
|
+
B(e, t, "onSelfDragEnd"), v(e, "onDragEnd"), kt(e, e.hovered);
|
|
987
1001
|
}
|
|
988
1002
|
function Yt(e) {
|
|
989
1003
|
const t = e.entities.selectingArea;
|
|
@@ -991,15 +1005,15 @@ function Yt(e) {
|
|
|
991
1005
|
const n = e.entities.selectableAreaMap.get(t), s = [...e.entities.selectedSet];
|
|
992
1006
|
n?.events?.onSelected?.(s);
|
|
993
1007
|
}
|
|
994
|
-
const
|
|
1008
|
+
const Zt = (e) => {
|
|
995
1009
|
const t = {
|
|
996
1010
|
current: null
|
|
997
1011
|
}, n = { value: 0 }, s = async () => {
|
|
998
1012
|
ye(), t.current?.cancel(), t.current = null;
|
|
999
1013
|
const r = e.state.value;
|
|
1000
1014
|
if (r === "dragging") {
|
|
1001
|
-
const g = await
|
|
1002
|
-
if (g === "accept" &&
|
|
1015
|
+
const g = await Ze(e);
|
|
1016
|
+
if (g === "accept" && Xe(e), g === "accept" || g === "cancel") {
|
|
1003
1017
|
te(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", a);
|
|
1004
1018
|
return;
|
|
1005
1019
|
}
|
|
@@ -1009,13 +1023,13 @@ const Xt = (e) => {
|
|
|
1009
1023
|
}, a = (r) => {
|
|
1010
1024
|
if (e.pointer.value && e.state.value !== "pending") {
|
|
1011
1025
|
if (e.pointer.value.current = { x: r.clientX, y: r.clientY }, mt(e)) {
|
|
1012
|
-
le(e, r, "onSelfDragStart"),
|
|
1026
|
+
le(e, r, "onSelfDragStart"), v(e, "onDragStart");
|
|
1013
1027
|
return;
|
|
1014
1028
|
}
|
|
1015
1029
|
if (e.state.value === "dragging") {
|
|
1016
1030
|
Vt(e, n);
|
|
1017
1031
|
const g = e.entities.initiatingDraggable;
|
|
1018
|
-
|
|
1032
|
+
B(e, g, "onSelfDragMove"), v(e, "onDragMove");
|
|
1019
1033
|
}
|
|
1020
1034
|
e.state.value === "selecting" && Ge(e);
|
|
1021
1035
|
}
|
|
@@ -1023,9 +1037,9 @@ const Xt = (e) => {
|
|
|
1023
1037
|
return { pointerDown: (r) => {
|
|
1024
1038
|
document.addEventListener("pointerup", s), document.addEventListener("pointermove", a);
|
|
1025
1039
|
const g = r.target, c = g.closest(
|
|
1026
|
-
|
|
1040
|
+
_.SELECT_AREA
|
|
1027
1041
|
), u = g.closest(
|
|
1028
|
-
|
|
1042
|
+
_.DRAGGABLE
|
|
1029
1043
|
);
|
|
1030
1044
|
if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(c)) {
|
|
1031
1045
|
be(), e.pointer.value = pe(r), e.state.value = "selecting", e.entities.selectingArea = c, e.entities.selectionBase = new Set(e.entities.selectedSet);
|
|
@@ -1036,15 +1050,15 @@ const Xt = (e) => {
|
|
|
1036
1050
|
if (!Fe(g, u, l?.dragHandle))
|
|
1037
1051
|
return;
|
|
1038
1052
|
be(), e.entities.initiatingDraggable = u;
|
|
1039
|
-
const f =
|
|
1053
|
+
const f = ze(r, u);
|
|
1040
1054
|
e.pointer.value = pe(r, f.x, f.y), l?.activation?.distance || l?.activation?.delay ? (e.state.value = "activating", l?.activation?.delay && (e.delay.startTime = Date.now(), t.current = ht(e, () => {
|
|
1041
|
-
ee(e), le(e, r, "onSelfDragStart"),
|
|
1042
|
-
}))) : (ee(e), le(e, r, "onSelfDragStart"),
|
|
1055
|
+
ee(e), le(e, r, "onSelfDragStart"), v(e, "onDragStart");
|
|
1056
|
+
}))) : (ee(e), le(e, r, "onSelfDragStart"), v(e, "onDragStart"));
|
|
1043
1057
|
}
|
|
1044
1058
|
}, pointerUp: s, pointerMove: a, cleanup: () => {
|
|
1045
1059
|
t.current?.cancel(), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", a), e.lib.draggableObserver.disconnect(), e.lib.droppableObserver.disconnect(), e.lib.selectableAreaObserver.disconnect(), e.lib.overlaySizeObserver.disconnect();
|
|
1046
1060
|
} };
|
|
1047
|
-
},
|
|
1061
|
+
}, Xt = {
|
|
1048
1062
|
ArrowUp: { dx: 0, dy: -1 },
|
|
1049
1063
|
ArrowDown: { dx: 0, dy: 1 },
|
|
1050
1064
|
ArrowLeft: { dx: -1, dy: 0 },
|
|
@@ -1055,35 +1069,35 @@ const Xt = (e) => {
|
|
|
1055
1069
|
KeyD: { dx: 1, dy: 0 }
|
|
1056
1070
|
}, Ut = (e) => (t) => {
|
|
1057
1071
|
const { keys: n } = e.keyboard;
|
|
1058
|
-
if (
|
|
1072
|
+
if (n.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1059
1073
|
if (n.forCancel.includes(t.code)) {
|
|
1060
|
-
t.preventDefault(), ye(),
|
|
1074
|
+
t.preventDefault(), ye(), B(
|
|
1061
1075
|
e,
|
|
1062
1076
|
e.entities.initiatingDraggable,
|
|
1063
1077
|
"onSelfDragCancel"
|
|
1064
|
-
),
|
|
1078
|
+
), v(e, "onDragCancel"), Se(e, e.hovered), te(e);
|
|
1065
1079
|
return;
|
|
1066
1080
|
}
|
|
1067
1081
|
if (n.forDrop.includes(t.code)) {
|
|
1068
|
-
t.preventDefault(), (async () => (await
|
|
1082
|
+
t.preventDefault(), (async () => (await Ze(e) && Xe(e), ye(), te(e)))();
|
|
1069
1083
|
return;
|
|
1070
1084
|
}
|
|
1071
|
-
const a =
|
|
1085
|
+
const a = Xt[t.code];
|
|
1072
1086
|
if (a && n.forMove.includes(t.code) && e.pointer.value) {
|
|
1073
1087
|
t.preventDefault();
|
|
1074
|
-
const
|
|
1088
|
+
const o = n.forMoveFaster.some(
|
|
1075
1089
|
(g) => n.pressedKeys.value.has(g)
|
|
1076
|
-
),
|
|
1090
|
+
), i = e.keyboard.step * (o ? e.keyboard.moveFaster : 1);
|
|
1077
1091
|
e.pointer.value.current = {
|
|
1078
|
-
x: e.pointer.value.current.x + a.dx *
|
|
1079
|
-
y: e.pointer.value.current.y + a.dy *
|
|
1092
|
+
x: e.pointer.value.current.x + a.dx * i,
|
|
1093
|
+
y: e.pointer.value.current.y + a.dy * i
|
|
1080
1094
|
};
|
|
1081
|
-
const r =
|
|
1082
|
-
De(e, e.hovered, r),
|
|
1095
|
+
const r = ve(e);
|
|
1096
|
+
De(e, e.hovered, r), B(
|
|
1083
1097
|
e,
|
|
1084
1098
|
e.entities.initiatingDraggable,
|
|
1085
1099
|
"onSelfDragMove"
|
|
1086
|
-
),
|
|
1100
|
+
), v(e, "onDragMove");
|
|
1087
1101
|
return;
|
|
1088
1102
|
}
|
|
1089
1103
|
return;
|
|
@@ -1091,28 +1105,28 @@ const Xt = (e) => {
|
|
|
1091
1105
|
if (n.forDrag.includes(t.code)) {
|
|
1092
1106
|
const a = document.activeElement;
|
|
1093
1107
|
if (!a) return;
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1108
|
+
const o = a.closest(
|
|
1109
|
+
_.DRAGGABLE
|
|
1096
1110
|
);
|
|
1097
|
-
if (!
|
|
1111
|
+
if (!o || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(o))
|
|
1098
1112
|
return;
|
|
1099
|
-
const
|
|
1100
|
-
if (!Fe(a,
|
|
1113
|
+
const i = e.entities.draggableMap.get(o);
|
|
1114
|
+
if (!Fe(a, o, i?.dragHandle, !0))
|
|
1101
1115
|
return;
|
|
1102
1116
|
t.preventDefault(), be();
|
|
1103
|
-
const r =
|
|
1117
|
+
const r = o.getBoundingClientRect(), g = r.left + r.width / 2, c = r.top + r.height / 2, u = {
|
|
1104
1118
|
clientX: g,
|
|
1105
1119
|
clientY: c
|
|
1106
1120
|
};
|
|
1107
|
-
e.entities.initiatingDraggable =
|
|
1108
|
-
const l =
|
|
1121
|
+
e.entities.initiatingDraggable = o;
|
|
1122
|
+
const l = ze(u, o);
|
|
1109
1123
|
e.pointer.value = pe(
|
|
1110
1124
|
u,
|
|
1111
1125
|
l.x,
|
|
1112
1126
|
l.y
|
|
1113
1127
|
), ee(e);
|
|
1114
|
-
const f =
|
|
1115
|
-
De(e, e.hovered, f),
|
|
1128
|
+
const f = ve(e);
|
|
1129
|
+
De(e, e.hovered, f), B(e, o, "onSelfDragStart"), v(e, "onDragStart");
|
|
1116
1130
|
}
|
|
1117
1131
|
}, $t = (e) => (t) => {
|
|
1118
1132
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
@@ -1164,28 +1178,28 @@ const Qt = {
|
|
|
1164
1178
|
}
|
|
1165
1179
|
};
|
|
1166
1180
|
function Ue(e, t, n, s = Qt, a) {
|
|
1167
|
-
const { speed:
|
|
1181
|
+
const { speed: o = 10, disabled: i = !1 } = t, r = Jt(t.threshold);
|
|
1168
1182
|
let g = null, c = null, u = null, l = 0, f = 0;
|
|
1169
1183
|
const d = (y) => {
|
|
1170
1184
|
a && (a.value = y);
|
|
1171
1185
|
}, m = (y) => {
|
|
1172
1186
|
const R = e.value, x = n();
|
|
1173
|
-
if (!R || !x ||
|
|
1187
|
+
if (!R || !x || i) {
|
|
1174
1188
|
d(!1);
|
|
1175
1189
|
return;
|
|
1176
1190
|
}
|
|
1177
1191
|
c || (c = y);
|
|
1178
|
-
const
|
|
1179
|
-
if (
|
|
1192
|
+
const X = y - c;
|
|
1193
|
+
if (X < ke) {
|
|
1180
1194
|
g = requestAnimationFrame(m);
|
|
1181
1195
|
return;
|
|
1182
1196
|
}
|
|
1183
|
-
const p =
|
|
1197
|
+
const p = o * (X / ke);
|
|
1184
1198
|
c = y;
|
|
1185
|
-
const { scrollTop:
|
|
1186
|
-
(!u || l !==
|
|
1187
|
-
let
|
|
1188
|
-
r.top > 0 && x.y - u.top < r.top ? (
|
|
1199
|
+
const { scrollTop: M, scrollLeft: K } = s.getScrollState(R);
|
|
1200
|
+
(!u || l !== M || f !== K) && (u = s.getRect ? s.getRect(R) : R.getBoundingClientRect(), l = M, f = K);
|
|
1201
|
+
let O = !1, ie = M, oe = K;
|
|
1202
|
+
r.top > 0 && x.y - u.top < r.top ? (ie = M - p, O = !0) : r.bottom > 0 && u.bottom - x.y < r.bottom && (ie = M + p, O = !0), r.left > 0 && x.x - u.left < r.left ? (oe = K - p, O = !0) : r.right > 0 && u.right - x.x < r.right && (oe = K + p, O = !0), O && s.setScroll(R, ie, oe), d(O), g = requestAnimationFrame(m);
|
|
1189
1203
|
};
|
|
1190
1204
|
return { run: () => {
|
|
1191
1205
|
c = null, g = requestAnimationFrame(m);
|
|
@@ -1225,32 +1239,32 @@ function nn(e, t) {
|
|
|
1225
1239
|
},
|
|
1226
1240
|
en,
|
|
1227
1241
|
n
|
|
1228
|
-
),
|
|
1242
|
+
), o = ne(
|
|
1229
1243
|
() => e.state.value,
|
|
1230
1244
|
(r) => {
|
|
1231
1245
|
r === "dragging" ? a.run() : a.stop();
|
|
1232
1246
|
}
|
|
1233
|
-
),
|
|
1234
|
-
|
|
1247
|
+
), i = () => {
|
|
1248
|
+
o(), a.stop();
|
|
1235
1249
|
};
|
|
1236
|
-
return qe(
|
|
1250
|
+
return qe(i), { isScrolling: n, stop: i };
|
|
1237
1251
|
}
|
|
1238
1252
|
const sn = (e) => {
|
|
1239
|
-
const t =
|
|
1240
|
-
let
|
|
1253
|
+
const t = Zt(e), n = de.keyDown(e), s = de.keyUp(e), a = de.clear(e), o = Wt(e);
|
|
1254
|
+
let i = null;
|
|
1241
1255
|
ne(
|
|
1242
1256
|
e.autoScrollViewport,
|
|
1243
1257
|
(r) => {
|
|
1244
|
-
|
|
1258
|
+
i?.(), i = null, (r === !0 || r && typeof r == "object") && (i = nn(
|
|
1245
1259
|
e,
|
|
1246
1260
|
r === !0 ? {} : r
|
|
1247
1261
|
).stop);
|
|
1248
1262
|
},
|
|
1249
1263
|
{ immediate: !0 }
|
|
1250
|
-
),
|
|
1251
|
-
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", n), document.addEventListener("keyup", s), document.addEventListener("blur", a), document.addEventListener("scroll",
|
|
1252
|
-
}),
|
|
1253
|
-
document.removeEventListener("pointerdown", t.pointerDown), document.removeEventListener("pointerup", t.pointerUp), document.removeEventListener("pointermove", t.pointerMove), document.removeEventListener("keydown", n), document.removeEventListener("keyup", s), document.removeEventListener("blur", a), document.removeEventListener("scroll",
|
|
1264
|
+
), Y(() => {
|
|
1265
|
+
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", n), document.addEventListener("keyup", s), document.addEventListener("blur", a), document.addEventListener("scroll", o, !0);
|
|
1266
|
+
}), Z(() => {
|
|
1267
|
+
document.removeEventListener("pointerdown", t.pointerDown), document.removeEventListener("pointerup", t.pointerUp), document.removeEventListener("pointermove", t.pointerMove), document.removeEventListener("keydown", n), document.removeEventListener("keyup", s), document.removeEventListener("blur", a), document.removeEventListener("scroll", o, !0), i?.(), t.cleanup();
|
|
1254
1268
|
});
|
|
1255
1269
|
}, ae = () => {
|
|
1256
1270
|
const e = Pe(Ae);
|
|
@@ -1275,16 +1289,16 @@ const sn = (e) => {
|
|
|
1275
1289
|
__name: "DefaultOverlay",
|
|
1276
1290
|
setup(e) {
|
|
1277
1291
|
const { entities: t, state: n, overlay: s } = $e();
|
|
1278
|
-
return (a,
|
|
1292
|
+
return (a, o) => V(n) === "dragging" ? (L(), W("div", {
|
|
1279
1293
|
key: 0,
|
|
1280
1294
|
class: "dnd-kit-default-overlay",
|
|
1281
1295
|
style: Le({
|
|
1282
|
-
"--position-x":
|
|
1283
|
-
"--position-y":
|
|
1296
|
+
"--position-x": V(s).position.value.x + "px",
|
|
1297
|
+
"--position-y": V(s).position.value.y + "px"
|
|
1284
1298
|
})
|
|
1285
1299
|
}, [
|
|
1286
|
-
(L(!0), W(me, null, We(
|
|
1287
|
-
r.render ? (L(), Q(he(r.render), { key: 0 })) : (L(), Q(he(
|
|
1300
|
+
(L(!0), W(me, null, We(V(t).draggingMap, ([i, r]) => (L(), W(me, null, [
|
|
1301
|
+
r.render ? (L(), Q(he(r.render), { key: 0 })) : (L(), Q(he(i.tagName), {
|
|
1288
1302
|
key: 1,
|
|
1289
1303
|
innerHTML: r.initialOuterHTML,
|
|
1290
1304
|
style: Le({
|
|
@@ -1309,17 +1323,17 @@ const sn = (e) => {
|
|
|
1309
1323
|
const a = b(
|
|
1310
1324
|
() => s.overlay.render.value ?? an
|
|
1311
1325
|
);
|
|
1312
|
-
return Qe(Ae, s), (
|
|
1313
|
-
|
|
1326
|
+
return Qe(Ae, s), (o, i) => (L(), W(me, null, [
|
|
1327
|
+
Ce(o.$slots, "default"),
|
|
1314
1328
|
(L(), Q(et, {
|
|
1315
|
-
to:
|
|
1329
|
+
to: V(s).overlay.to.value || "body"
|
|
1316
1330
|
}, [
|
|
1317
1331
|
tt("div", nt({
|
|
1318
1332
|
ref_key: "overlayRef",
|
|
1319
1333
|
ref: n,
|
|
1320
1334
|
class: "dnd-kit-overlay-container"
|
|
1321
1335
|
}, t), [
|
|
1322
|
-
|
|
1336
|
+
Ce(o.$slots, "overlay", { overlay: a.value }, () => [
|
|
1323
1337
|
(L(), Q(he(a.value)))
|
|
1324
1338
|
])
|
|
1325
1339
|
], 16)
|
|
@@ -1329,8 +1343,8 @@ const sn = (e) => {
|
|
|
1329
1343
|
});
|
|
1330
1344
|
function ln(e, t, n) {
|
|
1331
1345
|
const s = ae();
|
|
1332
|
-
let a,
|
|
1333
|
-
typeof t == "function" ? (a = {},
|
|
1346
|
+
let a, o, i;
|
|
1347
|
+
typeof t == "function" ? (a = {}, o = t) : (a = t ?? {}, o = n);
|
|
1334
1348
|
const r = b({
|
|
1335
1349
|
get() {
|
|
1336
1350
|
const l = S(e);
|
|
@@ -1351,22 +1365,22 @@ function ln(e, t, n) {
|
|
|
1351
1365
|
if (l)
|
|
1352
1366
|
return s.entities.draggableMap.get(l)?.hoveredPlacement;
|
|
1353
1367
|
});
|
|
1354
|
-
return
|
|
1355
|
-
|
|
1368
|
+
return Y(() => {
|
|
1369
|
+
i = S(e), i && (i.addEventListener("dragstart", D), i.addEventListener("drag", D), i.addEventListener("dragend", D), i.setAttribute(P.DRAGGABLE, ""), s.lib.draggableObserver.observe(i), s.entities.draggableMap.set(i, {
|
|
1356
1370
|
render: a.render,
|
|
1357
1371
|
disabled: a.disabled ?? !1,
|
|
1358
1372
|
groups: a.groups ?? [],
|
|
1359
1373
|
modifier: a.modifier,
|
|
1360
1374
|
events: a.events,
|
|
1361
|
-
payload:
|
|
1375
|
+
payload: o,
|
|
1362
1376
|
data: a.data,
|
|
1363
1377
|
dragHandle: a.dragHandle,
|
|
1364
1378
|
activation: a.activation,
|
|
1365
1379
|
placementMargins: a.placementMargins,
|
|
1366
1380
|
hoveredPlacement: void 0
|
|
1367
1381
|
}));
|
|
1368
|
-
}),
|
|
1369
|
-
|
|
1382
|
+
}), Z(() => {
|
|
1383
|
+
i && (s.lib.draggableObserver.unobserve(i), s.entities.visibleDraggableSet.delete(i), s.entities.draggableMap.delete(i), s.entities.modifiersDraggableSet.delete(i));
|
|
1370
1384
|
}), {
|
|
1371
1385
|
selected: r,
|
|
1372
1386
|
isDragging: g,
|
|
@@ -1377,8 +1391,8 @@ function ln(e, t, n) {
|
|
|
1377
1391
|
const cn = (e, t) => {
|
|
1378
1392
|
const n = ae(), s = b(() => e.value === n.entities.selectingArea);
|
|
1379
1393
|
let a = null;
|
|
1380
|
-
|
|
1381
|
-
a = S(e), a && (a.setAttribute(
|
|
1394
|
+
Y(() => {
|
|
1395
|
+
a = S(e), a && (a.setAttribute(P.SELECT_AREA, ""), n.lib.selectableAreaObserver.observe(a), n.entities.selectableAreaMap.set(a, {
|
|
1382
1396
|
modifier: t?.modifier ?? {
|
|
1383
1397
|
keys: ["ControlLeft"],
|
|
1384
1398
|
method: "every"
|
|
@@ -1387,36 +1401,36 @@ const cn = (e, t) => {
|
|
|
1387
1401
|
disabled: t?.disabled ?? !1,
|
|
1388
1402
|
groups: t?.groups ?? []
|
|
1389
1403
|
}));
|
|
1390
|
-
}),
|
|
1404
|
+
}), Z(() => {
|
|
1391
1405
|
a && (n.lib.selectableAreaObserver.unobserve(a), n.entities.visibleSelectableAreaSet.delete(a), n.entities.modifiersSelectableAreaSet.delete(a), n.entities.selectableAreaMap.delete(a));
|
|
1392
1406
|
});
|
|
1393
|
-
const
|
|
1407
|
+
const o = b(() => {
|
|
1394
1408
|
n.scrollPosition.x, n.scrollPosition.y;
|
|
1395
|
-
const
|
|
1396
|
-
return !
|
|
1409
|
+
const i = n.pointer.value;
|
|
1410
|
+
return !i || n.state.value !== "selecting" || !a || !s.value ? {} : vt(i.start, i.current, a);
|
|
1397
1411
|
});
|
|
1398
1412
|
return {
|
|
1399
1413
|
isSelecting: s,
|
|
1400
|
-
style:
|
|
1414
|
+
style: o
|
|
1401
1415
|
};
|
|
1402
1416
|
};
|
|
1403
1417
|
function gn(e, t) {
|
|
1404
1418
|
const n = Pe(Ae);
|
|
1405
1419
|
if (!n) throw Error("DnD provider not found");
|
|
1406
1420
|
let s = null;
|
|
1407
|
-
return
|
|
1408
|
-
s = S(e), s && (s.setAttribute(
|
|
1421
|
+
return Y(() => {
|
|
1422
|
+
s = S(e), s && (s.setAttribute(P.CONSTRAINT_AREA, ""), n.entities.constraintsAreaMap.set(s, {
|
|
1409
1423
|
axis: t?.axis || "both",
|
|
1410
1424
|
restrictToArea: t?.restrictToArea || !1
|
|
1411
1425
|
}));
|
|
1412
|
-
}),
|
|
1426
|
+
}), Z(() => {
|
|
1413
1427
|
s && n.entities.constraintsAreaMap.delete(s);
|
|
1414
1428
|
}), {};
|
|
1415
1429
|
}
|
|
1416
1430
|
function un(e, t, n) {
|
|
1417
1431
|
const s = ae();
|
|
1418
|
-
let a = null,
|
|
1419
|
-
typeof t == "function" ? (
|
|
1432
|
+
let a = null, o, i;
|
|
1433
|
+
typeof t == "function" ? (o = {}, i = t) : (o = t ?? {}, i = n);
|
|
1420
1434
|
const r = b(() => {
|
|
1421
1435
|
const c = S(e);
|
|
1422
1436
|
return c ? s.entities.allowedDroppableSet.has(c) : !1;
|
|
@@ -1425,17 +1439,17 @@ function un(e, t, n) {
|
|
|
1425
1439
|
if (c)
|
|
1426
1440
|
return s.entities.droppableMap.get(c)?.hoveredPlacement;
|
|
1427
1441
|
});
|
|
1428
|
-
return
|
|
1429
|
-
a = S(e), a && (a.setAttribute(
|
|
1430
|
-
disabled:
|
|
1431
|
-
groups:
|
|
1432
|
-
groupMatch:
|
|
1433
|
-
events:
|
|
1434
|
-
payload:
|
|
1435
|
-
data:
|
|
1442
|
+
return Y(() => {
|
|
1443
|
+
a = S(e), a && (a.setAttribute(P.DROPPABLE, ""), s.lib.droppableObserver.observe(a), s.entities.droppableMap.set(a, {
|
|
1444
|
+
disabled: o.disabled ?? !1,
|
|
1445
|
+
groups: o.groups ?? [],
|
|
1446
|
+
groupMatch: o.groupMatch ?? "every",
|
|
1447
|
+
events: o.events,
|
|
1448
|
+
payload: i,
|
|
1449
|
+
data: o.data,
|
|
1436
1450
|
hoveredPlacement: void 0
|
|
1437
1451
|
}));
|
|
1438
|
-
}),
|
|
1452
|
+
}), Z(() => {
|
|
1439
1453
|
a && (s.lib.droppableObserver.unobserve(a), s.entities.visibleDroppableSet.delete(a), s.entities.droppableMap.delete(a));
|
|
1440
1454
|
}), {
|
|
1441
1455
|
isAllowed: r,
|
|
@@ -1443,30 +1457,29 @@ function un(e, t, n) {
|
|
|
1443
1457
|
};
|
|
1444
1458
|
}
|
|
1445
1459
|
const fn = (e, t) => {
|
|
1446
|
-
const n = $e(), s = J(!1),
|
|
1460
|
+
const n = $e(), s = J(!1), o = Ue(
|
|
1447
1461
|
e,
|
|
1448
1462
|
t ?? {},
|
|
1449
1463
|
() => {
|
|
1450
1464
|
if (n.state.value !== "dragging") return null;
|
|
1451
|
-
const
|
|
1452
|
-
return
|
|
1453
|
-
x:
|
|
1454
|
-
y:
|
|
1455
|
-
} :
|
|
1465
|
+
const i = n.overlay.position.value, r = n.overlay.size.value;
|
|
1466
|
+
return i ? r?.width && r?.height ? {
|
|
1467
|
+
x: i.x + r.width / 2,
|
|
1468
|
+
y: i.y + r.height / 2
|
|
1469
|
+
} : i : null;
|
|
1456
1470
|
},
|
|
1457
1471
|
void 0,
|
|
1458
1472
|
s
|
|
1459
1473
|
);
|
|
1460
1474
|
return ne(
|
|
1461
1475
|
() => n.state.value,
|
|
1462
|
-
(
|
|
1463
|
-
|
|
1476
|
+
(i) => {
|
|
1477
|
+
i === "dragging" ? o.run() : o.stop();
|
|
1464
1478
|
}
|
|
1465
1479
|
), { isScrolling: s };
|
|
1466
1480
|
};
|
|
1467
1481
|
export {
|
|
1468
1482
|
rn as DnDProvider,
|
|
1469
|
-
Me as defaultCollisionDetection,
|
|
1470
1483
|
fn as makeAutoScroll,
|
|
1471
1484
|
gn as makeConstraintArea,
|
|
1472
1485
|
ln as makeDraggable,
|