@vue-dnd-kit/core 2.0.10 → 2.0.11
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/vue-dnd-kit-core.cjs.js +2 -2
- package/dist/vue-dnd-kit-core.es.js +214 -215
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
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)}
|
|
2
|
-
import { ref as j, watch as ie, shallowRef as te, reactive as q, computed as y, onScopeDispose as
|
|
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 y, onScopeDispose as Je, onMounted as U, onBeforeUnmount as V, inject as Oe, defineComponent as Fe, unref as k, openBlock as C, createElementBlock as J, normalizeStyle as Le, Fragment as he, renderList as Qe, createBlock as ne, resolveDynamicComponent as be, createCommentVNode as et, useTemplateRef as tt, provide as nt, renderSlot as Ce, Teleport as st, createElementVNode as ot, mergeProps as at } from "vue";
|
|
3
3
|
const T = {
|
|
4
4
|
SELECT_AREA: "data-dnd-kit-select-area",
|
|
5
5
|
DRAGGABLE: "data-dnd-kit-draggable",
|
|
@@ -9,7 +9,7 @@ const T = {
|
|
|
9
9
|
SELECT_AREA: `[${T.SELECT_AREA}]`,
|
|
10
10
|
DRAGGABLE: `[${T.DRAGGABLE}]`,
|
|
11
11
|
CONSTRAINT_AREA: `[${T.CONSTRAINT_AREA}]`
|
|
12
|
-
}, ve = "VueDnDKitProvider",
|
|
12
|
+
}, ve = "VueDnDKitProvider", Ie = (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;
|
|
@@ -22,13 +22,13 @@ const T = {
|
|
|
22
22
|
g[l]((c) => s.value.has(c)) && o.add(i);
|
|
23
23
|
}), o;
|
|
24
24
|
};
|
|
25
|
-
let
|
|
26
|
-
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, K = (e, t) => e !== t && e.contains(t),
|
|
25
|
+
let _e = "", it = "", rt = "";
|
|
26
|
+
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, K = (e, t) => e !== t && e.contains(t), lt = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), ye = () => {
|
|
27
27
|
const e = document.body;
|
|
28
|
-
|
|
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
|
}, pe = () => {
|
|
30
30
|
const e = document.body;
|
|
31
|
-
e.style.userSelect =
|
|
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
32
|
}, M = (e) => e.preventDefault(), xe = (e, t) => {
|
|
33
33
|
if (t.entities.draggableMap.get(e)?.disabled) return !0;
|
|
34
34
|
for (const n of t.entities.visibleDraggableSet)
|
|
@@ -44,7 +44,7 @@ const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$e
|
|
|
44
44
|
const s = new Set(t);
|
|
45
45
|
return e.some((n) => s.has(n));
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function ct(e, t, s, n) {
|
|
48
48
|
const o = /* @__PURE__ */ new Set();
|
|
49
49
|
for (const r of t.keys()) {
|
|
50
50
|
const g = s.get(r);
|
|
@@ -57,7 +57,7 @@ function gt(e, t, s, n) {
|
|
|
57
57
|
}
|
|
58
58
|
return a;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function gt(e, t, s) {
|
|
61
61
|
const n = /* @__PURE__ */ new Set();
|
|
62
62
|
for (const a of t.keys()) {
|
|
63
63
|
const r = s.get(a);
|
|
@@ -82,7 +82,7 @@ const ge = (e) => {
|
|
|
82
82
|
unobserve: (s) => t.unobserve(s),
|
|
83
83
|
disconnect: () => t.disconnect()
|
|
84
84
|
};
|
|
85
|
-
},
|
|
85
|
+
}, ut = (e) => {
|
|
86
86
|
const t = new ResizeObserver((s) => {
|
|
87
87
|
const n = s[0];
|
|
88
88
|
if (!n) return;
|
|
@@ -94,8 +94,8 @@ const ge = (e) => {
|
|
|
94
94
|
unobserve: (s) => t.unobserve(s),
|
|
95
95
|
disconnect: () => t.disconnect()
|
|
96
96
|
};
|
|
97
|
-
},
|
|
98
|
-
const t = j(null), s =
|
|
97
|
+
}, ft = (e) => {
|
|
98
|
+
const t = j(null), s = ut(t), n = ie(
|
|
99
99
|
e,
|
|
100
100
|
(i) => {
|
|
101
101
|
s.disconnect(), i && s.observe(i);
|
|
@@ -115,11 +115,11 @@ function Se(e, t = 0, s = 0) {
|
|
|
115
115
|
offset: { x: t, y: s }
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function Ge(e, t) {
|
|
119
119
|
const s = t.getBoundingClientRect(), n = s.width > 0 ? (e.clientX - s.left) / s.width : 0.5, o = s.height > 0 ? (e.clientY - s.top) / s.height : 0.5;
|
|
120
120
|
return { x: n, y: o };
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function He(e, t) {
|
|
123
123
|
return {
|
|
124
124
|
...t,
|
|
125
125
|
initialHTML: e.innerHTML,
|
|
@@ -127,34 +127,34 @@ function Ke(e, t) {
|
|
|
127
127
|
initialOuterHTML: e.outerHTML
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function dt(e, t, s) {
|
|
131
131
|
e.forEach((n) => {
|
|
132
132
|
const o = t.get(n);
|
|
133
|
-
s.set(n,
|
|
133
|
+
s.set(n, He(n, o));
|
|
134
134
|
}), e.clear();
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function mt(e, t, s) {
|
|
137
137
|
s.clear();
|
|
138
138
|
const n = t.get(e);
|
|
139
|
-
s.set(e,
|
|
139
|
+
s.set(e, He(e, n));
|
|
140
140
|
}
|
|
141
141
|
function se(e) {
|
|
142
|
-
e.entities.initiatingDraggable && (e.state.value = "dragging",
|
|
142
|
+
e.entities.initiatingDraggable && (e.state.value = "dragging", ht(
|
|
143
143
|
e.entities.initiatingDraggable,
|
|
144
144
|
e.entities.selectedSet,
|
|
145
145
|
e.entities.draggableMap,
|
|
146
146
|
e.entities.draggingMap
|
|
147
147
|
));
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
t.has(e) ?
|
|
149
|
+
function ht(e, t, s, n) {
|
|
150
|
+
t.has(e) ? dt(t, s, n) : (t.clear(), mt(e, s, n));
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function Ke(e, t, s, n) {
|
|
153
153
|
if (n || !s) return !0;
|
|
154
154
|
const o = e.closest(s);
|
|
155
155
|
return o ? t.contains(o) : !1;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function bt(e, t) {
|
|
158
158
|
if (!e || !t) return 1;
|
|
159
159
|
const s = Math.abs(e.current.x - e.start.x), n = Math.abs(e.current.y - e.start.y);
|
|
160
160
|
if (typeof t == "number") {
|
|
@@ -170,24 +170,24 @@ function yt(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 Ze(e, t, s) {
|
|
174
174
|
if (!s) return !0;
|
|
175
175
|
const n = s.distance != null, o = s.delay != null;
|
|
176
176
|
return !n && !o ? !0 : n && !o ? e >= 1 : !n && o ? t >= 1 : (s.condition ?? "both") === "both" ? e >= 1 && t >= 1 : e >= 1 || t >= 1;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function yt(e) {
|
|
179
179
|
if (e.state.value !== "activating" || !e.entities.initiatingDraggable)
|
|
180
180
|
return !1;
|
|
181
181
|
const t = e.entities.draggableMap.get(
|
|
182
182
|
e.entities.initiatingDraggable
|
|
183
183
|
);
|
|
184
|
-
return
|
|
184
|
+
return Ze(
|
|
185
185
|
e.distanceProgress.value,
|
|
186
186
|
e.delay.progress,
|
|
187
187
|
t?.activation
|
|
188
188
|
) ? (se(e), !0) : !1;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function pt(e, t) {
|
|
191
191
|
let s = null;
|
|
192
192
|
const n = () => {
|
|
193
193
|
if (e.state.value !== "activating" || !e.entities.initiatingDraggable) {
|
|
@@ -204,7 +204,7 @@ function St(e, t) {
|
|
|
204
204
|
e.delay.progress = Math.min(
|
|
205
205
|
(Date.now() - e.delay.startTime) / (i * 1e3),
|
|
206
206
|
1
|
|
207
|
-
),
|
|
207
|
+
), Ze(
|
|
208
208
|
e.distanceProgress.value,
|
|
209
209
|
e.delay.progress,
|
|
210
210
|
o?.activation
|
|
@@ -216,7 +216,7 @@ function St(e, t) {
|
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function St(e, t) {
|
|
220
220
|
const s = e.closest(
|
|
221
221
|
_.CONSTRAINT_AREA
|
|
222
222
|
);
|
|
@@ -225,10 +225,10 @@ function Dt(e, t) {
|
|
|
225
225
|
entity: t.get(s)
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function Dt(e, t, s, n) {
|
|
229
229
|
return s === "x" ? { x: e, y: n.top } : s === "y" ? { x: n.left, y: t } : { x: e, y: t };
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Mt(e, t, s, n, o) {
|
|
232
232
|
let i = e, a = t;
|
|
233
233
|
return s !== "y" && (i = Math.max(
|
|
234
234
|
n.left,
|
|
@@ -238,23 +238,23 @@ function wt(e, t, s, n, o) {
|
|
|
238
238
|
Math.min(n.bottom - o.height, t)
|
|
239
239
|
)), { x: i, y: a };
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
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
245
|
let g = e.current.x - a * e.offset.x, l = e.current.y - r * e.offset.y;
|
|
246
246
|
if (!s)
|
|
247
247
|
return { x: g, y: l };
|
|
248
|
-
const u =
|
|
248
|
+
const u = St(s, n);
|
|
249
249
|
if (!u)
|
|
250
250
|
return { x: g, y: l };
|
|
251
|
-
const { element: c, entity: f } = u, d = c.getBoundingClientRect(), m = s.getBoundingClientRect(), h =
|
|
251
|
+
const { element: c, entity: f } = u, d = c.getBoundingClientRect(), m = s.getBoundingClientRect(), h = Dt(
|
|
252
252
|
g,
|
|
253
253
|
l,
|
|
254
254
|
f.axis || "both",
|
|
255
255
|
m
|
|
256
256
|
);
|
|
257
|
-
return f.restrictToArea ?
|
|
257
|
+
return f.restrictToArea ? Mt(
|
|
258
258
|
h.x,
|
|
259
259
|
h.y,
|
|
260
260
|
f.axis || "both",
|
|
@@ -278,7 +278,7 @@ const N = {
|
|
|
278
278
|
],
|
|
279
279
|
forMoveFaster: ["ShiftLeft", "ShiftRight"]
|
|
280
280
|
};
|
|
281
|
-
function
|
|
281
|
+
function vt(e, t) {
|
|
282
282
|
const s = te(), n = j(), i = {
|
|
283
283
|
keys: {
|
|
284
284
|
pressedKeys: j(/* @__PURE__ */ new Set()),
|
|
@@ -300,23 +300,23 @@ function xt(e, t) {
|
|
|
300
300
|
draggingMap: /* @__PURE__ */ new Map(),
|
|
301
301
|
selectedSet: /* @__PURE__ */ new Set(),
|
|
302
302
|
selectionBase: /* @__PURE__ */ new Set(),
|
|
303
|
-
allowedDroppableSet: y(() => s.value ?
|
|
303
|
+
allowedDroppableSet: y(() => 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: y(() => s.value ?
|
|
309
|
+
allowedDraggableSet: y(() => s.value ? gt(
|
|
310
310
|
a.visibleDraggableSet,
|
|
311
311
|
a.draggingMap,
|
|
312
312
|
a.draggableMap
|
|
313
313
|
) : /* @__PURE__ */ new Set()),
|
|
314
|
-
modifiersSelectableAreaSet: y(() =>
|
|
314
|
+
modifiersSelectableAreaSet: y(() => Ie(
|
|
315
315
|
a.selectableAreaMap,
|
|
316
316
|
a.visibleSelectableAreaSet,
|
|
317
317
|
i.keys.pressedKeys
|
|
318
318
|
)),
|
|
319
|
-
modifiersDraggableSet: y(() =>
|
|
319
|
+
modifiersDraggableSet: y(() => Ie(
|
|
320
320
|
a.draggableMap,
|
|
321
321
|
a.visibleDraggableSet,
|
|
322
322
|
i.keys.pressedKeys,
|
|
@@ -339,16 +339,16 @@ function xt(e, t) {
|
|
|
339
339
|
}), c = y(() => {
|
|
340
340
|
if (!n.value || !a.initiatingDraggable) return 0;
|
|
341
341
|
const v = a.draggableMap.get(a.initiatingDraggable)?.activation?.distance;
|
|
342
|
-
return v ?
|
|
342
|
+
return v ? bt(n.value, v) : 1;
|
|
343
343
|
}), f = ge(
|
|
344
344
|
a.visibleDraggableSet
|
|
345
345
|
), d = ge(
|
|
346
346
|
a.visibleDroppableSet
|
|
347
347
|
), m = ge(
|
|
348
348
|
a.visibleSelectableAreaSet
|
|
349
|
-
), { overlaySize: h, overlaySizeObserver: S } =
|
|
349
|
+
), { overlaySize: h, overlaySizeObserver: S } = ft(e), b = j(), w = y(() => {
|
|
350
350
|
const p = a.initiatingDraggable;
|
|
351
|
-
return
|
|
351
|
+
return wt(
|
|
352
352
|
n.value,
|
|
353
353
|
e.value,
|
|
354
354
|
p || null,
|
|
@@ -399,7 +399,7 @@ 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
|
|
402
|
+
function I(e, t, s) {
|
|
403
403
|
const n = Math.max(0, Math.min(t, e.length));
|
|
404
404
|
return [...e.slice(0, n), ...s, ...e.slice(n)];
|
|
405
405
|
}
|
|
@@ -413,24 +413,24 @@ function H(e, t) {
|
|
|
413
413
|
for (const o of s) n = Ee(n, o, 1);
|
|
414
414
|
return n;
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function Ne(e, t, s) {
|
|
417
417
|
if (t === s || t < 0 || s < 0 || t >= e.length || s >= e.length)
|
|
418
418
|
return e;
|
|
419
419
|
const n = [...e];
|
|
420
420
|
return [n[t], n[s]] = [n[s], n[t]], n;
|
|
421
421
|
}
|
|
422
|
-
const
|
|
422
|
+
const R = {
|
|
423
423
|
getInsertSide(e, t) {
|
|
424
424
|
return e ? t === "vertical" ? e.top && !e.bottom ? "before" : e.bottom && !e.top ? "after" : e.top ? "before" : null : e.left && !e.right ? "before" : e.right && !e.left ? "after" : e.left ? "before" : null : null;
|
|
425
425
|
},
|
|
426
426
|
isAtZoneStart(e, t) {
|
|
427
|
-
return
|
|
427
|
+
return R.getInsertSide(e, t) === "before" && !e?.center;
|
|
428
428
|
},
|
|
429
429
|
isAtZoneEnd(e, t) {
|
|
430
|
-
return
|
|
430
|
+
return R.getInsertSide(e, t) === "after" && !e?.center;
|
|
431
431
|
}
|
|
432
432
|
};
|
|
433
|
-
function
|
|
433
|
+
function Ye(e, t) {
|
|
434
434
|
const { draggedItems: s, dropZone: n, hoveredDraggable: o } = e;
|
|
435
435
|
if (!s.length) return null;
|
|
436
436
|
const i = o?.placement.center === !0 && n != null && n.items !== o.items, a = i ? n.items : o?.items ?? n?.items;
|
|
@@ -440,27 +440,27 @@ function Xe(e, t) {
|
|
|
440
440
|
if (o && !i) {
|
|
441
441
|
const f = o.items === r && g.includes(o.index);
|
|
442
442
|
if (f && s.length === 1) {
|
|
443
|
-
const d =
|
|
443
|
+
const d = R.isAtZoneStart(n?.placement, t);
|
|
444
444
|
u = d ? 0 : l, c = d ? "prepend" : "append";
|
|
445
445
|
} else {
|
|
446
446
|
if (f)
|
|
447
447
|
return null;
|
|
448
448
|
{
|
|
449
|
-
const d =
|
|
449
|
+
const d = R.getInsertSide(o.placement, t), m = o.index;
|
|
450
450
|
d === "before" ? (u = Math.max(0, m), c = "insert") : d === "after" ? (u = Math.min(l, m + 1), c = "insert") : (u = l, c = "append");
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
} else {
|
|
454
454
|
if (!n) return null;
|
|
455
|
-
const f =
|
|
455
|
+
const f = R.isAtZoneStart(n.placement, t);
|
|
456
456
|
u = f ? 0 : l, c = f ? "prepend" : "append";
|
|
457
457
|
}
|
|
458
458
|
return { targetIndex: u, mode: c, targetArr: a };
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function xt(e, t = "vertical") {
|
|
461
461
|
const { draggedItems: s } = e;
|
|
462
462
|
if (!s.length) return null;
|
|
463
|
-
const n =
|
|
463
|
+
const n = Ye(e, t);
|
|
464
464
|
if (!n) return null;
|
|
465
465
|
const { targetArr: o, mode: i } = n;
|
|
466
466
|
let { targetIndex: a } = n;
|
|
@@ -468,14 +468,14 @@ function At(e, t = "vertical") {
|
|
|
468
468
|
if (l === o) {
|
|
469
469
|
const c = r.filter((d) => d < a).length;
|
|
470
470
|
a = Math.max(0, a - c);
|
|
471
|
-
const f =
|
|
471
|
+
const f = I(H(l, r), a, g);
|
|
472
472
|
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: a, mode: i, sameList: !0 };
|
|
473
473
|
} else {
|
|
474
|
-
const c = H(l, r), f =
|
|
474
|
+
const c = H(l, r), f = I(o, a, g);
|
|
475
475
|
return { sourceItems: c, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: a, mode: i, sameList: !1 };
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function At(e) {
|
|
479
479
|
const { draggedItems: t, hoveredDraggable: s } = e;
|
|
480
480
|
if (!t.length || !s) return null;
|
|
481
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, l = r === g;
|
|
@@ -483,7 +483,7 @@ function Et(e) {
|
|
|
483
483
|
if (t.length === 1) {
|
|
484
484
|
const u = n[0];
|
|
485
485
|
if (l) {
|
|
486
|
-
const c =
|
|
486
|
+
const c = Ne(r, u, o);
|
|
487
487
|
return { sourceItems: c, targetItems: c, sourceIndexes: n, targetIndex: o, sameList: !0 };
|
|
488
488
|
} else {
|
|
489
489
|
const c = [...r], f = [...g];
|
|
@@ -494,54 +494,54 @@ function Et(e) {
|
|
|
494
494
|
if (l) {
|
|
495
495
|
const c = n.filter((b) => b < o).length, f = Math.max(0, o - c), d = n.filter((b) => b < u).length, m = Math.max(0, u - d);
|
|
496
496
|
let h = H(r, n);
|
|
497
|
-
h =
|
|
497
|
+
h = I(h, f, i);
|
|
498
498
|
const S = m >= f ? m + i.length : m;
|
|
499
|
-
return h =
|
|
499
|
+
return h = I(h, S, [a]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex: f, sameList: !0 };
|
|
500
500
|
} else {
|
|
501
501
|
const c = n.filter((h) => h < u).length, f = Math.max(0, u - c);
|
|
502
502
|
let d = H(r, n);
|
|
503
|
-
d =
|
|
503
|
+
d = I(d, f, [a]);
|
|
504
504
|
let m = Ee(g, o);
|
|
505
|
-
return m =
|
|
505
|
+
return m = I(m, o, i), { sourceItems: d, targetItems: m, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function Et(e, t = "vertical") {
|
|
510
510
|
const { draggedItems: s } = e;
|
|
511
511
|
if (!s.length) return null;
|
|
512
|
-
const n =
|
|
512
|
+
const n = Ye(e, t);
|
|
513
513
|
if (!n) return null;
|
|
514
514
|
const { targetArr: o, targetIndex: i, mode: a } = n, r = s.map((l) => l.item);
|
|
515
|
-
return { targetItems:
|
|
515
|
+
return { targetItems: I(o, i, r), copiedItems: r, targetIndex: i, mode: a };
|
|
516
516
|
}
|
|
517
|
-
function
|
|
517
|
+
function Lt(e) {
|
|
518
518
|
const { draggedItems: t } = e;
|
|
519
519
|
if (!t.length) return null;
|
|
520
520
|
const s = t.map((a) => a.index), n = t.map((a) => a.item), o = t[0].items;
|
|
521
521
|
return { sourceItems: H(o, s), removedItems: n, sourceIndexes: s };
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function Ct(e) {
|
|
524
524
|
return {
|
|
525
525
|
// Low-level array ops
|
|
526
|
-
insertAt:
|
|
526
|
+
insertAt: I,
|
|
527
527
|
removeAt: Ee,
|
|
528
528
|
removeIndexes: H,
|
|
529
|
-
swapAt:
|
|
529
|
+
swapAt: Ne,
|
|
530
530
|
// Placement helpers
|
|
531
|
-
getInsertSide: (t, s) =>
|
|
532
|
-
isAtZoneStart: (t, s) =>
|
|
533
|
-
isAtZoneEnd: (t, s) =>
|
|
531
|
+
getInsertSide: (t, s) => R.getInsertSide(t, s),
|
|
532
|
+
isAtZoneStart: (t, s) => R.isAtZoneStart(t, s),
|
|
533
|
+
isAtZoneEnd: (t, s) => R.isAtZoneEnd(t, s),
|
|
534
534
|
// High-level (event-bound)
|
|
535
|
-
suggestSort: (t) =>
|
|
536
|
-
suggestSwap: () =>
|
|
537
|
-
suggestCopy: (t) =>
|
|
538
|
-
suggestRemove: () =>
|
|
535
|
+
suggestSort: (t) => xt(e, t),
|
|
536
|
+
suggestSwap: () => At(e),
|
|
537
|
+
suggestCopy: (t) => Et(e, t),
|
|
538
|
+
suggestRemove: () => Lt(e)
|
|
539
539
|
};
|
|
540
540
|
}
|
|
541
|
-
const P = (e) => e.keys().next().value,
|
|
541
|
+
const P = (e) => e.keys().next().value, It = (e) => e.target.closest(
|
|
542
542
|
_.DRAGGABLE
|
|
543
543
|
);
|
|
544
|
-
function
|
|
544
|
+
function Rt(e) {
|
|
545
545
|
const t = e.entities.initiatingDraggable;
|
|
546
546
|
if (!t) return [];
|
|
547
547
|
const s = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t), n = s?.payload;
|
|
@@ -572,7 +572,7 @@ function kt(e) {
|
|
|
572
572
|
}), [...l.values()].sort((u, c) => u.index - c.index);
|
|
573
573
|
}
|
|
574
574
|
const A = (e, t) => {
|
|
575
|
-
const s =
|
|
575
|
+
const s = Rt(e);
|
|
576
576
|
let n, o;
|
|
577
577
|
if (t) {
|
|
578
578
|
const i = e.entities.droppableMap.get(t);
|
|
@@ -615,7 +615,7 @@ const A = (e, t) => {
|
|
|
615
615
|
dropZone: n,
|
|
616
616
|
hoveredDraggable: o,
|
|
617
617
|
provider: e,
|
|
618
|
-
helpers:
|
|
618
|
+
helpers: Ct({ draggedItems: s, dropZone: n, hoveredDraggable: o })
|
|
619
619
|
};
|
|
620
620
|
}, F = (e, t, s) => {
|
|
621
621
|
if (!t) return;
|
|
@@ -626,7 +626,7 @@ const A = (e, t) => {
|
|
|
626
626
|
e.entities.draggingMap.forEach((n) => {
|
|
627
627
|
n.disabled || n.events?.[t]?.(s);
|
|
628
628
|
});
|
|
629
|
-
},
|
|
629
|
+
}, kt = (e, t, s) => {
|
|
630
630
|
if (t !== s) {
|
|
631
631
|
if (t && !G(t, e)) {
|
|
632
632
|
const n = A(e, t);
|
|
@@ -637,7 +637,7 @@ const A = (e, t) => {
|
|
|
637
637
|
e.entities.droppableMap.get(s)?.events?.onEnter?.(n);
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
|
-
},
|
|
640
|
+
}, Pt = (e, t, s) => {
|
|
641
641
|
if (t !== s) {
|
|
642
642
|
const n = A(e);
|
|
643
643
|
if (t) {
|
|
@@ -650,19 +650,19 @@ const A = (e, t) => {
|
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
}, ue = (e, t, s) => {
|
|
653
|
-
const n =
|
|
653
|
+
const n = It(t);
|
|
654
654
|
!n || !e.entities.draggingMap.has(n) || e.entities.draggingMap.get(n)?.events?.[s]?.(A(e));
|
|
655
|
-
},
|
|
655
|
+
}, Tt = (e, t) => {
|
|
656
656
|
const s = P(t.droppable);
|
|
657
657
|
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
658
|
-
},
|
|
658
|
+
}, Xe = (e, t) => {
|
|
659
659
|
const s = P(t.droppable);
|
|
660
660
|
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
661
661
|
};
|
|
662
|
-
function
|
|
662
|
+
function zt(e) {
|
|
663
663
|
return e.parentElement?.closest(_.SELECT_AREA) ?? null;
|
|
664
664
|
}
|
|
665
|
-
const
|
|
665
|
+
const Bt = (e, t, s) => {
|
|
666
666
|
if (!s) return {};
|
|
667
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
668
|
return {
|
|
@@ -675,15 +675,15 @@ const Ot = (e, t, s) => {
|
|
|
675
675
|
border: "1px solid #3b82f6",
|
|
676
676
|
backgroundColor: "#3b82f61a"
|
|
677
677
|
};
|
|
678
|
-
},
|
|
678
|
+
}, Ue = (e) => {
|
|
679
679
|
if (!e.pointer.value || !e.entities.selectingArea) return;
|
|
680
|
-
const { selectingArea: t } = e.entities, s =
|
|
680
|
+
const { selectingArea: t } = e.entities, s = Ot(
|
|
681
681
|
e.pointer.value.start,
|
|
682
682
|
e.pointer.value.current
|
|
683
683
|
), n = e.entities.selectableAreaMap.get(t)?.groups ?? [], o = e.lib.rectCache;
|
|
684
684
|
e.entities.visibleDraggableSet.forEach((i) => {
|
|
685
685
|
if (i === t || !t.contains(i)) return;
|
|
686
|
-
const a =
|
|
686
|
+
const a = zt(i);
|
|
687
687
|
if (a && a !== t) {
|
|
688
688
|
e.entities.selectedSet.delete(i);
|
|
689
689
|
return;
|
|
@@ -700,12 +700,12 @@ const Ot = (e, t, s) => {
|
|
|
700
700
|
let l = o.get(i);
|
|
701
701
|
l || (l = i.getBoundingClientRect(), o.set(i, l));
|
|
702
702
|
const u = e.entities.selectionBase.has(i);
|
|
703
|
-
|
|
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
704
|
});
|
|
705
|
-
},
|
|
705
|
+
}, Ot = (e, t) => {
|
|
706
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
707
|
return new DOMRect(s, n, a, r);
|
|
708
|
-
},
|
|
708
|
+
}, Ft = (e, t, s = 5) => {
|
|
709
709
|
const n = s / 2;
|
|
710
710
|
return {
|
|
711
711
|
left: e - n,
|
|
@@ -713,9 +713,9 @@ const Ot = (e, t, s) => {
|
|
|
713
713
|
width: s,
|
|
714
714
|
height: s
|
|
715
715
|
};
|
|
716
|
-
},
|
|
716
|
+
}, _t = (e) => {
|
|
717
717
|
const t = e.pointer.value?.current, s = t?.x ?? 0, n = t?.y ?? 0;
|
|
718
|
-
return
|
|
718
|
+
return Ft(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) {
|
|
@@ -737,28 +737,28 @@ const Ot = (e, t, s) => {
|
|
|
737
737
|
right: n > i,
|
|
738
738
|
center: !1
|
|
739
739
|
};
|
|
740
|
-
},
|
|
740
|
+
}, Gt = (e) => ({
|
|
741
741
|
x: e.left + e.width / 2,
|
|
742
742
|
y: e.top + e.height / 2
|
|
743
|
-
}),
|
|
744
|
-
const s =
|
|
743
|
+
}), Re = (e, t) => {
|
|
744
|
+
const s = Gt(t);
|
|
745
745
|
return Math.hypot(e.x - s.x, e.y - s.y);
|
|
746
746
|
};
|
|
747
|
-
function
|
|
747
|
+
function Ht(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
|
+
Ht(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
752
752
|
}
|
|
753
|
-
const
|
|
753
|
+
const Kt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
754
754
|
const n = P(t.droppable), o = P(t.draggable);
|
|
755
755
|
o && t.draggable.delete(o), n && t.droppable.delete(n);
|
|
756
|
-
const i =
|
|
756
|
+
const i = _t(e), a = s.zones[0], r = s.elements[0];
|
|
757
757
|
if (a && r && a === r && e.entities.droppableMap.has(a) && a) {
|
|
758
758
|
const c = a.getBoundingClientRect(), f = e.entities.draggableMap.get(a)?.placementMargins, d = B(i, c, f);
|
|
759
759
|
if (d.center) {
|
|
760
760
|
t.droppable.set(a, d);
|
|
761
|
-
const m =
|
|
761
|
+
const m = Kt(s.elements, a);
|
|
762
762
|
if (m) {
|
|
763
763
|
const h = m.getBoundingClientRect();
|
|
764
764
|
t.draggable.set(
|
|
@@ -782,8 +782,8 @@ const Zt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
|
782
782
|
B(i, c, f)
|
|
783
783
|
);
|
|
784
784
|
} else {
|
|
785
|
-
const c = e.pointer.value?.current ?? { x: 0, y: 0 }, f = a.getBoundingClientRect(), d = r.getBoundingClientRect(), m =
|
|
786
|
-
if (
|
|
785
|
+
const c = e.pointer.value?.current ?? { x: 0, y: 0 }, f = a.getBoundingClientRect(), d = r.getBoundingClientRect(), m = Re(c, f);
|
|
786
|
+
if (Re(c, d) < m) {
|
|
787
787
|
t.droppable.clear();
|
|
788
788
|
const S = e.entities.draggableMap.get(r)?.placementMargins;
|
|
789
789
|
t.draggable.set(
|
|
@@ -817,7 +817,7 @@ const Zt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
|
817
817
|
const c = e.entities.droppableMap.get(l);
|
|
818
818
|
c && W(c, t.droppable.get(l));
|
|
819
819
|
}
|
|
820
|
-
|
|
820
|
+
kt(e, n, l), Pt(e, o, u);
|
|
821
821
|
}, fe = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, X = (e) => {
|
|
822
822
|
if (!e)
|
|
823
823
|
return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
|
|
@@ -835,7 +835,7 @@ const Zt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
|
835
835
|
}, Y = (e) => ({
|
|
836
836
|
x: e.x + e.width / 2,
|
|
837
837
|
y: e.y + e.height / 2
|
|
838
|
-
}),
|
|
838
|
+
}), Zt = (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 Zt = (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
|
+
}, Nt = (e, t, s) => t >= e.x && t <= e.x + e.width && s >= e.y && s <= e.y + e.height, Yt = (e) => e.overlay.ref?.value ?? null, ke = (e) => {
|
|
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,41 +863,41 @@ const Zt = (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
|
-
}, De = (e) => e.entities.allowedDraggableSet,
|
|
866
|
+
}, De = (e) => e.entities.allowedDraggableSet, Ve = (e) => e.entities.allowedDroppableSet, Xt = (e, t) => !t.entities.draggingMap.has(e), Ut = (e, t) => ![...t.entities.draggingMap.keys()].some(
|
|
867
867
|
(s) => K(s, e)
|
|
868
|
-
),
|
|
868
|
+
), Vt = (e, t) => t.entities.draggableMap.has(e) ? !xe(e, t) : t.entities.droppableMap.has(e) ? !G(e, t) : !0, ee = (e, t) => Xt(e, t) && Ut(e, t) && Vt(e, t), de = 10;
|
|
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 $t(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 = De(e), o =
|
|
878
|
+
const n = De(e), o = Ve(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
884
|
const Me = (e) => {
|
|
885
|
-
if (!
|
|
886
|
-
const s = e.pointer.value?.current ?? { x: 0, y: 0 }, n =
|
|
885
|
+
if (!Yt(e)) return { elements: [], zones: [] };
|
|
886
|
+
const s = e.pointer.value?.current ?? { x: 0, y: 0 }, n = $t(e);
|
|
887
887
|
if (n) {
|
|
888
888
|
if (n.elements.length > 0) return n;
|
|
889
889
|
const l = n.zones[0];
|
|
890
890
|
if (!l) return n;
|
|
891
|
-
const u =
|
|
891
|
+
const u = ke(e);
|
|
892
892
|
return { elements: [...De(e)].filter(
|
|
893
893
|
(d) => l.contains(d) && ee(d, e)
|
|
894
894
|
).map((d) => ({ el: d, box: X(d) })).filter(
|
|
895
895
|
({ box: d }) => fe(d, u) && Q(d, u) >= de
|
|
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 =
|
|
898
|
+
const o = ke(e), i = [...De(e)].filter(
|
|
899
899
|
(l) => ee(l, e)
|
|
900
|
-
), a = [
|
|
900
|
+
), a = [...Ve(e)].filter(
|
|
901
901
|
(l) => ee(l, e)
|
|
902
902
|
), r = i.map((l) => ({ n: l, box: X(l) })).filter(
|
|
903
903
|
({ box: l }) => fe(l, o) && Q(l, o) >= de
|
|
@@ -915,7 +915,7 @@ function we(e) {
|
|
|
915
915
|
const t = Me(e);
|
|
916
916
|
ae(e, e.hovered, t);
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function qt(e, t) {
|
|
919
919
|
const s = e.collision?.throttle?.value ?? 0;
|
|
920
920
|
if (s <= 0) {
|
|
921
921
|
we(e);
|
|
@@ -924,7 +924,7 @@ function Wt(e, t) {
|
|
|
924
924
|
const n = Date.now();
|
|
925
925
|
n - t.value >= s && (t.value = n, we(e));
|
|
926
926
|
}
|
|
927
|
-
async function
|
|
927
|
+
async function $e(e) {
|
|
928
928
|
const t = e.hovered.droppable.keys().next().value;
|
|
929
929
|
if (!t || G(t, e)) return "accept";
|
|
930
930
|
const s = e.entities.droppableMap.get(t), n = A(e, t), o = s?.events?.onDrop?.(n);
|
|
@@ -935,49 +935,49 @@ async function qe(e) {
|
|
|
935
935
|
a = await o;
|
|
936
936
|
} catch {
|
|
937
937
|
const r = e.entities.initiatingDraggable;
|
|
938
|
-
return F(e, r, "onSelfDragCancel"), x(e, "onDragCancel"),
|
|
938
|
+
return F(e, r, "onSelfDragCancel"), x(e, "onDragCancel"), Xe(e, e.hovered), "cancel";
|
|
939
939
|
}
|
|
940
940
|
return a === !1 ? (e.state.value = "dragging", "decline") : "accept";
|
|
941
941
|
}
|
|
942
942
|
return o === !1 ? "decline" : "accept";
|
|
943
943
|
}
|
|
944
|
-
function
|
|
944
|
+
function qe(e) {
|
|
945
945
|
const t = e.entities.initiatingDraggable;
|
|
946
|
-
F(e, t, "onSelfDragEnd"), x(e, "onDragEnd"),
|
|
946
|
+
F(e, t, "onSelfDragEnd"), x(e, "onDragEnd"), Tt(e, e.hovered);
|
|
947
947
|
}
|
|
948
|
-
function
|
|
948
|
+
function Wt(e) {
|
|
949
949
|
const t = e.entities.selectingArea;
|
|
950
950
|
if (!t) return;
|
|
951
951
|
const s = e.entities.selectableAreaMap.get(t), n = [...e.entities.selectedSet];
|
|
952
952
|
s?.events?.onSelected?.(n);
|
|
953
953
|
}
|
|
954
|
-
const
|
|
954
|
+
const jt = (e) => {
|
|
955
955
|
const t = {
|
|
956
956
|
current: null
|
|
957
957
|
}, s = { value: 0 }, n = async () => {
|
|
958
958
|
pe(), t.current?.cancel(), t.current = null;
|
|
959
959
|
const r = e.state.value;
|
|
960
960
|
if (r === "dragging") {
|
|
961
|
-
const g = await
|
|
962
|
-
if (g === "accept" &&
|
|
961
|
+
const g = await $e(e);
|
|
962
|
+
if (g === "accept" && qe(e), g === "accept" || g === "cancel") {
|
|
963
963
|
oe(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
964
964
|
return;
|
|
965
965
|
}
|
|
966
966
|
return;
|
|
967
|
-
} else r === "selecting" &&
|
|
967
|
+
} else r === "selecting" && Wt(e);
|
|
968
968
|
oe(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
969
969
|
}, o = (r) => {
|
|
970
970
|
if (e.pointer.value) {
|
|
971
|
-
if (e.pointer.value.current = { x: r.clientX, y: r.clientY },
|
|
971
|
+
if (e.pointer.value.current = { x: r.clientX, y: r.clientY }, yt(e)) {
|
|
972
972
|
ue(e, r, "onSelfDragStart"), x(e, "onDragStart");
|
|
973
973
|
return;
|
|
974
974
|
}
|
|
975
975
|
if (e.state.value === "dragging") {
|
|
976
|
-
|
|
976
|
+
qt(e, s);
|
|
977
977
|
const g = e.entities.initiatingDraggable;
|
|
978
978
|
F(e, g, "onSelfDragMove"), x(e, "onDragMove");
|
|
979
979
|
}
|
|
980
|
-
e.state.value === "selecting" &&
|
|
980
|
+
e.state.value === "selecting" && Ue(e);
|
|
981
981
|
}
|
|
982
982
|
};
|
|
983
983
|
return { pointerDown: (r) => {
|
|
@@ -993,18 +993,18 @@ const Jt = (e) => {
|
|
|
993
993
|
}
|
|
994
994
|
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(u)) {
|
|
995
995
|
const c = e.entities.draggableMap.get(u);
|
|
996
|
-
if (!
|
|
996
|
+
if (!Ke(g, u, c?.dragHandle))
|
|
997
997
|
return;
|
|
998
998
|
ye(), e.entities.initiatingDraggable = u;
|
|
999
|
-
const f =
|
|
1000
|
-
e.pointer.value = Se(r, f.x, f.y), c?.activation?.distance || c?.activation?.delay ? (e.state.value = "activating", c?.activation?.delay && (e.delay.startTime = Date.now(), t.current =
|
|
999
|
+
const f = Ge(r, u);
|
|
1000
|
+
e.pointer.value = Se(r, f.x, f.y), c?.activation?.distance || c?.activation?.delay ? (e.state.value = "activating", c?.activation?.delay && (e.delay.startTime = Date.now(), t.current = pt(e, () => {
|
|
1001
1001
|
se(e), ue(e, r, "onSelfDragStart"), x(e, "onDragStart");
|
|
1002
1002
|
}))) : (se(e), ue(e, r, "onSelfDragStart"), x(e, "onDragStart"));
|
|
1003
1003
|
}
|
|
1004
1004
|
}, pointerUp: n, pointerMove: o, cleanup: () => {
|
|
1005
1005
|
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
1006
|
} };
|
|
1007
|
-
},
|
|
1007
|
+
}, Jt = {
|
|
1008
1008
|
ArrowUp: { dx: 0, dy: -1 },
|
|
1009
1009
|
ArrowDown: { dx: 0, dy: 1 },
|
|
1010
1010
|
ArrowLeft: { dx: -1, dy: 0 },
|
|
@@ -1013,7 +1013,7 @@ const Jt = (e) => {
|
|
|
1013
1013
|
KeyA: { dx: -1, dy: 0 },
|
|
1014
1014
|
KeyS: { dx: 0, dy: 1 },
|
|
1015
1015
|
KeyD: { dx: 1, dy: 0 }
|
|
1016
|
-
},
|
|
1016
|
+
}, Qt = (e) => (t) => {
|
|
1017
1017
|
const { keys: s } = e.keyboard;
|
|
1018
1018
|
if (s.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1019
1019
|
if (s.forCancel.includes(t.code)) {
|
|
@@ -1021,14 +1021,14 @@ const Jt = (e) => {
|
|
|
1021
1021
|
e,
|
|
1022
1022
|
e.entities.initiatingDraggable,
|
|
1023
1023
|
"onSelfDragCancel"
|
|
1024
|
-
), x(e, "onDragCancel"),
|
|
1024
|
+
), x(e, "onDragCancel"), Xe(e, e.hovered), oe(e);
|
|
1025
1025
|
return;
|
|
1026
1026
|
}
|
|
1027
1027
|
if (s.forDrop.includes(t.code)) {
|
|
1028
|
-
t.preventDefault(), (async () => (await
|
|
1028
|
+
t.preventDefault(), (async () => (await $e(e) && qe(e), pe(), oe(e)))();
|
|
1029
1029
|
return;
|
|
1030
1030
|
}
|
|
1031
|
-
const o =
|
|
1031
|
+
const o = Jt[t.code];
|
|
1032
1032
|
if (o && s.forMove.includes(t.code) && e.pointer.value) {
|
|
1033
1033
|
t.preventDefault();
|
|
1034
1034
|
const i = s.forMoveFaster.some(
|
|
@@ -1057,7 +1057,7 @@ const Jt = (e) => {
|
|
|
1057
1057
|
if (!i || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(i))
|
|
1058
1058
|
return;
|
|
1059
1059
|
const a = e.entities.draggableMap.get(i);
|
|
1060
|
-
if (!
|
|
1060
|
+
if (!Ke(o, i, a?.dragHandle, !0))
|
|
1061
1061
|
return;
|
|
1062
1062
|
t.preventDefault(), ye();
|
|
1063
1063
|
const r = i.getBoundingClientRect(), g = r.left + r.width / 2, l = r.top + r.height / 2, u = {
|
|
@@ -1065,7 +1065,7 @@ const Jt = (e) => {
|
|
|
1065
1065
|
clientY: l
|
|
1066
1066
|
};
|
|
1067
1067
|
e.entities.initiatingDraggable = i;
|
|
1068
|
-
const c =
|
|
1068
|
+
const c = Ge(u, i);
|
|
1069
1069
|
e.pointer.value = Se(
|
|
1070
1070
|
u,
|
|
1071
1071
|
c.x,
|
|
@@ -1074,15 +1074,15 @@ const Jt = (e) => {
|
|
|
1074
1074
|
const d = (e.collision?.run ?? Me)(e);
|
|
1075
1075
|
ae(e, e.hovered, d), F(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
1076
1076
|
}
|
|
1077
|
-
},
|
|
1077
|
+
}, en = (e) => (t) => {
|
|
1078
1078
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
1079
|
-
},
|
|
1079
|
+
}, tn = (e) => () => {
|
|
1080
1080
|
e.keyboard.keys.pressedKeys.value.clear();
|
|
1081
1081
|
}, me = {
|
|
1082
|
-
keyDown:
|
|
1083
|
-
keyUp:
|
|
1084
|
-
clear:
|
|
1085
|
-
},
|
|
1082
|
+
keyDown: Qt,
|
|
1083
|
+
keyUp: en,
|
|
1084
|
+
clear: tn
|
|
1085
|
+
}, nn = (e) => () => {
|
|
1086
1086
|
if (!e.state.value) return;
|
|
1087
1087
|
const t = e.scrollPosition.x, s = e.scrollPosition.y;
|
|
1088
1088
|
if (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging") {
|
|
@@ -1091,10 +1091,10 @@ const Jt = (e) => {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
if (e.state.value === "selecting" && e.pointer.value) {
|
|
1093
1093
|
const n = window.scrollX - t, o = window.scrollY - s;
|
|
1094
|
-
e.pointer.value.start.x -= n, e.pointer.value.start.y -= o,
|
|
1094
|
+
e.pointer.value.start.x -= n, e.pointer.value.start.y -= o, Ue(e);
|
|
1095
1095
|
}
|
|
1096
|
-
}, L = 50,
|
|
1097
|
-
function
|
|
1096
|
+
}, L = 50, sn = 144, Pe = 1e3 / sn;
|
|
1097
|
+
function on(e) {
|
|
1098
1098
|
return e == null ? {
|
|
1099
1099
|
top: L,
|
|
1100
1100
|
right: L,
|
|
@@ -1112,7 +1112,7 @@ function an(e) {
|
|
|
1112
1112
|
left: e.left ?? L
|
|
1113
1113
|
};
|
|
1114
1114
|
}
|
|
1115
|
-
const
|
|
1115
|
+
const an = {
|
|
1116
1116
|
getScrollState(e) {
|
|
1117
1117
|
return {
|
|
1118
1118
|
scrollTop: e.scrollTop,
|
|
@@ -1123,8 +1123,8 @@ const rn = {
|
|
|
1123
1123
|
e.scrollTop = t, e.scrollLeft = s;
|
|
1124
1124
|
}
|
|
1125
1125
|
};
|
|
1126
|
-
function
|
|
1127
|
-
const { speed: i = 10, disabled: a = !1 } = t, r =
|
|
1126
|
+
function We(e, t, s, n = an, o) {
|
|
1127
|
+
const { speed: i = 10, disabled: a = !1 } = t, r = on(t.threshold);
|
|
1128
1128
|
let g = null, l = null, u = null, c = 0, f = 0;
|
|
1129
1129
|
const d = (b) => {
|
|
1130
1130
|
o && (o.value = b);
|
|
@@ -1136,11 +1136,11 @@ function je(e, t, s, n = rn, o) {
|
|
|
1136
1136
|
}
|
|
1137
1137
|
l || (l = b);
|
|
1138
1138
|
const $ = b - l;
|
|
1139
|
-
if ($ <
|
|
1139
|
+
if ($ < Pe) {
|
|
1140
1140
|
g = requestAnimationFrame(m);
|
|
1141
1141
|
return;
|
|
1142
1142
|
}
|
|
1143
|
-
const p = i * ($ /
|
|
1143
|
+
const p = i * ($ / Pe);
|
|
1144
1144
|
l = b;
|
|
1145
1145
|
const { scrollTop: v, scrollLeft: Z } = n.getScrollState(w);
|
|
1146
1146
|
(!u || c !== v || f !== Z) && (u = n.getRect ? n.getRect(w) : w.getBoundingClientRect(), c = v, f = Z);
|
|
@@ -1153,7 +1153,7 @@ function je(e, t, s, n = rn, o) {
|
|
|
1153
1153
|
g && (cancelAnimationFrame(g), g = null), u = null, c = 0, f = 0, l = null, d(!1);
|
|
1154
1154
|
} };
|
|
1155
1155
|
}
|
|
1156
|
-
const
|
|
1156
|
+
const rn = {
|
|
1157
1157
|
getScrollState() {
|
|
1158
1158
|
return {
|
|
1159
1159
|
scrollTop: window.scrollY ?? document.documentElement.scrollTop,
|
|
@@ -1166,14 +1166,14 @@ const ln = {
|
|
|
1166
1166
|
getRect() {
|
|
1167
1167
|
return new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
1168
1168
|
}
|
|
1169
|
-
},
|
|
1169
|
+
}, ln = {
|
|
1170
1170
|
get value() {
|
|
1171
1171
|
return typeof document < "u" ? document.documentElement : null;
|
|
1172
1172
|
}
|
|
1173
1173
|
};
|
|
1174
|
-
function
|
|
1175
|
-
const s = te(!1), o =
|
|
1176
|
-
|
|
1174
|
+
function cn(e, t) {
|
|
1175
|
+
const s = te(!1), o = We(
|
|
1176
|
+
ln,
|
|
1177
1177
|
t ?? {},
|
|
1178
1178
|
() => {
|
|
1179
1179
|
if (e.state.value !== "dragging") return null;
|
|
@@ -1183,7 +1183,7 @@ function gn(e, t) {
|
|
|
1183
1183
|
y: r.y + g.height / 2
|
|
1184
1184
|
} : r : null;
|
|
1185
1185
|
},
|
|
1186
|
-
|
|
1186
|
+
rn,
|
|
1187
1187
|
s
|
|
1188
1188
|
), i = ie(
|
|
1189
1189
|
() => e.state.value,
|
|
@@ -1193,15 +1193,15 @@ function gn(e, t) {
|
|
|
1193
1193
|
), a = () => {
|
|
1194
1194
|
i(), o.stop();
|
|
1195
1195
|
};
|
|
1196
|
-
return
|
|
1196
|
+
return Je(a), { isScrolling: s, stop: a };
|
|
1197
1197
|
}
|
|
1198
|
-
const
|
|
1199
|
-
const t =
|
|
1198
|
+
const gn = (e) => {
|
|
1199
|
+
const t = jt(e), s = me.keyDown(e), n = me.keyUp(e), o = me.clear(e), i = nn(e);
|
|
1200
1200
|
let a = null;
|
|
1201
1201
|
ie(
|
|
1202
1202
|
e.autoScrollViewport,
|
|
1203
1203
|
(r) => {
|
|
1204
|
-
a?.(), a = null, (r === !0 || r && typeof r == "object") && (a =
|
|
1204
|
+
a?.(), a = null, (r === !0 || r && typeof r == "object") && (a = cn(
|
|
1205
1205
|
e,
|
|
1206
1206
|
r === !0 ? {} : r
|
|
1207
1207
|
).stop);
|
|
@@ -1213,10 +1213,10 @@ const un = (e) => {
|
|
|
1213
1213
|
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
1214
|
});
|
|
1215
1215
|
}, re = () => {
|
|
1216
|
-
const e =
|
|
1216
|
+
const e = Oe(ve);
|
|
1217
1217
|
if (!e) throw Error("DnD provider not found");
|
|
1218
1218
|
return e;
|
|
1219
|
-
},
|
|
1219
|
+
}, je = () => {
|
|
1220
1220
|
const e = re();
|
|
1221
1221
|
return {
|
|
1222
1222
|
overlay: e.overlay,
|
|
@@ -1231,20 +1231,20 @@ const un = (e) => {
|
|
|
1231
1231
|
collision: e.collision,
|
|
1232
1232
|
autoScrollViewport: e.autoScrollViewport
|
|
1233
1233
|
};
|
|
1234
|
-
},
|
|
1234
|
+
}, un = /* @__PURE__ */ Fe({
|
|
1235
1235
|
__name: "DefaultOverlay",
|
|
1236
1236
|
setup(e) {
|
|
1237
|
-
const { entities: t, state: s, overlay: n } =
|
|
1238
|
-
return (o, i) =>
|
|
1237
|
+
const { entities: t, state: s, overlay: n } = je();
|
|
1238
|
+
return (o, i) => k(s) === "dragging" ? (C(), J("div", {
|
|
1239
1239
|
key: 0,
|
|
1240
1240
|
class: "dnd-kit-default-overlay",
|
|
1241
1241
|
style: Le({
|
|
1242
|
-
"--position-x":
|
|
1243
|
-
"--position-y":
|
|
1242
|
+
"--position-x": k(n).position.value.x + "px",
|
|
1243
|
+
"--position-y": k(n).position.value.y + "px"
|
|
1244
1244
|
})
|
|
1245
1245
|
}, [
|
|
1246
|
-
(
|
|
1247
|
-
|
|
1246
|
+
(C(!0), J(he, null, Qe(k(t).draggingMap, ([a, r]) => (C(), J(he, null, [
|
|
1247
|
+
k(t).draggableMap.get(a)?.render ? (C(), ne(be(k(t).draggableMap.get(a)?.render), { key: 0 })) : (C(), ne(be(a.tagName), {
|
|
1248
1248
|
key: 1,
|
|
1249
1249
|
innerHTML: r.initialOuterHTML,
|
|
1250
1250
|
style: Le({
|
|
@@ -1253,9 +1253,9 @@ const un = (e) => {
|
|
|
1253
1253
|
})
|
|
1254
1254
|
}, null, 8, ["innerHTML", "style"]))
|
|
1255
1255
|
], 64))), 256))
|
|
1256
|
-
], 4)) :
|
|
1256
|
+
], 4)) : et("", !0);
|
|
1257
1257
|
}
|
|
1258
|
-
}),
|
|
1258
|
+
}), hn = /* @__PURE__ */ Fe({
|
|
1259
1259
|
__name: "DnDProvider",
|
|
1260
1260
|
props: {
|
|
1261
1261
|
autoScrollViewport: { type: [Object, Boolean, null] },
|
|
@@ -1264,31 +1264,30 @@ const un = (e) => {
|
|
|
1264
1264
|
class: {}
|
|
1265
1265
|
},
|
|
1266
1266
|
setup(e) {
|
|
1267
|
-
const t = e, s =
|
|
1268
|
-
|
|
1267
|
+
const t = e, s = tt("overlayRef"), n = vt(s, t);
|
|
1268
|
+
gn(n);
|
|
1269
1269
|
const o = y(
|
|
1270
|
-
() => n.overlay.render.value ??
|
|
1270
|
+
() => n.overlay.render.value ?? un
|
|
1271
1271
|
);
|
|
1272
|
-
return
|
|
1272
|
+
return nt(ve, n), (i, a) => (C(), J(he, null, [
|
|
1273
1273
|
Ce(i.$slots, "default"),
|
|
1274
|
-
(
|
|
1275
|
-
to:
|
|
1274
|
+
(C(), ne(st, {
|
|
1275
|
+
to: k(n).overlay.to.value || "body"
|
|
1276
1276
|
}, [
|
|
1277
|
-
|
|
1277
|
+
ot("div", at({
|
|
1278
1278
|
ref_key: "overlayRef",
|
|
1279
1279
|
ref: s,
|
|
1280
1280
|
class: "dnd-kit-overlay-container"
|
|
1281
1281
|
}, t), [
|
|
1282
1282
|
Ce(i.$slots, "overlay", { overlay: o.value }, () => [
|
|
1283
|
-
(
|
|
1283
|
+
(C(), ne(be(o.value)))
|
|
1284
1284
|
])
|
|
1285
1285
|
], 16)
|
|
1286
|
-
], 8, ["to"]))
|
|
1287
|
-
Ie("pre", null, it(C(n).entities.selectedSet), 1)
|
|
1286
|
+
], 8, ["to"]))
|
|
1288
1287
|
], 64));
|
|
1289
1288
|
}
|
|
1290
1289
|
});
|
|
1291
|
-
function
|
|
1290
|
+
function bn(e, t, s) {
|
|
1292
1291
|
const n = re();
|
|
1293
1292
|
let o, i, a;
|
|
1294
1293
|
typeof t == "function" ? (o = {}, i = t) : (o = t ?? {}, i = s);
|
|
@@ -1335,7 +1334,7 @@ function yn(e, t, s) {
|
|
|
1335
1334
|
isDragOver: u
|
|
1336
1335
|
};
|
|
1337
1336
|
}
|
|
1338
|
-
const
|
|
1337
|
+
const yn = (e, t) => {
|
|
1339
1338
|
const s = re(), n = y(() => e.value === s.entities.selectingArea);
|
|
1340
1339
|
let o = null;
|
|
1341
1340
|
U(() => {
|
|
@@ -1354,15 +1353,15 @@ const pn = (e, t) => {
|
|
|
1354
1353
|
const i = y(() => {
|
|
1355
1354
|
s.scrollPosition.x, s.scrollPosition.y;
|
|
1356
1355
|
const a = s.pointer.value;
|
|
1357
|
-
return !a || s.state.value !== "selecting" || !o || !n.value ? {} :
|
|
1356
|
+
return !a || s.state.value !== "selecting" || !o || !n.value ? {} : Bt(a.start, a.current, o);
|
|
1358
1357
|
});
|
|
1359
1358
|
return {
|
|
1360
1359
|
isSelecting: n,
|
|
1361
1360
|
style: i
|
|
1362
1361
|
};
|
|
1363
1362
|
};
|
|
1364
|
-
function
|
|
1365
|
-
const s =
|
|
1363
|
+
function pn(e, t) {
|
|
1364
|
+
const s = Oe(ve);
|
|
1366
1365
|
if (!s) throw Error("DnD provider not found");
|
|
1367
1366
|
let n = null;
|
|
1368
1367
|
return U(() => {
|
|
@@ -1374,7 +1373,7 @@ function Sn(e, t) {
|
|
|
1374
1373
|
n && s.entities.constraintsAreaMap.delete(n);
|
|
1375
1374
|
}), {};
|
|
1376
1375
|
}
|
|
1377
|
-
function
|
|
1376
|
+
function Sn(e, t, s) {
|
|
1378
1377
|
const n = re();
|
|
1379
1378
|
let o = null, i, a;
|
|
1380
1379
|
typeof t == "function" ? (i = {}, a = t) : (i = t ?? {}, a = s);
|
|
@@ -1402,8 +1401,8 @@ function Dn(e, t, s) {
|
|
|
1402
1401
|
isDragOver: g
|
|
1403
1402
|
};
|
|
1404
1403
|
}
|
|
1405
|
-
const
|
|
1406
|
-
const s =
|
|
1404
|
+
const Dn = (e, t) => {
|
|
1405
|
+
const s = je(), n = te(!1), i = We(
|
|
1407
1406
|
e,
|
|
1408
1407
|
t ?? {},
|
|
1409
1408
|
() => {
|
|
@@ -1424,26 +1423,26 @@ const Mn = (e, t) => {
|
|
|
1424
1423
|
}
|
|
1425
1424
|
), { isScrolling: n };
|
|
1426
1425
|
};
|
|
1427
|
-
function
|
|
1426
|
+
function Te(e, t) {
|
|
1428
1427
|
return t <= 0 ? e : Math.round(e / t) * t;
|
|
1429
1428
|
}
|
|
1430
|
-
function
|
|
1429
|
+
function Mn(e, t) {
|
|
1431
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;
|
|
1432
1431
|
return y(() => {
|
|
1433
1432
|
const { x: i, y: a } = e.value;
|
|
1434
1433
|
return {
|
|
1435
|
-
x:
|
|
1436
|
-
y:
|
|
1434
|
+
x: Te(i, n),
|
|
1435
|
+
y: Te(a, o)
|
|
1437
1436
|
};
|
|
1438
1437
|
});
|
|
1439
1438
|
}
|
|
1440
|
-
const
|
|
1439
|
+
const ze = () => !0, Be = () => 0, fn = "separate", dn = () => {
|
|
1441
1440
|
const e = {
|
|
1442
|
-
filterElements:
|
|
1443
|
-
filterZones:
|
|
1444
|
-
sortElements:
|
|
1445
|
-
sortZones:
|
|
1446
|
-
mergeStrategy:
|
|
1441
|
+
filterElements: ze,
|
|
1442
|
+
filterZones: ze,
|
|
1443
|
+
sortElements: Be,
|
|
1444
|
+
sortZones: Be,
|
|
1445
|
+
mergeStrategy: fn,
|
|
1447
1446
|
pickClosestBetweenFirst: !1
|
|
1448
1447
|
}, t = (n, o, i, a, r, g, l) => {
|
|
1449
1448
|
const u = a instanceof Set ? a : new Set(a), c = { containerBox: o, pointer: i }, f = e.minOverlapPercent, d = [];
|
|
@@ -1460,10 +1459,10 @@ const Be = () => !0, Oe = () => 0, dn = "separate", mn = () => {
|
|
|
1460
1459
|
node: m,
|
|
1461
1460
|
box: h,
|
|
1462
1461
|
meta: {
|
|
1463
|
-
isPointerInElement:
|
|
1462
|
+
isPointerInElement: Nt(h, i.x, i.y),
|
|
1464
1463
|
overlapPercent: S,
|
|
1465
1464
|
depth: b,
|
|
1466
|
-
centerDistance:
|
|
1465
|
+
centerDistance: Zt(
|
|
1467
1466
|
Y(o),
|
|
1468
1467
|
Y(h)
|
|
1469
1468
|
)
|
|
@@ -1580,16 +1579,16 @@ const Be = () => !0, Oe = () => 0, dn = "separate", mn = () => {
|
|
|
1580
1579
|
}
|
|
1581
1580
|
};
|
|
1582
1581
|
return s;
|
|
1583
|
-
},
|
|
1582
|
+
}, wn = () => dn();
|
|
1584
1583
|
export {
|
|
1585
|
-
|
|
1586
|
-
|
|
1584
|
+
hn as DnDProvider,
|
|
1585
|
+
wn as createSensor,
|
|
1587
1586
|
Me as defaultCollisionDetection,
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1587
|
+
Dn as makeAutoScroll,
|
|
1588
|
+
pn as makeConstraintArea,
|
|
1589
|
+
bn as makeDraggable,
|
|
1590
|
+
Sn as makeDroppable,
|
|
1591
|
+
yn as makeSelectionArea,
|
|
1592
|
+
Mn as makeSnappedOverlayPosition,
|
|
1593
|
+
je as useDnDProvider
|
|
1595
1594
|
};
|