@vue-dnd-kit/core 2.0.6 → 2.0.7
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,15 +1,15 @@
|
|
|
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
|
|
2
|
+
import { ref as j, watch as ae, shallowRef as ee, reactive as q, computed as y, onScopeDispose as We, onMounted as U, onBeforeUnmount as V, inject as Oe, defineComponent as Be, unref as k, openBlock as C, createElementBlock as J, normalizeStyle as Ae, Fragment as fe, renderList as je, createBlock as te, resolveDynamicComponent as de, createCommentVNode as Je, useTemplateRef as Qe, provide as et, renderSlot as Ee, Teleport as tt, createElementVNode as nt, mergeProps as st } from "vue";
|
|
3
3
|
const T = {
|
|
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
|
-
},
|
|
8
|
+
}, _ = {
|
|
9
9
|
SELECT_AREA: `[${T.SELECT_AREA}]`,
|
|
10
10
|
DRAGGABLE: `[${T.DRAGGABLE}]`,
|
|
11
11
|
CONSTRAINT_AREA: `[${T.CONSTRAINT_AREA}]`
|
|
12
|
-
},
|
|
12
|
+
}, Me = "VueDnDKitProvider", Le = (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,24 +22,24 @@ 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,
|
|
25
|
+
let Fe = "", ot = "", at = "";
|
|
26
|
+
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, K = (e, t) => e !== t && e.contains(t), rt = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), me = () => {
|
|
27
27
|
const e = document.body;
|
|
28
|
-
|
|
29
|
-
},
|
|
28
|
+
Fe = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", M), window.addEventListener("selectstart", M), window.addEventListener("touchstart", M), window.addEventListener("touchmove", M);
|
|
29
|
+
}, he = () => {
|
|
30
30
|
const e = document.body;
|
|
31
|
-
e.style.userSelect =
|
|
32
|
-
}, M = (e) => e.preventDefault(),
|
|
31
|
+
e.style.userSelect = Fe, e.style.touchAction = ot, e.style.overscrollBehavior = at, window.removeEventListener("contextmenu", M), window.removeEventListener("selectstart", M), window.removeEventListener("touchstart", M), window.removeEventListener("touchmove", M);
|
|
32
|
+
}, M = (e) => e.preventDefault(), ve = (e, t) => {
|
|
33
33
|
if (t.entities.draggableMap.get(e)?.disabled) return !0;
|
|
34
34
|
for (const n of t.entities.visibleDraggableSet)
|
|
35
|
-
if (t.entities.draggableMap.get(n)?.disabled &&
|
|
35
|
+
if (t.entities.draggableMap.get(n)?.disabled && K(n, e)) return !0;
|
|
36
36
|
return !1;
|
|
37
|
-
},
|
|
37
|
+
}, G = (e, t) => {
|
|
38
38
|
if (t.entities.droppableMap.get(e)?.disabled) return !0;
|
|
39
39
|
for (const n of t.entities.visibleDroppableSet)
|
|
40
|
-
if (t.entities.droppableMap.get(n)?.disabled &&
|
|
40
|
+
if (t.entities.droppableMap.get(n)?.disabled && K(n, e)) return !0;
|
|
41
41
|
return !1;
|
|
42
|
-
},
|
|
42
|
+
}, we = (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));
|
|
@@ -53,7 +53,7 @@ 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
|
+
we(r, l) && a.add(i);
|
|
57
57
|
}
|
|
58
58
|
return a;
|
|
59
59
|
}
|
|
@@ -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
|
+
we(o, g) && r.add(a);
|
|
70
70
|
}
|
|
71
71
|
return r;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const ce = (e) => {
|
|
74
74
|
const t = new IntersectionObserver((s) => {
|
|
75
75
|
s.forEach((n) => {
|
|
76
76
|
const o = n.target;
|
|
@@ -95,7 +95,7 @@ const le = (e) => {
|
|
|
95
95
|
disconnect: () => t.disconnect()
|
|
96
96
|
};
|
|
97
97
|
}, gt = (e) => {
|
|
98
|
-
const t =
|
|
98
|
+
const t = j(null), s = ct(t), n = ae(
|
|
99
99
|
e,
|
|
100
100
|
(r) => {
|
|
101
101
|
s.disconnect(), r && s.observe(r);
|
|
@@ -108,18 +108,18 @@ const le = (e) => {
|
|
|
108
108
|
}
|
|
109
109
|
} };
|
|
110
110
|
};
|
|
111
|
-
function
|
|
111
|
+
function be(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 _e(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 Ge(e, t) {
|
|
123
123
|
return {
|
|
124
124
|
...t,
|
|
125
125
|
initialHTML: e.innerHTML,
|
|
@@ -130,15 +130,15 @@ function _e(e, t) {
|
|
|
130
130
|
function ut(e, t, s) {
|
|
131
131
|
e.forEach((n) => {
|
|
132
132
|
const o = t.get(n);
|
|
133
|
-
s.set(n,
|
|
133
|
+
s.set(n, Ge(n, o));
|
|
134
134
|
}), e.clear();
|
|
135
135
|
}
|
|
136
136
|
function ft(e, t, s) {
|
|
137
137
|
s.clear();
|
|
138
138
|
const n = t.get(e);
|
|
139
|
-
s.set(e,
|
|
139
|
+
s.set(e, Ge(e, n));
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function ne(e) {
|
|
142
142
|
e.entities.initiatingDraggable && (e.state.value = "dragging", dt(
|
|
143
143
|
e.entities.initiatingDraggable,
|
|
144
144
|
e.entities.selectedSet,
|
|
@@ -149,7 +149,7 @@ function ee(e) {
|
|
|
149
149
|
function dt(e, t, s, n) {
|
|
150
150
|
t.has(e) ? ut(t, s, n) : (t.clear(), ft(e, s, n));
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function He(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;
|
|
@@ -170,7 +170,7 @@ 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 Ke(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;
|
|
@@ -181,11 +181,11 @@ function ht(e) {
|
|
|
181
181
|
const t = e.entities.draggableMap.get(
|
|
182
182
|
e.entities.initiatingDraggable
|
|
183
183
|
);
|
|
184
|
-
return
|
|
184
|
+
return Ke(
|
|
185
185
|
e.distanceProgress.value,
|
|
186
186
|
e.delay.progress,
|
|
187
187
|
t?.activation
|
|
188
|
-
) ? (
|
|
188
|
+
) ? (ne(e), !0) : !1;
|
|
189
189
|
}
|
|
190
190
|
function bt(e, t) {
|
|
191
191
|
let s = null;
|
|
@@ -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
|
+
), Ke(
|
|
208
208
|
e.distanceProgress.value,
|
|
209
209
|
e.delay.progress,
|
|
210
210
|
o?.activation
|
|
@@ -218,7 +218,7 @@ function bt(e, t) {
|
|
|
218
218
|
}
|
|
219
219
|
function yt(e, t) {
|
|
220
220
|
const s = e.closest(
|
|
221
|
-
|
|
221
|
+
_.CONSTRAINT_AREA
|
|
222
222
|
);
|
|
223
223
|
return !s || !t.has(s) ? null : {
|
|
224
224
|
element: s,
|
|
@@ -245,19 +245,19 @@ function Dt(e, t, s, n, o) {
|
|
|
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 f = yt(s, n);
|
|
249
|
+
if (!f)
|
|
250
250
|
return { x: g, y: l };
|
|
251
|
-
const { element: c, entity:
|
|
251
|
+
const { element: c, entity: u } = f, d = c.getBoundingClientRect(), m = s.getBoundingClientRect(), h = pt(
|
|
252
252
|
g,
|
|
253
253
|
l,
|
|
254
|
-
|
|
254
|
+
u.axis || "both",
|
|
255
255
|
m
|
|
256
256
|
);
|
|
257
|
-
return
|
|
257
|
+
return u.restrictToArea ? St(
|
|
258
258
|
h.x,
|
|
259
259
|
h.y,
|
|
260
|
-
|
|
260
|
+
u.axis || "both",
|
|
261
261
|
d,
|
|
262
262
|
r
|
|
263
263
|
) : h;
|
|
@@ -279,9 +279,9 @@ const N = {
|
|
|
279
279
|
forMoveFaster: ["ShiftLeft", "ShiftRight"]
|
|
280
280
|
};
|
|
281
281
|
function Mt(e, t) {
|
|
282
|
-
const s =
|
|
282
|
+
const s = ee(), n = j(), r = {
|
|
283
283
|
keys: {
|
|
284
|
-
pressedKeys:
|
|
284
|
+
pressedKeys: j(/* @__PURE__ */ new Set()),
|
|
285
285
|
forDrag: [...N.forDrag],
|
|
286
286
|
forCancel: [...N.forCancel],
|
|
287
287
|
forDrop: [...N.forDrop],
|
|
@@ -290,7 +290,7 @@ function Mt(e, t) {
|
|
|
290
290
|
},
|
|
291
291
|
step: 8,
|
|
292
292
|
moveFaster: 4
|
|
293
|
-
}, a =
|
|
293
|
+
}, a = q({
|
|
294
294
|
draggableMap: /* @__PURE__ */ new Map(),
|
|
295
295
|
droppableMap: /* @__PURE__ */ new Map(),
|
|
296
296
|
selectableAreaMap: /* @__PURE__ */ new Map(),
|
|
@@ -310,42 +310,42 @@ function Mt(e, t) {
|
|
|
310
310
|
a.draggingMap,
|
|
311
311
|
a.draggableMap
|
|
312
312
|
) : /* @__PURE__ */ new Set()),
|
|
313
|
-
modifiersSelectableAreaSet: y(() =>
|
|
313
|
+
modifiersSelectableAreaSet: y(() => Le(
|
|
314
314
|
a.selectableAreaMap,
|
|
315
315
|
a.visibleSelectableAreaSet,
|
|
316
316
|
r.keys.pressedKeys
|
|
317
317
|
)),
|
|
318
|
-
modifiersDraggableSet: y(() =>
|
|
318
|
+
modifiersDraggableSet: y(() => Le(
|
|
319
319
|
a.draggableMap,
|
|
320
320
|
a.visibleDraggableSet,
|
|
321
321
|
r.keys.pressedKeys,
|
|
322
|
-
(w) =>
|
|
322
|
+
(w) => ve(w, { entities: a })
|
|
323
323
|
)),
|
|
324
324
|
visibleDraggableSet: /* @__PURE__ */ new Set(),
|
|
325
325
|
visibleDroppableSet: /* @__PURE__ */ new Set(),
|
|
326
326
|
visibleSelectableAreaSet: /* @__PURE__ */ new Set()
|
|
327
|
-
}), i =
|
|
327
|
+
}), i = q({
|
|
328
328
|
draggable: /* @__PURE__ */ new Map(),
|
|
329
329
|
droppable: /* @__PURE__ */ new Map()
|
|
330
330
|
}), g = {
|
|
331
|
-
throttle:
|
|
332
|
-
}, l =
|
|
331
|
+
throttle: ee(0)
|
|
332
|
+
}, l = q({
|
|
333
333
|
x: window.scrollX,
|
|
334
334
|
y: window.scrollY
|
|
335
|
-
}),
|
|
335
|
+
}), f = 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
341
|
return w ? mt(n.value, w) : 1;
|
|
342
|
-
}),
|
|
342
|
+
}), u = ce(
|
|
343
343
|
a.visibleDraggableSet
|
|
344
|
-
), d =
|
|
344
|
+
), d = ce(
|
|
345
345
|
a.visibleDroppableSet
|
|
346
|
-
), m =
|
|
346
|
+
), m = ce(
|
|
347
347
|
a.visibleSelectableAreaSet
|
|
348
|
-
), { overlaySize: h, overlaySizeObserver: S } = gt(e), b =
|
|
348
|
+
), { overlaySize: h, overlaySizeObserver: S } = gt(e), b = j(), v = y(() => {
|
|
349
349
|
const p = a.initiatingDraggable;
|
|
350
350
|
return Dt(
|
|
351
351
|
n.value,
|
|
@@ -357,14 +357,14 @@ function Mt(e, t) {
|
|
|
357
357
|
}), E = y({
|
|
358
358
|
get: () => t?.overlayTo,
|
|
359
359
|
set: (p) => E.value = p
|
|
360
|
-
}),
|
|
360
|
+
}), $ = y(() => t?.autoScrollViewport);
|
|
361
361
|
return {
|
|
362
362
|
state: s,
|
|
363
363
|
pointer: n,
|
|
364
364
|
entities: a,
|
|
365
365
|
keyboard: r,
|
|
366
366
|
scrollPosition: l,
|
|
367
|
-
delay:
|
|
367
|
+
delay: f,
|
|
368
368
|
distanceProgress: c,
|
|
369
369
|
hovered: i,
|
|
370
370
|
collision: g,
|
|
@@ -376,16 +376,16 @@ function Mt(e, t) {
|
|
|
376
376
|
to: E
|
|
377
377
|
},
|
|
378
378
|
lib: {
|
|
379
|
-
draggableObserver:
|
|
379
|
+
draggableObserver: u,
|
|
380
380
|
droppableObserver: d,
|
|
381
381
|
selectableAreaObserver: m,
|
|
382
382
|
overlaySizeObserver: S,
|
|
383
383
|
rectCache: /* @__PURE__ */ new Map()
|
|
384
384
|
},
|
|
385
|
-
autoScrollViewport:
|
|
385
|
+
autoScrollViewport: $
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
|
-
const
|
|
388
|
+
const se = (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 xe(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
|
-
function
|
|
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 = xe(n, o, 1);
|
|
413
413
|
return n;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function Ze(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];
|
|
@@ -434,27 +434,27 @@ function Ne(e, t) {
|
|
|
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((u) => u.index), l = a.length;
|
|
438
|
+
let f, c;
|
|
439
439
|
if (o && !r) {
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
440
|
+
const u = o.items === i && g.includes(o.index);
|
|
441
|
+
if (u && s.length === 1) {
|
|
442
442
|
const d = R.isAtZoneStart(n?.placement, t);
|
|
443
|
-
|
|
443
|
+
f = d ? 0 : l, c = d ? "prepend" : "append";
|
|
444
444
|
} else {
|
|
445
|
-
if (
|
|
445
|
+
if (u)
|
|
446
446
|
return null;
|
|
447
447
|
{
|
|
448
448
|
const d = R.getInsertSide(o.placement, t), m = o.index;
|
|
449
|
-
d === "before" ? (
|
|
449
|
+
d === "before" ? (f = Math.max(0, m), c = "insert") : d === "after" ? (f = Math.min(l, m + 1), c = "insert") : (f = l, c = "append");
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
} else {
|
|
453
453
|
if (!n) return null;
|
|
454
|
-
const
|
|
455
|
-
|
|
454
|
+
const u = R.isAtZoneStart(n.placement, t);
|
|
455
|
+
f = u ? 0 : l, c = u ? "prepend" : "append";
|
|
456
456
|
}
|
|
457
|
-
return { targetIndex:
|
|
457
|
+
return { targetIndex: f, mode: c, targetArr: a };
|
|
458
458
|
}
|
|
459
459
|
function vt(e, t = "vertical") {
|
|
460
460
|
const { draggedItems: s } = e;
|
|
@@ -467,40 +467,40 @@ 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 u = I(H(l, i), a, g);
|
|
471
|
+
return { sourceItems: u, targetItems: u, draggedItems: g, sourceIndexes: i, targetIndex: a, mode: r, sameList: !0 };
|
|
472
472
|
} else {
|
|
473
|
-
const c =
|
|
474
|
-
return { sourceItems: c, targetItems:
|
|
473
|
+
const c = H(l, i), u = I(o, a, g);
|
|
474
|
+
return { sourceItems: c, targetItems: u, draggedItems: g, sourceIndexes: i, targetIndex: a, mode: r, sameList: !1 };
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
function wt(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((f) => f.index), o = s.index, r = t.map((f) => f.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 f = n[0];
|
|
484
484
|
if (l) {
|
|
485
|
-
const c =
|
|
485
|
+
const c = Ze(i, f, 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], u = [...g];
|
|
489
|
+
return c[f] = g[o], u[o] = i[f], { sourceItems: c, targetItems: u, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
490
490
|
}
|
|
491
491
|
} else {
|
|
492
|
-
const
|
|
492
|
+
const f = Math.min(...n);
|
|
493
493
|
if (l) {
|
|
494
|
-
const c = n.filter((b) => b < o).length,
|
|
495
|
-
let h =
|
|
496
|
-
h = I(h,
|
|
497
|
-
const S = m >=
|
|
498
|
-
return h = I(h, S, [a]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex:
|
|
494
|
+
const c = n.filter((b) => b < o).length, u = Math.max(0, o - c), d = n.filter((b) => b < f).length, m = Math.max(0, f - d);
|
|
495
|
+
let h = H(i, n);
|
|
496
|
+
h = I(h, u, r);
|
|
497
|
+
const S = m >= u ? m + r.length : m;
|
|
498
|
+
return h = I(h, S, [a]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex: u, sameList: !0 };
|
|
499
499
|
} else {
|
|
500
|
-
const c = n.filter((h) => h <
|
|
501
|
-
let d =
|
|
502
|
-
d = I(d,
|
|
503
|
-
let m =
|
|
500
|
+
const c = n.filter((h) => h < f).length, u = Math.max(0, f - c);
|
|
501
|
+
let d = H(i, n);
|
|
502
|
+
d = I(d, u, [a]);
|
|
503
|
+
let m = xe(g, o);
|
|
504
504
|
return m = I(m, o, r), { sourceItems: d, targetItems: m, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
505
505
|
}
|
|
506
506
|
}
|
|
@@ -517,15 +517,15 @@ function At(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
|
-
return { sourceItems:
|
|
520
|
+
return { sourceItems: H(o, s), removedItems: n, sourceIndexes: s };
|
|
521
521
|
}
|
|
522
522
|
function Et(e) {
|
|
523
523
|
return {
|
|
524
524
|
// Low-level array ops
|
|
525
525
|
insertAt: I,
|
|
526
|
-
removeAt:
|
|
527
|
-
removeIndexes:
|
|
528
|
-
swapAt:
|
|
526
|
+
removeAt: xe,
|
|
527
|
+
removeIndexes: H,
|
|
528
|
+
swapAt: Ze,
|
|
529
529
|
// Placement helpers
|
|
530
530
|
getInsertSide: (t, s) => R.getInsertSide(t, s),
|
|
531
531
|
isAtZoneStart: (t, s) => R.isAtZoneStart(t, s),
|
|
@@ -538,7 +538,7 @@ function Et(e) {
|
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
540
|
const P = (e) => e.keys().next().value, Lt = (e) => e.target.closest(
|
|
541
|
-
|
|
541
|
+
_.DRAGGABLE
|
|
542
542
|
);
|
|
543
543
|
function Ct(e) {
|
|
544
544
|
const t = e.entities.initiatingDraggable;
|
|
@@ -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((f, c) => {
|
|
558
|
+
const u = e.entities.draggableMap.get(c), d = u?.payload;
|
|
559
559
|
if (!d) return;
|
|
560
560
|
const m = d();
|
|
561
561
|
if (!Array.isArray(m) || m.length < 2) return;
|
|
@@ -566,9 +566,9 @@ function Ct(e) {
|
|
|
566
566
|
index: b,
|
|
567
567
|
item: S[b],
|
|
568
568
|
items: g,
|
|
569
|
-
data:
|
|
569
|
+
data: u?.data?.()
|
|
570
570
|
});
|
|
571
|
-
}), [...l.values()].sort((
|
|
571
|
+
}), [...l.values()].sort((f, c) => f.index - c.index);
|
|
572
572
|
}
|
|
573
573
|
const A = (e, t) => {
|
|
574
574
|
const s = Ct(e);
|
|
@@ -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, f = 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 u = l();
|
|
591
|
+
if (Array.isArray(u) && u.length >= 2) {
|
|
592
|
+
const [d, m] = u, h = Number(d);
|
|
593
593
|
o = {
|
|
594
594
|
element: a,
|
|
595
|
-
placement:
|
|
595
|
+
placement: f ?? 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: f ?? c,
|
|
605
605
|
index: -1,
|
|
606
606
|
item: void 0,
|
|
607
607
|
items: [],
|
|
@@ -616,7 +616,7 @@ const A = (e, t) => {
|
|
|
616
616
|
provider: e,
|
|
617
617
|
helpers: Et({ draggedItems: s, dropZone: n, hoveredDraggable: o })
|
|
618
618
|
};
|
|
619
|
-
},
|
|
619
|
+
}, F = (e, t, s) => {
|
|
620
620
|
if (!t) return;
|
|
621
621
|
const n = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t);
|
|
622
622
|
!n || n.disabled || n.events?.[s]?.(A(e));
|
|
@@ -627,11 +627,11 @@ const A = (e, t) => {
|
|
|
627
627
|
});
|
|
628
628
|
}, It = (e, t, s) => {
|
|
629
629
|
if (t !== s) {
|
|
630
|
-
if (t && !
|
|
630
|
+
if (t && !G(t, e)) {
|
|
631
631
|
const n = A(e, t);
|
|
632
632
|
e.entities.droppableMap.get(t)?.events?.onLeave?.(n);
|
|
633
633
|
}
|
|
634
|
-
if (s && !
|
|
634
|
+
if (s && !G(s, e)) {
|
|
635
635
|
const n = A(e, s);
|
|
636
636
|
e.entities.droppableMap.get(s)?.events?.onEnter?.(n);
|
|
637
637
|
}
|
|
@@ -648,18 +648,18 @@ const A = (e, t) => {
|
|
|
648
648
|
o && !o.disabled && o.events?.onHover?.(n);
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
},
|
|
651
|
+
}, ge = (e, t, s) => {
|
|
652
652
|
const n = Lt(t);
|
|
653
653
|
!n || !e.entities.draggingMap.has(n) || e.entities.draggingMap.get(n)?.events?.[s]?.(A(e));
|
|
654
654
|
}, kt = (e, t) => {
|
|
655
655
|
const s = P(t.droppable);
|
|
656
|
-
s && !
|
|
657
|
-
},
|
|
656
|
+
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
657
|
+
}, Ye = (e, t) => {
|
|
658
658
|
const s = P(t.droppable);
|
|
659
|
-
s && !
|
|
659
|
+
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
660
660
|
};
|
|
661
661
|
function Pt(e) {
|
|
662
|
-
return e.parentElement?.closest(
|
|
662
|
+
return e.parentElement?.closest(_.SELECT_AREA) ?? null;
|
|
663
663
|
}
|
|
664
664
|
const Tt = (e, t, s) => {
|
|
665
665
|
if (!s) return {};
|
|
@@ -674,9 +674,9 @@ const Tt = (e, t, s) => {
|
|
|
674
674
|
border: "1px solid #3b82f6",
|
|
675
675
|
backgroundColor: "#3b82f61a"
|
|
676
676
|
};
|
|
677
|
-
},
|
|
677
|
+
}, zt = (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 = Ot(
|
|
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;
|
|
@@ -687,19 +687,19 @@ const Tt = (e, t, s) => {
|
|
|
687
687
|
e.entities.selectedSet.delete(r);
|
|
688
688
|
return;
|
|
689
689
|
}
|
|
690
|
-
if (
|
|
690
|
+
if (ve(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 (!we(n, g)) {
|
|
696
696
|
e.entities.selectedSet.delete(r);
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
699
|
let l = o.get(r);
|
|
700
700
|
l || (l = r.getBoundingClientRect(), o.set(r, l)), rt(s, l) ? e.entities.selectedSet.add(r) : e.entities.selectedSet.delete(r);
|
|
701
701
|
});
|
|
702
|
-
},
|
|
702
|
+
}, Ot = (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
|
}, Bt = (e, t, s = 5) => {
|
|
@@ -713,11 +713,11 @@ const Tt = (e, t, s) => {
|
|
|
713
713
|
}, Ft = (e) => {
|
|
714
714
|
const t = e.pointer.value?.current, s = t?.x ?? 0, n = t?.y ?? 0;
|
|
715
715
|
return Bt(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, f = s.left ?? 0, c = t.left + f, u = t.right - g, d = t.top + i, m = t.bottom - l;
|
|
720
|
+
if (c < u && d < m && n >= c && n <= u && o >= d && o <= m)
|
|
721
721
|
return {
|
|
722
722
|
top: !1,
|
|
723
723
|
right: !1,
|
|
@@ -737,22 +737,22 @@ const Tt = (e, t, s) => {
|
|
|
737
737
|
}, _t = (e) => ({
|
|
738
738
|
x: e.left + e.width / 2,
|
|
739
739
|
y: e.top + e.height / 2
|
|
740
|
-
}),
|
|
740
|
+
}), Ce = (e, t) => {
|
|
741
741
|
const s = _t(t);
|
|
742
742
|
return Math.hypot(e.x - s.x, e.y - s.y);
|
|
743
743
|
};
|
|
744
744
|
function Gt(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
|
-
function
|
|
747
|
+
function W(e, t) {
|
|
748
748
|
Gt(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
749
749
|
}
|
|
750
|
-
const Ht = (e, t) => e.find((s) => s !== t &&
|
|
750
|
+
const Ht = (e, t) => e.find((s) => s !== t && K(t, s)), oe = (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
753
|
const r = Ft(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(), u = e.entities.draggableMap.get(a)?.placementMargins, d = O(r, c, u);
|
|
756
756
|
if (d.center) {
|
|
757
757
|
t.droppable.set(a, d);
|
|
758
758
|
const m = Ht(s.elements, a);
|
|
@@ -760,7 +760,7 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
760
760
|
const h = m.getBoundingClientRect();
|
|
761
761
|
t.draggable.set(
|
|
762
762
|
m,
|
|
763
|
-
|
|
763
|
+
O(r, h, void 0)
|
|
764
764
|
);
|
|
765
765
|
}
|
|
766
766
|
} else
|
|
@@ -768,54 +768,54 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
768
768
|
} else {
|
|
769
769
|
if (a) {
|
|
770
770
|
const c = a.getBoundingClientRect();
|
|
771
|
-
t.droppable.set(a,
|
|
771
|
+
t.droppable.set(a, O(r, c));
|
|
772
772
|
}
|
|
773
773
|
if (i)
|
|
774
774
|
if (a)
|
|
775
|
-
if (
|
|
776
|
-
const c = i.getBoundingClientRect(),
|
|
775
|
+
if (K(a, i)) {
|
|
776
|
+
const c = i.getBoundingClientRect(), u = e.entities.draggableMap.get(i)?.placementMargins;
|
|
777
777
|
t.draggable.set(
|
|
778
778
|
i,
|
|
779
|
-
|
|
779
|
+
O(r, c, u)
|
|
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 }, u = a.getBoundingClientRect(), d = i.getBoundingClientRect(), m = Ce(c, u);
|
|
783
|
+
if (Ce(c, d) < m) {
|
|
784
784
|
t.droppable.clear();
|
|
785
785
|
const S = e.entities.draggableMap.get(i)?.placementMargins;
|
|
786
786
|
t.draggable.set(
|
|
787
787
|
i,
|
|
788
|
-
|
|
788
|
+
O(r, d, S)
|
|
789
789
|
);
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
792
|
else {
|
|
793
|
-
const c = i.getBoundingClientRect(),
|
|
793
|
+
const c = i.getBoundingClientRect(), u = e.entities.draggableMap.get(i)?.placementMargins;
|
|
794
794
|
t.draggable.set(
|
|
795
795
|
i,
|
|
796
|
-
|
|
796
|
+
O(r, c, u)
|
|
797
797
|
);
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
const l = P(t.droppable),
|
|
801
|
-
if (o && o !==
|
|
800
|
+
const l = P(t.droppable), f = P(t.draggable);
|
|
801
|
+
if (o && o !== f) {
|
|
802
802
|
const c = e.entities.draggableMap.get(o);
|
|
803
|
-
c &&
|
|
803
|
+
c && W(c, void 0);
|
|
804
804
|
}
|
|
805
805
|
if (n && n !== l) {
|
|
806
806
|
const c = e.entities.droppableMap.get(n);
|
|
807
|
-
c &&
|
|
807
|
+
c && W(c, void 0);
|
|
808
808
|
}
|
|
809
|
-
if (
|
|
810
|
-
const c = e.entities.draggableMap.get(
|
|
811
|
-
c &&
|
|
809
|
+
if (f) {
|
|
810
|
+
const c = e.entities.draggableMap.get(f);
|
|
811
|
+
c && W(c, t.draggable.get(f));
|
|
812
812
|
}
|
|
813
813
|
if (l) {
|
|
814
814
|
const c = e.entities.droppableMap.get(l);
|
|
815
|
-
c &&
|
|
815
|
+
c && W(c, t.droppable.get(l));
|
|
816
816
|
}
|
|
817
|
-
It(e, n, l), Rt(e, o,
|
|
818
|
-
},
|
|
817
|
+
It(e, n, l), Rt(e, o, f);
|
|
818
|
+
}, Ie = (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();
|
|
@@ -829,10 +829,10 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
829
829
|
right: t.right,
|
|
830
830
|
bottom: t.bottom
|
|
831
831
|
};
|
|
832
|
-
},
|
|
832
|
+
}, Y = (e) => ({
|
|
833
833
|
x: e.x + e.width / 2,
|
|
834
834
|
y: e.y + e.height / 2
|
|
835
|
-
}), Kt = (e, t) => Math.hypot(t.x - e.x, t.y - e.y),
|
|
835
|
+
}), Kt = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), ye = (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 && H(t, s)), ne = (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
|
+
}, Zt = (e, t, s) => t >= e.x && t <= e.x + e.width && s >= e.y && s <= e.y + e.height, Nt = (e) => e.overlay.ref?.value ?? null, Yt = (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,59 +860,66 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
860
860
|
right: s + r,
|
|
861
861
|
bottom: n + a
|
|
862
862
|
};
|
|
863
|
-
},
|
|
864
|
-
(s) =>
|
|
865
|
-
), Vt = (e, t) => t.entities.draggableMap.has(e) ? !
|
|
866
|
-
function
|
|
863
|
+
}, pe = (e) => e.entities.allowedDraggableSet, Xe = (e) => e.entities.allowedDroppableSet, Xt = (e, t) => !t.entities.draggingMap.has(e), Ut = (e, t) => ![...t.entities.draggingMap.keys()].some(
|
|
864
|
+
(s) => K(s, e)
|
|
865
|
+
), Vt = (e, t) => t.entities.draggableMap.has(e) ? !ve(e, t) : t.entities.droppableMap.has(e) ? !G(e, t) : !0, Q = (e, t) => Xt(e, t) && Ut(e, t) && Vt(e, t), Re = 10;
|
|
866
|
+
function B(e, t) {
|
|
867
867
|
return Math.hypot(
|
|
868
868
|
t.x - (e.x + e.width / 2),
|
|
869
869
|
t.y - (e.y + e.height / 2)
|
|
870
870
|
);
|
|
871
871
|
}
|
|
872
872
|
function $t(e) {
|
|
873
|
-
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, s = document.
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
873
|
+
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, s = document.elementFromPoint(t.x, t.y);
|
|
874
|
+
if (!s) return null;
|
|
875
|
+
const n = pe(e), o = Xe(e), r = [], a = [];
|
|
876
|
+
let i = s;
|
|
877
|
+
for (; i; )
|
|
878
|
+
(n.has(i) || o.has(i)) && Q(i, e) && (n.has(i) && r.push(i), o.has(i) && a.push(i)), i = i.parentElement;
|
|
878
879
|
return r.length === 0 && a.length === 0 ? null : { elements: r, zones: a };
|
|
879
880
|
}
|
|
880
|
-
const
|
|
881
|
-
if (!
|
|
882
|
-
const s = $t(e);
|
|
883
|
-
if (
|
|
884
|
-
|
|
885
|
-
|
|
881
|
+
const Se = (e) => {
|
|
882
|
+
if (!Nt(e)) return { elements: [], zones: [] };
|
|
883
|
+
const s = e.pointer.value?.current ?? { x: 0, y: 0 }, n = $t(e);
|
|
884
|
+
if (n) {
|
|
885
|
+
if (n.elements.length > 0) return n;
|
|
886
|
+
const l = n.zones[0];
|
|
887
|
+
return l ? { elements: [...pe(e)].filter(
|
|
888
|
+
(u) => l.contains(u) && Q(u, e)
|
|
889
|
+
).map((u) => ({ el: u, box: X(u) })).sort((u, d) => B(u.box, s) - B(d.box, s)).map(({ el: u }) => u), zones: n.zones } : n;
|
|
890
|
+
}
|
|
891
|
+
const o = Yt(e), r = [...pe(e)].filter(
|
|
892
|
+
(l) => Q(l, e)
|
|
886
893
|
), a = [...Xe(e)].filter(
|
|
887
|
-
(l) =>
|
|
888
|
-
), i = r.map((l) => ({ n: l, box:
|
|
889
|
-
({ box: l }) =>
|
|
890
|
-
).sort((l,
|
|
891
|
-
({ box: l }) =>
|
|
892
|
-
).sort((l,
|
|
894
|
+
(l) => Q(l, e)
|
|
895
|
+
), i = r.map((l) => ({ n: l, box: X(l) })).filter(
|
|
896
|
+
({ box: l }) => Ie(l, o) && ye(l, o) >= Re
|
|
897
|
+
).sort((l, f) => B(l.box, s) - B(f.box, s)).map(({ n: l }) => l), g = a.map((l) => ({ n: l, box: X(l) })).filter(
|
|
898
|
+
({ box: l }) => Ie(l, o) && ye(l, o) >= Re
|
|
899
|
+
).sort((l, f) => B(l.box, s) - B(f.box, s)).map(({ n: l }) => l);
|
|
893
900
|
return { elements: i, zones: g };
|
|
894
901
|
};
|
|
895
|
-
function
|
|
902
|
+
function De(e) {
|
|
896
903
|
if (e.collision?.run) {
|
|
897
904
|
const s = e.collision.run(e);
|
|
898
|
-
|
|
905
|
+
oe(e, e.hovered, s);
|
|
899
906
|
return;
|
|
900
907
|
}
|
|
901
|
-
const t =
|
|
902
|
-
|
|
908
|
+
const t = Se(e);
|
|
909
|
+
oe(e, e.hovered, t);
|
|
903
910
|
}
|
|
904
911
|
function qt(e, t) {
|
|
905
912
|
const s = e.collision?.throttle?.value ?? 0;
|
|
906
913
|
if (s <= 0) {
|
|
907
|
-
|
|
914
|
+
De(e);
|
|
908
915
|
return;
|
|
909
916
|
}
|
|
910
917
|
const n = Date.now();
|
|
911
|
-
n - t.value >= s && (t.value = n,
|
|
918
|
+
n - t.value >= s && (t.value = n, De(e));
|
|
912
919
|
}
|
|
913
920
|
async function Ue(e) {
|
|
914
921
|
const t = e.hovered.droppable.keys().next().value;
|
|
915
|
-
if (!t ||
|
|
922
|
+
if (!t || G(t, e)) return "accept";
|
|
916
923
|
const s = e.entities.droppableMap.get(t), n = A(e, t), o = s?.events?.onDrop?.(n);
|
|
917
924
|
if (o != null && typeof o.then == "function") {
|
|
918
925
|
e.state.value = "pending";
|
|
@@ -921,7 +928,7 @@ async function Ue(e) {
|
|
|
921
928
|
a = await o;
|
|
922
929
|
} catch {
|
|
923
930
|
const i = e.entities.initiatingDraggable;
|
|
924
|
-
return
|
|
931
|
+
return F(e, i, "onSelfDragCancel"), x(e, "onDragCancel"), Ye(e, e.hovered), "cancel";
|
|
925
932
|
}
|
|
926
933
|
return a === !1 ? (e.state.value = "dragging", "decline") : "accept";
|
|
927
934
|
}
|
|
@@ -929,7 +936,7 @@ async function Ue(e) {
|
|
|
929
936
|
}
|
|
930
937
|
function Ve(e) {
|
|
931
938
|
const t = e.entities.initiatingDraggable;
|
|
932
|
-
|
|
939
|
+
F(e, t, "onSelfDragEnd"), x(e, "onDragEnd"), kt(e, e.hovered);
|
|
933
940
|
}
|
|
934
941
|
function Wt(e) {
|
|
935
942
|
const t = e.entities.selectingArea;
|
|
@@ -941,51 +948,51 @@ const jt = (e) => {
|
|
|
941
948
|
const t = {
|
|
942
949
|
current: null
|
|
943
950
|
}, s = { value: 0 }, n = async () => {
|
|
944
|
-
|
|
951
|
+
he(), t.current?.cancel(), t.current = null;
|
|
945
952
|
const i = e.state.value;
|
|
946
953
|
if (i === "dragging") {
|
|
947
954
|
const g = await Ue(e);
|
|
948
955
|
if (g === "accept" && Ve(e), g === "accept" || g === "cancel") {
|
|
949
|
-
|
|
956
|
+
se(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
950
957
|
return;
|
|
951
958
|
}
|
|
952
959
|
return;
|
|
953
960
|
} else i === "selecting" && Wt(e);
|
|
954
|
-
|
|
961
|
+
se(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
955
962
|
}, o = (i) => {
|
|
956
963
|
if (e.pointer.value) {
|
|
957
964
|
if (e.pointer.value.current = { x: i.clientX, y: i.clientY }, ht(e)) {
|
|
958
|
-
|
|
965
|
+
ge(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
959
966
|
return;
|
|
960
967
|
}
|
|
961
968
|
if (e.state.value === "dragging") {
|
|
962
969
|
qt(e, s);
|
|
963
970
|
const g = e.entities.initiatingDraggable;
|
|
964
|
-
|
|
971
|
+
F(e, g, "onSelfDragMove"), x(e, "onDragMove");
|
|
965
972
|
}
|
|
966
|
-
e.state.value === "selecting" &&
|
|
973
|
+
e.state.value === "selecting" && zt(e);
|
|
967
974
|
}
|
|
968
975
|
};
|
|
969
976
|
return { pointerDown: (i) => {
|
|
970
977
|
document.addEventListener("pointerup", n), document.addEventListener("pointermove", o);
|
|
971
978
|
const g = i.target, l = g.closest(
|
|
972
|
-
|
|
973
|
-
),
|
|
974
|
-
|
|
979
|
+
_.SELECT_AREA
|
|
980
|
+
), f = g.closest(
|
|
981
|
+
_.DRAGGABLE
|
|
975
982
|
);
|
|
976
983
|
if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(l)) {
|
|
977
|
-
|
|
984
|
+
me(), e.pointer.value = be(i), e.state.value = "selecting", e.entities.selectingArea = l;
|
|
978
985
|
return;
|
|
979
986
|
}
|
|
980
|
-
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(
|
|
981
|
-
const c = e.entities.draggableMap.get(
|
|
982
|
-
if (!
|
|
987
|
+
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(f)) {
|
|
988
|
+
const c = e.entities.draggableMap.get(f);
|
|
989
|
+
if (!He(g, f, c?.dragHandle))
|
|
983
990
|
return;
|
|
984
|
-
|
|
985
|
-
const
|
|
986
|
-
e.pointer.value =
|
|
987
|
-
|
|
988
|
-
}))) : (
|
|
991
|
+
me(), e.entities.initiatingDraggable = f;
|
|
992
|
+
const u = _e(i, f);
|
|
993
|
+
e.pointer.value = be(i, u.x, u.y), c?.activation?.distance || c?.activation?.delay ? (e.state.value = "activating", c?.activation?.delay && (e.delay.startTime = Date.now(), t.current = bt(e, () => {
|
|
994
|
+
ne(e), ge(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
995
|
+
}))) : (ne(e), ge(e, i, "onSelfDragStart"), x(e, "onDragStart"));
|
|
989
996
|
}
|
|
990
997
|
}, pointerUp: n, pointerMove: o, cleanup: () => {
|
|
991
998
|
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();
|
|
@@ -1003,15 +1010,15 @@ const jt = (e) => {
|
|
|
1003
1010
|
const { keys: s } = e.keyboard;
|
|
1004
1011
|
if (s.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1005
1012
|
if (s.forCancel.includes(t.code)) {
|
|
1006
|
-
t.preventDefault(),
|
|
1013
|
+
t.preventDefault(), he(), F(
|
|
1007
1014
|
e,
|
|
1008
1015
|
e.entities.initiatingDraggable,
|
|
1009
1016
|
"onSelfDragCancel"
|
|
1010
|
-
), x(e, "onDragCancel"),
|
|
1017
|
+
), x(e, "onDragCancel"), Ye(e, e.hovered), se(e);
|
|
1011
1018
|
return;
|
|
1012
1019
|
}
|
|
1013
1020
|
if (s.forDrop.includes(t.code)) {
|
|
1014
|
-
t.preventDefault(), (async () => (await Ue(e) && Ve(e),
|
|
1021
|
+
t.preventDefault(), (async () => (await Ue(e) && Ve(e), he(), se(e)))();
|
|
1015
1022
|
return;
|
|
1016
1023
|
}
|
|
1017
1024
|
const o = Jt[t.code];
|
|
@@ -1024,8 +1031,8 @@ const jt = (e) => {
|
|
|
1024
1031
|
x: e.pointer.value.current.x + o.dx * a,
|
|
1025
1032
|
y: e.pointer.value.current.y + o.dy * a
|
|
1026
1033
|
};
|
|
1027
|
-
const g = (e.collision?.run ??
|
|
1028
|
-
|
|
1034
|
+
const g = (e.collision?.run ?? Se)(e);
|
|
1035
|
+
oe(e, e.hovered, g), F(
|
|
1029
1036
|
e,
|
|
1030
1037
|
e.entities.initiatingDraggable,
|
|
1031
1038
|
"onSelfDragMove"
|
|
@@ -1038,39 +1045,39 @@ const jt = (e) => {
|
|
|
1038
1045
|
const o = document.activeElement;
|
|
1039
1046
|
if (!o) return;
|
|
1040
1047
|
const r = o.closest(
|
|
1041
|
-
|
|
1048
|
+
_.DRAGGABLE
|
|
1042
1049
|
);
|
|
1043
1050
|
if (!r || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(r))
|
|
1044
1051
|
return;
|
|
1045
1052
|
const a = e.entities.draggableMap.get(r);
|
|
1046
|
-
if (!
|
|
1053
|
+
if (!He(o, r, a?.dragHandle, !0))
|
|
1047
1054
|
return;
|
|
1048
|
-
t.preventDefault(),
|
|
1049
|
-
const i = r.getBoundingClientRect(), g = i.left + i.width / 2, l = i.top + i.height / 2,
|
|
1055
|
+
t.preventDefault(), me();
|
|
1056
|
+
const i = r.getBoundingClientRect(), g = i.left + i.width / 2, l = i.top + i.height / 2, f = {
|
|
1050
1057
|
clientX: g,
|
|
1051
1058
|
clientY: l
|
|
1052
1059
|
};
|
|
1053
1060
|
e.entities.initiatingDraggable = r;
|
|
1054
|
-
const c =
|
|
1055
|
-
e.pointer.value =
|
|
1056
|
-
|
|
1061
|
+
const c = _e(f, r);
|
|
1062
|
+
e.pointer.value = be(
|
|
1063
|
+
f,
|
|
1057
1064
|
c.x,
|
|
1058
1065
|
c.y
|
|
1059
|
-
),
|
|
1060
|
-
const d = (e.collision?.run ??
|
|
1061
|
-
|
|
1066
|
+
), ne(e);
|
|
1067
|
+
const d = (e.collision?.run ?? Se)(e);
|
|
1068
|
+
oe(e, e.hovered, d), F(e, r, "onSelfDragStart"), x(e, "onDragStart");
|
|
1062
1069
|
}
|
|
1063
1070
|
}, en = (e) => (t) => {
|
|
1064
1071
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
1065
1072
|
}, tn = (e) => () => {
|
|
1066
1073
|
e.keyboard.keys.pressedKeys.value.clear();
|
|
1067
|
-
},
|
|
1074
|
+
}, ue = {
|
|
1068
1075
|
keyDown: Qt,
|
|
1069
1076
|
keyUp: en,
|
|
1070
1077
|
clear: tn
|
|
1071
1078
|
}, nn = (e) => () => {
|
|
1072
|
-
e.state.value && (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging" &&
|
|
1073
|
-
}, L = 50, sn = 144,
|
|
1079
|
+
e.state.value && (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging" && De(e));
|
|
1080
|
+
}, L = 50, sn = 144, ke = 1e3 / sn;
|
|
1074
1081
|
function on(e) {
|
|
1075
1082
|
return e == null ? {
|
|
1076
1083
|
top: L,
|
|
@@ -1102,7 +1109,7 @@ const an = {
|
|
|
1102
1109
|
};
|
|
1103
1110
|
function $e(e, t, s, n = an, o) {
|
|
1104
1111
|
const { speed: r = 10, disabled: a = !1 } = t, i = on(t.threshold);
|
|
1105
|
-
let g = null, l = null,
|
|
1112
|
+
let g = null, l = null, f = null, c = 0, u = 0;
|
|
1106
1113
|
const d = (b) => {
|
|
1107
1114
|
o && (o.value = b);
|
|
1108
1115
|
}, m = (b) => {
|
|
@@ -1112,22 +1119,22 @@ function $e(e, t, s, n = an, o) {
|
|
|
1112
1119
|
return;
|
|
1113
1120
|
}
|
|
1114
1121
|
l || (l = b);
|
|
1115
|
-
const
|
|
1116
|
-
if (
|
|
1122
|
+
const $ = b - l;
|
|
1123
|
+
if ($ < ke) {
|
|
1117
1124
|
g = requestAnimationFrame(m);
|
|
1118
1125
|
return;
|
|
1119
1126
|
}
|
|
1120
|
-
const p = r * (
|
|
1127
|
+
const p = r * ($ / ke);
|
|
1121
1128
|
l = b;
|
|
1122
|
-
const { scrollTop: w, scrollLeft:
|
|
1123
|
-
(!
|
|
1124
|
-
let
|
|
1125
|
-
i.top > 0 && E.y -
|
|
1129
|
+
const { scrollTop: w, scrollLeft: Z } = n.getScrollState(v);
|
|
1130
|
+
(!f || c !== w || u !== Z) && (f = n.getRect ? n.getRect(v) : v.getBoundingClientRect(), c = w, u = Z);
|
|
1131
|
+
let z = !1, ie = w, le = Z;
|
|
1132
|
+
i.top > 0 && E.y - f.top < i.top ? (ie = w - p, z = !0) : i.bottom > 0 && f.bottom - E.y < i.bottom && (ie = w + p, z = !0), i.left > 0 && E.x - f.left < i.left ? (le = Z - p, z = !0) : i.right > 0 && f.right - E.x < i.right && (le = Z + p, z = !0), z && n.setScroll(v, ie, le), d(z), g = requestAnimationFrame(m);
|
|
1126
1133
|
};
|
|
1127
1134
|
return { run: () => {
|
|
1128
1135
|
l = null, g = requestAnimationFrame(m);
|
|
1129
1136
|
}, stop: () => {
|
|
1130
|
-
g && (cancelAnimationFrame(g), g = null),
|
|
1137
|
+
g && (cancelAnimationFrame(g), g = null), f = null, c = 0, u = 0, l = null, d(!1);
|
|
1131
1138
|
} };
|
|
1132
1139
|
}
|
|
1133
1140
|
const rn = {
|
|
@@ -1149,7 +1156,7 @@ const rn = {
|
|
|
1149
1156
|
}
|
|
1150
1157
|
};
|
|
1151
1158
|
function cn(e, t) {
|
|
1152
|
-
const s =
|
|
1159
|
+
const s = ee(!1), o = $e(
|
|
1153
1160
|
ln,
|
|
1154
1161
|
t ?? {},
|
|
1155
1162
|
() => {
|
|
@@ -1162,7 +1169,7 @@ function cn(e, t) {
|
|
|
1162
1169
|
},
|
|
1163
1170
|
rn,
|
|
1164
1171
|
s
|
|
1165
|
-
), r =
|
|
1172
|
+
), r = ae(
|
|
1166
1173
|
() => e.state.value,
|
|
1167
1174
|
(i) => {
|
|
1168
1175
|
i === "dragging" ? o.run() : o.stop();
|
|
@@ -1173,9 +1180,9 @@ function cn(e, t) {
|
|
|
1173
1180
|
return We(a), { isScrolling: s, stop: a };
|
|
1174
1181
|
}
|
|
1175
1182
|
const gn = (e) => {
|
|
1176
|
-
const t = jt(e), s =
|
|
1183
|
+
const t = jt(e), s = ue.keyDown(e), n = ue.keyUp(e), o = ue.clear(e), r = nn(e);
|
|
1177
1184
|
let a = null;
|
|
1178
|
-
|
|
1185
|
+
ae(
|
|
1179
1186
|
e.autoScrollViewport,
|
|
1180
1187
|
(i) => {
|
|
1181
1188
|
a?.(), a = null, (i === !0 || i && typeof i == "object") && (a = cn(
|
|
@@ -1184,17 +1191,17 @@ const gn = (e) => {
|
|
|
1184
1191
|
).stop);
|
|
1185
1192
|
},
|
|
1186
1193
|
{ immediate: !0 }
|
|
1187
|
-
),
|
|
1194
|
+
), U(() => {
|
|
1188
1195
|
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", s), document.addEventListener("keyup", n), document.addEventListener("blur", o), document.addEventListener("scroll", r, !0);
|
|
1189
|
-
}),
|
|
1196
|
+
}), V(() => {
|
|
1190
1197
|
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();
|
|
1191
1198
|
});
|
|
1192
|
-
},
|
|
1193
|
-
const e = Oe(
|
|
1199
|
+
}, re = () => {
|
|
1200
|
+
const e = Oe(Me);
|
|
1194
1201
|
if (!e) throw Error("DnD provider not found");
|
|
1195
1202
|
return e;
|
|
1196
1203
|
}, qe = () => {
|
|
1197
|
-
const e =
|
|
1204
|
+
const e = re();
|
|
1198
1205
|
return {
|
|
1199
1206
|
overlay: e.overlay,
|
|
1200
1207
|
delay: e.delay,
|
|
@@ -1208,23 +1215,23 @@ const gn = (e) => {
|
|
|
1208
1215
|
collision: e.collision,
|
|
1209
1216
|
autoScrollViewport: e.autoScrollViewport
|
|
1210
1217
|
};
|
|
1211
|
-
}, un = /* @__PURE__ */
|
|
1218
|
+
}, un = /* @__PURE__ */ Be({
|
|
1212
1219
|
__name: "DefaultOverlay",
|
|
1213
1220
|
setup(e) {
|
|
1214
1221
|
const { entities: t, state: s, overlay: n } = qe();
|
|
1215
|
-
return (o, r) => k(s) === "dragging" ? (C(),
|
|
1222
|
+
return (o, r) => k(s) === "dragging" ? (C(), J("div", {
|
|
1216
1223
|
key: 0,
|
|
1217
1224
|
class: "dnd-kit-default-overlay",
|
|
1218
|
-
style:
|
|
1225
|
+
style: Ae({
|
|
1219
1226
|
"--position-x": k(n).position.value.x + "px",
|
|
1220
1227
|
"--position-y": k(n).position.value.y + "px"
|
|
1221
1228
|
})
|
|
1222
1229
|
}, [
|
|
1223
|
-
(C(!0),
|
|
1224
|
-
k(t).draggableMap.get(a)?.render ? (C(),
|
|
1230
|
+
(C(!0), J(fe, null, je(k(t).draggingMap, ([a, i]) => (C(), J(fe, null, [
|
|
1231
|
+
k(t).draggableMap.get(a)?.render ? (C(), te(de(k(t).draggableMap.get(a)?.render), { key: 0 })) : (C(), te(de(a.tagName), {
|
|
1225
1232
|
key: 1,
|
|
1226
1233
|
innerHTML: i.initialOuterHTML,
|
|
1227
|
-
style:
|
|
1234
|
+
style: Ae({
|
|
1228
1235
|
width: i.initialRect.width + "px",
|
|
1229
1236
|
height: i.initialRect.height + "px"
|
|
1230
1237
|
})
|
|
@@ -1232,7 +1239,7 @@ const gn = (e) => {
|
|
|
1232
1239
|
], 64))), 256))
|
|
1233
1240
|
], 4)) : Je("", !0);
|
|
1234
1241
|
}
|
|
1235
|
-
}), hn = /* @__PURE__ */
|
|
1242
|
+
}), hn = /* @__PURE__ */ Be({
|
|
1236
1243
|
__name: "DnDProvider",
|
|
1237
1244
|
props: {
|
|
1238
1245
|
autoScrollViewport: { type: [Object, Boolean, null] },
|
|
@@ -1246,9 +1253,9 @@ const gn = (e) => {
|
|
|
1246
1253
|
const o = y(
|
|
1247
1254
|
() => n.overlay.render.value ?? un
|
|
1248
1255
|
);
|
|
1249
|
-
return et(
|
|
1250
|
-
|
|
1251
|
-
(C(),
|
|
1256
|
+
return et(Me, n), (r, a) => (C(), J(fe, null, [
|
|
1257
|
+
Ee(r.$slots, "default"),
|
|
1258
|
+
(C(), te(tt, {
|
|
1252
1259
|
to: k(n).overlay.to.value || "body"
|
|
1253
1260
|
}, [
|
|
1254
1261
|
nt("div", st({
|
|
@@ -1256,8 +1263,8 @@ const gn = (e) => {
|
|
|
1256
1263
|
ref: s,
|
|
1257
1264
|
class: "dnd-kit-overlay-container"
|
|
1258
1265
|
}, t), [
|
|
1259
|
-
|
|
1260
|
-
(C(),
|
|
1266
|
+
Ee(r.$slots, "overlay", { overlay: o.value }, () => [
|
|
1267
|
+
(C(), te(de(o.value)))
|
|
1261
1268
|
])
|
|
1262
1269
|
], 16)
|
|
1263
1270
|
], 8, ["to"]))
|
|
@@ -1265,7 +1272,7 @@ const gn = (e) => {
|
|
|
1265
1272
|
}
|
|
1266
1273
|
});
|
|
1267
1274
|
function bn(e, t, s) {
|
|
1268
|
-
const n =
|
|
1275
|
+
const n = re();
|
|
1269
1276
|
let o, r, a;
|
|
1270
1277
|
typeof t == "function" ? (o = {}, r = t) : (o = t ?? {}, r = s);
|
|
1271
1278
|
const i = y({
|
|
@@ -1274,8 +1281,8 @@ function bn(e, t, s) {
|
|
|
1274
1281
|
return c ? n.entities.selectedSet.has(c) : !1;
|
|
1275
1282
|
},
|
|
1276
1283
|
set(c) {
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1284
|
+
const u = D(e);
|
|
1285
|
+
u && n.entities.selectedSet[c ? "add" : "delete"](u);
|
|
1279
1286
|
}
|
|
1280
1287
|
}), g = y(() => {
|
|
1281
1288
|
const c = D(e);
|
|
@@ -1283,12 +1290,12 @@ function bn(e, t, s) {
|
|
|
1283
1290
|
}), l = y(() => {
|
|
1284
1291
|
const c = D(e);
|
|
1285
1292
|
return c ? n.entities.allowedDraggableSet.has(c) : !1;
|
|
1286
|
-
}),
|
|
1293
|
+
}), f = y(() => {
|
|
1287
1294
|
const c = D(e);
|
|
1288
1295
|
if (c)
|
|
1289
1296
|
return n.entities.draggableMap.get(c)?.hoveredPlacement;
|
|
1290
1297
|
});
|
|
1291
|
-
return
|
|
1298
|
+
return U(() => {
|
|
1292
1299
|
a = D(e), a && (a.addEventListener("dragstart", M), a.addEventListener("drag", M), a.addEventListener("dragend", M), a.setAttribute(T.DRAGGABLE, ""), n.lib.draggableObserver.observe(a), n.entities.draggableMap.set(a, {
|
|
1293
1300
|
render: o.render,
|
|
1294
1301
|
disabled: o.disabled ?? !1,
|
|
@@ -1302,19 +1309,19 @@ function bn(e, t, s) {
|
|
|
1302
1309
|
placementMargins: o.placementMargins,
|
|
1303
1310
|
hoveredPlacement: void 0
|
|
1304
1311
|
}));
|
|
1305
|
-
}),
|
|
1312
|
+
}), V(() => {
|
|
1306
1313
|
a && (n.lib.draggableObserver.unobserve(a), n.entities.visibleDraggableSet.delete(a), n.entities.draggableMap.delete(a), n.entities.modifiersDraggableSet.delete(a));
|
|
1307
1314
|
}), {
|
|
1308
1315
|
selected: i,
|
|
1309
1316
|
isDragging: g,
|
|
1310
1317
|
isAllowed: l,
|
|
1311
|
-
isDragOver:
|
|
1318
|
+
isDragOver: f
|
|
1312
1319
|
};
|
|
1313
1320
|
}
|
|
1314
1321
|
const yn = (e, t) => {
|
|
1315
|
-
const s =
|
|
1322
|
+
const s = re(), n = y(() => e.value === s.entities.selectingArea);
|
|
1316
1323
|
let o = null;
|
|
1317
|
-
|
|
1324
|
+
U(() => {
|
|
1318
1325
|
o = D(e), o && (o.setAttribute(T.SELECT_AREA, ""), s.lib.selectableAreaObserver.observe(o), s.entities.selectableAreaMap.set(o, {
|
|
1319
1326
|
modifier: t?.modifier ?? {
|
|
1320
1327
|
keys: ["ControlLeft"],
|
|
@@ -1324,7 +1331,7 @@ const yn = (e, t) => {
|
|
|
1324
1331
|
disabled: t?.disabled ?? !1,
|
|
1325
1332
|
groups: t?.groups ?? []
|
|
1326
1333
|
}));
|
|
1327
|
-
}),
|
|
1334
|
+
}), V(() => {
|
|
1328
1335
|
o && (s.lib.selectableAreaObserver.unobserve(o), s.entities.visibleSelectableAreaSet.delete(o), s.entities.modifiersSelectableAreaSet.delete(o), s.entities.selectableAreaMap.delete(o));
|
|
1329
1336
|
});
|
|
1330
1337
|
const r = y(() => {
|
|
@@ -1338,20 +1345,20 @@ const yn = (e, t) => {
|
|
|
1338
1345
|
};
|
|
1339
1346
|
};
|
|
1340
1347
|
function pn(e, t) {
|
|
1341
|
-
const s = Oe(
|
|
1348
|
+
const s = Oe(Me);
|
|
1342
1349
|
if (!s) throw Error("DnD provider not found");
|
|
1343
1350
|
let n = null;
|
|
1344
|
-
return
|
|
1351
|
+
return U(() => {
|
|
1345
1352
|
n = D(e), n && (n.setAttribute(T.CONSTRAINT_AREA, ""), s.entities.constraintsAreaMap.set(n, {
|
|
1346
1353
|
axis: t?.axis || "both",
|
|
1347
1354
|
restrictToArea: t?.restrictToArea || !1
|
|
1348
1355
|
}));
|
|
1349
|
-
}),
|
|
1356
|
+
}), V(() => {
|
|
1350
1357
|
n && s.entities.constraintsAreaMap.delete(n);
|
|
1351
1358
|
}), {};
|
|
1352
1359
|
}
|
|
1353
1360
|
function Sn(e, t, s) {
|
|
1354
|
-
const n =
|
|
1361
|
+
const n = re();
|
|
1355
1362
|
let o = null, r, a;
|
|
1356
1363
|
typeof t == "function" ? (r = {}, a = t) : (r = t ?? {}, a = s);
|
|
1357
1364
|
const i = y(() => {
|
|
@@ -1362,7 +1369,7 @@ function Sn(e, t, s) {
|
|
|
1362
1369
|
if (l)
|
|
1363
1370
|
return n.entities.droppableMap.get(l)?.hoveredPlacement;
|
|
1364
1371
|
});
|
|
1365
|
-
return
|
|
1372
|
+
return U(() => {
|
|
1366
1373
|
o = D(e), o && (o.setAttribute(T.DROPPABLE, ""), n.lib.droppableObserver.observe(o), n.entities.droppableMap.set(o, {
|
|
1367
1374
|
disabled: r.disabled ?? !1,
|
|
1368
1375
|
groups: r.groups ?? [],
|
|
@@ -1371,7 +1378,7 @@ function Sn(e, t, s) {
|
|
|
1371
1378
|
data: r.data,
|
|
1372
1379
|
hoveredPlacement: void 0
|
|
1373
1380
|
}));
|
|
1374
|
-
}),
|
|
1381
|
+
}), V(() => {
|
|
1375
1382
|
o && (n.lib.droppableObserver.unobserve(o), n.entities.visibleDroppableSet.delete(o), n.entities.droppableMap.delete(o));
|
|
1376
1383
|
}), {
|
|
1377
1384
|
isAllowed: i,
|
|
@@ -1379,7 +1386,7 @@ function Sn(e, t, s) {
|
|
|
1379
1386
|
};
|
|
1380
1387
|
}
|
|
1381
1388
|
const Dn = (e, t) => {
|
|
1382
|
-
const s = qe(), n =
|
|
1389
|
+
const s = qe(), n = ee(!1), r = $e(
|
|
1383
1390
|
e,
|
|
1384
1391
|
t ?? {},
|
|
1385
1392
|
() => {
|
|
@@ -1393,14 +1400,14 @@ const Dn = (e, t) => {
|
|
|
1393
1400
|
void 0,
|
|
1394
1401
|
n
|
|
1395
1402
|
);
|
|
1396
|
-
return
|
|
1403
|
+
return ae(
|
|
1397
1404
|
() => s.state.value,
|
|
1398
1405
|
(a) => {
|
|
1399
1406
|
a === "dragging" ? r.run() : r.stop();
|
|
1400
1407
|
}
|
|
1401
1408
|
), { isScrolling: n };
|
|
1402
1409
|
};
|
|
1403
|
-
function
|
|
1410
|
+
function Pe(e, t) {
|
|
1404
1411
|
return t <= 0 ? e : Math.round(e / t) * t;
|
|
1405
1412
|
}
|
|
1406
1413
|
function Mn(e, t) {
|
|
@@ -1408,40 +1415,40 @@ function Mn(e, t) {
|
|
|
1408
1415
|
return y(() => {
|
|
1409
1416
|
const { x: r, y: a } = e.value;
|
|
1410
1417
|
return {
|
|
1411
|
-
x:
|
|
1412
|
-
y:
|
|
1418
|
+
x: Pe(r, n),
|
|
1419
|
+
y: Pe(a, o)
|
|
1413
1420
|
};
|
|
1414
1421
|
});
|
|
1415
1422
|
}
|
|
1416
|
-
const
|
|
1423
|
+
const Te = () => !0, ze = () => 0, fn = "separate", dn = () => {
|
|
1417
1424
|
const e = {
|
|
1418
|
-
filterElements:
|
|
1419
|
-
filterZones:
|
|
1420
|
-
sortElements:
|
|
1421
|
-
sortZones:
|
|
1425
|
+
filterElements: Te,
|
|
1426
|
+
filterZones: Te,
|
|
1427
|
+
sortElements: ze,
|
|
1428
|
+
sortZones: ze,
|
|
1422
1429
|
mergeStrategy: fn,
|
|
1423
1430
|
pickClosestBetweenFirst: !1
|
|
1424
1431
|
}, t = (n, o, r, a, i, g, l) => {
|
|
1425
|
-
const
|
|
1426
|
-
for (const m of
|
|
1432
|
+
const f = a instanceof Set ? a : new Set(a), c = { containerBox: o, pointer: r }, u = e.minOverlapPercent, d = [];
|
|
1433
|
+
for (const m of f) {
|
|
1427
1434
|
if (!i(m, n)) continue;
|
|
1428
|
-
const h =
|
|
1435
|
+
const h = X(m);
|
|
1429
1436
|
if (!l(h, c)) continue;
|
|
1430
|
-
const S =
|
|
1431
|
-
if (
|
|
1437
|
+
const S = ye(h, o);
|
|
1438
|
+
if (u !== void 0 && S < u) continue;
|
|
1432
1439
|
let b = 0;
|
|
1433
|
-
for (const v of
|
|
1434
|
-
v !== m &&
|
|
1440
|
+
for (const v of f)
|
|
1441
|
+
v !== m && K(v, m) && b++;
|
|
1435
1442
|
d.push({
|
|
1436
1443
|
node: m,
|
|
1437
1444
|
box: h,
|
|
1438
1445
|
meta: {
|
|
1439
|
-
isPointerInElement:
|
|
1446
|
+
isPointerInElement: Zt(h, r.x, r.y),
|
|
1440
1447
|
overlapPercent: S,
|
|
1441
1448
|
depth: b,
|
|
1442
1449
|
centerDistance: Kt(
|
|
1443
|
-
|
|
1444
|
-
|
|
1450
|
+
Y(o),
|
|
1451
|
+
Y(h)
|
|
1445
1452
|
)
|
|
1446
1453
|
}
|
|
1447
1454
|
});
|
|
@@ -1493,7 +1500,7 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1493
1500
|
return (o) => {
|
|
1494
1501
|
const r = n.container(o);
|
|
1495
1502
|
if (!r) return { elements: [], zones: [] };
|
|
1496
|
-
const a = n.containerBox ? n.containerBox(o) :
|
|
1503
|
+
const a = n.containerBox ? n.containerBox(o) : X(r), i = o.pointer.value?.current ?? { x: 0, y: 0 }, g = t(
|
|
1497
1504
|
o,
|
|
1498
1505
|
a,
|
|
1499
1506
|
i,
|
|
@@ -1511,46 +1518,46 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1511
1518
|
n.collision
|
|
1512
1519
|
);
|
|
1513
1520
|
if (n.mergeStrategy === "unified-closest") {
|
|
1514
|
-
const
|
|
1515
|
-
...g.map((
|
|
1516
|
-
node:
|
|
1517
|
-
box:
|
|
1521
|
+
const f = [
|
|
1522
|
+
...g.map((u) => ({
|
|
1523
|
+
node: u.node,
|
|
1524
|
+
box: u.box,
|
|
1518
1525
|
isZone: !1,
|
|
1519
1526
|
distance: 0
|
|
1520
1527
|
})),
|
|
1521
|
-
...l.map((
|
|
1522
|
-
node:
|
|
1523
|
-
box:
|
|
1528
|
+
...l.map((u) => ({
|
|
1529
|
+
node: u.node,
|
|
1530
|
+
box: u.box,
|
|
1524
1531
|
isZone: !0,
|
|
1525
1532
|
distance: 0
|
|
1526
1533
|
}))
|
|
1527
1534
|
];
|
|
1528
|
-
if (
|
|
1529
|
-
for (const
|
|
1530
|
-
const d =
|
|
1531
|
-
|
|
1535
|
+
if (f.length === 0) return { elements: [], zones: [] };
|
|
1536
|
+
for (const u of f) {
|
|
1537
|
+
const d = Y(u.box);
|
|
1538
|
+
u.distance = Math.hypot(
|
|
1532
1539
|
i.x - d.x,
|
|
1533
1540
|
i.y - d.y
|
|
1534
1541
|
);
|
|
1535
1542
|
}
|
|
1536
|
-
const c =
|
|
1537
|
-
(
|
|
1543
|
+
const c = f.reduce(
|
|
1544
|
+
(u, d) => d.distance < u.distance ? d : u
|
|
1538
1545
|
);
|
|
1539
1546
|
return c.isZone ? { elements: [], zones: [c.node] } : { elements: [c.node], zones: [] };
|
|
1540
1547
|
}
|
|
1541
1548
|
if (n.pickClosestBetweenFirst && g[0] && l[0]) {
|
|
1542
|
-
const
|
|
1543
|
-
i.x -
|
|
1544
|
-
i.y -
|
|
1549
|
+
const f = Y(l[0].box), c = Y(g[0].box), u = Math.hypot(
|
|
1550
|
+
i.x - f.x,
|
|
1551
|
+
i.y - f.y
|
|
1545
1552
|
);
|
|
1546
1553
|
return Math.hypot(
|
|
1547
1554
|
i.x - c.x,
|
|
1548
1555
|
i.y - c.y
|
|
1549
|
-
) <
|
|
1556
|
+
) < u ? { elements: g.map((m) => m.node), zones: [] } : { elements: [], zones: l.map((m) => m.node) };
|
|
1550
1557
|
}
|
|
1551
1558
|
return {
|
|
1552
|
-
elements: g.map((
|
|
1553
|
-
zones: l.map((
|
|
1559
|
+
elements: g.map((f) => f.node),
|
|
1560
|
+
zones: l.map((f) => f.node)
|
|
1554
1561
|
};
|
|
1555
1562
|
};
|
|
1556
1563
|
}
|
|
@@ -1560,7 +1567,7 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1560
1567
|
export {
|
|
1561
1568
|
hn as DnDProvider,
|
|
1562
1569
|
vn as createSensor,
|
|
1563
|
-
|
|
1570
|
+
Se as defaultCollisionDetection,
|
|
1564
1571
|
Dn as makeAutoScroll,
|
|
1565
1572
|
pn as makeConstraintArea,
|
|
1566
1573
|
bn as makeDraggable,
|