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.
Files changed (50) hide show
  1. package/lib/index.es10.js +20 -19
  2. package/lib/index.es14.js +39 -41
  3. package/lib/index.es16.js +20 -20
  4. package/lib/index.es17.js +42 -0
  5. package/lib/index.es18.js +3 -15466
  6. package/lib/index.es19.js +2 -54
  7. package/lib/index.es21.js +15461 -63
  8. package/lib/index.es22.js +53 -39
  9. package/lib/index.es23.js +60 -2
  10. package/lib/index.es24.js +69 -2
  11. package/lib/index.es25.js +2 -2
  12. package/lib/index.es26.js +2 -2
  13. package/lib/index.es27.js +1 -1
  14. package/lib/index.es28.js +1 -1
  15. package/lib/index.es29.js +1 -1
  16. package/lib/index.es3.js +100 -97
  17. package/lib/index.es30.js +1 -1
  18. package/lib/index.es31.js +1 -1
  19. package/lib/index.es32.js +1 -1
  20. package/lib/index.es33.js +2 -2
  21. package/lib/index.es34.js +4 -0
  22. package/lib/index.es35.js +2 -4
  23. package/lib/index.es37.js +66 -0
  24. package/lib/index.es38.js +1049 -0
  25. package/lib/index.es4.js +13 -9
  26. package/lib/index.es42.js +21 -0
  27. package/lib/index.es43.js +43 -0
  28. package/lib/index.es44.js +42 -0
  29. package/lib/index.es45.js +91 -0
  30. package/lib/index.es46.js +58 -0
  31. package/lib/index.es47.js +33 -0
  32. package/lib/index.es49.js +72 -0
  33. package/lib/index.es7.js +305 -305
  34. package/lib/index.es8.js +11 -11
  35. package/lib/src/components/Graph/components/ActionBar/actionList.d.ts +4 -0
  36. package/lib/src/components/Graph/components/KnowledgeCard/components/AudioSection.d.ts +12 -0
  37. package/lib/src/components/Graph/components/KnowledgeCard/components/DocumentSection.d.ts +12 -0
  38. package/lib/src/components/Graph/components/KnowledgeCard/components/ImageSection.d.ts +12 -0
  39. package/lib/src/components/Graph/components/KnowledgeCard/components/ListCard.d.ts +14 -0
  40. package/lib/src/components/Graph/components/KnowledgeCard/components/PropertySection.d.ts +11 -0
  41. package/lib/src/components/Graph/components/KnowledgeCard/components/RelationSection.d.ts +13 -0
  42. package/lib/src/components/Graph/components/KnowledgeCard/components/SourceCard.d.ts +6 -0
  43. package/lib/src/components/Graph/components/KnowledgeCard/components/VideoSection.d.ts +12 -0
  44. package/lib/src/components/Graph/components/KnowledgeCard/data.d.ts +84 -0
  45. package/lib/src/components/Graph/types.d.ts +7 -1
  46. package/lib/src/components/Graph/utils/edge_node_styles.d.ts +1 -0
  47. package/lib/style.css +1 -1
  48. package/package.json +1 -1
  49. package/lib/index.es20.js +0 -62
  50. package/lib/index.es36.js +0 -4
