react-kggraph 0.0.17 → 0.0.19

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