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/lib/index.es3.js CHANGED
@@ -1,70 +1,72 @@
1
- import { jsx as y, jsxs as oe } from "react/jsx-runtime";
2
- import { useRef as x, useState as m, useEffect as O } from "react";
3
- import N from "cytoscape";
4
- import be from "cytoscape-cose-bilkent";
5
- import xe from "cytoscape-cise";
6
- import Ne from "cytoscape-fcose";
7
- import Ce from "storm-layout";
8
- import ke from "./index.es7.js";
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 ze, resDetailData as F } from "./index.es8.js";
11
- import { fixNodesToEdges as Ee, coseBilkentLayout as ne } from "./index.es9.js";
12
- import { edgeNodeStyles as we, defaultColors as se } from "./index.es10.js";
13
- import Le from "cytoscape-layout-utilities";
14
- import { message as S } from "antd";
15
- import { menuItemsConfig as Re } from "./index.es11.js";
16
- import { jsonStringify as L } from "./index.es12.js";
17
- import je from "./index.es13.js";
18
- import Te from "./index.es14.js";
19
- import { GraphProvider as $e } from "./index.es15.js";
20
- import De from "./index.es16.js";
21
- N.use(Le);
22
- N.use(xe);
23
- N.use(Ne);
24
- N.use(Ce);
25
- N.use(be);
26
- const et = ({
27
- data: de,
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: C = [],
30
- graphInfo: f,
31
- stepNextApi: re,
32
- knowledgeCardApi: ae,
33
- colors: k,
34
- actionBar: K
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 G, ee;
37
- const R = x(null), [v, P] = m([]), p = x(null), X = x(null), J = 1, [Oe, Q] = m(!1), [z, B] = m({}), [j, W] = m({}), [ie, le] = m("cose-bilkent"), V = x(null), Y = x(null), [ce, Z] = m(["", ""]), H = x(k);
38
- O(() => {
39
- H.current = k;
40
- }, [k]);
41
- const [c, E] = m({
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
- }), [T, _] = m({
49
+ }), [$, Z] = h({
48
50
  visible: !1,
49
51
  x: 0,
50
52
  y: 0,
51
53
  content: ""
52
- }), pe = Re({ cyRef: p, setContextMenu: E, onPathAnalysis: (G = X.current) == null ? void 0 : G.onPathAnalysis, setPathNodes: Z });
53
- O(() => {
54
- (C == null ? void 0 : C.length) > 1 && ze(p, { pathNodes: C, isGrayed: !1 });
55
- }, [L(C), L(v)]), O(() => {
56
- I == null || I({ graphData: v, nodeStatic: z, relationStatic: j });
57
- }, [L(v), L(z), L(j)]), O(() => {
58
- var a;
59
- if (!R.current || p.current) return;
60
- const { elements: d, typeListObj: r, relationListObj: w } = F(de, { typeObj: z, graphInfo: f });
61
- B(r), P(d), W(w), document.addEventListener("contextmenu", function(t) {
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 = N({
65
- container: R.current,
66
- elements: d,
67
- style: we({ elements: d, colors: k }),
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, ((a = f == null ? void 0 : f.searchNodes) == null ? void 0 : a.length) === 2)
76
- Ee(
77
+ if (p.current = e, ((d = m == null ? void 0 : m.searchNodes) == null ? void 0 : d.length) === 2)
78
+ Le(
77
79
  e,
78
- f.searchNodes[0],
79
- f.searchNodes[1]
80
+ m.searchNodes[0],
81
+ m.searchNodes[1]
80
82
  );
81
83
  else {
82
- const t = e.layout(ne());
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 o;
89
- const n = t.target;
90
- if (!n.hasClass("path-edge")) {
91
- const s = ((o = H.current) == null ? void 0 : o.edgeHoverColor) ?? se.edgeHoverColor;
92
- n.style({
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 o;
100
- const n = t.target;
101
- if (!n.hasClass("path-edge")) {
102
- const s = ((o = H.current) == null ? void 0 : o.edgeDefaultColor) ?? se.edgeDefaultColor;
103
- n.style({
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 n = t.target;
111
- n.hasClass("selected") || n.addClass("hover");
112
+ const o = t.target;
113
+ o.hasClass("selected") || o.addClass("hover");
112
114
  }), e.on("mouseover", "node", (t) => {
113
- const n = t.target, o = n.renderedPosition(), s = n.data("name") || "";
114
- n.addClass("hover"), _({
115
+ const o = t.target, n = o.renderedPosition(), s = o.data("name") || "";
116
+ o.addClass("hover"), Z({
115
117
  visible: !0,
116
- x: o.x,
117
- y: o.y - 60,
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"), _((o) => ({ ...o, visible: !1 }));
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 n = t.target, o = n.renderedPosition();
125
- console.log("renderedPos:::", n.data(), n.style("background-color")), E({
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: o.x - 90,
128
- y: o.y - 90,
129
- targetNode: n,
130
- bgColor: n.style("background-color")
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 n = t.target;
134
- e.nodes().removeClass("selected grayed highlighted"), e.edges().removeClass("selected grayed highlighted"), n.addClass("selected");
135
- const s = n.neighborhood().nodes().add(n), b = s.edgesWith(s);
136
- console.log("cy.nodes().not(relatedNodes):::", s), e.nodes().not(s).addClass("grayed"), e.edges().not(b).addClass("grayed"), s.addClass("highlighted"), b.addClass("highlighted");
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 && (E((n) => ({ ...n, 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"));
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 ue = async (d) => {
144
- const { id: r, kgId: w } = d, e = p.current;
145
+ const ye = async (r) => {
146
+ const { id: a, kgId: g } = r, e = p.current;
145
147
  if (!e) return;
146
- const a = e.$(`#${r}`);
147
- if (!a || a.length === 0) {
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((o) => o.data("parentId") ? (o.data("parentId") === r || o.data("idLabel") === `${r}-${o.data("name")}`) && o.data("zktype") === d.zktype : !1);
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 o = t.map((l) => l.id()), s = t.connectedEdges(), b = e.edges().filter(
154
- (l) => l.data("source") === r && o.includes(l.data("target"))
155
- ), $ = e.edges().filter((l) => l.data("appendedBy") === r), M = s.merge(b).merge($).filter((l) => l.data().zktype === d.zktype);
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 D = l.filter((g) => {
163
- var h, te;
164
- const i = g.data.zktype;
165
- if (g.group === "nodes" && o.includes((h = g.data) == null ? void 0 : h.id) && i && i === d.zktype)
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 (g.group === "edges" && i && i === d.zktype) {
168
- const fe = Array.from($).map((ve) => {
169
- const A = ve.data();
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 = g.data, me = fe.includes(`${q.source}-${q.target}-${q.label}`), he = ((te = g.data) == null ? void 0 : te.appendedBy) === r;
172
- return !me && !he;
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: u, relationListObj: U } = F({}, { graphData: D, typeObj: {} });
176
- return B(u), W(U), D;
177
- }), a.data("appendedNodes", []), a.data("isExpanded", !1);
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
- a.removed() || (a.style("border-width", ""), a.style("border-color", ""));
182
+ d.removed() || (d.style("border-width", ""), d.style("border-color", ""));
181
183
  }, 300);
182
184
  } else {
183
185
  try {
184
- Q(!0), S.open({
186
+ J(!0), C.open({
185
187
  type: "loading",
186
188
  content: "正在展开...",
187
189
  duration: 0
188
190
  });
189
- const o = await re({ uri: r, queryType: 1, kgId: w, zktype: d.zktype }), { elements: s, typeListObj: b, relationListObj: $ } = F(o.data, { graphData: v, typeObj: z, relationObj: j, zktype: d.zktype });
190
- if (B(b), W($), !((s == null ? void 0 : s.length) > 0)) {
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
- S.destroy(), S.warning("暂无数据");
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
- ...ne(),
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 h = 80 * J;
207
+ const b = 80 * X;
206
208
  return {
207
209
  ...i,
208
210
  style: {
209
211
  opacity: 0,
210
- width: h,
211
- height: h
212
+ width: b,
213
+ height: b
212
214
  },
213
215
  data: {
214
216
  ...i.data,
215
- parentId: r,
217
+ parentId: a,
216
218
  // 标记父节点
217
- appendedBy: r,
219
+ appendedBy: a,
218
220
  // 标记由谁追加
219
- idLabel: r + "-" + i.data.label,
220
- zktype: d.zktype,
221
+ idLabel: a + "-" + i.data.label,
222
+ zktype: r.zktype,
221
223
  isAppended: !0,
222
224
  // 标记是追加节点
223
- baseWidth: h,
224
- baseHeight: h
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: r,
233
- zktype: d.zktype
234
+ appendedBy: a,
235
+ zktype: r.zktype
234
236
  }
235
237
  };
236
- }), D = e.add(l);
238
+ }), O = e.add(l);
237
239
  P([...v, ...l]);
238
- const u = D.filter(":node"), U = u.map((i) => i.id());
239
- a.data("appendedNodes", U), a.data("isExpanded", !0);
240
- const g = e.nodes().difference(u);
241
- g.forEach((i) => i.lock()), M.placeNewNodes(u), e.layout({
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
- g.forEach((i) => i.unlock());
258
- }, 2e3), u.animate({
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
- u.style("opacity", ""), u.style("width", ""), u.style("height", "");
270
+ y.style("opacity", ""), y.style("width", ""), y.style("height", "");
269
271
  }
270
272
  }), setTimeout(() => {
271
- a.removed() || (a.style("border-width", ""), a.style("border-color", ""), e.center(a), e.zoom(e.zoom()));
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
- } catch (o) {
276
- console.error("请求接口失败:", o);
277
+ C.destroy();
278
+ } catch (n) {
279
+ C.destroy(), C.error("请求接口失败"), console.error("22请求接口失败:", n);
277
280
  }
278
- Q(!1), S.destroy();
281
+ J(!1);
279
282
  }
280
- E({ visible: !1 });
281
- }, ge = {
283
+ L({ visible: !1 });
284
+ }, fe = {
282
285
  expanded: "typed-literal",
283
286
  contract: "uri"
284
- }, ye = (d) => {
285
- if (console.log("handleMenuAction:::", d), c.targetNode) {
286
- const r = d.ids, w = c.targetNode.data();
287
- if (["expanded", "contract"].includes(r))
288
- ue({ kgId: 3, ...w, zktype: ge[r] });
289
- else if (r === "nodeInfo") {
290
- const e = c.targetNode, a = {
291
- id: e.id(),
292
- data: e.data(),
293
- position: e.position(),
294
- degree: e.degree(),
295
- inDegree: e.degree(!0),
296
- outDegree: e.degree(!1),
297
- classes: e.classes(),
298
- // 样式信息
299
- style: e.style()
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
- V.current.open(a);
302
- } else if (r === "knowledgeCard") {
303
- const e = c.targetNode;
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 console.log(555, K), /* @__PURE__ */ y($e, { value: { pathNodes: ce, setPathNodes: Z, graphInfo: f, graphData: v, layoutType: ie, setLayoutType: le, knowledgeCardApi: ae }, children: /* @__PURE__ */ oe("div", { className: "cytoscape-container", style: { position: "relative" }, children: [
310
- /* @__PURE__ */ y("div", { className: "btn-group" }),
311
- /* @__PURE__ */ y(
312
- ke,
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: X,
316
+ ref: K,
315
317
  cyRef: p,
316
- graphInfo: f,
317
- initNodeScale: J,
318
- cyContainerRef: R,
319
- typeObj: z,
320
- relationObj: j,
321
- colors: k,
322
- actionBar: K
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__ */ oe("div", { style: { position: "relative" }, children: [
326
- /* @__PURE__ */ y("div", { ref: R, className: "cy-container" }),
327
- c.visible && c.targetNode && /* @__PURE__ */ y(
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: `${c.x}px`,
333
- top: `${c.y}px`,
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: (d) => d.stopPropagation(),
347
- children: /* @__PURE__ */ y(je, { items: pe, centerImage: (ee = c == null ? void 0 : c.targetNode) == null ? void 0 : ee.data().image, onClick: (d) => ye(d) })
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
- T.visible && /* @__PURE__ */ y(
352
+ $.visible && /* @__PURE__ */ c(
351
353
  "div",
352
354
  {
353
355
  style: {
354
356
  position: "absolute",
355
- left: `${T.x}px`,
356
- top: `${T.y}px`,
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: T.content
372
+ children: $.content
371
373
  }
372
374
  )
373
375
  ] }),
374
- /* @__PURE__ */ y(Te, { ref: V }),
375
- /* @__PURE__ */ y(De, { ref: Y })
376
+ /* @__PURE__ */ c(Se, { ref: Q }),
377
+ /* @__PURE__ */ c(Pe, { ref: V })
376
378
  ] }) });
377
379
  };
378
380
  export {
379
- et as default
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
- onClick?: () => void;
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: GraphData | any[];
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
- export declare const menuItemsConfig: any;
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
+ }[];