react-kggraph 0.0.16 → 0.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.
Files changed (42) hide show
  1. package/README.md +47 -1
  2. package/lib/index.es.js +8 -6
  3. package/lib/index.es10.js +186 -69
  4. package/lib/index.es11.js +71 -28
  5. package/lib/index.es12.js +29 -69
  6. package/lib/index.es13.js +70 -224
  7. package/lib/index.es14.js +224 -4
  8. package/lib/index.es15.js +4 -35
  9. package/lib/index.es16.js +37 -0
  10. package/lib/index.es18.js +15462 -49
  11. package/lib/index.es19.js +50 -56
  12. package/lib/index.es20.js +57 -66
  13. package/lib/index.es21.js +68 -39
  14. package/lib/index.es22.js +40 -2
  15. package/lib/index.es23.js +1 -1
  16. package/lib/index.es24.js +2 -2
  17. package/lib/index.es25.js +1 -1
  18. package/lib/index.es26.js +1 -1
  19. package/lib/index.es27.js +1 -1
  20. package/lib/index.es28.js +1 -1
  21. package/lib/index.es29.js +1 -1
  22. package/lib/index.es3.js +173 -155
  23. package/lib/index.es30.js +1 -1
  24. package/lib/index.es31.js +1 -1
  25. package/lib/index.es32.js +2 -2
  26. package/lib/index.es33.js +4 -0
  27. package/lib/index.es35.js +4 -2
  28. package/lib/index.es36.js +4 -0
  29. package/lib/index.es4.js +17 -6
  30. package/lib/index.es5.js +6 -2
  31. package/lib/index.es6.js +2 -599
  32. package/lib/index.es7.js +580 -312
  33. package/lib/index.es8.js +294 -393
  34. package/lib/index.es9.js +408 -173
  35. package/lib/src/components/Graph/components/ActionBar/actionList.d.ts +10 -0
  36. package/lib/src/components/Graph/components/ActionBar/index.d.ts +15 -0
  37. package/lib/src/components/Graph/types.d.ts +51 -0
  38. package/lib/src/components/Graph/utils/edge_node_styles.d.ts +5 -2
  39. package/lib/style.css +1 -1
  40. package/package.json +2 -8
  41. package/lib/index.es17.js +0 -15469
  42. package/lib/index.es34.js +0 -6
package/lib/index.es7.js CHANGED
@@ -1,324 +1,592 @@
1
- import { message as C } from "antd";
1
+ import { jsxs as f, Fragment as $, jsx as o } from "react/jsx-runtime";
2
+ import Z, { forwardRef as Ge, useContext as Ue, useState as y, useRef as Xe, useImperativeHandle as Ye, useEffect as Be } from "react";
3
+ /* empty css */
4
+ import { Dropdown as Re, Flex as x, Modal as et, Drawer as tt, Tabs as re, Form as u, Input as I, Select as m, ColorPicker as A, Button as de, message as T } from "antd";
5
+ import { utils as E, writeFile as ot } from "./index.es18.js";
6
+ import { textPositionConfig as he, textLayout as lt, downloadData as nt, choiceConfig as st, linkAnalysis as at, layoutCongig as rt, handleCalcPath as it, getCyData as ie, donwnGraphData as ct } from "./index.es8.js";
7
+ import { GraphContext as dt } from "./index.es15.js";
8
+ import { layout as ht, fixNodesToEdges as gt } from "./index.es9.js";
9
+ import { defaultColors as z } from "./index.es10.js";
10
+ import mt from "./index.es19.js";
11
+ import ut from "./index.es20.js";
12
+ import pt from "./index.es21.js";
2
13
  import j from "./index.es22.js";
