react-kggraph 0.0.21 → 0.0.22
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.es3.js +85 -85
- package/package.json +1 -1
package/lib/index.es3.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as N, useState as v, useEffect as
|
|
1
|
+
import { jsx as m, jsxs as oe } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as N, useState as v, useEffect as S } from "react";
|
|
3
3
|
import k from "cytoscape";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import Ne from "cytoscape-cose-bilkent";
|
|
5
|
+
import Ce from "cytoscape-cise";
|
|
6
|
+
import ke from "cytoscape-fcose";
|
|
7
7
|
import ze from "storm-layout";
|
|
8
|
-
import
|
|
8
|
+
import Ee from "./index.es7.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import { handleCalcPath as
|
|
11
|
-
import { fixNodesToEdges as
|
|
12
|
-
import { edgeNodeStyles as
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import { menuItemsConfig as
|
|
10
|
+
import { handleCalcPath as we, resDetailData as F } from "./index.es8.js";
|
|
11
|
+
import { fixNodesToEdges as Le, coseBilkentLayout as ne } from "./index.es9.js";
|
|
12
|
+
import { edgeNodeStyles as Re, defaultColors as se } from "./index.es10.js";
|
|
13
|
+
import je from "cytoscape-layout-utilities";
|
|
14
|
+
import { message as C } from "antd";
|
|
15
|
+
import { menuItemsConfig as Te } 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
|
-
k.use(
|
|
17
|
+
import $e from "./index.es13.js";
|
|
18
|
+
import De from "./index.es14.js";
|
|
19
|
+
import { GraphProvider as Oe } from "./index.es15.js";
|
|
20
|
+
import Se from "./index.es16.js";
|
|
21
|
+
k.use(je);
|
|
22
|
+
k.use(Ce);
|
|
22
23
|
k.use(ke);
|
|
23
|
-
k.use(Ee);
|
|
24
24
|
k.use(ze);
|
|
25
|
-
k.use(
|
|
26
|
-
const
|
|
25
|
+
k.use(Ne);
|
|
26
|
+
const nt = ({
|
|
27
27
|
data: de,
|
|
28
28
|
getAllGraphData: I,
|
|
29
|
-
highPathAnalysis:
|
|
29
|
+
highPathAnalysis: z = [],
|
|
30
30
|
graphInfo: h,
|
|
31
31
|
stepNextApi: re,
|
|
32
32
|
knowledgeCardApi: ae,
|
|
33
|
-
colors:
|
|
33
|
+
colors: E,
|
|
34
34
|
actionBar: ie,
|
|
35
35
|
actionCircle: le,
|
|
36
|
-
noDataDesc:
|
|
36
|
+
noDataDesc: Ie = "暂无数据"
|
|
37
37
|
}) => {
|
|
38
38
|
var _, G, ee;
|
|
39
|
-
const j = N(null), [
|
|
40
|
-
|
|
41
|
-
H.current =
|
|
42
|
-
}, [
|
|
43
|
-
const [
|
|
39
|
+
const j = N(null), [c, P] = v([]), p = N(null), K = N(null), X = 1, [Pe, J] = v(!1), [w, B] = v({}), [T, W] = v({}), [ce, pe] = v("cose-bilkent"), Q = N(null), V = N(null), [ue, Y] = v(["", ""]), H = N(E);
|
|
40
|
+
S(() => {
|
|
41
|
+
H.current = E;
|
|
42
|
+
}, [E]);
|
|
43
|
+
const [u, L] = v({
|
|
44
44
|
visible: !1,
|
|
45
45
|
x: 0,
|
|
46
46
|
y: 0,
|
|
@@ -51,22 +51,22 @@ const dt = ({
|
|
|
51
51
|
x: 0,
|
|
52
52
|
y: 0,
|
|
53
53
|
content: ""
|
|
54
|
-
}),
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
-
}, [R(
|
|
58
|
-
I == null || I({ graphData:
|
|
59
|
-
}, [R(
|
|
54
|
+
}), ge = Te({ cyRef: p, setContextMenu: L, onPathAnalysis: (_ = K.current) == null ? void 0 : _.onPathAnalysis, setPathNodes: Y, actionCircle: le });
|
|
55
|
+
S(() => {
|
|
56
|
+
(z == null ? void 0 : z.length) > 1 && we(p, { pathNodes: z, isGrayed: !1 });
|
|
57
|
+
}, [R(z), R(c)]), S(() => {
|
|
58
|
+
I == null || I({ graphData: c, nodeStatic: w, relationStatic: T });
|
|
59
|
+
}, [R(c), R(w), R(T)]), S(() => {
|
|
60
60
|
var r;
|
|
61
61
|
if (!j.current || p.current) return;
|
|
62
|
-
const { elements: s, typeListObj: a, relationListObj:
|
|
63
|
-
B(a), P(s), W(
|
|
62
|
+
const { elements: s, typeListObj: a, relationListObj: g } = F(de, { typeObj: w, graphInfo: h });
|
|
63
|
+
B(a), P(s), W(g), document.addEventListener("contextmenu", function(t) {
|
|
64
64
|
t.preventDefault();
|
|
65
65
|
});
|
|
66
66
|
const e = k({
|
|
67
67
|
container: j.current,
|
|
68
68
|
elements: s,
|
|
69
|
-
style:
|
|
69
|
+
style: Re({ elements: s, colors: E }),
|
|
70
70
|
autounselectify: !1,
|
|
71
71
|
autolock: !1,
|
|
72
72
|
layout: {
|
|
@@ -75,7 +75,7 @@ const dt = ({
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
if (p.current = e, ((r = h == null ? void 0 : h.searchNodes) == null ? void 0 : r.length) === 2)
|
|
78
|
-
|
|
78
|
+
Le(
|
|
79
79
|
e,
|
|
80
80
|
h.searchNodes[0],
|
|
81
81
|
h.searchNodes[1]
|
|
@@ -142,8 +142,8 @@ const dt = ({
|
|
|
142
142
|
p.current && (p.current.destroy(), p.current = null);
|
|
143
143
|
};
|
|
144
144
|
}, []);
|
|
145
|
-
const
|
|
146
|
-
const { id: a, kgId:
|
|
145
|
+
const ye = async (s) => {
|
|
146
|
+
const { id: a, kgId: g } = s, e = p.current;
|
|
147
147
|
if (!e) return;
|
|
148
148
|
const r = e.$(`#${a}`);
|
|
149
149
|
if (!r || r.length === 0) {
|
|
@@ -154,28 +154,28 @@ const dt = ({
|
|
|
154
154
|
if (t.length > 0) {
|
|
155
155
|
const n = t.map((l) => l.id()), d = t.connectedEdges(), x = e.edges().filter(
|
|
156
156
|
(l) => l.data("source") === a && n.includes(l.data("target"))
|
|
157
|
-
),
|
|
157
|
+
), D = e.edges().filter((l) => l.data("appendedBy") === a), M = d.merge(x).merge(D).filter((l) => l.data().zktype === s.zktype);
|
|
158
158
|
t.animate({
|
|
159
159
|
style: { opacity: 0 }
|
|
160
160
|
}, {
|
|
161
161
|
duration: 200,
|
|
162
162
|
complete: () => {
|
|
163
163
|
e.remove(t), e.remove(M), P((l) => {
|
|
164
|
-
const
|
|
164
|
+
const O = l.filter((f) => {
|
|
165
165
|
var b, te;
|
|
166
|
-
const i =
|
|
167
|
-
if (
|
|
166
|
+
const i = f.data.zktype;
|
|
167
|
+
if (f.group === "nodes" && n.includes((b = f.data) == null ? void 0 : b.id) && i && i === s.zktype)
|
|
168
168
|
return !1;
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
const A =
|
|
169
|
+
if (f.group === "edges" && i && i === s.zktype) {
|
|
170
|
+
const he = Array.from(D).map((xe) => {
|
|
171
|
+
const A = xe.data();
|
|
172
172
|
return `${A.source}-${A.target}-${A.label}`;
|
|
173
|
-
}), q =
|
|
174
|
-
return !
|
|
173
|
+
}), q = f.data, ve = he.includes(`${q.source}-${q.target}-${q.label}`), be = ((te = f.data) == null ? void 0 : te.appendedBy) === a;
|
|
174
|
+
return !ve && !be;
|
|
175
175
|
}
|
|
176
176
|
return !0;
|
|
177
|
-
}), { typeListObj:
|
|
178
|
-
return B(
|
|
177
|
+
}), { typeListObj: y, relationListObj: U } = F({}, { graphData: O, typeObj: {} });
|
|
178
|
+
return B(y), W(U), O;
|
|
179
179
|
}), r.data("appendedNodes", []), r.data("isExpanded", !1);
|
|
180
180
|
}
|
|
181
181
|
}), setTimeout(() => {
|
|
@@ -188,8 +188,8 @@ const dt = ({
|
|
|
188
188
|
content: "正在展开...",
|
|
189
189
|
duration: 0
|
|
190
190
|
});
|
|
191
|
-
const n = await re({ uri: a, queryType: 1, kgId:
|
|
192
|
-
if (B(x), W(
|
|
191
|
+
const n = await re({ uri: a, queryType: 1, kgId: g, zktype: s.zktype }), { elements: d, typeListObj: x, relationListObj: D } = F(n.data, { graphData: c, typeObj: w, relationObj: T, zktype: s.zktype });
|
|
192
|
+
if (B(x), W(D), !((d == null ? void 0 : d.length) > 0)) {
|
|
193
193
|
setTimeout(() => {
|
|
194
194
|
C.destroy(), C.warning("暂无数据");
|
|
195
195
|
}, 2e3);
|
|
@@ -235,12 +235,12 @@ const dt = ({
|
|
|
235
235
|
zktype: s.zktype
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
|
-
}),
|
|
239
|
-
P([...
|
|
240
|
-
const
|
|
238
|
+
}), O = e.add(l);
|
|
239
|
+
P([...c, ...l]);
|
|
240
|
+
const y = O.filter(":node"), U = y.map((i) => i.id());
|
|
241
241
|
r.data("appendedNodes", U), r.data("isExpanded", !0);
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
const f = e.nodes().difference(y);
|
|
243
|
+
f.forEach((i) => i.lock()), M.placeNewNodes(y), e.layout({
|
|
244
244
|
name: "cose-bilkent",
|
|
245
245
|
randomize: !1,
|
|
246
246
|
// ⚠️ 这是关键!保持已有节点位置不变
|
|
@@ -256,8 +256,8 @@ const dt = ({
|
|
|
256
256
|
// 可以适当减少,因为只需要微调
|
|
257
257
|
gravity: 0.6
|
|
258
258
|
}).run(), setTimeout(() => {
|
|
259
|
-
|
|
260
|
-
}, 2e3),
|
|
259
|
+
f.forEach((i) => i.unlock());
|
|
260
|
+
}, 2e3), y.animate({
|
|
261
261
|
style: {
|
|
262
262
|
opacity: 1,
|
|
263
263
|
width: 20,
|
|
@@ -267,7 +267,7 @@ const dt = ({
|
|
|
267
267
|
duration: 400,
|
|
268
268
|
easing: "ease-out",
|
|
269
269
|
complete: () => {
|
|
270
|
-
|
|
270
|
+
y.style("opacity", ""), y.style("width", ""), y.style("height", "");
|
|
271
271
|
}
|
|
272
272
|
}), setTimeout(() => {
|
|
273
273
|
r.removed() || (r.style("border-width", ""), r.style("border-color", ""), e.center(r), e.zoom(e.zoom()));
|
|
@@ -281,19 +281,19 @@ const dt = ({
|
|
|
281
281
|
J(!1);
|
|
282
282
|
}
|
|
283
283
|
L({ visible: !1 });
|
|
284
|
-
},
|
|
284
|
+
}, fe = {
|
|
285
285
|
expanded: "typed-literal",
|
|
286
286
|
contract: "uri"
|
|
287
|
-
},
|
|
287
|
+
}, me = (s, a) => {
|
|
288
288
|
var e;
|
|
289
289
|
console.log("handleMenuAction:::", s, a);
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
292
|
-
const r = s.ids, t =
|
|
290
|
+
const g = a || u.targetNode;
|
|
291
|
+
if (g) {
|
|
292
|
+
const r = s.ids, t = g.data();
|
|
293
293
|
if (["expanded", "contract"].includes(r))
|
|
294
|
-
|
|
294
|
+
ye({ kgId: 3, ...t, zktype: fe[r] });
|
|
295
295
|
else if (r === "nodeInfo") {
|
|
296
|
-
const o =
|
|
296
|
+
const o = g, n = {
|
|
297
297
|
id: o.id(),
|
|
298
298
|
data: o.data(),
|
|
299
299
|
position: o.position(),
|
|
@@ -304,14 +304,14 @@ const dt = ({
|
|
|
304
304
|
style: o.style()
|
|
305
305
|
};
|
|
306
306
|
Q.current.open(n);
|
|
307
|
-
} else r === "knowledgeCard" && V.current.open(
|
|
308
|
-
(e = s.onClick) == null || e.call(s,
|
|
307
|
+
} else r === "knowledgeCard" && V.current.open(g.data());
|
|
308
|
+
(e = s.onClick) == null || e.call(s, g), L({ visible: !1, x: 0, y: 0, targetNode: null });
|
|
309
309
|
}
|
|
310
310
|
};
|
|
311
|
-
return ((G =
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
/* @__PURE__ */
|
|
314
|
-
|
|
311
|
+
return console.log(111, !(((G = c == null ? void 0 : c.nodes) == null ? void 0 : G.length) > 0), c), /* @__PURE__ */ m(Oe, { value: { pathNodes: ue, setPathNodes: Y, graphInfo: h, graphData: c, layoutType: ce, setLayoutType: pe, knowledgeCardApi: ae }, children: /* @__PURE__ */ oe("div", { className: "cytoscape-container relative", children: [
|
|
312
|
+
/* @__PURE__ */ m("div", { className: "btn-group" }),
|
|
313
|
+
/* @__PURE__ */ m(
|
|
314
|
+
Ee,
|
|
315
315
|
{
|
|
316
316
|
ref: K,
|
|
317
317
|
cyRef: p,
|
|
@@ -320,19 +320,19 @@ const dt = ({
|
|
|
320
320
|
cyContainerRef: j,
|
|
321
321
|
typeObj: w,
|
|
322
322
|
relationObj: T,
|
|
323
|
-
colors:
|
|
323
|
+
colors: E,
|
|
324
324
|
actionBar: ie
|
|
325
325
|
}
|
|
326
326
|
),
|
|
327
327
|
/* @__PURE__ */ oe("div", { className: "relative h-100", children: [
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
|
|
328
|
+
/* @__PURE__ */ m("div", { ref: j, className: "cy-container" }),
|
|
329
|
+
u.visible && u.targetNode && /* @__PURE__ */ m(
|
|
330
330
|
"div",
|
|
331
331
|
{
|
|
332
332
|
style: {
|
|
333
333
|
position: "absolute",
|
|
334
|
-
left: `${
|
|
335
|
-
top: `${
|
|
334
|
+
left: `${u.x}px`,
|
|
335
|
+
top: `${u.y}px`,
|
|
336
336
|
// backgroundColor: 'white',
|
|
337
337
|
// border: '1px solid #ccc',
|
|
338
338
|
// borderRadius: '50%',
|
|
@@ -346,10 +346,10 @@ const dt = ({
|
|
|
346
346
|
overflow: "hidden"
|
|
347
347
|
},
|
|
348
348
|
onClick: (s) => s.stopPropagation(),
|
|
349
|
-
children: /* @__PURE__ */
|
|
349
|
+
children: /* @__PURE__ */ m($e, { items: ge, centerImage: (ee = u == null ? void 0 : u.targetNode) == null ? void 0 : ee.data().image, targetNode: u.targetNode, onClick: (s, a) => me(s, a) })
|
|
350
350
|
}
|
|
351
351
|
),
|
|
352
|
-
$.visible && /* @__PURE__ */
|
|
352
|
+
$.visible && /* @__PURE__ */ m(
|
|
353
353
|
"div",
|
|
354
354
|
{
|
|
355
355
|
style: {
|
|
@@ -373,10 +373,10 @@ const dt = ({
|
|
|
373
373
|
}
|
|
374
374
|
)
|
|
375
375
|
] }),
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */
|
|
378
|
-
] }) })
|
|
376
|
+
/* @__PURE__ */ m(De, { ref: Q }),
|
|
377
|
+
/* @__PURE__ */ m(Se, { ref: V })
|
|
378
|
+
] }) });
|
|
379
379
|
};
|
|
380
380
|
export {
|
|
381
|
-
|
|
381
|
+
nt as default
|
|
382
382
|
};
|