@vue-dnd-kit/core 2.0.11 → 2.0.12
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/composables/makeDroppable.d.ts +8 -1
- package/dist/external/index.d.ts +0 -1
- package/dist/external/types/entities.d.ts +26 -0
- package/dist/internal/utils/groups.d.ts +4 -0
- package/dist/vue-dnd-kit-core.cjs.js +1 -1
- package/dist/vue-dnd-kit-core.es.js +510 -472
- package/package.json +1 -1
- package/dist/external/composables/makeSnappedOverlayPosition.d.ts +0 -20
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-default-overlay{transform:translate3d(var(--position-x),var(--position-y),0)}.dnd-kit-overlay-container{position:fixed;top:0;left:0;pointer-events:none;cursor:grabbing;z-index:9999}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
import { ref as j, watch as ie, shallowRef as te, reactive as q, computed as
|
|
3
|
-
const
|
|
2
|
+
import { ref as j, watch as ie, shallowRef as te, reactive as q, computed as p, onScopeDispose as Je, onMounted as X, onBeforeUnmount as U, inject as Oe, defineComponent as Fe, unref as V, openBlock as C, createElementBlock as J, normalizeStyle as Ce, Fragment as be, renderList as Qe, createBlock as ne, resolveDynamicComponent as ye, createCommentVNode as et, useTemplateRef as tt, provide as nt, renderSlot as Ie, Teleport as st, createElementVNode as ot, mergeProps as at } 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
|
-
},
|
|
8
|
+
}, F = {
|
|
9
|
+
SELECT_AREA: `[${P.SELECT_AREA}]`,
|
|
10
|
+
DRAGGABLE: `[${P.DRAGGABLE}]`,
|
|
11
|
+
CONSTRAINT_AREA: `[${P.CONSTRAINT_AREA}]`
|
|
12
|
+
}, Ae = "VueDnDKitProvider", Re = (e, t, s, n) => {
|
|
13
13
|
const o = /* @__PURE__ */ new Set();
|
|
14
14
|
return t.forEach((i) => {
|
|
15
15
|
const a = e.get(i), r = n ? n(i) : a?.disabled;
|
|
16
16
|
if (!a || r) return;
|
|
17
|
-
const g = a.modifier?.keys,
|
|
18
|
-
if (!g || !
|
|
17
|
+
const g = a.modifier?.keys, c = a.modifier?.method;
|
|
18
|
+
if (!g || !c || g.length === 0) {
|
|
19
19
|
o.add(i);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
g[
|
|
22
|
+
g[c]((l) => s.value.has(l)) && o.add(i);
|
|
23
23
|
}), o;
|
|
24
24
|
};
|
|
25
25
|
let _e = "", it = "", rt = "";
|
|
26
|
-
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null,
|
|
26
|
+
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, G = (e, t) => e !== t && e.contains(t), lt = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), pe = () => {
|
|
27
27
|
const e = document.body;
|
|
28
28
|
_e = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", M), window.addEventListener("selectstart", M), window.addEventListener("touchstart", M), window.addEventListener("touchmove", M);
|
|
29
|
-
},
|
|
29
|
+
}, Se = () => {
|
|
30
30
|
const e = document.body;
|
|
31
31
|
e.style.userSelect = _e, e.style.touchAction = it, e.style.overscrollBehavior = rt, window.removeEventListener("contextmenu", M), window.removeEventListener("selectstart", M), window.removeEventListener("touchstart", M), window.removeEventListener("touchmove", M);
|
|
32
|
-
}, M = (e) => e.preventDefault(),
|
|
32
|
+
}, M = (e) => e.preventDefault(), Ee = (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 && G(n, e)) return !0;
|
|
36
36
|
return !1;
|
|
37
|
-
},
|
|
37
|
+
}, _ = (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 && G(n, e)) return !0;
|
|
41
41
|
return !1;
|
|
42
|
-
},
|
|
42
|
+
}, re = (e, t) => {
|
|
43
43
|
if (!e.length || !t.length) return !0;
|
|
44
44
|
const s = new Set(t);
|
|
45
45
|
return e.some((n) => s.has(n));
|
|
46
46
|
};
|
|
47
47
|
function ct(e, t, s, n) {
|
|
48
|
-
const o =
|
|
49
|
-
for (const
|
|
50
|
-
const
|
|
51
|
-
|
|
48
|
+
const o = [];
|
|
49
|
+
for (const a of t.keys()) {
|
|
50
|
+
const r = s.get(a);
|
|
51
|
+
o.push({ groups: r?.groups ?? [] });
|
|
52
52
|
}
|
|
53
|
-
const i =
|
|
54
|
-
for (const
|
|
55
|
-
const
|
|
56
|
-
|
|
53
|
+
const i = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const a of e) {
|
|
55
|
+
const r = n.get(a), g = r?.groups ?? [], c = r?.groupMatch ?? "every";
|
|
56
|
+
(!o.length || o[c]((l) => re(l.groups, g))) && i.add(a);
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return i;
|
|
59
59
|
}
|
|
60
60
|
function gt(e, t, s) {
|
|
61
61
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -66,11 +66,11 @@ function gt(e, t, s) {
|
|
|
66
66
|
const o = [...n], i = /* @__PURE__ */ new Set();
|
|
67
67
|
for (const a of e) {
|
|
68
68
|
const g = s.get(a)?.groups ?? [];
|
|
69
|
-
|
|
69
|
+
re(o, g) && i.add(a);
|
|
70
70
|
}
|
|
71
71
|
return i;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const ue = (e) => {
|
|
74
74
|
const t = new IntersectionObserver((s) => {
|
|
75
75
|
s.forEach((n) => {
|
|
76
76
|
const o = n.target;
|
|
@@ -108,18 +108,18 @@ const ge = (e) => {
|
|
|
108
108
|
}
|
|
109
109
|
} };
|
|
110
110
|
};
|
|
111
|
-
function
|
|
111
|
+
function De(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 Ze(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,13 +130,13 @@ function He(e, t) {
|
|
|
130
130
|
function dt(e, t, s) {
|
|
131
131
|
e.forEach((n) => {
|
|
132
132
|
const o = t.get(n);
|
|
133
|
-
s.set(n,
|
|
133
|
+
s.set(n, Ge(n, o));
|
|
134
134
|
}), e.clear();
|
|
135
135
|
}
|
|
136
136
|
function mt(e, t, s) {
|
|
137
137
|
s.clear();
|
|
138
138
|
const n = t.get(e);
|
|
139
|
-
s.set(e,
|
|
139
|
+
s.set(e, Ge(e, n));
|
|
140
140
|
}
|
|
141
141
|
function se(e) {
|
|
142
142
|
e.entities.initiatingDraggable && (e.state.value = "dragging", ht(
|
|
@@ -149,7 +149,7 @@ function se(e) {
|
|
|
149
149
|
function ht(e, t, s, n) {
|
|
150
150
|
t.has(e) ? dt(t, s, n) : (t.clear(), mt(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;
|
|
@@ -158,8 +158,8 @@ function bt(e, t) {
|
|
|
158
158
|
if (!e || !t) return 1;
|
|
159
159
|
const s = Math.abs(e.current.x - e.start.x), n = Math.abs(e.current.y - e.start.y);
|
|
160
160
|
if (typeof t == "number") {
|
|
161
|
-
const
|
|
162
|
-
return Math.min(
|
|
161
|
+
const c = Math.sqrt(s * s + n * n);
|
|
162
|
+
return Math.min(c / t, 1);
|
|
163
163
|
}
|
|
164
164
|
const {
|
|
165
165
|
x: o = 0,
|
|
@@ -170,7 +170,7 @@ function bt(e, t) {
|
|
|
170
170
|
const r = o > 0 ? Math.min(s / o, 1) : 1, g = i > 0 ? Math.min(n / i, 1) : 1;
|
|
171
171
|
return a === "both" ? Math.min(r, g) : Math.max(r, 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,7 +181,7 @@ function yt(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
|
|
@@ -204,7 +204,7 @@ function pt(e, t) {
|
|
|
204
204
|
e.delay.progress = Math.min(
|
|
205
205
|
(Date.now() - e.delay.startTime) / (i * 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 pt(e, t) {
|
|
|
218
218
|
}
|
|
219
219
|
function St(e, t) {
|
|
220
220
|
const s = e.closest(
|
|
221
|
-
|
|
221
|
+
F.CONSTRAINT_AREA
|
|
222
222
|
);
|
|
223
223
|
return !s || !t.has(s) ? null : {
|
|
224
224
|
element: s,
|
|
@@ -242,15 +242,15 @@ function wt(e, t, s, n, o) {
|
|
|
242
242
|
if (!e || !t)
|
|
243
243
|
return { x: 0, y: 0 };
|
|
244
244
|
const i = t.getBoundingClientRect(), a = i.width || o?.width || 0, r = i.height || o?.height || 0;
|
|
245
|
-
let g = e.current.x - a * e.offset.x,
|
|
245
|
+
let g = e.current.x - a * e.offset.x, c = e.current.y - r * e.offset.y;
|
|
246
246
|
if (!s)
|
|
247
|
-
return { x: g, y:
|
|
247
|
+
return { x: g, y: c };
|
|
248
248
|
const u = St(s, n);
|
|
249
249
|
if (!u)
|
|
250
|
-
return { x: g, y:
|
|
251
|
-
const { element:
|
|
250
|
+
return { x: g, y: c };
|
|
251
|
+
const { element: l, entity: f } = u, d = l.getBoundingClientRect(), m = s.getBoundingClientRect(), h = Dt(
|
|
252
252
|
g,
|
|
253
|
-
|
|
253
|
+
c,
|
|
254
254
|
f.axis || "both",
|
|
255
255
|
m
|
|
256
256
|
);
|
|
@@ -262,7 +262,7 @@ function wt(e, t, s, n, o) {
|
|
|
262
262
|
i
|
|
263
263
|
) : h;
|
|
264
264
|
}
|
|
265
|
-
const
|
|
265
|
+
const K = {
|
|
266
266
|
forDrag: ["Enter", "Space"],
|
|
267
267
|
forCancel: ["Escape"],
|
|
268
268
|
forDrop: ["Enter", "Space"],
|
|
@@ -282,11 +282,11 @@ function vt(e, t) {
|
|
|
282
282
|
const s = te(), n = j(), i = {
|
|
283
283
|
keys: {
|
|
284
284
|
pressedKeys: j(/* @__PURE__ */ new Set()),
|
|
285
|
-
forDrag: [...
|
|
286
|
-
forCancel: [...
|
|
287
|
-
forDrop: [...
|
|
288
|
-
forMove: [...
|
|
289
|
-
forMoveFaster: [...
|
|
285
|
+
forDrag: [...K.forDrag],
|
|
286
|
+
forCancel: [...K.forCancel],
|
|
287
|
+
forDrop: [...K.forDrop],
|
|
288
|
+
forMove: [...K.forMove],
|
|
289
|
+
forMoveFaster: [...K.forMoveFaster]
|
|
290
290
|
},
|
|
291
291
|
step: 8,
|
|
292
292
|
moveFaster: 4
|
|
@@ -300,27 +300,27 @@ function vt(e, t) {
|
|
|
300
300
|
draggingMap: /* @__PURE__ */ new Map(),
|
|
301
301
|
selectedSet: /* @__PURE__ */ new Set(),
|
|
302
302
|
selectionBase: /* @__PURE__ */ new Set(),
|
|
303
|
-
allowedDroppableSet:
|
|
303
|
+
allowedDroppableSet: p(() => s.value ? ct(
|
|
304
304
|
a.visibleDroppableSet,
|
|
305
305
|
a.draggingMap,
|
|
306
306
|
a.draggableMap,
|
|
307
307
|
a.droppableMap
|
|
308
308
|
) : /* @__PURE__ */ new Set()),
|
|
309
|
-
allowedDraggableSet:
|
|
309
|
+
allowedDraggableSet: p(() => s.value ? gt(
|
|
310
310
|
a.visibleDraggableSet,
|
|
311
311
|
a.draggingMap,
|
|
312
312
|
a.draggableMap
|
|
313
313
|
) : /* @__PURE__ */ new Set()),
|
|
314
|
-
modifiersSelectableAreaSet:
|
|
314
|
+
modifiersSelectableAreaSet: p(() => Re(
|
|
315
315
|
a.selectableAreaMap,
|
|
316
316
|
a.visibleSelectableAreaSet,
|
|
317
317
|
i.keys.pressedKeys
|
|
318
318
|
)),
|
|
319
|
-
modifiersDraggableSet:
|
|
319
|
+
modifiersDraggableSet: p(() => Re(
|
|
320
320
|
a.draggableMap,
|
|
321
321
|
a.visibleDraggableSet,
|
|
322
322
|
i.keys.pressedKeys,
|
|
323
|
-
(v) =>
|
|
323
|
+
(v) => Ee(v, { entities: a })
|
|
324
324
|
)),
|
|
325
325
|
visibleDraggableSet: /* @__PURE__ */ new Set(),
|
|
326
326
|
visibleDroppableSet: /* @__PURE__ */ new Set(),
|
|
@@ -330,43 +330,43 @@ function vt(e, t) {
|
|
|
330
330
|
droppable: /* @__PURE__ */ new Map()
|
|
331
331
|
}), g = {
|
|
332
332
|
throttle: te(0)
|
|
333
|
-
},
|
|
333
|
+
}, c = q({
|
|
334
334
|
x: window.scrollX,
|
|
335
335
|
y: window.scrollY
|
|
336
336
|
}), u = q({
|
|
337
337
|
progress: 0,
|
|
338
338
|
startTime: 0
|
|
339
|
-
}),
|
|
339
|
+
}), l = p(() => {
|
|
340
340
|
if (!n.value || !a.initiatingDraggable) return 0;
|
|
341
341
|
const v = a.draggableMap.get(a.initiatingDraggable)?.activation?.distance;
|
|
342
342
|
return v ? bt(n.value, v) : 1;
|
|
343
|
-
}), f =
|
|
343
|
+
}), f = ue(
|
|
344
344
|
a.visibleDraggableSet
|
|
345
|
-
), d =
|
|
345
|
+
), d = ue(
|
|
346
346
|
a.visibleDroppableSet
|
|
347
|
-
), m =
|
|
347
|
+
), m = ue(
|
|
348
348
|
a.visibleSelectableAreaSet
|
|
349
|
-
), { overlaySize: h, overlaySizeObserver:
|
|
350
|
-
const
|
|
349
|
+
), { overlaySize: h, overlaySizeObserver: y } = ft(e), b = j(), w = p(() => {
|
|
350
|
+
const S = a.initiatingDraggable;
|
|
351
351
|
return wt(
|
|
352
352
|
n.value,
|
|
353
353
|
e.value,
|
|
354
|
-
|
|
354
|
+
S || null,
|
|
355
355
|
a.constraintsAreaMap,
|
|
356
356
|
h.value
|
|
357
357
|
);
|
|
358
|
-
}), E =
|
|
358
|
+
}), E = p({
|
|
359
359
|
get: () => t?.overlayTo,
|
|
360
|
-
set: (
|
|
361
|
-
}), $ =
|
|
360
|
+
set: (S) => E.value = S
|
|
361
|
+
}), $ = p(() => t?.autoScrollViewport);
|
|
362
362
|
return {
|
|
363
363
|
state: s,
|
|
364
364
|
pointer: n,
|
|
365
365
|
entities: a,
|
|
366
366
|
keyboard: i,
|
|
367
|
-
scrollPosition:
|
|
367
|
+
scrollPosition: c,
|
|
368
368
|
delay: u,
|
|
369
|
-
distanceProgress:
|
|
369
|
+
distanceProgress: l,
|
|
370
370
|
hovered: r,
|
|
371
371
|
collision: g,
|
|
372
372
|
overlay: {
|
|
@@ -380,7 +380,7 @@ function vt(e, t) {
|
|
|
380
380
|
draggableObserver: f,
|
|
381
381
|
droppableObserver: d,
|
|
382
382
|
selectableAreaObserver: m,
|
|
383
|
-
overlaySizeObserver:
|
|
383
|
+
overlaySizeObserver: y,
|
|
384
384
|
rectCache: /* @__PURE__ */ new Map()
|
|
385
385
|
},
|
|
386
386
|
autoScrollViewport: $
|
|
@@ -399,21 +399,68 @@ const oe = (e) => {
|
|
|
399
399
|
}
|
|
400
400
|
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
401
|
};
|
|
402
|
+
function xt(e) {
|
|
403
|
+
return e.parentElement?.closest(F.SELECT_AREA) ?? null;
|
|
404
|
+
}
|
|
405
|
+
const At = (e, t, s) => {
|
|
406
|
+
if (!s) return {};
|
|
407
|
+
const n = s.getBoundingClientRect(), o = Math.max(n.left, Math.min(e.x, t.x)), i = Math.max(n.top, Math.min(e.y, t.y)), a = Math.min(n.right, Math.max(e.x, t.x)), r = Math.min(n.bottom, Math.max(e.y, t.y)), g = Math.max(0, a - o), c = Math.max(0, r - i), u = o - n.left + s.scrollLeft, l = i - n.top + s.scrollTop;
|
|
408
|
+
return {
|
|
409
|
+
position: "absolute",
|
|
410
|
+
left: `${u}px`,
|
|
411
|
+
top: `${l}px`,
|
|
412
|
+
width: `${g}px`,
|
|
413
|
+
height: `${c}px`,
|
|
414
|
+
pointerEvents: "none",
|
|
415
|
+
border: "1px solid #3b82f6",
|
|
416
|
+
backgroundColor: "#3b82f61a"
|
|
417
|
+
};
|
|
418
|
+
}, Ne = (e) => {
|
|
419
|
+
if (!e.pointer.value || !e.entities.selectingArea) return;
|
|
420
|
+
const { selectingArea: t } = e.entities, s = Et(
|
|
421
|
+
e.pointer.value.start,
|
|
422
|
+
e.pointer.value.current
|
|
423
|
+
), n = e.entities.selectableAreaMap.get(t)?.groups ?? [], o = e.lib.rectCache;
|
|
424
|
+
e.entities.visibleDraggableSet.forEach((i) => {
|
|
425
|
+
if (i === t || !t.contains(i)) return;
|
|
426
|
+
const a = xt(i);
|
|
427
|
+
if (a && a !== t) {
|
|
428
|
+
e.entities.selectedSet.delete(i);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (Ee(i, e)) {
|
|
432
|
+
e.entities.selectedSet.delete(i);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const g = e.entities.draggableMap.get(i)?.groups ?? [];
|
|
436
|
+
if (!re(n, g)) {
|
|
437
|
+
e.entities.selectedSet.delete(i);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
let c = o.get(i);
|
|
441
|
+
c || (c = i.getBoundingClientRect(), o.set(i, c));
|
|
442
|
+
const u = e.entities.selectionBase.has(i);
|
|
443
|
+
lt(s, c) ? u ? e.entities.selectedSet.delete(i) : e.entities.selectedSet.add(i) : u ? e.entities.selectedSet.add(i) : e.entities.selectedSet.delete(i);
|
|
444
|
+
});
|
|
445
|
+
}, Et = (e, t) => {
|
|
446
|
+
const s = Math.min(e.x, t.x), n = Math.min(e.y, t.y), o = Math.max(e.x, t.x), i = Math.max(e.y, t.y), a = o - s, r = i - n;
|
|
447
|
+
return new DOMRect(s, n, a, r);
|
|
448
|
+
};
|
|
402
449
|
function I(e, t, s) {
|
|
403
450
|
const n = Math.max(0, Math.min(t, e.length));
|
|
404
451
|
return [...e.slice(0, n), ...s, ...e.slice(n)];
|
|
405
452
|
}
|
|
406
|
-
function
|
|
453
|
+
function Le(e, t, s = 1) {
|
|
407
454
|
const n = Math.max(0, Math.min(t, e.length - 1)), o = Math.max(0, Math.min(s, e.length - n));
|
|
408
455
|
return [...e.slice(0, n), ...e.slice(n + o)];
|
|
409
456
|
}
|
|
410
|
-
function
|
|
457
|
+
function Z(e, t) {
|
|
411
458
|
const s = [...new Set(t)].filter((o) => o >= 0 && o < e.length).sort((o, i) => i - o);
|
|
412
459
|
let n = e;
|
|
413
|
-
for (const o of s) n =
|
|
460
|
+
for (const o of s) n = Le(n, o, 1);
|
|
414
461
|
return n;
|
|
415
462
|
}
|
|
416
|
-
function
|
|
463
|
+
function Ve(e, t, s) {
|
|
417
464
|
if (t === s || t < 0 || s < 0 || t >= e.length || s >= e.length)
|
|
418
465
|
return e;
|
|
419
466
|
const n = [...e];
|
|
@@ -435,113 +482,113 @@ function Ye(e, t) {
|
|
|
435
482
|
if (!s.length) return null;
|
|
436
483
|
const i = o?.placement.center === !0 && n != null && n.items !== o.items, a = i ? n.items : o?.items ?? n?.items;
|
|
437
484
|
if (!a) return null;
|
|
438
|
-
const r = s[0].items, g = s.map((f) => f.index),
|
|
439
|
-
let u,
|
|
485
|
+
const r = s[0].items, g = s.map((f) => f.index), c = a.length;
|
|
486
|
+
let u, l;
|
|
440
487
|
if (o && !i) {
|
|
441
488
|
const f = o.items === r && g.includes(o.index);
|
|
442
489
|
if (f && s.length === 1) {
|
|
443
490
|
const d = R.isAtZoneStart(n?.placement, t);
|
|
444
|
-
u = d ? 0 :
|
|
491
|
+
u = d ? 0 : c, l = d ? "prepend" : "append";
|
|
445
492
|
} else {
|
|
446
493
|
if (f)
|
|
447
494
|
return null;
|
|
448
495
|
{
|
|
449
496
|
const d = R.getInsertSide(o.placement, t), m = o.index;
|
|
450
|
-
d === "before" ? (u = Math.max(0, m),
|
|
497
|
+
d === "before" ? (u = Math.max(0, m), l = "insert") : d === "after" ? (u = Math.min(c, m + 1), l = "insert") : (u = c, l = "append");
|
|
451
498
|
}
|
|
452
499
|
}
|
|
453
500
|
} else {
|
|
454
501
|
if (!n) return null;
|
|
455
502
|
const f = R.isAtZoneStart(n.placement, t);
|
|
456
|
-
u = f ? 0 :
|
|
503
|
+
u = f ? 0 : c, l = f ? "prepend" : "append";
|
|
457
504
|
}
|
|
458
|
-
return { targetIndex: u, mode:
|
|
505
|
+
return { targetIndex: u, mode: l, targetArr: a };
|
|
459
506
|
}
|
|
460
|
-
function
|
|
507
|
+
function Lt(e, t = "vertical") {
|
|
461
508
|
const { draggedItems: s } = e;
|
|
462
509
|
if (!s.length) return null;
|
|
463
510
|
const n = Ye(e, t);
|
|
464
511
|
if (!n) return null;
|
|
465
512
|
const { targetArr: o, mode: i } = n;
|
|
466
513
|
let { targetIndex: a } = n;
|
|
467
|
-
const r = s.map((
|
|
468
|
-
if (
|
|
469
|
-
const
|
|
470
|
-
a = Math.max(0, a -
|
|
471
|
-
const f = I(
|
|
514
|
+
const r = s.map((l) => l.index), g = s.map((l) => l.item), c = s[0].items;
|
|
515
|
+
if (c === o) {
|
|
516
|
+
const l = r.filter((d) => d < a).length;
|
|
517
|
+
a = Math.max(0, a - l);
|
|
518
|
+
const f = I(Z(c, r), a, g);
|
|
472
519
|
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: a, mode: i, sameList: !0 };
|
|
473
520
|
} else {
|
|
474
|
-
const
|
|
475
|
-
return { sourceItems:
|
|
521
|
+
const l = Z(c, r), f = I(o, a, g);
|
|
522
|
+
return { sourceItems: l, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: a, mode: i, sameList: !1 };
|
|
476
523
|
}
|
|
477
524
|
}
|
|
478
|
-
function
|
|
525
|
+
function Ct(e) {
|
|
479
526
|
const { draggedItems: t, hoveredDraggable: s } = e;
|
|
480
527
|
if (!t.length || !s) return null;
|
|
481
|
-
const n = t.map((u) => u.index), o = s.index, i = t.map((u) => u.item), a = s.item, r = t[0].items, g = s.items,
|
|
482
|
-
if (
|
|
528
|
+
const n = t.map((u) => u.index), o = s.index, i = t.map((u) => u.item), a = s.item, r = t[0].items, g = s.items, c = r === g;
|
|
529
|
+
if (c && n.includes(o)) return null;
|
|
483
530
|
if (t.length === 1) {
|
|
484
531
|
const u = n[0];
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
return { sourceItems:
|
|
532
|
+
if (c) {
|
|
533
|
+
const l = Ve(r, u, o);
|
|
534
|
+
return { sourceItems: l, targetItems: l, sourceIndexes: n, targetIndex: o, sameList: !0 };
|
|
488
535
|
} else {
|
|
489
|
-
const
|
|
490
|
-
return
|
|
536
|
+
const l = [...r], f = [...g];
|
|
537
|
+
return l[u] = g[o], f[o] = r[u], { sourceItems: l, targetItems: f, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
491
538
|
}
|
|
492
539
|
} else {
|
|
493
540
|
const u = Math.min(...n);
|
|
494
|
-
if (
|
|
495
|
-
const
|
|
496
|
-
let h =
|
|
541
|
+
if (c) {
|
|
542
|
+
const l = n.filter((b) => b < o).length, f = Math.max(0, o - l), d = n.filter((b) => b < u).length, m = Math.max(0, u - d);
|
|
543
|
+
let h = Z(r, n);
|
|
497
544
|
h = I(h, f, i);
|
|
498
|
-
const
|
|
499
|
-
return h = I(h,
|
|
545
|
+
const y = m >= f ? m + i.length : m;
|
|
546
|
+
return h = I(h, y, [a]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex: f, sameList: !0 };
|
|
500
547
|
} else {
|
|
501
|
-
const
|
|
502
|
-
let d =
|
|
548
|
+
const l = n.filter((h) => h < u).length, f = Math.max(0, u - l);
|
|
549
|
+
let d = Z(r, n);
|
|
503
550
|
d = I(d, f, [a]);
|
|
504
|
-
let m =
|
|
551
|
+
let m = Le(g, o);
|
|
505
552
|
return m = I(m, o, i), { sourceItems: d, targetItems: m, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
506
553
|
}
|
|
507
554
|
}
|
|
508
555
|
}
|
|
509
|
-
function
|
|
556
|
+
function It(e, t = "vertical") {
|
|
510
557
|
const { draggedItems: s } = e;
|
|
511
558
|
if (!s.length) return null;
|
|
512
559
|
const n = Ye(e, t);
|
|
513
560
|
if (!n) return null;
|
|
514
|
-
const { targetArr: o, targetIndex: i, mode: a } = n, r = s.map((
|
|
561
|
+
const { targetArr: o, targetIndex: i, mode: a } = n, r = s.map((c) => c.item);
|
|
515
562
|
return { targetItems: I(o, i, r), copiedItems: r, targetIndex: i, mode: a };
|
|
516
563
|
}
|
|
517
|
-
function
|
|
564
|
+
function Rt(e) {
|
|
518
565
|
const { draggedItems: t } = e;
|
|
519
566
|
if (!t.length) return null;
|
|
520
567
|
const s = t.map((a) => a.index), n = t.map((a) => a.item), o = t[0].items;
|
|
521
|
-
return { sourceItems:
|
|
568
|
+
return { sourceItems: Z(o, s), removedItems: n, sourceIndexes: s };
|
|
522
569
|
}
|
|
523
|
-
function
|
|
570
|
+
function Xe(e) {
|
|
524
571
|
return {
|
|
525
572
|
// Low-level array ops
|
|
526
573
|
insertAt: I,
|
|
527
|
-
removeAt:
|
|
528
|
-
removeIndexes:
|
|
529
|
-
swapAt:
|
|
574
|
+
removeAt: Le,
|
|
575
|
+
removeIndexes: Z,
|
|
576
|
+
swapAt: Ve,
|
|
530
577
|
// Placement helpers
|
|
531
578
|
getInsertSide: (t, s) => R.getInsertSide(t, s),
|
|
532
579
|
isAtZoneStart: (t, s) => R.isAtZoneStart(t, s),
|
|
533
580
|
isAtZoneEnd: (t, s) => R.isAtZoneEnd(t, s),
|
|
534
581
|
// High-level (event-bound)
|
|
535
|
-
suggestSort: (t) =>
|
|
536
|
-
suggestSwap: () =>
|
|
537
|
-
suggestCopy: (t) =>
|
|
538
|
-
suggestRemove: () =>
|
|
582
|
+
suggestSort: (t) => Lt(e, t),
|
|
583
|
+
suggestSwap: () => Ct(e),
|
|
584
|
+
suggestCopy: (t) => It(e, t),
|
|
585
|
+
suggestRemove: () => Rt(e)
|
|
539
586
|
};
|
|
540
587
|
}
|
|
541
|
-
const
|
|
542
|
-
|
|
588
|
+
const k = (e) => e.keys().next().value, kt = (e) => e.target.closest(
|
|
589
|
+
F.DRAGGABLE
|
|
543
590
|
);
|
|
544
|
-
function
|
|
591
|
+
function Pt(e) {
|
|
545
592
|
const t = e.entities.initiatingDraggable;
|
|
546
593
|
if (!t) return [];
|
|
547
594
|
const s = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t), n = s?.payload;
|
|
@@ -549,30 +596,30 @@ function Rt(e) {
|
|
|
549
596
|
return s?.data ? [{ index: -1, item: void 0, items: [], data: s.data() }] : [];
|
|
550
597
|
const o = n();
|
|
551
598
|
if (!Array.isArray(o) || o.length < 2) return [];
|
|
552
|
-
const [i, a] = o, r = Number(i), g = a,
|
|
553
|
-
return
|
|
599
|
+
const [i, a] = o, r = Number(i), g = a, c = /* @__PURE__ */ new Map();
|
|
600
|
+
return c.set(r, {
|
|
554
601
|
index: r,
|
|
555
602
|
item: g[r],
|
|
556
603
|
items: g,
|
|
557
604
|
data: s?.data?.()
|
|
558
|
-
}), e.entities.draggingMap.forEach((u,
|
|
559
|
-
const f = e.entities.draggableMap.get(
|
|
605
|
+
}), e.entities.draggingMap.forEach((u, l) => {
|
|
606
|
+
const f = e.entities.draggableMap.get(l), d = f?.payload;
|
|
560
607
|
if (!d) return;
|
|
561
608
|
const m = d();
|
|
562
609
|
if (!Array.isArray(m) || m.length < 2) return;
|
|
563
|
-
const [h,
|
|
564
|
-
if (
|
|
610
|
+
const [h, y] = m;
|
|
611
|
+
if (y !== g) return;
|
|
565
612
|
const b = Number(h);
|
|
566
|
-
|
|
613
|
+
c.has(b) || c.set(b, {
|
|
567
614
|
index: b,
|
|
568
|
-
item:
|
|
615
|
+
item: y[b],
|
|
569
616
|
items: g,
|
|
570
617
|
data: f?.data?.()
|
|
571
618
|
});
|
|
572
|
-
}), [...
|
|
619
|
+
}), [...c.values()].sort((u, l) => u.index - l.index);
|
|
573
620
|
}
|
|
574
621
|
const A = (e, t) => {
|
|
575
|
-
const s =
|
|
622
|
+
const s = Pt(e);
|
|
576
623
|
let n, o;
|
|
577
624
|
if (t) {
|
|
578
625
|
const i = e.entities.droppableMap.get(t);
|
|
@@ -584,16 +631,16 @@ const A = (e, t) => {
|
|
|
584
631
|
data: i.data?.()
|
|
585
632
|
};
|
|
586
633
|
}
|
|
587
|
-
const a =
|
|
634
|
+
const a = k(e.hovered.draggable);
|
|
588
635
|
if (a && (a === t || t.contains(a)) && a) {
|
|
589
|
-
const g = e.entities.draggableMap.get(a),
|
|
590
|
-
if (
|
|
591
|
-
const f =
|
|
636
|
+
const g = e.entities.draggableMap.get(a), c = g?.payload, u = e.hovered.draggable.get(a), l = { top: !1, right: !1, bottom: !1, left: !1, center: !1 };
|
|
637
|
+
if (c) {
|
|
638
|
+
const f = c();
|
|
592
639
|
if (Array.isArray(f) && f.length >= 2) {
|
|
593
640
|
const [d, m] = f, h = Number(d);
|
|
594
641
|
o = {
|
|
595
642
|
element: a,
|
|
596
|
-
placement: u ??
|
|
643
|
+
placement: u ?? l,
|
|
597
644
|
index: h,
|
|
598
645
|
item: m[h],
|
|
599
646
|
items: m,
|
|
@@ -602,7 +649,7 @@ const A = (e, t) => {
|
|
|
602
649
|
}
|
|
603
650
|
} else g?.data && (o = {
|
|
604
651
|
element: a,
|
|
605
|
-
placement: u ??
|
|
652
|
+
placement: u ?? l,
|
|
606
653
|
index: -1,
|
|
607
654
|
item: void 0,
|
|
608
655
|
items: [],
|
|
@@ -615,9 +662,9 @@ const A = (e, t) => {
|
|
|
615
662
|
dropZone: n,
|
|
616
663
|
hoveredDraggable: o,
|
|
617
664
|
provider: e,
|
|
618
|
-
helpers:
|
|
665
|
+
helpers: Xe({ draggedItems: s, dropZone: n, hoveredDraggable: o })
|
|
619
666
|
};
|
|
620
|
-
},
|
|
667
|
+
}, T = (e, t, s) => {
|
|
621
668
|
if (!t) return;
|
|
622
669
|
const n = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t);
|
|
623
670
|
!n || n.disabled || n.events?.[s]?.(A(e));
|
|
@@ -626,18 +673,18 @@ const A = (e, t) => {
|
|
|
626
673
|
e.entities.draggingMap.forEach((n) => {
|
|
627
674
|
n.disabled || n.events?.[t]?.(s);
|
|
628
675
|
});
|
|
629
|
-
},
|
|
676
|
+
}, Tt = (e, t, s) => {
|
|
630
677
|
if (t !== s) {
|
|
631
|
-
if (t && !
|
|
678
|
+
if (t && !_(t, e)) {
|
|
632
679
|
const n = A(e, t);
|
|
633
680
|
e.entities.droppableMap.get(t)?.events?.onLeave?.(n);
|
|
634
681
|
}
|
|
635
|
-
if (s && !
|
|
682
|
+
if (s && !_(s, e)) {
|
|
636
683
|
const n = A(e, s);
|
|
637
684
|
e.entities.droppableMap.get(s)?.events?.onEnter?.(n);
|
|
638
685
|
}
|
|
639
686
|
}
|
|
640
|
-
},
|
|
687
|
+
}, zt = (e, t, s) => {
|
|
641
688
|
if (t !== s) {
|
|
642
689
|
const n = A(e);
|
|
643
690
|
if (t) {
|
|
@@ -649,63 +696,16 @@ const A = (e, t) => {
|
|
|
649
696
|
o && !o.disabled && o.events?.onHover?.(n);
|
|
650
697
|
}
|
|
651
698
|
}
|
|
652
|
-
},
|
|
653
|
-
const n =
|
|
699
|
+
}, fe = (e, t, s) => {
|
|
700
|
+
const n = kt(t);
|
|
654
701
|
!n || !e.entities.draggingMap.has(n) || e.entities.draggingMap.get(n)?.events?.[s]?.(A(e));
|
|
655
|
-
},
|
|
656
|
-
const s =
|
|
657
|
-
s && !
|
|
658
|
-
},
|
|
659
|
-
const s =
|
|
660
|
-
s && !
|
|
661
|
-
}
|
|
662
|
-
function zt(e) {
|
|
663
|
-
return e.parentElement?.closest(_.SELECT_AREA) ?? null;
|
|
664
|
-
}
|
|
665
|
-
const Bt = (e, t, s) => {
|
|
666
|
-
if (!s) return {};
|
|
667
|
-
const n = s.getBoundingClientRect(), o = Math.max(n.left, Math.min(e.x, t.x)), i = Math.max(n.top, Math.min(e.y, t.y)), a = Math.min(n.right, Math.max(e.x, t.x)), r = Math.min(n.bottom, Math.max(e.y, t.y)), g = Math.max(0, a - o), l = Math.max(0, r - i), u = o - n.left + s.scrollLeft, c = i - n.top + s.scrollTop;
|
|
668
|
-
return {
|
|
669
|
-
position: "absolute",
|
|
670
|
-
left: `${u}px`,
|
|
671
|
-
top: `${c}px`,
|
|
672
|
-
width: `${g}px`,
|
|
673
|
-
height: `${l}px`,
|
|
674
|
-
pointerEvents: "none",
|
|
675
|
-
border: "1px solid #3b82f6",
|
|
676
|
-
backgroundColor: "#3b82f61a"
|
|
677
|
-
};
|
|
678
|
-
}, Ue = (e) => {
|
|
679
|
-
if (!e.pointer.value || !e.entities.selectingArea) return;
|
|
680
|
-
const { selectingArea: t } = e.entities, s = Ot(
|
|
681
|
-
e.pointer.value.start,
|
|
682
|
-
e.pointer.value.current
|
|
683
|
-
), n = e.entities.selectableAreaMap.get(t)?.groups ?? [], o = e.lib.rectCache;
|
|
684
|
-
e.entities.visibleDraggableSet.forEach((i) => {
|
|
685
|
-
if (i === t || !t.contains(i)) return;
|
|
686
|
-
const a = zt(i);
|
|
687
|
-
if (a && a !== t) {
|
|
688
|
-
e.entities.selectedSet.delete(i);
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
if (xe(i, e)) {
|
|
692
|
-
e.entities.selectedSet.delete(i);
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
const g = e.entities.draggableMap.get(i)?.groups ?? [];
|
|
696
|
-
if (!Ae(n, g)) {
|
|
697
|
-
e.entities.selectedSet.delete(i);
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
let l = o.get(i);
|
|
701
|
-
l || (l = i.getBoundingClientRect(), o.set(i, l));
|
|
702
|
-
const u = e.entities.selectionBase.has(i);
|
|
703
|
-
lt(s, l) ? u ? e.entities.selectedSet.delete(i) : e.entities.selectedSet.add(i) : u ? e.entities.selectedSet.add(i) : e.entities.selectedSet.delete(i);
|
|
704
|
-
});
|
|
705
|
-
}, Ot = (e, t) => {
|
|
706
|
-
const s = Math.min(e.x, t.x), n = Math.min(e.y, t.y), o = Math.max(e.x, t.x), i = Math.max(e.y, t.y), a = o - s, r = i - n;
|
|
707
|
-
return new DOMRect(s, n, a, r);
|
|
708
|
-
}, Ft = (e, t, s = 5) => {
|
|
702
|
+
}, Bt = (e, t) => {
|
|
703
|
+
const s = k(t.droppable);
|
|
704
|
+
s && !_(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
705
|
+
}, Me = (e, t) => {
|
|
706
|
+
const s = k(t.droppable);
|
|
707
|
+
s && !_(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
708
|
+
}, Ot = (e, t, s = 5) => {
|
|
709
709
|
const n = s / 2;
|
|
710
710
|
return {
|
|
711
711
|
left: e - n,
|
|
@@ -713,14 +713,14 @@ const Bt = (e, t, s) => {
|
|
|
713
713
|
width: s,
|
|
714
714
|
height: s
|
|
715
715
|
};
|
|
716
|
-
},
|
|
716
|
+
}, Ft = (e) => {
|
|
717
717
|
const t = e.pointer.value?.current, s = t?.x ?? 0, n = t?.y ?? 0;
|
|
718
|
-
return
|
|
718
|
+
return Ot(s, n, 5);
|
|
719
719
|
}, B = (e, t, s) => {
|
|
720
720
|
const n = e.left + e.width / 2, o = e.top + e.height / 2;
|
|
721
721
|
if (s) {
|
|
722
|
-
const r = s.top ?? 0, g = s.right ?? 0,
|
|
723
|
-
if (
|
|
722
|
+
const r = s.top ?? 0, g = s.right ?? 0, c = s.bottom ?? 0, u = s.left ?? 0, l = t.left + u, f = t.right - g, d = t.top + r, m = t.bottom - c;
|
|
723
|
+
if (l < f && d < m && n >= l && n <= f && o >= d && o <= m)
|
|
724
724
|
return {
|
|
725
725
|
top: !1,
|
|
726
726
|
right: !1,
|
|
@@ -737,28 +737,28 @@ const Bt = (e, t, s) => {
|
|
|
737
737
|
right: n > i,
|
|
738
738
|
center: !1
|
|
739
739
|
};
|
|
740
|
-
},
|
|
740
|
+
}, _t = (e) => ({
|
|
741
741
|
x: e.left + e.width / 2,
|
|
742
742
|
y: e.top + e.height / 2
|
|
743
|
-
}),
|
|
744
|
-
const s =
|
|
743
|
+
}), ke = (e, t) => {
|
|
744
|
+
const s = _t(t);
|
|
745
745
|
return Math.hypot(e.x - s.x, e.y - s.y);
|
|
746
746
|
};
|
|
747
|
-
function
|
|
747
|
+
function Zt(e, t) {
|
|
748
748
|
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
749
|
}
|
|
750
750
|
function W(e, t) {
|
|
751
|
-
|
|
751
|
+
Zt(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
752
752
|
}
|
|
753
|
-
const
|
|
754
|
-
const n =
|
|
753
|
+
const Gt = (e, t) => e.find((s) => s !== t && G(t, s)), ae = (e, t, s) => {
|
|
754
|
+
const n = k(t.droppable), o = k(t.draggable);
|
|
755
755
|
o && t.draggable.delete(o), n && t.droppable.delete(n);
|
|
756
|
-
const i =
|
|
756
|
+
const i = Ft(e), a = s.zones[0], r = s.elements[0];
|
|
757
757
|
if (a && r && a === r && e.entities.droppableMap.has(a) && a) {
|
|
758
|
-
const
|
|
758
|
+
const l = a.getBoundingClientRect(), f = e.entities.draggableMap.get(a)?.placementMargins, d = B(i, l, f);
|
|
759
759
|
if (d.center) {
|
|
760
760
|
t.droppable.set(a, d);
|
|
761
|
-
const m =
|
|
761
|
+
const m = Gt(s.elements, a);
|
|
762
762
|
if (m) {
|
|
763
763
|
const h = m.getBoundingClientRect();
|
|
764
764
|
t.draggable.set(
|
|
@@ -770,55 +770,55 @@ const Kt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
|
770
770
|
t.draggable.set(r, d);
|
|
771
771
|
} else {
|
|
772
772
|
if (a) {
|
|
773
|
-
const
|
|
774
|
-
t.droppable.set(a, B(i,
|
|
773
|
+
const l = a.getBoundingClientRect();
|
|
774
|
+
t.droppable.set(a, B(i, l));
|
|
775
775
|
}
|
|
776
776
|
if (r)
|
|
777
777
|
if (a)
|
|
778
|
-
if (
|
|
779
|
-
const
|
|
778
|
+
if (G(a, r)) {
|
|
779
|
+
const l = r.getBoundingClientRect(), f = e.entities.draggableMap.get(r)?.placementMargins;
|
|
780
780
|
t.draggable.set(
|
|
781
781
|
r,
|
|
782
|
-
B(i,
|
|
782
|
+
B(i, l, f)
|
|
783
783
|
);
|
|
784
784
|
} else {
|
|
785
|
-
const
|
|
786
|
-
if (
|
|
785
|
+
const l = e.pointer.value?.current ?? { x: 0, y: 0 }, f = a.getBoundingClientRect(), d = r.getBoundingClientRect(), m = ke(l, f);
|
|
786
|
+
if (ke(l, d) < m) {
|
|
787
787
|
t.droppable.clear();
|
|
788
|
-
const
|
|
788
|
+
const y = e.entities.draggableMap.get(r)?.placementMargins;
|
|
789
789
|
t.draggable.set(
|
|
790
790
|
r,
|
|
791
|
-
B(i, d,
|
|
791
|
+
B(i, d, y)
|
|
792
792
|
);
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
else {
|
|
796
|
-
const
|
|
796
|
+
const l = r.getBoundingClientRect(), f = e.entities.draggableMap.get(r)?.placementMargins;
|
|
797
797
|
t.draggable.set(
|
|
798
798
|
r,
|
|
799
|
-
B(i,
|
|
799
|
+
B(i, l, f)
|
|
800
800
|
);
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
|
-
const
|
|
803
|
+
const c = k(t.droppable), u = k(t.draggable);
|
|
804
804
|
if (o && o !== u) {
|
|
805
|
-
const
|
|
806
|
-
|
|
805
|
+
const l = e.entities.draggableMap.get(o);
|
|
806
|
+
l && W(l, void 0);
|
|
807
807
|
}
|
|
808
|
-
if (n && n !==
|
|
809
|
-
const
|
|
810
|
-
|
|
808
|
+
if (n && n !== c) {
|
|
809
|
+
const l = e.entities.droppableMap.get(n);
|
|
810
|
+
l && W(l, void 0);
|
|
811
811
|
}
|
|
812
812
|
if (u) {
|
|
813
|
-
const
|
|
814
|
-
|
|
813
|
+
const l = e.entities.draggableMap.get(u);
|
|
814
|
+
l && W(l, t.draggable.get(u));
|
|
815
815
|
}
|
|
816
|
-
if (
|
|
817
|
-
const
|
|
818
|
-
|
|
816
|
+
if (c) {
|
|
817
|
+
const l = e.entities.droppableMap.get(c);
|
|
818
|
+
l && W(l, t.droppable.get(c));
|
|
819
819
|
}
|
|
820
|
-
|
|
821
|
-
},
|
|
820
|
+
Tt(e, n, c), zt(e, o, u);
|
|
821
|
+
}, de = (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, Y = (e) => {
|
|
822
822
|
if (!e)
|
|
823
823
|
return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
|
|
824
824
|
const t = e.getBoundingClientRect();
|
|
@@ -832,10 +832,10 @@ const Kt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
|
832
832
|
right: t.right,
|
|
833
833
|
bottom: t.bottom
|
|
834
834
|
};
|
|
835
|
-
},
|
|
835
|
+
}, N = (e) => ({
|
|
836
836
|
x: e.x + e.width / 2,
|
|
837
837
|
y: e.y + e.height / 2
|
|
838
|
-
}),
|
|
838
|
+
}), Ht = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), Q = (e, t) => {
|
|
839
839
|
const s = Math.max(
|
|
840
840
|
0,
|
|
841
841
|
Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)
|
|
@@ -844,7 +844,7 @@ const Kt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
|
844
844
|
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
|
|
845
845
|
), o = s * n, i = e.width * e.height, a = t.width * t.height;
|
|
846
846
|
return i === 0 || a === 0 ? 0 : (o / i * 100 + o / a * 100) / 2;
|
|
847
|
-
},
|
|
847
|
+
}, Kt = (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, Pe = (e) => {
|
|
848
848
|
const t = e.overlay.position?.value ?? { x: 0, y: 0 }, { x: s, y: n } = t, o = e.overlay.size?.value;
|
|
849
849
|
let i, a;
|
|
850
850
|
if (o)
|
|
@@ -863,99 +863,151 @@ const Kt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
|
863
863
|
right: s + i,
|
|
864
864
|
bottom: n + a
|
|
865
865
|
};
|
|
866
|
-
},
|
|
867
|
-
(s) =>
|
|
868
|
-
),
|
|
866
|
+
}, we = (e) => e.entities.allowedDraggableSet, Ue = (e) => e.entities.allowedDroppableSet, Vt = (e, t) => !t.entities.draggingMap.has(e), Yt = (e, t) => ![...t.entities.draggingMap.keys()].some(
|
|
867
|
+
(s) => G(s, e)
|
|
868
|
+
), Xt = (e, t) => t.entities.draggableMap.has(e) ? !Ee(e, t) : t.entities.droppableMap.has(e) ? !_(e, t) : !0, ee = (e, t) => Vt(e, t) && Yt(e, t) && Xt(e, t), me = 10;
|
|
869
869
|
function O(e, t) {
|
|
870
870
|
return Math.hypot(
|
|
871
871
|
t.x - (e.x + e.width / 2),
|
|
872
872
|
t.y - (e.y + e.height / 2)
|
|
873
873
|
);
|
|
874
874
|
}
|
|
875
|
-
function
|
|
875
|
+
function Ut(e) {
|
|
876
876
|
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, s = document.elementFromPoint(t.x, t.y);
|
|
877
877
|
if (!s) return null;
|
|
878
|
-
const n =
|
|
878
|
+
const n = we(e), o = Ue(e), i = [], a = [];
|
|
879
879
|
let r = s;
|
|
880
880
|
for (; r; )
|
|
881
881
|
(n.has(r) || o.has(r)) && ee(r, e) && (n.has(r) && i.push(r), o.has(r) && a.push(r)), r = r.parentElement;
|
|
882
882
|
return i.length === 0 && a.length === 0 ? null : { elements: i, zones: a };
|
|
883
883
|
}
|
|
884
|
-
const
|
|
885
|
-
if (!
|
|
886
|
-
const s = e.pointer.value?.current ?? { x: 0, y: 0 }, n =
|
|
884
|
+
const ve = (e) => {
|
|
885
|
+
if (!Nt(e)) return { elements: [], zones: [] };
|
|
886
|
+
const s = e.pointer.value?.current ?? { x: 0, y: 0 }, n = Ut(e);
|
|
887
887
|
if (n) {
|
|
888
888
|
if (n.elements.length > 0) return n;
|
|
889
|
-
const
|
|
890
|
-
if (!
|
|
891
|
-
const u =
|
|
892
|
-
return { elements: [...
|
|
893
|
-
(d) =>
|
|
894
|
-
).map((d) => ({ el: d, box:
|
|
895
|
-
({ box: d }) =>
|
|
889
|
+
const c = n.zones[0];
|
|
890
|
+
if (!c) return n;
|
|
891
|
+
const u = Pe(e);
|
|
892
|
+
return { elements: [...we(e)].filter(
|
|
893
|
+
(d) => c.contains(d) && ee(d, e)
|
|
894
|
+
).map((d) => ({ el: d, box: Y(d) })).filter(
|
|
895
|
+
({ box: d }) => de(d, u) && Q(d, u) >= me
|
|
896
896
|
).sort((d, m) => O(d.box, s) - O(m.box, s)).map(({ el: d }) => d), zones: n.zones };
|
|
897
897
|
}
|
|
898
|
-
const o =
|
|
899
|
-
(
|
|
900
|
-
), a = [...
|
|
901
|
-
(
|
|
902
|
-
), r = i.map((
|
|
903
|
-
({ box:
|
|
904
|
-
).sort((
|
|
905
|
-
({ box:
|
|
906
|
-
).sort((
|
|
898
|
+
const o = Pe(e), i = [...we(e)].filter(
|
|
899
|
+
(c) => ee(c, e)
|
|
900
|
+
), a = [...Ue(e)].filter(
|
|
901
|
+
(c) => ee(c, e)
|
|
902
|
+
), r = i.map((c) => ({ n: c, box: Y(c) })).filter(
|
|
903
|
+
({ box: c }) => de(c, o) && Q(c, o) >= me
|
|
904
|
+
).sort((c, u) => O(c.box, s) - O(u.box, s)).map(({ n: c }) => c), g = a.map((c) => ({ n: c, box: Y(c) })).filter(
|
|
905
|
+
({ box: c }) => de(c, o) && Q(c, o) >= me
|
|
906
|
+
).sort((c, u) => O(c.box, s) - O(u.box, s)).map(({ n: c }) => c);
|
|
907
907
|
return { elements: r, zones: g };
|
|
908
908
|
};
|
|
909
|
-
function
|
|
909
|
+
function xe(e) {
|
|
910
910
|
if (e.collision?.run) {
|
|
911
911
|
const s = e.collision.run(e);
|
|
912
912
|
ae(e, e.hovered, s);
|
|
913
913
|
return;
|
|
914
914
|
}
|
|
915
|
-
const t =
|
|
915
|
+
const t = ve(e);
|
|
916
916
|
ae(e, e.hovered, t);
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function $t(e, t) {
|
|
919
919
|
const s = e.collision?.throttle?.value ?? 0;
|
|
920
920
|
if (s <= 0) {
|
|
921
|
-
|
|
921
|
+
xe(e);
|
|
922
922
|
return;
|
|
923
923
|
}
|
|
924
924
|
const n = Date.now();
|
|
925
|
-
n - t.value >= s && (t.value = n,
|
|
925
|
+
n - t.value >= s && (t.value = n, xe(e));
|
|
926
926
|
}
|
|
927
927
|
async function $e(e) {
|
|
928
928
|
const t = e.hovered.droppable.keys().next().value;
|
|
929
|
-
if (!t ||
|
|
930
|
-
const s = e.entities.droppableMap.get(t), n = A(e, t)
|
|
931
|
-
|
|
929
|
+
if (!t || _(t, e)) return "accept";
|
|
930
|
+
const s = e.entities.droppableMap.get(t), n = A(e, t);
|
|
931
|
+
let o = n;
|
|
932
|
+
if (s?.groupMatch === "some" && (s.groups?.length ?? 0) > 0) {
|
|
933
|
+
const r = s.groups, g = /* @__PURE__ */ new Map();
|
|
934
|
+
for (const [l] of e.entities.draggingMap) {
|
|
935
|
+
const f = e.entities.draggableMap.get(l), d = f?.payload?.();
|
|
936
|
+
if (!Array.isArray(d) || d.length < 2) continue;
|
|
937
|
+
const m = Number(d[0]), h = d[1], y = n.draggedItems.find(
|
|
938
|
+
(b) => b.index === m && b.items === h
|
|
939
|
+
);
|
|
940
|
+
y && g.set(y, f?.groups ?? []);
|
|
941
|
+
}
|
|
942
|
+
const c = n.draggedItems.filter(
|
|
943
|
+
(l) => re(g.get(l) ?? [], r)
|
|
944
|
+
), u = n.draggedItems.filter(
|
|
945
|
+
(l) => !c.includes(l)
|
|
946
|
+
);
|
|
947
|
+
if (u.length > 0) {
|
|
948
|
+
const l = (f) => ({
|
|
949
|
+
...n,
|
|
950
|
+
draggedItems: f,
|
|
951
|
+
helpers: Xe({ ...n, draggedItems: f })
|
|
952
|
+
});
|
|
953
|
+
if (s.events?.onValidate) {
|
|
954
|
+
const f = s.events.onValidate({
|
|
955
|
+
validItems: c,
|
|
956
|
+
invalidItems: u,
|
|
957
|
+
dropZone: n.dropZone,
|
|
958
|
+
hoveredDraggable: n.hoveredDraggable
|
|
959
|
+
}), d = f != null && typeof f.then == "function";
|
|
960
|
+
let m;
|
|
961
|
+
if (d) {
|
|
962
|
+
e.state.value = "pending";
|
|
963
|
+
try {
|
|
964
|
+
m = await f;
|
|
965
|
+
} catch {
|
|
966
|
+
const y = e.entities.initiatingDraggable;
|
|
967
|
+
return T(e, y, "onSelfDragCancel"), x(e, "onDragCancel"), Me(e, e.hovered), "cancel";
|
|
968
|
+
}
|
|
969
|
+
} else
|
|
970
|
+
m = f;
|
|
971
|
+
if (m === !1)
|
|
972
|
+
return e.state.value = "dragging", "decline";
|
|
973
|
+
const h = Array.isArray(m) ? m : c;
|
|
974
|
+
if (h.length === 0) return "accept";
|
|
975
|
+
o = l(h);
|
|
976
|
+
} else {
|
|
977
|
+
if (c.length === 0) return "accept";
|
|
978
|
+
o = l(c);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
const i = s?.events?.onDrop?.(o);
|
|
983
|
+
if (i != null && typeof i.then == "function") {
|
|
932
984
|
e.state.value = "pending";
|
|
933
|
-
let
|
|
985
|
+
let r;
|
|
934
986
|
try {
|
|
935
|
-
|
|
987
|
+
r = await i;
|
|
936
988
|
} catch {
|
|
937
|
-
const
|
|
938
|
-
return
|
|
989
|
+
const g = e.entities.initiatingDraggable;
|
|
990
|
+
return T(e, g, "onSelfDragCancel"), x(e, "onDragCancel"), Me(e, e.hovered), "cancel";
|
|
939
991
|
}
|
|
940
|
-
return
|
|
992
|
+
return r === !1 ? (e.state.value = "dragging", "decline") : "accept";
|
|
941
993
|
}
|
|
942
|
-
return
|
|
994
|
+
return i === !1 ? "decline" : "accept";
|
|
943
995
|
}
|
|
944
996
|
function qe(e) {
|
|
945
997
|
const t = e.entities.initiatingDraggable;
|
|
946
|
-
|
|
998
|
+
T(e, t, "onSelfDragEnd"), x(e, "onDragEnd"), Bt(e, e.hovered);
|
|
947
999
|
}
|
|
948
|
-
function
|
|
1000
|
+
function qt(e) {
|
|
949
1001
|
const t = e.entities.selectingArea;
|
|
950
1002
|
if (!t) return;
|
|
951
1003
|
const s = e.entities.selectableAreaMap.get(t), n = [...e.entities.selectedSet];
|
|
952
1004
|
s?.events?.onSelected?.(n);
|
|
953
1005
|
}
|
|
954
|
-
const
|
|
1006
|
+
const Wt = (e) => {
|
|
955
1007
|
const t = {
|
|
956
1008
|
current: null
|
|
957
1009
|
}, s = { value: 0 }, n = async () => {
|
|
958
|
-
|
|
1010
|
+
Se(), t.current?.cancel(), t.current = null;
|
|
959
1011
|
const r = e.state.value;
|
|
960
1012
|
if (r === "dragging") {
|
|
961
1013
|
const g = await $e(e);
|
|
@@ -964,47 +1016,47 @@ const jt = (e) => {
|
|
|
964
1016
|
return;
|
|
965
1017
|
}
|
|
966
1018
|
return;
|
|
967
|
-
} else r === "selecting" &&
|
|
1019
|
+
} else r === "selecting" && qt(e);
|
|
968
1020
|
oe(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
969
1021
|
}, o = (r) => {
|
|
970
|
-
if (e.pointer.value) {
|
|
1022
|
+
if (e.pointer.value && e.state.value !== "pending") {
|
|
971
1023
|
if (e.pointer.value.current = { x: r.clientX, y: r.clientY }, yt(e)) {
|
|
972
|
-
|
|
1024
|
+
fe(e, r, "onSelfDragStart"), x(e, "onDragStart");
|
|
973
1025
|
return;
|
|
974
1026
|
}
|
|
975
1027
|
if (e.state.value === "dragging") {
|
|
976
|
-
|
|
1028
|
+
$t(e, s);
|
|
977
1029
|
const g = e.entities.initiatingDraggable;
|
|
978
|
-
|
|
1030
|
+
T(e, g, "onSelfDragMove"), x(e, "onDragMove");
|
|
979
1031
|
}
|
|
980
|
-
e.state.value === "selecting" &&
|
|
1032
|
+
e.state.value === "selecting" && Ne(e);
|
|
981
1033
|
}
|
|
982
1034
|
};
|
|
983
1035
|
return { pointerDown: (r) => {
|
|
984
1036
|
document.addEventListener("pointerup", n), document.addEventListener("pointermove", o);
|
|
985
|
-
const g = r.target,
|
|
986
|
-
|
|
1037
|
+
const g = r.target, c = g.closest(
|
|
1038
|
+
F.SELECT_AREA
|
|
987
1039
|
), u = g.closest(
|
|
988
|
-
|
|
1040
|
+
F.DRAGGABLE
|
|
989
1041
|
);
|
|
990
|
-
if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(
|
|
991
|
-
|
|
1042
|
+
if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(c)) {
|
|
1043
|
+
pe(), e.pointer.value = De(r), e.state.value = "selecting", e.entities.selectingArea = c, e.entities.selectionBase = new Set(e.entities.selectedSet);
|
|
992
1044
|
return;
|
|
993
1045
|
}
|
|
994
1046
|
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(u)) {
|
|
995
|
-
const
|
|
996
|
-
if (!
|
|
1047
|
+
const l = e.entities.draggableMap.get(u);
|
|
1048
|
+
if (!He(g, u, l?.dragHandle))
|
|
997
1049
|
return;
|
|
998
|
-
|
|
999
|
-
const f =
|
|
1000
|
-
e.pointer.value =
|
|
1001
|
-
se(e),
|
|
1002
|
-
}))) : (se(e),
|
|
1050
|
+
pe(), e.entities.initiatingDraggable = u;
|
|
1051
|
+
const f = Ze(r, u);
|
|
1052
|
+
e.pointer.value = De(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 = pt(e, () => {
|
|
1053
|
+
se(e), fe(e, r, "onSelfDragStart"), x(e, "onDragStart");
|
|
1054
|
+
}))) : (se(e), fe(e, r, "onSelfDragStart"), x(e, "onDragStart"));
|
|
1003
1055
|
}
|
|
1004
1056
|
}, pointerUp: n, pointerMove: o, cleanup: () => {
|
|
1005
1057
|
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();
|
|
1006
1058
|
} };
|
|
1007
|
-
},
|
|
1059
|
+
}, jt = {
|
|
1008
1060
|
ArrowUp: { dx: 0, dy: -1 },
|
|
1009
1061
|
ArrowDown: { dx: 0, dy: 1 },
|
|
1010
1062
|
ArrowLeft: { dx: -1, dy: 0 },
|
|
@@ -1013,33 +1065,33 @@ const jt = (e) => {
|
|
|
1013
1065
|
KeyA: { dx: -1, dy: 0 },
|
|
1014
1066
|
KeyS: { dx: 0, dy: 1 },
|
|
1015
1067
|
KeyD: { dx: 1, dy: 0 }
|
|
1016
|
-
},
|
|
1068
|
+
}, Jt = (e) => (t) => {
|
|
1017
1069
|
const { keys: s } = e.keyboard;
|
|
1018
|
-
if (s.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1070
|
+
if (console.log(t.code), s.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1019
1071
|
if (s.forCancel.includes(t.code)) {
|
|
1020
|
-
t.preventDefault(),
|
|
1072
|
+
t.preventDefault(), Se(), T(
|
|
1021
1073
|
e,
|
|
1022
1074
|
e.entities.initiatingDraggable,
|
|
1023
1075
|
"onSelfDragCancel"
|
|
1024
|
-
), x(e, "onDragCancel"),
|
|
1076
|
+
), x(e, "onDragCancel"), Me(e, e.hovered), oe(e);
|
|
1025
1077
|
return;
|
|
1026
1078
|
}
|
|
1027
1079
|
if (s.forDrop.includes(t.code)) {
|
|
1028
|
-
t.preventDefault(), (async () => (await $e(e) && qe(e),
|
|
1080
|
+
t.preventDefault(), (async () => (await $e(e) && qe(e), Se(), oe(e)))();
|
|
1029
1081
|
return;
|
|
1030
1082
|
}
|
|
1031
|
-
const o =
|
|
1083
|
+
const o = jt[t.code];
|
|
1032
1084
|
if (o && s.forMove.includes(t.code) && e.pointer.value) {
|
|
1033
1085
|
t.preventDefault();
|
|
1034
1086
|
const i = s.forMoveFaster.some(
|
|
1035
|
-
(
|
|
1087
|
+
(c) => s.pressedKeys.value.has(c)
|
|
1036
1088
|
), a = e.keyboard.step * (i ? e.keyboard.moveFaster : 1);
|
|
1037
1089
|
e.pointer.value.current = {
|
|
1038
1090
|
x: e.pointer.value.current.x + o.dx * a,
|
|
1039
1091
|
y: e.pointer.value.current.y + o.dy * a
|
|
1040
1092
|
};
|
|
1041
|
-
const g = (e.collision?.run ??
|
|
1042
|
-
ae(e, e.hovered, g),
|
|
1093
|
+
const g = (e.collision?.run ?? ve)(e);
|
|
1094
|
+
ae(e, e.hovered, g), T(
|
|
1043
1095
|
e,
|
|
1044
1096
|
e.entities.initiatingDraggable,
|
|
1045
1097
|
"onSelfDragMove"
|
|
@@ -1052,49 +1104,49 @@ const jt = (e) => {
|
|
|
1052
1104
|
const o = document.activeElement;
|
|
1053
1105
|
if (!o) return;
|
|
1054
1106
|
const i = o.closest(
|
|
1055
|
-
|
|
1107
|
+
F.DRAGGABLE
|
|
1056
1108
|
);
|
|
1057
1109
|
if (!i || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(i))
|
|
1058
1110
|
return;
|
|
1059
1111
|
const a = e.entities.draggableMap.get(i);
|
|
1060
|
-
if (!
|
|
1112
|
+
if (!He(o, i, a?.dragHandle, !0))
|
|
1061
1113
|
return;
|
|
1062
|
-
t.preventDefault(),
|
|
1063
|
-
const r = i.getBoundingClientRect(), g = r.left + r.width / 2,
|
|
1114
|
+
t.preventDefault(), pe();
|
|
1115
|
+
const r = i.getBoundingClientRect(), g = r.left + r.width / 2, c = r.top + r.height / 2, u = {
|
|
1064
1116
|
clientX: g,
|
|
1065
|
-
clientY:
|
|
1117
|
+
clientY: c
|
|
1066
1118
|
};
|
|
1067
1119
|
e.entities.initiatingDraggable = i;
|
|
1068
|
-
const
|
|
1069
|
-
e.pointer.value =
|
|
1120
|
+
const l = Ze(u, i);
|
|
1121
|
+
e.pointer.value = De(
|
|
1070
1122
|
u,
|
|
1071
|
-
|
|
1072
|
-
|
|
1123
|
+
l.x,
|
|
1124
|
+
l.y
|
|
1073
1125
|
), se(e);
|
|
1074
|
-
const d = (e.collision?.run ??
|
|
1075
|
-
ae(e, e.hovered, d),
|
|
1126
|
+
const d = (e.collision?.run ?? ve)(e);
|
|
1127
|
+
ae(e, e.hovered, d), T(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
1076
1128
|
}
|
|
1077
|
-
},
|
|
1129
|
+
}, Qt = (e) => (t) => {
|
|
1078
1130
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
1079
|
-
},
|
|
1131
|
+
}, en = (e) => () => {
|
|
1080
1132
|
e.keyboard.keys.pressedKeys.value.clear();
|
|
1081
|
-
},
|
|
1082
|
-
keyDown:
|
|
1083
|
-
keyUp:
|
|
1084
|
-
clear:
|
|
1085
|
-
},
|
|
1133
|
+
}, he = {
|
|
1134
|
+
keyDown: Jt,
|
|
1135
|
+
keyUp: Qt,
|
|
1136
|
+
clear: en
|
|
1137
|
+
}, tn = (e) => () => {
|
|
1086
1138
|
if (!e.state.value) return;
|
|
1087
1139
|
const t = e.scrollPosition.x, s = e.scrollPosition.y;
|
|
1088
1140
|
if (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging") {
|
|
1089
|
-
|
|
1141
|
+
xe(e);
|
|
1090
1142
|
return;
|
|
1091
1143
|
}
|
|
1092
1144
|
if (e.state.value === "selecting" && e.pointer.value) {
|
|
1093
1145
|
const n = window.scrollX - t, o = window.scrollY - s;
|
|
1094
|
-
e.pointer.value.start.x -= n, e.pointer.value.start.y -= o,
|
|
1146
|
+
e.pointer.value.start.x -= n, e.pointer.value.start.y -= o, Ne(e);
|
|
1095
1147
|
}
|
|
1096
|
-
}, L = 50,
|
|
1097
|
-
function
|
|
1148
|
+
}, L = 50, nn = 144, Te = 1e3 / nn;
|
|
1149
|
+
function sn(e) {
|
|
1098
1150
|
return e == null ? {
|
|
1099
1151
|
top: L,
|
|
1100
1152
|
right: L,
|
|
@@ -1112,7 +1164,7 @@ function on(e) {
|
|
|
1112
1164
|
left: e.left ?? L
|
|
1113
1165
|
};
|
|
1114
1166
|
}
|
|
1115
|
-
const
|
|
1167
|
+
const on = {
|
|
1116
1168
|
getScrollState(e) {
|
|
1117
1169
|
return {
|
|
1118
1170
|
scrollTop: e.scrollTop,
|
|
@@ -1123,9 +1175,9 @@ const an = {
|
|
|
1123
1175
|
e.scrollTop = t, e.scrollLeft = s;
|
|
1124
1176
|
}
|
|
1125
1177
|
};
|
|
1126
|
-
function We(e, t, s, n =
|
|
1127
|
-
const { speed: i = 10, disabled: a = !1 } = t, r =
|
|
1128
|
-
let g = null,
|
|
1178
|
+
function We(e, t, s, n = on, o) {
|
|
1179
|
+
const { speed: i = 10, disabled: a = !1 } = t, r = sn(t.threshold);
|
|
1180
|
+
let g = null, c = null, u = null, l = 0, f = 0;
|
|
1129
1181
|
const d = (b) => {
|
|
1130
1182
|
o && (o.value = b);
|
|
1131
1183
|
}, m = (b) => {
|
|
@@ -1134,26 +1186,26 @@ function We(e, t, s, n = an, o) {
|
|
|
1134
1186
|
d(!1);
|
|
1135
1187
|
return;
|
|
1136
1188
|
}
|
|
1137
|
-
|
|
1138
|
-
const $ = b -
|
|
1139
|
-
if ($ <
|
|
1189
|
+
c || (c = b);
|
|
1190
|
+
const $ = b - c;
|
|
1191
|
+
if ($ < Te) {
|
|
1140
1192
|
g = requestAnimationFrame(m);
|
|
1141
1193
|
return;
|
|
1142
1194
|
}
|
|
1143
|
-
const
|
|
1144
|
-
|
|
1145
|
-
const { scrollTop: v, scrollLeft:
|
|
1146
|
-
(!u ||
|
|
1147
|
-
let z = !1,
|
|
1148
|
-
r.top > 0 && E.y - u.top < r.top ? (
|
|
1195
|
+
const S = i * ($ / Te);
|
|
1196
|
+
c = b;
|
|
1197
|
+
const { scrollTop: v, scrollLeft: H } = n.getScrollState(w);
|
|
1198
|
+
(!u || l !== v || f !== H) && (u = n.getRect ? n.getRect(w) : w.getBoundingClientRect(), l = v, f = H);
|
|
1199
|
+
let z = !1, ce = v, ge = H;
|
|
1200
|
+
r.top > 0 && E.y - u.top < r.top ? (ce = v - S, z = !0) : r.bottom > 0 && u.bottom - E.y < r.bottom && (ce = v + S, z = !0), r.left > 0 && E.x - u.left < r.left ? (ge = H - S, z = !0) : r.right > 0 && u.right - E.x < r.right && (ge = H + S, z = !0), z && n.setScroll(w, ce, ge), d(z), g = requestAnimationFrame(m);
|
|
1149
1201
|
};
|
|
1150
1202
|
return { run: () => {
|
|
1151
|
-
|
|
1203
|
+
c = null, g = requestAnimationFrame(m);
|
|
1152
1204
|
}, stop: () => {
|
|
1153
|
-
g && (cancelAnimationFrame(g), g = null), u = null,
|
|
1205
|
+
g && (cancelAnimationFrame(g), g = null), u = null, l = 0, f = 0, c = null, d(!1);
|
|
1154
1206
|
} };
|
|
1155
1207
|
}
|
|
1156
|
-
const
|
|
1208
|
+
const an = {
|
|
1157
1209
|
getScrollState() {
|
|
1158
1210
|
return {
|
|
1159
1211
|
scrollTop: window.scrollY ?? document.documentElement.scrollTop,
|
|
@@ -1166,14 +1218,14 @@ const rn = {
|
|
|
1166
1218
|
getRect() {
|
|
1167
1219
|
return new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
1168
1220
|
}
|
|
1169
|
-
},
|
|
1221
|
+
}, rn = {
|
|
1170
1222
|
get value() {
|
|
1171
1223
|
return typeof document < "u" ? document.documentElement : null;
|
|
1172
1224
|
}
|
|
1173
1225
|
};
|
|
1174
|
-
function
|
|
1226
|
+
function ln(e, t) {
|
|
1175
1227
|
const s = te(!1), o = We(
|
|
1176
|
-
|
|
1228
|
+
rn,
|
|
1177
1229
|
t ?? {},
|
|
1178
1230
|
() => {
|
|
1179
1231
|
if (e.state.value !== "dragging") return null;
|
|
@@ -1183,7 +1235,7 @@ function cn(e, t) {
|
|
|
1183
1235
|
y: r.y + g.height / 2
|
|
1184
1236
|
} : r : null;
|
|
1185
1237
|
},
|
|
1186
|
-
|
|
1238
|
+
an,
|
|
1187
1239
|
s
|
|
1188
1240
|
), i = ie(
|
|
1189
1241
|
() => e.state.value,
|
|
@@ -1195,29 +1247,29 @@ function cn(e, t) {
|
|
|
1195
1247
|
};
|
|
1196
1248
|
return Je(a), { isScrolling: s, stop: a };
|
|
1197
1249
|
}
|
|
1198
|
-
const
|
|
1199
|
-
const t =
|
|
1250
|
+
const cn = (e) => {
|
|
1251
|
+
const t = Wt(e), s = he.keyDown(e), n = he.keyUp(e), o = he.clear(e), i = tn(e);
|
|
1200
1252
|
let a = null;
|
|
1201
1253
|
ie(
|
|
1202
1254
|
e.autoScrollViewport,
|
|
1203
1255
|
(r) => {
|
|
1204
|
-
a?.(), a = null, (r === !0 || r && typeof r == "object") && (a =
|
|
1256
|
+
a?.(), a = null, (r === !0 || r && typeof r == "object") && (a = ln(
|
|
1205
1257
|
e,
|
|
1206
1258
|
r === !0 ? {} : r
|
|
1207
1259
|
).stop);
|
|
1208
1260
|
},
|
|
1209
1261
|
{ immediate: !0 }
|
|
1210
|
-
),
|
|
1262
|
+
), X(() => {
|
|
1211
1263
|
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", s), document.addEventListener("keyup", n), document.addEventListener("blur", o), document.addEventListener("scroll", i, !0);
|
|
1212
|
-
}),
|
|
1264
|
+
}), U(() => {
|
|
1213
1265
|
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", i, !0), a?.(), t.cleanup();
|
|
1214
1266
|
});
|
|
1215
|
-
},
|
|
1216
|
-
const e = Oe(
|
|
1267
|
+
}, le = () => {
|
|
1268
|
+
const e = Oe(Ae);
|
|
1217
1269
|
if (!e) throw Error("DnD provider not found");
|
|
1218
1270
|
return e;
|
|
1219
1271
|
}, je = () => {
|
|
1220
|
-
const e =
|
|
1272
|
+
const e = le();
|
|
1221
1273
|
return {
|
|
1222
1274
|
overlay: e.overlay,
|
|
1223
1275
|
delay: e.delay,
|
|
@@ -1231,23 +1283,23 @@ const gn = (e) => {
|
|
|
1231
1283
|
collision: e.collision,
|
|
1232
1284
|
autoScrollViewport: e.autoScrollViewport
|
|
1233
1285
|
};
|
|
1234
|
-
},
|
|
1286
|
+
}, gn = /* @__PURE__ */ Fe({
|
|
1235
1287
|
__name: "DefaultOverlay",
|
|
1236
1288
|
setup(e) {
|
|
1237
1289
|
const { entities: t, state: s, overlay: n } = je();
|
|
1238
|
-
return (o, i) =>
|
|
1290
|
+
return (o, i) => V(s) === "dragging" ? (C(), J("div", {
|
|
1239
1291
|
key: 0,
|
|
1240
1292
|
class: "dnd-kit-default-overlay",
|
|
1241
|
-
style:
|
|
1242
|
-
"--position-x":
|
|
1243
|
-
"--position-y":
|
|
1293
|
+
style: Ce({
|
|
1294
|
+
"--position-x": V(n).position.value.x + "px",
|
|
1295
|
+
"--position-y": V(n).position.value.y + "px"
|
|
1244
1296
|
})
|
|
1245
1297
|
}, [
|
|
1246
|
-
(C(!0), J(
|
|
1247
|
-
|
|
1298
|
+
(C(!0), J(be, null, Qe(V(t).draggingMap, ([a, r]) => (C(), J(be, null, [
|
|
1299
|
+
r.render ? (C(), ne(ye(r.render), { key: 0 })) : (C(), ne(ye(a.tagName), {
|
|
1248
1300
|
key: 1,
|
|
1249
1301
|
innerHTML: r.initialOuterHTML,
|
|
1250
|
-
style:
|
|
1302
|
+
style: Ce({
|
|
1251
1303
|
width: r.initialRect.width + "px",
|
|
1252
1304
|
height: r.initialRect.height + "px"
|
|
1253
1305
|
})
|
|
@@ -1255,7 +1307,7 @@ const gn = (e) => {
|
|
|
1255
1307
|
], 64))), 256))
|
|
1256
1308
|
], 4)) : et("", !0);
|
|
1257
1309
|
}
|
|
1258
|
-
}),
|
|
1310
|
+
}), mn = /* @__PURE__ */ Fe({
|
|
1259
1311
|
__name: "DnDProvider",
|
|
1260
1312
|
props: {
|
|
1261
1313
|
autoScrollViewport: { type: [Object, Boolean, null] },
|
|
@@ -1265,54 +1317,54 @@ const gn = (e) => {
|
|
|
1265
1317
|
},
|
|
1266
1318
|
setup(e) {
|
|
1267
1319
|
const t = e, s = tt("overlayRef"), n = vt(s, t);
|
|
1268
|
-
|
|
1269
|
-
const o =
|
|
1270
|
-
() => n.overlay.render.value ??
|
|
1320
|
+
cn(n);
|
|
1321
|
+
const o = p(
|
|
1322
|
+
() => n.overlay.render.value ?? gn
|
|
1271
1323
|
);
|
|
1272
|
-
return nt(
|
|
1273
|
-
|
|
1324
|
+
return nt(Ae, n), (i, a) => (C(), J(be, null, [
|
|
1325
|
+
Ie(i.$slots, "default"),
|
|
1274
1326
|
(C(), ne(st, {
|
|
1275
|
-
to:
|
|
1327
|
+
to: V(n).overlay.to.value || "body"
|
|
1276
1328
|
}, [
|
|
1277
1329
|
ot("div", at({
|
|
1278
1330
|
ref_key: "overlayRef",
|
|
1279
1331
|
ref: s,
|
|
1280
1332
|
class: "dnd-kit-overlay-container"
|
|
1281
1333
|
}, t), [
|
|
1282
|
-
|
|
1283
|
-
(C(), ne(
|
|
1334
|
+
Ie(i.$slots, "overlay", { overlay: o.value }, () => [
|
|
1335
|
+
(C(), ne(ye(o.value)))
|
|
1284
1336
|
])
|
|
1285
1337
|
], 16)
|
|
1286
1338
|
], 8, ["to"]))
|
|
1287
1339
|
], 64));
|
|
1288
1340
|
}
|
|
1289
1341
|
});
|
|
1290
|
-
function
|
|
1291
|
-
const n =
|
|
1342
|
+
function hn(e, t, s) {
|
|
1343
|
+
const n = le();
|
|
1292
1344
|
let o, i, a;
|
|
1293
1345
|
typeof t == "function" ? (o = {}, i = t) : (o = t ?? {}, i = s);
|
|
1294
|
-
const r =
|
|
1346
|
+
const r = p({
|
|
1295
1347
|
get() {
|
|
1296
|
-
const
|
|
1297
|
-
return
|
|
1348
|
+
const l = D(e);
|
|
1349
|
+
return l ? n.entities.selectedSet.has(l) : !1;
|
|
1298
1350
|
},
|
|
1299
|
-
set(
|
|
1351
|
+
set(l) {
|
|
1300
1352
|
const f = D(e);
|
|
1301
|
-
f && n.entities.selectedSet[
|
|
1353
|
+
f && n.entities.selectedSet[l ? "add" : "delete"](f);
|
|
1302
1354
|
}
|
|
1303
|
-
}), g =
|
|
1304
|
-
const
|
|
1305
|
-
return
|
|
1306
|
-
}),
|
|
1307
|
-
const
|
|
1308
|
-
return
|
|
1309
|
-
}), u =
|
|
1310
|
-
const
|
|
1311
|
-
if (
|
|
1312
|
-
return n.entities.draggableMap.get(
|
|
1355
|
+
}), g = p(() => {
|
|
1356
|
+
const l = D(e);
|
|
1357
|
+
return l ? n.entities.draggingMap.has(l) : !1;
|
|
1358
|
+
}), c = p(() => {
|
|
1359
|
+
const l = D(e);
|
|
1360
|
+
return l ? n.entities.allowedDraggableSet.has(l) : !1;
|
|
1361
|
+
}), u = p(() => {
|
|
1362
|
+
const l = D(e);
|
|
1363
|
+
if (l)
|
|
1364
|
+
return n.entities.draggableMap.get(l)?.hoveredPlacement;
|
|
1313
1365
|
});
|
|
1314
|
-
return
|
|
1315
|
-
a = D(e), a && (a.addEventListener("dragstart", M), a.addEventListener("drag", M), a.addEventListener("dragend", M), a.setAttribute(
|
|
1366
|
+
return X(() => {
|
|
1367
|
+
a = D(e), a && (a.addEventListener("dragstart", M), a.addEventListener("drag", M), a.addEventListener("dragend", M), a.setAttribute(P.DRAGGABLE, ""), n.lib.draggableObserver.observe(a), n.entities.draggableMap.set(a, {
|
|
1316
1368
|
render: o.render,
|
|
1317
1369
|
disabled: o.disabled ?? !1,
|
|
1318
1370
|
groups: o.groups ?? [],
|
|
@@ -1325,20 +1377,20 @@ function bn(e, t, s) {
|
|
|
1325
1377
|
placementMargins: o.placementMargins,
|
|
1326
1378
|
hoveredPlacement: void 0
|
|
1327
1379
|
}));
|
|
1328
|
-
}),
|
|
1380
|
+
}), U(() => {
|
|
1329
1381
|
a && (n.lib.draggableObserver.unobserve(a), n.entities.visibleDraggableSet.delete(a), n.entities.draggableMap.delete(a), n.entities.modifiersDraggableSet.delete(a));
|
|
1330
1382
|
}), {
|
|
1331
1383
|
selected: r,
|
|
1332
1384
|
isDragging: g,
|
|
1333
|
-
isAllowed:
|
|
1385
|
+
isAllowed: c,
|
|
1334
1386
|
isDragOver: u
|
|
1335
1387
|
};
|
|
1336
1388
|
}
|
|
1337
|
-
const
|
|
1338
|
-
const s =
|
|
1389
|
+
const bn = (e, t) => {
|
|
1390
|
+
const s = le(), n = p(() => e.value === s.entities.selectingArea);
|
|
1339
1391
|
let o = null;
|
|
1340
|
-
|
|
1341
|
-
o = D(e), o && (o.setAttribute(
|
|
1392
|
+
X(() => {
|
|
1393
|
+
o = D(e), o && (o.setAttribute(P.SELECT_AREA, ""), s.lib.selectableAreaObserver.observe(o), s.entities.selectableAreaMap.set(o, {
|
|
1342
1394
|
modifier: t?.modifier ?? {
|
|
1343
1395
|
keys: ["ControlLeft"],
|
|
1344
1396
|
method: "every"
|
|
@@ -1347,61 +1399,62 @@ const yn = (e, t) => {
|
|
|
1347
1399
|
disabled: t?.disabled ?? !1,
|
|
1348
1400
|
groups: t?.groups ?? []
|
|
1349
1401
|
}));
|
|
1350
|
-
}),
|
|
1402
|
+
}), U(() => {
|
|
1351
1403
|
o && (s.lib.selectableAreaObserver.unobserve(o), s.entities.visibleSelectableAreaSet.delete(o), s.entities.modifiersSelectableAreaSet.delete(o), s.entities.selectableAreaMap.delete(o));
|
|
1352
1404
|
});
|
|
1353
|
-
const i =
|
|
1405
|
+
const i = p(() => {
|
|
1354
1406
|
s.scrollPosition.x, s.scrollPosition.y;
|
|
1355
1407
|
const a = s.pointer.value;
|
|
1356
|
-
return !a || s.state.value !== "selecting" || !o || !n.value ? {} :
|
|
1408
|
+
return !a || s.state.value !== "selecting" || !o || !n.value ? {} : At(a.start, a.current, o);
|
|
1357
1409
|
});
|
|
1358
1410
|
return {
|
|
1359
1411
|
isSelecting: n,
|
|
1360
1412
|
style: i
|
|
1361
1413
|
};
|
|
1362
1414
|
};
|
|
1363
|
-
function
|
|
1364
|
-
const s = Oe(
|
|
1415
|
+
function yn(e, t) {
|
|
1416
|
+
const s = Oe(Ae);
|
|
1365
1417
|
if (!s) throw Error("DnD provider not found");
|
|
1366
1418
|
let n = null;
|
|
1367
|
-
return
|
|
1368
|
-
n = D(e), n && (n.setAttribute(
|
|
1419
|
+
return X(() => {
|
|
1420
|
+
n = D(e), n && (n.setAttribute(P.CONSTRAINT_AREA, ""), s.entities.constraintsAreaMap.set(n, {
|
|
1369
1421
|
axis: t?.axis || "both",
|
|
1370
1422
|
restrictToArea: t?.restrictToArea || !1
|
|
1371
1423
|
}));
|
|
1372
|
-
}),
|
|
1424
|
+
}), U(() => {
|
|
1373
1425
|
n && s.entities.constraintsAreaMap.delete(n);
|
|
1374
1426
|
}), {};
|
|
1375
1427
|
}
|
|
1376
|
-
function
|
|
1377
|
-
const n =
|
|
1428
|
+
function pn(e, t, s) {
|
|
1429
|
+
const n = le();
|
|
1378
1430
|
let o = null, i, a;
|
|
1379
1431
|
typeof t == "function" ? (i = {}, a = t) : (i = t ?? {}, a = s);
|
|
1380
|
-
const r =
|
|
1381
|
-
const
|
|
1382
|
-
return
|
|
1383
|
-
}), g =
|
|
1384
|
-
const
|
|
1385
|
-
if (
|
|
1386
|
-
return n.entities.droppableMap.get(
|
|
1432
|
+
const r = p(() => {
|
|
1433
|
+
const c = D(e);
|
|
1434
|
+
return c ? n.entities.allowedDroppableSet.has(c) : !1;
|
|
1435
|
+
}), g = p(() => {
|
|
1436
|
+
const c = D(e);
|
|
1437
|
+
if (c)
|
|
1438
|
+
return n.entities.droppableMap.get(c)?.hoveredPlacement;
|
|
1387
1439
|
});
|
|
1388
|
-
return
|
|
1389
|
-
o = D(e), o && (o.setAttribute(
|
|
1440
|
+
return X(() => {
|
|
1441
|
+
o = D(e), o && (o.setAttribute(P.DROPPABLE, ""), n.lib.droppableObserver.observe(o), n.entities.droppableMap.set(o, {
|
|
1390
1442
|
disabled: i.disabled ?? !1,
|
|
1391
1443
|
groups: i.groups ?? [],
|
|
1444
|
+
groupMatch: i.groupMatch ?? "every",
|
|
1392
1445
|
events: i.events,
|
|
1393
1446
|
payload: a,
|
|
1394
1447
|
data: i.data,
|
|
1395
1448
|
hoveredPlacement: void 0
|
|
1396
1449
|
}));
|
|
1397
|
-
}),
|
|
1450
|
+
}), U(() => {
|
|
1398
1451
|
o && (n.lib.droppableObserver.unobserve(o), n.entities.visibleDroppableSet.delete(o), n.entities.droppableMap.delete(o));
|
|
1399
1452
|
}), {
|
|
1400
1453
|
isAllowed: r,
|
|
1401
1454
|
isDragOver: g
|
|
1402
1455
|
};
|
|
1403
1456
|
}
|
|
1404
|
-
const
|
|
1457
|
+
const Sn = (e, t) => {
|
|
1405
1458
|
const s = je(), n = te(!1), i = We(
|
|
1406
1459
|
e,
|
|
1407
1460
|
t ?? {},
|
|
@@ -1422,54 +1475,40 @@ const Dn = (e, t) => {
|
|
|
1422
1475
|
a === "dragging" ? i.run() : i.stop();
|
|
1423
1476
|
}
|
|
1424
1477
|
), { isScrolling: n };
|
|
1425
|
-
}
|
|
1426
|
-
function Te(e, t) {
|
|
1427
|
-
return t <= 0 ? e : Math.round(e / t) * t;
|
|
1428
|
-
}
|
|
1429
|
-
function Mn(e, t) {
|
|
1430
|
-
const s = t && "grid" in t && t.grid != null, n = t ? s ? t.grid : t.gridX : 1, o = t ? s ? t.grid : t.gridY : 1;
|
|
1431
|
-
return y(() => {
|
|
1432
|
-
const { x: i, y: a } = e.value;
|
|
1433
|
-
return {
|
|
1434
|
-
x: Te(i, n),
|
|
1435
|
-
y: Te(a, o)
|
|
1436
|
-
};
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1439
|
-
const ze = () => !0, Be = () => 0, fn = "separate", dn = () => {
|
|
1478
|
+
}, ze = () => !0, Be = () => 0, un = "separate", fn = () => {
|
|
1440
1479
|
const e = {
|
|
1441
1480
|
filterElements: ze,
|
|
1442
1481
|
filterZones: ze,
|
|
1443
1482
|
sortElements: Be,
|
|
1444
1483
|
sortZones: Be,
|
|
1445
|
-
mergeStrategy:
|
|
1484
|
+
mergeStrategy: un,
|
|
1446
1485
|
pickClosestBetweenFirst: !1
|
|
1447
|
-
}, t = (n, o, i, a, r, g,
|
|
1448
|
-
const u = a instanceof Set ? a : new Set(a),
|
|
1486
|
+
}, t = (n, o, i, a, r, g, c) => {
|
|
1487
|
+
const u = a instanceof Set ? a : new Set(a), l = { containerBox: o, pointer: i }, f = e.minOverlapPercent, d = [];
|
|
1449
1488
|
for (const m of u) {
|
|
1450
1489
|
if (!r(m, n)) continue;
|
|
1451
|
-
const h =
|
|
1452
|
-
if (!
|
|
1453
|
-
const
|
|
1454
|
-
if (f !== void 0 &&
|
|
1490
|
+
const h = Y(m);
|
|
1491
|
+
if (!c(h, l)) continue;
|
|
1492
|
+
const y = Q(h, o);
|
|
1493
|
+
if (f !== void 0 && y < f) continue;
|
|
1455
1494
|
let b = 0;
|
|
1456
1495
|
for (const w of u)
|
|
1457
|
-
w !== m &&
|
|
1496
|
+
w !== m && G(w, m) && b++;
|
|
1458
1497
|
d.push({
|
|
1459
1498
|
node: m,
|
|
1460
1499
|
box: h,
|
|
1461
1500
|
meta: {
|
|
1462
|
-
isPointerInElement:
|
|
1463
|
-
overlapPercent:
|
|
1501
|
+
isPointerInElement: Kt(h, i.x, i.y),
|
|
1502
|
+
overlapPercent: y,
|
|
1464
1503
|
depth: b,
|
|
1465
|
-
centerDistance:
|
|
1466
|
-
|
|
1467
|
-
|
|
1504
|
+
centerDistance: Ht(
|
|
1505
|
+
N(o),
|
|
1506
|
+
N(h)
|
|
1468
1507
|
)
|
|
1469
1508
|
}
|
|
1470
1509
|
});
|
|
1471
1510
|
}
|
|
1472
|
-
return d.sort((m, h) => g(m, h,
|
|
1511
|
+
return d.sort((m, h) => g(m, h, l)), d;
|
|
1473
1512
|
}, s = {
|
|
1474
1513
|
container(n) {
|
|
1475
1514
|
return e.container = n, s;
|
|
@@ -1516,7 +1555,7 @@ const ze = () => !0, Be = () => 0, fn = "separate", dn = () => {
|
|
|
1516
1555
|
return (o) => {
|
|
1517
1556
|
const i = n.container(o);
|
|
1518
1557
|
if (!i) return { elements: [], zones: [] };
|
|
1519
|
-
const a = n.containerBox ? n.containerBox(o) :
|
|
1558
|
+
const a = n.containerBox ? n.containerBox(o) : Y(i), r = o.pointer.value?.current ?? { x: 0, y: 0 }, g = t(
|
|
1520
1559
|
o,
|
|
1521
1560
|
a,
|
|
1522
1561
|
r,
|
|
@@ -1524,7 +1563,7 @@ const ze = () => !0, Be = () => 0, fn = "separate", dn = () => {
|
|
|
1524
1563
|
n.filterElements,
|
|
1525
1564
|
n.sortElements,
|
|
1526
1565
|
n.collision
|
|
1527
|
-
),
|
|
1566
|
+
), c = t(
|
|
1528
1567
|
o,
|
|
1529
1568
|
a,
|
|
1530
1569
|
r,
|
|
@@ -1541,7 +1580,7 @@ const ze = () => !0, Be = () => 0, fn = "separate", dn = () => {
|
|
|
1541
1580
|
isZone: !1,
|
|
1542
1581
|
distance: 0
|
|
1543
1582
|
})),
|
|
1544
|
-
...
|
|
1583
|
+
...c.map((f) => ({
|
|
1545
1584
|
node: f.node,
|
|
1546
1585
|
box: f.box,
|
|
1547
1586
|
isZone: !0,
|
|
@@ -1550,45 +1589,44 @@ const ze = () => !0, Be = () => 0, fn = "separate", dn = () => {
|
|
|
1550
1589
|
];
|
|
1551
1590
|
if (u.length === 0) return { elements: [], zones: [] };
|
|
1552
1591
|
for (const f of u) {
|
|
1553
|
-
const d =
|
|
1592
|
+
const d = N(f.box);
|
|
1554
1593
|
f.distance = Math.hypot(
|
|
1555
1594
|
r.x - d.x,
|
|
1556
1595
|
r.y - d.y
|
|
1557
1596
|
);
|
|
1558
1597
|
}
|
|
1559
|
-
const
|
|
1598
|
+
const l = u.reduce(
|
|
1560
1599
|
(f, d) => d.distance < f.distance ? d : f
|
|
1561
1600
|
);
|
|
1562
|
-
return
|
|
1601
|
+
return l.isZone ? { elements: [], zones: [l.node] } : { elements: [l.node], zones: [] };
|
|
1563
1602
|
}
|
|
1564
|
-
if (n.pickClosestBetweenFirst && g[0] &&
|
|
1565
|
-
const u =
|
|
1603
|
+
if (n.pickClosestBetweenFirst && g[0] && c[0]) {
|
|
1604
|
+
const u = N(c[0].box), l = N(g[0].box), f = Math.hypot(
|
|
1566
1605
|
r.x - u.x,
|
|
1567
1606
|
r.y - u.y
|
|
1568
1607
|
);
|
|
1569
1608
|
return Math.hypot(
|
|
1570
|
-
r.x -
|
|
1571
|
-
r.y -
|
|
1572
|
-
) < f ? { elements: g.map((m) => m.node), zones: [] } : { elements: [], zones:
|
|
1609
|
+
r.x - l.x,
|
|
1610
|
+
r.y - l.y
|
|
1611
|
+
) < f ? { elements: g.map((m) => m.node), zones: [] } : { elements: [], zones: c.map((m) => m.node) };
|
|
1573
1612
|
}
|
|
1574
1613
|
return {
|
|
1575
1614
|
elements: g.map((u) => u.node),
|
|
1576
|
-
zones:
|
|
1615
|
+
zones: c.map((u) => u.node)
|
|
1577
1616
|
};
|
|
1578
1617
|
};
|
|
1579
1618
|
}
|
|
1580
1619
|
};
|
|
1581
1620
|
return s;
|
|
1582
|
-
},
|
|
1621
|
+
}, Dn = () => fn();
|
|
1583
1622
|
export {
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
Mn as makeSnappedOverlayPosition,
|
|
1623
|
+
mn as DnDProvider,
|
|
1624
|
+
Dn as createSensor,
|
|
1625
|
+
ve as defaultCollisionDetection,
|
|
1626
|
+
Sn as makeAutoScroll,
|
|
1627
|
+
yn as makeConstraintArea,
|
|
1628
|
+
hn as makeDraggable,
|
|
1629
|
+
pn as makeDroppable,
|
|
1630
|
+
bn as makeSelectionArea,
|
|
1593
1631
|
je as useDnDProvider
|
|
1594
1632
|
};
|