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