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