@vue-dnd-kit/core 2.1.4 → 2.2.0
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/README.md +74 -74
- package/dist/external/components/DragPreview.vue.d.ts +8 -1
- package/dist/external/types/entities.d.ts +200 -198
- package/dist/external/types/index.d.ts +5 -5
- package/dist/external/types/operations.d.ts +186 -184
- package/dist/external/types/placement.d.ts +34 -34
- package/dist/external/types/pointer.d.ts +10 -10
- package/dist/external/types/provider.d.ts +84 -82
- package/dist/vue-dnd-kit-core.cjs.js +2 -2
- package/dist/vue-dnd-kit-core.es.js +356 -348
- package/package.json +75 -75
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-preview{transform-origin:0 0;will-change:transform
|
|
2
|
-
import { shallowRef as
|
|
3
|
-
const
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-preview{transform-origin:0 0;will-change:transform}.dnd-kit-preview-container{position:fixed;top:0;left:0;pointer-events:none;cursor:grabbing;z-index:9999}")),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
2
|
+
import { shallowRef as V, ref as oe, reactive as $, computed as b, watch as te, onScopeDispose as je, onMounted as X, onBeforeUnmount as Z, inject as Pe, defineComponent as Be, useTemplateRef as Oe, unref as q, openBlock as L, createElementBlock as j, normalizeStyle as Ce, renderSlot as me, Fragment as he, renderList as We, createBlock as J, resolveDynamicComponent as be, createCommentVNode as Je, provide as Qe, Teleport as et, createElementVNode as tt, mergeProps as nt } from "vue";
|
|
3
|
+
const O = {
|
|
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: `[${
|
|
8
|
+
}, H = {
|
|
9
|
+
SELECT_AREA: `[${O.SELECT_AREA}]`,
|
|
10
|
+
DRAGGABLE: `[${O.DRAGGABLE}]`,
|
|
11
|
+
CONSTRAINT_AREA: `[${O.CONSTRAINT_AREA}]`
|
|
12
12
|
}, xe = "VueDnDKitProvider", Ie = (e, t, n, s) => {
|
|
13
|
-
const
|
|
13
|
+
const i = /* @__PURE__ */ new Set();
|
|
14
14
|
return t.forEach((o) => {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
const g =
|
|
15
|
+
const a = e.get(o), r = s ? s(o) : a?.disabled;
|
|
16
|
+
if (!a || r) return;
|
|
17
|
+
const g = a.modifier?.keys, c = a.modifier?.method;
|
|
18
18
|
if (!g || !c || g.length === 0) {
|
|
19
|
-
|
|
19
|
+
i.add(o);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
g[c]((l) => n.value.has(l)) &&
|
|
23
|
-
}),
|
|
22
|
+
g[c]((l) => n.value.has(l)) && i.add(o);
|
|
23
|
+
}), i;
|
|
24
24
|
};
|
|
25
|
-
let
|
|
26
|
-
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null,
|
|
25
|
+
let Fe = "", st = "", it = "";
|
|
26
|
+
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, G = (e, t) => e !== t && e.contains(t), at = (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
|
+
Fe = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", w), window.addEventListener("selectstart", w), window.addEventListener("touchstart", w), window.addEventListener("touchmove", w);
|
|
29
29
|
}, ye = () => {
|
|
30
30
|
const e = document.body;
|
|
31
|
-
e.style.userSelect =
|
|
31
|
+
e.style.userSelect = Fe, e.style.touchAction = st, e.style.overscrollBehavior = it, window.removeEventListener("contextmenu", w), window.removeEventListener("selectstart", w), window.removeEventListener("touchstart", w), window.removeEventListener("touchmove", w);
|
|
32
32
|
}, w = (e) => e.preventDefault(), Ee = (e, t) => {
|
|
33
33
|
if (t.entities.draggableMap.get(e)?.disabled) return !0;
|
|
34
34
|
for (const s of t.entities.visibleDraggableSet)
|
|
35
|
-
if (t.entities.draggableMap.get(s)?.disabled &&
|
|
35
|
+
if (t.entities.draggableMap.get(s)?.disabled && G(s, e)) return !0;
|
|
36
36
|
return !1;
|
|
37
|
-
},
|
|
37
|
+
}, K = (e, t) => {
|
|
38
38
|
if (t.entities.droppableMap.get(e)?.disabled) return !0;
|
|
39
39
|
for (const s of t.entities.visibleDroppableSet)
|
|
40
|
-
if (t.entities.droppableMap.get(s)?.disabled &&
|
|
40
|
+
if (t.entities.droppableMap.get(s)?.disabled && G(s, e)) return !0;
|
|
41
41
|
return !1;
|
|
42
42
|
}, ne = (e, t) => {
|
|
43
43
|
if (!e.length || !t.length) return !0;
|
|
@@ -45,36 +45,36 @@ const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$e
|
|
|
45
45
|
return e.some((s) => n.has(s));
|
|
46
46
|
};
|
|
47
47
|
function ot(e, t, n, s) {
|
|
48
|
-
const
|
|
49
|
-
for (const
|
|
50
|
-
const r = n.get(
|
|
51
|
-
|
|
48
|
+
const i = [];
|
|
49
|
+
for (const a of t.keys()) {
|
|
50
|
+
const r = n.get(a);
|
|
51
|
+
i.push({ groups: r?.groups ?? [] });
|
|
52
52
|
}
|
|
53
53
|
const o = /* @__PURE__ */ new Set();
|
|
54
|
-
for (const
|
|
55
|
-
const r = s.get(
|
|
56
|
-
(!
|
|
54
|
+
for (const a of e) {
|
|
55
|
+
const r = s.get(a), g = r?.groups ?? [], c = r?.groupMatch ?? "every";
|
|
56
|
+
(!i.length || i[c]((l) => ne(l.groups, g))) && o.add(a);
|
|
57
57
|
}
|
|
58
58
|
return o;
|
|
59
59
|
}
|
|
60
60
|
function rt(e, t, n) {
|
|
61
61
|
const s = /* @__PURE__ */ new Set();
|
|
62
|
-
for (const
|
|
63
|
-
const r = n.get(
|
|
62
|
+
for (const a of t.keys()) {
|
|
63
|
+
const r = n.get(a);
|
|
64
64
|
for (const g of r?.groups ?? []) s.add(g);
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
for (const
|
|
68
|
-
const g = n.get(
|
|
69
|
-
ne(
|
|
66
|
+
const i = [...s], o = /* @__PURE__ */ new Set();
|
|
67
|
+
for (const a of e) {
|
|
68
|
+
const g = n.get(a)?.groups ?? [];
|
|
69
|
+
ne(i, g) && o.add(a);
|
|
70
70
|
}
|
|
71
71
|
return o;
|
|
72
72
|
}
|
|
73
73
|
const re = (e) => {
|
|
74
74
|
const t = new IntersectionObserver((n) => {
|
|
75
75
|
n.forEach((s) => {
|
|
76
|
-
const
|
|
77
|
-
e[s.isIntersecting ? "add" : "delete"](
|
|
76
|
+
const i = s.target;
|
|
77
|
+
e[s.isIntersecting ? "add" : "delete"](i);
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
return {
|
|
@@ -90,11 +90,11 @@ function Se(e, t = 0, n = 0) {
|
|
|
90
90
|
offset: { x: t, y: n }
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function Fe(e, t) {
|
|
94
|
-
const n = t.getBoundingClientRect(), s = n.width > 0 ? (e.clientX - n.left) / n.width : 0.5, a = n.height > 0 ? (e.clientY - n.top) / n.height : 0.5;
|
|
95
|
-
return { x: s, y: a };
|
|
96
|
-
}
|
|
97
93
|
function ze(e, t) {
|
|
94
|
+
const n = t.getBoundingClientRect(), s = n.width > 0 ? (e.clientX - n.left) / n.width : 0.5, i = n.height > 0 ? (e.clientY - n.top) / n.height : 0.5;
|
|
95
|
+
return { x: s, y: i };
|
|
96
|
+
}
|
|
97
|
+
function _e(e, t) {
|
|
98
98
|
return {
|
|
99
99
|
...t,
|
|
100
100
|
initialHTML: e.innerHTML,
|
|
@@ -104,14 +104,14 @@ function ze(e, t) {
|
|
|
104
104
|
}
|
|
105
105
|
function lt(e, t, n) {
|
|
106
106
|
e.forEach((s) => {
|
|
107
|
-
const
|
|
108
|
-
n.set(s,
|
|
107
|
+
const i = t.get(s);
|
|
108
|
+
n.set(s, _e(s, i));
|
|
109
109
|
}), e.clear();
|
|
110
110
|
}
|
|
111
111
|
function ct(e, t, n) {
|
|
112
112
|
n.clear();
|
|
113
113
|
const s = t.get(e);
|
|
114
|
-
n.set(e,
|
|
114
|
+
n.set(e, _e(e, s));
|
|
115
115
|
}
|
|
116
116
|
function Q(e) {
|
|
117
117
|
e.entities.initiatingDraggable && (e.state.value = "dragging", gt(
|
|
@@ -126,8 +126,8 @@ function gt(e, t, n, s) {
|
|
|
126
126
|
}
|
|
127
127
|
function He(e, t, n, s) {
|
|
128
128
|
if (s || !n) return !0;
|
|
129
|
-
const
|
|
130
|
-
return
|
|
129
|
+
const i = e.closest(n);
|
|
130
|
+
return i ? t.contains(i) : !1;
|
|
131
131
|
}
|
|
132
132
|
function ut(e, t) {
|
|
133
133
|
if (!e || !t) return 1;
|
|
@@ -137,18 +137,18 @@ function ut(e, t) {
|
|
|
137
137
|
return Math.min(c / t, 1);
|
|
138
138
|
}
|
|
139
139
|
const {
|
|
140
|
-
x:
|
|
140
|
+
x: i = 0,
|
|
141
141
|
y: o = 0,
|
|
142
|
-
condition:
|
|
142
|
+
condition: a = "any"
|
|
143
143
|
} = t;
|
|
144
|
-
if (
|
|
145
|
-
const r =
|
|
146
|
-
return
|
|
144
|
+
if (i === 0 && o === 0) return 1;
|
|
145
|
+
const r = i > 0 ? Math.min(n / i, 1) : 1, g = o > 0 ? Math.min(s / o, 1) : 1;
|
|
146
|
+
return a === "both" ? Math.min(r, g) : Math.max(r, g);
|
|
147
147
|
}
|
|
148
148
|
function Ge(e, t, n) {
|
|
149
149
|
if (!n) return !0;
|
|
150
|
-
const s = n.distance != null,
|
|
151
|
-
return !s && !
|
|
150
|
+
const s = n.distance != null, i = n.delay != null;
|
|
151
|
+
return !s && !i ? !0 : s && !i ? e >= 1 : !s && i ? t >= 1 : (n.condition ?? "both") === "both" ? e >= 1 && t >= 1 : e >= 1 || t >= 1;
|
|
152
152
|
}
|
|
153
153
|
function ft(e) {
|
|
154
154
|
if (e.state.value !== "activating" || !e.entities.initiatingDraggable)
|
|
@@ -169,9 +169,9 @@ function dt(e, t) {
|
|
|
169
169
|
n = null;
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const i = e.entities.draggableMap.get(
|
|
173
173
|
e.entities.initiatingDraggable
|
|
174
|
-
), o =
|
|
174
|
+
), o = i?.activation?.delay;
|
|
175
175
|
if (!o) {
|
|
176
176
|
n = null;
|
|
177
177
|
return;
|
|
@@ -182,7 +182,7 @@ function dt(e, t) {
|
|
|
182
182
|
), Ge(
|
|
183
183
|
e.distanceProgress.value,
|
|
184
184
|
e.delay.progress,
|
|
185
|
-
|
|
185
|
+
i?.activation
|
|
186
186
|
) ? (t(), n = null) : n = requestAnimationFrame(s);
|
|
187
187
|
};
|
|
188
188
|
return n = requestAnimationFrame(s), {
|
|
@@ -193,7 +193,7 @@ function dt(e, t) {
|
|
|
193
193
|
}
|
|
194
194
|
function mt(e, t) {
|
|
195
195
|
const n = e.closest(
|
|
196
|
-
|
|
196
|
+
H.CONSTRAINT_AREA
|
|
197
197
|
);
|
|
198
198
|
return !n || !t.has(n) ? null : {
|
|
199
199
|
element: n,
|
|
@@ -203,28 +203,28 @@ function mt(e, t) {
|
|
|
203
203
|
function ht(e, t, n, s) {
|
|
204
204
|
return n === "x" ? { x: e, y: s.top } : n === "y" ? { x: s.left, y: t } : { x: e, y: t };
|
|
205
205
|
}
|
|
206
|
-
function bt(e, t, n, s,
|
|
207
|
-
let o = e,
|
|
206
|
+
function bt(e, t, n, s, i) {
|
|
207
|
+
let o = e, a = t;
|
|
208
208
|
return n !== "y" && (o = Math.max(
|
|
209
209
|
s.left,
|
|
210
|
-
Math.min(s.right -
|
|
211
|
-
)), n !== "x" && (
|
|
210
|
+
Math.min(s.right - i.width, e)
|
|
211
|
+
)), n !== "x" && (a = Math.max(
|
|
212
212
|
s.top,
|
|
213
|
-
Math.min(s.bottom -
|
|
214
|
-
)), { x: o, y:
|
|
213
|
+
Math.min(s.bottom - i.height, t)
|
|
214
|
+
)), { x: o, y: a };
|
|
215
215
|
}
|
|
216
216
|
function pt(e, t, n, s) {
|
|
217
217
|
if (!e)
|
|
218
218
|
return { x: 0, y: 0 };
|
|
219
|
-
const
|
|
220
|
-
let
|
|
219
|
+
const i = t?.width ?? 0, o = t?.height ?? 0;
|
|
220
|
+
let a = e.current.x - i * e.offset.x, r = e.current.y - o * e.offset.y;
|
|
221
221
|
if (!n)
|
|
222
|
-
return { x:
|
|
222
|
+
return { x: a, y: r };
|
|
223
223
|
const g = mt(n, s);
|
|
224
224
|
if (!g)
|
|
225
|
-
return { x:
|
|
225
|
+
return { x: a, y: r };
|
|
226
226
|
const { element: c, entity: u } = g, l = c.getBoundingClientRect(), f = n.getBoundingClientRect(), d = ht(
|
|
227
|
-
|
|
227
|
+
a,
|
|
228
228
|
r,
|
|
229
229
|
u.axis || "both",
|
|
230
230
|
f
|
|
@@ -254,7 +254,7 @@ const Y = {
|
|
|
254
254
|
forMoveFaster: ["ShiftLeft", "ShiftRight"]
|
|
255
255
|
};
|
|
256
256
|
function yt(e, t) {
|
|
257
|
-
const n =
|
|
257
|
+
const n = V(), s = oe(), o = {
|
|
258
258
|
keys: {
|
|
259
259
|
pressedKeys: oe(/* @__PURE__ */ new Set()),
|
|
260
260
|
forDrag: [...Y.forDrag],
|
|
@@ -265,7 +265,7 @@ function yt(e, t) {
|
|
|
265
265
|
},
|
|
266
266
|
step: 8,
|
|
267
267
|
moveFaster: 4
|
|
268
|
-
},
|
|
268
|
+
}, a = $({
|
|
269
269
|
draggableMap: /* @__PURE__ */ new Map(),
|
|
270
270
|
droppableMap: /* @__PURE__ */ new Map(),
|
|
271
271
|
selectableAreaMap: /* @__PURE__ */ new Map(),
|
|
@@ -276,59 +276,59 @@ function yt(e, t) {
|
|
|
276
276
|
selectedSet: /* @__PURE__ */ new Set(),
|
|
277
277
|
selectionBase: /* @__PURE__ */ new Set(),
|
|
278
278
|
allowedDroppableSet: b(() => n.value ? ot(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
a.visibleDroppableSet,
|
|
280
|
+
a.draggingMap,
|
|
281
|
+
a.draggableMap,
|
|
282
|
+
a.droppableMap
|
|
283
283
|
) : /* @__PURE__ */ new Set()),
|
|
284
284
|
allowedDraggableSet: b(() => n.value ? rt(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
a.visibleDraggableSet,
|
|
286
|
+
a.draggingMap,
|
|
287
|
+
a.draggableMap
|
|
288
288
|
) : /* @__PURE__ */ new Set()),
|
|
289
289
|
modifiersSelectableAreaSet: b(() => Ie(
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
a.selectableAreaMap,
|
|
291
|
+
a.visibleSelectableAreaSet,
|
|
292
292
|
o.keys.pressedKeys
|
|
293
293
|
)),
|
|
294
294
|
modifiersDraggableSet: b(() => Ie(
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
a.draggableMap,
|
|
296
|
+
a.visibleDraggableSet,
|
|
297
297
|
o.keys.pressedKeys,
|
|
298
|
-
(S) => Ee(S, { entities:
|
|
298
|
+
(S) => Ee(S, { entities: a })
|
|
299
299
|
)),
|
|
300
300
|
visibleDraggableSet: /* @__PURE__ */ new Set(),
|
|
301
301
|
visibleDroppableSet: /* @__PURE__ */ new Set(),
|
|
302
302
|
visibleSelectableAreaSet: /* @__PURE__ */ new Set()
|
|
303
|
-
}), r =
|
|
303
|
+
}), r = $({
|
|
304
304
|
draggable: /* @__PURE__ */ new Map(),
|
|
305
305
|
droppable: /* @__PURE__ */ new Map()
|
|
306
306
|
}), g = {
|
|
307
|
-
throttle:
|
|
308
|
-
}, c =
|
|
307
|
+
throttle: V(0)
|
|
308
|
+
}, c = $({
|
|
309
309
|
x: window.scrollX,
|
|
310
310
|
y: window.scrollY
|
|
311
|
-
}), u =
|
|
311
|
+
}), u = $({
|
|
312
312
|
progress: 0,
|
|
313
313
|
startTime: 0
|
|
314
314
|
}), l = b(() => {
|
|
315
|
-
if (!s.value || !
|
|
316
|
-
const S =
|
|
315
|
+
if (!s.value || !a.initiatingDraggable) return 0;
|
|
316
|
+
const S = a.draggableMap.get(a.initiatingDraggable)?.activation?.distance;
|
|
317
317
|
return S ? ut(s.value, S) : 1;
|
|
318
318
|
}), f = re(
|
|
319
|
-
|
|
319
|
+
a.visibleDraggableSet
|
|
320
320
|
), d = re(
|
|
321
|
-
|
|
321
|
+
a.visibleDroppableSet
|
|
322
322
|
), m = re(
|
|
323
|
-
|
|
324
|
-
), h = oe(), M =
|
|
323
|
+
a.visibleSelectableAreaSet
|
|
324
|
+
), h = oe(), M = V(new DOMRect()), p = b(() => {
|
|
325
325
|
c.x, c.y;
|
|
326
|
-
const y = M.value, S =
|
|
326
|
+
const y = M.value, S = a.initiatingDraggable, k = S ? a.draggingMap.get(S) : null, T = y.width && y.height ? y : k?.initialRect ?? null;
|
|
327
327
|
return pt(
|
|
328
328
|
s.value,
|
|
329
329
|
T,
|
|
330
330
|
S || null,
|
|
331
|
-
|
|
331
|
+
a.constraintsAreaMap
|
|
332
332
|
);
|
|
333
333
|
}), x = b({
|
|
334
334
|
get: () => t?.previewTo,
|
|
@@ -337,7 +337,7 @@ function yt(e, t) {
|
|
|
337
337
|
return {
|
|
338
338
|
state: n,
|
|
339
339
|
pointer: s,
|
|
340
|
-
entities:
|
|
340
|
+
entities: a,
|
|
341
341
|
keyboard: o,
|
|
342
342
|
scrollPosition: c,
|
|
343
343
|
delay: u,
|
|
@@ -374,11 +374,11 @@ const ee = (e) => {
|
|
|
374
374
|
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();
|
|
375
375
|
};
|
|
376
376
|
function St(e) {
|
|
377
|
-
return e.parentElement?.closest(
|
|
377
|
+
return e.parentElement?.closest(H.SELECT_AREA) ?? null;
|
|
378
378
|
}
|
|
379
379
|
const Dt = (e, t, n) => {
|
|
380
380
|
if (!n) return {};
|
|
381
|
-
const s = n.getBoundingClientRect(),
|
|
381
|
+
const s = n.getBoundingClientRect(), i = Math.max(s.left, Math.min(e.x, t.x)), o = Math.max(s.top, Math.min(e.y, t.y)), a = Math.min(s.right, Math.max(e.x, t.x)), r = Math.min(s.bottom, Math.max(e.y, t.y)), g = Math.max(0, a - i), c = Math.max(0, r - o), u = i - s.left + n.scrollLeft, l = o - s.top + n.scrollTop;
|
|
382
382
|
return {
|
|
383
383
|
position: "absolute",
|
|
384
384
|
left: `${u}px`,
|
|
@@ -394,11 +394,11 @@ const Dt = (e, t, n) => {
|
|
|
394
394
|
const { selectingArea: t } = e.entities, n = wt(
|
|
395
395
|
e.pointer.value.start,
|
|
396
396
|
e.pointer.value.current
|
|
397
|
-
), s = e.entities.selectableAreaMap.get(t)?.groups ?? [],
|
|
397
|
+
), s = e.entities.selectableAreaMap.get(t)?.groups ?? [], i = e.lib.rectCache;
|
|
398
398
|
e.entities.visibleDraggableSet.forEach((o) => {
|
|
399
399
|
if (o === t || !t.contains(o)) return;
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
400
|
+
const a = St(o);
|
|
401
|
+
if (a && a !== t) {
|
|
402
402
|
e.entities.selectedSet.delete(o);
|
|
403
403
|
return;
|
|
404
404
|
}
|
|
@@ -411,27 +411,27 @@ const Dt = (e, t, n) => {
|
|
|
411
411
|
e.entities.selectedSet.delete(o);
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
|
-
let c =
|
|
415
|
-
c || (c = o.getBoundingClientRect(),
|
|
414
|
+
let c = i.get(o);
|
|
415
|
+
c || (c = o.getBoundingClientRect(), i.set(o, c));
|
|
416
416
|
const u = e.entities.selectionBase.has(o);
|
|
417
|
-
|
|
417
|
+
at(n, c) ? u ? e.entities.selectedSet.delete(o) : e.entities.selectedSet.add(o) : u ? e.entities.selectedSet.add(o) : e.entities.selectedSet.delete(o);
|
|
418
418
|
});
|
|
419
419
|
}, wt = (e, t) => {
|
|
420
|
-
const n = Math.min(e.x, t.x), s = Math.min(e.y, t.y),
|
|
421
|
-
return new DOMRect(n, s,
|
|
420
|
+
const n = Math.min(e.x, t.x), s = Math.min(e.y, t.y), i = Math.max(e.x, t.x), o = Math.max(e.y, t.y), a = i - n, r = o - s;
|
|
421
|
+
return new DOMRect(n, s, a, r);
|
|
422
422
|
};
|
|
423
423
|
function C(e, t, n) {
|
|
424
424
|
const s = Math.max(0, Math.min(t, e.length));
|
|
425
425
|
return [...e.slice(0, s), ...n, ...e.slice(s)];
|
|
426
426
|
}
|
|
427
427
|
function Le(e, t, n = 1) {
|
|
428
|
-
const s = Math.max(0, Math.min(t, e.length - 1)),
|
|
429
|
-
return [...e.slice(0, s), ...e.slice(s +
|
|
428
|
+
const s = Math.max(0, Math.min(t, e.length - 1)), i = Math.max(0, Math.min(n, e.length - s));
|
|
429
|
+
return [...e.slice(0, s), ...e.slice(s + i)];
|
|
430
430
|
}
|
|
431
|
-
function
|
|
432
|
-
const n = [...new Set(t)].filter((
|
|
431
|
+
function N(e, t) {
|
|
432
|
+
const n = [...new Set(t)].filter((i) => i >= 0 && i < e.length).sort((i, o) => o - i);
|
|
433
433
|
let s = e;
|
|
434
|
-
for (const
|
|
434
|
+
for (const i of n) s = Le(s, i, 1);
|
|
435
435
|
return s;
|
|
436
436
|
}
|
|
437
437
|
function Ne(e, t, n) {
|
|
@@ -451,15 +451,15 @@ const I = {
|
|
|
451
451
|
return I.getInsertSide(e, t) === "after" && !e?.center;
|
|
452
452
|
}
|
|
453
453
|
};
|
|
454
|
-
function
|
|
455
|
-
const { draggedItems: n, dropZone: s, hoveredDraggable:
|
|
454
|
+
function Ye(e, t) {
|
|
455
|
+
const { draggedItems: n, dropZone: s, hoveredDraggable: i } = e;
|
|
456
456
|
if (!n.length) return null;
|
|
457
|
-
const o =
|
|
458
|
-
if (!
|
|
459
|
-
const r = n[0].items, g = n.map((f) => f.index), c =
|
|
457
|
+
const o = i?.placement.center === !0 && s != null && s.items !== i.items, a = o ? s.items : i?.items ?? s?.items;
|
|
458
|
+
if (!a) return null;
|
|
459
|
+
const r = n[0].items, g = n.map((f) => f.index), c = a.length;
|
|
460
460
|
let u, l;
|
|
461
|
-
if (
|
|
462
|
-
const f =
|
|
461
|
+
if (i && !o) {
|
|
462
|
+
const f = i.items === r && g.includes(i.index);
|
|
463
463
|
if (f && n.length === 1) {
|
|
464
464
|
const d = I.isAtZoneStart(s?.placement, t);
|
|
465
465
|
u = d ? 0 : c, l = d ? "prepend" : "append";
|
|
@@ -467,7 +467,7 @@ function Ve(e, t) {
|
|
|
467
467
|
if (f)
|
|
468
468
|
return null;
|
|
469
469
|
{
|
|
470
|
-
const d = I.getInsertSide(
|
|
470
|
+
const d = I.getInsertSide(i.placement, t), m = i.index;
|
|
471
471
|
d === "before" ? (u = Math.max(0, m), l = "insert") : d === "after" ? (u = Math.min(c, m + 1), l = "insert") : (u = c, l = "append");
|
|
472
472
|
}
|
|
473
473
|
}
|
|
@@ -476,77 +476,77 @@ function Ve(e, t) {
|
|
|
476
476
|
const f = I.isAtZoneStart(s.placement, t);
|
|
477
477
|
u = f ? 0 : c, l = f ? "prepend" : "append";
|
|
478
478
|
}
|
|
479
|
-
return { targetIndex: u, mode: l, targetArr:
|
|
479
|
+
return { targetIndex: u, mode: l, targetArr: a };
|
|
480
480
|
}
|
|
481
481
|
function Mt(e, t = "vertical") {
|
|
482
482
|
const { draggedItems: n } = e;
|
|
483
483
|
if (!n.length) return null;
|
|
484
|
-
const s =
|
|
484
|
+
const s = Ye(e, t);
|
|
485
485
|
if (!s) return null;
|
|
486
|
-
const { targetArr:
|
|
487
|
-
let { targetIndex:
|
|
486
|
+
const { targetArr: i, mode: o } = s;
|
|
487
|
+
let { targetIndex: a } = s;
|
|
488
488
|
const r = n.map((l) => l.index), g = n.map((l) => l.item), c = n[0].items;
|
|
489
|
-
if (c ===
|
|
490
|
-
const l = r.filter((d) => d <
|
|
491
|
-
|
|
492
|
-
const f = C(
|
|
493
|
-
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex:
|
|
489
|
+
if (c === i) {
|
|
490
|
+
const l = r.filter((d) => d < a).length;
|
|
491
|
+
a = Math.max(0, a - l);
|
|
492
|
+
const f = C(N(c, r), a, g);
|
|
493
|
+
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: a, mode: o, sameList: !0 };
|
|
494
494
|
} else {
|
|
495
|
-
const l =
|
|
496
|
-
return { sourceItems: l, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex:
|
|
495
|
+
const l = N(c, r), f = C(i, a, g);
|
|
496
|
+
return { sourceItems: l, targetItems: f, draggedItems: g, sourceIndexes: r, targetIndex: a, mode: o, sameList: !1 };
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
function vt(e) {
|
|
500
500
|
const { draggedItems: t, hoveredDraggable: n } = e;
|
|
501
501
|
if (!t.length || !n) return null;
|
|
502
|
-
const s = t.map((u) => u.index),
|
|
503
|
-
if (c && s.includes(
|
|
502
|
+
const s = t.map((u) => u.index), i = n.index, o = t.map((u) => u.item), a = n.item, r = t[0].items, g = n.items, c = r === g;
|
|
503
|
+
if (c && s.includes(i)) return null;
|
|
504
504
|
if (t.length === 1) {
|
|
505
505
|
const u = s[0];
|
|
506
506
|
if (c) {
|
|
507
|
-
const l = Ne(r, u,
|
|
508
|
-
return { sourceItems: l, targetItems: l, sourceIndexes: s, targetIndex:
|
|
507
|
+
const l = Ne(r, u, i);
|
|
508
|
+
return { sourceItems: l, targetItems: l, sourceIndexes: s, targetIndex: i, sameList: !0 };
|
|
509
509
|
} else {
|
|
510
510
|
const l = [...r], f = [...g];
|
|
511
|
-
return l[u] = g[
|
|
511
|
+
return l[u] = g[i], f[i] = r[u], { sourceItems: l, targetItems: f, sourceIndexes: s, targetIndex: i, sameList: !1 };
|
|
512
512
|
}
|
|
513
513
|
} else {
|
|
514
514
|
const u = Math.min(...s);
|
|
515
515
|
if (c) {
|
|
516
|
-
const l = s.filter((p) => p <
|
|
517
|
-
let h =
|
|
516
|
+
const l = s.filter((p) => p < i).length, f = Math.max(0, i - l), d = s.filter((p) => p < u).length, m = Math.max(0, u - d);
|
|
517
|
+
let h = N(r, s);
|
|
518
518
|
h = C(h, f, o);
|
|
519
519
|
const M = m >= f ? m + o.length : m;
|
|
520
|
-
return h = C(h, M, [
|
|
520
|
+
return h = C(h, M, [a]), { sourceItems: h, targetItems: h, sourceIndexes: s, targetIndex: f, sameList: !0 };
|
|
521
521
|
} else {
|
|
522
522
|
const l = s.filter((h) => h < u).length, f = Math.max(0, u - l);
|
|
523
|
-
let d =
|
|
524
|
-
d = C(d, f, [
|
|
525
|
-
let m = Le(g,
|
|
526
|
-
return m = C(m,
|
|
523
|
+
let d = N(r, s);
|
|
524
|
+
d = C(d, f, [a]);
|
|
525
|
+
let m = Le(g, i);
|
|
526
|
+
return m = C(m, i, o), { sourceItems: d, targetItems: m, sourceIndexes: s, targetIndex: i, sameList: !1 };
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
530
|
function At(e, t = "vertical") {
|
|
531
531
|
const { draggedItems: n } = e;
|
|
532
532
|
if (!n.length) return null;
|
|
533
|
-
const s =
|
|
533
|
+
const s = Ye(e, t);
|
|
534
534
|
if (!s) return null;
|
|
535
|
-
const { targetArr:
|
|
536
|
-
return { targetItems: C(
|
|
535
|
+
const { targetArr: i, targetIndex: o, mode: a } = s, r = n.map((c) => c.item);
|
|
536
|
+
return { targetItems: C(i, o, r), copiedItems: r, targetIndex: o, mode: a };
|
|
537
537
|
}
|
|
538
538
|
function xt(e) {
|
|
539
539
|
const { draggedItems: t } = e;
|
|
540
540
|
if (!t.length) return null;
|
|
541
|
-
const n = t.map((
|
|
542
|
-
return { sourceItems:
|
|
541
|
+
const n = t.map((a) => a.index), s = t.map((a) => a.item), i = t[0].items;
|
|
542
|
+
return { sourceItems: N(i, n), removedItems: s, sourceIndexes: n };
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function Ve(e) {
|
|
545
545
|
return {
|
|
546
546
|
// Low-level array ops
|
|
547
547
|
insertAt: C,
|
|
548
548
|
removeAt: Le,
|
|
549
|
-
removeIndexes:
|
|
549
|
+
removeIndexes: N,
|
|
550
550
|
swapAt: Ne,
|
|
551
551
|
// Placement helpers
|
|
552
552
|
getInsertSide: (t, n) => I.getInsertSide(t, n),
|
|
@@ -560,7 +560,7 @@ function Ye(e) {
|
|
|
560
560
|
};
|
|
561
561
|
}
|
|
562
562
|
const B = (e) => e.keys().next().value, Et = (e) => e.target.closest(
|
|
563
|
-
|
|
563
|
+
H.DRAGGABLE
|
|
564
564
|
);
|
|
565
565
|
function Lt(e) {
|
|
566
566
|
const t = e.entities.initiatingDraggable;
|
|
@@ -568,9 +568,9 @@ function Lt(e) {
|
|
|
568
568
|
const n = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t), s = n?.payload;
|
|
569
569
|
if (!s)
|
|
570
570
|
return n?.data ? [{ index: -1, item: void 0, items: [], data: n.data() }] : [];
|
|
571
|
-
const
|
|
572
|
-
if (!Array.isArray(
|
|
573
|
-
const [o,
|
|
571
|
+
const i = s();
|
|
572
|
+
if (!Array.isArray(i) || i.length < 2) return [];
|
|
573
|
+
const [o, a] = i, r = Number(o), g = a, c = /* @__PURE__ */ new Map();
|
|
574
574
|
return c.set(r, {
|
|
575
575
|
index: r,
|
|
576
576
|
item: g[r],
|
|
@@ -594,7 +594,7 @@ function Lt(e) {
|
|
|
594
594
|
}
|
|
595
595
|
const A = (e, t) => {
|
|
596
596
|
const n = Lt(e);
|
|
597
|
-
let s,
|
|
597
|
+
let s, i;
|
|
598
598
|
if (t) {
|
|
599
599
|
const o = e.entities.droppableMap.get(t);
|
|
600
600
|
if (o) {
|
|
@@ -605,15 +605,15 @@ const A = (e, t) => {
|
|
|
605
605
|
data: o.data?.()
|
|
606
606
|
};
|
|
607
607
|
}
|
|
608
|
-
const
|
|
609
|
-
if (
|
|
610
|
-
const g = e.entities.draggableMap.get(
|
|
608
|
+
const a = B(e.hovered.draggable);
|
|
609
|
+
if (a && (a === t || t.contains(a)) && a) {
|
|
610
|
+
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 };
|
|
611
611
|
if (c) {
|
|
612
612
|
const f = c();
|
|
613
613
|
if (Array.isArray(f) && f.length >= 2) {
|
|
614
614
|
const [d, m] = f, h = Number(d);
|
|
615
|
-
|
|
616
|
-
element:
|
|
615
|
+
i = {
|
|
616
|
+
element: a,
|
|
617
617
|
placement: u ?? l,
|
|
618
618
|
index: h,
|
|
619
619
|
item: m[h],
|
|
@@ -621,8 +621,8 @@ const A = (e, t) => {
|
|
|
621
621
|
data: g?.data?.()
|
|
622
622
|
};
|
|
623
623
|
}
|
|
624
|
-
} else g?.data && (
|
|
625
|
-
element:
|
|
624
|
+
} else g?.data && (i = {
|
|
625
|
+
element: a,
|
|
626
626
|
placement: u ?? l,
|
|
627
627
|
index: -1,
|
|
628
628
|
item: void 0,
|
|
@@ -634,11 +634,11 @@ const A = (e, t) => {
|
|
|
634
634
|
return {
|
|
635
635
|
draggedItems: n,
|
|
636
636
|
dropZone: s,
|
|
637
|
-
hoveredDraggable:
|
|
637
|
+
hoveredDraggable: i,
|
|
638
638
|
provider: e,
|
|
639
|
-
helpers:
|
|
639
|
+
helpers: Ve({ draggedItems: n, dropZone: s, hoveredDraggable: i })
|
|
640
640
|
};
|
|
641
|
-
},
|
|
641
|
+
}, F = (e, t, n) => {
|
|
642
642
|
if (!t) return;
|
|
643
643
|
const s = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t);
|
|
644
644
|
!s || s.disabled || s.events?.[n]?.(A(e));
|
|
@@ -649,11 +649,11 @@ const A = (e, t) => {
|
|
|
649
649
|
});
|
|
650
650
|
}, Ct = (e, t, n) => {
|
|
651
651
|
if (t !== n) {
|
|
652
|
-
if (t && !
|
|
652
|
+
if (t && !K(t, e)) {
|
|
653
653
|
const s = A(e, t);
|
|
654
654
|
e.entities.droppableMap.get(t)?.events?.onLeave?.(s);
|
|
655
655
|
}
|
|
656
|
-
if (n && !
|
|
656
|
+
if (n && !K(n, e)) {
|
|
657
657
|
const s = A(e, n);
|
|
658
658
|
e.entities.droppableMap.get(n)?.events?.onEnter?.(s);
|
|
659
659
|
}
|
|
@@ -662,12 +662,12 @@ const A = (e, t) => {
|
|
|
662
662
|
if (t !== n) {
|
|
663
663
|
const s = A(e);
|
|
664
664
|
if (t) {
|
|
665
|
-
const
|
|
666
|
-
|
|
665
|
+
const i = e.entities.draggableMap.get(t);
|
|
666
|
+
i && !i.disabled && i.events?.onLeave?.(s);
|
|
667
667
|
}
|
|
668
668
|
if (n) {
|
|
669
|
-
const
|
|
670
|
-
|
|
669
|
+
const i = e.entities.draggableMap.get(n);
|
|
670
|
+
i && !i.disabled && i.events?.onHover?.(s);
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
673
|
}, le = (e, t, n) => {
|
|
@@ -675,10 +675,10 @@ const A = (e, t) => {
|
|
|
675
675
|
!s || !e.entities.draggingMap.has(s) || e.entities.draggingMap.get(s)?.events?.[n]?.(A(e));
|
|
676
676
|
}, Rt = (e, t) => {
|
|
677
677
|
const n = B(t.droppable);
|
|
678
|
-
n && !
|
|
678
|
+
n && !K(n, e) && e.entities.droppableMap.get(n)?.events?.onLeave?.(A(e, n));
|
|
679
679
|
}, De = (e, t) => {
|
|
680
680
|
const n = B(t.droppable);
|
|
681
|
-
n && !
|
|
681
|
+
n && !K(n, e) && e.entities.droppableMap.get(n)?.events?.onLeave?.(A(e, n));
|
|
682
682
|
}, kt = (e, t, n = 5) => {
|
|
683
683
|
const s = n / 2;
|
|
684
684
|
return {
|
|
@@ -691,10 +691,10 @@ const A = (e, t) => {
|
|
|
691
691
|
const t = e.pointer.value?.current, n = t?.x ?? 0, s = t?.y ?? 0;
|
|
692
692
|
return kt(n, s, 5);
|
|
693
693
|
}, P = (e, t, n) => {
|
|
694
|
-
const s = e.left + e.width / 2,
|
|
694
|
+
const s = e.left + e.width / 2, i = e.top + e.height / 2;
|
|
695
695
|
if (n) {
|
|
696
696
|
const r = n.top ?? 0, g = n.right ?? 0, c = n.bottom ?? 0, u = n.left ?? 0, l = t.left + u, f = t.right - g, d = t.top + r, m = t.bottom - c;
|
|
697
|
-
if (l < f && d < m && s >= l && s <= f &&
|
|
697
|
+
if (l < f && d < m && s >= l && s <= f && i >= d && i <= m)
|
|
698
698
|
return {
|
|
699
699
|
top: !1,
|
|
700
700
|
right: !1,
|
|
@@ -703,10 +703,10 @@ const A = (e, t) => {
|
|
|
703
703
|
center: !0
|
|
704
704
|
};
|
|
705
705
|
}
|
|
706
|
-
const o = t.left + t.width / 2,
|
|
706
|
+
const o = t.left + t.width / 2, a = t.top + t.height / 2;
|
|
707
707
|
return {
|
|
708
|
-
top:
|
|
709
|
-
bottom:
|
|
708
|
+
top: i <= a,
|
|
709
|
+
bottom: i > a,
|
|
710
710
|
left: s <= o,
|
|
711
711
|
right: s > o,
|
|
712
712
|
center: !1
|
|
@@ -721,18 +721,18 @@ const A = (e, t) => {
|
|
|
721
721
|
function Bt(e, t) {
|
|
722
722
|
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;
|
|
723
723
|
}
|
|
724
|
-
function
|
|
724
|
+
function U(e, t) {
|
|
725
725
|
Bt(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
726
726
|
}
|
|
727
|
-
const
|
|
728
|
-
const s = B(t.droppable),
|
|
729
|
-
|
|
730
|
-
const o = Tt(e),
|
|
731
|
-
if (
|
|
732
|
-
const l =
|
|
727
|
+
const Ot = (e, t) => e.find((n) => n !== t && G(t, n)), we = (e, t, n) => {
|
|
728
|
+
const s = B(t.droppable), i = B(t.draggable);
|
|
729
|
+
i && t.draggable.delete(i), s && t.droppable.delete(s);
|
|
730
|
+
const o = Tt(e), a = n.zones[0], r = n.elements[0];
|
|
731
|
+
if (a && r && a === r && e.entities.droppableMap.has(a) && a) {
|
|
732
|
+
const l = a.getBoundingClientRect(), f = e.entities.draggableMap.get(a)?.placementMargins, d = P(o, l, f);
|
|
733
733
|
if (d.center) {
|
|
734
|
-
t.droppable.set(
|
|
735
|
-
const m =
|
|
734
|
+
t.droppable.set(a, d);
|
|
735
|
+
const m = Ot(n.elements, a);
|
|
736
736
|
if (m) {
|
|
737
737
|
const h = m.getBoundingClientRect();
|
|
738
738
|
t.draggable.set(
|
|
@@ -742,7 +742,7 @@ const _t = (e, t) => e.find((n) => n !== t && K(t, n)), we = (e, t, n) => {
|
|
|
742
742
|
}
|
|
743
743
|
} else {
|
|
744
744
|
t.draggable.set(r, d);
|
|
745
|
-
const m = n.zones.find((h) => h !==
|
|
745
|
+
const m = n.zones.find((h) => h !== a);
|
|
746
746
|
if (m) {
|
|
747
747
|
const h = m.getBoundingClientRect();
|
|
748
748
|
t.droppable.set(
|
|
@@ -752,20 +752,20 @@ const _t = (e, t) => e.find((n) => n !== t && K(t, n)), we = (e, t, n) => {
|
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
754
|
} else {
|
|
755
|
-
if (
|
|
756
|
-
const l =
|
|
757
|
-
t.droppable.set(
|
|
755
|
+
if (a) {
|
|
756
|
+
const l = a.getBoundingClientRect();
|
|
757
|
+
t.droppable.set(a, P(o, l));
|
|
758
758
|
}
|
|
759
759
|
if (r)
|
|
760
|
-
if (
|
|
761
|
-
if (
|
|
760
|
+
if (a)
|
|
761
|
+
if (G(a, r)) {
|
|
762
762
|
const l = r.getBoundingClientRect(), f = e.entities.draggableMap.get(r)?.placementMargins;
|
|
763
763
|
t.draggable.set(
|
|
764
764
|
r,
|
|
765
765
|
P(o, l, f)
|
|
766
766
|
);
|
|
767
767
|
} else {
|
|
768
|
-
const l = e.pointer.value?.current ?? { x: 0, y: 0 }, f =
|
|
768
|
+
const l = e.pointer.value?.current ?? { x: 0, y: 0 }, f = a.getBoundingClientRect(), d = r.getBoundingClientRect(), m = Re(l, f);
|
|
769
769
|
if (Re(l, d) < m) {
|
|
770
770
|
t.droppable.clear();
|
|
771
771
|
const M = e.entities.draggableMap.get(r)?.placementMargins;
|
|
@@ -784,23 +784,23 @@ const _t = (e, t) => e.find((n) => n !== t && K(t, n)), we = (e, t, n) => {
|
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
const c = B(t.droppable), u = B(t.draggable);
|
|
787
|
-
if (
|
|
788
|
-
const l = e.entities.draggableMap.get(
|
|
789
|
-
l &&
|
|
787
|
+
if (i && i !== u) {
|
|
788
|
+
const l = e.entities.draggableMap.get(i);
|
|
789
|
+
l && U(l, void 0);
|
|
790
790
|
}
|
|
791
791
|
if (s && s !== c) {
|
|
792
792
|
const l = e.entities.droppableMap.get(s);
|
|
793
|
-
l &&
|
|
793
|
+
l && U(l, void 0);
|
|
794
794
|
}
|
|
795
795
|
if (u) {
|
|
796
796
|
const l = e.entities.draggableMap.get(u);
|
|
797
|
-
l &&
|
|
797
|
+
l && U(l, t.draggable.get(u));
|
|
798
798
|
}
|
|
799
799
|
if (c) {
|
|
800
800
|
const l = e.entities.droppableMap.get(c);
|
|
801
|
-
l &&
|
|
801
|
+
l && U(l, t.droppable.get(c));
|
|
802
802
|
}
|
|
803
|
-
Ct(e, s, c), It(e,
|
|
803
|
+
Ct(e, s, c), It(e, i, u);
|
|
804
804
|
}, ce = (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, ge = (e) => {
|
|
805
805
|
if (!e)
|
|
806
806
|
return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
|
|
@@ -822,35 +822,35 @@ const _t = (e, t) => e.find((n) => n !== t && K(t, n)), we = (e, t, n) => {
|
|
|
822
822
|
), s = Math.max(
|
|
823
823
|
0,
|
|
824
824
|
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
|
|
825
|
-
),
|
|
826
|
-
return o === 0 ||
|
|
827
|
-
},
|
|
828
|
-
const t = e.preview.position?.value ?? { x: 0, y: 0 }, { x: n, y: s } = t,
|
|
829
|
-
let o,
|
|
830
|
-
if (
|
|
831
|
-
o =
|
|
825
|
+
), i = n * s, o = e.width * e.height, a = t.width * t.height;
|
|
826
|
+
return o === 0 || a === 0 ? 0 : (i / o * 100 + i / a * 100) / 2;
|
|
827
|
+
}, Ft = (e) => e.preview.ref?.value ?? null, ke = (e) => {
|
|
828
|
+
const t = e.preview.position?.value ?? { x: 0, y: 0 }, { x: n, y: s } = t, i = e.preview.size?.value;
|
|
829
|
+
let o, a;
|
|
830
|
+
if (i)
|
|
831
|
+
o = i.width, a = i.height;
|
|
832
832
|
else {
|
|
833
833
|
const r = e.preview.ref?.value?.getBoundingClientRect();
|
|
834
|
-
o = r?.width ?? 0,
|
|
834
|
+
o = r?.width ?? 0, a = r?.height ?? 0;
|
|
835
835
|
}
|
|
836
836
|
return {
|
|
837
837
|
x: n,
|
|
838
838
|
y: s,
|
|
839
839
|
width: o,
|
|
840
|
-
height:
|
|
840
|
+
height: a,
|
|
841
841
|
top: s,
|
|
842
842
|
left: n,
|
|
843
843
|
right: n + o,
|
|
844
|
-
bottom: s +
|
|
844
|
+
bottom: s + a
|
|
845
845
|
};
|
|
846
|
-
}, Me = (e) => e.entities.allowedDraggableSet,
|
|
847
|
-
if (
|
|
846
|
+
}, Me = (e) => e.entities.allowedDraggableSet, Xe = (e) => e.entities.allowedDroppableSet, zt = (e, t) => !t.entities.draggingMap.has(e), _t = (e, t) => ![...t.entities.draggingMap.keys()].some((n) => {
|
|
847
|
+
if (G(n, e)) return !0;
|
|
848
848
|
const s = n.parentElement;
|
|
849
|
-
return !!(s && e !== n && !t.entities.draggableMap.has(s) && !t.entities.droppableMap.has(s) &&
|
|
849
|
+
return !!(s && e !== n && !t.entities.draggableMap.has(s) && !t.entities.droppableMap.has(s) && G(s, e) && [
|
|
850
850
|
...t.entities.draggableMap.keys()
|
|
851
851
|
].filter((o) => o.parentElement === s).length === 1);
|
|
852
|
-
}), Ht = (e, t) => t.entities.draggableMap.has(e) ? !Ee(e, t) : t.entities.droppableMap.has(e) ? !
|
|
853
|
-
function
|
|
852
|
+
}), Ht = (e, t) => t.entities.draggableMap.has(e) ? !Ee(e, t) : t.entities.droppableMap.has(e) ? !K(e, t) : !0, W = (e, t) => zt(e, t) && _t(e, t) && Ht(e, t), fe = 10;
|
|
853
|
+
function _(e, t) {
|
|
854
854
|
return Math.hypot(
|
|
855
855
|
t.x - (e.x + e.width / 2),
|
|
856
856
|
t.y - (e.y + e.height / 2)
|
|
@@ -859,14 +859,14 @@ function z(e, t) {
|
|
|
859
859
|
function Gt(e) {
|
|
860
860
|
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, n = document.elementFromPoint(t.x, t.y);
|
|
861
861
|
if (!n) return null;
|
|
862
|
-
const s = Me(e),
|
|
862
|
+
const s = Me(e), i = Xe(e), o = [], a = [];
|
|
863
863
|
let r = n;
|
|
864
864
|
for (; r; )
|
|
865
|
-
(s.has(r) ||
|
|
866
|
-
return o.length === 0 &&
|
|
865
|
+
(s.has(r) || i.has(r)) && W(r, e) && (s.has(r) && o.push(r), i.has(r) && a.push(r)), r = r.parentElement;
|
|
866
|
+
return o.length === 0 && a.length === 0 ? null : { elements: o, zones: a };
|
|
867
867
|
}
|
|
868
868
|
const ve = (e) => {
|
|
869
|
-
if (!
|
|
869
|
+
if (!Ft(e)) return { elements: [], zones: [] };
|
|
870
870
|
const n = e.pointer.value?.current ?? { x: 0, y: 0 }, s = Gt(e);
|
|
871
871
|
if (s) {
|
|
872
872
|
if (s.elements.length > 0) return s;
|
|
@@ -874,20 +874,20 @@ const ve = (e) => {
|
|
|
874
874
|
if (!c) return s;
|
|
875
875
|
const u = ke(e);
|
|
876
876
|
return { elements: [...Me(e)].filter(
|
|
877
|
-
(d) => c.contains(d) &&
|
|
877
|
+
(d) => c.contains(d) && W(d, e)
|
|
878
878
|
).map((d) => ({ el: d, box: ge(d) })).filter(
|
|
879
879
|
({ box: d }) => ce(d, u) && ue(d, u) >= fe
|
|
880
|
-
).sort((d, m) =>
|
|
880
|
+
).sort((d, m) => _(d.box, n) - _(m.box, n)).map(({ el: d }) => d), zones: s.zones };
|
|
881
881
|
}
|
|
882
|
-
const
|
|
883
|
-
(c) =>
|
|
884
|
-
),
|
|
885
|
-
(c) =>
|
|
882
|
+
const i = ke(e), o = [...Me(e)].filter(
|
|
883
|
+
(c) => W(c, e)
|
|
884
|
+
), a = [...Xe(e)].filter(
|
|
885
|
+
(c) => W(c, e)
|
|
886
886
|
), r = o.map((c) => ({ n: c, box: ge(c) })).filter(
|
|
887
|
-
({ box: c }) => ce(c,
|
|
888
|
-
).sort((c, u) =>
|
|
889
|
-
({ box: c }) => ce(c,
|
|
890
|
-
).sort((c, u) =>
|
|
887
|
+
({ box: c }) => ce(c, i) && ue(c, i) >= fe
|
|
888
|
+
).sort((c, u) => _(c.box, n) - _(u.box, n)).map(({ n: c }) => c), g = a.map((c) => ({ n: c, box: ge(c) })).filter(
|
|
889
|
+
({ box: c }) => ce(c, i) && ue(c, i) >= fe
|
|
890
|
+
).sort((c, u) => _(c.box, n) - _(u.box, n)).map(({ n: c }) => c);
|
|
891
891
|
return { elements: r, zones: g };
|
|
892
892
|
};
|
|
893
893
|
function Ae(e) {
|
|
@@ -903,11 +903,11 @@ function Kt(e, t) {
|
|
|
903
903
|
const s = Date.now();
|
|
904
904
|
s - t.value >= n && (t.value = s, Ae(e));
|
|
905
905
|
}
|
|
906
|
-
async function
|
|
906
|
+
async function Ze(e) {
|
|
907
907
|
const t = e.hovered.droppable.keys().next().value;
|
|
908
|
-
if (!t ||
|
|
908
|
+
if (!t || K(t, e)) return "accept";
|
|
909
909
|
const n = e.entities.droppableMap.get(t), s = A(e, t);
|
|
910
|
-
let
|
|
910
|
+
let i = s;
|
|
911
911
|
if (n?.groupMatch === "some" && (n.groups?.length ?? 0) > 0) {
|
|
912
912
|
const r = n.groups, g = s.draggedItems.filter((u) => {
|
|
913
913
|
for (const [, l] of e.entities.draggingMap) {
|
|
@@ -923,7 +923,7 @@ async function Xe(e) {
|
|
|
923
923
|
const u = (l) => ({
|
|
924
924
|
...s,
|
|
925
925
|
draggedItems: l,
|
|
926
|
-
helpers:
|
|
926
|
+
helpers: Ve({ ...s, draggedItems: l })
|
|
927
927
|
});
|
|
928
928
|
if (n.events?.onValidate) {
|
|
929
929
|
const l = n.events.onValidate({
|
|
@@ -939,7 +939,7 @@ async function Xe(e) {
|
|
|
939
939
|
d = await l;
|
|
940
940
|
} catch {
|
|
941
941
|
const h = e.entities.initiatingDraggable;
|
|
942
|
-
return
|
|
942
|
+
return F(e, h, "onSelfDragCancel"), v(e, "onDragCancel"), De(e, e.hovered), "cancel";
|
|
943
943
|
}
|
|
944
944
|
} else
|
|
945
945
|
d = l;
|
|
@@ -947,14 +947,14 @@ async function Xe(e) {
|
|
|
947
947
|
return e.state.value = "dragging", "decline";
|
|
948
948
|
const m = Array.isArray(d) ? d : g;
|
|
949
949
|
if (m.length === 0) return "accept";
|
|
950
|
-
|
|
950
|
+
i = u(m);
|
|
951
951
|
} else {
|
|
952
952
|
if (g.length === 0) return "accept";
|
|
953
|
-
|
|
953
|
+
i = u(g);
|
|
954
954
|
}
|
|
955
955
|
}
|
|
956
956
|
}
|
|
957
|
-
const o = n?.events?.onDrop?.(
|
|
957
|
+
const o = n?.events?.onDrop?.(i);
|
|
958
958
|
if (o != null && typeof o.then == "function") {
|
|
959
959
|
e.state.value = "pending";
|
|
960
960
|
let r;
|
|
@@ -962,7 +962,7 @@ async function Xe(e) {
|
|
|
962
962
|
r = await o;
|
|
963
963
|
} catch {
|
|
964
964
|
const g = e.entities.initiatingDraggable;
|
|
965
|
-
return
|
|
965
|
+
return F(e, g, "onSelfDragCancel"), v(e, "onDragCancel"), De(e, e.hovered), "cancel";
|
|
966
966
|
}
|
|
967
967
|
return r === !1 ? (e.state.value = "dragging", "decline") : "accept";
|
|
968
968
|
}
|
|
@@ -970,7 +970,7 @@ async function Xe(e) {
|
|
|
970
970
|
}
|
|
971
971
|
function $e(e) {
|
|
972
972
|
const t = e.entities.initiatingDraggable;
|
|
973
|
-
|
|
973
|
+
F(e, t, "onSelfDragEnd"), v(e, "onDragEnd"), Rt(e, e.hovered);
|
|
974
974
|
}
|
|
975
975
|
function Nt(e) {
|
|
976
976
|
const t = e.entities.selectingArea;
|
|
@@ -978,22 +978,22 @@ function Nt(e) {
|
|
|
978
978
|
const n = e.entities.selectableAreaMap.get(t), s = [...e.entities.selectedSet];
|
|
979
979
|
n?.events?.onSelected?.(s);
|
|
980
980
|
}
|
|
981
|
-
const
|
|
981
|
+
const Yt = (e) => {
|
|
982
982
|
const t = {
|
|
983
983
|
current: null
|
|
984
984
|
}, n = { value: 0 }, s = async () => {
|
|
985
985
|
ye(), t.current?.cancel(), t.current = null;
|
|
986
986
|
const r = e.state.value;
|
|
987
987
|
if (r === "dragging") {
|
|
988
|
-
const g = await
|
|
988
|
+
const g = await Ze(e);
|
|
989
989
|
if (g === "accept" && $e(e), g === "accept" || g === "cancel") {
|
|
990
|
-
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove",
|
|
990
|
+
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i);
|
|
991
991
|
return;
|
|
992
992
|
}
|
|
993
993
|
return;
|
|
994
994
|
} else r === "selecting" && Nt(e);
|
|
995
|
-
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove",
|
|
996
|
-
},
|
|
995
|
+
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i);
|
|
996
|
+
}, i = (r) => {
|
|
997
997
|
if (e.pointer.value && e.state.value !== "pending") {
|
|
998
998
|
if (e.pointer.value.current = { x: r.clientX, y: r.clientY }, ft(e)) {
|
|
999
999
|
le(e, r, "onSelfDragStart"), v(e, "onDragStart");
|
|
@@ -1002,17 +1002,17 @@ const Vt = (e) => {
|
|
|
1002
1002
|
if (e.state.value === "dragging") {
|
|
1003
1003
|
Kt(e, n);
|
|
1004
1004
|
const g = e.entities.initiatingDraggable;
|
|
1005
|
-
|
|
1005
|
+
F(e, g, "onSelfDragMove"), v(e, "onDragMove");
|
|
1006
1006
|
}
|
|
1007
1007
|
e.state.value === "selecting" && Ke(e);
|
|
1008
1008
|
}
|
|
1009
1009
|
};
|
|
1010
1010
|
return { pointerDown: (r) => {
|
|
1011
|
-
document.addEventListener("pointerup", s), document.addEventListener("pointermove",
|
|
1011
|
+
document.addEventListener("pointerup", s), document.addEventListener("pointermove", i);
|
|
1012
1012
|
const g = r.target, c = g.closest(
|
|
1013
|
-
|
|
1013
|
+
H.SELECT_AREA
|
|
1014
1014
|
), u = g.closest(
|
|
1015
|
-
|
|
1015
|
+
H.DRAGGABLE
|
|
1016
1016
|
);
|
|
1017
1017
|
if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(c)) {
|
|
1018
1018
|
pe(), e.pointer.value = Se(r), e.state.value = "selecting", e.entities.selectingArea = c, e.entities.selectionBase = new Set(e.entities.selectedSet);
|
|
@@ -1023,15 +1023,15 @@ const Vt = (e) => {
|
|
|
1023
1023
|
if (!He(g, u, l?.dragHandle))
|
|
1024
1024
|
return;
|
|
1025
1025
|
pe(), e.entities.initiatingDraggable = u;
|
|
1026
|
-
const f =
|
|
1026
|
+
const f = ze(r, u);
|
|
1027
1027
|
e.pointer.value = Se(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 = dt(e, () => {
|
|
1028
1028
|
Q(e), le(e, r, "onSelfDragStart"), v(e, "onDragStart");
|
|
1029
1029
|
}))) : (Q(e), le(e, r, "onSelfDragStart"), v(e, "onDragStart"));
|
|
1030
1030
|
}
|
|
1031
|
-
}, pointerUp: s, pointerMove:
|
|
1032
|
-
t.current?.cancel(), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove",
|
|
1031
|
+
}, pointerUp: s, pointerMove: i, cleanup: () => {
|
|
1032
|
+
t.current?.cancel(), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i), e.lib.draggableObserver.disconnect(), e.lib.droppableObserver.disconnect(), e.lib.selectableAreaObserver.disconnect();
|
|
1033
1033
|
} };
|
|
1034
|
-
},
|
|
1034
|
+
}, Vt = {
|
|
1035
1035
|
ArrowUp: { dx: 0, dy: -1 },
|
|
1036
1036
|
ArrowDown: { dx: 0, dy: 1 },
|
|
1037
1037
|
ArrowLeft: { dx: -1, dy: 0 },
|
|
@@ -1040,11 +1040,11 @@ const Vt = (e) => {
|
|
|
1040
1040
|
KeyA: { dx: -1, dy: 0 },
|
|
1041
1041
|
KeyS: { dx: 0, dy: 1 },
|
|
1042
1042
|
KeyD: { dx: 1, dy: 0 }
|
|
1043
|
-
},
|
|
1043
|
+
}, Xt = (e) => (t) => {
|
|
1044
1044
|
const { keys: n } = e.keyboard;
|
|
1045
1045
|
if (n.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1046
1046
|
if (n.forCancel.includes(t.code)) {
|
|
1047
|
-
t.preventDefault(), ye(),
|
|
1047
|
+
t.preventDefault(), ye(), F(
|
|
1048
1048
|
e,
|
|
1049
1049
|
e.entities.initiatingDraggable,
|
|
1050
1050
|
"onSelfDragCancel"
|
|
@@ -1052,21 +1052,21 @@ const Vt = (e) => {
|
|
|
1052
1052
|
return;
|
|
1053
1053
|
}
|
|
1054
1054
|
if (n.forDrop.includes(t.code)) {
|
|
1055
|
-
t.preventDefault(), (async () => (await
|
|
1055
|
+
t.preventDefault(), (async () => (await Ze(e) && $e(e), ye(), ee(e)))();
|
|
1056
1056
|
return;
|
|
1057
1057
|
}
|
|
1058
|
-
const
|
|
1059
|
-
if (
|
|
1058
|
+
const i = Vt[t.code];
|
|
1059
|
+
if (i && n.forMove.includes(t.code) && e.pointer.value) {
|
|
1060
1060
|
t.preventDefault();
|
|
1061
1061
|
const o = n.forMoveFaster.some(
|
|
1062
1062
|
(g) => n.pressedKeys.value.has(g)
|
|
1063
|
-
),
|
|
1063
|
+
), a = e.keyboard.step * (o ? e.keyboard.moveFaster : 1);
|
|
1064
1064
|
e.pointer.value.current = {
|
|
1065
|
-
x: e.pointer.value.current.x +
|
|
1066
|
-
y: e.pointer.value.current.y +
|
|
1065
|
+
x: e.pointer.value.current.x + i.dx * a,
|
|
1066
|
+
y: e.pointer.value.current.y + i.dy * a
|
|
1067
1067
|
};
|
|
1068
1068
|
const r = ve(e);
|
|
1069
|
-
we(e, e.hovered, r),
|
|
1069
|
+
we(e, e.hovered, r), F(
|
|
1070
1070
|
e,
|
|
1071
1071
|
e.entities.initiatingDraggable,
|
|
1072
1072
|
"onSelfDragMove"
|
|
@@ -1076,15 +1076,15 @@ const Vt = (e) => {
|
|
|
1076
1076
|
return;
|
|
1077
1077
|
}
|
|
1078
1078
|
if (n.forDrag.includes(t.code)) {
|
|
1079
|
-
const
|
|
1080
|
-
if (!
|
|
1081
|
-
const o =
|
|
1082
|
-
|
|
1079
|
+
const i = document.activeElement;
|
|
1080
|
+
if (!i) return;
|
|
1081
|
+
const o = i.closest(
|
|
1082
|
+
H.DRAGGABLE
|
|
1083
1083
|
);
|
|
1084
1084
|
if (!o || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(o))
|
|
1085
1085
|
return;
|
|
1086
|
-
const
|
|
1087
|
-
if (!He(
|
|
1086
|
+
const a = e.entities.draggableMap.get(o);
|
|
1087
|
+
if (!He(i, o, a?.dragHandle, !0))
|
|
1088
1088
|
return;
|
|
1089
1089
|
t.preventDefault(), pe();
|
|
1090
1090
|
const r = o.getBoundingClientRect(), g = r.left + r.width / 2, c = r.top + r.height / 2, u = {
|
|
@@ -1092,22 +1092,22 @@ const Vt = (e) => {
|
|
|
1092
1092
|
clientY: c
|
|
1093
1093
|
};
|
|
1094
1094
|
e.entities.initiatingDraggable = o;
|
|
1095
|
-
const l =
|
|
1095
|
+
const l = ze(u, o);
|
|
1096
1096
|
e.pointer.value = Se(
|
|
1097
1097
|
u,
|
|
1098
1098
|
l.x,
|
|
1099
1099
|
l.y
|
|
1100
1100
|
), Q(e);
|
|
1101
1101
|
const f = ve(e);
|
|
1102
|
-
we(e, e.hovered, f),
|
|
1102
|
+
we(e, e.hovered, f), F(e, o, "onSelfDragStart"), v(e, "onDragStart");
|
|
1103
1103
|
}
|
|
1104
|
-
},
|
|
1104
|
+
}, Zt = (e) => (t) => {
|
|
1105
1105
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
1106
1106
|
}, $t = (e) => () => {
|
|
1107
1107
|
e.keyboard.keys.pressedKeys.value.clear();
|
|
1108
1108
|
}, de = {
|
|
1109
|
-
keyDown:
|
|
1110
|
-
keyUp:
|
|
1109
|
+
keyDown: Xt,
|
|
1110
|
+
keyUp: Zt,
|
|
1111
1111
|
clear: $t
|
|
1112
1112
|
}, Ut = (e) => () => {
|
|
1113
1113
|
if (!e.state.value) return;
|
|
@@ -1117,11 +1117,11 @@ const Vt = (e) => {
|
|
|
1117
1117
|
return;
|
|
1118
1118
|
}
|
|
1119
1119
|
if (e.state.value === "selecting" && e.pointer.value) {
|
|
1120
|
-
const s = window.scrollX - t,
|
|
1121
|
-
e.pointer.value.start.x -= s, e.pointer.value.start.y -=
|
|
1120
|
+
const s = window.scrollX - t, i = window.scrollY - n;
|
|
1121
|
+
e.pointer.value.start.x -= s, e.pointer.value.start.y -= i, Ke(e);
|
|
1122
1122
|
}
|
|
1123
1123
|
}, E = 50, qt = 144, Te = 1e3 / qt;
|
|
1124
|
-
function
|
|
1124
|
+
function jt(e) {
|
|
1125
1125
|
return e == null ? {
|
|
1126
1126
|
top: E,
|
|
1127
1127
|
right: E,
|
|
@@ -1139,7 +1139,7 @@ function Wt(e) {
|
|
|
1139
1139
|
left: e.left ?? E
|
|
1140
1140
|
};
|
|
1141
1141
|
}
|
|
1142
|
-
const
|
|
1142
|
+
const Wt = {
|
|
1143
1143
|
getScrollState(e) {
|
|
1144
1144
|
return {
|
|
1145
1145
|
scrollTop: e.scrollTop,
|
|
@@ -1150,14 +1150,14 @@ const jt = {
|
|
|
1150
1150
|
e.scrollTop = t, e.scrollLeft = n;
|
|
1151
1151
|
}
|
|
1152
1152
|
};
|
|
1153
|
-
function Ue(e, t, n, s =
|
|
1154
|
-
const { speed: o = 10, disabled:
|
|
1153
|
+
function Ue(e, t, n, s = Wt, i) {
|
|
1154
|
+
const { speed: o = 10, disabled: a = !1 } = t, r = jt(t.threshold);
|
|
1155
1155
|
let g = null, c = null, u = null, l = 0, f = 0;
|
|
1156
1156
|
const d = (p) => {
|
|
1157
|
-
|
|
1157
|
+
i && (i.value = p);
|
|
1158
1158
|
}, m = (p) => {
|
|
1159
1159
|
const x = e.value, R = n();
|
|
1160
|
-
if (!x || !R ||
|
|
1160
|
+
if (!x || !R || a) {
|
|
1161
1161
|
d(!1);
|
|
1162
1162
|
return;
|
|
1163
1163
|
}
|
|
@@ -1171,8 +1171,8 @@ function Ue(e, t, n, s = jt, a) {
|
|
|
1171
1171
|
c = p;
|
|
1172
1172
|
const { scrollTop: k, scrollLeft: T } = s.getScrollState(x);
|
|
1173
1173
|
(!u || l !== k || f !== T) && (u = s.getRect ? s.getRect(x) : x.getBoundingClientRect(), l = k, f = T);
|
|
1174
|
-
let
|
|
1175
|
-
r.top > 0 && R.y - u.top < r.top ? (
|
|
1174
|
+
let z = !1, ie = k, ae = T;
|
|
1175
|
+
r.top > 0 && R.y - u.top < r.top ? (ie = k - S, z = !0) : r.bottom > 0 && u.bottom - R.y < r.bottom && (ie = k + S, z = !0), r.left > 0 && R.x - u.left < r.left ? (ae = T - S, z = !0) : r.right > 0 && u.right - R.x < r.right && (ae = T + S, z = !0), z && s.setScroll(x, ie, ae), d(z), g = requestAnimationFrame(m);
|
|
1176
1176
|
};
|
|
1177
1177
|
return { run: () => {
|
|
1178
1178
|
c = null, g = requestAnimationFrame(m);
|
|
@@ -1199,7 +1199,7 @@ const Jt = {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
};
|
|
1201
1201
|
function en(e, t) {
|
|
1202
|
-
const n =
|
|
1202
|
+
const n = V(!1), i = Ue(
|
|
1203
1203
|
Qt,
|
|
1204
1204
|
t ?? {},
|
|
1205
1205
|
() => {
|
|
@@ -1215,29 +1215,29 @@ function en(e, t) {
|
|
|
1215
1215
|
), o = te(
|
|
1216
1216
|
() => e.state.value,
|
|
1217
1217
|
(r) => {
|
|
1218
|
-
r === "dragging" ?
|
|
1218
|
+
r === "dragging" ? i.run() : i.stop();
|
|
1219
1219
|
}
|
|
1220
|
-
),
|
|
1221
|
-
o(),
|
|
1220
|
+
), a = () => {
|
|
1221
|
+
o(), i.stop();
|
|
1222
1222
|
};
|
|
1223
|
-
return
|
|
1223
|
+
return je(a), { isScrolling: n, stop: a };
|
|
1224
1224
|
}
|
|
1225
1225
|
const tn = (e) => {
|
|
1226
|
-
const t =
|
|
1227
|
-
let
|
|
1226
|
+
const t = Yt(e), n = de.keyDown(e), s = de.keyUp(e), i = de.clear(e), o = Ut(e);
|
|
1227
|
+
let a = null;
|
|
1228
1228
|
te(
|
|
1229
1229
|
e.autoScrollViewport,
|
|
1230
1230
|
(r) => {
|
|
1231
|
-
|
|
1231
|
+
a?.(), a = null, (r === !0 || r && typeof r == "object") && (a = en(
|
|
1232
1232
|
e,
|
|
1233
1233
|
r === !0 ? {} : r
|
|
1234
1234
|
).stop);
|
|
1235
1235
|
},
|
|
1236
1236
|
{ immediate: !0 }
|
|
1237
1237
|
), X(() => {
|
|
1238
|
-
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", n), document.addEventListener("keyup", s), document.addEventListener("blur",
|
|
1239
|
-
}),
|
|
1240
|
-
document.removeEventListener("pointerdown", t.pointerDown), document.removeEventListener("pointerup", t.pointerUp), document.removeEventListener("pointermove", t.pointerMove), document.removeEventListener("keydown", n), document.removeEventListener("keyup", s), document.removeEventListener("blur",
|
|
1238
|
+
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", n), document.addEventListener("keyup", s), document.addEventListener("blur", i), document.addEventListener("scroll", o, !0);
|
|
1239
|
+
}), Z(() => {
|
|
1240
|
+
document.removeEventListener("pointerdown", t.pointerDown), document.removeEventListener("pointerup", t.pointerUp), document.removeEventListener("pointermove", t.pointerMove), document.removeEventListener("keydown", n), document.removeEventListener("keyup", s), document.removeEventListener("blur", i), document.removeEventListener("scroll", o, !0), a?.(), t.cleanup();
|
|
1241
1241
|
});
|
|
1242
1242
|
}, se = () => {
|
|
1243
1243
|
const e = Pe(xe);
|
|
@@ -1260,33 +1260,41 @@ const tn = (e) => {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
}, nn = /* @__PURE__ */ Be({
|
|
1262
1262
|
__name: "DragPreview",
|
|
1263
|
+
props: {
|
|
1264
|
+
grid: {}
|
|
1265
|
+
},
|
|
1263
1266
|
setup(e) {
|
|
1264
|
-
const { state: t, entities: n, preview: s } = qe(),
|
|
1265
|
-
|
|
1266
|
-
() =>
|
|
1267
|
+
const { state: t, entities: n, preview: s } = qe(), i = Oe("contentRef");
|
|
1268
|
+
te(
|
|
1269
|
+
() => i.value,
|
|
1267
1270
|
() => {
|
|
1268
|
-
const
|
|
1269
|
-
|
|
1271
|
+
const r = i.value?.getBoundingClientRect();
|
|
1272
|
+
r && (s.size.value = r);
|
|
1270
1273
|
}
|
|
1271
|
-
)
|
|
1274
|
+
);
|
|
1275
|
+
const o = (r, g) => !g || g <= 0 ? r : Math.round(r / g) * g, a = b(() => {
|
|
1276
|
+
const { x: r, y: g } = s.position.value, c = typeof e.grid == "object" ? e.grid.x : e.grid, u = typeof e.grid == "object" ? e.grid.y : e.grid;
|
|
1277
|
+
return { x: o(r, c), y: o(g, u) };
|
|
1278
|
+
});
|
|
1279
|
+
return (r, g) => q(t) === "dragging" ? (L(), j("div", {
|
|
1272
1280
|
key: 0,
|
|
1273
1281
|
class: "dnd-kit-preview",
|
|
1274
1282
|
ref_key: "contentRef",
|
|
1275
|
-
ref:
|
|
1283
|
+
ref: i,
|
|
1276
1284
|
style: Ce({
|
|
1277
|
-
transform: `translate3d(${
|
|
1285
|
+
transform: `translate3d(${a.value.x}px, ${a.value.y}px, 0)`
|
|
1278
1286
|
})
|
|
1279
1287
|
}, [
|
|
1280
|
-
me(
|
|
1281
|
-
draggingMap:
|
|
1288
|
+
me(r.$slots, "default", {
|
|
1289
|
+
draggingMap: q(n).draggingMap
|
|
1282
1290
|
}, () => [
|
|
1283
|
-
(L(!0),
|
|
1284
|
-
|
|
1291
|
+
(L(!0), j(he, null, We(q(n).draggingMap, ([c, u]) => (L(), j(he, { key: c }, [
|
|
1292
|
+
u.render ? (L(), J(be(u.render), { key: 0 })) : (L(), J(be(c.tagName), {
|
|
1285
1293
|
key: 1,
|
|
1286
|
-
innerHTML:
|
|
1294
|
+
innerHTML: u.initialOuterHTML,
|
|
1287
1295
|
style: Ce({
|
|
1288
|
-
width:
|
|
1289
|
-
height:
|
|
1296
|
+
width: u.initialRect.width + "px",
|
|
1297
|
+
height: u.initialRect.height + "px"
|
|
1290
1298
|
})
|
|
1291
1299
|
}, null, 8, ["innerHTML", "style"]))
|
|
1292
1300
|
], 64))), 128))
|
|
@@ -1302,21 +1310,21 @@ const tn = (e) => {
|
|
|
1302
1310
|
class: {}
|
|
1303
1311
|
},
|
|
1304
1312
|
setup(e) {
|
|
1305
|
-
const t = e, n =
|
|
1313
|
+
const t = e, n = Oe("previewRef"), s = yt(n, t);
|
|
1306
1314
|
tn(s);
|
|
1307
|
-
const
|
|
1308
|
-
return Qe(xe, s), (o,
|
|
1315
|
+
const i = b(() => s.preview.render.value ?? nn);
|
|
1316
|
+
return Qe(xe, s), (o, a) => (L(), j(he, null, [
|
|
1309
1317
|
me(o.$slots, "default"),
|
|
1310
1318
|
(L(), J(et, {
|
|
1311
|
-
to:
|
|
1319
|
+
to: q(s).preview.to.value || "body"
|
|
1312
1320
|
}, [
|
|
1313
1321
|
tt("div", nt({
|
|
1314
1322
|
ref_key: "previewRef",
|
|
1315
1323
|
ref: n,
|
|
1316
1324
|
class: "dnd-kit-preview-container"
|
|
1317
1325
|
}, t), [
|
|
1318
|
-
me(o.$slots, "preview", { preview:
|
|
1319
|
-
(L(), J(be(
|
|
1326
|
+
me(o.$slots, "preview", { preview: i.value }, () => [
|
|
1327
|
+
(L(), J(be(i.value)))
|
|
1320
1328
|
])
|
|
1321
1329
|
], 16)
|
|
1322
1330
|
], 8, ["to"]))
|
|
@@ -1325,8 +1333,8 @@ const tn = (e) => {
|
|
|
1325
1333
|
});
|
|
1326
1334
|
function on(e, t, n) {
|
|
1327
1335
|
const s = se();
|
|
1328
|
-
let
|
|
1329
|
-
typeof t == "function" ? (
|
|
1336
|
+
let i, o, a;
|
|
1337
|
+
typeof t == "function" ? (i = {}, o = t) : (i = t ?? {}, o = n);
|
|
1330
1338
|
const r = b({
|
|
1331
1339
|
get() {
|
|
1332
1340
|
const l = D(e);
|
|
@@ -1348,21 +1356,21 @@ function on(e, t, n) {
|
|
|
1348
1356
|
return s.entities.draggableMap.get(l)?.hoveredPlacement;
|
|
1349
1357
|
});
|
|
1350
1358
|
return X(() => {
|
|
1351
|
-
|
|
1352
|
-
render:
|
|
1353
|
-
disabled:
|
|
1354
|
-
groups:
|
|
1355
|
-
modifier:
|
|
1356
|
-
events:
|
|
1359
|
+
a = D(e), a && (a.addEventListener("dragstart", w), a.addEventListener("drag", w), a.addEventListener("dragend", w), a.setAttribute(O.DRAGGABLE, ""), s.lib.draggableObserver.observe(a), s.entities.draggableMap.set(a, {
|
|
1360
|
+
render: i.render,
|
|
1361
|
+
disabled: i.disabled ?? !1,
|
|
1362
|
+
groups: i.groups ?? [],
|
|
1363
|
+
modifier: i.modifier,
|
|
1364
|
+
events: i.events,
|
|
1357
1365
|
payload: o,
|
|
1358
|
-
data:
|
|
1359
|
-
dragHandle:
|
|
1360
|
-
activation:
|
|
1361
|
-
placementMargins:
|
|
1366
|
+
data: i.data,
|
|
1367
|
+
dragHandle: i.dragHandle,
|
|
1368
|
+
activation: i.activation,
|
|
1369
|
+
placementMargins: i.placementMargins,
|
|
1362
1370
|
hoveredPlacement: void 0
|
|
1363
1371
|
}));
|
|
1364
|
-
}),
|
|
1365
|
-
|
|
1372
|
+
}), Z(() => {
|
|
1373
|
+
a && (s.lib.draggableObserver.unobserve(a), s.entities.visibleDraggableSet.delete(a), s.entities.draggableMap.delete(a), s.entities.modifiersDraggableSet.delete(a));
|
|
1366
1374
|
}), {
|
|
1367
1375
|
selected: r,
|
|
1368
1376
|
isDragging: g,
|
|
@@ -1372,9 +1380,9 @@ function on(e, t, n) {
|
|
|
1372
1380
|
}
|
|
1373
1381
|
const rn = (e, t) => {
|
|
1374
1382
|
const n = se(), s = b(() => e.value === n.entities.selectingArea);
|
|
1375
|
-
let
|
|
1383
|
+
let i = null;
|
|
1376
1384
|
X(() => {
|
|
1377
|
-
|
|
1385
|
+
i = D(e), i && (i.setAttribute(O.SELECT_AREA, ""), n.lib.selectableAreaObserver.observe(i), n.entities.selectableAreaMap.set(i, {
|
|
1378
1386
|
modifier: t?.modifier ?? {
|
|
1379
1387
|
keys: ["ControlLeft"],
|
|
1380
1388
|
method: "every"
|
|
@@ -1383,13 +1391,13 @@ const rn = (e, t) => {
|
|
|
1383
1391
|
disabled: t?.disabled ?? !1,
|
|
1384
1392
|
groups: t?.groups ?? []
|
|
1385
1393
|
}));
|
|
1386
|
-
}),
|
|
1387
|
-
|
|
1394
|
+
}), Z(() => {
|
|
1395
|
+
i && (n.lib.selectableAreaObserver.unobserve(i), n.entities.visibleSelectableAreaSet.delete(i), n.entities.modifiersSelectableAreaSet.delete(i), n.entities.selectableAreaMap.delete(i));
|
|
1388
1396
|
});
|
|
1389
1397
|
const o = b(() => {
|
|
1390
1398
|
n.scrollPosition.x, n.scrollPosition.y;
|
|
1391
|
-
const
|
|
1392
|
-
return !
|
|
1399
|
+
const a = n.pointer.value;
|
|
1400
|
+
return !a || n.state.value !== "selecting" || !i || !s.value ? {} : Dt(a.start, a.current, i);
|
|
1393
1401
|
});
|
|
1394
1402
|
return {
|
|
1395
1403
|
isSelecting: s,
|
|
@@ -1401,18 +1409,18 @@ function ln(e, t) {
|
|
|
1401
1409
|
if (!n) throw Error("DnD provider not found");
|
|
1402
1410
|
let s = null;
|
|
1403
1411
|
return X(() => {
|
|
1404
|
-
s = D(e), s && (s.setAttribute(
|
|
1412
|
+
s = D(e), s && (s.setAttribute(O.CONSTRAINT_AREA, ""), n.entities.constraintsAreaMap.set(s, {
|
|
1405
1413
|
axis: t?.axis || "both",
|
|
1406
1414
|
restrictToArea: t?.restrictToArea || !1
|
|
1407
1415
|
}));
|
|
1408
|
-
}),
|
|
1416
|
+
}), Z(() => {
|
|
1409
1417
|
s && n.entities.constraintsAreaMap.delete(s);
|
|
1410
1418
|
}), {};
|
|
1411
1419
|
}
|
|
1412
1420
|
function cn(e, t, n) {
|
|
1413
1421
|
const s = se();
|
|
1414
|
-
let
|
|
1415
|
-
typeof t == "function" ? (o = {},
|
|
1422
|
+
let i = null, o, a;
|
|
1423
|
+
typeof t == "function" ? (o = {}, a = t) : (o = t ?? {}, a = n);
|
|
1416
1424
|
const r = b(() => {
|
|
1417
1425
|
const c = D(e);
|
|
1418
1426
|
return c ? s.entities.allowedDroppableSet.has(c) : !1;
|
|
@@ -1422,41 +1430,41 @@ function cn(e, t, n) {
|
|
|
1422
1430
|
return s.entities.droppableMap.get(c)?.hoveredPlacement;
|
|
1423
1431
|
});
|
|
1424
1432
|
return X(() => {
|
|
1425
|
-
|
|
1433
|
+
i = D(e), i && (i.setAttribute(O.DROPPABLE, ""), s.lib.droppableObserver.observe(i), s.entities.droppableMap.set(i, {
|
|
1426
1434
|
disabled: o.disabled ?? !1,
|
|
1427
1435
|
groups: o.groups ?? [],
|
|
1428
1436
|
groupMatch: o.groupMatch ?? "every",
|
|
1429
1437
|
events: o.events,
|
|
1430
|
-
payload:
|
|
1438
|
+
payload: a,
|
|
1431
1439
|
data: o.data,
|
|
1432
1440
|
hoveredPlacement: void 0
|
|
1433
1441
|
}));
|
|
1434
|
-
}),
|
|
1435
|
-
|
|
1442
|
+
}), Z(() => {
|
|
1443
|
+
i && (s.lib.droppableObserver.unobserve(i), s.entities.visibleDroppableSet.delete(i), s.entities.droppableMap.delete(i));
|
|
1436
1444
|
}), {
|
|
1437
1445
|
isAllowed: r,
|
|
1438
1446
|
isDragOver: g
|
|
1439
1447
|
};
|
|
1440
1448
|
}
|
|
1441
1449
|
const gn = (e, t) => {
|
|
1442
|
-
const n = qe(), s =
|
|
1450
|
+
const n = qe(), s = V(!1), o = Ue(
|
|
1443
1451
|
e,
|
|
1444
1452
|
t ?? {},
|
|
1445
1453
|
() => {
|
|
1446
1454
|
if (n.state.value !== "dragging") return null;
|
|
1447
|
-
const
|
|
1448
|
-
return
|
|
1449
|
-
x:
|
|
1450
|
-
y:
|
|
1451
|
-
} :
|
|
1455
|
+
const a = n.preview.position.value, r = n.preview.size.value;
|
|
1456
|
+
return a ? r?.width && r?.height ? {
|
|
1457
|
+
x: a.x + r.width / 2,
|
|
1458
|
+
y: a.y + r.height / 2
|
|
1459
|
+
} : a : null;
|
|
1452
1460
|
},
|
|
1453
1461
|
void 0,
|
|
1454
1462
|
s
|
|
1455
1463
|
);
|
|
1456
1464
|
return te(
|
|
1457
1465
|
() => n.state.value,
|
|
1458
|
-
(
|
|
1459
|
-
|
|
1466
|
+
(a) => {
|
|
1467
|
+
a === "dragging" ? o.run() : o.stop();
|
|
1460
1468
|
}
|
|
1461
1469
|
), { isScrolling: s };
|
|
1462
1470
|
};
|