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