react-kggraph 0.0.32 → 0.0.33
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/{src/components → components}/Graph/components/KnowledgeCard/components/ListCard.d.ts +1 -1
- package/lib/{src/components → components}/Graph/components/KnowledgeCard/data.d.ts +1 -1
- package/lib/{src/components → components}/Graph/types.d.ts +7 -6
- package/lib/{src/components → components}/Graph/utils/layouts.d.ts +14 -14
- package/lib/{src/components → components}/Graph/utils/tools.d.ts +2 -2
- package/lib/index.es3.js +211 -217
- package/lib/index.es45.js +1 -1
- package/lib/index.es7.js +217 -217
- package/lib/index.es8.js +0 -1
- package/lib/index.es9.js +10 -10
- package/package.json +1 -1
- /package/lib/{src/components → components}/Graph/api.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/ActionBar/actionList.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/ActionBar/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/GraphListData/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/components/AudioSection.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/components/DocumentSection.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/components/ImageSection.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/components/PropertySection.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/components/RelationSection.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/components/SourceCard.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/components/VideoSection.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/KnowledgeCard/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/NodeInfoDrawer/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/PathAnalysis/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/PathAnalysisLevel/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/QueryNode/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/components/SettingCircle/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/context.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/index.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/utils/edge_node_styles.d.ts +0 -0
- /package/lib/{src/components → components}/Graph/utils/menuItems.d.ts +0 -0
- /package/lib/{index.es50.js → index.es47.js} +0 -0
package/lib/index.es3.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as k, useState as
|
|
1
|
+
import { jsx as y, jsxs as oe } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as k, useState as h, useEffect as R } from "react";
|
|
3
3
|
import N from "cytoscape";
|
|
4
4
|
import Ne from "cytoscape-cose-bilkent";
|
|
5
5
|
import ze from "cytoscape-cise";
|
|
@@ -7,73 +7,73 @@ import Ee from "cytoscape-fcose";
|
|
|
7
7
|
import je from "storm-layout";
|
|
8
8
|
import we 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
|
|
10
|
+
import { handleCalcPath as Le, resDetailData as F } from "./index.es8.js";
|
|
11
|
+
import { fixNodesToEdges as Oe, coseBilkentLayout as Pe } from "./index.es9.js";
|
|
12
|
+
import { edgeNodeStyles as De, defaultColors as ne, nodeSize as Re } from "./index.es10.js";
|
|
13
|
+
import Se from "cytoscape-layout-utilities";
|
|
14
|
+
import { message as v } from "antd";
|
|
15
15
|
import { menuItemsConfig as Te } from "./index.es11.js";
|
|
16
16
|
import { jsonStringify as w } from "./index.es12.js";
|
|
17
17
|
import $e from "./index.es13.js";
|
|
18
18
|
import Ie from "./index.es14.js";
|
|
19
19
|
import { GraphProvider as Be } from "./index.es15.js";
|
|
20
20
|
import Ae from "./index.es16.js";
|
|
21
|
-
import
|
|
22
|
-
N.use(
|
|
21
|
+
import Me from "./index.es17.js";
|
|
22
|
+
N.use(Se);
|
|
23
23
|
N.use(ze);
|
|
24
24
|
N.use(Ee);
|
|
25
25
|
N.use(je);
|
|
26
26
|
N.use(Ne);
|
|
27
27
|
const lt = ({
|
|
28
28
|
data: z,
|
|
29
|
-
getAllGraphData:
|
|
30
|
-
highPathAnalysis:
|
|
31
|
-
graphInfo:
|
|
32
|
-
stepNextApi:
|
|
33
|
-
knowledgeCardApi:
|
|
29
|
+
getAllGraphData: S,
|
|
30
|
+
highPathAnalysis: X = [],
|
|
31
|
+
graphInfo: g,
|
|
32
|
+
stepNextApi: re,
|
|
33
|
+
knowledgeCardApi: se,
|
|
34
34
|
colors: E,
|
|
35
|
-
actionBar:
|
|
36
|
-
actionCircle:
|
|
37
|
-
queryStatisticsConfig:
|
|
38
|
-
className:
|
|
39
|
-
noDataDesc:
|
|
35
|
+
actionBar: ae,
|
|
36
|
+
actionCircle: de,
|
|
37
|
+
queryStatisticsConfig: ie = [{ label: "实体", key: "entity" }, { label: "关系", key: "relation" }],
|
|
38
|
+
className: le,
|
|
39
|
+
noDataDesc: We = "暂无数据"
|
|
40
40
|
}) => {
|
|
41
|
-
var
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
var V, G;
|
|
42
|
+
const L = k(null), [b, Z] = h([]), c = k(null), q = k(null), K = 1, [He, U] = h(!1), [x, T] = h({}), [O, $] = h({}), [ce, pe] = h("cose-bilkent"), Y = k(null), _ = k(null), [ge, J] = h(["", ""]), I = k(E);
|
|
43
|
+
R(() => {
|
|
44
|
+
I.current = E;
|
|
45
45
|
}, [E]);
|
|
46
|
-
const [
|
|
46
|
+
const [u, j] = h({
|
|
47
47
|
visible: !1,
|
|
48
48
|
x: 0,
|
|
49
49
|
y: 0,
|
|
50
50
|
targetNode: null,
|
|
51
51
|
bgColor: ""
|
|
52
|
-
}), [
|
|
52
|
+
}), [P, Q] = h({
|
|
53
53
|
visible: !1,
|
|
54
54
|
x: 0,
|
|
55
55
|
y: 0,
|
|
56
56
|
content: ""
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
const { nodes:
|
|
60
|
-
((
|
|
61
|
-
}, [w(
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}),
|
|
66
|
-
}, [w(
|
|
67
|
-
var
|
|
68
|
-
if (!
|
|
69
|
-
const { elements:
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
}), ue = Te({ cyRef: c, setContextMenu: j, onPathAnalysis: (V = q.current) == null ? void 0 : V.onPathAnalysis, setPathNodes: J, actionCircle: de });
|
|
58
|
+
R(() => {
|
|
59
|
+
const { nodes: e, links: r } = X || {};
|
|
60
|
+
((e == null ? void 0 : e.length) > 0 || (r == null ? void 0 : r.length) > 0) && Le(c, { nodes: e, links: r, isGrayed: !1 });
|
|
61
|
+
}, [w(X), w(b)]), R(() => {
|
|
62
|
+
const e = [], r = [];
|
|
63
|
+
b.forEach((d) => {
|
|
64
|
+
d.group === "nodes" ? e.push(d.data) : d.group === "edges" && r.push(d.data);
|
|
65
|
+
}), S == null || S({ graphData: b, nodeStatic: x, relationStatic: O, data: { nodes: e, links: r }, paths: z.paths, data2: z.data2, logId: z.logId, costtime: z.costtime });
|
|
66
|
+
}, [w(b), w(x), w(O)]), R(() => {
|
|
67
|
+
var i;
|
|
68
|
+
if (!L.current || c.current) return;
|
|
69
|
+
const { elements: e, typeListObj: r, relationListObj: d } = F(z, { typeObj: x, graphInfo: g });
|
|
70
|
+
T(r), Z(e), $(d), document.addEventListener("contextmenu", function(n) {
|
|
71
|
+
n.preventDefault();
|
|
72
72
|
});
|
|
73
|
-
const
|
|
74
|
-
container:
|
|
75
|
-
elements:
|
|
76
|
-
style:
|
|
73
|
+
const t = N({
|
|
74
|
+
container: L.current,
|
|
75
|
+
elements: e,
|
|
76
|
+
style: De({ elements: e, colors: E }),
|
|
77
77
|
autounselectify: !1,
|
|
78
78
|
autolock: !1,
|
|
79
79
|
maxZoom: 1,
|
|
@@ -82,142 +82,177 @@ const lt = ({
|
|
|
82
82
|
// 使用预设布局,完全依赖 position
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
if (c.current = t, ((i = g == null ? void 0 : g.searchNodes) == null ? void 0 : i.length) === 2)
|
|
86
|
+
Oe(
|
|
87
|
+
t,
|
|
88
|
+
g.searchNodes[0],
|
|
89
|
+
g.searchNodes[1]
|
|
90
90
|
);
|
|
91
91
|
else {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const n = t.layout(Pe());
|
|
93
|
+
n.run(), n.on("layoutstop", () => {
|
|
94
|
+
t.fit(void 0, 50), t.center();
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
return
|
|
98
|
-
var
|
|
99
|
-
const o =
|
|
97
|
+
return t.on("mouseover", "edge", (n) => {
|
|
98
|
+
var s;
|
|
99
|
+
const o = n.target;
|
|
100
100
|
if (!o.hasClass("path-edge")) {
|
|
101
|
-
const a = ((
|
|
101
|
+
const a = ((s = I.current) == null ? void 0 : s.edgeHoverColor) ?? ne.edgeHoverColor;
|
|
102
102
|
o.style({
|
|
103
103
|
"line-color": a,
|
|
104
104
|
"target-arrow-color": a,
|
|
105
105
|
opacity: 0.8
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
}),
|
|
109
|
-
var
|
|
110
|
-
const o =
|
|
108
|
+
}), t.on("mouseout", "edge", (n) => {
|
|
109
|
+
var s;
|
|
110
|
+
const o = n.target;
|
|
111
111
|
if (!o.hasClass("path-edge")) {
|
|
112
|
-
const a = ((
|
|
112
|
+
const a = ((s = I.current) == null ? void 0 : s.edgeDefaultColor) ?? ne.edgeDefaultColor;
|
|
113
113
|
o.style({
|
|
114
114
|
"line-color": a,
|
|
115
115
|
"target-arrow-color": a,
|
|
116
116
|
opacity: 1
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
}),
|
|
120
|
-
const o =
|
|
119
|
+
}), t.on("mouseover", "node", (n) => {
|
|
120
|
+
const o = n.target;
|
|
121
121
|
o.hasClass("selected") || o.addClass("hover");
|
|
122
|
-
}),
|
|
123
|
-
const o =
|
|
124
|
-
o.addClass("hover"),
|
|
122
|
+
}), t.on("mouseover", "node", (n) => {
|
|
123
|
+
const o = n.target, s = o.renderedPosition(), a = o.data("name") || "";
|
|
124
|
+
o.addClass("hover"), Q({
|
|
125
125
|
visible: !0,
|
|
126
|
-
x:
|
|
127
|
-
y:
|
|
126
|
+
x: s.x,
|
|
127
|
+
y: s.y - 60,
|
|
128
128
|
content: a
|
|
129
129
|
});
|
|
130
|
-
}),
|
|
131
|
-
|
|
132
|
-
}),
|
|
133
|
-
|
|
134
|
-
const o =
|
|
130
|
+
}), t.on("mouseout", "node", (n) => {
|
|
131
|
+
n.target.removeClass("hover"), Q((s) => ({ ...s, visible: !1 }));
|
|
132
|
+
}), t.on("cxttap", "node", (n) => {
|
|
133
|
+
n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation(), n.originalEvent && (n.originalEvent.preventDefault(), n.originalEvent.stopPropagation(), n.originalEvent.stopImmediatePropagation());
|
|
134
|
+
const o = n.target, s = o.renderedPosition();
|
|
135
135
|
console.log("renderedPos:::", o.data(), o.style("background-color")), j({
|
|
136
136
|
visible: !0,
|
|
137
|
-
x:
|
|
138
|
-
y:
|
|
137
|
+
x: s.x - 90,
|
|
138
|
+
y: s.y - 90,
|
|
139
139
|
targetNode: o,
|
|
140
140
|
bgColor: o.style("background-color")
|
|
141
141
|
});
|
|
142
|
-
}),
|
|
143
|
-
const o =
|
|
144
|
-
|
|
145
|
-
const a = o.neighborhood().nodes().add(o),
|
|
146
|
-
console.log("cy.nodes().not(relatedNodes):::", a),
|
|
147
|
-
}),
|
|
148
|
-
|
|
142
|
+
}), c.current = t, t.on("click", "node", (n) => {
|
|
143
|
+
const o = n.target;
|
|
144
|
+
t.nodes().removeClass("selected grayed highlighted"), t.edges().removeClass("selected grayed highlighted"), o.addClass("selected");
|
|
145
|
+
const a = o.neighborhood().nodes().add(o), m = a.edgesWith(a);
|
|
146
|
+
console.log("cy.nodes().not(relatedNodes):::", a), t.nodes().not(a).addClass("grayed"), t.edges().not(m).addClass("grayed"), a.addClass("highlighted"), m.addClass("highlighted");
|
|
147
|
+
}), t.on("tap", (n) => {
|
|
148
|
+
n.target === t && (j((o) => ({ ...o, visible: !1 })), t.nodes().removeClass("grayed highlighted highlight selected correlationStyle path-node level-highlight level-selected level-grayed"), t.edges().removeClass("grayed highlighted highlight selected correlationStyle path-edge level-highlightedge level-grayed"));
|
|
149
149
|
}), () => {
|
|
150
|
-
|
|
150
|
+
c.current && (c.current.destroy(), c.current = null);
|
|
151
151
|
};
|
|
152
152
|
}, []);
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
153
|
+
const fe = ({ addedNodes: e, currentNode: r, cy: d, currentZoom: t }) => {
|
|
154
|
+
const i = e == null ? void 0 : e.length;
|
|
155
|
+
console.log(33333, e == null ? void 0 : e.length);
|
|
156
|
+
const n = Math.max(0.1, 18 / (i || 1)), o = d.layout({
|
|
157
|
+
name: "concentric",
|
|
158
|
+
spacingFactor: n,
|
|
159
|
+
// 节点越多间距越小,防止溢出
|
|
160
|
+
minNodeSpacing: 0,
|
|
161
|
+
// 最小间距设为0
|
|
162
|
+
concentric: function(s) {
|
|
163
|
+
return s.degree();
|
|
164
|
+
},
|
|
165
|
+
levelWidth: function(s) {
|
|
166
|
+
return 2;
|
|
167
|
+
},
|
|
168
|
+
// 随机排序
|
|
169
|
+
// sort: function(a, b) {
|
|
170
|
+
// return Math.random() - 0.5;
|
|
171
|
+
// },
|
|
172
|
+
// 添加随机偏移,打破完美圆环
|
|
173
|
+
transform: function(s, a) {
|
|
174
|
+
const m = (Math.random() - 0.5) * 50, C = (Math.random() - 0.5) * 50;
|
|
175
|
+
return {
|
|
176
|
+
x: a.x + m,
|
|
177
|
+
y: a.y + C
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
o.one("layoutstop", () => {
|
|
182
|
+
d.fit(void 0, 20), d.animate({
|
|
183
|
+
center: { eles: r },
|
|
184
|
+
zoom: t,
|
|
185
|
+
duration: 400
|
|
186
|
+
}), v.destroy();
|
|
187
|
+
}), o.run();
|
|
188
|
+
}, ye = async (e) => {
|
|
189
|
+
const { id: r, kgId: d } = e, t = c.current;
|
|
190
|
+
if (!t) return;
|
|
191
|
+
const i = t.$id(r);
|
|
192
|
+
if (!i || i.length === 0) {
|
|
158
193
|
console.error("当前节点不存在");
|
|
159
194
|
return;
|
|
160
195
|
}
|
|
161
|
-
const
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
(
|
|
165
|
-
),
|
|
166
|
-
|
|
196
|
+
const n = t.nodes().filter((s) => s.data("parentId") ? (s.data("parentId") === r || s.data("idLabel") === `${r}-${s.data("name")}`) && s.data("zktype") === e.zktype : !1);
|
|
197
|
+
if (n.length > 0) {
|
|
198
|
+
const s = n.map((l) => l.id()), a = n.connectedEdges(), m = t.edges().filter(
|
|
199
|
+
(l) => l.data("source") === r && s.includes(l.data("target"))
|
|
200
|
+
), C = t.edges().filter((l) => l.data("appendedBy") === r), B = a.merge(m).merge(C).filter((l) => l.data().zktype === e.zktype);
|
|
201
|
+
n.animate({
|
|
167
202
|
style: { opacity: 0 }
|
|
168
203
|
}, {
|
|
169
204
|
duration: 200,
|
|
170
205
|
complete: () => {
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
var
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
206
|
+
t.remove(n), t.remove(B), Z((l) => {
|
|
207
|
+
const A = l.filter((f) => {
|
|
208
|
+
var ee, te;
|
|
209
|
+
const D = f.data.zktype;
|
|
210
|
+
if (f.group === "nodes" && s.includes((ee = f.data) == null ? void 0 : ee.id) && D && D === e.zktype)
|
|
176
211
|
return !1;
|
|
177
|
-
if (
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
return `${
|
|
181
|
-
}),
|
|
212
|
+
if (f.group === "edges" && D && D === e.zktype) {
|
|
213
|
+
const be = Array.from(C).map((ke) => {
|
|
214
|
+
const H = ke.data();
|
|
215
|
+
return `${H.source}-${H.target}-${H.label}`;
|
|
216
|
+
}), W = f.data, xe = be.includes(`${W.source}-${W.target}-${W.label}`), Ce = ((te = f.data) == null ? void 0 : te.appendedBy) === r;
|
|
182
217
|
return !xe && !Ce;
|
|
183
218
|
}
|
|
184
219
|
return !0;
|
|
185
|
-
}), { typeListObj: M, relationListObj:
|
|
186
|
-
return
|
|
187
|
-
}),
|
|
220
|
+
}), { typeListObj: M, relationListObj: p } = F({}, { graphData: A, typeObj: {} });
|
|
221
|
+
return T(M), $(p), A;
|
|
222
|
+
}), i.data("appendedNodes", []), i.data("isExpanded", !1);
|
|
188
223
|
}
|
|
189
224
|
}), setTimeout(() => {
|
|
190
|
-
|
|
225
|
+
i.removed() || (i.style("border-width", ""), i.style("border-color", ""));
|
|
191
226
|
}, 300);
|
|
192
227
|
} else {
|
|
193
228
|
try {
|
|
194
|
-
|
|
229
|
+
U(!0), v.open({
|
|
195
230
|
type: "loading",
|
|
196
231
|
content: "正在展开...",
|
|
197
232
|
duration: 0
|
|
198
233
|
});
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
234
|
+
const s = await re({ uri: r, queryType: 1, kgId: d, zktype: e.zktype }), { elements: a, typeListObj: m, relationListObj: C } = F(s.data, { graphData: b, typeObj: x, relationObj: O, zktype: e.zktype });
|
|
235
|
+
if (T(m), $(C), !((a == null ? void 0 : a.length) > 0)) {
|
|
201
236
|
setTimeout(() => {
|
|
202
|
-
|
|
237
|
+
v.destroy(), v.warning("暂无数据");
|
|
203
238
|
}, 2e3);
|
|
204
239
|
return;
|
|
205
240
|
}
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
-
const
|
|
241
|
+
const B = t.zoom();
|
|
242
|
+
if ((a == null ? void 0 : a.length) > 0) {
|
|
243
|
+
const l = a.map((p) => {
|
|
244
|
+
if (p.group === "nodes") {
|
|
245
|
+
const f = Re * K;
|
|
211
246
|
return {
|
|
212
|
-
...
|
|
247
|
+
...p,
|
|
213
248
|
// position,
|
|
214
|
-
style: { opacity: 1, width:
|
|
249
|
+
style: { opacity: 1, width: f, height: f },
|
|
215
250
|
data: {
|
|
216
|
-
...
|
|
217
|
-
parentId:
|
|
218
|
-
appendedBy:
|
|
219
|
-
idLabel:
|
|
220
|
-
zktype:
|
|
251
|
+
...p.data,
|
|
252
|
+
parentId: r,
|
|
253
|
+
appendedBy: r,
|
|
254
|
+
idLabel: r + "-" + p.data.label,
|
|
255
|
+
zktype: e.zktype,
|
|
221
256
|
isAppended: !0,
|
|
222
257
|
baseWidth: 80,
|
|
223
258
|
baseHeight: 80
|
|
@@ -225,77 +260,38 @@ const lt = ({
|
|
|
225
260
|
};
|
|
226
261
|
}
|
|
227
262
|
return {
|
|
228
|
-
...
|
|
229
|
-
data: { ...
|
|
263
|
+
...p,
|
|
264
|
+
data: { ...p.data, appendedBy: r, zktype: e.zktype }
|
|
230
265
|
};
|
|
231
266
|
});
|
|
232
|
-
console.log(888,
|
|
233
|
-
if (
|
|
234
|
-
return
|
|
235
|
-
});
|
|
236
|
-
const M = e.add(c).filter(":node"), ne = d.position(), y = e.layout({
|
|
237
|
-
name: "concentric",
|
|
238
|
-
// ✅ 使用 concentric 实现多层
|
|
239
|
-
eles: M,
|
|
240
|
-
fit: !1,
|
|
241
|
-
animate: !0,
|
|
242
|
-
animationDuration: 500,
|
|
243
|
-
avoidOverlap: !1,
|
|
244
|
-
// 允许重叠
|
|
245
|
-
spacingFactor: 3,
|
|
246
|
-
// 层间距因子
|
|
247
|
-
minNodeSpacing: 100,
|
|
248
|
-
// radius: 120,
|
|
249
|
-
// ✅ 决定节点在哪个层(返回相同值=同层,不同值=不同层)
|
|
250
|
-
concentric: function(i) {
|
|
251
|
-
return i.degree();
|
|
252
|
-
},
|
|
253
|
-
// ✅ 每层最少节点数(决定层数)
|
|
254
|
-
levelWidth: function(i) {
|
|
255
|
-
return 2;
|
|
256
|
-
},
|
|
257
|
-
// 随机排序
|
|
258
|
-
// sort: function(a, b) {
|
|
259
|
-
// return Math.random() - 0.5;
|
|
260
|
-
// },
|
|
261
|
-
// 添加随机偏移,打破完美圆环
|
|
262
|
-
transform: function(i, h) {
|
|
263
|
-
const S = (Math.random() - 0.5) * 20, H = (Math.random() - 0.5) * 20;
|
|
264
|
-
return {
|
|
265
|
-
x: h.x + S,
|
|
266
|
-
y: h.y + H
|
|
267
|
-
};
|
|
268
|
-
}
|
|
267
|
+
console.log(888, l), t.nodes().forEach((p) => {
|
|
268
|
+
if (p.data("id") !== r)
|
|
269
|
+
return p.lock();
|
|
269
270
|
});
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
center: { eles: d },
|
|
273
|
-
zoom: A,
|
|
274
|
-
duration: 400
|
|
275
|
-
}), b.destroy();
|
|
276
|
-
}), y.run();
|
|
271
|
+
const M = t.add(l).filter(":node");
|
|
272
|
+
fe({ addedNodes: M, currentNode: i, cy: t, currentZoom: B });
|
|
277
273
|
} else
|
|
278
274
|
console.log("没有找到相关节点数据");
|
|
279
|
-
|
|
280
|
-
} catch (
|
|
281
|
-
|
|
275
|
+
v.destroy();
|
|
276
|
+
} catch (s) {
|
|
277
|
+
v.destroy(), v.error("请求接口失败"), console.error("22请求接口失败:", s);
|
|
282
278
|
}
|
|
283
|
-
|
|
279
|
+
U(!1);
|
|
284
280
|
}
|
|
285
281
|
j({ visible: !1 });
|
|
286
|
-
},
|
|
282
|
+
}, me = {
|
|
287
283
|
expanded: "typed-literal",
|
|
288
284
|
contract: "uri"
|
|
289
|
-
},
|
|
290
|
-
var
|
|
291
|
-
console.log("handleMenuAction:::",
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
const
|
|
295
|
-
if (["expanded", "contract"].includes(
|
|
296
|
-
|
|
297
|
-
else if (
|
|
298
|
-
const o =
|
|
285
|
+
}, he = (e, r) => {
|
|
286
|
+
var t;
|
|
287
|
+
console.log("handleMenuAction:::", e, r);
|
|
288
|
+
const d = r || u.targetNode;
|
|
289
|
+
if (d) {
|
|
290
|
+
const i = e.ids, n = d.data();
|
|
291
|
+
if (["expanded", "contract"].includes(i))
|
|
292
|
+
ye({ kgId: g.kgId, ...n, zktype: me[i] });
|
|
293
|
+
else if (i === "nodeInfo") {
|
|
294
|
+
const o = d, s = {
|
|
299
295
|
id: o.id(),
|
|
300
296
|
data: o.data(),
|
|
301
297
|
position: o.position(),
|
|
@@ -305,42 +301,40 @@ const lt = ({
|
|
|
305
301
|
classes: o.classes(),
|
|
306
302
|
style: o.style()
|
|
307
303
|
};
|
|
308
|
-
|
|
309
|
-
} else
|
|
310
|
-
(
|
|
304
|
+
Y.current.open(s);
|
|
305
|
+
} else i === "knowledgeCard" && _.current.open(d.data());
|
|
306
|
+
(t = e.onClick) == null || t.call(e, d), j({ visible: !1, x: 0, y: 0, targetNode: null });
|
|
311
307
|
}
|
|
308
|
+
}, ve = () => {
|
|
309
|
+
const e = {};
|
|
310
|
+
return Object.keys(x).forEach((r) => {
|
|
311
|
+
r !== "_" && (e[r] = x[r]);
|
|
312
|
+
}), e;
|
|
312
313
|
};
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return Object.keys(x).forEach((s) => {
|
|
317
|
-
s !== "_" && (n[s] = x[s]);
|
|
318
|
-
}), n;
|
|
319
|
-
};
|
|
320
|
-
return /* @__PURE__ */ m(Be, { value: { pathNodes: fe, setPathNodes: V, graphInfo: u, graphData: g, layoutType: ge, setLayoutType: ue, knowledgeCardApi: de, queryStatisticsConfig: ce, actionBar: ie }, children: /* @__PURE__ */ se("div", { className: We("cytoscape-container relative", pe), children: [
|
|
321
|
-
/* @__PURE__ */ m("div", { className: "btn-group" }),
|
|
322
|
-
/* @__PURE__ */ m(
|
|
314
|
+
return /* @__PURE__ */ y(Be, { value: { pathNodes: ge, setPathNodes: J, graphInfo: g, graphData: b, layoutType: ce, setLayoutType: pe, knowledgeCardApi: se, queryStatisticsConfig: ie, actionBar: ae }, children: /* @__PURE__ */ oe("div", { className: Me("cytoscape-container relative", le), children: [
|
|
315
|
+
/* @__PURE__ */ y("div", { className: "btn-group" }),
|
|
316
|
+
/* @__PURE__ */ y(
|
|
323
317
|
we,
|
|
324
318
|
{
|
|
325
|
-
ref:
|
|
326
|
-
cyRef:
|
|
327
|
-
graphInfo:
|
|
328
|
-
initNodeScale:
|
|
329
|
-
cyContainerRef:
|
|
330
|
-
typeObj:
|
|
331
|
-
relationObj:
|
|
319
|
+
ref: q,
|
|
320
|
+
cyRef: c,
|
|
321
|
+
graphInfo: g,
|
|
322
|
+
initNodeScale: K,
|
|
323
|
+
cyContainerRef: L,
|
|
324
|
+
typeObj: ve(),
|
|
325
|
+
relationObj: O,
|
|
332
326
|
colors: E
|
|
333
327
|
}
|
|
334
328
|
),
|
|
335
|
-
/* @__PURE__ */
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
|
|
329
|
+
/* @__PURE__ */ oe("div", { className: "relative h-100", children: [
|
|
330
|
+
/* @__PURE__ */ y("div", { ref: L, className: "cy-container" }),
|
|
331
|
+
u.visible && u.targetNode && /* @__PURE__ */ y(
|
|
338
332
|
"div",
|
|
339
333
|
{
|
|
340
334
|
style: {
|
|
341
335
|
position: "absolute",
|
|
342
|
-
left: `${
|
|
343
|
-
top: `${
|
|
336
|
+
left: `${u.x}px`,
|
|
337
|
+
top: `${u.y}px`,
|
|
344
338
|
// backgroundColor: 'white',
|
|
345
339
|
// border: '1px solid #ccc',
|
|
346
340
|
// borderRadius: '50%',
|
|
@@ -353,17 +347,17 @@ const lt = ({
|
|
|
353
347
|
height: "200px",
|
|
354
348
|
overflow: "hidden"
|
|
355
349
|
},
|
|
356
|
-
onClick: (
|
|
357
|
-
children: /* @__PURE__ */
|
|
350
|
+
onClick: (e) => e.stopPropagation(),
|
|
351
|
+
children: /* @__PURE__ */ y($e, { items: ue, centerImage: (G = u == null ? void 0 : u.targetNode) == null ? void 0 : G.data().image, targetNode: u.targetNode, onClick: (e, r) => he(e, r) })
|
|
358
352
|
}
|
|
359
353
|
),
|
|
360
|
-
|
|
354
|
+
P.visible && /* @__PURE__ */ y(
|
|
361
355
|
"div",
|
|
362
356
|
{
|
|
363
357
|
style: {
|
|
364
358
|
position: "absolute",
|
|
365
|
-
left: `${
|
|
366
|
-
top: `${
|
|
359
|
+
left: `${P.x}px`,
|
|
360
|
+
top: `${P.y}px`,
|
|
367
361
|
transform: "translateX(-50%)",
|
|
368
362
|
backgroundColor: "rgba(0, 0, 0, 0.85)",
|
|
369
363
|
color: "#fff",
|
|
@@ -377,12 +371,12 @@ const lt = ({
|
|
|
377
371
|
overflow: "hidden",
|
|
378
372
|
textOverflow: "ellipsis"
|
|
379
373
|
},
|
|
380
|
-
children:
|
|
374
|
+
children: P.content
|
|
381
375
|
}
|
|
382
376
|
)
|
|
383
377
|
] }),
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
/* @__PURE__ */
|
|
378
|
+
/* @__PURE__ */ y(Ie, { ref: Y, cyRef: c }),
|
|
379
|
+
/* @__PURE__ */ y(Ae, { ref: _ })
|
|
386
380
|
] }) });
|
|
387
381
|
};
|
|
388
382
|
export {
|
package/lib/index.es45.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { useState as m, useEffect as w } from "react";
|
|
3
|
-
import h from "./index.
|
|
3
|
+
import h from "./index.es47.js";
|
|
4
4
|
const k = ({ relations: t, kgIds: s, viewMode: a = "list", source: c = "" }) => {
|
|
5
5
|
const [d, l] = m(t);
|
|
6
6
|
w(() => {
|