react-kggraph 0.0.22 → 0.0.24
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 +20 -19
- package/lib/index.es14.js +39 -41
- package/lib/index.es16.js +20 -20
- package/lib/index.es17.js +42 -0
- package/lib/index.es18.js +3 -15466
- package/lib/index.es19.js +2 -54
- package/lib/index.es21.js +15461 -63
- package/lib/index.es22.js +53 -39
- package/lib/index.es23.js +60 -2
- package/lib/index.es24.js +69 -2
- package/lib/index.es25.js +2 -2
- package/lib/index.es26.js +2 -2
- 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 +100 -97
- package/lib/index.es30.js +1 -1
- package/lib/index.es31.js +1 -1
- package/lib/index.es32.js +1 -1
- package/lib/index.es33.js +2 -2
- package/lib/index.es34.js +4 -0
- package/lib/index.es35.js +2 -4
- package/lib/index.es37.js +66 -0
- package/lib/index.es38.js +1049 -0
- package/lib/index.es4.js +13 -9
- package/lib/index.es42.js +21 -0
- package/lib/index.es43.js +43 -0
- package/lib/index.es44.js +42 -0
- package/lib/index.es45.js +91 -0
- package/lib/index.es46.js +58 -0
- package/lib/index.es47.js +33 -0
- package/lib/index.es49.js +72 -0
- package/lib/index.es7.js +305 -305
- package/lib/index.es8.js +11 -11
- package/lib/src/components/Graph/components/ActionBar/actionList.d.ts +4 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/AudioSection.d.ts +12 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/DocumentSection.d.ts +12 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/ImageSection.d.ts +12 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/ListCard.d.ts +14 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/PropertySection.d.ts +11 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/RelationSection.d.ts +13 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/SourceCard.d.ts +6 -0
- package/lib/src/components/Graph/components/KnowledgeCard/components/VideoSection.d.ts +12 -0
- package/lib/src/components/Graph/components/KnowledgeCard/data.d.ts +84 -0
- package/lib/src/components/Graph/types.d.ts +7 -1
- package/lib/src/components/Graph/utils/edge_node_styles.d.ts +1 -0
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/lib/index.es20.js +0 -62
- package/lib/index.es36.js +0 -4
package/lib/index.es3.js
CHANGED
|
@@ -1,84 +1,88 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as N, useState as v, useEffect as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { jsx as h, jsxs as oe } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as N, useState as v, useEffect as O } from "react";
|
|
3
|
+
import C from "cytoscape";
|
|
4
|
+
import Ce from "cytoscape-cose-bilkent";
|
|
5
|
+
import ze from "cytoscape-cise";
|
|
6
|
+
import Ee from "cytoscape-fcose";
|
|
7
|
+
import we from "storm-layout";
|
|
8
|
+
import Le from "./index.es7.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import { handleCalcPath as
|
|
11
|
-
import { fixNodesToEdges as
|
|
12
|
-
import { edgeNodeStyles as
|
|
13
|
-
import
|
|
14
|
-
import { message as
|
|
15
|
-
import { menuItemsConfig as
|
|
10
|
+
import { handleCalcPath as Re, resDetailData as F } from "./index.es8.js";
|
|
11
|
+
import { fixNodesToEdges as je, coseBilkentLayout as ne } from "./index.es9.js";
|
|
12
|
+
import { edgeNodeStyles as Te, defaultColors as se, nodeSize as $e } from "./index.es10.js";
|
|
13
|
+
import De from "cytoscape-layout-utilities";
|
|
14
|
+
import { message as k } from "antd";
|
|
15
|
+
import { menuItemsConfig as Se } from "./index.es11.js";
|
|
16
16
|
import { jsonStringify as R } from "./index.es12.js";
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { GraphProvider as
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
import Oe from "./index.es13.js";
|
|
18
|
+
import Ie from "./index.es14.js";
|
|
19
|
+
import { GraphProvider as Pe } from "./index.es15.js";
|
|
20
|
+
import Be from "./index.es16.js";
|
|
21
|
+
import We from "./index.es17.js";
|
|
22
|
+
C.use(De);
|
|
23
|
+
C.use(ze);
|
|
24
|
+
C.use(Ee);
|
|
25
|
+
C.use(we);
|
|
26
|
+
C.use(Ce);
|
|
27
|
+
const it = ({
|
|
27
28
|
data: de,
|
|
28
29
|
getAllGraphData: I,
|
|
29
30
|
highPathAnalysis: z = [],
|
|
30
|
-
graphInfo:
|
|
31
|
+
graphInfo: u,
|
|
31
32
|
stepNextApi: re,
|
|
32
33
|
knowledgeCardApi: ae,
|
|
33
34
|
colors: E,
|
|
34
35
|
actionBar: ie,
|
|
35
36
|
actionCircle: le,
|
|
36
|
-
|
|
37
|
+
queryStatisticsConfig: ce = ["实体", "关系"],
|
|
38
|
+
className: pe,
|
|
39
|
+
noDataDesc: He = "暂无数据"
|
|
37
40
|
}) => {
|
|
38
41
|
var _, G, ee;
|
|
39
|
-
const j = N(null), [c, P] = v([]), p = N(null), K = N(null), X = 1, [
|
|
40
|
-
|
|
42
|
+
const j = N(null), [c, P] = v([]), p = N(null), K = N(null), X = 1, [Me, Z] = v(!1), [w, B] = v({}), [T, W] = v({}), [ue, ge] = v("cose-bilkent"), J = N(null), Q = N(null), [ye, V] = v(["", ""]), H = N(E);
|
|
43
|
+
O(() => {
|
|
41
44
|
H.current = E;
|
|
42
45
|
}, [E]);
|
|
43
|
-
const [
|
|
46
|
+
const [g, L] = v({
|
|
44
47
|
visible: !1,
|
|
45
48
|
x: 0,
|
|
46
49
|
y: 0,
|
|
47
50
|
targetNode: null,
|
|
48
51
|
bgColor: ""
|
|
49
|
-
}), [$,
|
|
52
|
+
}), [$, Y] = v({
|
|
50
53
|
visible: !1,
|
|
51
54
|
x: 0,
|
|
52
55
|
y: 0,
|
|
53
56
|
content: ""
|
|
54
|
-
}),
|
|
55
|
-
|
|
56
|
-
(z == null ? void 0 : z.length) > 1 &&
|
|
57
|
-
}, [R(z), R(c)]),
|
|
57
|
+
}), fe = Se({ cyRef: p, setContextMenu: L, onPathAnalysis: (_ = K.current) == null ? void 0 : _.onPathAnalysis, setPathNodes: V, actionCircle: le });
|
|
58
|
+
O(() => {
|
|
59
|
+
(z == null ? void 0 : z.length) > 1 && Re(p, { pathNodes: z, isGrayed: !1 });
|
|
60
|
+
}, [R(z), R(c)]), O(() => {
|
|
58
61
|
I == null || I({ graphData: c, nodeStatic: w, relationStatic: T });
|
|
59
|
-
}, [R(c), R(w), R(T)]),
|
|
62
|
+
}, [R(c), R(w), R(T)]), O(() => {
|
|
60
63
|
var r;
|
|
61
64
|
if (!j.current || p.current) return;
|
|
62
|
-
const { elements: s, typeListObj: a, relationListObj:
|
|
63
|
-
B(a), P(s), W(
|
|
65
|
+
const { elements: s, typeListObj: a, relationListObj: y } = F(de, { typeObj: w, graphInfo: u });
|
|
66
|
+
B(a), P(s), W(y), document.addEventListener("contextmenu", function(t) {
|
|
64
67
|
t.preventDefault();
|
|
65
68
|
});
|
|
66
|
-
const e =
|
|
69
|
+
const e = C({
|
|
67
70
|
container: j.current,
|
|
68
71
|
elements: s,
|
|
69
|
-
style:
|
|
72
|
+
style: Te({ elements: s, colors: E }),
|
|
70
73
|
autounselectify: !1,
|
|
71
74
|
autolock: !1,
|
|
75
|
+
maxZoom: 1,
|
|
72
76
|
layout: {
|
|
73
77
|
name: "preset"
|
|
74
78
|
// 使用预设布局,完全依赖 position
|
|
75
79
|
}
|
|
76
80
|
});
|
|
77
|
-
if (p.current = e, ((r =
|
|
78
|
-
|
|
81
|
+
if (p.current = e, ((r = u == null ? void 0 : u.searchNodes) == null ? void 0 : r.length) === 2)
|
|
82
|
+
je(
|
|
79
83
|
e,
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
u.searchNodes[0],
|
|
85
|
+
u.searchNodes[1]
|
|
82
86
|
);
|
|
83
87
|
else {
|
|
84
88
|
const t = e.layout(ne());
|
|
@@ -113,14 +117,14 @@ const nt = ({
|
|
|
113
117
|
o.hasClass("selected") || o.addClass("hover");
|
|
114
118
|
}), e.on("mouseover", "node", (t) => {
|
|
115
119
|
const o = t.target, n = o.renderedPosition(), d = o.data("name") || "";
|
|
116
|
-
o.addClass("hover"),
|
|
120
|
+
o.addClass("hover"), Y({
|
|
117
121
|
visible: !0,
|
|
118
122
|
x: n.x,
|
|
119
123
|
y: n.y - 60,
|
|
120
124
|
content: d
|
|
121
125
|
});
|
|
122
126
|
}), e.on("mouseout", "node", (t) => {
|
|
123
|
-
t.target.removeClass("hover"),
|
|
127
|
+
t.target.removeClass("hover"), Y((n) => ({ ...n, visible: !1 }));
|
|
124
128
|
}), e.on("cxttap", "node", (t) => {
|
|
125
129
|
t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), t.originalEvent && (t.originalEvent.preventDefault(), t.originalEvent.stopPropagation(), t.originalEvent.stopImmediatePropagation());
|
|
126
130
|
const o = t.target, n = o.renderedPosition();
|
|
@@ -142,8 +146,8 @@ const nt = ({
|
|
|
142
146
|
p.current && (p.current.destroy(), p.current = null);
|
|
143
147
|
};
|
|
144
148
|
}, []);
|
|
145
|
-
const
|
|
146
|
-
const { id: a, kgId:
|
|
149
|
+
const me = async (s) => {
|
|
150
|
+
const { id: a, kgId: y } = s, e = p.current;
|
|
147
151
|
if (!e) return;
|
|
148
152
|
const r = e.$(`#${a}`);
|
|
149
153
|
if (!r || r.length === 0) {
|
|
@@ -161,21 +165,21 @@ const nt = ({
|
|
|
161
165
|
duration: 200,
|
|
162
166
|
complete: () => {
|
|
163
167
|
e.remove(t), e.remove(M), P((l) => {
|
|
164
|
-
const
|
|
168
|
+
const S = l.filter((m) => {
|
|
165
169
|
var b, te;
|
|
166
|
-
const i =
|
|
167
|
-
if (
|
|
170
|
+
const i = m.data.zktype;
|
|
171
|
+
if (m.group === "nodes" && n.includes((b = m.data) == null ? void 0 : b.id) && i && i === s.zktype)
|
|
168
172
|
return !1;
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
const A =
|
|
173
|
+
if (m.group === "edges" && i && i === s.zktype) {
|
|
174
|
+
const be = Array.from(D).map((ke) => {
|
|
175
|
+
const A = ke.data();
|
|
172
176
|
return `${A.source}-${A.target}-${A.label}`;
|
|
173
|
-
}), q =
|
|
174
|
-
return !
|
|
177
|
+
}), q = m.data, xe = be.includes(`${q.source}-${q.target}-${q.label}`), Ne = ((te = m.data) == null ? void 0 : te.appendedBy) === a;
|
|
178
|
+
return !xe && !Ne;
|
|
175
179
|
}
|
|
176
180
|
return !0;
|
|
177
|
-
}), { typeListObj:
|
|
178
|
-
return B(
|
|
181
|
+
}), { typeListObj: f, relationListObj: U } = F({}, { graphData: S, typeObj: {} });
|
|
182
|
+
return B(f), W(U), S;
|
|
179
183
|
}), r.data("appendedNodes", []), r.data("isExpanded", !1);
|
|
180
184
|
}
|
|
181
185
|
}), setTimeout(() => {
|
|
@@ -183,15 +187,15 @@ const nt = ({
|
|
|
183
187
|
}, 300);
|
|
184
188
|
} else {
|
|
185
189
|
try {
|
|
186
|
-
|
|
190
|
+
Z(!0), k.open({
|
|
187
191
|
type: "loading",
|
|
188
192
|
content: "正在展开...",
|
|
189
193
|
duration: 0
|
|
190
194
|
});
|
|
191
|
-
const n = await re({ uri: a, queryType: 1, kgId:
|
|
195
|
+
const n = await re({ uri: a, queryType: 1, kgId: y, zktype: s.zktype }), { elements: d, typeListObj: x, relationListObj: D } = F(n.data, { graphData: c, typeObj: w, relationObj: T, zktype: s.zktype });
|
|
192
196
|
if (B(x), W(D), !((d == null ? void 0 : d.length) > 0)) {
|
|
193
197
|
setTimeout(() => {
|
|
194
|
-
|
|
198
|
+
k.destroy(), k.warning("暂无数据");
|
|
195
199
|
}, 2e3);
|
|
196
200
|
return;
|
|
197
201
|
}
|
|
@@ -204,7 +208,7 @@ const nt = ({
|
|
|
204
208
|
// 随机偏移,避免完全重叠
|
|
205
209
|
}), l = d.map((i) => {
|
|
206
210
|
if (i.group === "nodes") {
|
|
207
|
-
const b =
|
|
211
|
+
const b = $e * X;
|
|
208
212
|
return {
|
|
209
213
|
...i,
|
|
210
214
|
style: {
|
|
@@ -235,12 +239,12 @@ const nt = ({
|
|
|
235
239
|
zktype: s.zktype
|
|
236
240
|
}
|
|
237
241
|
};
|
|
238
|
-
}),
|
|
242
|
+
}), S = e.add(l);
|
|
239
243
|
P([...c, ...l]);
|
|
240
|
-
const
|
|
244
|
+
const f = S.filter(":node"), U = f.map((i) => i.id());
|
|
241
245
|
r.data("appendedNodes", U), r.data("isExpanded", !0);
|
|
242
|
-
const
|
|
243
|
-
|
|
246
|
+
const m = e.nodes().difference(f);
|
|
247
|
+
m.forEach((i) => i.lock()), M.placeNewNodes(f), e.layout({
|
|
244
248
|
name: "cose-bilkent",
|
|
245
249
|
randomize: !1,
|
|
246
250
|
// ⚠️ 这是关键!保持已有节点位置不变
|
|
@@ -256,8 +260,8 @@ const nt = ({
|
|
|
256
260
|
// 可以适当减少,因为只需要微调
|
|
257
261
|
gravity: 0.6
|
|
258
262
|
}).run(), setTimeout(() => {
|
|
259
|
-
|
|
260
|
-
}, 2e3),
|
|
263
|
+
m.forEach((i) => i.unlock());
|
|
264
|
+
}, 2e3), f.animate({
|
|
261
265
|
style: {
|
|
262
266
|
opacity: 1,
|
|
263
267
|
width: 20,
|
|
@@ -267,33 +271,33 @@ const nt = ({
|
|
|
267
271
|
duration: 400,
|
|
268
272
|
easing: "ease-out",
|
|
269
273
|
complete: () => {
|
|
270
|
-
|
|
274
|
+
f.style("opacity", ""), f.style("width", ""), f.style("height", "");
|
|
271
275
|
}
|
|
272
276
|
}), setTimeout(() => {
|
|
273
277
|
r.removed() || (r.style("border-width", ""), r.style("border-color", ""), e.center(r), e.zoom(e.zoom()));
|
|
274
278
|
}, 600);
|
|
275
279
|
} else
|
|
276
280
|
console.log("没有找到相关节点数据");
|
|
277
|
-
|
|
281
|
+
k.destroy();
|
|
278
282
|
} catch (n) {
|
|
279
|
-
|
|
283
|
+
k.destroy(), k.error("请求接口失败"), console.error("22请求接口失败:", n);
|
|
280
284
|
}
|
|
281
|
-
|
|
285
|
+
Z(!1);
|
|
282
286
|
}
|
|
283
287
|
L({ visible: !1 });
|
|
284
|
-
},
|
|
288
|
+
}, he = {
|
|
285
289
|
expanded: "typed-literal",
|
|
286
290
|
contract: "uri"
|
|
287
|
-
},
|
|
291
|
+
}, ve = (s, a) => {
|
|
288
292
|
var e;
|
|
289
293
|
console.log("handleMenuAction:::", s, a);
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
292
|
-
const r = s.ids, t =
|
|
294
|
+
const y = a || g.targetNode;
|
|
295
|
+
if (y) {
|
|
296
|
+
const r = s.ids, t = y.data();
|
|
293
297
|
if (["expanded", "contract"].includes(r))
|
|
294
|
-
|
|
298
|
+
me({ kgId: u.kgId, ...t, zktype: he[r] });
|
|
295
299
|
else if (r === "nodeInfo") {
|
|
296
|
-
const o =
|
|
300
|
+
const o = y, n = {
|
|
297
301
|
id: o.id(),
|
|
298
302
|
data: o.data(),
|
|
299
303
|
position: o.position(),
|
|
@@ -303,36 +307,35 @@ const nt = ({
|
|
|
303
307
|
classes: o.classes(),
|
|
304
308
|
style: o.style()
|
|
305
309
|
};
|
|
306
|
-
|
|
307
|
-
} else r === "knowledgeCard" &&
|
|
308
|
-
(e = s.onClick) == null || e.call(s,
|
|
310
|
+
J.current.open(n);
|
|
311
|
+
} else r === "knowledgeCard" && Q.current.open(y.data());
|
|
312
|
+
(e = s.onClick) == null || e.call(s, y), L({ visible: !1, x: 0, y: 0, targetNode: null });
|
|
309
313
|
}
|
|
310
314
|
};
|
|
311
|
-
return console.log(111, !(((G = c == null ? void 0 : c.nodes) == null ? void 0 : G.length) > 0), c), /* @__PURE__ */
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
/* @__PURE__ */
|
|
314
|
-
|
|
315
|
+
return console.log(111, !(((G = c == null ? void 0 : c.nodes) == null ? void 0 : G.length) > 0), c), /* @__PURE__ */ h(Pe, { value: { pathNodes: ye, setPathNodes: V, graphInfo: u, graphData: c, layoutType: ue, setLayoutType: ge, knowledgeCardApi: ae, queryStatisticsConfig: ce, actionBar: ie }, children: /* @__PURE__ */ oe("div", { className: We("cytoscape-container relative", pe), children: [
|
|
316
|
+
/* @__PURE__ */ h("div", { className: "btn-group" }),
|
|
317
|
+
/* @__PURE__ */ h(
|
|
318
|
+
Le,
|
|
315
319
|
{
|
|
316
320
|
ref: K,
|
|
317
321
|
cyRef: p,
|
|
318
|
-
graphInfo:
|
|
322
|
+
graphInfo: u,
|
|
319
323
|
initNodeScale: X,
|
|
320
324
|
cyContainerRef: j,
|
|
321
325
|
typeObj: w,
|
|
322
326
|
relationObj: T,
|
|
323
|
-
colors: E
|
|
324
|
-
actionBar: ie
|
|
327
|
+
colors: E
|
|
325
328
|
}
|
|
326
329
|
),
|
|
327
330
|
/* @__PURE__ */ oe("div", { className: "relative h-100", children: [
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
|
|
331
|
+
/* @__PURE__ */ h("div", { ref: j, className: "cy-container" }),
|
|
332
|
+
g.visible && g.targetNode && /* @__PURE__ */ h(
|
|
330
333
|
"div",
|
|
331
334
|
{
|
|
332
335
|
style: {
|
|
333
336
|
position: "absolute",
|
|
334
|
-
left: `${
|
|
335
|
-
top: `${
|
|
337
|
+
left: `${g.x}px`,
|
|
338
|
+
top: `${g.y}px`,
|
|
336
339
|
// backgroundColor: 'white',
|
|
337
340
|
// border: '1px solid #ccc',
|
|
338
341
|
// borderRadius: '50%',
|
|
@@ -346,10 +349,10 @@ const nt = ({
|
|
|
346
349
|
overflow: "hidden"
|
|
347
350
|
},
|
|
348
351
|
onClick: (s) => s.stopPropagation(),
|
|
349
|
-
children: /* @__PURE__ */
|
|
352
|
+
children: /* @__PURE__ */ h(Oe, { items: fe, centerImage: (ee = g == null ? void 0 : g.targetNode) == null ? void 0 : ee.data().image, targetNode: g.targetNode, onClick: (s, a) => ve(s, a) })
|
|
350
353
|
}
|
|
351
354
|
),
|
|
352
|
-
$.visible && /* @__PURE__ */
|
|
355
|
+
$.visible && /* @__PURE__ */ h(
|
|
353
356
|
"div",
|
|
354
357
|
{
|
|
355
358
|
style: {
|
|
@@ -373,10 +376,10 @@ const nt = ({
|
|
|
373
376
|
}
|
|
374
377
|
)
|
|
375
378
|
] }),
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */
|
|
379
|
+
/* @__PURE__ */ h(Ie, { ref: J }),
|
|
380
|
+
/* @__PURE__ */ h(Be, { ref: Q })
|
|
378
381
|
] }) });
|
|
379
382
|
};
|
|
380
383
|
export {
|
|
381
|
-
|
|
384
|
+
it as default
|
|
382
385
|
};
|