react-kggraph 0.0.18 → 0.0.20
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/README.md +151 -9
- package/lib/index.es11.js +68 -70
- package/lib/index.es13.js +12 -18
- package/lib/index.es14.js +61 -216
- package/lib/index.es3.js +187 -185
- package/lib/index.es7.js +1 -3
- package/lib/src/components/Graph/components/SettingCircle/index.d.ts +4 -2
- package/lib/src/components/Graph/types.d.ts +13 -1
- package/lib/src/components/Graph/utils/menuItems.d.ts +12 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
package/lib/index.es3.js
CHANGED
|
@@ -1,70 +1,72 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { jsx as c, jsxs as te } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as N, useState as h, useEffect as S } from "react";
|
|
3
|
+
import k from "cytoscape";
|
|
4
|
+
import Ne from "cytoscape-cose-bilkent";
|
|
5
|
+
import Ce from "cytoscape-cise";
|
|
6
|
+
import ke from "cytoscape-fcose";
|
|
7
|
+
import Ee from "storm-layout";
|
|
8
|
+
import ze 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
|
|
16
|
-
import { jsonStringify as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { GraphProvider as
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
data:
|
|
10
|
+
import { handleCalcPath as we, resDetailData as F } from "./index.es8.js";
|
|
11
|
+
import { fixNodesToEdges as Le, coseBilkentLayout as oe } from "./index.es9.js";
|
|
12
|
+
import { edgeNodeStyles as Re, defaultColors as ne } from "./index.es10.js";
|
|
13
|
+
import je from "cytoscape-layout-utilities";
|
|
14
|
+
import { Row as Te, Empty as $e, message as C } from "antd";
|
|
15
|
+
import { menuItemsConfig as De } from "./index.es11.js";
|
|
16
|
+
import { jsonStringify as R } from "./index.es12.js";
|
|
17
|
+
import Oe from "./index.es13.js";
|
|
18
|
+
import Se from "./index.es14.js";
|
|
19
|
+
import { GraphProvider as Ie } from "./index.es15.js";
|
|
20
|
+
import Pe from "./index.es16.js";
|
|
21
|
+
k.use(je);
|
|
22
|
+
k.use(Ce);
|
|
23
|
+
k.use(ke);
|
|
24
|
+
k.use(Ee);
|
|
25
|
+
k.use(Ne);
|
|
26
|
+
const rt = ({
|
|
27
|
+
data: re,
|
|
28
28
|
getAllGraphData: I,
|
|
29
|
-
highPathAnalysis:
|
|
30
|
-
graphInfo:
|
|
31
|
-
stepNextApi:
|
|
32
|
-
knowledgeCardApi:
|
|
33
|
-
colors:
|
|
34
|
-
actionBar:
|
|
29
|
+
highPathAnalysis: E = [],
|
|
30
|
+
graphInfo: m,
|
|
31
|
+
stepNextApi: se,
|
|
32
|
+
knowledgeCardApi: de,
|
|
33
|
+
colors: z,
|
|
34
|
+
actionBar: ae,
|
|
35
|
+
actionCircle: ie,
|
|
36
|
+
noDataDesc: le = "暂无数据"
|
|
35
37
|
}) => {
|
|
36
|
-
var
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
H.current =
|
|
40
|
-
}, [
|
|
41
|
-
const [
|
|
38
|
+
var _, G;
|
|
39
|
+
const j = N(null), [v, P] = h([]), p = N(null), K = N(null), X = 1, [Be, J] = h(!1), [w, B] = h({}), [T, W] = h({}), [ce, pe] = h("cose-bilkent"), Q = N(null), V = N(null), [ue, Y] = h(["", ""]), H = N(z);
|
|
40
|
+
S(() => {
|
|
41
|
+
H.current = z;
|
|
42
|
+
}, [z]);
|
|
43
|
+
const [u, L] = h({
|
|
42
44
|
visible: !1,
|
|
43
45
|
x: 0,
|
|
44
46
|
y: 0,
|
|
45
47
|
targetNode: null,
|
|
46
48
|
bgColor: ""
|
|
47
|
-
}), [
|
|
49
|
+
}), [$, Z] = h({
|
|
48
50
|
visible: !1,
|
|
49
51
|
x: 0,
|
|
50
52
|
y: 0,
|
|
51
53
|
content: ""
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
(
|
|
55
|
-
}, [
|
|
56
|
-
I == null || I({ graphData: v, nodeStatic:
|
|
57
|
-
}, [
|
|
58
|
-
var
|
|
59
|
-
if (!
|
|
60
|
-
const { elements:
|
|
61
|
-
B(
|
|
54
|
+
}), ge = De({ cyRef: p, setContextMenu: L, onPathAnalysis: (_ = K.current) == null ? void 0 : _.onPathAnalysis, setPathNodes: Y, actionCircle: ie });
|
|
55
|
+
S(() => {
|
|
56
|
+
(E == null ? void 0 : E.length) > 1 && we(p, { pathNodes: E, isGrayed: !1 });
|
|
57
|
+
}, [R(E), R(v)]), S(() => {
|
|
58
|
+
I == null || I({ graphData: v, nodeStatic: w, relationStatic: T });
|
|
59
|
+
}, [R(v), R(w), R(T)]), S(() => {
|
|
60
|
+
var d;
|
|
61
|
+
if (!j.current || p.current) return;
|
|
62
|
+
const { elements: r, typeListObj: a, relationListObj: g } = F(re, { typeObj: w, graphInfo: m });
|
|
63
|
+
B(a), P(r), W(g), document.addEventListener("contextmenu", function(t) {
|
|
62
64
|
t.preventDefault();
|
|
63
65
|
});
|
|
64
|
-
const e =
|
|
65
|
-
container:
|
|
66
|
-
elements:
|
|
67
|
-
style:
|
|
66
|
+
const e = k({
|
|
67
|
+
container: j.current,
|
|
68
|
+
elements: r,
|
|
69
|
+
style: Re({ elements: r, colors: z }),
|
|
68
70
|
autounselectify: !1,
|
|
69
71
|
autolock: !1,
|
|
70
72
|
layout: {
|
|
@@ -72,156 +74,156 @@ const et = ({
|
|
|
72
74
|
// 使用预设布局,完全依赖 position
|
|
73
75
|
}
|
|
74
76
|
});
|
|
75
|
-
if (p.current = e, ((
|
|
76
|
-
|
|
77
|
+
if (p.current = e, ((d = m == null ? void 0 : m.searchNodes) == null ? void 0 : d.length) === 2)
|
|
78
|
+
Le(
|
|
77
79
|
e,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
m.searchNodes[0],
|
|
81
|
+
m.searchNodes[1]
|
|
80
82
|
);
|
|
81
83
|
else {
|
|
82
|
-
const t = e.layout(
|
|
84
|
+
const t = e.layout(oe());
|
|
83
85
|
t.run(), t.on("layoutstop", () => {
|
|
84
86
|
e.fit(void 0, 50), e.center();
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
return e.on("mouseover", "edge", (t) => {
|
|
88
|
-
var
|
|
89
|
-
const
|
|
90
|
-
if (!
|
|
91
|
-
const s = ((
|
|
92
|
-
|
|
90
|
+
var n;
|
|
91
|
+
const o = t.target;
|
|
92
|
+
if (!o.hasClass("path-edge")) {
|
|
93
|
+
const s = ((n = H.current) == null ? void 0 : n.edgeHoverColor) ?? ne.edgeHoverColor;
|
|
94
|
+
o.style({
|
|
93
95
|
"line-color": s,
|
|
94
96
|
"target-arrow-color": s,
|
|
95
97
|
opacity: 0.8
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
100
|
}), e.on("mouseout", "edge", (t) => {
|
|
99
|
-
var
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
102
|
-
const s = ((
|
|
103
|
-
|
|
101
|
+
var n;
|
|
102
|
+
const o = t.target;
|
|
103
|
+
if (!o.hasClass("path-edge")) {
|
|
104
|
+
const s = ((n = H.current) == null ? void 0 : n.edgeDefaultColor) ?? ne.edgeDefaultColor;
|
|
105
|
+
o.style({
|
|
104
106
|
"line-color": s,
|
|
105
107
|
"target-arrow-color": s,
|
|
106
108
|
opacity: 1
|
|
107
109
|
});
|
|
108
110
|
}
|
|
109
111
|
}), e.on("mouseover", "node", (t) => {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
+
const o = t.target;
|
|
113
|
+
o.hasClass("selected") || o.addClass("hover");
|
|
112
114
|
}), e.on("mouseover", "node", (t) => {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
+
const o = t.target, n = o.renderedPosition(), s = o.data("name") || "";
|
|
116
|
+
o.addClass("hover"), Z({
|
|
115
117
|
visible: !0,
|
|
116
|
-
x:
|
|
117
|
-
y:
|
|
118
|
+
x: n.x,
|
|
119
|
+
y: n.y - 60,
|
|
118
120
|
content: s
|
|
119
121
|
});
|
|
120
122
|
}), e.on("mouseout", "node", (t) => {
|
|
121
|
-
t.target.removeClass("hover"),
|
|
123
|
+
t.target.removeClass("hover"), Z((n) => ({ ...n, visible: !1 }));
|
|
122
124
|
}), e.on("cxttap", "node", (t) => {
|
|
123
125
|
t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), t.originalEvent && (t.originalEvent.preventDefault(), t.originalEvent.stopPropagation(), t.originalEvent.stopImmediatePropagation());
|
|
124
|
-
const
|
|
125
|
-
console.log("renderedPos:::",
|
|
126
|
+
const o = t.target, n = o.renderedPosition();
|
|
127
|
+
console.log("renderedPos:::", o.data(), o.style("background-color")), L({
|
|
126
128
|
visible: !0,
|
|
127
|
-
x:
|
|
128
|
-
y:
|
|
129
|
-
targetNode:
|
|
130
|
-
bgColor:
|
|
129
|
+
x: n.x - 90,
|
|
130
|
+
y: n.y - 90,
|
|
131
|
+
targetNode: o,
|
|
132
|
+
bgColor: o.style("background-color")
|
|
131
133
|
});
|
|
132
134
|
}), p.current = e, e.on("click", "node", (t) => {
|
|
133
|
-
const
|
|
134
|
-
e.nodes().removeClass("selected grayed highlighted"), e.edges().removeClass("selected grayed highlighted"),
|
|
135
|
-
const s =
|
|
136
|
-
console.log("cy.nodes().not(relatedNodes):::", s), e.nodes().not(s).addClass("grayed"), e.edges().not(
|
|
135
|
+
const o = t.target;
|
|
136
|
+
e.nodes().removeClass("selected grayed highlighted"), e.edges().removeClass("selected grayed highlighted"), o.addClass("selected");
|
|
137
|
+
const s = o.neighborhood().nodes().add(o), x = s.edgesWith(s);
|
|
138
|
+
console.log("cy.nodes().not(relatedNodes):::", s), e.nodes().not(s).addClass("grayed"), e.edges().not(x).addClass("grayed"), s.addClass("highlighted"), x.addClass("highlighted");
|
|
137
139
|
}), e.on("tap", (t) => {
|
|
138
|
-
t.target === e && (
|
|
140
|
+
t.target === e && (L((o) => ({ ...o, 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"));
|
|
139
141
|
}), () => {
|
|
140
142
|
p.current && (p.current.destroy(), p.current = null);
|
|
141
143
|
};
|
|
142
144
|
}, []);
|
|
143
|
-
const
|
|
144
|
-
const { id:
|
|
145
|
+
const ye = async (r) => {
|
|
146
|
+
const { id: a, kgId: g } = r, e = p.current;
|
|
145
147
|
if (!e) return;
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
148
|
+
const d = e.$(`#${a}`);
|
|
149
|
+
if (!d || d.length === 0) {
|
|
148
150
|
console.error("当前节点不存在");
|
|
149
151
|
return;
|
|
150
152
|
}
|
|
151
|
-
const t = e.nodes().filter((
|
|
153
|
+
const t = e.nodes().filter((n) => n.data("parentId") ? (n.data("parentId") === a || n.data("idLabel") === `${a}-${n.data("name")}`) && n.data("zktype") === r.zktype : !1);
|
|
152
154
|
if (t.length > 0) {
|
|
153
|
-
const
|
|
154
|
-
(l) => l.data("source") ===
|
|
155
|
-
),
|
|
155
|
+
const n = t.map((l) => l.id()), s = t.connectedEdges(), x = e.edges().filter(
|
|
156
|
+
(l) => l.data("source") === a && n.includes(l.data("target"))
|
|
157
|
+
), D = e.edges().filter((l) => l.data("appendedBy") === a), M = s.merge(x).merge(D).filter((l) => l.data().zktype === r.zktype);
|
|
156
158
|
t.animate({
|
|
157
159
|
style: { opacity: 0 }
|
|
158
160
|
}, {
|
|
159
161
|
duration: 200,
|
|
160
162
|
complete: () => {
|
|
161
163
|
e.remove(t), e.remove(M), P((l) => {
|
|
162
|
-
const
|
|
163
|
-
var
|
|
164
|
-
const i =
|
|
165
|
-
if (
|
|
164
|
+
const O = l.filter((f) => {
|
|
165
|
+
var b, ee;
|
|
166
|
+
const i = f.data.zktype;
|
|
167
|
+
if (f.group === "nodes" && n.includes((b = f.data) == null ? void 0 : b.id) && i && i === r.zktype)
|
|
166
168
|
return !1;
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
const A =
|
|
169
|
+
if (f.group === "edges" && i && i === r.zktype) {
|
|
170
|
+
const he = Array.from(D).map((xe) => {
|
|
171
|
+
const A = xe.data();
|
|
170
172
|
return `${A.source}-${A.target}-${A.label}`;
|
|
171
|
-
}), q =
|
|
172
|
-
return !
|
|
173
|
+
}), q = f.data, ve = he.includes(`${q.source}-${q.target}-${q.label}`), be = ((ee = f.data) == null ? void 0 : ee.appendedBy) === a;
|
|
174
|
+
return !ve && !be;
|
|
173
175
|
}
|
|
174
176
|
return !0;
|
|
175
|
-
}), { typeListObj:
|
|
176
|
-
return B(
|
|
177
|
-
}),
|
|
177
|
+
}), { typeListObj: y, relationListObj: U } = F({}, { graphData: O, typeObj: {} });
|
|
178
|
+
return B(y), W(U), O;
|
|
179
|
+
}), d.data("appendedNodes", []), d.data("isExpanded", !1);
|
|
178
180
|
}
|
|
179
181
|
}), setTimeout(() => {
|
|
180
|
-
|
|
182
|
+
d.removed() || (d.style("border-width", ""), d.style("border-color", ""));
|
|
181
183
|
}, 300);
|
|
182
184
|
} else {
|
|
183
185
|
try {
|
|
184
|
-
|
|
186
|
+
J(!0), C.open({
|
|
185
187
|
type: "loading",
|
|
186
188
|
content: "正在展开...",
|
|
187
189
|
duration: 0
|
|
188
190
|
});
|
|
189
|
-
const
|
|
190
|
-
if (B(
|
|
191
|
+
const n = await se({ uri: a, queryType: 1, kgId: g, zktype: r.zktype }), { elements: s, typeListObj: x, relationListObj: D } = F(n.data, { graphData: v, typeObj: w, relationObj: T, zktype: r.zktype });
|
|
192
|
+
if (B(x), W(D), !((s == null ? void 0 : s.length) > 0)) {
|
|
191
193
|
setTimeout(() => {
|
|
192
|
-
|
|
194
|
+
C.destroy(), C.warning("暂无数据");
|
|
193
195
|
}, 2e3);
|
|
194
196
|
return;
|
|
195
197
|
}
|
|
196
198
|
if ((s == null ? void 0 : s.length) > 0) {
|
|
197
199
|
const M = e.layoutUtilities({
|
|
198
|
-
...
|
|
200
|
+
...oe(),
|
|
199
201
|
idealEdgeLength: 80,
|
|
200
202
|
// 与你的期望边长匹配
|
|
201
203
|
offset: 30
|
|
202
204
|
// 随机偏移,避免完全重叠
|
|
203
205
|
}), l = s.map((i) => {
|
|
204
206
|
if (i.group === "nodes") {
|
|
205
|
-
const
|
|
207
|
+
const b = 80 * X;
|
|
206
208
|
return {
|
|
207
209
|
...i,
|
|
208
210
|
style: {
|
|
209
211
|
opacity: 0,
|
|
210
|
-
width:
|
|
211
|
-
height:
|
|
212
|
+
width: b,
|
|
213
|
+
height: b
|
|
212
214
|
},
|
|
213
215
|
data: {
|
|
214
216
|
...i.data,
|
|
215
|
-
parentId:
|
|
217
|
+
parentId: a,
|
|
216
218
|
// 标记父节点
|
|
217
|
-
appendedBy:
|
|
219
|
+
appendedBy: a,
|
|
218
220
|
// 标记由谁追加
|
|
219
|
-
idLabel:
|
|
220
|
-
zktype:
|
|
221
|
+
idLabel: a + "-" + i.data.label,
|
|
222
|
+
zktype: r.zktype,
|
|
221
223
|
isAppended: !0,
|
|
222
224
|
// 标记是追加节点
|
|
223
|
-
baseWidth:
|
|
224
|
-
baseHeight:
|
|
225
|
+
baseWidth: b,
|
|
226
|
+
baseHeight: b
|
|
225
227
|
}
|
|
226
228
|
};
|
|
227
229
|
}
|
|
@@ -229,16 +231,16 @@ const et = ({
|
|
|
229
231
|
...i,
|
|
230
232
|
data: {
|
|
231
233
|
...i.data,
|
|
232
|
-
appendedBy:
|
|
233
|
-
zktype:
|
|
234
|
+
appendedBy: a,
|
|
235
|
+
zktype: r.zktype
|
|
234
236
|
}
|
|
235
237
|
};
|
|
236
|
-
}),
|
|
238
|
+
}), O = e.add(l);
|
|
237
239
|
P([...v, ...l]);
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
240
|
+
const y = O.filter(":node"), U = y.map((i) => i.id());
|
|
241
|
+
d.data("appendedNodes", U), d.data("isExpanded", !0);
|
|
242
|
+
const f = e.nodes().difference(y);
|
|
243
|
+
f.forEach((i) => i.lock()), M.placeNewNodes(y), e.layout({
|
|
242
244
|
name: "cose-bilkent",
|
|
243
245
|
randomize: !1,
|
|
244
246
|
// ⚠️ 这是关键!保持已有节点位置不变
|
|
@@ -254,8 +256,8 @@ const et = ({
|
|
|
254
256
|
// 可以适当减少,因为只需要微调
|
|
255
257
|
gravity: 0.6
|
|
256
258
|
}).run(), setTimeout(() => {
|
|
257
|
-
|
|
258
|
-
}, 2e3),
|
|
259
|
+
f.forEach((i) => i.unlock());
|
|
260
|
+
}, 2e3), y.animate({
|
|
259
261
|
style: {
|
|
260
262
|
opacity: 1,
|
|
261
263
|
width: 20,
|
|
@@ -265,72 +267,72 @@ const et = ({
|
|
|
265
267
|
duration: 400,
|
|
266
268
|
easing: "ease-out",
|
|
267
269
|
complete: () => {
|
|
268
|
-
|
|
270
|
+
y.style("opacity", ""), y.style("width", ""), y.style("height", "");
|
|
269
271
|
}
|
|
270
272
|
}), setTimeout(() => {
|
|
271
|
-
|
|
273
|
+
d.removed() || (d.style("border-width", ""), d.style("border-color", ""), e.center(d), e.zoom(e.zoom()));
|
|
272
274
|
}, 600);
|
|
273
275
|
} else
|
|
274
276
|
console.log("没有找到相关节点数据");
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
C.destroy();
|
|
278
|
+
} catch (n) {
|
|
279
|
+
C.destroy(), C.error("请求接口失败"), console.error("22请求接口失败:", n);
|
|
277
280
|
}
|
|
278
|
-
|
|
281
|
+
J(!1);
|
|
279
282
|
}
|
|
280
|
-
|
|
281
|
-
},
|
|
283
|
+
L({ visible: !1 });
|
|
284
|
+
}, fe = {
|
|
282
285
|
expanded: "typed-literal",
|
|
283
286
|
contract: "uri"
|
|
284
|
-
},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
287
|
+
}, me = (r, a) => {
|
|
288
|
+
var e;
|
|
289
|
+
console.log("handleMenuAction:::", r, a);
|
|
290
|
+
const g = a || u.targetNode;
|
|
291
|
+
if (g) {
|
|
292
|
+
const d = r.ids, t = g.data();
|
|
293
|
+
if (["expanded", "contract"].includes(d))
|
|
294
|
+
ye({ kgId: 3, ...t, zktype: fe[d] });
|
|
295
|
+
else if (d === "nodeInfo") {
|
|
296
|
+
const o = g, n = {
|
|
297
|
+
id: o.id(),
|
|
298
|
+
data: o.data(),
|
|
299
|
+
position: o.position(),
|
|
300
|
+
degree: o.degree(),
|
|
301
|
+
inDegree: o.degree(!0),
|
|
302
|
+
outDegree: o.degree(!1),
|
|
303
|
+
classes: o.classes(),
|
|
304
|
+
style: o.style()
|
|
300
305
|
};
|
|
301
|
-
|
|
302
|
-
} else
|
|
303
|
-
|
|
304
|
-
Y.current.open(e.data());
|
|
305
|
-
}
|
|
306
|
-
d.action(c.targetNode), E({ visible: !1, x: 0, y: 0, targetNode: null });
|
|
306
|
+
Q.current.open(n);
|
|
307
|
+
} else d === "knowledgeCard" && V.current.open(g.data());
|
|
308
|
+
(e = r.onClick) == null || e.call(r, g), L({ visible: !1, x: 0, y: 0, targetNode: null });
|
|
307
309
|
}
|
|
308
310
|
};
|
|
309
|
-
return
|
|
310
|
-
/* @__PURE__ */
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
311
|
+
return v.length < 1 ? /* @__PURE__ */ c(Te, { className: "h-100", align: "middle", justify: "center", children: /* @__PURE__ */ c($e, { description: le }) }) : /* @__PURE__ */ c(Ie, { value: { pathNodes: ue, setPathNodes: Y, graphInfo: m, graphData: v, layoutType: ce, setLayoutType: pe, knowledgeCardApi: de }, children: /* @__PURE__ */ te("div", { className: "cytoscape-container relative", children: [
|
|
312
|
+
/* @__PURE__ */ c("div", { className: "btn-group" }),
|
|
313
|
+
/* @__PURE__ */ c(
|
|
314
|
+
ze,
|
|
313
315
|
{
|
|
314
|
-
ref:
|
|
316
|
+
ref: K,
|
|
315
317
|
cyRef: p,
|
|
316
|
-
graphInfo:
|
|
317
|
-
initNodeScale:
|
|
318
|
-
cyContainerRef:
|
|
319
|
-
typeObj:
|
|
320
|
-
relationObj:
|
|
321
|
-
colors:
|
|
322
|
-
actionBar:
|
|
318
|
+
graphInfo: m,
|
|
319
|
+
initNodeScale: X,
|
|
320
|
+
cyContainerRef: j,
|
|
321
|
+
typeObj: w,
|
|
322
|
+
relationObj: T,
|
|
323
|
+
colors: z,
|
|
324
|
+
actionBar: ae
|
|
323
325
|
}
|
|
324
326
|
),
|
|
325
|
-
/* @__PURE__ */
|
|
326
|
-
/* @__PURE__ */
|
|
327
|
-
|
|
327
|
+
/* @__PURE__ */ te("div", { className: "relative h-100", children: [
|
|
328
|
+
/* @__PURE__ */ c("div", { ref: j, className: "cy-container" }),
|
|
329
|
+
u.visible && u.targetNode && /* @__PURE__ */ c(
|
|
328
330
|
"div",
|
|
329
331
|
{
|
|
330
332
|
style: {
|
|
331
333
|
position: "absolute",
|
|
332
|
-
left: `${
|
|
333
|
-
top: `${
|
|
334
|
+
left: `${u.x}px`,
|
|
335
|
+
top: `${u.y}px`,
|
|
334
336
|
// backgroundColor: 'white',
|
|
335
337
|
// border: '1px solid #ccc',
|
|
336
338
|
// borderRadius: '50%',
|
|
@@ -343,17 +345,17 @@ const et = ({
|
|
|
343
345
|
height: "200px",
|
|
344
346
|
overflow: "hidden"
|
|
345
347
|
},
|
|
346
|
-
onClick: (
|
|
347
|
-
children: /* @__PURE__ */
|
|
348
|
+
onClick: (r) => r.stopPropagation(),
|
|
349
|
+
children: /* @__PURE__ */ c(Oe, { items: ge, centerImage: (G = u == null ? void 0 : u.targetNode) == null ? void 0 : G.data().image, targetNode: u.targetNode, onClick: (r, a) => me(r, a) })
|
|
348
350
|
}
|
|
349
351
|
),
|
|
350
|
-
|
|
352
|
+
$.visible && /* @__PURE__ */ c(
|
|
351
353
|
"div",
|
|
352
354
|
{
|
|
353
355
|
style: {
|
|
354
356
|
position: "absolute",
|
|
355
|
-
left: `${
|
|
356
|
-
top: `${
|
|
357
|
+
left: `${$.x}px`,
|
|
358
|
+
top: `${$.y}px`,
|
|
357
359
|
transform: "translateX(-50%)",
|
|
358
360
|
backgroundColor: "rgba(0, 0, 0, 0.85)",
|
|
359
361
|
color: "#fff",
|
|
@@ -367,14 +369,14 @@ const et = ({
|
|
|
367
369
|
overflow: "hidden",
|
|
368
370
|
textOverflow: "ellipsis"
|
|
369
371
|
},
|
|
370
|
-
children:
|
|
372
|
+
children: $.content
|
|
371
373
|
}
|
|
372
374
|
)
|
|
373
375
|
] }),
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
+
/* @__PURE__ */ c(Se, { ref: Q }),
|
|
377
|
+
/* @__PURE__ */ c(Pe, { ref: V })
|
|
376
378
|
] }) });
|
|
377
379
|
};
|
|
378
380
|
export {
|
|
379
|
-
|
|
381
|
+
rt as default
|
|
380
382
|
};
|
package/lib/index.es7.js
CHANGED
|
@@ -16,8 +16,6 @@ import { actionList as ft } from "./index.es4.js";
|
|
|
16
16
|
const q = (b, r) => (S) => {
|
|
17
17
|
S.stopPropagation(), b == null || b(r || "");
|
|
18
18
|
}, bt = (b) => {
|
|
19
|
-
if (!b)
|
|
20
|
-
return { bottom: 20, right: 20 };
|
|
21
19
|
if (typeof b == "string")
|
|
22
20
|
switch (b) {
|
|
23
21
|
case "top":
|
|
@@ -49,7 +47,7 @@ const q = (b, r) => (S) => {
|
|
|
49
47
|
actionBar: L
|
|
50
48
|
}, me) => {
|
|
51
49
|
var ne, se, ae;
|
|
52
|
-
const F = L == null ? void 0 : L.position, K = (L == null ? void 0 : L.actionList) ?? ft, H = { ...z, ...ge }, { layoutType: ue, setLayoutType: pe } = Ue(dt), [k, fe] = y(""), [be, M] = y(!1), [Q, we] = y(S), [ye, V] = y(!1), [Ce, P] = y(!1), [G, ve] = y(null), [xe, U] = y(!1), [X, Y] = y(!1), [Se, Ne] = y("node"), O = Xe(null), [B, Le] = y(!0), [R, ke] = y(/* @__PURE__ */ new Set()), [ee, De] = y(/* @__PURE__ */ new Set());
|
|
50
|
+
const F = (L == null ? void 0 : L.position) || "top-left", K = (L == null ? void 0 : L.actionList) ?? ft, H = { ...z, ...ge }, { layoutType: ue, setLayoutType: pe } = Ue(dt), [k, fe] = y(""), [be, M] = y(!1), [Q, we] = y(S), [ye, V] = y(!1), [Ce, P] = y(!1), [G, ve] = y(null), [xe, U] = y(!1), [X, Y] = y(!1), [Se, Ne] = y("node"), O = Xe(null), [B, Le] = y(!0), [R, ke] = y(/* @__PURE__ */ new Set()), [ee, De] = y(/* @__PURE__ */ new Set());
|
|
53
51
|
Ye(me, () => ({
|
|
54
52
|
onPathAnalysis: () => {
|
|
55
53
|
oe();
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
interface MenuItem {
|
|
3
3
|
label: string;
|
|
4
|
-
|
|
4
|
+
ids?: string;
|
|
5
|
+
onClick?: (node?: any) => void;
|
|
5
6
|
}
|
|
6
7
|
interface RadialMenuProps {
|
|
7
8
|
items?: MenuItem[];
|
|
8
9
|
centerImage?: string;
|
|
9
10
|
size?: number;
|
|
10
|
-
onClick: any;
|
|
11
|
+
onClick: (item: MenuItem, targetNode?: any) => void;
|
|
12
|
+
targetNode?: any;
|
|
11
13
|
}
|
|
12
14
|
declare const RadialMenu: React.FC<RadialMenuProps>;
|
|
13
15
|
export default RadialMenu;
|
|
@@ -63,6 +63,14 @@ export type ActionBarPosition = 'top' | 'bottom' | 'left' | 'right' | 'top-left'
|
|
|
63
63
|
bottom?: string | number;
|
|
64
64
|
left?: string | number;
|
|
65
65
|
};
|
|
66
|
+
export interface ActionCircleItem {
|
|
67
|
+
/** 菜单项唯一标识 */
|
|
68
|
+
ids: string;
|
|
69
|
+
/** 菜单项显示文本 */
|
|
70
|
+
label: string;
|
|
71
|
+
/** 自定义点击事件 */
|
|
72
|
+
onClick?: (node: any) => void;
|
|
73
|
+
}
|
|
66
74
|
export interface ActionBarItem {
|
|
67
75
|
key: string;
|
|
68
76
|
title: string;
|
|
@@ -79,7 +87,7 @@ export interface ActionBarConfig {
|
|
|
79
87
|
}
|
|
80
88
|
export interface CytoscapeReactProps {
|
|
81
89
|
/** 图谱数据 */
|
|
82
|
-
data
|
|
90
|
+
data?: GraphData | any[];
|
|
83
91
|
/** 获取完整图谱数据的回调函数 */
|
|
84
92
|
getAllGraphData?: (params?: any) => void;
|
|
85
93
|
/** 搜索类型 */
|
|
@@ -98,4 +106,8 @@ export interface CytoscapeReactProps {
|
|
|
98
106
|
actionBarPosition?: ActionBarPosition;
|
|
99
107
|
/** ActionBar 配置 */
|
|
100
108
|
actionBar?: ActionBarConfig;
|
|
109
|
+
/** 右键菜单配置,传入则覆盖/追加默认菜单项 */
|
|
110
|
+
actionCircle?: ActionCircleItem[];
|
|
111
|
+
/** 暂无数据描述 */
|
|
112
|
+
noDataDesc?: string;
|
|
101
113
|
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { ActionCircleItem } from '../types';
|
|
2
|
+
export declare const menuItemsConfig: ({ cyRef, setContextMenu, onPathAnalysis, setPathNodes, actionCircle }: {
|
|
3
|
+
cyRef: any;
|
|
4
|
+
setContextMenu: any;
|
|
5
|
+
onPathAnalysis?: () => void;
|
|
6
|
+
setPathNodes: any;
|
|
7
|
+
actionCircle?: ActionCircleItem[];
|
|
8
|
+
}) => {
|
|
9
|
+
label: string;
|
|
10
|
+
ids: string;
|
|
11
|
+
onClick: (node: any) => void;
|
|
12
|
+
}[];
|