react-kggraph 0.0.11 → 0.0.13
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/lib/index.es10.js +49 -165
- package/lib/index.es11.js +28 -68
- package/lib/index.es12.js +69 -29
- package/lib/index.es13.js +224 -70
- package/lib/index.es14.js +4 -224
- package/lib/index.es15.js +35 -4
- package/lib/index.es17.js +15469 -0
- package/lib/index.es18.js +49 -15462
- package/lib/index.es19.js +56 -50
- package/lib/index.es20.js +66 -57
- package/lib/index.es21.js +39 -68
- package/lib/index.es22.js +2 -40
- package/lib/index.es23.js +1 -1
- package/lib/index.es24.js +2 -2
- package/lib/index.es25.js +1 -1
- package/lib/index.es26.js +1 -1
- package/lib/index.es27.js +1 -1
- package/lib/index.es28.js +1 -1
- package/lib/index.es29.js +1 -1
- package/lib/index.es3.js +58 -59
- package/lib/index.es30.js +1 -1
- package/lib/index.es31.js +1 -1
- package/lib/index.es32.js +2 -2
- package/lib/index.es34.js +6 -0
- package/lib/index.es35.js +2 -4
- package/lib/index.es6.js +9 -9
- package/lib/index.es7.js +322 -5
- package/lib/index.es8.js +393 -294
- package/lib/index.es9.js +173 -408
- package/lib/src/components/Graph/index.d.ts +1 -1
- package/package.json +1 -1
- package/lib/index.es16.js +0 -38
- package/lib/index.es33.js +0 -4
- package/lib/index.es36.js +0 -4
package/lib/index.es3.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
import { jsx as y, jsxs as G } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as E, useState as m, useEffect as q } from "react";
|
|
3
3
|
import x from "cytoscape";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
4
|
+
import fe from "cytoscape-cose-bilkent";
|
|
5
|
+
import me from "cytoscape-cise";
|
|
6
|
+
import he from "cytoscape-fcose";
|
|
7
|
+
import ve from "storm-layout";
|
|
8
|
+
import be from "./index.es6.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import ke from "cytoscape-layout-utilities";
|
|
10
|
+
import { handleCalcPath as xe, resDetailData as A } from "./index.es7.js";
|
|
11
|
+
import { fixNodesToEdges as Ne, coseBilkentLayout as ee } from "./index.es8.js";
|
|
12
|
+
import { edgeNodeStyles as ke } from "./index.es9.js";
|
|
13
|
+
import Ce from "cytoscape-layout-utilities";
|
|
15
14
|
import { message as O } from "antd";
|
|
16
|
-
import { menuItemsConfig as
|
|
17
|
-
import { jsonStringify as w } from "./index.
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { GraphProvider as
|
|
21
|
-
import
|
|
22
|
-
x.use(
|
|
23
|
-
x.use(ye);
|
|
24
|
-
x.use(fe);
|
|
15
|
+
import { menuItemsConfig as ze } from "./index.es10.js";
|
|
16
|
+
import { jsonStringify as w } from "./index.es11.js";
|
|
17
|
+
import Ee from "./index.es12.js";
|
|
18
|
+
import we from "./index.es13.js";
|
|
19
|
+
import { GraphProvider as Le } from "./index.es14.js";
|
|
20
|
+
import Te from "./index.es15.js";
|
|
21
|
+
x.use(Ce);
|
|
25
22
|
x.use(me);
|
|
26
|
-
x.use(
|
|
27
|
-
|
|
23
|
+
x.use(he);
|
|
24
|
+
x.use(ve);
|
|
25
|
+
x.use(fe);
|
|
26
|
+
const Ze = ({ data: te, getAllGraphData: S, searchType: je, highPathAnalysis: N = [], graphInfo: f, stepNextApi: oe, knowledgeCardApi: ne }) => {
|
|
28
27
|
var Y, Z;
|
|
29
|
-
const L = E(null), [v, D] = m([]), p = E(null), F = E(null), H = 1, [
|
|
28
|
+
const L = E(null), [v, D] = m([]), p = E(null), F = E(null), H = 1, [Re, K] = m(!1), [k, I] = m({}), [T, P] = m({}), [se, de] = m("cose-bilkent"), X = E(null), J = E(null), [ae, Q] = m(["", ""]), [c, C] = m({
|
|
30
29
|
visible: !1,
|
|
31
30
|
x: 0,
|
|
32
31
|
y: 0,
|
|
@@ -37,13 +36,13 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
37
36
|
x: 0,
|
|
38
37
|
y: 0,
|
|
39
38
|
content: ""
|
|
40
|
-
}),
|
|
39
|
+
}), re = ze({ cyRef: p, setContextMenu: C, onPathAnalysis: (Y = F.current) == null ? void 0 : Y.onPathAnalysis, setPathNodes: Q });
|
|
41
40
|
q(() => {
|
|
42
|
-
(N == null ? void 0 : N.length) > 1 &&
|
|
41
|
+
(N == null ? void 0 : N.length) > 1 && xe(p, { pathNodes: N, isGrayed: !1 });
|
|
43
42
|
}, [w(N), w(v)]), q(() => {
|
|
44
43
|
S == null || S({ graphData: v, nodeStatic: k, relationStatic: T });
|
|
45
44
|
}, [w(v), w(k), w(T)]), q(() => {
|
|
46
|
-
var
|
|
45
|
+
var a;
|
|
47
46
|
if (!L.current || p.current) return;
|
|
48
47
|
const { elements: o, typeListObj: d, relationListObj: z } = A(te, { typeObj: k, graphInfo: f });
|
|
49
48
|
I(d), D(o), P(z), document.addEventListener("contextmenu", function(t) {
|
|
@@ -52,7 +51,7 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
52
51
|
const e = x({
|
|
53
52
|
container: L.current,
|
|
54
53
|
elements: o,
|
|
55
|
-
style:
|
|
54
|
+
style: ke({ elements: o }),
|
|
56
55
|
autounselectify: !1,
|
|
57
56
|
autolock: !1,
|
|
58
57
|
layout: {
|
|
@@ -60,8 +59,8 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
60
59
|
// 使用预设布局,完全依赖 position
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
|
-
if (p.current = e, ((
|
|
64
|
-
|
|
62
|
+
if (p.current = e, ((a = f == null ? void 0 : f.searchNodes) == null ? void 0 : a.length) === 2)
|
|
63
|
+
Ne(
|
|
65
64
|
e,
|
|
66
65
|
f.searchNodes[0],
|
|
67
66
|
f.searchNodes[1]
|
|
@@ -88,12 +87,12 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
88
87
|
const s = t.target;
|
|
89
88
|
s.hasClass("selected") || s.addClass("hover");
|
|
90
89
|
}), e.on("mouseover", "node", (t) => {
|
|
91
|
-
const s = t.target, n = s.renderedPosition(),
|
|
90
|
+
const s = t.target, n = s.renderedPosition(), r = s.data("name") || "";
|
|
92
91
|
s.addClass("hover"), V({
|
|
93
92
|
visible: !0,
|
|
94
93
|
x: n.x,
|
|
95
94
|
y: n.y - 60,
|
|
96
|
-
content:
|
|
95
|
+
content: r
|
|
97
96
|
});
|
|
98
97
|
}), e.on("mouseout", "node", (t) => {
|
|
99
98
|
t.target.removeClass("hover"), V((n) => ({ ...n, visible: !1 }));
|
|
@@ -110,27 +109,27 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
110
109
|
}), p.current = e, e.on("click", "node", (t) => {
|
|
111
110
|
const s = t.target;
|
|
112
111
|
e.nodes().removeClass("selected grayed highlighted"), e.edges().removeClass("selected grayed highlighted"), s.addClass("selected");
|
|
113
|
-
const
|
|
114
|
-
console.log("cy.nodes().not(relatedNodes):::",
|
|
112
|
+
const r = s.neighborhood().nodes().add(s), b = r.edgesWith(r);
|
|
113
|
+
console.log("cy.nodes().not(relatedNodes):::", r), e.nodes().not(r).addClass("grayed"), e.edges().not(b).addClass("grayed"), r.addClass("highlighted"), b.addClass("highlighted");
|
|
115
114
|
}), e.on("tap", (t) => {
|
|
116
115
|
t.target === e && (C((s) => ({ ...s, visible: !1 })), e.nodes().removeClass("grayed highlighted highlight selected correlationStyle path-node level-highlight level-selected level-grayed"), e.edges().removeClass("grayed highlighted highlight selected correlationStyle path-edge level-highlightedge level-grayed"));
|
|
117
116
|
}), () => {
|
|
118
117
|
p.current && (p.current.destroy(), p.current = null);
|
|
119
118
|
};
|
|
120
119
|
}, []);
|
|
121
|
-
const
|
|
120
|
+
const ie = async (o) => {
|
|
122
121
|
const { id: d, kgId: z } = o, e = p.current;
|
|
123
122
|
if (!e) return;
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
123
|
+
const a = e.$(`#${d}`);
|
|
124
|
+
if (!a || a.length === 0) {
|
|
126
125
|
console.error("当前节点不存在");
|
|
127
126
|
return;
|
|
128
127
|
}
|
|
129
128
|
const t = e.nodes().filter((n) => n.data("parentId") ? (n.data("parentId") === d || n.data("idLabel") === `${d}-${n.data("name")}`) && n.data("zktype") === o.zktype : !1);
|
|
130
129
|
if (t.length > 0) {
|
|
131
|
-
const n = t.map((l) => l.id()),
|
|
130
|
+
const n = t.map((l) => l.id()), r = t.connectedEdges(), b = e.edges().filter(
|
|
132
131
|
(l) => l.data("source") === d && n.includes(l.data("target"))
|
|
133
|
-
), R = e.edges().filter((l) => l.data("appendedBy") === d), B =
|
|
132
|
+
), R = e.edges().filter((l) => l.data("appendedBy") === d), B = r.merge(b).merge(R).filter((l) => l.data().zktype === o.zktype);
|
|
134
133
|
t.animate({
|
|
135
134
|
style: { opacity: 0 }
|
|
136
135
|
}, {
|
|
@@ -143,19 +142,19 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
143
142
|
if (u.group === "nodes" && n.includes((h = u.data) == null ? void 0 : h.id) && i && i === o.zktype)
|
|
144
143
|
return !1;
|
|
145
144
|
if (u.group === "edges" && i && i === o.zktype) {
|
|
146
|
-
const
|
|
147
|
-
const U =
|
|
145
|
+
const pe = Array.from(R).map((ye) => {
|
|
146
|
+
const U = ye.data();
|
|
148
147
|
return `${U.source}-${U.target}-${U.label}`;
|
|
149
|
-
}), M = u.data,
|
|
150
|
-
return !
|
|
148
|
+
}), M = u.data, ge = pe.includes(`${M.source}-${M.target}-${M.label}`), ue = ((_ = u.data) == null ? void 0 : _.appendedBy) === d;
|
|
149
|
+
return !ge && !ue;
|
|
151
150
|
}
|
|
152
151
|
return !0;
|
|
153
152
|
}), { typeListObj: g, relationListObj: W } = A({}, { graphData: $, typeObj: {} });
|
|
154
153
|
return I(g), P(W), $;
|
|
155
|
-
}),
|
|
154
|
+
}), a.data("appendedNodes", []), a.data("isExpanded", !1);
|
|
156
155
|
}
|
|
157
156
|
}), setTimeout(() => {
|
|
158
|
-
|
|
157
|
+
a.removed() || (a.style("border-width", ""), a.style("border-color", ""));
|
|
159
158
|
}, 300);
|
|
160
159
|
} else {
|
|
161
160
|
try {
|
|
@@ -164,21 +163,21 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
164
163
|
content: "正在展开...",
|
|
165
164
|
duration: 0
|
|
166
165
|
});
|
|
167
|
-
const n = await
|
|
168
|
-
if (I(b), P(R), console.log(555e3,
|
|
166
|
+
const n = await oe({ uri: d, queryType: 1, kgId: z, zktype: o.zktype }), { elements: r, typeListObj: b, relationListObj: R } = A(n.data, { graphData: v, typeObj: k, relationObj: T, zktype: o.zktype });
|
|
167
|
+
if (I(b), P(R), console.log(555e3, r), !((r == null ? void 0 : r.length) > 0)) {
|
|
169
168
|
O.warning("暂无数据"), setTimeout(() => {
|
|
170
169
|
O.destroy();
|
|
171
170
|
}, 2e3);
|
|
172
171
|
return;
|
|
173
172
|
}
|
|
174
|
-
if ((
|
|
173
|
+
if ((r == null ? void 0 : r.length) > 0) {
|
|
175
174
|
const B = e.layoutUtilities({
|
|
176
175
|
...ee(),
|
|
177
176
|
idealEdgeLength: 80,
|
|
178
177
|
// 与你的期望边长匹配
|
|
179
178
|
offset: 30
|
|
180
179
|
// 随机偏移,避免完全重叠
|
|
181
|
-
}), l =
|
|
180
|
+
}), l = r.map((i) => {
|
|
182
181
|
if (i.group === "nodes") {
|
|
183
182
|
const h = 80 * H;
|
|
184
183
|
return {
|
|
@@ -214,7 +213,7 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
214
213
|
}), $ = e.add(l);
|
|
215
214
|
D([...v, ...l]);
|
|
216
215
|
const g = $.filter(":node"), W = g.map((i) => i.id());
|
|
217
|
-
|
|
216
|
+
a.data("appendedNodes", W), a.data("isExpanded", !0);
|
|
218
217
|
const u = e.nodes().difference(g);
|
|
219
218
|
u.forEach((i) => i.lock()), B.placeNewNodes(g), e.layout({
|
|
220
219
|
name: "cose-bilkent",
|
|
@@ -246,7 +245,7 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
246
245
|
g.style("opacity", ""), g.style("width", ""), g.style("height", "");
|
|
247
246
|
}
|
|
248
247
|
}), setTimeout(() => {
|
|
249
|
-
|
|
248
|
+
a.removed() || (a.style("border-width", ""), a.style("border-color", ""), e.center(a), e.zoom(e.zoom()));
|
|
250
249
|
}, 600);
|
|
251
250
|
} else
|
|
252
251
|
console.log("没有找到相关节点数据");
|
|
@@ -256,16 +255,16 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
256
255
|
K(!1), O.destroy();
|
|
257
256
|
}
|
|
258
257
|
C({ visible: !1 });
|
|
259
|
-
},
|
|
258
|
+
}, le = {
|
|
260
259
|
expanded: "typed-literal",
|
|
261
260
|
contract: "uri"
|
|
262
|
-
},
|
|
261
|
+
}, ce = (o) => {
|
|
263
262
|
if (console.log("handleMenuAction:::", o), c.targetNode) {
|
|
264
263
|
const d = o.ids, z = c.targetNode.data();
|
|
265
264
|
if (["expanded", "contract"].includes(d))
|
|
266
|
-
|
|
265
|
+
ie({ kgId: 3, ...z, zktype: le[d] });
|
|
267
266
|
else if (d === "nodeInfo") {
|
|
268
|
-
const e = c.targetNode,
|
|
267
|
+
const e = c.targetNode, a = {
|
|
269
268
|
id: e.id(),
|
|
270
269
|
data: e.data(),
|
|
271
270
|
position: e.position(),
|
|
@@ -276,7 +275,7 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
276
275
|
// 样式信息
|
|
277
276
|
style: e.style()
|
|
278
277
|
};
|
|
279
|
-
X.current.open(
|
|
278
|
+
X.current.open(a);
|
|
280
279
|
} else if (d === "knowledgeCard") {
|
|
281
280
|
const e = c.targetNode;
|
|
282
281
|
J.current.open(e.data());
|
|
@@ -284,10 +283,10 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
284
283
|
o.action(c.targetNode), C({ visible: !1, x: 0, y: 0, targetNode: null });
|
|
285
284
|
}
|
|
286
285
|
};
|
|
287
|
-
return /* @__PURE__ */ y(
|
|
286
|
+
return /* @__PURE__ */ y(Le, { value: { pathNodes: ae, setPathNodes: Q, graphInfo: f, graphData: v, layoutType: se, setLayoutType: de, knowledgeCardApi: ne }, children: /* @__PURE__ */ G("div", { className: "cytoscape-container", style: { position: "relative" }, children: [
|
|
288
287
|
/* @__PURE__ */ y("div", { className: "btn-group" }),
|
|
289
288
|
/* @__PURE__ */ y(
|
|
290
|
-
|
|
289
|
+
be,
|
|
291
290
|
{
|
|
292
291
|
ref: F,
|
|
293
292
|
cyRef: p,
|
|
@@ -320,7 +319,7 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
320
319
|
overflow: "hidden"
|
|
321
320
|
},
|
|
322
321
|
onClick: (o) => o.stopPropagation(),
|
|
323
|
-
children: /* @__PURE__ */ y(
|
|
322
|
+
children: /* @__PURE__ */ y(Ee, { items: re, centerImage: (Z = c == null ? void 0 : c.targetNode) == null ? void 0 : Z.data().image, onClick: (o) => ce(o) })
|
|
324
323
|
}
|
|
325
324
|
),
|
|
326
325
|
j.visible && /* @__PURE__ */ y(
|
|
@@ -347,8 +346,8 @@ const Ze = ({ data: te, getAllGraphData: S, searchType: Te, highPathAnalysis: N
|
|
|
347
346
|
}
|
|
348
347
|
)
|
|
349
348
|
] }),
|
|
350
|
-
/* @__PURE__ */ y(
|
|
351
|
-
/* @__PURE__ */ y(
|
|
349
|
+
/* @__PURE__ */ y(we, { ref: X }),
|
|
350
|
+
/* @__PURE__ */ y(Te, { ref: J })
|
|
352
351
|
] }) });
|
|
353
352
|
};
|
|
354
353
|
export {
|