react-kggraph 0.0.8 → 0.0.9

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 (67) hide show
  1. package/lib/index.es.js +8 -4
  2. package/lib/index.es10.js +188 -0
  3. package/lib/index.es11.js +72 -0
  4. package/lib/index.es12.js +32 -0
  5. package/lib/index.es13.js +72 -0
  6. package/lib/index.es14.js +226 -0
  7. package/lib/index.es15.js +6 -0
  8. package/lib/index.es16.js +38 -0
  9. package/lib/index.es18.js +15469 -0
  10. package/lib/index.es19.js +56 -0
  11. package/lib/index.es20.js +62 -0
  12. package/lib/index.es21.js +71 -0
  13. package/lib/index.es22.js +42 -0
  14. package/lib/index.es23.js +4 -0
  15. package/lib/index.es24.js +4 -0
  16. package/lib/index.es25.js +4 -0
  17. package/lib/index.es26.js +4 -0
  18. package/lib/index.es27.js +4 -0
  19. package/lib/index.es28.js +4 -0
  20. package/lib/index.es29.js +4 -0
  21. package/lib/index.es3.js +356 -0
  22. package/lib/index.es30.js +4 -0
  23. package/lib/index.es31.js +4 -0
  24. package/lib/index.es32.js +4 -0
  25. package/lib/index.es33.js +4 -0
  26. package/lib/index.es35.js +6 -0
  27. package/lib/index.es36.js +4 -0
  28. package/lib/index.es4.js +8 -0
  29. package/lib/index.es5.js +4 -0
  30. package/lib/index.es6.js +601 -0
  31. package/lib/index.es7.js +7 -0
  32. package/lib/index.es8.js +324 -0
  33. package/lib/index.es9.js +423 -0
  34. package/lib/style.css +1 -0
  35. package/package.json +2 -3
  36. package/lib/index10.es.js +0 -4
  37. package/lib/index11.es.js +0 -4
  38. package/lib/index12.es.js +0 -4
  39. package/lib/index13.es.js +0 -4
  40. package/lib/index14.es.js +0 -4
  41. package/lib/index15.es.js +0 -4
  42. package/lib/index16.es.js +0 -4
  43. package/lib/index17.es.js +0 -25
  44. package/lib/index18.es.js +0 -330
  45. package/lib/index19.es.js +0 -5
  46. package/lib/index2.es.js +0 -13
  47. package/lib/index20.es.js +0 -284
  48. package/lib/index22.es.js +0 -70
  49. package/lib/index24.es.js +0 -68
  50. package/lib/index26.es.js +0 -72
  51. package/lib/index27.es.js +0 -32
  52. package/lib/index28.es.js +0 -828
  53. package/lib/index29.es.js +0 -4
  54. package/lib/index30.es.js +0 -161
  55. package/lib/index31.es.js +0 -71
  56. package/lib/index33.es.js +0 -100
  57. package/lib/index34.es.js +0 -250
  58. package/lib/index35.es.js +0 -47
  59. package/lib/index36.es.js +0 -376
  60. package/lib/index37.es.js +0 -12
  61. package/lib/index38.es.js +0 -6
  62. package/lib/index5.es.js +0 -12387
  63. package/lib/index6.es.js +0 -4
  64. package/lib/index7.es.js +0 -4
  65. package/lib/index8.es.js +0 -4
  66. package/lib/index9.es.js +0 -4
  67. package/lib/react-kggraph.css +0 -2
@@ -0,0 +1,324 @@
1
+ import { message as C } from "antd";
2
+ import j from "./index.es23.js";
3
+ import I from "./index.es24.js";
4
+ import P from "./index.es25.js";
5
+ import $ from "./index.es26.js";
6
+ import D from "./index.es27.js";
7
+ import J from "./index.es28.js";
8
+ import N from "./index.es29.js";
9
+ import R from "./index.es30.js";
10
+ import q from "./index.es31.js";
11
+ import A from "./index.es32.js";
12
+ import B from "./index.es33.js";
13
+ import { jsonStringifyParse as U } from "./index.es12.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 } });
71
+ });
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"
115
+ };
116
+ break;
117
+ case "bottom":
118
+ e = {
119
+ ...e,
120
+ "text-halign": "center",
121
+ "text-valign": "bottom",
122
+ "text-margin-y": "5px"
123
+ };
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());
144
+ else {
145
+ e.nodes().removeClass("path-node"), e.edges().removeClass("path-edge"), C.warning(`找不到节点:${a}`);
146
+ return;
147
+ }
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;
158
+ });
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;
175
+ }
176
+ }
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
+ ];
312
+ 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
324
+ };