3
- import I from "./index.es23.js";
4
- import P from "./index.es24.js";
5
- import $ from "./index.es25.js";
6
- import D from "./index.es26.js";
7
- import J from "./index.es27.js";
8
- import N from "./index.es28.js";
9
- import R from "./index.es29.js";
10
- import q from "./index.es30.js";
11
- import A from "./index.es31.js";
12
- import B from "./index.es32.js";
13
- import { jsonStringifyParse as U } from "./index.es11.js";
14
- const L = [j, I, P, $, D, J, N, R, q, A], G = (c) => {
15
- let o = {};
16
- const s = {}, e = [];
17
- return c.forEach((n) => {
18
- var a;
19
- const { group: d } = n;
20
- if (d === "nodes") {
21
- const r = n.data, l = (a = r.properties) == null ? void 0 : a.type, i = r.type;
22
- !i && l === "uri" || (!e.includes(i) && l === "uri" ? (e.push(i), o = { ...o, [i]: { ...o[i], count: 1, img: r.image } }) : l === "uri" && i && (o = { ...o, [i]: { ...o[i], img: r.image, count: o[i].count + 1 } }));
23
- } else if (d === "edges") {
24
- const r = n.data, { label: l } = r;
25
- s[l] ? s[l] = s[l] + 1 : s[l] = 1;
26
- } else
27
- console.log("nonono");
28
- }), {
29
- typeListArr: e,
30
- typeListObj: o,
31
- relationListObj: s
32
- };
33
- }, te = (c, { graphData: o = [], typeObj: s, zktype: e, graphInfo: n = {} }) => {
34
- let d = U(s);
35
- const a = Object.keys(s), r = n.searchNodes || [], l = new Set(
36
- (o == null ? void 0 : o.map((g) => {
37
- var t, m, h;
38
- return g.group === "nodes" ? (t = g.data) == null ? void 0 : t.id : ((m = g.data) == null ? void 0 : m.source) + "-" + ((h = g.data) == null ? void 0 : h.target);
39
- }).filter(Boolean)) || []
40
- ), { nodes: i = [], links: p = [] } = c || {}, y = [], k = (g) => {
41
- g.forEach((t) => {
42
- var m, h;
43
- if (!l.has(t.id)) {
44
- const v = (m = t.properties) == null ? void 0 : m.type, f = t.type, E = t.label.split("#").pop();
45
- let w = -1;
46
- if (!f && v === "uri")
47
- w = t.image || L[0];
48
- else if (!a.includes(f) && v === "uri") {
49
- a.push(f);
50
- const O = a.indexOf(f);
51
- w = t.image || L[O] || L[0], d = { ...d, [f]: { ...d[f], img: w } };
52
- } else v === "uri" && f && (w = (h = d[f]) == null ? void 0 : h.img);
53
- const S = {
54
- ...t,
55
- name: E,
56
- "properties-type": v,
57
- image: r.includes(E) ? B : w,
58
- baseWidth: 80,
59
- // 保存基础宽度
60
- baseHeight: 80
61
- // 保存基础高度
62
- };
63
- y.push({ group: "nodes", data: S });
64
- }
65
- });
66
- };
67
- ((g) => {
68
- g.forEach((t) => {
69
- const { label: m } = t, h = `${t.source}-${t.target}`;
70
- l.has(h) || y.push({ group: "edges", data: { ...t, name: m, zktype: e } });
14
+ import { downloadFile as ce } from "./index.es12.js";
15
+ import { actionList as ft } from "./index.es4.js";
16
+ const q = (b, r) => (S) => {
17
+ S.stopPropagation(), b == null || b(r || "");
18
+ }, bt = (b) => {
19
+ if (!b)
20
+ return { bottom: 20, right: 20 };
21
+ if (typeof b == "string")
22
+ switch (b) {
23
+ case "top":
24
+ return { top: 20, left: "50%", transform: "translateX(-50%)" };
25
+ case "bottom":
26
+ return { bottom: 20, left: "50%", transform: "translateX(-50%)" };
27
+ case "left":
28
+ return { top: "50%", left: 20, transform: "translateY(-50%)" };
29
+ case "right":
30
+ return { top: "50%", right: 20, transform: "translateY(-50%)" };
31
+ case "top-left":
32
+ return { top: 20, left: 20 };
33
+ case "top-right":
34
+ return { top: 20, right: 20 };
35
+ case "bottom-left":
36
+ return { bottom: 20, left: 20 };
37
+ case "bottom-right":
38
+ default:
39
+ return { bottom: 20, right: 20 };
40
+ }
41
+ return b;
42
+ }, At = Ge(({
43
+ graphInfo: b,
44
+ cyRef: r,
45
+ initNodeScale: S,
46
+ typeObj: v,
47
+ relationObj: D,
48
+ colors: ge,
49
+ actionBar: L
50
+ }, me) => {
51
+ var ne, se, ae;
52
+ const F = L == null ? void 0 : L.position, K = (L == null ? void 0 : L.actionList) ?? ft, H = { ...z, ...ge }, { layoutType: ue, setLayoutType: pe } = Ue(dt), [k, fe] = y(""), [be, M] = y(!1), [Q, we] = y(S), [ye, V] = y(!1), [Ce, P] = y(!1), [G, ve] = y(null), [xe, U] = y(!1), [X, Y] = y(!1), [Se, Ne] = y("node"), O = Xe(null), [B, Le] = y(!0), [R, ke] = y(/* @__PURE__ */ new Set()), [ee, De] = y(/* @__PURE__ */ new Set());
53
+ Ye(me, () => ({
54
+ onPathAnalysis: () => {
55
+ oe();
56
+ }
57
+ })), Be(() => {
58
+ te();
59
+ }, [k]);
60
+ const te = async (e) => {
61
+ const t = r.current;
62
+ if (!t || !k) {
63
+ t == null || t.nodes().removeClass("highlight"), t == null || t.fit();
64
+ return;
65
+ }
66
+ const l = t.nodes().filter((n) => {
67
+ const c = (n.data("name") || "").toLowerCase(), d = (n.data("role") || "").toLowerCase(), p = (n.data("dept") || "").toLowerCase(), g = String(n.data("id") || "").toLowerCase();
68
+ return c.includes(k.toLowerCase()) || d.includes(k.toLowerCase()) || p.includes(k.toLowerCase()) || g.includes(k.toLowerCase());
71
69
  });
72
- })(p), k(i);
73
- const { typeListObj: u, relationListObj: x } = G([...y, ...o]);
74
- return {
75
- elements: y,
76
- typeListObj: u,
77
- relationListObj: x
78
- };
79
- }, oe = (c, o) => {
80
- const s = c.current;
81
- if (!s) return;
82
- let e = {
83
- color: "#000"
84
- };
85
- switch (o) {
86
- case "center":
87
- e = {
88
- "text-halign": "center",
89
- "text-valign": "center"
90
- // 'color': '#fff',
91
- };
92
- break;
93
- case "left":
94
- e = {
95
- ...e,
96
- "text-halign": "left",
97
- "text-valign": "center",
98
- "text-margin-x": "-5px"
99
- };
100
- break;
101
- case "right":
102
- e = {
103
- ...e,
104
- "text-halign": "right",
105
- "text-valign": "center",
106
- "text-margin-x": "5px"
107
- };
108
- break;
109
- case "top":
110
- e = {
111
- ...e,
112
- "text-halign": "center",
113
- "text-valign": "top",
114
- "text-margin-y": "-5px"
70
+ t.nodes().removeClass("highlight"), l.addClass("highlight"), l.length === 1 ? (console.log("matchedNodes:::", l), t.animate({
71
+ center: {
72
+ eles: l
73
+ },
74
+ duration: 500
75
+ })) : alert("未找到对应节点");
76
+ }, Ee = (e) => {
77
+ const t = r.current;
78
+ if (!t) return;
79
+ const l = t.zoom();
80
+ console.log(999, l);
81
+ let n = 0;
82
+ switch (e) {
83
+ case "out":
84
+ n = Math.max(l * 0.8, 0.1);
85
+ break;
86
+ case "in":
87
+ n = Math.min(l * 1.2, 3);
88
+ break;
89
+ }
90
+ t.zoom(n), t.center();
91
+ }, Ie = () => {
92
+ console.log("查询节点"), V(!0), P(!1), O.current.close();
93
+ }, oe = () => {
94
+ console.log("路径分析"), V(!1), P(!0), O.current.close();
95
+ }, Ve = (e) => {
96
+ var l;
97
+ pe(e);
98
+ const t = r.current;
99
+ t && (t.nodes().unlock(), ht(r, e), e === "cose-bilkent" && ((l = b == null ? void 0 : b.searchNodes) == null ? void 0 : l.length) === 2 && gt(
100
+ t,
101
+ b.searchNodes[0],
102
+ b.searchNodes[1]
103
+ ));
104
+ }, Pe = () => {
105
+ const e = r.current;
106
+ e && ct(e);
107
+ }, Oe = () => {
108
+ const e = r.current;
109
+ if (!e) return;
110
+ const t = ie(e);
111
+ ve(t), U(!0);
112
+ }, le = (e, t) => {
113
+ const l = e.current;
114
+ if (!l) return;
115
+ const n = 2;
116
+ if (t === "downloadPng") {
117
+ const c = l.png({ scale: n, bg: "transparent", full: !0, quality: 1 });
118
+ ce(c, `graph_${Date.now()}.png`);
119
+ } else if (t === "downloadJpg") {
120
+ const c = l.jpg({ scale: n, bg: "#ffffff", full: !0, quality: 1 });
121
+ ce(c, `graph_${Date.now()}.jpg`);
122
+ }
123
+ }, Te = () => {
124
+ const e = r.current;
125
+ if (!e) return;
126
+ const t = ie(e), { nodes: l = [], edges: n = [] } = t, c = l.map((g) => {
127
+ var h, a;
128
+ const i = g.data || {}, C = i.properties || {};
129
+ return {
130
+ 节点名称: i.name || i.label || "",
131
+ 节点ID: i.id || "",
132
+ 节点类型: i.types || "",
133
+ URI: i.label || "",
134
+ X坐标: ((h = g.position) == null ? void 0 : h.x) || "",
135
+ Y坐标: ((a = g.position) == null ? void 0 : a.y) || "",
136
+ 层级: i.level || "",
137
+ 宽度: i.baseWidth || "",
138
+ 高度: i.baseHeight || "",
139
+ 图片: i.image || "",
140
+ 属性ID: C.id || "",
141
+ 属性值: C.value || ""
115
142
  };
116
- break;
117
- case "bottom":
118
- e = {
119
- ...e,
120
- "text-halign": "center",
121
- "text-valign": "bottom",
122
- "text-margin-y": "5px"
143
+ }), d = n.map((g) => {
144
+ var a, s, w, N;
145
+ const i = g.data || {}, C = ((s = (a = i.source) == null ? void 0 : a.split("/#")[0]) == null ? void 0 : s.split("/").pop()) || i.source, h = ((N = (w = i.target) == null ? void 0 : w.split("/#")[0]) == null ? void 0 : N.split("/").pop()) || i.target;
146
+ return {
147
+ 源节点: C,
148
+ 目标节点: h,
149
+ 源URI: i.source || "",
150
+ 目标URI: i.target || "",
151
+ 关系名称: i.name || i.label || "",
152
+ 关系ID: i.id || ""
123
153
  };
124
- break;
125
- }
126
- s.nodes().style(e), s.style().update();
127
- }, ne = async (c, { pathNodes: o, isGrayed: s = !0 }) => {
128
- const e = c.current;
129
- if (!e)
130
- return;
131
- if ((o == null ? void 0 : o.length) < 2) {
132
- C.warning("请至少设置 2 个路径节点!");
133
- return;
134
- }
135
- if ([...new Set(o)].length !== o.length) {
136
- C.warning("路径中存在重复节点,请检查!");
137
- return;
138
- }
139
- const d = [];
140
- for (const a of o) {
141
- const r = e.nodes().filter((l) => l.data("name") === a);
142
- if (r.length > 0)
143
- d.push(r.id());
154
+ }), p = E.book_new();
155
+ if (c.length > 0) {
156
+ const g = E.json_to_sheet(c);
157
+ g["!cols"] = [
158
+ { wch: 30 },
159
+ // 节点名称
160
+ { wch: 60 },
161
+ // 节点ID
162
+ { wch: 15 },
163
+ // 节点类型
164
+ { wch: 50 },
165
+ // URI
166
+ { wch: 12 },
167
+ // X坐标
168
+ { wch: 12 },
169
+ // Y坐标
170
+ { wch: 8 },
171
+ // 层级
172
+ { wch: 8 },
173
+ // 宽度
174
+ { wch: 8 },
175
+ // 高度
176
+ { wch: 40 },
177
+ // 图片
178
+ { wch: 50 },
179
+ // 属性ID
180
+ { wch: 40 }
181
+ // 属性值
182
+ ], E.book_append_sheet(p, g, "节点");
183
+ }
184
+ if (d.length > 0) {
185
+ const g = E.json_to_sheet(d);
186
+ g["!cols"] = [
187
+ { wch: 30 },
188
+ // 源节点
189
+ { wch: 30 },
190
+ // 目标节点
191
+ { wch: 60 },
192
+ // 源URI
193
+ { wch: 60 },
194
+ // 目标URI
195
+ { wch: 15 },
196
+ // 关系名称
197
+ { wch: 40 }
198
+ // 关系ID
199
+ ], E.book_append_sheet(p, g, "关系");
200
+ }
201
+ ot(p, `graph_${Date.now()}.xlsx`);
202
+ }, ze = (e, t) => {
203
+ switch (e.stopPropagation(), t) {
204
+ case "downloadJson":
205
+ Pe();
206
+ break;
207
+ case "previewJsonList":
208
+ Oe();
209
+ break;
210
+ case "downloadExcel":
211
+ Te();
212
+ break;
213
+ case "previewDataList":
214
+ break;
215
+ case "downloadJpg":
216
+ le(r, t);
217
+ break;
218
+ case "downloadPng":
219
+ le(r, t);
220
+ break;
221
+ }
222
+ }, je = () => {
223
+ V(!1), P(!1), O.current.open();
224
+ }, Ae = (e) => {
225
+ const t = r.current;
226
+ if (t)
227
+ if (t.panningEnabled(!0), e === "all")
228
+ t.nodes().addClass("selected"), t.nodes().select(), t.elements().select();
229
+ else if (e === "reverse") {
230
+ const l = t.elements().filter(":selected"), n = t.elements().not(":selected");
231
+ l.length > 0 ? (l.unselect(), n.select(), l.removeClass("selected"), n.addClass("selected")) : (t.elements().select(), t.elements().addClass("selected"));
232
+ } else e === "click" ? (t.off("click", "node"), t.on("click", "node", (l) => {
233
+ const n = l.target;
234
+ t.nodes().removeClass("selected grayed highlighted"), t.edges().removeClass("selected grayed highlighted"), n.addClass("selected");
235
+ const d = n.neighborhood().nodes().add(n), p = d.edgesWith(d);
236
+ console.log("cy.nodes().not(relatedNodes):::", d), t.nodes().not(d).addClass("grayed"), t.edges().not(p).addClass("grayed"), d.addClass("highlighted"), p.addClass("highlighted");
237
+ })) : e === "box" && (console.log("进入框选模式"), t.nodes().removeClass("selected"), t.nodes().unselect(), t.elements().unselect(), t.boxSelectionEnabled(!0), t.panningEnabled(!1), t.on("boxselectstart", () => {
238
+ console.log("开始框选...");
239
+ }), t.on("boxselect", (l) => {
240
+ const n = t.elements(":selected");
241
+ console.log("框选完成,选中元素数:", n.length), t.elements().removeClass("selected"), n.addClass("selected");
242
+ }), t.on("boxselectend", () => {
243
+ console.log("框选结束"), t.zoomingEnabled(!0), t.panningEnabled(!0);
244
+ }));
245
+ }, Fe = () => {
246
+ const e = r.current;
247
+ if (console.log("isShow::::"), be)
248
+ M(!1), e.nodes('[types="typed-literal" ]').style("visibility", "visible"), e.edges().style("visibility", "visible");
144
249
  else {
145
- e.nodes().removeClass("path-node"), e.edges().removeClass("path-edge"), C.warning(`找不到节点:${a}`);
250
+ M(!0);
251
+ const t = e.nodes('[types="typed-literal" ]');
252
+ t.style("visibility", "hidden"), t.connectedEdges().style("visibility", "hidden");
253
+ }
254
+ }, He = (e) => {
255
+ const t = r.current;
256
+ if (!t) return;
257
+ const l = e === "out" ? Math.max(Q * 0.8, 0.1) : Math.min(Q * 1.2, 5);
258
+ we(l);
259
+ const n = t.nodes();
260
+ n.style("width", (c) => (c.data("baseWidth") || 80) * l), n.style("height", (c) => (c.data("baseHeight") || 80) * l);
261
+ }, _e = (e) => {
262
+ fe(e.content), te(e.content);
263
+ }, We = (e = "刘强东", t = "1") => {
264
+ const l = r.current;
265
+ if (!l) return;
266
+ l.elements().removeClass("level-highlight level-selected level-grayed level-highlightedge");
267
+ const n = l.nodes().filter((h) => (h.data("name") || h.data("id") || "").toString().includes(e));
268
+ if (n.length === 0) {
269
+ T.warning(`未找到节点: ${e}`);
146
270
  return;
147
271
  }
148
- }
149
- try {
150
- e.nodes().removeClass("path-node").removeClass("grayed"), e.edges().removeClass("path-edge").removeClass("grayed");
151
- let a = e.collection(), r = 0, l = !0;
152
- const i = [];
153
- for (let p = 0; p < d.length - 1; p++) {
154
- const y = d[p], k = d[p + 1], b = e.getElementById(y), u = e.getElementById(k), x = b.edgesWith(u).filter(function(t) {
155
- return t.data("source") === y && t.data("target") === k;
156
- }), g = u.edgesWith(b).filter(function(t) {
157
- return t.data("source") === k && t.data("target") === y;
272
+ const c = parseInt(t) || 1, d = l.collection(), p = [];
273
+ n.forEach((h) => {
274
+ h.addClass("level-selected"), d.merge(h);
275
+ let a = l.collection();
276
+ const s = /* @__PURE__ */ new Set();
277
+ s.add(h.id()), c >= 1 && (a = h.neighborhood().nodes(), a.forEach((w) => {
278
+ s.add(w.id()), d.merge(w);
279
+ }), p.push(a));
280
+ for (let w = 2; w <= c; w++) {
281
+ const N = l.collection();
282
+ a.forEach((W) => {
283
+ W.neighborhood().nodes().forEach((J) => {
284
+ s.has(J.id()) || (s.add(J.id()), N.merge(J));
285
+ });
286
+ }), N.forEach((W) => d.merge(W)), p.push(N), a = N;
287
+ }
288
+ }), p.forEach((h) => {
289
+ h.addClass("level-highlight");
290
+ }), l.edges().filter((h) => {
291
+ const a = h.source(), s = h.target();
292
+ return d.contains(a) && d.contains(s);
293
+ }).addClass("level-highlightedge");
294
+ const i = l.elements().filter(".level-selected, .level-highlight, .level-highlightedge");
295
+ l.elements().not(i).addClass("level-grayed"), T.success(`已高亮 "${e}" 及其 ${c} 度关联节点和连线`);
296
+ }, Je = (e) => {
297
+ const t = r.current;
298
+ if (!t) return;
299
+ const l = new Set(R);
300
+ l.has(e) ? (l.delete(e), t.nodes().filter((n) => n.data("type") === e).show()) : (l.add(e), t.nodes().filter((n) => n.data("type") === e).hide()), ke(l);
301
+ }, $e = (e) => {
302
+ const t = r.current;
303
+ if (!t) return;
304
+ const l = new Set(ee);
305
+ l.has(e) ? (l.delete(e), t.edges().filter((n) => n.data("name") === e).show()) : (l.add(e), t.edges().filter((n) => n.data("name") === e).hide()), De(l);
306
+ }, Ze = () => {
307
+ const e = r.current;
308
+ e.remove(e.elements());
309
+ }, qe = () => {
310
+ Y(!X);
311
+ }, Ke = (e) => {
312
+ var c, d;
313
+ const t = r.current;
314
+ if (!t) return;
315
+ console.log("saveNodeConfig values:", e), console.log("showLabel value:", e.showLabel);
316
+ const l = typeof e.fontColor == "object" && ((d = (c = e.fontColor) == null ? void 0 : c.toHexString) == null ? void 0 : d.call(c)) || e.fontColor, n = e.showLabel === "show";
317
+ console.log("showLabelValue:", n), t.nodes().forEach((p) => {
318
+ const g = n && (p.data("name") || p.data("label")) || "";
319
+ console.log("Setting node label:", g), p.style({
320
+ width: e.nodeSize,
321
+ height: e.nodeSize,
322
+ "font-size": e.fontSize,
323
+ color: l || H.nodeLabelColor,
324
+ "font-weight": e.fontWeight,
325
+ "font-style": e.fontStyle,
326
+ "text-valign": e.textPosition,
327
+ "text-halign": "center",
328
+ "text-margin-y": e.textOffset,
329
+ label: g,
330
+ "text-opacity": g ? 1 : 0
331
+ });
332
+ }), T.success("节点配置保存成功");
333
+ }, Me = (e) => {
334
+ var p, g, i, C, h, a;
335
+ const t = r.current;
336
+ if (!t) return;
337
+ console.log("saveEdgeConfig values:", e), console.log("edge showLabel value:", e.showLabel);
338
+ const l = typeof e.edgeColor == "object" && ((g = (p = e.edgeColor) == null ? void 0 : p.toHexString) == null ? void 0 : g.call(p)) || e.edgeColor, n = typeof e.fontColor == "object" && ((C = (i = e.fontColor) == null ? void 0 : i.toHexString) == null ? void 0 : C.call(i)) || e.fontColor, c = typeof e.labelBgColor == "object" && ((a = (h = e.labelBgColor) == null ? void 0 : h.toHexString) == null ? void 0 : a.call(h)) || e.labelBgColor, d = e.showLabel === "show";
339
+ t.edges().forEach((s) => {
340
+ const w = d && (s.data("label") || s.data("name")) || "";
341
+ console.log("Setting edge label:", w), s.style({
342
+ width: e.edgeWidth,
343
+ "line-color": l || z.edgeDefaultColor,
344
+ "target-arrow-color": l || z.edgeDefaultColor,
345
+ "target-arrow-shape": e.showArrow === "show" ? "triangle" : "none",
346
+ "font-size": e.fontSize,
347
+ color: n || z.edgeLabelColor,
348
+ "font-weight": e.fontWeight,
349
+ "font-style": e.fontStyle,
350
+ label: w,
351
+ "text-opacity": w ? 1 : 0,
352
+ "text-background-color": c || "transparent",
353
+ "text-background-opacity": c ? 1 : 0,
354
+ "text-background-padding": "2px"
158
355
  });
159
- if (x.length > 0 || g.length > 0) {
160
- const t = x.add(g);
161
- a = a.union(t).union(b).union(u), r += t.length, b.addClass("path-node"), u.addClass("path-node"), t.addClass("path-edge"), i.push(b.data("name"), u.data("name")), console.log(`找到直接连接的边:正向${x.length}条,反向${g.length}条`);
162
- } else {
163
- const t = e.elements().aStar({
164
- root: b,
165
- goal: u,
166
- directed: !1
167
- });
168
- if (t.found && t.path) {
169
- a = a.union(t.path), r += t.distance, t.path.nodes().addClass("path-node"), t.path.edges().addClass("path-edge");
170
- const m = t.path.nodes().map((h) => h.data("name"));
171
- i.push(...m);
172
- } else {
173
- l = !1, console.log(`节点 ${o[p]} ${o[p + 1]} 之间没有路径`);
174
- break;
356
+ }), T.success("连线配置保存成功");
357
+ }, Qe = bt(F), _ = F === "left" || F === "right";
358
+ return console.log(1e3, K), /* @__PURE__ */ f($, { children: [
359
+ /* @__PURE__ */ o("div", { className: j("graph-bar", { "graph-bar-vertical": _ }), style: Qe, children: /* @__PURE__ */ o("div", { className: j("graph-bar-min", {
360
+ "graph-bar-min-vertical": _
361
+ }), children: K.map(({ key: e, title: t, icon: l, onClick: n }) => {
362
+ var g, i, C, h;
363
+ const c = () => l && l.length > 0 ? l.length > 1 ? /* @__PURE__ */ o(x, { gap: "5px", children: l.map((a, s) => e === "nodeZoom" ? Z.cloneElement(a, {
364
+ onClick: () => He(s === 0 ? "in" : "out"),
365
+ key: s
366
+ }) : e === "canvasZoom" ? Z.cloneElement(a, {
367
+ onClick: () => Ee(s === 0 ? "in" : "out"),
368
+ key: s
369
+ }) : Z.cloneElement(a, { key: s })) }) : /* @__PURE__ */ o(x, { gap: "5px", children: l }) : null, d = (a) => {
370
+ switch (console.log(444, e, a), e) {
371
+ case "queryStatistics":
372
+ Le(!B);
373
+ break;
374
+ case "graphDisplaySettings":
375
+ qe();
376
+ break;
377
+ case "hideAttributes":
378
+ Fe();
379
+ break;
380
+ case "clearCanvas":
381
+ Ze();
382
+ break;
383
+ default:
384
+ a == null || a(r);
385
+ }
386
+ };
387
+ if (["layout", "analysis", "select", "downloadData", "textPosition"].includes(e)) {
388
+ let a = [];
389
+ switch (e) {
390
+ case "layout":
391
+ a = (g = rt) == null ? void 0 : g.map((s) => ({
392
+ ...s,
393
+ label: /* @__PURE__ */ o("div", { className: j({ "text-[#145afd]": ue === s.key }), onClick: q(Ve, s.key), children: s.label })
394
+ }));
395
+ break;
396
+ case "analysis":
397
+ a = at.map((s) => ({
398
+ ...s,
399
+ label: /* @__PURE__ */ o("div", { onClick: (w) => {
400
+ switch (w.stopPropagation(), s.key) {
401
+ case "query":
402
+ Ie();
403
+ break;
404
+ case "link":
405
+ je();
406
+ break;
407
+ case "path":
408
+ oe();
409
+ break;
410
+ }
411
+ }, children: s.label })
412
+ }));
413
+ break;
414
+ case "select":
415
+ a = (i = st) == null ? void 0 : i.map((s) => ({ ...s, label: /* @__PURE__ */ o("div", { onClick: q(Ae, s.key), children: s.label }) }));
416
+ break;
417
+ case "downloadData":
418
+ a = (C = nt) == null ? void 0 : C.map((s) => ({ ...s, label: /* @__PURE__ */ o("div", { onClick: (w) => ze(w, s.key), children: s.label }) }));
419
+ break;
420
+ case "textPosition":
421
+ a = (h = he) == null ? void 0 : h.map((s) => ({ ...s, label: /* @__PURE__ */ o("div", { onClick: q(() => lt(r, s.key), s.key), children: s.label }) }));
422
+ break;
175
423
  }
424
+ return /* @__PURE__ */ o(Re, { trigger: ["hover"], placement: _ ? "bottomRight" : "bottom", menu: { items: a }, children: /* @__PURE__ */ f(x, { wrap: !0, align: "center", justify: "center", className: "hove-active cursor", children: [
425
+ c(),
426
+ /* @__PURE__ */ o(x, { className: "w-100 ", justify: "center", children: t })
427
+ ] }) }, e);
176
428
  }
177
- }
178
- if (l && a.length > 0) {
179
- const p = a.nodes(), y = a.edges();
180
- p.addClass("path-node"), y.addClass("path-edge"), s && (e.nodes().not(p).addClass("grayed"), e.edges().not(y).addClass("grayed"));
181
- } else
182
- C.warning("无法找到完整的路径!");
183
- } catch (a) {
184
- console.error(2e3, "计算路径时出错:", a), C.warning("计算路径时出错,请重试!");
185
- }
186
- }, T = (c) => {
187
- const o = c.nodes().map((n) => ({
188
- data: n.data(),
189
- position: n.position(),
190
- style: {
191
- width: n.style("width"),
192
- height: n.style("height"),
193
- backgroundColor: n.style("background-color")
194
- }
195
- })), s = c.edges().map((n) => ({
196
- data: n.data(),
197
- style: {
198
- width: n.style("width"),
199
- "line-color": n.style("line-color"),
200
- "target-arrow-color": n.style("target-arrow-color")
201
- }
202
- }));
203
- return { nodes: o, edges: s };
204
- }, ae = (c) => {
205
- const o = T(c), s = new Blob([JSON.stringify(o, null, 2)], { type: "application/json" }), e = URL.createObjectURL(s), n = document.createElement("a");
206
- n.href = e, n.download = `graph-data-${Date.now()}.json`, n.click(), URL.revokeObjectURL(e);
207
- }, se = [
208
- {
209
- label: "网络布局",
210
- key: "cose-bilkent"
211
- },
212
- {
213
- label: "弹性布局",
214
- key: "fcose"
215
- },
216
- {
217
- label: "网格布局",
218
- key: "grid"
219
- },
220
- {
221
- label: "球面布局",
222
- key: "circle"
223
- },
224
- {
225
- label: "层级布局",
226
- key: "breadthfirst"
227
- },
228
- {
229
- label: "同心圆布局",
230
- key: "concentric"
231
- }
232
- ], le = [
233
- {
234
- label: "查询节点",
235
- key: "query",
236
- func: "queryNode"
237
- },
238
- {
239
- label: "连接分析",
240
- key: "link",
241
- func: "onLevelClick"
242
- },
243
- {
244
- label: "路径分析",
245
- key: "path",
246
- func: "pathAnalysis"
247
- }
248
- ], re = [
249
- {
250
- label: "全选",
251
- key: "all"
252
- },
253
- {
254
- label: "反选",
255
- key: "reverse"
256
- },
257
- {
258
- label: "点选模式",
259
- key: "click"
260
- },
261
- {
262
- label: "框选模式",
263
- key: "box"
264
- }
265
- ], ie = [
266
- {
267
- label: "下载JSON",
268
- key: "downloadJson"
269
- },
270
- {
271
- label: "预览JSON列表",
272
- key: "previewJsonList"
273
- },
274
- {
275
- label: "下载EXCEL",
276
- key: "downloadExcel"
277
- },
278
- // {
279
- // label: '预览数据列表',
280
- // key: 'previewDataList'
281
- // },
282
- {
283
- label: "下载JPG",
284
- key: "downloadJpg"
285
- },
286
- {
287
- label: "下载PNG",
288
- key: "downloadPng"
289
- }
290
- ], ce = [
291
- {
292
- label: "居中",
293
- key: "center"
294
- },
295
- {
296
- label: "顶部",
297
- key: "top"
298
- },
299
- {
300
- label: "底部",
301
- key: "bottom"
302
- },
303
- {
304
- label: "左侧",
305
- key: "left"
306
- },
307
- {
308
- label: "右侧",
309
- key: "right"
310
- }
311
- ];
429
+ return /* @__PURE__ */ f(x, { wrap: !0, align: "center", justify: "center", className: "hove-active cursor", onClick: () => d(n), children: [
430
+ c(),
431
+ /* @__PURE__ */ o(x, { className: "w-100 ", justify: "center", children: t })
432
+ ] }, e);
433
+ }) }) }),
434
+ /* @__PURE__ */ o(mt, { isVisible: ye, searchChange: (e) => _e(e), closeQuery: () => V(!1) }),
435
+ /* @__PURE__ */ o(ut, { isVisible: Ce, analysis: (e) => it(r, { pathNodes: e }), closePath: () => P(!1) }),
436
+ /* @__PURE__ */ o(pt, { ref: O, onLevelClick: We }),
437
+ /* @__PURE__ */ o(
438
+ et,
439
+ {
440
+ title: "JSON预览",
441
+ open: xe,
442
+ onCancel: () => U(!1),
443
+ footer: null,
444
+ width: 800,
445
+ children: /* @__PURE__ */ o("pre", { style: { maxHeight: "60vh", overflow: "auto", background: "#f5f5f5", padding: "16px", borderRadius: "4px" }, children: G ? JSON.stringify(G, null, 2) : "暂无数据" })
446
+ }
447
+ ),
448
+ /* @__PURE__ */ o(
449
+ tt,
450
+ {
451
+ title: "图显示设置",
452
+ placement: "right",
453
+ open: X,
454
+ onClose: () => Y(!1),
455
+ mask: !1,
456
+ size: 300,
457
+ styles: {
458
+ body: { height: "calc(100vh - 55px)", display: "flex", flexDirection: "column", padding: "10px" },
459
+ header: { position: "sticky", top: 0, background: "#fff", zIndex: 10 },
460
+ content: { display: "flex", flexDirection: "column" }
461
+ },
462
+ getContainer: !1,
463
+ children: /* @__PURE__ */ o(
464
+ re,
465
+ {
466
+ activeKey: Se,
467
+ onChange: Ne,
468
+ style: { flex: 1, overflow: "auto" },
469
+ tabBarStyle: { padding: "0 16px", margin: 0, background: "#fff", position: "sticky", top: 0, zIndex: 10 },
470
+ items: [
471
+ {
472
+ label: "节点设置",
473
+ key: "node",
474
+ children: /* @__PURE__ */ o(wt, { onSave: Ke, colors: H })
475
+ },
476
+ {
477
+ label: "连线设置",
478
+ key: "edge",
479
+ children: /* @__PURE__ */ o(yt, { onSave: Me, colors: H })
480
+ }
481
+ ]
482
+ }
483
+ )
484
+ }
485
+ ),
486
+ /* @__PURE__ */ o("div", { className: j("gtaph-statics absolute", {
487
+ hidden: !B
488
+ }), children: /* @__PURE__ */ o(
489
+ re,
490
+ {
491
+ items: [
492
+ {
493
+ label: "实体",
494
+ key: "entity",
495
+ children: /* @__PURE__ */ o($, { children: Object.keys(v).length > 0 ? /* @__PURE__ */ f("div", { children: [
496
+ /* @__PURE__ */ f("p", { children: [
497
+ "实体数量:",
498
+ Object.values(v).reduce((e, t) => e + t.count, 0)
499
+ ] }),
500
+ /* @__PURE__ */ f("p", { className: "my-4px", children: [
501
+ "实体类型:",
502
+ Object.keys(v).length
503
+ ] }),
504
+ /* @__PURE__ */ o(x, { gap: "5px", justify: "start", className: "w-100", wrap: !0, children: Object.keys(v).map((e) => /* @__PURE__ */ f(x, { gap: "4px", justify: "start", className: `w-100 cursor ${R.has(e) ? "opacity-30" : ""}`, onClick: () => Je(e), children: [
505
+ /* @__PURE__ */ o("img", { className: "w-20px rounded-50", src: v[e].img, alt: "" }),
506
+ e,
507
+ "",
508
+ v[e].count
509
+ ] }, e)) })
510
+ ] }) : /* @__PURE__ */ o("span", { className: "text-[#666]", children: "暂无实体统计!" }) })
511
+ },
512
+ {
513
+ label: "关系",
514
+ key: "relation",
515
+ children: /* @__PURE__ */ o($, { children: ((ne = Object.keys(D)) == null ? void 0 : ne.length) > 0 ? /* @__PURE__ */ f("div", { children: [
516
+ /* @__PURE__ */ f("div", { children: [
517
+ "关系数量:",
518
+ (se = Object.keys(D)) == null ? void 0 : se.length
519
+ ] }),
520
+ /* @__PURE__ */ f("div", { className: "my-4px", children: [
521
+ "关系类型:",
522
+ (ae = Object.values(D)) == null ? void 0 : ae.reduce((e, t) => e + t, 0)
523
+ ] }),
524
+ /* @__PURE__ */ o(x, { gap: "5px", justify: "start", className: "w-100", wrap: !0, children: Object.keys(D).map((e) => /* @__PURE__ */ f(x, { gap: "4px", className: `w-100 cursor ${ee.has(e) ? "opacity-30" : ""}`, onClick: () => $e(e), children: [
525
+ e,
526
+ ":",
527
+ D[e]
528
+ ] }, e)) })
529
+ ] }) : /* @__PURE__ */ o("span", { className: "text-[#666]", children: "暂无关系统计!" }) })
530
+ }
531
+ ]
532
+ }
533
+ ) })
534
+ ] });
535
+ }), wt = ({ onSave: b, colors: r }) => {
536
+ const [S] = u.useForm();
537
+ return /* @__PURE__ */ f(u, { form: S, layout: "vertical", onFinish: b, className: "setting-form", children: [
538
+ /* @__PURE__ */ f("div", { className: "setting-form-content", children: [
539
+ /* @__PURE__ */ o(u.Item, { label: "节点大小", name: "nodeSize", initialValue: 80, children: /* @__PURE__ */ o(I, { type: "number", placeholder: "请输入节点大小" }) }),
540
+ /* @__PURE__ */ o(u.Item, { label: "显示标签", name: "showLabel", initialValue: "show", children: /* @__PURE__ */ f(m, { children: [
541
+ /* @__PURE__ */ o(m.Option, { value: "show", children: "显示" }),
542
+ /* @__PURE__ */ o(m.Option, { value: "hide", children: "隐藏" })
543
+ ] }) }),
544
+ /* @__PURE__ */ o(u.Item, { label: "字体位置", name: "textPosition", initialValue: "bottom", children: /* @__PURE__ */ o(m, { children: he.map((v) => /* @__PURE__ */ o(m.Option, { value: v.key, children: v.label }, v.key)) }) }),
545
+ /* @__PURE__ */ o(u.Item, { label: "字体偏移", name: "textOffset", initialValue: 5, children: /* @__PURE__ */ o(I, { type: "number", placeholder: "请输入字体偏移量" }) }),
546
+ /* @__PURE__ */ o(u.Item, { label: "字体颜色", name: "fontColor", initialValue: r.nodeLabelColor, children: /* @__PURE__ */ o(A, { showText: !0 }) }),
547
+ /* @__PURE__ */ o(u.Item, { label: "字体大小", name: "fontSize", initialValue: r.nodeLabelFontSize, children: /* @__PURE__ */ o(I, { type: "number", placeholder: "请输入字体大小" }) }),
548
+ /* @__PURE__ */ o(u.Item, { label: "字体粗细", name: "fontWeight", initialValue: "normal", children: /* @__PURE__ */ f(m, { children: [
549
+ /* @__PURE__ */ o(m.Option, { value: "normal", children: "常规" }),
550
+ /* @__PURE__ */ o(m.Option, { value: "bold", children: "粗体" }),
551
+ /* @__PURE__ */ o(m.Option, { value: "lighter", children: "细体" })
552
+ ] }) }),
553
+ /* @__PURE__ */ o(u.Item, { label: "字体样式", name: "fontStyle", initialValue: "normal", children: /* @__PURE__ */ f(m, { children: [
554
+ /* @__PURE__ */ o(m.Option, { value: "normal", children: "默认" }),
555
+ /* @__PURE__ */ o(m.Option, { value: "italic", children: "斜体" })
556
+ ] }) })
557
+ ] }),
558
+ /* @__PURE__ */ o("div", { className: "setting-form-footer", children: /* @__PURE__ */ o(u.Item, { children: /* @__PURE__ */ o(de, { type: "primary", htmlType: "submit", block: !0, children: "保存节点配置" }) }) })
559
+ ] });
560
+ }, yt = ({ onSave: b, colors: r }) => {
561
+ const [S] = u.useForm();
562
+ return /* @__PURE__ */ f(u, { form: S, layout: "vertical", onFinish: b, className: "setting-form", children: [
563
+ /* @__PURE__ */ f("div", { className: "setting-form-content", children: [
564
+ /* @__PURE__ */ o(u.Item, { label: "连线宽度", name: "edgeWidth", initialValue: 2, children: /* @__PURE__ */ o(I, { type: "number", placeholder: "请输入连线宽度" }) }),
565
+ /* @__PURE__ */ o(u.Item, { label: "连线箭头", name: "showArrow", initialValue: "show", children: /* @__PURE__ */ f(m, { children: [
566
+ /* @__PURE__ */ o(m.Option, { value: "show", children: "显示" }),
567
+ /* @__PURE__ */ o(m.Option, { value: "hide", children: "隐藏" })
568
+ ] }) }),
569
+ /* @__PURE__ */ o(u.Item, { label: "连线颜色", name: "edgeColor", initialValue: r.edgeDefaultColor, children: /* @__PURE__ */ o(A, { showText: !0 }) }),
570
+ /* @__PURE__ */ o(u.Item, { label: "显示标签", name: "showLabel", initialValue: "show", children: /* @__PURE__ */ f(m, { children: [
571
+ /* @__PURE__ */ o(m.Option, { value: "show", children: "显示" }),
572
+ /* @__PURE__ */ o(m.Option, { value: "hide", children: "隐藏" })
573
+ ] }) }),
574
+ /* @__PURE__ */ o(u.Item, { label: "字体大小", name: "fontSize", initialValue: r.edgeLabelFontSize, children: /* @__PURE__ */ o(I, { type: "number", placeholder: "请输入字体大小" }) }),
575
+ /* @__PURE__ */ o(u.Item, { label: "字体颜色", name: "fontColor", initialValue: r.edgeLabelColor, children: /* @__PURE__ */ o(A, { showText: !0 }) }),
576
+ /* @__PURE__ */ o(u.Item, { label: "字体粗细", name: "fontWeight", initialValue: "normal", children: /* @__PURE__ */ f(m, { children: [
577
+ /* @__PURE__ */ o(m.Option, { value: "normal", children: "常规" }),
578
+ /* @__PURE__ */ o(m.Option, { value: "bold", children: "粗体" })
579
+ ] }) }),
580
+ /* @__PURE__ */ o(u.Item, { label: "字体样式", name: "fontStyle", initialValue: "normal", children: /* @__PURE__ */ f(m, { children: [
581
+ /* @__PURE__ */ o(m.Option, { value: "normal", children: "默认" }),
582
+ /* @__PURE__ */ o(m.Option, { value: "italic", children: "斜体" })
583
+ ] }) }),
584
+ /* @__PURE__ */ o(u.Item, { label: "标签背景色", name: "labelBgColor", initialValue: "#ffffff", children: /* @__PURE__ */ o(A, { showText: !0 }) })
585
+ ] }),
586
+ /* @__PURE__ */ o("div", { className: "setting-form-footer", children: /* @__PURE__ */ o(u.Item, { children: /* @__PURE__ */ o(de, { type: "primary", htmlType: "submit", block: !0, children: "保存连线配置" }) }) })
587
+ ] });
588
+ };
312
589
  export {
313
- re as choiceConfig,
314
- ae as donwnGraphData,
315
- ie as downloadData,
316
- T as getCyData,
317
- ne as handleCalcPath,
318
- L as imageMap,
319
- se as layoutCongig,
320
- le as linkAnalysis,
321
- te as resDetailData,
322
- oe as textLayout,
323
- ce as textPositionConfig
590
+ ft as actionList,
591
+ At as default
324
592
  };