@vue-dnd-kit/core 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-default-overlay{transform:translate3d(var(--position-x),var(--position-y),0)}.dnd-kit-overlay-container{position:fixed;top:0;left:0;pointer-events:none;cursor:grabbing;z-index:9999}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
import { ref as
|
|
2
|
+
import { ref as j, watch as re, shallowRef as te, reactive as q, computed as y, onScopeDispose as je, onMounted as U, onBeforeUnmount as V, inject as Be, defineComponent as Fe, unref as k, openBlock as C, createElementBlock as J, normalizeStyle as Le, Fragment as he, renderList as Je, createBlock as ne, resolveDynamicComponent as be, createCommentVNode as Qe, useTemplateRef as et, provide as tt, renderSlot as Ce, Teleport as nt, createElementVNode as st, mergeProps as ot } from "vue";
|
|
3
3
|
const T = {
|
|
4
4
|
SELECT_AREA: "data-dnd-kit-select-area",
|
|
5
5
|
DRAGGABLE: "data-dnd-kit-draggable",
|
|
6
6
|
DROPPABLE: "data-dnd-kit-droppable",
|
|
7
7
|
CONSTRAINT_AREA: "data-dnd-kit-constraint-area"
|
|
8
|
-
},
|
|
8
|
+
}, _ = {
|
|
9
9
|
SELECT_AREA: `[${T.SELECT_AREA}]`,
|
|
10
10
|
DRAGGABLE: `[${T.DRAGGABLE}]`,
|
|
11
11
|
CONSTRAINT_AREA: `[${T.CONSTRAINT_AREA}]`
|
|
12
|
-
},
|
|
12
|
+
}, we = "VueDnDKitProvider", Ie = (e, t, s, n) => {
|
|
13
13
|
const o = /* @__PURE__ */ new Set();
|
|
14
14
|
return t.forEach((r) => {
|
|
15
15
|
const a = e.get(r), i = n ? n(r) : a?.disabled;
|
|
@@ -22,29 +22,29 @@ const T = {
|
|
|
22
22
|
g[l]((c) => s.value.has(c)) && o.add(r);
|
|
23
23
|
}), o;
|
|
24
24
|
};
|
|
25
|
-
let
|
|
26
|
-
const D = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null,
|
|
25
|
+
let _e = "", at = "", 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), it = (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
|
-
|
|
29
|
-
},
|
|
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
|
+
}, pe = () => {
|
|
30
30
|
const e = document.body;
|
|
31
|
-
e.style.userSelect =
|
|
32
|
-
}, M = (e) => e.preventDefault(),
|
|
31
|
+
e.style.userSelect = _e, e.style.touchAction = at, e.style.overscrollBehavior = rt, window.removeEventListener("contextmenu", M), window.removeEventListener("selectstart", M), window.removeEventListener("touchstart", M), window.removeEventListener("touchmove", M);
|
|
32
|
+
}, M = (e) => e.preventDefault(), xe = (e, t) => {
|
|
33
33
|
if (t.entities.draggableMap.get(e)?.disabled) return !0;
|
|
34
34
|
for (const n of t.entities.visibleDraggableSet)
|
|
35
|
-
if (t.entities.draggableMap.get(n)?.disabled &&
|
|
35
|
+
if (t.entities.draggableMap.get(n)?.disabled && K(n, e)) return !0;
|
|
36
36
|
return !1;
|
|
37
|
-
},
|
|
37
|
+
}, G = (e, t) => {
|
|
38
38
|
if (t.entities.droppableMap.get(e)?.disabled) return !0;
|
|
39
39
|
for (const n of t.entities.visibleDroppableSet)
|
|
40
|
-
if (t.entities.droppableMap.get(n)?.disabled &&
|
|
40
|
+
if (t.entities.droppableMap.get(n)?.disabled && K(n, e)) return !0;
|
|
41
41
|
return !1;
|
|
42
|
-
},
|
|
42
|
+
}, Ae = (e, t) => {
|
|
43
43
|
if (!e.length || !t.length) return !0;
|
|
44
44
|
const s = new Set(t);
|
|
45
45
|
return e.some((n) => s.has(n));
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function lt(e, t, s, n) {
|
|
48
48
|
const o = /* @__PURE__ */ new Set();
|
|
49
49
|
for (const i of t.keys()) {
|
|
50
50
|
const g = s.get(i);
|
|
@@ -53,11 +53,11 @@ function it(e, t, s, n) {
|
|
|
53
53
|
const r = [...o], a = /* @__PURE__ */ new Set();
|
|
54
54
|
for (const i of e) {
|
|
55
55
|
const l = n.get(i)?.groups ?? [];
|
|
56
|
-
|
|
56
|
+
Ae(r, l) && a.add(i);
|
|
57
57
|
}
|
|
58
58
|
return a;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function ct(e, t, s) {
|
|
61
61
|
const n = /* @__PURE__ */ new Set();
|
|
62
62
|
for (const a of t.keys()) {
|
|
63
63
|
const i = s.get(a);
|
|
@@ -66,11 +66,11 @@ function lt(e, t, s) {
|
|
|
66
66
|
const o = [...n], r = /* @__PURE__ */ new Set();
|
|
67
67
|
for (const a of e) {
|
|
68
68
|
const g = s.get(a)?.groups ?? [];
|
|
69
|
-
|
|
69
|
+
Ae(o, g) && r.add(a);
|
|
70
70
|
}
|
|
71
71
|
return r;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const ge = (e) => {
|
|
74
74
|
const t = new IntersectionObserver((s) => {
|
|
75
75
|
s.forEach((n) => {
|
|
76
76
|
const o = n.target;
|
|
@@ -82,7 +82,7 @@ const le = (e) => {
|
|
|
82
82
|
unobserve: (s) => t.unobserve(s),
|
|
83
83
|
disconnect: () => t.disconnect()
|
|
84
84
|
};
|
|
85
|
-
},
|
|
85
|
+
}, gt = (e) => {
|
|
86
86
|
const t = new ResizeObserver((s) => {
|
|
87
87
|
const n = s[0];
|
|
88
88
|
if (!n) return;
|
|
@@ -94,8 +94,8 @@ const le = (e) => {
|
|
|
94
94
|
unobserve: (s) => t.unobserve(s),
|
|
95
95
|
disconnect: () => t.disconnect()
|
|
96
96
|
};
|
|
97
|
-
},
|
|
98
|
-
const t =
|
|
97
|
+
}, ut = (e) => {
|
|
98
|
+
const t = j(null), s = gt(t), n = re(
|
|
99
99
|
e,
|
|
100
100
|
(r) => {
|
|
101
101
|
s.disconnect(), r && s.observe(r);
|
|
@@ -108,18 +108,18 @@ const le = (e) => {
|
|
|
108
108
|
}
|
|
109
109
|
} };
|
|
110
110
|
};
|
|
111
|
-
function
|
|
111
|
+
function Se(e, t = 0, s = 0) {
|
|
112
112
|
return {
|
|
113
113
|
start: { x: e.clientX, y: e.clientY },
|
|
114
114
|
current: { x: e.clientX, y: e.clientY },
|
|
115
115
|
offset: { x: t, y: s }
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function 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 _e(e, t) {
|
|
|
127
127
|
initialOuterHTML: e.outerHTML
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function ft(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 dt(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
|
-
function
|
|
142
|
-
e.entities.initiatingDraggable && (e.state.value = "dragging",
|
|
141
|
+
function se(e) {
|
|
142
|
+
e.entities.initiatingDraggable && (e.state.value = "dragging", mt(
|
|
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 mt(e, t, s, n) {
|
|
150
|
+
t.has(e) ? ft(t, s, n) : (t.clear(), dt(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 ht(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 mt(e, t) {
|
|
|
170
170
|
const i = o > 0 ? Math.min(s / o, 1) : 1, g = r > 0 ? Math.min(n / r, 1) : 1;
|
|
171
171
|
return a === "both" ? Math.min(i, g) : Math.max(i, g);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function 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 bt(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 yt(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 bt(e, t) {
|
|
|
204
204
|
e.delay.progress = Math.min(
|
|
205
205
|
(Date.now() - e.delay.startTime) / (r * 1e3),
|
|
206
206
|
1
|
|
207
|
-
),
|
|
207
|
+
), Ze(
|
|
208
208
|
e.distanceProgress.value,
|
|
209
209
|
e.delay.progress,
|
|
210
210
|
o?.activation
|
|
@@ -216,19 +216,19 @@ function bt(e, t) {
|
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function pt(e, t) {
|
|
220
220
|
const s = e.closest(
|
|
221
|
-
|
|
221
|
+
_.CONSTRAINT_AREA
|
|
222
222
|
);
|
|
223
223
|
return !s || !t.has(s) ? null : {
|
|
224
224
|
element: s,
|
|
225
225
|
entity: t.get(s)
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function St(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 Dt(e, t, s, n, o) {
|
|
232
232
|
let r = e, a = t;
|
|
233
233
|
return s !== "y" && (r = Math.max(
|
|
234
234
|
n.left,
|
|
@@ -238,23 +238,23 @@ function St(e, t, s, n, o) {
|
|
|
238
238
|
Math.min(n.bottom - o.height, t)
|
|
239
239
|
)), { x: r, y: a };
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Mt(e, t, s, n, o) {
|
|
242
242
|
if (!e || !t)
|
|
243
243
|
return { x: 0, y: 0 };
|
|
244
244
|
const r = t.getBoundingClientRect(), a = r.width || o?.width || 0, i = r.height || o?.height || 0;
|
|
245
245
|
let g = e.current.x - a * e.offset.x, l = e.current.y - i * e.offset.y;
|
|
246
246
|
if (!s)
|
|
247
247
|
return { x: g, y: l };
|
|
248
|
-
const u =
|
|
248
|
+
const u = pt(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 = St(
|
|
252
252
|
g,
|
|
253
253
|
l,
|
|
254
254
|
f.axis || "both",
|
|
255
255
|
m
|
|
256
256
|
);
|
|
257
|
-
return f.restrictToArea ?
|
|
257
|
+
return f.restrictToArea ? Dt(
|
|
258
258
|
h.x,
|
|
259
259
|
h.y,
|
|
260
260
|
f.axis || "both",
|
|
@@ -278,10 +278,10 @@ const N = {
|
|
|
278
278
|
],
|
|
279
279
|
forMoveFaster: ["ShiftLeft", "ShiftRight"]
|
|
280
280
|
};
|
|
281
|
-
function
|
|
282
|
-
const s =
|
|
281
|
+
function vt(e, t) {
|
|
282
|
+
const s = te(), n = j(), r = {
|
|
283
283
|
keys: {
|
|
284
|
-
pressedKeys:
|
|
284
|
+
pressedKeys: j(/* @__PURE__ */ new Set()),
|
|
285
285
|
forDrag: [...N.forDrag],
|
|
286
286
|
forCancel: [...N.forCancel],
|
|
287
287
|
forDrop: [...N.forDrop],
|
|
@@ -290,7 +290,7 @@ function Mt(e, t) {
|
|
|
290
290
|
},
|
|
291
291
|
step: 8,
|
|
292
292
|
moveFaster: 4
|
|
293
|
-
}, a =
|
|
293
|
+
}, a = q({
|
|
294
294
|
draggableMap: /* @__PURE__ */ new Map(),
|
|
295
295
|
droppableMap: /* @__PURE__ */ new Map(),
|
|
296
296
|
selectableAreaMap: /* @__PURE__ */ new Map(),
|
|
@@ -299,55 +299,55 @@ function Mt(e, t) {
|
|
|
299
299
|
selectingArea: void 0,
|
|
300
300
|
draggingMap: /* @__PURE__ */ new Map(),
|
|
301
301
|
selectedSet: /* @__PURE__ */ new Set(),
|
|
302
|
-
allowedDroppableSet: y(() => s.value ?
|
|
302
|
+
allowedDroppableSet: y(() => s.value ? lt(
|
|
303
303
|
a.visibleDroppableSet,
|
|
304
304
|
a.draggingMap,
|
|
305
305
|
a.draggableMap,
|
|
306
306
|
a.droppableMap
|
|
307
307
|
) : /* @__PURE__ */ new Set()),
|
|
308
|
-
allowedDraggableSet: y(() => s.value ?
|
|
308
|
+
allowedDraggableSet: y(() => s.value ? ct(
|
|
309
309
|
a.visibleDraggableSet,
|
|
310
310
|
a.draggingMap,
|
|
311
311
|
a.draggableMap
|
|
312
312
|
) : /* @__PURE__ */ new Set()),
|
|
313
|
-
modifiersSelectableAreaSet: y(() =>
|
|
313
|
+
modifiersSelectableAreaSet: y(() => Ie(
|
|
314
314
|
a.selectableAreaMap,
|
|
315
315
|
a.visibleSelectableAreaSet,
|
|
316
316
|
r.keys.pressedKeys
|
|
317
317
|
)),
|
|
318
|
-
modifiersDraggableSet: y(() =>
|
|
318
|
+
modifiersDraggableSet: y(() => Ie(
|
|
319
319
|
a.draggableMap,
|
|
320
320
|
a.visibleDraggableSet,
|
|
321
321
|
r.keys.pressedKeys,
|
|
322
|
-
(w) =>
|
|
322
|
+
(w) => xe(w, { entities: a })
|
|
323
323
|
)),
|
|
324
324
|
visibleDraggableSet: /* @__PURE__ */ new Set(),
|
|
325
325
|
visibleDroppableSet: /* @__PURE__ */ new Set(),
|
|
326
326
|
visibleSelectableAreaSet: /* @__PURE__ */ new Set()
|
|
327
|
-
}), i =
|
|
327
|
+
}), i = q({
|
|
328
328
|
draggable: /* @__PURE__ */ new Map(),
|
|
329
329
|
droppable: /* @__PURE__ */ new Map()
|
|
330
330
|
}), g = {
|
|
331
|
-
throttle:
|
|
332
|
-
}, l =
|
|
331
|
+
throttle: te(0)
|
|
332
|
+
}, l = q({
|
|
333
333
|
x: window.scrollX,
|
|
334
334
|
y: window.scrollY
|
|
335
|
-
}), u =
|
|
335
|
+
}), u = q({
|
|
336
336
|
progress: 0,
|
|
337
337
|
startTime: 0
|
|
338
338
|
}), c = y(() => {
|
|
339
339
|
if (!n.value || !a.initiatingDraggable) return 0;
|
|
340
340
|
const w = a.draggableMap.get(a.initiatingDraggable)?.activation?.distance;
|
|
341
|
-
return w ?
|
|
342
|
-
}), f =
|
|
341
|
+
return w ? ht(n.value, w) : 1;
|
|
342
|
+
}), f = ge(
|
|
343
343
|
a.visibleDraggableSet
|
|
344
|
-
), d =
|
|
344
|
+
), d = ge(
|
|
345
345
|
a.visibleDroppableSet
|
|
346
|
-
), m =
|
|
346
|
+
), m = ge(
|
|
347
347
|
a.visibleSelectableAreaSet
|
|
348
|
-
), { overlaySize: h, overlaySizeObserver: S } =
|
|
348
|
+
), { overlaySize: h, overlaySizeObserver: S } = ut(e), b = j(), v = y(() => {
|
|
349
349
|
const p = a.initiatingDraggable;
|
|
350
|
-
return
|
|
350
|
+
return Mt(
|
|
351
351
|
n.value,
|
|
352
352
|
e.value,
|
|
353
353
|
p || null,
|
|
@@ -357,7 +357,7 @@ function Mt(e, t) {
|
|
|
357
357
|
}), E = y({
|
|
358
358
|
get: () => t?.overlayTo,
|
|
359
359
|
set: (p) => E.value = p
|
|
360
|
-
}),
|
|
360
|
+
}), $ = y(() => t?.autoScrollViewport);
|
|
361
361
|
return {
|
|
362
362
|
state: s,
|
|
363
363
|
pointer: n,
|
|
@@ -382,10 +382,10 @@ function Mt(e, t) {
|
|
|
382
382
|
overlaySizeObserver: S,
|
|
383
383
|
rectCache: /* @__PURE__ */ new Map()
|
|
384
384
|
},
|
|
385
|
-
autoScrollViewport:
|
|
385
|
+
autoScrollViewport: $
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
|
-
const
|
|
388
|
+
const oe = (e) => {
|
|
389
389
|
const t = e.hovered.draggable.keys().next().value;
|
|
390
390
|
if (t) {
|
|
391
391
|
const n = e.entities.draggableMap.get(t);
|
|
@@ -402,17 +402,17 @@ function I(e, t, s) {
|
|
|
402
402
|
const n = Math.max(0, Math.min(t, e.length));
|
|
403
403
|
return [...e.slice(0, n), ...s, ...e.slice(n)];
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function Ee(e, t, s = 1) {
|
|
406
406
|
const n = Math.max(0, Math.min(t, e.length - 1)), o = Math.max(0, Math.min(s, e.length - n));
|
|
407
407
|
return [...e.slice(0, n), ...e.slice(n + o)];
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function H(e, t) {
|
|
410
410
|
const s = [...new Set(t)].filter((o) => o >= 0 && o < e.length).sort((o, r) => r - o);
|
|
411
411
|
let n = e;
|
|
412
|
-
for (const o of s) n =
|
|
412
|
+
for (const o of s) n = Ee(n, o, 1);
|
|
413
413
|
return n;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function Ne(e, t, s) {
|
|
416
416
|
if (t === s || t < 0 || s < 0 || t >= e.length || s >= e.length)
|
|
417
417
|
return e;
|
|
418
418
|
const n = [...e];
|
|
@@ -429,7 +429,7 @@ const R = {
|
|
|
429
429
|
return R.getInsertSide(e, t) === "after" && !e?.center;
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
|
-
function
|
|
432
|
+
function Ye(e, t) {
|
|
433
433
|
const { draggedItems: s, dropZone: n, hoveredDraggable: o } = e;
|
|
434
434
|
if (!s.length) return null;
|
|
435
435
|
const r = o?.placement.center === !0 && n != null && n.items !== o.items, a = r ? n.items : o?.items ?? n?.items;
|
|
@@ -456,10 +456,10 @@ function Ne(e, t) {
|
|
|
456
456
|
}
|
|
457
457
|
return { targetIndex: u, mode: c, targetArr: a };
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function wt(e, t = "vertical") {
|
|
460
460
|
const { draggedItems: s } = e;
|
|
461
461
|
if (!s.length) return null;
|
|
462
|
-
const n =
|
|
462
|
+
const n = Ye(e, t);
|
|
463
463
|
if (!n) return null;
|
|
464
464
|
const { targetArr: o, mode: r } = n;
|
|
465
465
|
let { targetIndex: a } = n;
|
|
@@ -467,14 +467,14 @@ function vt(e, t = "vertical") {
|
|
|
467
467
|
if (l === o) {
|
|
468
468
|
const c = i.filter((d) => d < a).length;
|
|
469
469
|
a = Math.max(0, a - c);
|
|
470
|
-
const f = I(
|
|
470
|
+
const f = I(H(l, i), a, g);
|
|
471
471
|
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: i, targetIndex: a, mode: r, sameList: !0 };
|
|
472
472
|
} else {
|
|
473
|
-
const c =
|
|
473
|
+
const c = H(l, i), f = I(o, a, g);
|
|
474
474
|
return { sourceItems: c, targetItems: f, draggedItems: g, sourceIndexes: i, targetIndex: a, mode: r, sameList: !1 };
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function xt(e) {
|
|
478
478
|
const { draggedItems: t, hoveredDraggable: s } = e;
|
|
479
479
|
if (!t.length || !s) return null;
|
|
480
480
|
const n = t.map((u) => u.index), o = s.index, r = t.map((u) => u.item), a = s.item, i = t[0].items, g = s.items, l = i === g;
|
|
@@ -482,7 +482,7 @@ function wt(e) {
|
|
|
482
482
|
if (t.length === 1) {
|
|
483
483
|
const u = n[0];
|
|
484
484
|
if (l) {
|
|
485
|
-
const c =
|
|
485
|
+
const c = Ne(i, u, o);
|
|
486
486
|
return { sourceItems: c, targetItems: c, sourceIndexes: n, targetIndex: o, sameList: !0 };
|
|
487
487
|
} else {
|
|
488
488
|
const c = [...i], f = [...g];
|
|
@@ -492,55 +492,55 @@ function wt(e) {
|
|
|
492
492
|
const u = Math.min(...n);
|
|
493
493
|
if (l) {
|
|
494
494
|
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);
|
|
495
|
-
let h =
|
|
495
|
+
let h = H(i, n);
|
|
496
496
|
h = I(h, f, r);
|
|
497
497
|
const S = m >= f ? m + r.length : m;
|
|
498
498
|
return h = I(h, S, [a]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex: f, sameList: !0 };
|
|
499
499
|
} else {
|
|
500
500
|
const c = n.filter((h) => h < u).length, f = Math.max(0, u - c);
|
|
501
|
-
let d =
|
|
501
|
+
let d = H(i, n);
|
|
502
502
|
d = I(d, f, [a]);
|
|
503
|
-
let m =
|
|
503
|
+
let m = Ee(g, o);
|
|
504
504
|
return m = I(m, o, r), { sourceItems: d, targetItems: m, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function At(e, t = "vertical") {
|
|
509
509
|
const { draggedItems: s } = e;
|
|
510
510
|
if (!s.length) return null;
|
|
511
|
-
const n =
|
|
511
|
+
const n = Ye(e, t);
|
|
512
512
|
if (!n) return null;
|
|
513
513
|
const { targetArr: o, targetIndex: r, mode: a } = n, i = s.map((l) => l.item);
|
|
514
514
|
return { targetItems: I(o, r, i), copiedItems: i, targetIndex: r, mode: a };
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function Et(e) {
|
|
517
517
|
const { draggedItems: t } = e;
|
|
518
518
|
if (!t.length) return null;
|
|
519
519
|
const s = t.map((a) => a.index), n = t.map((a) => a.item), o = t[0].items;
|
|
520
|
-
return { sourceItems:
|
|
520
|
+
return { sourceItems: H(o, s), removedItems: n, sourceIndexes: s };
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function Lt(e) {
|
|
523
523
|
return {
|
|
524
524
|
// Low-level array ops
|
|
525
525
|
insertAt: I,
|
|
526
|
-
removeAt:
|
|
527
|
-
removeIndexes:
|
|
528
|
-
swapAt:
|
|
526
|
+
removeAt: Ee,
|
|
527
|
+
removeIndexes: H,
|
|
528
|
+
swapAt: Ne,
|
|
529
529
|
// Placement helpers
|
|
530
530
|
getInsertSide: (t, s) => R.getInsertSide(t, s),
|
|
531
531
|
isAtZoneStart: (t, s) => R.isAtZoneStart(t, s),
|
|
532
532
|
isAtZoneEnd: (t, s) => R.isAtZoneEnd(t, s),
|
|
533
533
|
// High-level (event-bound)
|
|
534
|
-
suggestSort: (t) =>
|
|
535
|
-
suggestSwap: () =>
|
|
536
|
-
suggestCopy: (t) =>
|
|
537
|
-
suggestRemove: () =>
|
|
534
|
+
suggestSort: (t) => wt(e, t),
|
|
535
|
+
suggestSwap: () => xt(e),
|
|
536
|
+
suggestCopy: (t) => At(e, t),
|
|
537
|
+
suggestRemove: () => Et(e)
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
|
-
const P = (e) => e.keys().next().value,
|
|
541
|
-
|
|
540
|
+
const P = (e) => e.keys().next().value, Ct = (e) => e.target.closest(
|
|
541
|
+
_.DRAGGABLE
|
|
542
542
|
);
|
|
543
|
-
function
|
|
543
|
+
function It(e) {
|
|
544
544
|
const t = e.entities.initiatingDraggable;
|
|
545
545
|
if (!t) return [];
|
|
546
546
|
const s = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t), n = s?.payload;
|
|
@@ -571,7 +571,7 @@ function Ct(e) {
|
|
|
571
571
|
}), [...l.values()].sort((u, c) => u.index - c.index);
|
|
572
572
|
}
|
|
573
573
|
const A = (e, t) => {
|
|
574
|
-
const s =
|
|
574
|
+
const s = It(e);
|
|
575
575
|
let n, o;
|
|
576
576
|
if (t) {
|
|
577
577
|
const r = e.entities.droppableMap.get(t);
|
|
@@ -614,9 +614,9 @@ const A = (e, t) => {
|
|
|
614
614
|
dropZone: n,
|
|
615
615
|
hoveredDraggable: o,
|
|
616
616
|
provider: e,
|
|
617
|
-
helpers:
|
|
617
|
+
helpers: Lt({ draggedItems: s, dropZone: n, hoveredDraggable: o })
|
|
618
618
|
};
|
|
619
|
-
},
|
|
619
|
+
}, F = (e, t, s) => {
|
|
620
620
|
if (!t) return;
|
|
621
621
|
const n = e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t);
|
|
622
622
|
!n || n.disabled || n.events?.[s]?.(A(e));
|
|
@@ -625,18 +625,18 @@ const A = (e, t) => {
|
|
|
625
625
|
e.entities.draggingMap.forEach((n) => {
|
|
626
626
|
n.disabled || n.events?.[t]?.(s);
|
|
627
627
|
});
|
|
628
|
-
},
|
|
628
|
+
}, Rt = (e, t, s) => {
|
|
629
629
|
if (t !== s) {
|
|
630
|
-
if (t && !
|
|
630
|
+
if (t && !G(t, e)) {
|
|
631
631
|
const n = A(e, t);
|
|
632
632
|
e.entities.droppableMap.get(t)?.events?.onLeave?.(n);
|
|
633
633
|
}
|
|
634
|
-
if (s && !
|
|
634
|
+
if (s && !G(s, e)) {
|
|
635
635
|
const n = A(e, s);
|
|
636
636
|
e.entities.droppableMap.get(s)?.events?.onEnter?.(n);
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
|
-
},
|
|
639
|
+
}, kt = (e, t, s) => {
|
|
640
640
|
if (t !== s) {
|
|
641
641
|
const n = A(e);
|
|
642
642
|
if (t) {
|
|
@@ -648,20 +648,20 @@ const A = (e, t) => {
|
|
|
648
648
|
o && !o.disabled && o.events?.onHover?.(n);
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
},
|
|
652
|
-
const n =
|
|
651
|
+
}, ue = (e, t, s) => {
|
|
652
|
+
const n = Ct(t);
|
|
653
653
|
!n || !e.entities.draggingMap.has(n) || e.entities.draggingMap.get(n)?.events?.[s]?.(A(e));
|
|
654
|
-
},
|
|
654
|
+
}, Pt = (e, t) => {
|
|
655
655
|
const s = P(t.droppable);
|
|
656
|
-
s && !
|
|
657
|
-
},
|
|
656
|
+
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
657
|
+
}, Xe = (e, t) => {
|
|
658
658
|
const s = P(t.droppable);
|
|
659
|
-
s && !
|
|
659
|
+
s && !G(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(A(e, s));
|
|
660
660
|
};
|
|
661
|
-
function
|
|
662
|
-
return e.parentElement?.closest(
|
|
661
|
+
function Tt(e) {
|
|
662
|
+
return e.parentElement?.closest(_.SELECT_AREA) ?? null;
|
|
663
663
|
}
|
|
664
|
-
const
|
|
664
|
+
const zt = (e, t, s) => {
|
|
665
665
|
if (!s) return {};
|
|
666
666
|
const n = s.getBoundingClientRect(), o = Math.max(n.left, Math.min(e.x, t.x)), r = Math.max(n.top, Math.min(e.y, t.y)), a = Math.min(n.right, Math.max(e.x, t.x)), i = Math.min(n.bottom, Math.max(e.y, t.y)), g = Math.max(0, a - o), l = Math.max(0, i - r);
|
|
667
667
|
return {
|
|
@@ -676,33 +676,33 @@ const Tt = (e, t, s) => {
|
|
|
676
676
|
};
|
|
677
677
|
}, Ot = (e) => {
|
|
678
678
|
if (!e.pointer.value || !e.entities.selectingArea) return;
|
|
679
|
-
const { selectingArea: t } = e.entities, s =
|
|
679
|
+
const { selectingArea: t } = e.entities, s = Bt(
|
|
680
680
|
e.pointer.value.start,
|
|
681
681
|
e.pointer.value.current
|
|
682
682
|
), n = e.entities.selectableAreaMap.get(t)?.groups ?? [], o = e.lib.rectCache;
|
|
683
683
|
e.entities.visibleDraggableSet.forEach((r) => {
|
|
684
684
|
if (r === t || !t.contains(r)) return;
|
|
685
|
-
const a =
|
|
685
|
+
const a = Tt(r);
|
|
686
686
|
if (a && a !== t) {
|
|
687
687
|
e.entities.selectedSet.delete(r);
|
|
688
688
|
return;
|
|
689
689
|
}
|
|
690
|
-
if (
|
|
690
|
+
if (xe(r, e)) {
|
|
691
691
|
e.entities.selectedSet.delete(r);
|
|
692
692
|
return;
|
|
693
693
|
}
|
|
694
694
|
const g = e.entities.draggableMap.get(r)?.groups ?? [];
|
|
695
|
-
if (!
|
|
695
|
+
if (!Ae(n, g)) {
|
|
696
696
|
e.entities.selectedSet.delete(r);
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
699
|
let l = o.get(r);
|
|
700
|
-
l || (l = r.getBoundingClientRect(), o.set(r, l)),
|
|
700
|
+
l || (l = r.getBoundingClientRect(), o.set(r, l)), it(s, l) ? e.entities.selectedSet.add(r) : e.entities.selectedSet.delete(r);
|
|
701
701
|
});
|
|
702
|
-
},
|
|
702
|
+
}, Bt = (e, t) => {
|
|
703
703
|
const s = Math.min(e.x, t.x), n = Math.min(e.y, t.y), o = Math.max(e.x, t.x), r = Math.max(e.y, t.y), a = o - s, i = r - n;
|
|
704
704
|
return new DOMRect(s, n, a, i);
|
|
705
|
-
},
|
|
705
|
+
}, Ft = (e, t, s = 5) => {
|
|
706
706
|
const n = s / 2;
|
|
707
707
|
return {
|
|
708
708
|
left: e - n,
|
|
@@ -710,10 +710,10 @@ const Tt = (e, t, s) => {
|
|
|
710
710
|
width: s,
|
|
711
711
|
height: s
|
|
712
712
|
};
|
|
713
|
-
},
|
|
713
|
+
}, _t = (e) => {
|
|
714
714
|
const t = e.pointer.value?.current, s = t?.x ?? 0, n = t?.y ?? 0;
|
|
715
|
-
return
|
|
716
|
-
},
|
|
715
|
+
return Ft(s, n, 5);
|
|
716
|
+
}, O = (e, t, s) => {
|
|
717
717
|
const n = e.left + e.width / 2, o = e.top + e.height / 2;
|
|
718
718
|
if (s) {
|
|
719
719
|
const i = s.top ?? 0, g = s.right ?? 0, l = s.bottom ?? 0, u = s.left ?? 0, c = t.left + u, f = t.right - g, d = t.top + i, m = t.bottom - l;
|
|
@@ -734,33 +734,33 @@ const Tt = (e, t, s) => {
|
|
|
734
734
|
right: n > r,
|
|
735
735
|
center: !1
|
|
736
736
|
};
|
|
737
|
-
},
|
|
737
|
+
}, Gt = (e) => ({
|
|
738
738
|
x: e.left + e.width / 2,
|
|
739
739
|
y: e.top + e.height / 2
|
|
740
|
-
}),
|
|
741
|
-
const s =
|
|
740
|
+
}), Re = (e, t) => {
|
|
741
|
+
const s = Gt(t);
|
|
742
742
|
return Math.hypot(e.x - s.x, e.y - s.y);
|
|
743
743
|
};
|
|
744
|
-
function
|
|
744
|
+
function Ht(e, t) {
|
|
745
745
|
return e === t ? !0 : !e || !t ? !1 : e.top === t.top && e.right === t.right && e.bottom === t.bottom && e.left === t.left && e.center === t.center;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
748
|
-
|
|
747
|
+
function W(e, t) {
|
|
748
|
+
Ht(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
749
749
|
}
|
|
750
|
-
const
|
|
750
|
+
const Kt = (e, t) => e.find((s) => s !== t && K(t, s)), ae = (e, t, s) => {
|
|
751
751
|
const n = P(t.droppable), o = P(t.draggable);
|
|
752
752
|
o && t.draggable.delete(o), n && t.droppable.delete(n);
|
|
753
|
-
const r =
|
|
753
|
+
const r = _t(e), a = s.zones[0], i = s.elements[0];
|
|
754
754
|
if (a && i && a === i && e.entities.droppableMap.has(a) && a) {
|
|
755
|
-
const c = a.getBoundingClientRect(), f = e.entities.draggableMap.get(a)?.placementMargins, d =
|
|
755
|
+
const c = a.getBoundingClientRect(), f = e.entities.draggableMap.get(a)?.placementMargins, d = O(r, c, f);
|
|
756
756
|
if (d.center) {
|
|
757
757
|
t.droppable.set(a, d);
|
|
758
|
-
const m =
|
|
758
|
+
const m = Kt(s.elements, a);
|
|
759
759
|
if (m) {
|
|
760
760
|
const h = m.getBoundingClientRect();
|
|
761
761
|
t.draggable.set(
|
|
762
762
|
m,
|
|
763
|
-
|
|
763
|
+
O(r, h, void 0)
|
|
764
764
|
);
|
|
765
765
|
}
|
|
766
766
|
} else
|
|
@@ -768,24 +768,24 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
768
768
|
} else {
|
|
769
769
|
if (a) {
|
|
770
770
|
const c = a.getBoundingClientRect();
|
|
771
|
-
t.droppable.set(a,
|
|
771
|
+
t.droppable.set(a, O(r, c));
|
|
772
772
|
}
|
|
773
773
|
if (i)
|
|
774
774
|
if (a)
|
|
775
|
-
if (
|
|
775
|
+
if (K(a, i)) {
|
|
776
776
|
const c = i.getBoundingClientRect(), f = e.entities.draggableMap.get(i)?.placementMargins;
|
|
777
777
|
t.draggable.set(
|
|
778
778
|
i,
|
|
779
|
-
|
|
779
|
+
O(r, c, f)
|
|
780
780
|
);
|
|
781
781
|
} else {
|
|
782
|
-
const c = e.pointer.value?.current ?? { x: 0, y: 0 }, f = a.getBoundingClientRect(), d = i.getBoundingClientRect(), m =
|
|
783
|
-
if (
|
|
782
|
+
const c = e.pointer.value?.current ?? { x: 0, y: 0 }, f = a.getBoundingClientRect(), d = i.getBoundingClientRect(), m = Re(c, f);
|
|
783
|
+
if (Re(c, d) < m) {
|
|
784
784
|
t.droppable.clear();
|
|
785
785
|
const S = e.entities.draggableMap.get(i)?.placementMargins;
|
|
786
786
|
t.draggable.set(
|
|
787
787
|
i,
|
|
788
|
-
|
|
788
|
+
O(r, d, S)
|
|
789
789
|
);
|
|
790
790
|
}
|
|
791
791
|
}
|
|
@@ -793,29 +793,29 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
793
793
|
const c = i.getBoundingClientRect(), f = e.entities.draggableMap.get(i)?.placementMargins;
|
|
794
794
|
t.draggable.set(
|
|
795
795
|
i,
|
|
796
|
-
|
|
796
|
+
O(r, c, f)
|
|
797
797
|
);
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
const l = P(t.droppable), u = P(t.draggable);
|
|
801
801
|
if (o && o !== u) {
|
|
802
802
|
const c = e.entities.draggableMap.get(o);
|
|
803
|
-
c &&
|
|
803
|
+
c && W(c, void 0);
|
|
804
804
|
}
|
|
805
805
|
if (n && n !== l) {
|
|
806
806
|
const c = e.entities.droppableMap.get(n);
|
|
807
|
-
c &&
|
|
807
|
+
c && W(c, void 0);
|
|
808
808
|
}
|
|
809
809
|
if (u) {
|
|
810
810
|
const c = e.entities.draggableMap.get(u);
|
|
811
|
-
c &&
|
|
811
|
+
c && W(c, t.draggable.get(u));
|
|
812
812
|
}
|
|
813
813
|
if (l) {
|
|
814
814
|
const c = e.entities.droppableMap.get(l);
|
|
815
|
-
c &&
|
|
815
|
+
c && W(c, t.droppable.get(l));
|
|
816
816
|
}
|
|
817
|
-
|
|
818
|
-
},
|
|
817
|
+
Rt(e, n, l), kt(e, o, u);
|
|
818
|
+
}, 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) => {
|
|
819
819
|
if (!e)
|
|
820
820
|
return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
|
|
821
821
|
const t = e.getBoundingClientRect();
|
|
@@ -829,10 +829,10 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
829
829
|
right: t.right,
|
|
830
830
|
bottom: t.bottom
|
|
831
831
|
};
|
|
832
|
-
},
|
|
832
|
+
}, Y = (e) => ({
|
|
833
833
|
x: e.x + e.width / 2,
|
|
834
834
|
y: e.y + e.height / 2
|
|
835
|
-
}),
|
|
835
|
+
}), Zt = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), Q = (e, t) => {
|
|
836
836
|
const s = Math.max(
|
|
837
837
|
0,
|
|
838
838
|
Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)
|
|
@@ -841,7 +841,7 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
841
841
|
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
|
|
842
842
|
), o = s * n, r = e.width * e.height, a = t.width * t.height;
|
|
843
843
|
return r === 0 || a === 0 ? 0 : (o / r * 100 + o / a * 100) / 2;
|
|
844
|
-
}, Nt = (e, t, s) => t >= e.x && t <= e.x + e.width && s >= e.y && s <= e.y + e.height,
|
|
844
|
+
}, 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) => {
|
|
845
845
|
const t = e.overlay.position?.value ?? { x: 0, y: 0 }, { x: s, y: n } = t, o = e.overlay.size?.value;
|
|
846
846
|
let r, a;
|
|
847
847
|
if (o)
|
|
@@ -860,59 +860,70 @@ const Ht = (e, t) => e.find((s) => s !== t && H(t, s)), ne = (e, t, s) => {
|
|
|
860
860
|
right: s + r,
|
|
861
861
|
bottom: n + a
|
|
862
862
|
};
|
|
863
|
-
},
|
|
864
|
-
(s) =>
|
|
865
|
-
), Vt = (e, t) => t.entities.draggableMap.has(e) ? !
|
|
866
|
-
function
|
|
863
|
+
}, De = (e) => e.entities.allowedDraggableSet, Ue = (e) => e.entities.allowedDroppableSet, Xt = (e, t) => !t.entities.draggingMap.has(e), Ut = (e, t) => ![...t.entities.draggingMap.keys()].some(
|
|
864
|
+
(s) => K(s, e)
|
|
865
|
+
), Vt = (e, t) => t.entities.draggableMap.has(e) ? !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;
|
|
866
|
+
function B(e, t) {
|
|
867
867
|
return Math.hypot(
|
|
868
868
|
t.x - (e.x + e.width / 2),
|
|
869
869
|
t.y - (e.y + e.height / 2)
|
|
870
870
|
);
|
|
871
871
|
}
|
|
872
872
|
function $t(e) {
|
|
873
|
-
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, s = document.
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
873
|
+
const t = e.pointer.value?.current ?? { x: 0, y: 0 }, s = document.elementFromPoint(t.x, t.y);
|
|
874
|
+
if (!s) return null;
|
|
875
|
+
const n = De(e), o = Ue(e), r = [], a = [];
|
|
876
|
+
let i = s;
|
|
877
|
+
for (; i; )
|
|
878
|
+
(n.has(i) || o.has(i)) && ee(i, e) && (n.has(i) && r.push(i), o.has(i) && a.push(i)), i = i.parentElement;
|
|
878
879
|
return r.length === 0 && a.length === 0 ? null : { elements: r, zones: a };
|
|
879
880
|
}
|
|
880
|
-
const
|
|
881
|
-
if (!
|
|
882
|
-
const s = $t(e);
|
|
883
|
-
if (
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
881
|
+
const Me = (e) => {
|
|
882
|
+
if (!Yt(e)) return { elements: [], zones: [] };
|
|
883
|
+
const s = e.pointer.value?.current ?? { x: 0, y: 0 }, n = $t(e);
|
|
884
|
+
if (n) {
|
|
885
|
+
if (n.elements.length > 0) return n;
|
|
886
|
+
const l = n.zones[0];
|
|
887
|
+
if (!l) return n;
|
|
888
|
+
const u = ke(e);
|
|
889
|
+
return { elements: [...De(e)].filter(
|
|
890
|
+
(d) => l.contains(d) && ee(d, e)
|
|
891
|
+
).map((d) => ({ el: d, box: X(d) })).filter(
|
|
892
|
+
({ box: d }) => fe(d, u) && Q(d, u) >= de
|
|
893
|
+
).sort((d, m) => B(d.box, s) - B(m.box, s)).map(({ el: d }) => d), zones: n.zones };
|
|
894
|
+
}
|
|
895
|
+
const o = ke(e), r = [...De(e)].filter(
|
|
896
|
+
(l) => ee(l, e)
|
|
897
|
+
), a = [...Ue(e)].filter(
|
|
898
|
+
(l) => ee(l, e)
|
|
899
|
+
), i = r.map((l) => ({ n: l, box: X(l) })).filter(
|
|
900
|
+
({ box: l }) => fe(l, o) && Q(l, o) >= de
|
|
901
|
+
).sort((l, u) => B(l.box, s) - B(u.box, s)).map(({ n: l }) => l), g = a.map((l) => ({ n: l, box: X(l) })).filter(
|
|
902
|
+
({ box: l }) => fe(l, o) && Q(l, o) >= de
|
|
903
|
+
).sort((l, u) => B(l.box, s) - B(u.box, s)).map(({ n: l }) => l);
|
|
893
904
|
return { elements: i, zones: g };
|
|
894
905
|
};
|
|
895
|
-
function
|
|
906
|
+
function ve(e) {
|
|
896
907
|
if (e.collision?.run) {
|
|
897
908
|
const s = e.collision.run(e);
|
|
898
|
-
|
|
909
|
+
ae(e, e.hovered, s);
|
|
899
910
|
return;
|
|
900
911
|
}
|
|
901
|
-
const t =
|
|
902
|
-
|
|
912
|
+
const t = Me(e);
|
|
913
|
+
ae(e, e.hovered, t);
|
|
903
914
|
}
|
|
904
915
|
function qt(e, t) {
|
|
905
916
|
const s = e.collision?.throttle?.value ?? 0;
|
|
906
917
|
if (s <= 0) {
|
|
907
|
-
|
|
918
|
+
ve(e);
|
|
908
919
|
return;
|
|
909
920
|
}
|
|
910
921
|
const n = Date.now();
|
|
911
|
-
n - t.value >= s && (t.value = n,
|
|
922
|
+
n - t.value >= s && (t.value = n, ve(e));
|
|
912
923
|
}
|
|
913
|
-
async function
|
|
924
|
+
async function Ve(e) {
|
|
914
925
|
const t = e.hovered.droppable.keys().next().value;
|
|
915
|
-
if (!t ||
|
|
926
|
+
if (!t || G(t, e)) return "accept";
|
|
916
927
|
const s = e.entities.droppableMap.get(t), n = A(e, t), o = s?.events?.onDrop?.(n);
|
|
917
928
|
if (o != null && typeof o.then == "function") {
|
|
918
929
|
e.state.value = "pending";
|
|
@@ -921,15 +932,15 @@ async function Ue(e) {
|
|
|
921
932
|
a = await o;
|
|
922
933
|
} catch {
|
|
923
934
|
const i = e.entities.initiatingDraggable;
|
|
924
|
-
return
|
|
935
|
+
return F(e, i, "onSelfDragCancel"), x(e, "onDragCancel"), Xe(e, e.hovered), "cancel";
|
|
925
936
|
}
|
|
926
937
|
return a === !1 ? (e.state.value = "dragging", "decline") : "accept";
|
|
927
938
|
}
|
|
928
939
|
return o === !1 ? "decline" : "accept";
|
|
929
940
|
}
|
|
930
|
-
function
|
|
941
|
+
function $e(e) {
|
|
931
942
|
const t = e.entities.initiatingDraggable;
|
|
932
|
-
|
|
943
|
+
F(e, t, "onSelfDragEnd"), x(e, "onDragEnd"), Pt(e, e.hovered);
|
|
933
944
|
}
|
|
934
945
|
function Wt(e) {
|
|
935
946
|
const t = e.entities.selectingArea;
|
|
@@ -941,27 +952,27 @@ const jt = (e) => {
|
|
|
941
952
|
const t = {
|
|
942
953
|
current: null
|
|
943
954
|
}, s = { value: 0 }, n = async () => {
|
|
944
|
-
|
|
955
|
+
pe(), t.current?.cancel(), t.current = null;
|
|
945
956
|
const i = e.state.value;
|
|
946
957
|
if (i === "dragging") {
|
|
947
|
-
const g = await
|
|
948
|
-
if (g === "accept" &&
|
|
949
|
-
|
|
958
|
+
const g = await Ve(e);
|
|
959
|
+
if (g === "accept" && $e(e), g === "accept" || g === "cancel") {
|
|
960
|
+
oe(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
950
961
|
return;
|
|
951
962
|
}
|
|
952
963
|
return;
|
|
953
964
|
} else i === "selecting" && Wt(e);
|
|
954
|
-
|
|
965
|
+
oe(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
955
966
|
}, o = (i) => {
|
|
956
967
|
if (e.pointer.value) {
|
|
957
|
-
if (e.pointer.value.current = { x: i.clientX, y: i.clientY },
|
|
958
|
-
|
|
968
|
+
if (e.pointer.value.current = { x: i.clientX, y: i.clientY }, bt(e)) {
|
|
969
|
+
ue(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
959
970
|
return;
|
|
960
971
|
}
|
|
961
972
|
if (e.state.value === "dragging") {
|
|
962
973
|
qt(e, s);
|
|
963
974
|
const g = e.entities.initiatingDraggable;
|
|
964
|
-
|
|
975
|
+
F(e, g, "onSelfDragMove"), x(e, "onDragMove");
|
|
965
976
|
}
|
|
966
977
|
e.state.value === "selecting" && Ot(e);
|
|
967
978
|
}
|
|
@@ -969,23 +980,23 @@ const jt = (e) => {
|
|
|
969
980
|
return { pointerDown: (i) => {
|
|
970
981
|
document.addEventListener("pointerup", n), document.addEventListener("pointermove", o);
|
|
971
982
|
const g = i.target, l = g.closest(
|
|
972
|
-
|
|
983
|
+
_.SELECT_AREA
|
|
973
984
|
), u = g.closest(
|
|
974
|
-
|
|
985
|
+
_.DRAGGABLE
|
|
975
986
|
);
|
|
976
987
|
if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(l)) {
|
|
977
|
-
|
|
988
|
+
ye(), e.pointer.value = Se(i), e.state.value = "selecting", e.entities.selectingArea = l;
|
|
978
989
|
return;
|
|
979
990
|
}
|
|
980
991
|
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(u)) {
|
|
981
992
|
const c = e.entities.draggableMap.get(u);
|
|
982
|
-
if (!
|
|
993
|
+
if (!Ke(g, u, c?.dragHandle))
|
|
983
994
|
return;
|
|
984
|
-
|
|
985
|
-
const f =
|
|
986
|
-
e.pointer.value =
|
|
987
|
-
|
|
988
|
-
}))) : (
|
|
995
|
+
ye(), e.entities.initiatingDraggable = u;
|
|
996
|
+
const f = Ge(i, u);
|
|
997
|
+
e.pointer.value = Se(i, f.x, f.y), c?.activation?.distance || c?.activation?.delay ? (e.state.value = "activating", c?.activation?.delay && (e.delay.startTime = Date.now(), t.current = yt(e, () => {
|
|
998
|
+
se(e), ue(e, i, "onSelfDragStart"), x(e, "onDragStart");
|
|
999
|
+
}))) : (se(e), ue(e, i, "onSelfDragStart"), x(e, "onDragStart"));
|
|
989
1000
|
}
|
|
990
1001
|
}, pointerUp: n, pointerMove: o, cleanup: () => {
|
|
991
1002
|
t.current?.cancel(), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o), e.lib.draggableObserver.disconnect(), e.lib.droppableObserver.disconnect(), e.lib.selectableAreaObserver.disconnect(), e.lib.overlaySizeObserver.disconnect();
|
|
@@ -1003,15 +1014,15 @@ const jt = (e) => {
|
|
|
1003
1014
|
const { keys: s } = e.keyboard;
|
|
1004
1015
|
if (s.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1005
1016
|
if (s.forCancel.includes(t.code)) {
|
|
1006
|
-
t.preventDefault(),
|
|
1017
|
+
t.preventDefault(), pe(), F(
|
|
1007
1018
|
e,
|
|
1008
1019
|
e.entities.initiatingDraggable,
|
|
1009
1020
|
"onSelfDragCancel"
|
|
1010
|
-
), x(e, "onDragCancel"),
|
|
1021
|
+
), x(e, "onDragCancel"), Xe(e, e.hovered), oe(e);
|
|
1011
1022
|
return;
|
|
1012
1023
|
}
|
|
1013
1024
|
if (s.forDrop.includes(t.code)) {
|
|
1014
|
-
t.preventDefault(), (async () => (await
|
|
1025
|
+
t.preventDefault(), (async () => (await Ve(e) && $e(e), pe(), oe(e)))();
|
|
1015
1026
|
return;
|
|
1016
1027
|
}
|
|
1017
1028
|
const o = Jt[t.code];
|
|
@@ -1024,8 +1035,8 @@ const jt = (e) => {
|
|
|
1024
1035
|
x: e.pointer.value.current.x + o.dx * a,
|
|
1025
1036
|
y: e.pointer.value.current.y + o.dy * a
|
|
1026
1037
|
};
|
|
1027
|
-
const g = (e.collision?.run ??
|
|
1028
|
-
|
|
1038
|
+
const g = (e.collision?.run ?? Me)(e);
|
|
1039
|
+
ae(e, e.hovered, g), F(
|
|
1029
1040
|
e,
|
|
1030
1041
|
e.entities.initiatingDraggable,
|
|
1031
1042
|
"onSelfDragMove"
|
|
@@ -1038,39 +1049,39 @@ const jt = (e) => {
|
|
|
1038
1049
|
const o = document.activeElement;
|
|
1039
1050
|
if (!o) return;
|
|
1040
1051
|
const r = o.closest(
|
|
1041
|
-
|
|
1052
|
+
_.DRAGGABLE
|
|
1042
1053
|
);
|
|
1043
1054
|
if (!r || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(r))
|
|
1044
1055
|
return;
|
|
1045
1056
|
const a = e.entities.draggableMap.get(r);
|
|
1046
|
-
if (!
|
|
1057
|
+
if (!Ke(o, r, a?.dragHandle, !0))
|
|
1047
1058
|
return;
|
|
1048
|
-
t.preventDefault(),
|
|
1059
|
+
t.preventDefault(), ye();
|
|
1049
1060
|
const i = r.getBoundingClientRect(), g = i.left + i.width / 2, l = i.top + i.height / 2, u = {
|
|
1050
1061
|
clientX: g,
|
|
1051
1062
|
clientY: l
|
|
1052
1063
|
};
|
|
1053
1064
|
e.entities.initiatingDraggable = r;
|
|
1054
|
-
const c =
|
|
1055
|
-
e.pointer.value =
|
|
1065
|
+
const c = Ge(u, r);
|
|
1066
|
+
e.pointer.value = Se(
|
|
1056
1067
|
u,
|
|
1057
1068
|
c.x,
|
|
1058
1069
|
c.y
|
|
1059
|
-
),
|
|
1060
|
-
const d = (e.collision?.run ??
|
|
1061
|
-
|
|
1070
|
+
), se(e);
|
|
1071
|
+
const d = (e.collision?.run ?? Me)(e);
|
|
1072
|
+
ae(e, e.hovered, d), F(e, r, "onSelfDragStart"), x(e, "onDragStart");
|
|
1062
1073
|
}
|
|
1063
1074
|
}, en = (e) => (t) => {
|
|
1064
1075
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
1065
1076
|
}, tn = (e) => () => {
|
|
1066
1077
|
e.keyboard.keys.pressedKeys.value.clear();
|
|
1067
|
-
},
|
|
1078
|
+
}, me = {
|
|
1068
1079
|
keyDown: Qt,
|
|
1069
1080
|
keyUp: en,
|
|
1070
1081
|
clear: tn
|
|
1071
1082
|
}, nn = (e) => () => {
|
|
1072
|
-
e.state.value && (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging" &&
|
|
1073
|
-
}, L = 50, sn = 144,
|
|
1083
|
+
e.state.value && (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging" && ve(e));
|
|
1084
|
+
}, L = 50, sn = 144, Pe = 1e3 / sn;
|
|
1074
1085
|
function on(e) {
|
|
1075
1086
|
return e == null ? {
|
|
1076
1087
|
top: L,
|
|
@@ -1100,7 +1111,7 @@ const an = {
|
|
|
1100
1111
|
e.scrollTop = t, e.scrollLeft = s;
|
|
1101
1112
|
}
|
|
1102
1113
|
};
|
|
1103
|
-
function
|
|
1114
|
+
function qe(e, t, s, n = an, o) {
|
|
1104
1115
|
const { speed: r = 10, disabled: a = !1 } = t, i = on(t.threshold);
|
|
1105
1116
|
let g = null, l = null, u = null, c = 0, f = 0;
|
|
1106
1117
|
const d = (b) => {
|
|
@@ -1112,17 +1123,17 @@ function $e(e, t, s, n = an, o) {
|
|
|
1112
1123
|
return;
|
|
1113
1124
|
}
|
|
1114
1125
|
l || (l = b);
|
|
1115
|
-
const
|
|
1116
|
-
if (
|
|
1126
|
+
const $ = b - l;
|
|
1127
|
+
if ($ < Pe) {
|
|
1117
1128
|
g = requestAnimationFrame(m);
|
|
1118
1129
|
return;
|
|
1119
1130
|
}
|
|
1120
|
-
const p = r * (
|
|
1131
|
+
const p = r * ($ / Pe);
|
|
1121
1132
|
l = b;
|
|
1122
|
-
const { scrollTop: w, scrollLeft:
|
|
1123
|
-
(!u || c !== w || f !==
|
|
1124
|
-
let
|
|
1125
|
-
i.top > 0 && E.y - u.top < i.top ? (
|
|
1133
|
+
const { scrollTop: w, scrollLeft: Z } = n.getScrollState(v);
|
|
1134
|
+
(!u || c !== w || f !== Z) && (u = n.getRect ? n.getRect(v) : v.getBoundingClientRect(), c = w, f = Z);
|
|
1135
|
+
let z = !1, le = w, ce = Z;
|
|
1136
|
+
i.top > 0 && E.y - u.top < i.top ? (le = w - p, z = !0) : i.bottom > 0 && u.bottom - E.y < i.bottom && (le = w + p, z = !0), i.left > 0 && E.x - u.left < i.left ? (ce = Z - p, z = !0) : i.right > 0 && u.right - E.x < i.right && (ce = Z + p, z = !0), z && n.setScroll(v, le, ce), d(z), g = requestAnimationFrame(m);
|
|
1126
1137
|
};
|
|
1127
1138
|
return { run: () => {
|
|
1128
1139
|
l = null, g = requestAnimationFrame(m);
|
|
@@ -1149,7 +1160,7 @@ const rn = {
|
|
|
1149
1160
|
}
|
|
1150
1161
|
};
|
|
1151
1162
|
function cn(e, t) {
|
|
1152
|
-
const s =
|
|
1163
|
+
const s = te(!1), o = qe(
|
|
1153
1164
|
ln,
|
|
1154
1165
|
t ?? {},
|
|
1155
1166
|
() => {
|
|
@@ -1162,7 +1173,7 @@ function cn(e, t) {
|
|
|
1162
1173
|
},
|
|
1163
1174
|
rn,
|
|
1164
1175
|
s
|
|
1165
|
-
), r =
|
|
1176
|
+
), r = re(
|
|
1166
1177
|
() => e.state.value,
|
|
1167
1178
|
(i) => {
|
|
1168
1179
|
i === "dragging" ? o.run() : o.stop();
|
|
@@ -1170,12 +1181,12 @@ function cn(e, t) {
|
|
|
1170
1181
|
), a = () => {
|
|
1171
1182
|
r(), o.stop();
|
|
1172
1183
|
};
|
|
1173
|
-
return
|
|
1184
|
+
return je(a), { isScrolling: s, stop: a };
|
|
1174
1185
|
}
|
|
1175
1186
|
const gn = (e) => {
|
|
1176
|
-
const t = jt(e), s =
|
|
1187
|
+
const t = jt(e), s = me.keyDown(e), n = me.keyUp(e), o = me.clear(e), r = nn(e);
|
|
1177
1188
|
let a = null;
|
|
1178
|
-
|
|
1189
|
+
re(
|
|
1179
1190
|
e.autoScrollViewport,
|
|
1180
1191
|
(i) => {
|
|
1181
1192
|
a?.(), a = null, (i === !0 || i && typeof i == "object") && (a = cn(
|
|
@@ -1184,17 +1195,17 @@ const gn = (e) => {
|
|
|
1184
1195
|
).stop);
|
|
1185
1196
|
},
|
|
1186
1197
|
{ immediate: !0 }
|
|
1187
|
-
),
|
|
1198
|
+
), U(() => {
|
|
1188
1199
|
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", s), document.addEventListener("keyup", n), document.addEventListener("blur", o), document.addEventListener("scroll", r, !0);
|
|
1189
|
-
}),
|
|
1200
|
+
}), V(() => {
|
|
1190
1201
|
document.removeEventListener("pointerdown", t.pointerDown), document.removeEventListener("pointerup", t.pointerUp), document.removeEventListener("pointermove", t.pointerMove), document.removeEventListener("keydown", s), document.removeEventListener("keyup", n), document.removeEventListener("blur", o), document.removeEventListener("scroll", r, !0), a?.(), t.cleanup();
|
|
1191
1202
|
});
|
|
1192
|
-
},
|
|
1193
|
-
const e =
|
|
1203
|
+
}, ie = () => {
|
|
1204
|
+
const e = Be(we);
|
|
1194
1205
|
if (!e) throw Error("DnD provider not found");
|
|
1195
1206
|
return e;
|
|
1196
|
-
},
|
|
1197
|
-
const e =
|
|
1207
|
+
}, We = () => {
|
|
1208
|
+
const e = ie();
|
|
1198
1209
|
return {
|
|
1199
1210
|
overlay: e.overlay,
|
|
1200
1211
|
delay: e.delay,
|
|
@@ -1208,31 +1219,31 @@ const gn = (e) => {
|
|
|
1208
1219
|
collision: e.collision,
|
|
1209
1220
|
autoScrollViewport: e.autoScrollViewport
|
|
1210
1221
|
};
|
|
1211
|
-
}, un = /* @__PURE__ */
|
|
1222
|
+
}, un = /* @__PURE__ */ Fe({
|
|
1212
1223
|
__name: "DefaultOverlay",
|
|
1213
1224
|
setup(e) {
|
|
1214
|
-
const { entities: t, state: s, overlay: n } =
|
|
1215
|
-
return (o, r) => k(s) === "dragging" ? (C(),
|
|
1225
|
+
const { entities: t, state: s, overlay: n } = We();
|
|
1226
|
+
return (o, r) => k(s) === "dragging" ? (C(), J("div", {
|
|
1216
1227
|
key: 0,
|
|
1217
1228
|
class: "dnd-kit-default-overlay",
|
|
1218
|
-
style:
|
|
1229
|
+
style: Le({
|
|
1219
1230
|
"--position-x": k(n).position.value.x + "px",
|
|
1220
1231
|
"--position-y": k(n).position.value.y + "px"
|
|
1221
1232
|
})
|
|
1222
1233
|
}, [
|
|
1223
|
-
(C(!0),
|
|
1224
|
-
k(t).draggableMap.get(a)?.render ? (C(),
|
|
1234
|
+
(C(!0), J(he, null, Je(k(t).draggingMap, ([a, i]) => (C(), J(he, null, [
|
|
1235
|
+
k(t).draggableMap.get(a)?.render ? (C(), ne(be(k(t).draggableMap.get(a)?.render), { key: 0 })) : (C(), ne(be(a.tagName), {
|
|
1225
1236
|
key: 1,
|
|
1226
1237
|
innerHTML: i.initialOuterHTML,
|
|
1227
|
-
style:
|
|
1238
|
+
style: Le({
|
|
1228
1239
|
width: i.initialRect.width + "px",
|
|
1229
1240
|
height: i.initialRect.height + "px"
|
|
1230
1241
|
})
|
|
1231
1242
|
}, null, 8, ["innerHTML", "style"]))
|
|
1232
1243
|
], 64))), 256))
|
|
1233
|
-
], 4)) :
|
|
1244
|
+
], 4)) : Qe("", !0);
|
|
1234
1245
|
}
|
|
1235
|
-
}), hn = /* @__PURE__ */
|
|
1246
|
+
}), hn = /* @__PURE__ */ Fe({
|
|
1236
1247
|
__name: "DnDProvider",
|
|
1237
1248
|
props: {
|
|
1238
1249
|
autoScrollViewport: { type: [Object, Boolean, null] },
|
|
@@ -1241,23 +1252,23 @@ const gn = (e) => {
|
|
|
1241
1252
|
class: {}
|
|
1242
1253
|
},
|
|
1243
1254
|
setup(e) {
|
|
1244
|
-
const t = e, s =
|
|
1255
|
+
const t = e, s = et("overlayRef"), n = vt(s, t);
|
|
1245
1256
|
gn(n);
|
|
1246
1257
|
const o = y(
|
|
1247
1258
|
() => n.overlay.render.value ?? un
|
|
1248
1259
|
);
|
|
1249
|
-
return
|
|
1250
|
-
|
|
1251
|
-
(C(),
|
|
1260
|
+
return tt(we, n), (r, a) => (C(), J(he, null, [
|
|
1261
|
+
Ce(r.$slots, "default"),
|
|
1262
|
+
(C(), ne(nt, {
|
|
1252
1263
|
to: k(n).overlay.to.value || "body"
|
|
1253
1264
|
}, [
|
|
1254
|
-
|
|
1265
|
+
st("div", ot({
|
|
1255
1266
|
ref_key: "overlayRef",
|
|
1256
1267
|
ref: s,
|
|
1257
1268
|
class: "dnd-kit-overlay-container"
|
|
1258
1269
|
}, t), [
|
|
1259
|
-
|
|
1260
|
-
(C(),
|
|
1270
|
+
Ce(r.$slots, "overlay", { overlay: o.value }, () => [
|
|
1271
|
+
(C(), ne(be(o.value)))
|
|
1261
1272
|
])
|
|
1262
1273
|
], 16)
|
|
1263
1274
|
], 8, ["to"]))
|
|
@@ -1265,7 +1276,7 @@ const gn = (e) => {
|
|
|
1265
1276
|
}
|
|
1266
1277
|
});
|
|
1267
1278
|
function bn(e, t, s) {
|
|
1268
|
-
const n =
|
|
1279
|
+
const n = ie();
|
|
1269
1280
|
let o, r, a;
|
|
1270
1281
|
typeof t == "function" ? (o = {}, r = t) : (o = t ?? {}, r = s);
|
|
1271
1282
|
const i = y({
|
|
@@ -1288,7 +1299,7 @@ function bn(e, t, s) {
|
|
|
1288
1299
|
if (c)
|
|
1289
1300
|
return n.entities.draggableMap.get(c)?.hoveredPlacement;
|
|
1290
1301
|
});
|
|
1291
|
-
return
|
|
1302
|
+
return U(() => {
|
|
1292
1303
|
a = D(e), a && (a.addEventListener("dragstart", M), a.addEventListener("drag", M), a.addEventListener("dragend", M), a.setAttribute(T.DRAGGABLE, ""), n.lib.draggableObserver.observe(a), n.entities.draggableMap.set(a, {
|
|
1293
1304
|
render: o.render,
|
|
1294
1305
|
disabled: o.disabled ?? !1,
|
|
@@ -1302,7 +1313,7 @@ function bn(e, t, s) {
|
|
|
1302
1313
|
placementMargins: o.placementMargins,
|
|
1303
1314
|
hoveredPlacement: void 0
|
|
1304
1315
|
}));
|
|
1305
|
-
}),
|
|
1316
|
+
}), V(() => {
|
|
1306
1317
|
a && (n.lib.draggableObserver.unobserve(a), n.entities.visibleDraggableSet.delete(a), n.entities.draggableMap.delete(a), n.entities.modifiersDraggableSet.delete(a));
|
|
1307
1318
|
}), {
|
|
1308
1319
|
selected: i,
|
|
@@ -1312,9 +1323,9 @@ function bn(e, t, s) {
|
|
|
1312
1323
|
};
|
|
1313
1324
|
}
|
|
1314
1325
|
const yn = (e, t) => {
|
|
1315
|
-
const s =
|
|
1326
|
+
const s = ie(), n = y(() => e.value === s.entities.selectingArea);
|
|
1316
1327
|
let o = null;
|
|
1317
|
-
|
|
1328
|
+
U(() => {
|
|
1318
1329
|
o = D(e), o && (o.setAttribute(T.SELECT_AREA, ""), s.lib.selectableAreaObserver.observe(o), s.entities.selectableAreaMap.set(o, {
|
|
1319
1330
|
modifier: t?.modifier ?? {
|
|
1320
1331
|
keys: ["ControlLeft"],
|
|
@@ -1324,13 +1335,13 @@ const yn = (e, t) => {
|
|
|
1324
1335
|
disabled: t?.disabled ?? !1,
|
|
1325
1336
|
groups: t?.groups ?? []
|
|
1326
1337
|
}));
|
|
1327
|
-
}),
|
|
1338
|
+
}), V(() => {
|
|
1328
1339
|
o && (s.lib.selectableAreaObserver.unobserve(o), s.entities.visibleSelectableAreaSet.delete(o), s.entities.modifiersSelectableAreaSet.delete(o), s.entities.selectableAreaMap.delete(o));
|
|
1329
1340
|
});
|
|
1330
1341
|
const r = y(() => {
|
|
1331
1342
|
s.scrollPosition.x, s.scrollPosition.y;
|
|
1332
1343
|
const a = s.pointer.value;
|
|
1333
|
-
return !a || s.state.value !== "selecting" || !o || !n.value ? {} :
|
|
1344
|
+
return !a || s.state.value !== "selecting" || !o || !n.value ? {} : zt(a.start, a.current, o);
|
|
1334
1345
|
});
|
|
1335
1346
|
return {
|
|
1336
1347
|
isSelecting: n,
|
|
@@ -1338,20 +1349,20 @@ const yn = (e, t) => {
|
|
|
1338
1349
|
};
|
|
1339
1350
|
};
|
|
1340
1351
|
function pn(e, t) {
|
|
1341
|
-
const s =
|
|
1352
|
+
const s = Be(we);
|
|
1342
1353
|
if (!s) throw Error("DnD provider not found");
|
|
1343
1354
|
let n = null;
|
|
1344
|
-
return
|
|
1355
|
+
return U(() => {
|
|
1345
1356
|
n = D(e), n && (n.setAttribute(T.CONSTRAINT_AREA, ""), s.entities.constraintsAreaMap.set(n, {
|
|
1346
1357
|
axis: t?.axis || "both",
|
|
1347
1358
|
restrictToArea: t?.restrictToArea || !1
|
|
1348
1359
|
}));
|
|
1349
|
-
}),
|
|
1360
|
+
}), V(() => {
|
|
1350
1361
|
n && s.entities.constraintsAreaMap.delete(n);
|
|
1351
1362
|
}), {};
|
|
1352
1363
|
}
|
|
1353
1364
|
function Sn(e, t, s) {
|
|
1354
|
-
const n =
|
|
1365
|
+
const n = ie();
|
|
1355
1366
|
let o = null, r, a;
|
|
1356
1367
|
typeof t == "function" ? (r = {}, a = t) : (r = t ?? {}, a = s);
|
|
1357
1368
|
const i = y(() => {
|
|
@@ -1362,7 +1373,7 @@ function Sn(e, t, s) {
|
|
|
1362
1373
|
if (l)
|
|
1363
1374
|
return n.entities.droppableMap.get(l)?.hoveredPlacement;
|
|
1364
1375
|
});
|
|
1365
|
-
return
|
|
1376
|
+
return U(() => {
|
|
1366
1377
|
o = D(e), o && (o.setAttribute(T.DROPPABLE, ""), n.lib.droppableObserver.observe(o), n.entities.droppableMap.set(o, {
|
|
1367
1378
|
disabled: r.disabled ?? !1,
|
|
1368
1379
|
groups: r.groups ?? [],
|
|
@@ -1371,7 +1382,7 @@ function Sn(e, t, s) {
|
|
|
1371
1382
|
data: r.data,
|
|
1372
1383
|
hoveredPlacement: void 0
|
|
1373
1384
|
}));
|
|
1374
|
-
}),
|
|
1385
|
+
}), V(() => {
|
|
1375
1386
|
o && (n.lib.droppableObserver.unobserve(o), n.entities.visibleDroppableSet.delete(o), n.entities.droppableMap.delete(o));
|
|
1376
1387
|
}), {
|
|
1377
1388
|
isAllowed: i,
|
|
@@ -1379,7 +1390,7 @@ function Sn(e, t, s) {
|
|
|
1379
1390
|
};
|
|
1380
1391
|
}
|
|
1381
1392
|
const Dn = (e, t) => {
|
|
1382
|
-
const s =
|
|
1393
|
+
const s = We(), n = te(!1), r = qe(
|
|
1383
1394
|
e,
|
|
1384
1395
|
t ?? {},
|
|
1385
1396
|
() => {
|
|
@@ -1393,14 +1404,14 @@ const Dn = (e, t) => {
|
|
|
1393
1404
|
void 0,
|
|
1394
1405
|
n
|
|
1395
1406
|
);
|
|
1396
|
-
return
|
|
1407
|
+
return re(
|
|
1397
1408
|
() => s.state.value,
|
|
1398
1409
|
(a) => {
|
|
1399
1410
|
a === "dragging" ? r.run() : r.stop();
|
|
1400
1411
|
}
|
|
1401
1412
|
), { isScrolling: n };
|
|
1402
1413
|
};
|
|
1403
|
-
function
|
|
1414
|
+
function Te(e, t) {
|
|
1404
1415
|
return t <= 0 ? e : Math.round(e / t) * t;
|
|
1405
1416
|
}
|
|
1406
1417
|
function Mn(e, t) {
|
|
@@ -1408,30 +1419,30 @@ function Mn(e, t) {
|
|
|
1408
1419
|
return y(() => {
|
|
1409
1420
|
const { x: r, y: a } = e.value;
|
|
1410
1421
|
return {
|
|
1411
|
-
x:
|
|
1412
|
-
y:
|
|
1422
|
+
x: Te(r, n),
|
|
1423
|
+
y: Te(a, o)
|
|
1413
1424
|
};
|
|
1414
1425
|
});
|
|
1415
1426
|
}
|
|
1416
|
-
const
|
|
1427
|
+
const ze = () => !0, Oe = () => 0, fn = "separate", dn = () => {
|
|
1417
1428
|
const e = {
|
|
1418
|
-
filterElements:
|
|
1419
|
-
filterZones:
|
|
1420
|
-
sortElements:
|
|
1421
|
-
sortZones:
|
|
1429
|
+
filterElements: ze,
|
|
1430
|
+
filterZones: ze,
|
|
1431
|
+
sortElements: Oe,
|
|
1432
|
+
sortZones: Oe,
|
|
1422
1433
|
mergeStrategy: fn,
|
|
1423
1434
|
pickClosestBetweenFirst: !1
|
|
1424
1435
|
}, t = (n, o, r, a, i, g, l) => {
|
|
1425
1436
|
const u = a instanceof Set ? a : new Set(a), c = { containerBox: o, pointer: r }, f = e.minOverlapPercent, d = [];
|
|
1426
1437
|
for (const m of u) {
|
|
1427
1438
|
if (!i(m, n)) continue;
|
|
1428
|
-
const h =
|
|
1439
|
+
const h = X(m);
|
|
1429
1440
|
if (!l(h, c)) continue;
|
|
1430
|
-
const S =
|
|
1441
|
+
const S = Q(h, o);
|
|
1431
1442
|
if (f !== void 0 && S < f) continue;
|
|
1432
1443
|
let b = 0;
|
|
1433
1444
|
for (const v of u)
|
|
1434
|
-
v !== m &&
|
|
1445
|
+
v !== m && K(v, m) && b++;
|
|
1435
1446
|
d.push({
|
|
1436
1447
|
node: m,
|
|
1437
1448
|
box: h,
|
|
@@ -1439,9 +1450,9 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1439
1450
|
isPointerInElement: Nt(h, r.x, r.y),
|
|
1440
1451
|
overlapPercent: S,
|
|
1441
1452
|
depth: b,
|
|
1442
|
-
centerDistance:
|
|
1443
|
-
|
|
1444
|
-
|
|
1453
|
+
centerDistance: Zt(
|
|
1454
|
+
Y(o),
|
|
1455
|
+
Y(h)
|
|
1445
1456
|
)
|
|
1446
1457
|
}
|
|
1447
1458
|
});
|
|
@@ -1493,7 +1504,7 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1493
1504
|
return (o) => {
|
|
1494
1505
|
const r = n.container(o);
|
|
1495
1506
|
if (!r) return { elements: [], zones: [] };
|
|
1496
|
-
const a = n.containerBox ? n.containerBox(o) :
|
|
1507
|
+
const a = n.containerBox ? n.containerBox(o) : X(r), i = o.pointer.value?.current ?? { x: 0, y: 0 }, g = t(
|
|
1497
1508
|
o,
|
|
1498
1509
|
a,
|
|
1499
1510
|
i,
|
|
@@ -1527,7 +1538,7 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1527
1538
|
];
|
|
1528
1539
|
if (u.length === 0) return { elements: [], zones: [] };
|
|
1529
1540
|
for (const f of u) {
|
|
1530
|
-
const d =
|
|
1541
|
+
const d = Y(f.box);
|
|
1531
1542
|
f.distance = Math.hypot(
|
|
1532
1543
|
i.x - d.x,
|
|
1533
1544
|
i.y - d.y
|
|
@@ -1539,7 +1550,7 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1539
1550
|
return c.isZone ? { elements: [], zones: [c.node] } : { elements: [c.node], zones: [] };
|
|
1540
1551
|
}
|
|
1541
1552
|
if (n.pickClosestBetweenFirst && g[0] && l[0]) {
|
|
1542
|
-
const u =
|
|
1553
|
+
const u = Y(l[0].box), c = Y(g[0].box), f = Math.hypot(
|
|
1543
1554
|
i.x - u.x,
|
|
1544
1555
|
i.y - u.y
|
|
1545
1556
|
);
|
|
@@ -1560,12 +1571,12 @@ const Pe = () => !0, Te = () => 0, fn = "separate", dn = () => {
|
|
|
1560
1571
|
export {
|
|
1561
1572
|
hn as DnDProvider,
|
|
1562
1573
|
vn as createSensor,
|
|
1563
|
-
|
|
1574
|
+
Me as defaultCollisionDetection,
|
|
1564
1575
|
Dn as makeAutoScroll,
|
|
1565
1576
|
pn as makeConstraintArea,
|
|
1566
1577
|
bn as makeDraggable,
|
|
1567
1578
|
Sn as makeDroppable,
|
|
1568
1579
|
yn as makeSelectionArea,
|
|
1569
1580
|
Mn as makeSnappedOverlayPosition,
|
|
1570
|
-
|
|
1581
|
+
We as useDnDProvider
|
|
1571
1582
|
};
|