@salilvnair/dui 1.0.2 → 1.0.4
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/index.js +1235 -1254
- package/dist/index.js.map +1 -1
- package/dist/lib/components/input/HighlightedInputView.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/vis-setup.js +323 -240
- package/dist/vis-setup.js.map +1 -1
- package/package.json +1 -1
package/dist/vis-setup.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { m as
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { DataSet as
|
|
5
|
-
import { Network as
|
|
6
|
-
const
|
|
1
|
+
import { m as Xt, r as Yt } from "./chunks/vis-runtime-DkpA8K_T.js";
|
|
2
|
+
import { jsxs as Ut, jsx as Mt } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as M, useEffect as Et } from "react";
|
|
4
|
+
import { DataSet as Rt } from "vis-data/peer";
|
|
5
|
+
import { Network as Kt } from "vis-network/peer";
|
|
6
|
+
const ut = [
|
|
7
7
|
"#4E79A7",
|
|
8
8
|
"#F28E2B",
|
|
9
9
|
"#E15759",
|
|
@@ -14,7 +14,7 @@ const ot = [
|
|
|
14
14
|
"#FF9DA7",
|
|
15
15
|
"#9C755F",
|
|
16
16
|
"#BAB0AC"
|
|
17
|
-
],
|
|
17
|
+
], at = 0.12, Vt = 300, Zt = 0.45, Tt = 220, qt = 120, lt = 96, kt = {
|
|
18
18
|
dark: {
|
|
19
19
|
text: "#d4d4d4",
|
|
20
20
|
chipBg: "rgba(37, 37, 38, 0.85)",
|
|
@@ -32,112 +32,153 @@ const ot = [
|
|
|
32
32
|
viewportStroke: "#1f2328"
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
function
|
|
36
|
-
return
|
|
35
|
+
function Wt(e) {
|
|
36
|
+
return e.color ? e.color : e.communityId != null ? ut[e.communityId % ut.length] : "#6B7280";
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const Jt = (e, s) => e.left < s.right && e.right > s.left && e.top < s.bottom && e.bottom > s.top;
|
|
39
|
+
function Qt() {
|
|
40
|
+
const e = /* @__PURE__ */ new Map(), s = (i, c) => i * 73856093 ^ c * 19349663, f = (i, c) => {
|
|
41
|
+
const m = Math.floor(i.left / lt), C = Math.floor(i.right / lt), O = Math.floor(i.top / lt), K = Math.floor(i.bottom / lt);
|
|
42
|
+
for (let N = m; N <= C; N++) for (let x = O; x <= K; x++) c(s(N, x));
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
collides(i) {
|
|
46
|
+
let c = !1;
|
|
47
|
+
return f(i, (m) => {
|
|
48
|
+
if (c) return;
|
|
49
|
+
const C = e.get(m);
|
|
50
|
+
if (C) {
|
|
51
|
+
for (let O = 0; O < C.length; O++) if (Jt(i, C[O])) {
|
|
52
|
+
c = !0;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}), c;
|
|
57
|
+
},
|
|
58
|
+
insert(i) {
|
|
59
|
+
f(i, (c) => {
|
|
60
|
+
const m = e.get(c);
|
|
61
|
+
m ? m.push(i) : e.set(c, [i]);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function te(e) {
|
|
67
|
+
const s = document.createElement("div");
|
|
68
|
+
return s.style.position = "absolute", s.style.borderRadius = "9999px", s.style.letterSpacing = "0.01em", s.style.whiteSpace = "nowrap", s.style.pointerEvents = "none", s.style.display = "none", e == null || e.appendChild(s), s;
|
|
41
69
|
}
|
|
42
|
-
function
|
|
70
|
+
function _t(e, s, f) {
|
|
71
|
+
e.textContent !== s && (e.textContent = s), e.style.padding !== f.padding && (e.style.padding = f.padding);
|
|
72
|
+
const i = `${f.fontSize}px`;
|
|
73
|
+
e.style.fontSize !== i && (e.style.fontSize = i);
|
|
74
|
+
const c = String(f.fontWeight);
|
|
75
|
+
e.style.fontWeight !== c && (e.style.fontWeight = c), e.style.background !== f.bg && (e.style.background = f.bg);
|
|
76
|
+
const m = `1px solid ${f.border}`;
|
|
77
|
+
e.style.border !== m && (e.style.border = m), e.style.color !== f.color && (e.style.color = f.color);
|
|
78
|
+
}
|
|
79
|
+
function ee(e) {
|
|
43
80
|
return {
|
|
44
|
-
color:
|
|
45
|
-
bg: `color-mix(in srgb, ${
|
|
46
|
-
border: `color-mix(in srgb, ${
|
|
81
|
+
color: e,
|
|
82
|
+
bg: `color-mix(in srgb, ${e} 16%, transparent)`,
|
|
83
|
+
border: `color-mix(in srgb, ${e} 40%, transparent)`,
|
|
47
84
|
fontSize: 12,
|
|
48
85
|
fontWeight: 600,
|
|
49
86
|
padding: "3px 9px"
|
|
50
87
|
};
|
|
51
88
|
}
|
|
52
|
-
function
|
|
89
|
+
function ne(e) {
|
|
53
90
|
return {
|
|
54
|
-
color:
|
|
55
|
-
bg:
|
|
56
|
-
border:
|
|
91
|
+
color: e.text,
|
|
92
|
+
bg: e.chipBg,
|
|
93
|
+
border: e.chipBorder,
|
|
57
94
|
fontSize: 10,
|
|
58
95
|
fontWeight: 500,
|
|
59
96
|
padding: "2px 7px"
|
|
60
97
|
};
|
|
61
98
|
}
|
|
62
|
-
function
|
|
63
|
-
const i = new Set(
|
|
99
|
+
function $t(e, s, f) {
|
|
100
|
+
const i = new Set(f.filter((x) => x.communityId === s).map((x) => x.id));
|
|
64
101
|
if (i.size < 2) return;
|
|
65
|
-
for (const
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
joinCondition: (
|
|
102
|
+
for (const x of i)
|
|
103
|
+
if (!e.findNode(x).length || e.isCluster(x)) return;
|
|
104
|
+
const c = ut[s % ut.length], m = `cluster:community:${s}`, C = `Community ${s} (${i.size})`, O = Math.min(20 + i.size * 2, 60), K = Math.max(11, Math.min(16, Math.round(O * 0.32))), N = -(O + K * 0.5);
|
|
105
|
+
e.cluster({
|
|
106
|
+
joinCondition: (x) => i.has(x.id),
|
|
70
107
|
// vis-network genuinely accepts `id` in clusterNodeProperties at runtime
|
|
71
108
|
// (it's how you address the cluster later via openCluster/isCluster) —
|
|
72
109
|
// the shipped .d.ts's NodeOptions type just doesn't declare it.
|
|
73
110
|
clusterNodeProperties: {
|
|
74
|
-
id:
|
|
111
|
+
id: m,
|
|
75
112
|
// Member count only — the full name is tooltip + legend-panel only
|
|
76
113
|
// (see the doc comment above). Not empty string: vis-network defaults
|
|
77
114
|
// `label` to the literal "cluster" when it's `undefined`, which would
|
|
78
115
|
// otherwise draw a stray caption under every collapsed community.
|
|
79
116
|
label: String(i.size),
|
|
80
|
-
font: { color: "#ffffff", size:
|
|
81
|
-
title:
|
|
117
|
+
font: { color: "#ffffff", size: K, vadjust: N },
|
|
118
|
+
title: C,
|
|
82
119
|
shape: "dot",
|
|
83
120
|
// Larger + white-ringed so a collapsed community reads as a distinct
|
|
84
121
|
// "group" at a glance, not just another same-sized leaf node.
|
|
85
|
-
size:
|
|
122
|
+
size: O,
|
|
86
123
|
borderWidth: 3,
|
|
87
|
-
color: { background:
|
|
124
|
+
color: { background: c, border: "#ffffff", highlight: { background: c, border: "#ffffff" } },
|
|
88
125
|
// Soft colored glow (a hint of the community's own color) instead of a
|
|
89
126
|
// flat plain circle — same "elevated card" depth language dui's own
|
|
90
127
|
// panels use, just expressed on canvas.
|
|
91
|
-
shadow: { enabled: !0, color: `${
|
|
128
|
+
shadow: { enabled: !0, color: `${c}66`, size: 16, x: 0, y: 4 }
|
|
92
129
|
}
|
|
93
130
|
});
|
|
94
131
|
}
|
|
95
|
-
function
|
|
96
|
-
nodes:
|
|
97
|
-
edges:
|
|
98
|
-
onNodeClick:
|
|
132
|
+
function oe({
|
|
133
|
+
nodes: e,
|
|
134
|
+
edges: s,
|
|
135
|
+
onNodeClick: f,
|
|
99
136
|
selectedId: i,
|
|
100
|
-
fitTrigger:
|
|
101
|
-
onReady:
|
|
102
|
-
colorBy:
|
|
103
|
-
sizeBy:
|
|
104
|
-
className:
|
|
105
|
-
style:
|
|
106
|
-
enableClustering:
|
|
107
|
-
enableHoverDim:
|
|
108
|
-
enableMinimap:
|
|
109
|
-
theme:
|
|
137
|
+
fitTrigger: c,
|
|
138
|
+
onReady: m,
|
|
139
|
+
colorBy: C,
|
|
140
|
+
sizeBy: O,
|
|
141
|
+
className: K = "",
|
|
142
|
+
style: N,
|
|
143
|
+
enableClustering: x = !1,
|
|
144
|
+
enableHoverDim: St = !1,
|
|
145
|
+
enableMinimap: q = !1,
|
|
146
|
+
theme: ft = "dark"
|
|
110
147
|
}) {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
if (!
|
|
116
|
-
let
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
}),
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
const
|
|
148
|
+
const V = M(null), dt = M(null), j = M(null), Dt = M(null), Bt = M(null), Z = M(/* @__PURE__ */ new Map()), Ct = M(/* @__PURE__ */ new Map()), Ot = M(/* @__PURE__ */ new Map()), zt = M(null), pt = M([]), ht = M([]), gt = M(/* @__PURE__ */ new Map()), k = M(i);
|
|
149
|
+
k.current = i;
|
|
150
|
+
const X = M(!1);
|
|
151
|
+
Et(() => {
|
|
152
|
+
if (!V.current) return;
|
|
153
|
+
let u = null;
|
|
154
|
+
Z.current = new Map(e.map((t) => [t.id, t]));
|
|
155
|
+
const w = {}, y = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map();
|
|
156
|
+
s.forEach((t, n) => {
|
|
157
|
+
w[t.source] = (w[t.source] ?? 0) + 1, w[t.target] = (w[t.target] ?? 0) + 1, y.has(t.source) || y.set(t.source, /* @__PURE__ */ new Set()), y.has(t.target) || y.set(t.target, /* @__PURE__ */ new Set()), y.get(t.source).add(t.target), y.get(t.target).add(t.source);
|
|
158
|
+
const r = t.id ?? n;
|
|
159
|
+
z.has(t.source) || z.set(t.source, /* @__PURE__ */ new Set()), z.has(t.target) || z.set(t.target, /* @__PURE__ */ new Set()), z.get(t.source).add(r), z.get(t.target).add(r);
|
|
160
|
+
}), Ct.current = y, Ot.current = z;
|
|
161
|
+
const L = Math.max(1, ...Object.values(w)), R = kt[ft], J = /* @__PURE__ */ new Map(), bt = e.map((t) => {
|
|
162
|
+
const n = C ? C(t) : Wt(t);
|
|
163
|
+
J.set(t.id, n);
|
|
164
|
+
const r = w[t.id] ?? 1, a = O ? O(t, r, L) : 10 + 30 * (r / L);
|
|
128
165
|
return {
|
|
129
166
|
id: t.id,
|
|
130
167
|
title: t.label,
|
|
168
|
+
// No `label` here on purpose: every label is a pooled DOM chip
|
|
169
|
+
// positioned by syncAllChipPositions. Collapsed community nodes are
|
|
170
|
+
// the one exception and set their own label natively — see
|
|
171
|
+
// clusterCommunity.
|
|
131
172
|
// Selection keeps the node's own fill and flags it with a themed
|
|
132
173
|
// border instead — the old highlight swapped the fill to the theme
|
|
133
174
|
// text color, which read as a jarring near-black circle in light
|
|
134
175
|
// mode (and near-white in dark).
|
|
135
|
-
color: { background:
|
|
176
|
+
color: { background: n, border: n, highlight: { background: n, border: R.text } },
|
|
136
177
|
size: Math.round(a * 10) / 10,
|
|
137
178
|
shape: "dot"
|
|
138
179
|
};
|
|
139
|
-
}),
|
|
140
|
-
id: t.id ??
|
|
180
|
+
}), nt = s.map((t, n) => ({
|
|
181
|
+
id: t.id ?? n,
|
|
141
182
|
from: t.source,
|
|
142
183
|
to: t.target,
|
|
143
184
|
title: t.type,
|
|
@@ -146,9 +187,22 @@ function jt({
|
|
|
146
187
|
// stand-in for the gradient edges ck8t's ReactFlow canvas uses.
|
|
147
188
|
color: { inherit: "both", opacity: 0.55 },
|
|
148
189
|
arrows: { to: { enabled: !0, scaleFactor: 0.6 } }
|
|
149
|
-
})),
|
|
150
|
-
|
|
151
|
-
const
|
|
190
|
+
})), F = new Rt(bt), W = new Rt(nt);
|
|
191
|
+
Dt.current = F, Bt.current = W;
|
|
192
|
+
const Q = e.length > Vt, wt = {
|
|
193
|
+
// vis-network defaults `layout.improvedLayout` to true, which runs a
|
|
194
|
+
// Kamada-Kawai pre-positioning pass whenever the graph exceeds its
|
|
195
|
+
// internal clusterThreshold (150 nodes). On graphs with many
|
|
196
|
+
// uneven-sized communities that pass regularly fails to reduce the
|
|
197
|
+
// graph within its own iteration budget: it logs "This network could
|
|
198
|
+
// not be positioned by this version of the improved layout
|
|
199
|
+
// algorithm" and falls back to leaving most nodes near their default
|
|
200
|
+
// circular starting positions with a ±35px jitter — the stray ring of
|
|
201
|
+
// dots around the outside that physics then can't pull in within its
|
|
202
|
+
// stabilization budget. Skipping the pre-pass (vis's own documented
|
|
203
|
+
// suggestion, printed in that same message) lets forceAtlas2Based
|
|
204
|
+
// position everything from a clean random start instead.
|
|
205
|
+
layout: { improvedLayout: !1 },
|
|
152
206
|
physics: {
|
|
153
207
|
enabled: !0,
|
|
154
208
|
solver: "forceAtlas2Based",
|
|
@@ -185,220 +239,249 @@ function jt({
|
|
|
185
239
|
shape: "dot",
|
|
186
240
|
borderWidth: 1.5,
|
|
187
241
|
borderWidthSelected: 3,
|
|
188
|
-
shadow: { enabled: !
|
|
242
|
+
shadow: { enabled: !Q, color: "rgba(0,0,0,0.35)", size: 8, x: 0, y: 3 }
|
|
189
243
|
},
|
|
190
244
|
edges: {
|
|
191
245
|
// 'continuous' recomputes bezier control points per edge per draw —
|
|
192
246
|
// the most expensive of vis-network's smooth types. Straight lines
|
|
193
247
|
// above the threshold; edges are hidden during zoom either way.
|
|
194
|
-
smooth:
|
|
195
|
-
shadow: { enabled: !
|
|
248
|
+
smooth: Q ? !1 : { enabled: !0, type: "continuous", roundness: 0.25 },
|
|
249
|
+
shadow: { enabled: !Q, color: "rgba(0,0,0,0.12)", size: 3, x: 0, y: 1 }
|
|
196
250
|
}
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
const t =
|
|
201
|
-
if (!t || !
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
204
|
-
const
|
|
251
|
+
}, o = new Kt(V.current, { nodes: F, edges: W }, wt);
|
|
252
|
+
j.current = o;
|
|
253
|
+
const G = () => {
|
|
254
|
+
const t = dt.current;
|
|
255
|
+
if (!t || !q) return;
|
|
256
|
+
const n = t.getContext("2d");
|
|
257
|
+
if (!n) return;
|
|
258
|
+
const r = o.getPositions(), a = Object.values(r).map((l) => l.x), d = Object.values(r).map((l) => l.y);
|
|
205
259
|
if (a.length === 0) return;
|
|
206
|
-
const
|
|
207
|
-
(
|
|
208
|
-
(
|
|
260
|
+
const S = Math.min(...a), D = Math.max(...a), p = Math.min(...d), et = Math.max(...d), U = t.width, H = t.height, it = Math.max(1, D - S), st = Math.max(1, et - p), h = (l, v) => [
|
|
261
|
+
(l - S) / it * (U - 10) + 5,
|
|
262
|
+
(v - p) / st * (H - 10) + 5
|
|
209
263
|
];
|
|
210
|
-
|
|
211
|
-
const [
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
|
|
264
|
+
n.clearRect(0, 0, U, H), n.fillStyle = R.minimapBg, n.fillRect(0, 0, U, H), Object.entries(r).forEach(([l, v]) => {
|
|
265
|
+
const [B, b] = h(v.x, v.y), A = Z.current.get(l);
|
|
266
|
+
n.fillStyle = A ? C ? C(A) : Wt(A) : "#6B7280", n.beginPath();
|
|
267
|
+
const _ = w[l] ?? 0;
|
|
268
|
+
n.arc(B, b, 1 + 1.5 * (_ / L), 0, Math.PI * 2), n.fill();
|
|
215
269
|
});
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
const
|
|
219
|
-
|
|
270
|
+
const g = o.getScale(), E = o.getViewPosition(), T = V.current;
|
|
271
|
+
if (T && g > 0) {
|
|
272
|
+
const l = T.clientWidth / g, v = T.clientHeight / g, [B, b] = h(E.x - l / 2, E.y - v / 2), [A, _] = h(E.x + l / 2, E.y + v / 2);
|
|
273
|
+
n.strokeStyle = R.viewportStroke, n.lineWidth = 1, n.strokeRect(B, b, A - B, _ - b);
|
|
220
274
|
}
|
|
221
275
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
276
|
+
let I = null;
|
|
277
|
+
const ot = () => {
|
|
278
|
+
I = null;
|
|
279
|
+
};
|
|
280
|
+
let xt = null, vt = null;
|
|
281
|
+
const At = /* @__PURE__ */ new Map();
|
|
282
|
+
s.forEach((t, n) => {
|
|
283
|
+
t.type && At.set(t.id ?? n, t.type);
|
|
228
284
|
});
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
285
|
+
const Pt = (t, n) => {
|
|
286
|
+
let r = t[n];
|
|
287
|
+
return r || (r = te(zt.current), t[n] = r), r;
|
|
288
|
+
}, Lt = (t, n, r) => {
|
|
289
|
+
const a = `${n}\0${r}`;
|
|
290
|
+
let d = gt.current.get(a);
|
|
291
|
+
return d || (d = { w: t.offsetWidth, h: t.offsetHeight }, gt.current.set(a, d)), d;
|
|
292
|
+
}, rt = (t, n) => {
|
|
293
|
+
for (let r = n; r < t.length; r++)
|
|
294
|
+
t[r].style.display !== "none" && (t[r].style.display = "none");
|
|
295
|
+
}, Y = () => {
|
|
296
|
+
var it, st;
|
|
297
|
+
const t = pt.current, n = ht.current, r = ((it = V.current) == null ? void 0 : it.clientWidth) ?? 0, a = ((st = V.current) == null ? void 0 : st.clientHeight) ?? 0;
|
|
298
|
+
if (o.getScale() < Zt || !r || !a) {
|
|
299
|
+
rt(t, 0), rt(n, 0);
|
|
300
|
+
return;
|
|
245
301
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
302
|
+
I || (I = o.getPositions());
|
|
303
|
+
const d = o.DOMtoCanvas({ x: 0, y: 0 }), S = o.DOMtoCanvas({ x: r, y: a }), D = [];
|
|
304
|
+
for (const h in I) {
|
|
305
|
+
const g = I[h];
|
|
306
|
+
g.x < d.x || g.x > S.x || g.y < d.y || g.y > S.y || Z.current.has(h) && D.push({ id: h, deg: w[h] ?? 0 });
|
|
307
|
+
}
|
|
308
|
+
D.length > Tt && (D.sort((h, g) => g.deg - h.deg), D.length = Tt);
|
|
309
|
+
const p = Qt(), et = 12;
|
|
310
|
+
let U = 0;
|
|
311
|
+
for (const h of D) {
|
|
312
|
+
const g = Z.current.get(h.id);
|
|
313
|
+
if (!(g != null && g.label) || o.findNode(h.id).length !== 1) continue;
|
|
314
|
+
const E = o.getBoundingBox(h.id);
|
|
315
|
+
if (!E) continue;
|
|
316
|
+
const T = o.canvasToDOM({ x: (E.left + E.right) / 2, y: E.bottom }), l = Pt(t, U);
|
|
317
|
+
_t(l, g.label, ee(J.get(h.id) ?? "#6B7280")), l.style.display !== "" && (l.style.display = "");
|
|
318
|
+
const v = !xt || xt.has(h.id) ? "1" : String(at);
|
|
319
|
+
l.style.opacity !== v && (l.style.opacity = v);
|
|
320
|
+
const { w: B, h: b } = Lt(l, "n", g.label), A = T.x - B / 2, _ = T.y + 6;
|
|
321
|
+
let $ = A, P = _;
|
|
322
|
+
for (let ct = 0; ct < et; ct++) {
|
|
323
|
+
const Nt = Math.floor(ct / 3), jt = ct % 3 - 1;
|
|
324
|
+
if ($ = A + jt * (B + 6), P = _ + Nt * (b + 3), !p.collides({ left: $, top: P, right: $ + B, bottom: P + b })) break;
|
|
256
325
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
326
|
+
l.style.left = `${$}px`, l.style.top = `${P}px`, p.insert({ left: $, top: P, right: $ + B, bottom: P + b }), U++;
|
|
327
|
+
}
|
|
328
|
+
rt(t, U);
|
|
329
|
+
let H = 0;
|
|
330
|
+
for (const [h, g] of At) {
|
|
331
|
+
if (H >= qt) break;
|
|
332
|
+
const E = W.get(h);
|
|
333
|
+
if (!E) continue;
|
|
334
|
+
const T = I[E.from], l = I[E.to];
|
|
335
|
+
if (!T || !l) continue;
|
|
336
|
+
const v = { x: (T.x + l.x) / 2, y: (T.y + l.y) / 2 };
|
|
337
|
+
if (v.x < d.x || v.x > S.x || v.y < d.y || v.y > S.y || o.findNode(E.from).length !== 1 || o.findNode(E.to).length !== 1) continue;
|
|
338
|
+
const B = o.canvasToDOM(v), b = Pt(n, H);
|
|
339
|
+
_t(b, g, ne(R)), b.style.display !== "" && (b.style.display = "");
|
|
340
|
+
const A = !vt || vt.has(h) ? "1" : String(at);
|
|
341
|
+
b.style.opacity !== A && (b.style.opacity = A);
|
|
342
|
+
const { w: _, h: $ } = Lt(b, "e", g), P = { left: B.x - _ / 2, top: B.y - $ / 2, right: B.x + _ / 2, bottom: B.y + $ / 2 };
|
|
343
|
+
if (p.collides(P)) {
|
|
344
|
+
b.style.display = "none";
|
|
260
345
|
continue;
|
|
261
346
|
}
|
|
262
|
-
|
|
347
|
+
b.style.left = `${P.left}px`, b.style.top = `${P.top}px`, p.insert(P), H++;
|
|
263
348
|
}
|
|
349
|
+
rt(n, H);
|
|
264
350
|
};
|
|
265
|
-
let
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
351
|
+
let tt = null;
|
|
352
|
+
const Ht = () => {
|
|
353
|
+
X.current || tt === null && (tt = requestAnimationFrame(() => {
|
|
354
|
+
tt = null, Y();
|
|
355
|
+
}));
|
|
270
356
|
};
|
|
271
|
-
if (
|
|
272
|
-
|
|
357
|
+
if (o.once("stabilizationIterationsDone", () => {
|
|
358
|
+
o.setOptions({ physics: { enabled: !1 } });
|
|
273
359
|
let t = !1;
|
|
274
|
-
if (
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}),
|
|
360
|
+
if (x) {
|
|
361
|
+
const r = new Set(e.map((a) => a.communityId).filter((a) => a != null));
|
|
362
|
+
r.forEach((a) => $t(o, a, e)), r.size > 1 && (t = !0, o.once("stabilizationIterationsDone", () => {
|
|
363
|
+
o.setOptions({ physics: { enabled: !1 } }), G(), ot(), Y(), k.current && o.findNode(k.current).length > 0 && (o.selectNodes([k.current]), o.focus(k.current, { scale: 1.4, animation: !0 }), X.current = !0), m == null || m();
|
|
364
|
+
}), o.setOptions({
|
|
279
365
|
physics: { enabled: !0, stabilization: { iterations: 80, fit: !1 } }
|
|
280
|
-
}),
|
|
366
|
+
}), o.stabilize(80));
|
|
281
367
|
}
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
}),
|
|
285
|
-
|
|
286
|
-
}),
|
|
368
|
+
const n = o.getScale();
|
|
369
|
+
n > 0 && o.moveTo({ scale: n * 0.92 }), G(), ot(), Y(), t || (k.current && o.findNode(k.current).length > 0 && (o.selectNodes([k.current]), o.focus(k.current, { scale: 1.4, animation: !0 }), X.current = !0), m == null || m());
|
|
370
|
+
}), o.on("afterDrawing", Ht), o.on("dragEnd", () => {
|
|
371
|
+
ot(), Y();
|
|
372
|
+
}), o.on("animationFinished", () => {
|
|
373
|
+
X.current = !1, Y(), q && G();
|
|
374
|
+
}), o.on("click", (t) => {
|
|
287
375
|
if (t.nodes.length === 0) return;
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
|
|
376
|
+
const n = t.nodes[0], r = Z.current.get(n);
|
|
377
|
+
if (r) {
|
|
378
|
+
f == null || f(r);
|
|
291
379
|
return;
|
|
292
380
|
}
|
|
293
|
-
|
|
294
|
-
}),
|
|
381
|
+
o.isCluster(n) && (f == null || f({ id: n, label: n }));
|
|
382
|
+
}), x && o.on("doubleClick", (t) => {
|
|
295
383
|
if (t.nodes.length !== 1) return;
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
298
|
-
|
|
384
|
+
const n = t.nodes[0];
|
|
385
|
+
if (o.isCluster(n))
|
|
386
|
+
o.openCluster(n);
|
|
299
387
|
else {
|
|
300
|
-
const
|
|
301
|
-
(
|
|
388
|
+
const r = Z.current.get(n);
|
|
389
|
+
(r == null ? void 0 : r.communityId) != null && $t(o, r.communityId, e);
|
|
302
390
|
}
|
|
303
|
-
|
|
304
|
-
}),
|
|
305
|
-
let t = new Set(
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
for (const
|
|
309
|
-
for (const
|
|
310
|
-
|
|
311
|
-
const
|
|
312
|
-
for (const
|
|
313
|
-
|
|
314
|
-
for (const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
for (const [o, m] of X.current)
|
|
318
|
-
a.has(o) !== t.has(o) && (m.style.opacity = a.has(o) ? "1" : String(nt));
|
|
319
|
-
for (const [o, m] of Y.current)
|
|
320
|
-
c.has(o) !== e.has(o) && (m.style.opacity = c.has(o) ? "1" : String(nt));
|
|
321
|
-
t = a, e = c;
|
|
391
|
+
G(), ot(), Y();
|
|
392
|
+
}), St) {
|
|
393
|
+
let t = new Set(F.getIds()), n = new Set(W.getIds());
|
|
394
|
+
const r = (a, d) => {
|
|
395
|
+
const S = [];
|
|
396
|
+
for (const p of a) t.has(p) || S.push({ id: p, opacity: 1 });
|
|
397
|
+
for (const p of t) a.has(p) || S.push({ id: p, opacity: at });
|
|
398
|
+
S.length && F.update(S);
|
|
399
|
+
const D = [];
|
|
400
|
+
for (const p of d)
|
|
401
|
+
n.has(p) || D.push({ id: p, color: { inherit: "both", opacity: 0.9 } });
|
|
402
|
+
for (const p of n)
|
|
403
|
+
d.has(p) || D.push({ id: p, color: { inherit: "both", opacity: at } });
|
|
404
|
+
D.length && W.update(D), xt = a, vt = d, Y(), t = a, n = d;
|
|
322
405
|
};
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
[
|
|
327
|
-
),
|
|
328
|
-
|
|
329
|
-
}),
|
|
330
|
-
|
|
331
|
-
|
|
406
|
+
o.on("hoverNode", (a) => {
|
|
407
|
+
u !== null && (clearTimeout(u), u = null);
|
|
408
|
+
const d = a.node, S = Ct.current.get(d) ?? /* @__PURE__ */ new Set(), D = new Set(
|
|
409
|
+
[d, ...S].filter((et) => F.get(et) != null)
|
|
410
|
+
), p = Ot.current.get(d) ?? /* @__PURE__ */ new Set();
|
|
411
|
+
r(D, p);
|
|
412
|
+
}), o.on("blurNode", () => {
|
|
413
|
+
u = setTimeout(() => {
|
|
414
|
+
u = null, r(new Set(F.getIds()), new Set(W.getIds()));
|
|
332
415
|
}, 80);
|
|
333
416
|
});
|
|
334
417
|
}
|
|
335
|
-
if (
|
|
336
|
-
|
|
418
|
+
if (q) {
|
|
419
|
+
o.on("dragEnd", G);
|
|
337
420
|
let t = 0;
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
const
|
|
341
|
-
|
|
421
|
+
const n = () => {
|
|
422
|
+
if (X.current) return;
|
|
423
|
+
const r = Date.now();
|
|
424
|
+
r - t < 100 || (t = r, G());
|
|
342
425
|
};
|
|
343
|
-
|
|
426
|
+
o.on("zoom", n), o.on("afterDrawing", n);
|
|
344
427
|
}
|
|
345
428
|
return () => {
|
|
346
|
-
|
|
347
|
-
for (const t of
|
|
348
|
-
|
|
349
|
-
for (const t of
|
|
350
|
-
|
|
429
|
+
u !== null && clearTimeout(u), tt !== null && cancelAnimationFrame(tt), o.destroy(), j.current = null, Dt.current = null, Bt.current = null;
|
|
430
|
+
for (const t of pt.current) t.remove();
|
|
431
|
+
pt.current = [];
|
|
432
|
+
for (const t of ht.current) t.remove();
|
|
433
|
+
ht.current = [], gt.current.clear();
|
|
351
434
|
};
|
|
352
|
-
}, [
|
|
353
|
-
const
|
|
354
|
-
!
|
|
355
|
-
}, [i,
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
if (!
|
|
360
|
-
|
|
435
|
+
}, [e, s, x, St, q, ft]), Et(() => {
|
|
436
|
+
const u = j.current;
|
|
437
|
+
!u || !i || u.findNode(i).length > 0 && (u.selectNodes([i]), u.focus(i, { scale: 1.4, animation: !0 }), X.current = !0);
|
|
438
|
+
}, [i, e]);
|
|
439
|
+
const mt = M(c);
|
|
440
|
+
Et(() => {
|
|
441
|
+
const u = j.current;
|
|
442
|
+
if (!u || c === void 0 || c === mt.current) {
|
|
443
|
+
mt.current = c;
|
|
361
444
|
return;
|
|
362
445
|
}
|
|
363
|
-
|
|
364
|
-
}, [
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
370
|
-
const
|
|
446
|
+
mt.current = c, u.unselectAll(), u.fit({ animation: !0 }), X.current = !0;
|
|
447
|
+
}, [c]);
|
|
448
|
+
const It = (u) => {
|
|
449
|
+
const w = j.current, y = dt.current;
|
|
450
|
+
if (!w || !y) return null;
|
|
451
|
+
const z = w.getPositions(), L = Object.values(z).map((I) => I.x), R = Object.values(z).map((I) => I.y);
|
|
452
|
+
if (L.length === 0) return null;
|
|
453
|
+
const J = Math.min(...L), bt = Math.max(...L), nt = Math.min(...R), F = Math.max(...R), W = y.getBoundingClientRect(), Q = u.clientX - W.left, wt = u.clientY - W.top, o = Math.max(1, bt - J), G = Math.max(1, F - nt);
|
|
371
454
|
return {
|
|
372
|
-
x: (
|
|
373
|
-
y: (
|
|
455
|
+
x: (Q - 5) / (y.width - 10) * o + J,
|
|
456
|
+
y: (wt - 5) / (y.height - 10) * G + nt
|
|
374
457
|
};
|
|
375
|
-
},
|
|
376
|
-
var
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
var
|
|
383
|
-
if (!
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
},
|
|
387
|
-
|
|
458
|
+
}, Ft = (u) => {
|
|
459
|
+
var y;
|
|
460
|
+
const w = It(u);
|
|
461
|
+
w && ((y = j.current) == null || y.moveTo({ position: w, animation: !0 }));
|
|
462
|
+
}, yt = M(!1), Gt = (u) => {
|
|
463
|
+
yt.current = !0;
|
|
464
|
+
const w = (z) => {
|
|
465
|
+
var R;
|
|
466
|
+
if (!yt.current) return;
|
|
467
|
+
const L = It(z);
|
|
468
|
+
L && ((R = j.current) == null || R.moveTo({ position: L }));
|
|
469
|
+
}, y = () => {
|
|
470
|
+
yt.current = !1, window.removeEventListener("mousemove", w), window.removeEventListener("mouseup", y);
|
|
388
471
|
};
|
|
389
|
-
window.addEventListener("mousemove",
|
|
472
|
+
window.addEventListener("mousemove", w), window.addEventListener("mouseup", y), u.preventDefault();
|
|
390
473
|
};
|
|
391
|
-
return /* @__PURE__ */
|
|
392
|
-
/* @__PURE__ */
|
|
393
|
-
/* @__PURE__ */
|
|
394
|
-
|
|
474
|
+
return /* @__PURE__ */ Ut("div", { className: K, style: { width: "100%", height: "100%", position: "relative", ...N }, children: [
|
|
475
|
+
/* @__PURE__ */ Mt("div", { ref: V, style: { width: "100%", height: "100%" } }),
|
|
476
|
+
/* @__PURE__ */ Mt("div", { ref: zt, style: { position: "absolute", inset: 0, overflow: "hidden", pointerEvents: "none" } }),
|
|
477
|
+
q && /* @__PURE__ */ Mt(
|
|
395
478
|
"canvas",
|
|
396
479
|
{
|
|
397
|
-
ref:
|
|
480
|
+
ref: dt,
|
|
398
481
|
width: 140,
|
|
399
482
|
height: 100,
|
|
400
|
-
onClick:
|
|
401
|
-
onMouseDown:
|
|
483
|
+
onClick: Ft,
|
|
484
|
+
onMouseDown: Gt,
|
|
402
485
|
style: {
|
|
403
486
|
// bottom 72 (not 8): host apps commonly float a chat/action
|
|
404
487
|
// orb in the bottom-right corner — leave that spot free.
|
|
@@ -406,13 +489,13 @@ function jt({
|
|
|
406
489
|
bottom: 72,
|
|
407
490
|
right: 8,
|
|
408
491
|
borderRadius: 4,
|
|
409
|
-
border: `1px solid ${
|
|
492
|
+
border: `1px solid ${kt[ft].minimapBorder}`,
|
|
410
493
|
cursor: "grab"
|
|
411
494
|
}
|
|
412
495
|
}
|
|
413
496
|
)
|
|
414
497
|
] });
|
|
415
498
|
}
|
|
416
|
-
|
|
417
|
-
|
|
499
|
+
Yt(oe);
|
|
500
|
+
Xt();
|
|
418
501
|
//# sourceMappingURL=vis-setup.js.map
|