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