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