@vue-dnd-kit/core 2.1.5 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,80 +1,80 @@
|
|
|
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
|
|
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
8
|
}, G = {
|
|
9
|
-
SELECT_AREA: `[${
|
|
10
|
-
DRAGGABLE: `[${
|
|
11
|
-
CONSTRAINT_AREA: `[${
|
|
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
|
-
const
|
|
14
|
-
return t.forEach((
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
|
|
13
|
+
const i = /* @__PURE__ */ new Set();
|
|
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
|
-
|
|
23
|
-
}),
|
|
22
|
+
c[l]((g) => n.value.has(g)) && i.add(r);
|
|
23
|
+
}), i;
|
|
24
24
|
};
|
|
25
|
-
let
|
|
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 =
|
|
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
|
|
48
|
-
const
|
|
49
|
-
for (const
|
|
50
|
-
const
|
|
51
|
-
|
|
47
|
+
function rt(e, t, n, s) {
|
|
48
|
+
const i = [];
|
|
49
|
+
for (const a of t.keys()) {
|
|
50
|
+
const o = n.get(a);
|
|
51
|
+
i.push({ groups: o?.groups ?? [] });
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
for (const
|
|
55
|
-
const
|
|
56
|
-
(!
|
|
53
|
+
const r = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const a of e) {
|
|
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
|
-
for (const
|
|
63
|
-
const
|
|
64
|
-
for (const
|
|
62
|
+
for (const a of t.keys()) {
|
|
63
|
+
const o = n.get(a);
|
|
64
|
+
for (const c of o?.groups ?? []) s.add(c);
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
for (const
|
|
68
|
-
const
|
|
69
|
-
ne(
|
|
66
|
+
const i = [...s], r = /* @__PURE__ */ new Set();
|
|
67
|
+
for (const a of e) {
|
|
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) => {
|
|
75
75
|
n.forEach((s) => {
|
|
76
|
-
const
|
|
77
|
-
e[s.isIntersecting ? "add" : "delete"](
|
|
76
|
+
const i = s.target;
|
|
77
|
+
e[s.isIntersecting ? "add" : "delete"](i);
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
return {
|
|
@@ -83,18 +83,18 @@ 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 },
|
|
90
90
|
offset: { x: t, y: n }
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function Fe(e, t) {
|
|
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;
|
|
95
|
-
return { x: s, y: a };
|
|
96
|
-
}
|
|
97
93
|
function ze(e, t) {
|
|
94
|
+
const n = t.getBoundingClientRect(), s = n.width > 0 ? (e.clientX - n.left) / n.width : 0.5, i = n.height > 0 ? (e.clientY - n.top) / n.height : 0.5;
|
|
95
|
+
return { x: s, y: i };
|
|
96
|
+
}
|
|
97
|
+
function _e(e, t) {
|
|
98
98
|
return {
|
|
99
99
|
...t,
|
|
100
100
|
initialHTML: e.innerHTML,
|
|
@@ -102,87 +102,87 @@ function ze(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
|
-
const
|
|
108
|
-
n.set(s,
|
|
107
|
+
const i = t.get(s);
|
|
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
|
-
n.set(e,
|
|
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
|
-
const
|
|
130
|
-
return
|
|
129
|
+
const i = e.closest(n);
|
|
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
|
-
x:
|
|
141
|
-
y:
|
|
142
|
-
condition:
|
|
140
|
+
x: i = 0,
|
|
141
|
+
y: r = 0,
|
|
142
|
+
condition: a = "any"
|
|
143
143
|
} = t;
|
|
144
|
-
if (
|
|
145
|
-
const
|
|
146
|
-
return
|
|
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
|
-
const s = n.distance != null,
|
|
151
|
-
return !s && !
|
|
150
|
+
const s = n.distance != null, i = n.delay != null;
|
|
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) {
|
|
169
169
|
n = null;
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const
|
|
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
|
|
186
186
|
) ? (t(), n = null) : n = requestAnimationFrame(s);
|
|
187
187
|
};
|
|
188
188
|
return n = requestAnimationFrame(s), {
|
|
@@ -191,7 +191,7 @@ 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
|
);
|
|
@@ -200,40 +200,40 @@ function mt(e, t) {
|
|
|
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
|
-
Math.min(s.right -
|
|
211
|
-
)), n !== "x" && (
|
|
210
|
+
Math.min(s.right - i.width, e)
|
|
211
|
+
)), n !== "x" && (a = Math.max(
|
|
212
212
|
s.top,
|
|
213
|
-
Math.min(s.bottom -
|
|
214
|
-
)), { x:
|
|
213
|
+
Math.min(s.bottom - i.height, t)
|
|
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
|
|
220
|
-
let
|
|
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:
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
225
|
-
return { x:
|
|
226
|
-
const { element:
|
|
227
|
-
|
|
228
|
-
|
|
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
|
+
a,
|
|
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 =
|
|
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],
|
|
@@ -265,7 +265,7 @@ function yt(e, t) {
|
|
|
265
265
|
},
|
|
266
266
|
step: 8,
|
|
267
267
|
moveFaster: 4
|
|
268
|
-
},
|
|
268
|
+
}, a = $({
|
|
269
269
|
draggableMap: /* @__PURE__ */ new Map(),
|
|
270
270
|
droppableMap: /* @__PURE__ */ new Map(),
|
|
271
271
|
selectableAreaMap: /* @__PURE__ */ new Map(),
|
|
@@ -275,75 +275,75 @@ 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 ?
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
allowedDroppableSet: b(() => n.value ? rt(
|
|
279
|
+
a.visibleDroppableSet,
|
|
280
|
+
a.draggingMap,
|
|
281
|
+
a.draggableMap,
|
|
282
|
+
a.droppableMap
|
|
283
283
|
) : /* @__PURE__ */ new Set()),
|
|
284
|
-
allowedDraggableSet: b(() => n.value ?
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
284
|
+
allowedDraggableSet: b(() => n.value ? lt(
|
|
285
|
+
a.visibleDraggableSet,
|
|
286
|
+
a.draggingMap,
|
|
287
|
+
a.draggableMap
|
|
288
288
|
) : /* @__PURE__ */ new Set()),
|
|
289
289
|
modifiersSelectableAreaSet: b(() => Ie(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
a.selectableAreaMap,
|
|
291
|
+
a.visibleSelectableAreaSet,
|
|
292
|
+
r.keys.pressedKeys
|
|
293
293
|
)),
|
|
294
294
|
modifiersDraggableSet: b(() => Ie(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
(
|
|
295
|
+
a.draggableMap,
|
|
296
|
+
a.visibleDraggableSet,
|
|
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
|
-
}),
|
|
307
|
-
throttle:
|
|
308
|
-
},
|
|
306
|
+
}), c = {
|
|
307
|
+
throttle: V(0)
|
|
308
|
+
}, l = $({
|
|
309
309
|
x: window.scrollX,
|
|
310
310
|
y: window.scrollY
|
|
311
|
-
}), u =
|
|
311
|
+
}), u = $({
|
|
312
312
|
progress: 0,
|
|
313
313
|
startTime: 0
|
|
314
|
-
}),
|
|
315
|
-
if (!s.value || !
|
|
316
|
-
const
|
|
317
|
-
return
|
|
314
|
+
}), g = b(() => {
|
|
315
|
+
if (!s.value || !a.initiatingDraggable) return 0;
|
|
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(
|
|
321
|
-
|
|
321
|
+
a.visibleDroppableSet
|
|
322
322
|
), m = re(
|
|
323
|
-
|
|
324
|
-
), h = oe(), M =
|
|
325
|
-
|
|
326
|
-
const y = M.value,
|
|
327
|
-
return
|
|
323
|
+
a.visibleSelectableAreaSet
|
|
324
|
+
), h = oe(), M = V(new DOMRect()), p = b(() => {
|
|
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
|
-
|
|
331
|
-
|
|
329
|
+
P,
|
|
330
|
+
D || null,
|
|
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
|
-
entities:
|
|
341
|
-
keyboard:
|
|
342
|
-
scrollPosition:
|
|
340
|
+
entities: a,
|
|
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) => {
|
|
@@ -376,62 +376,62 @@ const ee = (e) => {
|
|
|
376
376
|
function St(e) {
|
|
377
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(),
|
|
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
|
-
), s = e.entities.selectableAreaMap.get(t)?.groups ?? [],
|
|
398
|
-
e.entities.visibleDraggableSet.forEach((
|
|
399
|
-
if (
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
e.entities.selectedSet.delete(
|
|
397
|
+
), s = e.entities.selectableAreaMap.get(t)?.groups ?? [], i = e.lib.rectCache;
|
|
398
|
+
e.entities.visibleDraggableSet.forEach((r) => {
|
|
399
|
+
if (r === t || !t.contains(r)) return;
|
|
400
|
+
const a = St(r);
|
|
401
|
+
if (a && a !== t) {
|
|
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),
|
|
421
|
-
return new DOMRect(n, s,
|
|
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));
|
|
425
425
|
return [...e.slice(0, s), ...n, ...e.slice(s)];
|
|
426
426
|
}
|
|
427
427
|
function Le(e, t, n = 1) {
|
|
428
|
-
const s = Math.max(0, Math.min(t, e.length - 1)),
|
|
429
|
-
return [...e.slice(0, s), ...e.slice(s +
|
|
428
|
+
const s = Math.max(0, Math.min(t, e.length - 1)), i = Math.max(0, Math.min(n, e.length - s));
|
|
429
|
+
return [...e.slice(0, s), ...e.slice(s + i)];
|
|
430
430
|
}
|
|
431
|
-
function
|
|
432
|
-
const n = [...new Set(t)].filter((
|
|
431
|
+
function N(e, t) {
|
|
432
|
+
const n = [...new Set(t)].filter((i) => i >= 0 && i < e.length).sort((i, r) => r - i);
|
|
433
433
|
let s = e;
|
|
434
|
-
for (const
|
|
434
|
+
for (const i of n) s = Le(s, i, 1);
|
|
435
435
|
return s;
|
|
436
436
|
}
|
|
437
437
|
function Ne(e, t, n) {
|
|
@@ -440,246 +440,255 @@ 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
|
-
function
|
|
455
|
-
const { draggedItems: n, dropZone: s, hoveredDraggable:
|
|
454
|
+
function Ye(e, t) {
|
|
455
|
+
const { draggedItems: n, dropZone: s, hoveredDraggable: i } = e;
|
|
456
456
|
if (!n.length) return null;
|
|
457
|
-
const
|
|
458
|
-
if (!
|
|
459
|
-
const
|
|
460
|
-
let u,
|
|
461
|
-
if (
|
|
462
|
-
const f =
|
|
457
|
+
const r = i?.placement.center === !0 && s != null && s.items !== i.items, a = r ? s.items : i?.items ?? s?.items;
|
|
458
|
+
if (!a) return null;
|
|
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
|
-
const s =
|
|
484
|
+
const s = Ye(e, t);
|
|
485
485
|
if (!s) return null;
|
|
486
|
-
const { targetArr:
|
|
487
|
-
let { targetIndex:
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
const f = C(
|
|
493
|
-
return { sourceItems: f, targetItems: f, draggedItems:
|
|
486
|
+
const { targetArr: i, mode: r } = s;
|
|
487
|
+
let { targetIndex: a } = s;
|
|
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),
|
|
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 =
|
|
518
|
-
h = C(h, f,
|
|
519
|
-
const M = m >= f ? m +
|
|
520
|
-
return h = C(h, 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
|
+
return h = C(h, M, [a]), { sourceItems: h, targetItems: h, sourceIndexes: s, targetIndex: f, sameList: !0 };
|
|
521
521
|
} else {
|
|
522
|
-
const
|
|
523
|
-
let d =
|
|
524
|
-
d = C(d, f, [
|
|
525
|
-
let m = Le(
|
|
526
|
-
return m = C(m,
|
|
522
|
+
const g = s.filter((h) => h < u).length, f = Math.max(0, u - g);
|
|
523
|
+
let d = N(o, s);
|
|
524
|
+
d = C(d, f, [a]);
|
|
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
|
-
const s =
|
|
533
|
+
const s = Ye(e, t);
|
|
534
534
|
if (!s) return null;
|
|
535
|
-
const { targetArr:
|
|
536
|
-
return { targetItems: C(
|
|
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
|
-
const n = t.map((
|
|
542
|
-
return { sourceItems:
|
|
541
|
+
const n = t.map((a) => a.index), s = t.map((a) => a.item), i = t[0].items;
|
|
542
|
+
return { sourceItems: N(i, n), removedItems: s, sourceIndexes: n };
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function Ve(e) {
|
|
545
545
|
return {
|
|
546
546
|
// Low-level array ops
|
|
547
547
|
insertAt: C,
|
|
548
548
|
removeAt: Le,
|
|
549
|
-
removeIndexes:
|
|
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
|
|
562
|
+
const O = (e) => e.keys().next().value, Lt = (e) => e.target.closest(
|
|
563
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
|
-
const
|
|
572
|
-
if (!Array.isArray(
|
|
573
|
-
const [
|
|
574
|
-
return
|
|
575
|
-
index:
|
|
576
|
-
item:
|
|
577
|
-
items:
|
|
580
|
+
const i = s();
|
|
581
|
+
if (!Array.isArray(i) || i.length < 2) return [];
|
|
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 =
|
|
597
|
-
let s,
|
|
605
|
+
const n = Ct(e);
|
|
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
|
|
609
|
-
if (
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
612
|
-
const f =
|
|
617
|
+
const a = O(e.hovered.draggable);
|
|
618
|
+
if (a && (a === t || t.contains(a)) && a) {
|
|
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
|
-
|
|
616
|
-
element:
|
|
617
|
-
placement: u ??
|
|
624
|
+
i = {
|
|
625
|
+
element: a,
|
|
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
|
|
625
|
-
element:
|
|
626
|
-
placement: u ??
|
|
633
|
+
} else c?.data && (i = {
|
|
634
|
+
element: a,
|
|
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
|
}
|
|
634
643
|
return {
|
|
635
644
|
draggedItems: n,
|
|
636
645
|
dropZone: s,
|
|
637
|
-
hoveredDraggable:
|
|
646
|
+
hoveredDraggable: i,
|
|
638
647
|
provider: e,
|
|
639
|
-
helpers:
|
|
648
|
+
helpers: Ve({ draggedItems: n, dropZone: s, hoveredDraggable: i })
|
|
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
|
-
if (t && !
|
|
661
|
+
if (t && !K(t, e)) {
|
|
653
662
|
const s = A(e, t);
|
|
654
663
|
e.entities.droppableMap.get(t)?.events?.onLeave?.(s);
|
|
655
664
|
}
|
|
656
|
-
if (n && !
|
|
665
|
+
if (n && !K(n, e)) {
|
|
657
666
|
const s = A(e, n);
|
|
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) {
|
|
665
|
-
const
|
|
666
|
-
|
|
674
|
+
const i = e.entities.draggableMap.get(t);
|
|
675
|
+
i && !i.disabled && i.events?.onLeave?.(s);
|
|
667
676
|
}
|
|
668
677
|
if (n) {
|
|
669
|
-
const
|
|
670
|
-
|
|
678
|
+
const i = e.entities.draggableMap.get(n);
|
|
679
|
+
i && !i.disabled && i.events?.onHover?.(s);
|
|
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 =
|
|
678
|
-
n && !
|
|
679
|
-
},
|
|
680
|
-
const n =
|
|
681
|
-
n && !
|
|
682
|
-
},
|
|
685
|
+
}, kt = (e, t) => {
|
|
686
|
+
const n = O(t.droppable);
|
|
687
|
+
n && !K(n, e) && e.entities.droppableMap.get(n)?.events?.onLeave?.(A(e, n));
|
|
688
|
+
}, Se = (e, t) => {
|
|
689
|
+
const n = O(t.droppable);
|
|
690
|
+
n && !K(n, e) && e.entities.droppableMap.get(n)?.events?.onLeave?.(A(e, n));
|
|
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
|
-
},
|
|
694
|
-
const s = e.left + e.width / 2,
|
|
701
|
+
return Tt(n, s, 5);
|
|
702
|
+
}, B = (e, t, n) => {
|
|
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
|
-
top:
|
|
709
|
-
bottom:
|
|
710
|
-
left: s <=
|
|
711
|
-
right: s >
|
|
717
|
+
top: i <= a,
|
|
718
|
+
bottom: i > a,
|
|
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
|
-
function
|
|
725
|
-
|
|
733
|
+
function U(e, t) {
|
|
734
|
+
Ot(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
726
735
|
}
|
|
727
|
-
const
|
|
728
|
-
const s =
|
|
729
|
-
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
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);
|
|
738
|
+
i && t.draggable.delete(i), s && t.droppable.delete(s);
|
|
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
|
-
t.droppable.set(
|
|
735
|
-
const m =
|
|
743
|
+
t.droppable.set(a, d);
|
|
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(
|
|
745
|
-
const m = n.zones.find((h) => h !==
|
|
753
|
+
t.draggable.set(o, d);
|
|
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
|
-
if (
|
|
756
|
-
const
|
|
757
|
-
t.droppable.set(
|
|
764
|
+
if (a) {
|
|
765
|
+
const g = a.getBoundingClientRect();
|
|
766
|
+
t.droppable.set(a, B(r, g));
|
|
758
767
|
}
|
|
759
|
-
if (
|
|
760
|
-
if (
|
|
761
|
-
if (
|
|
762
|
-
const
|
|
768
|
+
if (o)
|
|
769
|
+
if (a)
|
|
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
|
|
787
|
-
if (
|
|
788
|
-
const
|
|
789
|
-
|
|
795
|
+
const l = O(t.droppable), u = O(t.draggable);
|
|
796
|
+
if (i && i !== u) {
|
|
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 _t = (e, t) => e.find((n) => n !== t && K(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
|
-
),
|
|
826
|
-
return
|
|
827
|
-
},
|
|
828
|
-
const t = e.preview.position?.value ?? { x: 0, y: 0 }, { x: n, y: s } = t,
|
|
829
|
-
let
|
|
830
|
-
if (
|
|
831
|
-
|
|
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) => {
|
|
837
|
+
const t = e.preview.position?.value ?? { x: 0, y: 0 }, { x: n, y: s } = t, i = e.preview.size?.value;
|
|
838
|
+
let r, a;
|
|
839
|
+
if (i)
|
|
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:
|
|
840
|
-
height:
|
|
848
|
+
width: r,
|
|
849
|
+
height: a,
|
|
841
850
|
top: s,
|
|
842
851
|
left: n,
|
|
843
|
-
right: n +
|
|
844
|
-
bottom: s +
|
|
852
|
+
right: n + r,
|
|
853
|
+
bottom: s + a
|
|
845
854
|
};
|
|
846
|
-
}, Me = (e) => e.entities.allowedDraggableSet, Ze = (e) => e.entities.allowedDroppableSet,
|
|
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) ? !
|
|
853
|
-
function
|
|
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;
|
|
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),
|
|
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
|
-
).sort((d, m) =>
|
|
889
|
+
).sort((d, m) => _(d.box, n) - _(m.box, n)).map(({ el: d }) => d), zones: s.zones };
|
|
881
890
|
}
|
|
882
|
-
const
|
|
883
|
-
(
|
|
884
|
-
),
|
|
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,76 +912,76 @@ 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
|
-
if (!t ||
|
|
917
|
+
if (!t || K(t, e)) return "accept";
|
|
909
918
|
const n = e.entities.droppableMap.get(t), s = A(e, t);
|
|
910
|
-
let
|
|
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:
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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];
|
|
@@ -983,55 +992,55 @@ const Vt = (e) => {
|
|
|
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 (
|
|
990
|
-
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove",
|
|
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") {
|
|
999
|
+
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", i);
|
|
991
1000
|
return;
|
|
992
1001
|
}
|
|
993
1002
|
return;
|
|
994
|
-
} else
|
|
995
|
-
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove",
|
|
996
|
-
},
|
|
1003
|
+
} else o === "selecting" && Yt(e);
|
|
1004
|
+
ee(e), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove", 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
|
-
|
|
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: (
|
|
1011
|
-
document.addEventListener("pointerup", s), document.addEventListener("pointermove",
|
|
1012
|
-
const
|
|
1019
|
+
return { pointerDown: (o) => {
|
|
1020
|
+
document.addEventListener("pointerup", s), document.addEventListener("pointermove", i);
|
|
1021
|
+
const c = o.composedPath?.()[0] ?? o.target, l = c.closest(
|
|
1013
1022
|
G.SELECT_AREA
|
|
1014
|
-
), u =
|
|
1023
|
+
), u = c.closest(
|
|
1015
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 =
|
|
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
|
-
}, pointerUp: s, pointerMove:
|
|
1032
|
-
t.current?.cancel(), document.removeEventListener("pointerup", s), document.removeEventListener("pointermove",
|
|
1040
|
+
}, pointerUp: s, pointerMove: i, cleanup: () => {
|
|
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 },
|
|
@@ -1044,29 +1053,29 @@ const Vt = (e) => {
|
|
|
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)) {
|
|
1047
|
-
t.preventDefault(), ye(),
|
|
1056
|
+
t.preventDefault(), ye(), F(
|
|
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
|
|
1059
|
-
if (
|
|
1067
|
+
const i = Xt[t.code];
|
|
1068
|
+
if (i && n.forMove.includes(t.code) && e.pointer.value) {
|
|
1060
1069
|
t.preventDefault();
|
|
1061
|
-
const
|
|
1062
|
-
(
|
|
1063
|
-
),
|
|
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
|
-
x: e.pointer.value.current.x +
|
|
1066
|
-
y: e.pointer.value.current.y +
|
|
1074
|
+
x: e.pointer.value.current.x + i.dx * a,
|
|
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"
|
|
@@ -1076,40 +1085,40 @@ const Vt = (e) => {
|
|
|
1076
1085
|
return;
|
|
1077
1086
|
}
|
|
1078
1087
|
if (n.forDrag.includes(t.code)) {
|
|
1079
|
-
const
|
|
1080
|
-
if (!
|
|
1081
|
-
const
|
|
1088
|
+
const i = document.activeElement;
|
|
1089
|
+
if (!i) return;
|
|
1090
|
+
const r = i.closest(
|
|
1082
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
|
|
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),
|
|
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
1118
|
keyDown: Zt,
|
|
1110
|
-
keyUp:
|
|
1111
|
-
clear:
|
|
1112
|
-
},
|
|
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") {
|
|
@@ -1117,10 +1126,10 @@ const Vt = (e) => {
|
|
|
1117
1126
|
return;
|
|
1118
1127
|
}
|
|
1119
1128
|
if (e.state.value === "selecting" && e.pointer.value) {
|
|
1120
|
-
const s = window.scrollX - t,
|
|
1121
|
-
e.pointer.value.start.x -= s, e.pointer.value.start.y -=
|
|
1129
|
+
const s = window.scrollX - t, i = window.scrollY - n;
|
|
1130
|
+
e.pointer.value.start.x -= s, e.pointer.value.start.y -= i, Ke(e);
|
|
1122
1131
|
}
|
|
1123
|
-
}, E = 50,
|
|
1132
|
+
}, E = 50, jt = 144, Te = 1e3 / jt;
|
|
1124
1133
|
function Wt(e) {
|
|
1125
1134
|
return e == null ? {
|
|
1126
1135
|
top: E,
|
|
@@ -1139,7 +1148,7 @@ function Wt(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 jt = {
|
|
|
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
|
|
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 =
|
|
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
|
-
),
|
|
1221
|
-
|
|
1229
|
+
), a = () => {
|
|
1230
|
+
r(), i.stop();
|
|
1222
1231
|
};
|
|
1223
|
-
return We(
|
|
1232
|
+
return We(a), { isScrolling: n, stop: a };
|
|
1224
1233
|
}
|
|
1225
|
-
const
|
|
1226
|
-
const t = Vt(e), n = de.keyDown(e), s = de.keyUp(e),
|
|
1227
|
-
let
|
|
1234
|
+
const nn = (e) => {
|
|
1235
|
+
const t = Vt(e), n = de.keyDown(e), s = de.keyUp(e), i = de.clear(e), r = qt(e);
|
|
1236
|
+
let a = null;
|
|
1228
1237
|
te(
|
|
1229
1238
|
e.autoScrollViewport,
|
|
1230
|
-
(
|
|
1231
|
-
|
|
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",
|
|
1239
|
-
}),
|
|
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",
|
|
1247
|
+
document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", n), document.addEventListener("keyup", s), document.addEventListener("blur", i), document.addEventListener("scroll", r, !0);
|
|
1248
|
+
}), Z(() => {
|
|
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,42 +1267,50 @@ const tn = (e) => {
|
|
|
1258
1267
|
collision: e.collision,
|
|
1259
1268
|
autoScrollViewport: e.autoScrollViewport
|
|
1260
1269
|
};
|
|
1261
|
-
},
|
|
1270
|
+
}, sn = /* @__PURE__ */ Be({
|
|
1262
1271
|
__name: "DragPreview",
|
|
1272
|
+
props: {
|
|
1273
|
+
grid: {}
|
|
1274
|
+
},
|
|
1263
1275
|
setup(e) {
|
|
1264
|
-
const { state: t, entities: n, preview: s } =
|
|
1265
|
-
|
|
1266
|
-
() =>
|
|
1276
|
+
const { state: t, entities: n, preview: s } = je(), i = Oe("contentRef");
|
|
1277
|
+
te(
|
|
1278
|
+
() => i.value,
|
|
1267
1279
|
() => {
|
|
1268
|
-
const o =
|
|
1280
|
+
const o = i.value?.getBoundingClientRect();
|
|
1269
1281
|
o && (s.size.value = o);
|
|
1270
1282
|
}
|
|
1271
|
-
)
|
|
1283
|
+
);
|
|
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) };
|
|
1287
|
+
});
|
|
1288
|
+
return (o, c) => q(t) === "dragging" ? (L(), j("div", {
|
|
1272
1289
|
key: 0,
|
|
1273
1290
|
class: "dnd-kit-preview",
|
|
1274
1291
|
ref_key: "contentRef",
|
|
1275
|
-
ref:
|
|
1292
|
+
ref: i,
|
|
1276
1293
|
style: Ce({
|
|
1277
|
-
transform: `translate3d(${
|
|
1294
|
+
transform: `translate3d(${a.value.x}px, ${a.value.y}px, 0)`
|
|
1278
1295
|
})
|
|
1279
1296
|
}, [
|
|
1280
1297
|
me(o.$slots, "default", {
|
|
1281
|
-
draggingMap:
|
|
1298
|
+
draggingMap: q(n).draggingMap
|
|
1282
1299
|
}, () => [
|
|
1283
|
-
(L(!0),
|
|
1284
|
-
|
|
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), {
|
|
1285
1302
|
key: 1,
|
|
1286
|
-
innerHTML:
|
|
1303
|
+
innerHTML: u.initialOuterHTML,
|
|
1287
1304
|
style: Ce({
|
|
1288
|
-
width:
|
|
1289
|
-
height:
|
|
1305
|
+
width: u.initialRect.width + "px",
|
|
1306
|
+
height: u.initialRect.height + "px"
|
|
1290
1307
|
})
|
|
1291
1308
|
}, null, 8, ["innerHTML", "style"]))
|
|
1292
1309
|
], 64))), 128))
|
|
1293
1310
|
])
|
|
1294
|
-
], 4)) :
|
|
1311
|
+
], 4)) : Qe("", !0);
|
|
1295
1312
|
}
|
|
1296
|
-
}),
|
|
1313
|
+
}), on = /* @__PURE__ */ Be({
|
|
1297
1314
|
__name: "DnDProvider",
|
|
1298
1315
|
props: {
|
|
1299
1316
|
autoScrollViewport: { type: [Object, Boolean, null] },
|
|
@@ -1302,79 +1319,86 @@ const tn = (e) => {
|
|
|
1302
1319
|
class: {}
|
|
1303
1320
|
},
|
|
1304
1321
|
setup(e) {
|
|
1305
|
-
const t = e, n =
|
|
1306
|
-
|
|
1307
|
-
const
|
|
1308
|
-
return
|
|
1309
|
-
me(
|
|
1310
|
-
(L(), J(
|
|
1311
|
-
to:
|
|
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, {
|
|
1328
|
+
to: q(s).preview.to.value || "body"
|
|
1312
1329
|
}, [
|
|
1313
|
-
|
|
1330
|
+
nt("div", st({
|
|
1314
1331
|
ref_key: "previewRef",
|
|
1315
1332
|
ref: n,
|
|
1316
1333
|
class: "dnd-kit-preview-container"
|
|
1317
1334
|
}, t), [
|
|
1318
|
-
me(
|
|
1319
|
-
(L(), J(be(
|
|
1335
|
+
me(r.$slots, "preview", { preview: i.value }, () => [
|
|
1336
|
+
(L(), J(be(i.value)))
|
|
1320
1337
|
])
|
|
1321
1338
|
], 16)
|
|
1322
1339
|
], 8, ["to"]))
|
|
1323
1340
|
], 64));
|
|
1324
1341
|
}
|
|
1325
1342
|
});
|
|
1326
|
-
function
|
|
1343
|
+
function rn(e, t, n) {
|
|
1327
1344
|
const s = se();
|
|
1328
|
-
let
|
|
1329
|
-
typeof t == "function" ? (
|
|
1330
|
-
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({
|
|
1331
1348
|
get() {
|
|
1332
|
-
const
|
|
1333
|
-
return
|
|
1349
|
+
const f = S(e);
|
|
1350
|
+
return f ? s.entities.selectedSet.has(f) : !1;
|
|
1334
1351
|
},
|
|
1335
|
-
set(
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1352
|
+
set(f) {
|
|
1353
|
+
const d = S(e);
|
|
1354
|
+
d && s.entities.selectedSet[f ? "add" : "delete"](d);
|
|
1338
1355
|
}
|
|
1339
|
-
}),
|
|
1340
|
-
const
|
|
1341
|
-
return
|
|
1342
|
-
}), c = b(() => {
|
|
1343
|
-
const l = D(e);
|
|
1344
|
-
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;
|
|
1345
1359
|
}), u = b(() => {
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
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;
|
|
1349
1366
|
});
|
|
1350
1367
|
return X(() => {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
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,
|
|
1370
|
+
render: i.render,
|
|
1371
|
+
disabled: i.disabled ?? !1,
|
|
1372
|
+
groups: i.groups ?? [],
|
|
1373
|
+
modifier: i.modifier,
|
|
1374
|
+
events: i.events,
|
|
1375
|
+
payload: r,
|
|
1376
|
+
data: i.data,
|
|
1377
|
+
dragHandle: i.dragHandle,
|
|
1378
|
+
activation: i.activation,
|
|
1379
|
+
placementMargins: i.placementMargins,
|
|
1362
1380
|
hoveredPlacement: void 0
|
|
1363
|
-
}))
|
|
1364
|
-
|
|
1365
|
-
|
|
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
|
+
}
|
|
1388
|
+
}), Z(() => {
|
|
1389
|
+
a && (s.lib.draggableObserver.unobserve(a), s.entities.visibleDraggableSet.delete(a), s.entities.draggableMap.delete(a), s.entities.modifiersDraggableSet.delete(a));
|
|
1366
1390
|
}), {
|
|
1367
|
-
selected:
|
|
1368
|
-
isDragging:
|
|
1369
|
-
isAllowed:
|
|
1370
|
-
isDragOver:
|
|
1391
|
+
selected: c,
|
|
1392
|
+
isDragging: l,
|
|
1393
|
+
isAllowed: u,
|
|
1394
|
+
isDragOver: g
|
|
1371
1395
|
};
|
|
1372
1396
|
}
|
|
1373
|
-
const
|
|
1397
|
+
const ln = (e, t) => {
|
|
1374
1398
|
const n = se(), s = b(() => e.value === n.entities.selectingArea);
|
|
1375
|
-
let
|
|
1399
|
+
let i = null;
|
|
1376
1400
|
X(() => {
|
|
1377
|
-
|
|
1401
|
+
i = S(e), i && (i.setAttribute(I.SELECT_AREA, ""), n.lib.selectableAreaObserver.observe(i), n.entities.selectableAreaMap.set(i, {
|
|
1378
1402
|
modifier: t?.modifier ?? {
|
|
1379
1403
|
keys: ["ControlLeft"],
|
|
1380
1404
|
method: "every"
|
|
@@ -1383,90 +1407,90 @@ const rn = (e, t) => {
|
|
|
1383
1407
|
disabled: t?.disabled ?? !1,
|
|
1384
1408
|
groups: t?.groups ?? []
|
|
1385
1409
|
}));
|
|
1386
|
-
}),
|
|
1387
|
-
|
|
1410
|
+
}), Z(() => {
|
|
1411
|
+
i && (n.lib.selectableAreaObserver.unobserve(i), n.entities.visibleSelectableAreaSet.delete(i), n.entities.modifiersSelectableAreaSet.delete(i), n.entities.selectableAreaMap.delete(i));
|
|
1388
1412
|
});
|
|
1389
|
-
const
|
|
1413
|
+
const r = b(() => {
|
|
1390
1414
|
n.scrollPosition.x, n.scrollPosition.y;
|
|
1391
|
-
const
|
|
1392
|
-
return !
|
|
1415
|
+
const a = n.pointer.value;
|
|
1416
|
+
return !a || n.state.value !== "selecting" || !i || !s.value ? {} : wt(a.start, a.current, i);
|
|
1393
1417
|
});
|
|
1394
1418
|
return {
|
|
1395
1419
|
isSelecting: s,
|
|
1396
|
-
style:
|
|
1420
|
+
style: r
|
|
1397
1421
|
};
|
|
1398
1422
|
};
|
|
1399
|
-
function
|
|
1423
|
+
function cn(e, t) {
|
|
1400
1424
|
const n = Pe(xe);
|
|
1401
1425
|
if (!n) throw Error("DnD provider not found");
|
|
1402
1426
|
let s = null;
|
|
1403
1427
|
return X(() => {
|
|
1404
|
-
s =
|
|
1428
|
+
s = S(e), s && (s.setAttribute(I.CONSTRAINT_AREA, ""), n.entities.constraintsAreaMap.set(s, {
|
|
1405
1429
|
axis: t?.axis || "both",
|
|
1406
1430
|
restrictToArea: t?.restrictToArea || !1
|
|
1407
1431
|
}));
|
|
1408
|
-
}),
|
|
1432
|
+
}), Z(() => {
|
|
1409
1433
|
s && n.entities.constraintsAreaMap.delete(s);
|
|
1410
1434
|
}), {};
|
|
1411
1435
|
}
|
|
1412
|
-
function
|
|
1436
|
+
function gn(e, t, n) {
|
|
1413
1437
|
const s = se();
|
|
1414
|
-
let
|
|
1415
|
-
typeof t == "function" ? (
|
|
1416
|
-
const
|
|
1417
|
-
const
|
|
1418
|
-
return
|
|
1419
|
-
}),
|
|
1420
|
-
const
|
|
1421
|
-
if (
|
|
1422
|
-
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;
|
|
1423
1447
|
});
|
|
1424
1448
|
return X(() => {
|
|
1425
|
-
|
|
1426
|
-
disabled:
|
|
1427
|
-
groups:
|
|
1428
|
-
groupMatch:
|
|
1429
|
-
events:
|
|
1430
|
-
payload:
|
|
1431
|
-
data:
|
|
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,
|
|
1454
|
+
payload: a,
|
|
1455
|
+
data: r.data,
|
|
1432
1456
|
hoveredPlacement: void 0
|
|
1433
1457
|
}));
|
|
1434
|
-
}),
|
|
1435
|
-
|
|
1458
|
+
}), Z(() => {
|
|
1459
|
+
i && (s.lib.droppableObserver.unobserve(i), s.entities.visibleDroppableSet.delete(i), s.entities.droppableMap.delete(i));
|
|
1436
1460
|
}), {
|
|
1437
|
-
isAllowed:
|
|
1438
|
-
isDragOver:
|
|
1461
|
+
isAllowed: o,
|
|
1462
|
+
isDragOver: c
|
|
1439
1463
|
};
|
|
1440
1464
|
}
|
|
1441
|
-
const
|
|
1442
|
-
const n =
|
|
1465
|
+
const un = (e, t) => {
|
|
1466
|
+
const n = je(), s = V(!1), r = qe(
|
|
1443
1467
|
e,
|
|
1444
1468
|
t ?? {},
|
|
1445
1469
|
() => {
|
|
1446
1470
|
if (n.state.value !== "dragging") return null;
|
|
1447
|
-
const
|
|
1448
|
-
return
|
|
1449
|
-
x:
|
|
1450
|
-
y:
|
|
1451
|
-
} :
|
|
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
|
|
1475
|
+
} : a : null;
|
|
1452
1476
|
},
|
|
1453
1477
|
void 0,
|
|
1454
1478
|
s
|
|
1455
1479
|
);
|
|
1456
1480
|
return te(
|
|
1457
1481
|
() => n.state.value,
|
|
1458
|
-
(
|
|
1459
|
-
|
|
1482
|
+
(a) => {
|
|
1483
|
+
a === "dragging" ? r.run() : r.stop();
|
|
1460
1484
|
}
|
|
1461
1485
|
), { isScrolling: s };
|
|
1462
1486
|
};
|
|
1463
1487
|
export {
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1488
|
+
on as DnDProvider,
|
|
1489
|
+
sn as DragPreview,
|
|
1490
|
+
un as makeAutoScroll,
|
|
1491
|
+
cn as makeConstraintArea,
|
|
1492
|
+
rn as makeDraggable,
|
|
1493
|
+
gn as makeDroppable,
|
|
1494
|
+
ln as makeSelectionArea,
|
|
1495
|
+
je as useDnDProvider
|
|
1472
1496
|
};
|