package/lib/index.es3.js CHANGED
@@ -1,84 +1,88 @@
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
- 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 ze from "storm-layout";
8
- import Ee from "./index.es7.js";
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 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";
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 $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);
23
- k.use(ke);
24
- k.use(ze);
25
- k.use(Ne);
26
- const nt = ({
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: h,
31
+ graphInfo: u,
31
32
  stepNextApi: re,
32
33
  knowledgeCardApi: ae,
33
34
  colors: E,
34
35
  actionBar: ie,
35
36
  actionCircle: le,
36
- noDataDesc: Ie = "暂无数据"
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, [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(() => {
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 [u, L] = v({
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
- }), [$, Z] = v({
52
+ }), [$, Y] = v({
50
53
  visible: !1,
51
54
  x: 0,
52
55
  y: 0,
53
56
  content: ""
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(() => {
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)]), S(() => {
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: g } = F(de, { typeObj: w, graphInfo: h });
63
- B(a), P(s), W(g), document.addEventListener("contextmenu", function(t) {
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 = k({
69
+ const e = C({
67
70
  container: j.current,
68
71
  elements: s,
69
- style: Re({ elements: s, colors: E }),
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 = h == null ? void 0 : h.searchNodes) == null ? void 0 : r.length) === 2)
78
- Le(
81
+ if (p.current = e, ((r = u == null ? void 0 : u.searchNodes) == null ? void 0 : r.length) === 2)
82
+ je(
79
83
  e,
80
- h.searchNodes[0],
81
- h.searchNodes[1]
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"), Z({
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"), Z((n) => ({ ...n, visible: !1 }));
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 ye = async (s) => {
146
- const { id: a, kgId: g } = s, e = p.current;
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 O = l.filter((f) => {
168
+ const S = l.filter((m) => {
165
169
  var b, te;
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)
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 (f.group === "edges" && i && i === s.zktype) {
170
- const he = Array.from(D).map((xe) => {
171
- const A = xe.data();
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 = 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;
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: y, relationListObj: U } = F({}, { graphData: O, typeObj: {} });
178
- return B(y), W(U), O;
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
- J(!0), C.open({
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: g, zktype: s.zktype }), { elements: d, typeListObj: x, relationListObj: D } = F(n.data, { graphData: c, typeObj: w, relationObj: T, zktype: s.zktype });
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
- C.destroy(), C.warning("暂无数据");
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 = 80 * X;
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
- }), O = e.add(l);
242
+ }), S = e.add(l);
239
243
  P([...c, ...l]);
240
- const y = O.filter(":node"), U = y.map((i) => i.id());
244
+ const f = S.filter(":node"), U = f.map((i) => i.id());
241
245
  r.data("appendedNodes", U), r.data("isExpanded", !0);
242
- const f = e.nodes().difference(y);
243
- f.forEach((i) => i.lock()), M.placeNewNodes(y), e.layout({
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
- f.forEach((i) => i.unlock());
260
- }, 2e3), y.animate({
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
- y.style("opacity", ""), y.style("width", ""), y.style("height", "");
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
- C.destroy();
281
+ k.destroy();
278
282
  } catch (n) {
279
- C.destroy(), C.error("请求接口失败"), console.error("22请求接口失败:", n);
283
+ k.destroy(), k.error("请求接口失败"), console.error("22请求接口失败:", n);
280
284
  }
281
- J(!1);
285
+ Z(!1);
282
286
  }
283
287
  L({ visible: !1 });
284
- }, fe = {
288
+ }, he = {
285
289
  expanded: "typed-literal",
286
290
  contract: "uri"
287
- }, me = (s, a) => {
291
+ }, ve = (s, a) => {
288
292
  var e;
289
293
  console.log("handleMenuAction:::", s, a);
290
- const g = a || u.targetNode;
291
- if (g) {
292
- const r = s.ids, t = g.data();
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
- ye({ kgId: 3, ...t, zktype: fe[r] });
298
+ me({ kgId: u.kgId, ...t, zktype: he[r] });
295
299
  else if (r === "nodeInfo") {
296
- const o = g, n = {
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
- Q.current.open(n);
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 });
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__ */ 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
+ 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: h,
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__ */ m("div", { ref: j, className: "cy-container" }),
329
- u.visible && u.targetNode && /* @__PURE__ */ m(
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: `${u.x}px`,
335
- top: `${u.y}px`,
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__ */ 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) })
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__ */ m(
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__ */ m(De, { ref: Q }),
377
- /* @__PURE__ */ m(Se, { ref: V })
379
+ /* @__PURE__ */ h(Ie, { ref: J }),
380
+ /* @__PURE__ */ h(Be, { ref: Q })
378
381
  ] }) });
379
382
  };
380
383
  export {
381
- nt as default
384
+ it as default
382
385
  };