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