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