marquee-selection 0.0.11 → 0.0.12
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/README.md +2 -1
- package/dist/index.d.ts +3 -0
- package/dist/marquee-selection.es.js +196 -177
- package/dist/marquee-selection.es.js.map +1 -1
- package/dist/marquee-selection.umd.js +1 -1
- package/dist/marquee-selection.umd.js.map +1 -1
- package/index.html +9 -0
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
function ce(jt) {
|
|
2
2
|
const {
|
|
3
|
-
container:
|
|
3
|
+
container: B,
|
|
4
4
|
selectable: at = "img",
|
|
5
5
|
exclude: Q,
|
|
6
6
|
selectionMode: ft = "intersects",
|
|
7
7
|
minOverlapRatio: Vt = 0,
|
|
8
8
|
overlapMetric: Wt = "element",
|
|
9
9
|
selectedClass: Z = "selected",
|
|
10
|
-
onChange:
|
|
10
|
+
onChange: ut,
|
|
11
11
|
preventAncestorSelection: Kt = !0,
|
|
12
12
|
conflictStrategy: _t,
|
|
13
|
-
groupMode:
|
|
13
|
+
groupMode: q = !1,
|
|
14
14
|
groupOverlayClass: Mt,
|
|
15
|
-
groupColor:
|
|
15
|
+
groupColor: pt,
|
|
16
16
|
groupRandomColor: Jt = !1,
|
|
17
17
|
groupColorPalette: tt,
|
|
18
18
|
multi: kt = !1,
|
|
@@ -35,11 +35,11 @@ function ce(jt) {
|
|
|
35
35
|
}
|
|
36
36
|
return !1;
|
|
37
37
|
};
|
|
38
|
-
if (!
|
|
39
|
-
let mt = 0, bt = 0, j = !1,
|
|
38
|
+
if (!B) throw new Error("container is required");
|
|
39
|
+
let mt = 0, bt = 0, j = !1, $ = null, xt = !1, P = /* @__PURE__ */ new Set(), U = null, vt = "replace", a = [], nt = [], I = [], Y = [];
|
|
40
40
|
const Qt = () => `hsl(${Math.floor(Math.random() * 360)}, 70%, 55%)`, wt = () => {
|
|
41
|
-
if (
|
|
42
|
-
return
|
|
41
|
+
if (pt && typeof pt == "string")
|
|
42
|
+
return pt;
|
|
43
43
|
if (Jt) {
|
|
44
44
|
if (Array.isArray(tt) && tt.length > 0) {
|
|
45
45
|
const t = Math.floor(Math.random() * tt.length);
|
|
@@ -87,7 +87,7 @@ function ce(jt) {
|
|
|
87
87
|
const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), o = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), s = Math.max(0, o - c), y = n * s, h = Math.max(1, e.width * e.height);
|
|
88
88
|
return y / h;
|
|
89
89
|
}, ne = (t, e) => {
|
|
90
|
-
const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), o = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), s = Math.max(0, o - c), y = n * s, h = Math.max(1, t.width * t.height),
|
|
90
|
+
const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), o = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), s = Math.max(0, o - c), y = n * s, h = Math.max(1, t.width * t.height), u = Math.max(1, e.width * e.height), d = h + u - y;
|
|
91
91
|
return y / d;
|
|
92
92
|
}, Gt = (t, e) => Wt === "iou" ? ne(t, e) : ee(t, e), Bt = (t, e, r, i) => {
|
|
93
93
|
const c = Math.min(t, r), o = Math.min(e, i), n = Math.abs(r - t), s = Math.abs(i - e);
|
|
@@ -99,8 +99,8 @@ function ce(jt) {
|
|
|
99
99
|
return { left: r, top: i, width: c - r, height: o - i };
|
|
100
100
|
}, K = () => {
|
|
101
101
|
nt.forEach((t) => t.remove()), nt = [];
|
|
102
|
-
},
|
|
103
|
-
if (K(), !
|
|
102
|
+
}, N = () => {
|
|
103
|
+
if (K(), !q) return;
|
|
104
104
|
const t = [], e = (r, i) => r.left < i.right && r.right > i.left && r.top < i.bottom && r.bottom > i.top;
|
|
105
105
|
a.forEach((r, i) => {
|
|
106
106
|
const c = Ct(r);
|
|
@@ -113,22 +113,22 @@ function ce(jt) {
|
|
|
113
113
|
y.textContent = `组 ${i + 1}`;
|
|
114
114
|
const h = document.createElement("button");
|
|
115
115
|
h.textContent = I[i] ? "显示" : "隐藏", h.style.background = "rgba(0,0,0,0.15)", h.style.border = "none", h.style.color = "#fff", h.style.padding = "2px 6px", h.style.borderRadius = "3px", h.style.cursor = "pointer", h.onclick = (b) => {
|
|
116
|
-
b.stopPropagation(), ot(i, !I[i]),
|
|
116
|
+
b.stopPropagation(), ot(i, !I[i]), N(), O();
|
|
117
117
|
};
|
|
118
|
-
const
|
|
119
|
-
|
|
118
|
+
const u = document.createElement("button");
|
|
119
|
+
u.textContent = "取消组", u.style.background = "rgba(0,0,0,0.15)", u.style.border = "none", u.style.color = "#fff", u.style.padding = "2px 6px", u.style.borderRadius = "3px", u.style.cursor = "pointer", u.onclick = (b) => {
|
|
120
120
|
b.stopPropagation(), ot(i, !1), Ft(i);
|
|
121
|
-
}, s.appendChild(y), s.appendChild(h), s.appendChild(
|
|
121
|
+
}, s.appendChild(y), s.appendChild(h), s.appendChild(u);
|
|
122
122
|
const d = (b) => {
|
|
123
123
|
const l = c ? new DOMRect(c.left, c.top, c.width, c.height) : null;
|
|
124
124
|
if (!l) return [];
|
|
125
125
|
const f = [];
|
|
126
|
-
return a.forEach((w,
|
|
127
|
-
if (
|
|
126
|
+
return a.forEach((w, p) => {
|
|
127
|
+
if (p === b) return;
|
|
128
128
|
const v = Ct(w);
|
|
129
129
|
if (!v) return;
|
|
130
130
|
const S = new DOMRect(v.left, v.top, v.width, v.height);
|
|
131
|
-
lt(l, S) && f.push(
|
|
131
|
+
lt(l, S) && f.push(p);
|
|
132
132
|
}), f;
|
|
133
133
|
};
|
|
134
134
|
if ((() => {
|
|
@@ -140,72 +140,91 @@ function ce(jt) {
|
|
|
140
140
|
const f = () => {
|
|
141
141
|
const w = s.querySelector(".merge-panel");
|
|
142
142
|
w && w.remove();
|
|
143
|
-
const
|
|
144
|
-
|
|
143
|
+
const p = document.createElement("div");
|
|
144
|
+
p.className = "merge-panel", p.style.position = "absolute", p.style.left = "0", p.style.top = "22px", p.style.minWidth = "160px", p.style.padding = "8px", p.style.background = "#fff", p.style.color = "#333", p.style.border = "1px solid rgba(0,0,0,0.15)", p.style.borderRadius = "6px", p.style.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", p.style.pointerEvents = "auto", p.style.zIndex = "2147483647";
|
|
145
145
|
const v = document.createElement("div");
|
|
146
|
-
v.textContent = "选择要合并的组", v.style.fontSize = "12px", v.style.marginBottom = "6px",
|
|
146
|
+
v.textContent = "选择要合并的组", v.style.fontSize = "12px", v.style.marginBottom = "6px", p.appendChild(v);
|
|
147
147
|
const S = document.createElement("div");
|
|
148
148
|
S.style.maxHeight = "200px", S.style.overflow = "auto";
|
|
149
|
-
const
|
|
150
|
-
b.forEach((
|
|
149
|
+
const L = [];
|
|
150
|
+
b.forEach((z) => {
|
|
151
151
|
const R = document.createElement("label");
|
|
152
152
|
R.style.display = "flex", R.style.alignItems = "center", R.style.gap = "6px", R.style.fontSize = "12px", R.style.margin = "4px 0";
|
|
153
|
-
const
|
|
154
|
-
|
|
153
|
+
const F = document.createElement("input");
|
|
154
|
+
F.type = "checkbox", F.checked = !0, F.value = String(z);
|
|
155
155
|
const J = document.createElement("span");
|
|
156
|
-
J.textContent = `组 ${
|
|
157
|
-
}),
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
156
|
+
J.textContent = `组 ${z + 1}`, R.appendChild(F), R.appendChild(J), S.appendChild(R), L.push(F);
|
|
157
|
+
}), p.appendChild(S);
|
|
158
|
+
const G = document.createElement("div");
|
|
159
|
+
G.style.display = "flex", G.style.gap = "8px", G.style.marginTop = "8px";
|
|
160
|
+
const E = document.createElement("button");
|
|
161
|
+
E.textContent = "确认", E.style.padding = "2px 8px", E.style.cursor = "pointer";
|
|
162
162
|
const M = document.createElement("button");
|
|
163
|
-
M.textContent = "取消", M.style.padding = "2px 8px", M.style.cursor = "pointer",
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
const R =
|
|
163
|
+
M.textContent = "取消", M.style.padding = "2px 8px", M.style.cursor = "pointer", G.appendChild(E), G.appendChild(M), p.appendChild(G), M.onclick = (z) => {
|
|
164
|
+
z.stopPropagation(), p.remove();
|
|
165
|
+
}, E.onclick = (z) => {
|
|
166
|
+
z.stopPropagation();
|
|
167
|
+
const R = L.filter((C) => C.checked).map((C) => parseInt(C.value, 10)).filter((C) => !Number.isNaN(C));
|
|
168
168
|
if (R.length === 0) {
|
|
169
|
-
|
|
169
|
+
p.remove();
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
(a[i] || []).forEach((
|
|
174
|
-
(a[
|
|
175
|
-
}), a[i] = Array.from(
|
|
176
|
-
const re = [...R].sort((
|
|
172
|
+
const F = /* @__PURE__ */ new Set();
|
|
173
|
+
(a[i] || []).forEach((C) => F.add(C)), R.forEach((C) => {
|
|
174
|
+
(a[C] || []).forEach((ie) => F.add(ie));
|
|
175
|
+
}), a[i] = Array.from(F);
|
|
176
|
+
const re = [...R].sort((C, ct) => ct - C);
|
|
177
177
|
let $t = i;
|
|
178
|
-
re.forEach((
|
|
179
|
-
|
|
178
|
+
re.forEach((C) => {
|
|
179
|
+
C < 0 || C >= a.length || C === i || (ot(C, !1), a.splice(C, 1), I.splice(C, 1), Y.splice(C, 1), k !== null && (k === C ? k = null : k > C && k--), C < $t && $t--);
|
|
180
180
|
}), k = $t;
|
|
181
181
|
const Ut = /* @__PURE__ */ new Set();
|
|
182
|
-
a.forEach((
|
|
183
|
-
}, s.appendChild(
|
|
182
|
+
a.forEach((C) => C.forEach((ct) => Ut.add(ct))), A(Ut), N(), p.remove(), O();
|
|
183
|
+
}, s.appendChild(p);
|
|
184
184
|
};
|
|
185
185
|
l.onclick = (w) => {
|
|
186
186
|
w.stopPropagation(), f();
|
|
187
187
|
}, s.appendChild(l);
|
|
188
188
|
})(), n.appendChild(s), yt && yt.length) {
|
|
189
189
|
const b = (l) => {
|
|
190
|
-
const f = document.createElement("button")
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
190
|
+
const f = document.createElement("button"), w = {
|
|
191
|
+
label: l.label || "按钮",
|
|
192
|
+
title: l.title || ""
|
|
193
|
+
}, p = () => {
|
|
194
|
+
f.textContent = w.label || "", f.title = w.title || "";
|
|
195
|
+
};
|
|
196
|
+
p(), f.style.background = "rgba(0,0,0,0.15)", f.style.border = "none", f.style.color = "#fff", f.style.padding = "2px 6px", f.style.borderRadius = "3px", f.style.cursor = "pointer", l.className && (f.className += (f.className ? " " : "") + l.className), f.onclick = (v) => {
|
|
197
|
+
var G;
|
|
198
|
+
v.stopPropagation();
|
|
199
|
+
const S = {
|
|
200
|
+
index: i,
|
|
201
|
+
group: a[i] || [],
|
|
202
|
+
controller: Nt,
|
|
203
|
+
getSnapshot: () => it(),
|
|
204
|
+
refresh: () => {
|
|
205
|
+
N(), O();
|
|
206
|
+
},
|
|
207
|
+
mouseX: v.clientX,
|
|
208
|
+
mouseY: v.clientY,
|
|
209
|
+
anchorRect: s.getBoundingClientRect(),
|
|
210
|
+
anchorEl: s,
|
|
211
|
+
overlayEl: n,
|
|
212
|
+
label: w.label,
|
|
213
|
+
title: w.title,
|
|
214
|
+
buttonEl: f
|
|
215
|
+
}, L = (E) => {
|
|
216
|
+
Object.defineProperty(S, E, {
|
|
217
|
+
configurable: !0,
|
|
218
|
+
get: () => w[E],
|
|
219
|
+
set: (M) => {
|
|
220
|
+
const z = M ?? "";
|
|
221
|
+
w[E] !== z && (w[E] = z, p());
|
|
222
|
+
}
|
|
208
223
|
});
|
|
224
|
+
};
|
|
225
|
+
L("label"), L("title");
|
|
226
|
+
try {
|
|
227
|
+
(G = l.onClick) == null || G.call(l, S);
|
|
209
228
|
} catch {
|
|
210
229
|
}
|
|
211
230
|
}, s.appendChild(f);
|
|
@@ -221,25 +240,25 @@ function ce(jt) {
|
|
|
221
240
|
], l = s.style.visibility;
|
|
222
241
|
s.style.visibility = "hidden";
|
|
223
242
|
const f = 28, w = 6;
|
|
224
|
-
t: for (let
|
|
243
|
+
t: for (let p = 0; p < b.length; p++)
|
|
225
244
|
for (let v = 0; v < 6; v++) {
|
|
226
245
|
s.style.left = "", s.style.right = "", s.style.top = "", s.style.bottom = "";
|
|
227
246
|
const S = s.offsetHeight || 22;
|
|
228
|
-
b[
|
|
229
|
-
const
|
|
230
|
-
left:
|
|
231
|
-
top:
|
|
232
|
-
right:
|
|
233
|
-
bottom:
|
|
247
|
+
b[p] === "tl" ? (s.style.left = "0", s.style.top = `${-S - w + v * f}px`) : b[p] === "tr" ? (s.style.right = "0", s.style.top = `${-S - w + v * f}px`) : b[p] === "bl" ? (s.style.left = "0", s.style.top = `${c.height + w + v * f}px`) : (s.style.right = "0", s.style.top = `${c.height + w + v * f}px`);
|
|
248
|
+
const L = s.getBoundingClientRect(), G = {
|
|
249
|
+
left: L.left,
|
|
250
|
+
top: L.top,
|
|
251
|
+
right: L.right,
|
|
252
|
+
bottom: L.bottom
|
|
234
253
|
};
|
|
235
|
-
let
|
|
254
|
+
let E = !1;
|
|
236
255
|
for (const M of t)
|
|
237
|
-
if (e(
|
|
238
|
-
|
|
256
|
+
if (e(G, M)) {
|
|
257
|
+
E = !0;
|
|
239
258
|
break;
|
|
240
259
|
}
|
|
241
|
-
if (!
|
|
242
|
-
t.push(
|
|
260
|
+
if (!E) {
|
|
261
|
+
t.push(G);
|
|
243
262
|
break t;
|
|
244
263
|
}
|
|
245
264
|
}
|
|
@@ -256,7 +275,7 @@ function ce(jt) {
|
|
|
256
275
|
const f = 8;
|
|
257
276
|
b === "top" ? (l.style.cursor = "ns-resize", l.style.left = "-4px", l.style.right = "-4px", l.style.top = `-${f / 2 | 0}px`, l.style.height = `${f}px`) : b === "bottom" ? (l.style.cursor = "ns-resize", l.style.left = "-4px", l.style.right = "-4px", l.style.bottom = `-${f / 2 | 0}px`, l.style.height = `${f}px`) : b === "left" ? (l.style.cursor = "ew-resize", l.style.top = "-4px", l.style.bottom = "-4px", l.style.left = `-${f / 2 | 0}px`, l.style.width = `${f}px`) : b === "right" ? (l.style.cursor = "ew-resize", l.style.top = "-4px", l.style.bottom = "-4px", l.style.right = `-${f / 2 | 0}px`, l.style.width = `${f}px`) : b === "nw" ? (l.style.cursor = "nwse-resize", l.style.left = `-${f / 2 | 0}px`, l.style.top = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`) : b === "ne" ? (l.style.cursor = "nesw-resize", l.style.right = `-${f / 2 | 0}px`, l.style.top = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`) : b === "sw" ? (l.style.cursor = "nesw-resize", l.style.left = `-${f / 2 | 0}px`, l.style.bottom = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`) : b === "se" && (l.style.cursor = "nwse-resize", l.style.right = `-${f / 2 | 0}px`, l.style.bottom = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`), l.onmousedown = (w) => {
|
|
258
277
|
w.preventDefault(), w.stopPropagation();
|
|
259
|
-
const
|
|
278
|
+
const p = {
|
|
260
279
|
left: parseFloat(n.style.left || "0"),
|
|
261
280
|
top: parseFloat(n.style.top || "0"),
|
|
262
281
|
width: parseFloat(n.style.width || "0"),
|
|
@@ -267,7 +286,7 @@ function ce(jt) {
|
|
|
267
286
|
side: b,
|
|
268
287
|
startX: w.clientX,
|
|
269
288
|
startY: w.clientY,
|
|
270
|
-
startRect:
|
|
289
|
+
startRect: p,
|
|
271
290
|
overlay: n
|
|
272
291
|
}, document.addEventListener("mousemove", zt), document.addEventListener("mouseup", oe, { once: !0 });
|
|
273
292
|
}, n.appendChild(l);
|
|
@@ -277,58 +296,58 @@ function ce(jt) {
|
|
|
277
296
|
}, zt = (t) => {
|
|
278
297
|
if (!D) return;
|
|
279
298
|
const { idx: e, side: r, startX: i, startY: c, startRect: o, overlay: n } = D, s = t.clientX - i, y = t.clientY - c;
|
|
280
|
-
let h = o.left,
|
|
299
|
+
let h = o.left, u = o.top, d = o.width, g = o.height;
|
|
281
300
|
const m = 4;
|
|
282
|
-
r === "left" || r === "nw" || r === "sw" ? (h = o.left + s, d = o.width - s, d < m && (h = o.left + (o.width - m), d = m)) : (r === "right" || r === "ne" || r === "se") && (d = o.width + s, d < m && (d = m)), r === "top" || r === "nw" || r === "ne" ? (
|
|
283
|
-
const x = _(h,
|
|
284
|
-
a.forEach((
|
|
285
|
-
M !== e &&
|
|
301
|
+
r === "left" || r === "nw" || r === "sw" ? (h = o.left + s, d = o.width - s, d < m && (h = o.left + (o.width - m), d = m)) : (r === "right" || r === "ne" || r === "se") && (d = o.width + s, d < m && (d = m)), r === "top" || r === "nw" || r === "ne" ? (u = o.top + y, g = o.height - y, g < m && (u = o.top + (o.height - m), g = m)) : (r === "bottom" || r === "sw" || r === "se") && (g = o.height + y, g < m && (g = m)), n.style.left = `${h}px`, n.style.top = `${u}px`, n.style.width = `${d}px`, n.style.height = `${g}px`;
|
|
302
|
+
const x = _(h, u, d, g), b = new Set(a[e] || []), l = /* @__PURE__ */ new Set();
|
|
303
|
+
a.forEach((E, M) => {
|
|
304
|
+
M !== e && E.forEach((z) => l.add(z));
|
|
286
305
|
});
|
|
287
306
|
const f = new Set(x);
|
|
288
|
-
let w = !1,
|
|
289
|
-
for (let
|
|
290
|
-
if (
|
|
291
|
-
const M = new Set(a[
|
|
292
|
-
let
|
|
293
|
-
for (const R of f) M.has(R) &&
|
|
294
|
-
if (
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
else if (
|
|
298
|
-
|
|
307
|
+
let w = !1, p = !1;
|
|
308
|
+
for (let E = 0; E < a.length; E++) {
|
|
309
|
+
if (E === e) continue;
|
|
310
|
+
const M = new Set(a[E] || []);
|
|
311
|
+
let z = 0;
|
|
312
|
+
for (const R of f) M.has(R) && z++;
|
|
313
|
+
if (z !== 0 && !(z === M.size && z === f.size))
|
|
314
|
+
if (z === M.size)
|
|
315
|
+
p = !0;
|
|
316
|
+
else if (z === f.size)
|
|
317
|
+
p = !0;
|
|
299
318
|
else {
|
|
300
319
|
w = !0;
|
|
301
320
|
break;
|
|
302
321
|
}
|
|
303
322
|
}
|
|
304
|
-
const v = x.filter((
|
|
305
|
-
if (S ||
|
|
323
|
+
const v = x.filter((E) => !b.has(E)).length, S = !X && (w || !T && p), L = !H && v > 0;
|
|
324
|
+
if (S || L) {
|
|
306
325
|
n.style.outline = "1px dashed #ff4d4f", n.style.background = "rgba(255,77,79,0.06)";
|
|
307
|
-
const
|
|
308
|
-
a.forEach((M,
|
|
309
|
-
(
|
|
310
|
-
}), A(
|
|
326
|
+
const E = /* @__PURE__ */ new Set();
|
|
327
|
+
a.forEach((M, z) => {
|
|
328
|
+
(z === e ? a[e] || [] : M).forEach((F) => E.add(F));
|
|
329
|
+
}), A(E);
|
|
311
330
|
} else {
|
|
312
|
-
const
|
|
313
|
-
n.style.outline = `1px solid ${
|
|
331
|
+
const E = Y[e] || "rgba(255, 165, 0, 0.9)";
|
|
332
|
+
n.style.outline = `1px solid ${E}`, n.style.background = "transparent";
|
|
314
333
|
const M = /* @__PURE__ */ new Set();
|
|
315
|
-
a.forEach((
|
|
316
|
-
(R === e ? x :
|
|
334
|
+
a.forEach((z, R) => {
|
|
335
|
+
(R === e ? x : z).forEach((J) => M.add(J));
|
|
317
336
|
}), A(M);
|
|
318
337
|
}
|
|
319
338
|
}, oe = (t) => {
|
|
320
339
|
if (!D) return;
|
|
321
|
-
const { idx: e, overlay: r, startRect: i } = D, c = parseFloat(r.style.left || "0"), o = parseFloat(r.style.top || "0"), n = parseFloat(r.style.width || "0"), s = parseFloat(r.style.height || "0"), y = _(c, o, n, s), h = new Set(a[e] || []),
|
|
322
|
-
a.forEach((
|
|
323
|
-
v !== e &&
|
|
340
|
+
const { idx: e, overlay: r, startRect: i } = D, c = parseFloat(r.style.left || "0"), o = parseFloat(r.style.top || "0"), n = parseFloat(r.style.width || "0"), s = parseFloat(r.style.height || "0"), y = _(c, o, n, s), h = new Set(a[e] || []), u = /* @__PURE__ */ new Set();
|
|
341
|
+
a.forEach((p, v) => {
|
|
342
|
+
v !== e && p.forEach((S) => u.add(S));
|
|
324
343
|
});
|
|
325
344
|
const d = new Set(y);
|
|
326
345
|
let g = !1, m = !1;
|
|
327
|
-
for (let
|
|
328
|
-
if (
|
|
329
|
-
const v = new Set(a[
|
|
346
|
+
for (let p = 0; p < a.length; p++) {
|
|
347
|
+
if (p === e) continue;
|
|
348
|
+
const v = new Set(a[p] || []);
|
|
330
349
|
let S = 0;
|
|
331
|
-
for (const
|
|
350
|
+
for (const L of d) v.has(L) && S++;
|
|
332
351
|
if (S !== 0 && !(S === v.size && S === d.size))
|
|
333
352
|
if (S === v.size || S === d.size)
|
|
334
353
|
m = !0;
|
|
@@ -337,27 +356,27 @@ function ce(jt) {
|
|
|
337
356
|
break;
|
|
338
357
|
}
|
|
339
358
|
}
|
|
340
|
-
const x = y.filter((
|
|
359
|
+
const x = y.filter((p) => !h.has(p)).length, b = !X && (g || !T && m), l = !H && x > 0;
|
|
341
360
|
if (b || l) {
|
|
342
|
-
const
|
|
343
|
-
a.forEach((v) => v.forEach((S) =>
|
|
361
|
+
const p = /* @__PURE__ */ new Set();
|
|
362
|
+
a.forEach((v) => v.forEach((S) => p.add(S))), A(p), N(), D = null, document.removeEventListener("mousemove", zt), O();
|
|
344
363
|
return;
|
|
345
364
|
}
|
|
346
365
|
a[e] = y;
|
|
347
366
|
const w = /* @__PURE__ */ new Set();
|
|
348
|
-
a.forEach((
|
|
367
|
+
a.forEach((p) => p.forEach((v) => w.add(v))), A(w), N(), D = null, document.removeEventListener("mousemove", zt), O();
|
|
349
368
|
}, Ft = (t) => {
|
|
350
369
|
if (t < 0 || t >= a.length) return !1;
|
|
351
370
|
const e = a[t];
|
|
352
|
-
e && e.forEach((i) => i.style.visibility = ""), a.splice(t, 1), I.splice(t, 1), Y.splice(t, 1), k !== null && (k === t ? k = null : k > t && k--), K(),
|
|
371
|
+
e && e.forEach((i) => i.style.visibility = ""), a.splice(t, 1), I.splice(t, 1), Y.splice(t, 1), k !== null && (k === t ? k = null : k > t && k--), K(), N();
|
|
353
372
|
const r = /* @__PURE__ */ new Set();
|
|
354
|
-
return a.forEach((i) => i.forEach((c) => r.add(c))), A(r),
|
|
373
|
+
return a.forEach((i) => i.forEach((c) => r.add(c))), A(r), O(), !0;
|
|
355
374
|
}, se = (t) => {
|
|
356
|
-
if (!
|
|
357
|
-
const e = Array.from(new Set(t)).filter((
|
|
375
|
+
if (!q || !Array.isArray(t) || t.length === 0) return !1;
|
|
376
|
+
const e = Array.from(new Set(t)).filter((u) => {
|
|
358
377
|
var d;
|
|
359
378
|
try {
|
|
360
|
-
return !!
|
|
379
|
+
return !!u && B.contains(u) && !gt(u) && ((d = u.matches) == null ? void 0 : d.call(u, at));
|
|
361
380
|
} catch {
|
|
362
381
|
return !1;
|
|
363
382
|
}
|
|
@@ -365,8 +384,8 @@ function ce(jt) {
|
|
|
365
384
|
if (e.length === 0 || St(e) !== null) return !1;
|
|
366
385
|
const i = new Set(e);
|
|
367
386
|
let c = !1, o = !1;
|
|
368
|
-
for (const
|
|
369
|
-
const d = new Set(
|
|
387
|
+
for (const u of a) {
|
|
388
|
+
const d = new Set(u);
|
|
370
389
|
let g = 0;
|
|
371
390
|
for (const m of i) d.has(m) && g++;
|
|
372
391
|
if (g !== 0 && !(g === d.size && g === i.size))
|
|
@@ -377,25 +396,25 @@ function ce(jt) {
|
|
|
377
396
|
break;
|
|
378
397
|
}
|
|
379
398
|
}
|
|
380
|
-
const n = new Set(
|
|
399
|
+
const n = new Set(P), s = !X && (c || !T && o), y = !H && n.size > 0 && e.length > 0;
|
|
381
400
|
if (s || y) return !1;
|
|
382
401
|
a.push(e), I.push(!1), Y.push(wt()), k = a.length - 1;
|
|
383
402
|
const h = /* @__PURE__ */ new Set();
|
|
384
|
-
return a.forEach((
|
|
403
|
+
return a.forEach((u) => u.forEach((d) => h.add(d))), A(h), N(), O(), !0;
|
|
385
404
|
}, le = (t) => {
|
|
386
|
-
if (
|
|
405
|
+
if (q) return "add";
|
|
387
406
|
const e = kt ? ht ?? "add" : "replace";
|
|
388
407
|
return kt ? ht === "auto" ? t.shiftKey ? "add" : t.altKey ? "subtract" : t.metaKey || t.ctrlKey ? "toggle" : "add" : ht ?? e : "replace";
|
|
389
408
|
}, A = (t) => {
|
|
390
|
-
for (const e of Array.from(
|
|
409
|
+
for (const e of Array.from(P))
|
|
391
410
|
t.has(e) || e.classList.remove(Z);
|
|
392
411
|
for (const e of Array.from(t))
|
|
393
|
-
|
|
394
|
-
|
|
412
|
+
P.has(e) || e.classList.add(Z);
|
|
413
|
+
P = t, ut && ut(q ? {
|
|
395
414
|
type: "groups",
|
|
396
415
|
groups: a.slice(),
|
|
397
|
-
flat: Array.from(
|
|
398
|
-
} : { type: "single", selected: Array.from(
|
|
416
|
+
flat: Array.from(P)
|
|
417
|
+
} : { type: "single", selected: Array.from(P) });
|
|
399
418
|
}, qt = (t, e, r) => {
|
|
400
419
|
if (r === "replace") return new Set(e);
|
|
401
420
|
const i = new Set(t);
|
|
@@ -410,28 +429,28 @@ function ce(jt) {
|
|
|
410
429
|
}, Pt = (t) => {
|
|
411
430
|
if (t.button !== 0) return;
|
|
412
431
|
const e = t.target;
|
|
413
|
-
!
|
|
432
|
+
!B.contains(e) && e !== document.body || (mt = t.clientX, bt = t.clientY, j = !0, $ = Zt(), vt = le(t), U = new Set(P), t.preventDefault());
|
|
414
433
|
}, Yt = (t) => {
|
|
415
434
|
var g;
|
|
416
435
|
if (!j && et) {
|
|
417
436
|
const m = t.target, x = (g = m == null ? void 0 : m.closest) == null ? void 0 : g.call(m, at);
|
|
418
|
-
x &&
|
|
437
|
+
x && B.contains(x) && !gt(x) ? st(x) : st(null);
|
|
419
438
|
}
|
|
420
|
-
if (!j ||
|
|
439
|
+
if (!j || !$) return;
|
|
421
440
|
const { left: e, top: r, width: i, height: c } = Bt(
|
|
422
441
|
mt,
|
|
423
442
|
bt,
|
|
424
443
|
t.clientX,
|
|
425
444
|
t.clientY
|
|
426
445
|
);
|
|
427
|
-
|
|
446
|
+
$.style.left = `${e}px`, $.style.top = `${r}px`, $.style.width = `${i}px`, $.style.height = `${c}px`;
|
|
428
447
|
const o = _(e, r, i, c), n = U ?? /* @__PURE__ */ new Set(), s = new Set(o);
|
|
429
448
|
let y = 0;
|
|
430
449
|
for (const m of s) n.has(m) && y++;
|
|
431
450
|
let h = "disjoint";
|
|
432
451
|
y === 0 ? h = "disjoint" : y === s.size && y === n.size ? h = "equal" : y === s.size || y === n.size ? h = "containment" : h = "partial";
|
|
433
|
-
const
|
|
434
|
-
if (xt =
|
|
452
|
+
const u = !X && (h === "partial" || !T && h === "containment"), d = !H && n.size > 0 && o.length > 0;
|
|
453
|
+
if (xt = u || d, $ && (xt ? ($.style.outline = "1px dashed #ff4d4f", $.style.background = "rgba(255,77,79,0.12)") : ($.style.outline = "1px dashed #268aff", $.style.background = "rgba(38,138,255,0.12)")), xt)
|
|
435
454
|
A(n);
|
|
436
455
|
else {
|
|
437
456
|
const m = qt(n, o, vt);
|
|
@@ -439,7 +458,7 @@ function ce(jt) {
|
|
|
439
458
|
}
|
|
440
459
|
}, Dt = (t) => {
|
|
441
460
|
if (!j) return;
|
|
442
|
-
j = !1,
|
|
461
|
+
j = !1, $ && $.parentNode && $.parentNode.removeChild($), $ = null;
|
|
443
462
|
const { left: e, top: r, width: i, height: c } = Bt(
|
|
444
463
|
mt,
|
|
445
464
|
bt,
|
|
@@ -450,42 +469,42 @@ function ce(jt) {
|
|
|
450
469
|
for (const x of s) n.has(x) && y++;
|
|
451
470
|
let h = "disjoint";
|
|
452
471
|
y === 0 ? h = "disjoint" : y === s.size && y === n.size ? h = "equal" : y === s.size || y === n.size ? h = "containment" : h = "partial";
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
A(n), U = null,
|
|
472
|
+
const u = !X && (h === "partial" || !T && h === "containment"), d = !H && n.size > 0 && o.length > 0;
|
|
473
|
+
if (u || d) {
|
|
474
|
+
A(n), U = null, O();
|
|
456
475
|
return;
|
|
457
476
|
}
|
|
458
477
|
const m = qt(n, o, vt);
|
|
459
|
-
if (A(m),
|
|
478
|
+
if (A(m), q && o.length > 0) {
|
|
460
479
|
const x = St(o);
|
|
461
480
|
if (x !== null) {
|
|
462
481
|
try {
|
|
463
482
|
console.warn(`重复编组被阻止:与已存在的第${x + 1}组元素完全一致`);
|
|
464
483
|
} catch {
|
|
465
484
|
}
|
|
466
|
-
U = null,
|
|
485
|
+
U = null, O();
|
|
467
486
|
return;
|
|
468
487
|
}
|
|
469
488
|
a.push(o), k = a.length - 1, I.push(!1), Y.push(wt());
|
|
470
489
|
const b = /* @__PURE__ */ new Set();
|
|
471
|
-
a.forEach((l) => l.forEach((f) => b.add(f))), A(b),
|
|
490
|
+
a.forEach((l) => l.forEach((f) => b.add(f))), A(b), N();
|
|
472
491
|
}
|
|
473
|
-
U = null,
|
|
492
|
+
U = null, O();
|
|
474
493
|
}, Xt = (t) => {
|
|
475
494
|
var m;
|
|
476
|
-
if (!dt || !
|
|
495
|
+
if (!dt || !q) return;
|
|
477
496
|
const e = t.target;
|
|
478
497
|
if (!e) return;
|
|
479
498
|
let r = e;
|
|
480
|
-
if (At && (r = ((m = e.closest) == null ? void 0 : m.call(e, At)) || null), !r || !
|
|
481
|
-
const i = r.getBoundingClientRect(), c = _(i.left, i.top, i.width, i.height), o = new Set(
|
|
499
|
+
if (At && (r = ((m = e.closest) == null ? void 0 : m.call(e, At)) || null), !r || !B.contains(r)) return;
|
|
500
|
+
const i = r.getBoundingClientRect(), c = _(i.left, i.top, i.width, i.height), o = new Set(P), n = new Set(c);
|
|
482
501
|
let s = 0;
|
|
483
502
|
for (const x of n) o.has(x) && s++;
|
|
484
503
|
let y = "disjoint";
|
|
485
504
|
s === 0 ? y = "disjoint" : s === n.size && s === o.size ? y = "equal" : s === n.size || s === o.size ? y = "containment" : y = "partial";
|
|
486
|
-
const h = !X && (y === "partial" || !T && y === "containment"),
|
|
487
|
-
if (c.length === 0 || h ||
|
|
488
|
-
|
|
505
|
+
const h = !X && (y === "partial" || !T && y === "containment"), u = !H && o.size > 0 && c.length > 0;
|
|
506
|
+
if (c.length === 0 || h || u) {
|
|
507
|
+
O();
|
|
489
508
|
return;
|
|
490
509
|
}
|
|
491
510
|
const d = St(c);
|
|
@@ -494,23 +513,23 @@ function ce(jt) {
|
|
|
494
513
|
console.warn(`重复编组被阻止:与已存在的第${d + 1}组元素完全一致`);
|
|
495
514
|
} catch {
|
|
496
515
|
}
|
|
497
|
-
|
|
516
|
+
O();
|
|
498
517
|
return;
|
|
499
518
|
}
|
|
500
519
|
a.push(c), k = a.length - 1, I.push(!1), Y.push(wt());
|
|
501
520
|
const g = /* @__PURE__ */ new Set();
|
|
502
|
-
a.forEach((x) => x.forEach((b) => g.add(b))), A(g),
|
|
521
|
+
a.forEach((x) => x.forEach((b) => g.add(b))), A(g), N(), O();
|
|
503
522
|
}, Ht = () => st(null);
|
|
504
523
|
function _(t, e, r, i) {
|
|
505
524
|
if (r === 0 || i === 0) return [];
|
|
506
|
-
const c =
|
|
525
|
+
const c = B.getBoundingClientRect(), o = new DOMRect(t, e, r, i);
|
|
507
526
|
if (!lt(o, c)) return [];
|
|
508
|
-
const n = Array.from(
|
|
527
|
+
const n = Array.from(B.querySelectorAll(at));
|
|
509
528
|
let s = [];
|
|
510
529
|
const y = /* @__PURE__ */ new Map();
|
|
511
|
-
for (const
|
|
512
|
-
if (gt(
|
|
513
|
-
const d =
|
|
530
|
+
for (const u of n) {
|
|
531
|
+
if (gt(u)) continue;
|
|
532
|
+
const d = u.getBoundingClientRect();
|
|
514
533
|
if (!lt(d, c)) continue;
|
|
515
534
|
let g = !1;
|
|
516
535
|
if (ft === "contains")
|
|
@@ -522,22 +541,22 @@ function ce(jt) {
|
|
|
522
541
|
lt(o, d) && (g = Gt(o, d) >= Math.max(0, Math.min(1, Vt)));
|
|
523
542
|
if (g) {
|
|
524
543
|
const m = ft === "contains" ? 1 : Gt(o, d);
|
|
525
|
-
y.set(
|
|
544
|
+
y.set(u, m), s.push(u);
|
|
526
545
|
}
|
|
527
546
|
}
|
|
528
547
|
const h = _t ?? (Kt ? "leaf" : "none");
|
|
529
548
|
if (h !== "none" && s.length > 1) {
|
|
530
549
|
if (h === "leaf")
|
|
531
550
|
s = s.filter(
|
|
532
|
-
(
|
|
533
|
-
(d) => d !==
|
|
551
|
+
(u) => !s.some(
|
|
552
|
+
(d) => d !== u && u.contains(d)
|
|
534
553
|
)
|
|
535
554
|
);
|
|
536
555
|
else if (h === "best") {
|
|
537
|
-
const
|
|
556
|
+
const u = [...s].sort(
|
|
538
557
|
(g, m) => (y.get(m) || 0) - (y.get(g) || 0)
|
|
539
558
|
), d = [];
|
|
540
|
-
for (const g of
|
|
559
|
+
for (const g of u)
|
|
541
560
|
d.find(
|
|
542
561
|
(x) => x.contains(g) || g.contains(x)
|
|
543
562
|
) || d.push(g);
|
|
@@ -546,11 +565,11 @@ function ce(jt) {
|
|
|
546
565
|
}
|
|
547
566
|
return s;
|
|
548
567
|
}
|
|
549
|
-
document.addEventListener("mousedown", Pt, !0), document.addEventListener("mousemove", Yt), document.addEventListener("mouseup", Dt), et &&
|
|
550
|
-
const rt = () =>
|
|
551
|
-
|
|
568
|
+
document.addEventListener("mousedown", Pt, !0), document.addEventListener("mousemove", Yt), document.addEventListener("mouseup", Dt), et && B.addEventListener("mouseleave", Ht), q && dt && B.addEventListener("dblclick", Xt);
|
|
569
|
+
const rt = () => N();
|
|
570
|
+
q && (window.addEventListener("scroll", rt, !0), window.addEventListener("resize", rt));
|
|
552
571
|
const it = () => {
|
|
553
|
-
if (
|
|
572
|
+
if (q) {
|
|
554
573
|
const t = a.map((o) => Ct(o)), e = Array(a.length).fill(null), r = t.map(
|
|
555
574
|
(o) => o ? Math.max(0, o.width * o.height) : Number.POSITIVE_INFINITY
|
|
556
575
|
);
|
|
@@ -560,9 +579,9 @@ function ce(jt) {
|
|
|
560
579
|
let s = null, y = Number.POSITIVE_INFINITY;
|
|
561
580
|
for (let h = 0; h < a.length; h++) {
|
|
562
581
|
if (o === h) continue;
|
|
563
|
-
const
|
|
564
|
-
if (!
|
|
565
|
-
if (
|
|
582
|
+
const u = t[h];
|
|
583
|
+
if (!u) continue;
|
|
584
|
+
if (u.left <= n.left && u.top <= n.top && u.left + u.width >= n.left + n.width && u.top + u.height >= n.top + n.height) {
|
|
566
585
|
const g = Number(r[h]);
|
|
567
586
|
g < y && (y = g, s = h);
|
|
568
587
|
}
|
|
@@ -583,14 +602,14 @@ function ce(jt) {
|
|
|
583
602
|
return {
|
|
584
603
|
type: "groups",
|
|
585
604
|
groups: a.map((o) => o.slice()),
|
|
586
|
-
flat: Array.from(
|
|
605
|
+
flat: Array.from(P),
|
|
587
606
|
hidden: I.slice(),
|
|
588
607
|
groupRects: t,
|
|
589
608
|
groupNesting: { parents: e, children: i, roots: c }
|
|
590
609
|
};
|
|
591
610
|
}
|
|
592
|
-
return { type: "single", selected: Array.from(
|
|
593
|
-
},
|
|
611
|
+
return { type: "single", selected: Array.from(P) };
|
|
612
|
+
}, O = () => {
|
|
594
613
|
const t = it();
|
|
595
614
|
if (It)
|
|
596
615
|
try {
|
|
@@ -610,9 +629,9 @@ function ce(jt) {
|
|
|
610
629
|
}
|
|
611
630
|
}, Tt = {
|
|
612
631
|
destroy() {
|
|
613
|
-
document.removeEventListener("mousedown", Pt), document.removeEventListener("mousemove", Yt), document.removeEventListener("mouseup", Dt),
|
|
632
|
+
document.removeEventListener("mousedown", Pt), document.removeEventListener("mousemove", Yt), document.removeEventListener("mouseup", Dt), $ && $.parentNode && $.parentNode.removeChild($), $ = null, B.querySelectorAll(`.${Z}`).forEach((e) => e.classList.remove(Z)), et && (B.removeEventListener("mouseleave", Ht), st(null)), q && (window.removeEventListener("scroll", rt, !0), window.removeEventListener("resize", rt)), q && dt && B.removeEventListener("dblclick", Xt), K(), a.forEach(
|
|
614
633
|
(e) => e.forEach((r) => r.style.visibility = "")
|
|
615
|
-
), a = [], I = [], Y = [], k = null,
|
|
634
|
+
), a = [], I = [], Y = [], k = null, P.clear(), V.splice(0), Et.splice(0);
|
|
616
635
|
},
|
|
617
636
|
getGroups() {
|
|
618
637
|
return a.slice();
|
|
@@ -632,19 +651,19 @@ function ce(jt) {
|
|
|
632
651
|
return ot(t, e);
|
|
633
652
|
},
|
|
634
653
|
toggleGroupVisibility(t) {
|
|
635
|
-
return t < 0 || t >= a.length ? !1 : (I[t] = !I[t], Ot(t),
|
|
654
|
+
return t < 0 || t >= a.length ? !1 : (I[t] = !I[t], Ot(t), N(), !0);
|
|
636
655
|
},
|
|
637
656
|
getSelectionResult() {
|
|
638
657
|
return it();
|
|
639
658
|
},
|
|
640
659
|
refresh() {
|
|
641
|
-
|
|
660
|
+
N();
|
|
642
661
|
},
|
|
643
662
|
hideOverlays() {
|
|
644
663
|
K();
|
|
645
664
|
},
|
|
646
665
|
showAndRefreshOverlays() {
|
|
647
|
-
|
|
666
|
+
N();
|
|
648
667
|
},
|
|
649
668
|
// 获取当前组级嵌套信息
|
|
650
669
|
getGroupNesting() {
|