react-kggraph 0.0.1
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 +16 -0
- package/lib/components/Graph/CytoscapeReact.css +1 -0
- package/lib/components/Graph/components/ActionBar/index.css +1 -0
- package/lib/components/Graph/components/PathAnalysis/index.css +1 -0
- package/lib/components/Graph/components/PathAnalysisLevel/index.css +1 -0
- package/lib/components/Graph/components/SettingCircle/index.css +1 -0
- package/lib/favicon.svg +1 -0
- package/lib/icons.svg +24 -0
- package/lib/index.cjs.js +1 -0
- package/lib/index.esm.js +3 -0
- package/lib/index10.cjs.js +1 -0
- package/lib/index10.esm.js +4 -0
- package/lib/index11.cjs.js +1 -0
- package/lib/index11.esm.js +4 -0
- package/lib/index12.cjs.js +1 -0
- package/lib/index12.esm.js +4 -0
- package/lib/index13.cjs.js +1 -0
- package/lib/index13.esm.js +4 -0
- package/lib/index14.cjs.js +1 -0
- package/lib/index14.esm.js +4 -0
- package/lib/index15.cjs.js +1 -0
- package/lib/index15.esm.js +4 -0
- package/lib/index16.cjs.js +1 -0
- package/lib/index16.esm.js +25 -0
- package/lib/index17.cjs.js +1 -0
- package/lib/index17.esm.js +330 -0
- package/lib/index18.cjs.js +1 -0
- package/lib/index18.esm.js +5 -0
- package/lib/index19.cjs.js +1 -0
- package/lib/index19.esm.js +284 -0
- package/lib/index2.cjs.js +1 -0
- package/lib/index2.esm.js +16 -0
- package/lib/index21.cjs.js +1 -0
- package/lib/index21.esm.js +27 -0
- package/lib/index22.cjs.js +16 -0
- package/lib/index22.esm.js +453 -0
- package/lib/index23.cjs.js +1 -0
- package/lib/index23.esm.js +10 -0
- package/lib/index24.cjs.js +1 -0
- package/lib/index24.esm.js +70 -0
- package/lib/index26.cjs.js +1 -0
- package/lib/index26.esm.js +68 -0
- package/lib/index28.cjs.js +1 -0
- package/lib/index28.esm.js +72 -0
- package/lib/index29.cjs.js +1 -0
- package/lib/index29.esm.js +32 -0
- package/lib/index30.cjs.js +1 -0
- package/lib/index30.esm.js +828 -0
- package/lib/index32.cjs.js +1 -0
- package/lib/index32.esm.js +4 -0
- package/lib/index33.cjs.js +1 -0
- package/lib/index33.esm.js +161 -0
- package/lib/index34.cjs.js +1 -0
- package/lib/index34.esm.js +71 -0
- package/lib/index36.cjs.js +1 -0
- package/lib/index36.esm.js +100 -0
- package/lib/index37.cjs.js +1 -0
- package/lib/index37.esm.js +250 -0
- package/lib/index38.cjs.js +1 -0
- package/lib/index38.esm.js +47 -0
- package/lib/index39.cjs.js +1 -0
- package/lib/index39.esm.js +378 -0
- package/lib/index4.cjs.js +95 -0
- package/lib/index4.esm.js +12387 -0
- package/lib/index40.cjs.js +1 -0
- package/lib/index40.esm.js +6 -0
- package/lib/index5.cjs.js +1 -0
- package/lib/index5.esm.js +4 -0
- package/lib/index6.cjs.js +1 -0
- package/lib/index6.esm.js +4 -0
- package/lib/index7.cjs.js +1 -0
- package/lib/index7.esm.js +4 -0
- package/lib/index8.cjs.js +1 -0
- package/lib/index8.esm.js +4 -0
- package/lib/index9.cjs.js +1 -0
- package/lib/index9.esm.js +4 -0
- package/lib/src/components/Graph/api.d.ts +2 -0
- package/lib/src/components/Graph/components/ActionBar/index.d.ts +9 -0
- package/lib/src/components/Graph/components/KnowledgeCard/index.d.ts +3 -0
- package/lib/src/components/Graph/components/NodeInfoDrawer/index.d.ts +3 -0
- package/lib/src/components/Graph/components/PathAnalysis/index.d.ts +9 -0
- package/lib/src/components/Graph/components/PathAnalysisLevel/index.d.ts +5 -0
- package/lib/src/components/Graph/components/QueryNode/index.d.ts +8 -0
- package/lib/src/components/Graph/components/SettingCircle/index.d.ts +13 -0
- package/lib/src/components/Graph/context.d.ts +2 -0
- package/lib/src/components/Graph/index.d.ts +8 -0
- package/lib/src/components/Graph/types.d.ts +6 -0
- package/lib/src/components/Graph/utils/edge_node_styles.d.ts +3 -0
- package/lib/src/components/Graph/utils/layouts.d.ts +108 -0
- package/lib/src/components/Graph/utils/menuItems.d.ts +1 -0
- package/lib/src/components/Graph/utils/tools.d.ts +38 -0
- package/package.json +64 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./index2.cjs.js`),t=require(`./index16.cjs.js`),n=require(`./index17.cjs.js`),r=require(`./index18.cjs.js`),i=require(`./index19.cjs.js`),a=require(`./index23.cjs.js`),o=require(`./index30.cjs.js`);;/* empty css */const s=require(`./index32.cjs.js`),c=require(`./index33.cjs.js`),l=require(`./index34.cjs.js`),u=require(`./index36.cjs.js`),d=require(`./index37.cjs.js`),f=require(`./index38.cjs.js`);let p=require(`react`),m=require(`cytoscape`);m=e.__toESM(m,1);let h=require(`cytoscape-cose-bilkent`);h=e.__toESM(h,1);let g=require(`cytoscape-cise`);g=e.__toESM(g,1);let _=require(`cytoscape-fcose`);_=e.__toESM(_,1);let v=require(`storm-layout`);v=e.__toESM(v,1);let y=require(`antd`),b=require(`cytoscape-layout-utilities`);b=e.__toESM(b,1);var x=a.default;m.default.use(b.default),m.default.use(g.default),m.default.use(_.default),m.default.use(v.default),m.default.use(h.default);var S=({data:e,getAllGraphData:a,searchType:h,highPathAnalysis:g=[],graphInfo:_})=>{let v=(0,p.useRef)(null),[b,S]=(0,p.useState)([]),C=(0,p.useRef)(null),w=(0,p.useRef)(null),[T,E]=(0,p.useState)(!1),[D,O]=(0,p.useState)({}),[k,A]=(0,p.useState)({}),[j,M]=(0,p.useState)(`cose-bilkent`),N=(0,p.useRef)(null),P=(0,p.useRef)(null),[F,I]=(0,p.useState)([``,``]),[L,R]=(0,p.useState)({visible:!1,x:0,y:0,targetNode:null,bgColor:``}),[z,B]=(0,p.useState)({visible:!1,x:0,y:0,content:``}),V=l.menuItemsConfig({cyRef:C,setContextMenu:R,onPathAnalysis:w.current?.onPathAnalysis,setPathNodes:I});(0,p.useEffect)(()=>{g?.length>1&&n.handleCalcPath(C,{pathNodes:g,isGrayed:!1})},[t.jsonStringify(g),t.jsonStringify(b)]),(0,p.useEffect)(()=>{a?.({graphData:b,nodeStatic:D,relationStatic:k})},[t.jsonStringify(b),t.jsonStringify(D),t.jsonStringify(k)]),(0,p.useEffect)(()=>{if(!v.current||C.current)return;let{elements:t,typeListObj:r,relationListObj:a}=n.resDetailData(e,{typeObj:D,relationObj:k,graphInfo:_});O(r),S(t),A(a),document.addEventListener(`contextmenu`,function(e){e.preventDefault()});let o=(0,m.default)({container:v.current,elements:t,style:c.edgeNodeStyles({elements:t}),autounselectify:!1,autolock:!1,layout:{name:`preset`}});if(C.current=o,_?.searchNodes?.length===2)i.fixNodesToEdges(o,_.searchNodes[0],_.searchNodes[1]);else{let e=o.layout(i.coseBilkentLayout());e.run(),e.on(`layoutstop`,()=>{o.fit(void 0,50),o.center()})}return o.on(`mouseover`,`edge`,e=>{e.target.hasClass(`path-edge`)||e.target.style({"line-color":`#1890ff`,"target-arrow-color":`#1890ff`,opacity:.8})}),o.on(`mouseout`,`edge`,e=>{e.target.hasClass(`path-edge`)||e.target.style({"line-color":`#ccc`,"target-arrow-color":`#ccc`,opacity:1})}),o.on(`mouseover`,`node`,e=>{let t=e.target;t.hasClass(`selected`)||t.addClass(`hover`)}),o.on(`mouseover`,`node`,e=>{let t=e.target,n=t.renderedPosition(),r=t.data(`name`)||``;t.addClass(`hover`),B({visible:!0,x:n.x,y:n.y-60,content:r})}),o.on(`mouseout`,`node`,e=>{e.target.removeClass(`hover`),B(e=>({...e,visible:!1}))}),o.on(`cxttap`,`node`,e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.originalEvent&&(e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),e.originalEvent.stopImmediatePropagation());let t=e.target,n=t.renderedPosition();console.log(`renderedPos:::`,t.data(),t.style(`background-color`)),R({visible:!0,x:n.x-90,y:n.y-90,targetNode:t,bgColor:t.style(`background-color`)})}),C.current=o,o.on(`click`,`node`,e=>{let t=e.target;o.nodes().removeClass(`selected grayed highlighted`),o.edges().removeClass(`selected grayed highlighted`),t.addClass(`selected`);let n=t.neighborhood().nodes().add(t),r=n.edgesWith(n);console.log(`cy.nodes().not(relatedNodes):::`,n),o.nodes().not(n).addClass(`grayed`),o.edges().not(r).addClass(`grayed`),n.addClass(`highlighted`),r.addClass(`highlighted`)}),o.on(`tap`,e=>{e.target===o&&(R(e=>({...e,visible:!1})),o.nodes().removeClass(`grayed highlighted highlight selected correlationStyle path-node level-highlight level-selected level-grayed`),o.edges().removeClass(`grayed highlighted highlight selected correlationStyle path-edge level-highlightedge level-grayed`))}),()=>{C.current&&=(C.current.destroy(),null)}},[]);let H=async e=>{let{id:t,kgId:r}=e,a=C.current;if(!a)return;let o=a.$(`#${t}`);if(!o||o.length===0){console.error(`当前节点不存在`);return}let c=a.nodes().filter(n=>n.data(`parentId`)?(n.data(`parentId`)===t||n.data(`idLabel`)===`${t}-${n.data(`name`)}`)&&n.data(`zktype`)===e.zktype:!1);if(c.length>0){let r=c.map(e=>e.id()),i=c.connectedEdges(),s=a.edges().filter(e=>e.data(`source`)===t&&r.includes(e.data(`target`))),l=a.edges().filter(e=>e.data(`appendedBy`)===t),u=i.merge(s).merge(l).filter(t=>t.data().zktype===e.zktype);c.animate({style:{opacity:0}},{duration:200,complete:()=>{a.remove(c),a.remove(u),S(i=>{let a=i.filter(n=>{let i=n.data.zktype;if(n.group===`nodes`&&r.includes(n.data?.id)&&i&&i===e.zktype)return!1;if(n.group===`edges`&&i&&i===e.zktype){let e=Array.from(l).map(e=>{let t=e.data();return`${t.source}-${t.target}-${t.label}`}),r=n.data,i=e.includes(`${r.source}-${r.target}-${r.label}`),a=n.data?.appendedBy===t;return!i&&!a}return!0}),{typeListObj:o,relationListObj:s}=n.resDetailData({},{graphData:a,typeObj:{},relationObj:{},isOnlyStatic:!0});return O(o),A(s),a}),o.data(`appendedNodes`,[]),o.data(`isExpanded`,!1)}}),setTimeout(()=>{o.removed()||(o.style(`border-width`,``),o.style(`border-color`,``))},300)}else{try{E(!0),y.message.open({type:`loading`,content:`正在展开...`,duration:0});let{elements:c,typeListObj:l,relationListObj:u}=n.resDetailData((await s.stepNext({uri:t,queryType:1,kgId:r,zktype:e.zktype})).data,{graphData:b,typeObj:D,relationObj:k,zktype:e.zktype});if(O(l),A(u),console.log(555e3,c),!(c?.length>0)){y.message.warning(`暂无数据`),setTimeout(()=>{y.message.destroy()},2e3);return}if(c?.length>0){let n=a.layoutUtilities({...i.coseBilkentLayout(),idealEdgeLength:80,offset:30}),r=c.map(n=>n.group===`nodes`?{...n,style:{opacity:0,width:80,height:80},data:{...n.data,parentId:t,appendedBy:t,idLabel:t+`-`+n.data.label,zktype:e.zktype,isAppended:!0,baseWidth:80,baseHeight:80}}:{...n,data:{...n.data,appendedBy:t,zktype:e.zktype}}),s=a.add(r);S([...b,...r]);let l=s.filter(`:node`),u=l.map(e=>e.id());o.data(`appendedNodes`,u),o.data(`isExpanded`,!0);let d=a.nodes().difference(l);d.forEach(e=>e.lock()),n.placeNewNodes(l),a.layout({name:`cose-bilkent`,randomize:!1,animate:!0,animationDuration:500,fit:!1,nodeRepulsion:1005e3,idealEdgeLength:100,edgeElasticity:.3,numIter:800,gravity:.6}).run(),setTimeout(()=>{d.forEach(e=>e.unlock())},2e3),l.animate({style:{opacity:1,width:20,height:30}},{duration:400,easing:`ease-out`,complete:()=>{l.style(`opacity`,``),l.style(`width`,``),l.style(`height`,``)}}),setTimeout(()=>{o.removed()||(o.style(`border-width`,``),o.style(`border-color`,``),a.center(o),a.zoom(a.zoom()))},600)}else console.log(`没有找到相关节点数据`)}catch(e){console.error(`请求接口失败:`,e)}E(!1),y.message.destroy()}R({visible:!1})},U={expanded:`typed-literal`,contract:`uri`},W=e=>{if(console.log(`handleMenuAction:::`,e),L.targetNode){let t=e.ids,n=L.targetNode.data();if([`expanded`,`contract`].includes(t))H({kgId:3,...n,zktype:U[t]});else if(t===`nodeInfo`){let e=L.targetNode,t={id:e.id(),data:e.data(),position:e.position(),degree:e.degree(),inDegree:e.degree(!0),outDegree:e.degree(!1),classes:e.classes(),style:e.style()};N.current.open(t)}else if(t===`knowledgeCard`){let e=L.targetNode;P.current.open(e.data())}e.action(L.targetNode),R({visible:!1,x:0,y:0,targetNode:null})}};return(0,x.jsx)(r.GraphProvider,{value:{pathNodes:F,setPathNodes:I,graphInfo:_,graphData:b,layoutType:j,setLayoutType:M},children:(0,x.jsxs)(`div`,{className:`cytoscape-container`,style:{position:`relative`},children:[(0,x.jsx)(`div`,{className:`btn-group`}),(0,x.jsx)(o.default,{ref:w,cyRef:C,graphInfo:_,initNodeScale:1,cyContainerRef:v,typeObj:D,relationObj:k}),(0,x.jsxs)(`div`,{style:{position:`relative`},children:[(0,x.jsx)(`div`,{ref:v,className:`cy-container`}),L.visible&&L.targetNode&&(0,x.jsx)(`div`,{style:{position:`absolute`,left:`${L.x}px`,top:`${L.y}px`,zIndex:1e4,minWidth:`120px`,padding:`4px 0`,pointerEvents:`auto`,width:`200px`,height:`200px`,overflow:`hidden`},onClick:e=>e.stopPropagation(),children:(0,x.jsx)(u.default,{items:V,centerImage:L?.targetNode?.data().image,onClick:e=>W(e)})}),z.visible&&(0,x.jsx)(`div`,{style:{position:`absolute`,left:`${z.x}px`,top:`${z.y}px`,transform:`translateX(-50%)`,backgroundColor:`rgba(0, 0, 0, 0.85)`,color:`#fff`,padding:`6px 12px`,borderRadius:`4px`,fontSize:`14px`,whiteSpace:`nowrap`,zIndex:9999,pointerEvents:`none`,maxWidth:`1000px`,overflow:`hidden`,textOverflow:`ellipsis`},children:z.content})]}),(0,x.jsx)(d.default,{ref:N}),(0,x.jsx)(f.default,{ref:P})]})})};exports.default=S;
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { jsonStringify as e } from "./index16.esm.js";
|
|
2
|
+
import { handleCalcPath as t, resDetailData as n } from "./index17.esm.js";
|
|
3
|
+
import { GraphProvider as r } from "./index18.esm.js";
|
|
4
|
+
import { coseBilkentLayout as i, fixNodesToEdges as a } from "./index19.esm.js";
|
|
5
|
+
import { require_jsx_runtime as o } from "./index23.esm.js";
|
|
6
|
+
import s from "./index30.esm.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { stepNext as c } from "./index32.esm.js";
|
|
9
|
+
import { edgeNodeStyles as l } from "./index33.esm.js";
|
|
10
|
+
import { menuItemsConfig as u } from "./index34.esm.js";
|
|
11
|
+
import d from "./index36.esm.js";
|
|
12
|
+
import f from "./index37.esm.js";
|
|
13
|
+
import p from "./index38.esm.js";
|
|
14
|
+
import { useEffect as m, useRef as h, useState as g } from "react";
|
|
15
|
+
import _ from "cytoscape";
|
|
16
|
+
import v from "cytoscape-cose-bilkent";
|
|
17
|
+
import y from "cytoscape-cise";
|
|
18
|
+
import b from "cytoscape-fcose";
|
|
19
|
+
import x from "storm-layout";
|
|
20
|
+
import { message as S } from "antd";
|
|
21
|
+
import C from "cytoscape-layout-utilities";
|
|
22
|
+
//#region src/components/Graph/index.tsx
|
|
23
|
+
var w = o();
|
|
24
|
+
_.use(C), _.use(y), _.use(b), _.use(x), _.use(v);
|
|
25
|
+
var T = ({ data: o, getAllGraphData: v, searchType: y, highPathAnalysis: b = [], graphInfo: x }) => {
|
|
26
|
+
let C = h(null), [T, E] = g([]), D = h(null), O = h(null), [k, A] = g(!1), [j, M] = g({}), [N, P] = g({}), [F, I] = g("cose-bilkent"), L = h(null), R = h(null), [z, B] = g(["", ""]), [V, H] = g({
|
|
27
|
+
visible: !1,
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
targetNode: null,
|
|
31
|
+
bgColor: ""
|
|
32
|
+
}), [U, W] = g({
|
|
33
|
+
visible: !1,
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
36
|
+
content: ""
|
|
37
|
+
}), G = u({
|
|
38
|
+
cyRef: D,
|
|
39
|
+
setContextMenu: H,
|
|
40
|
+
onPathAnalysis: O.current?.onPathAnalysis,
|
|
41
|
+
setPathNodes: B
|
|
42
|
+
});
|
|
43
|
+
m(() => {
|
|
44
|
+
b?.length > 1 && t(D, {
|
|
45
|
+
pathNodes: b,
|
|
46
|
+
isGrayed: !1
|
|
47
|
+
});
|
|
48
|
+
}, [e(b), e(T)]), m(() => {
|
|
49
|
+
v?.({
|
|
50
|
+
graphData: T,
|
|
51
|
+
nodeStatic: j,
|
|
52
|
+
relationStatic: N
|
|
53
|
+
});
|
|
54
|
+
}, [
|
|
55
|
+
e(T),
|
|
56
|
+
e(j),
|
|
57
|
+
e(N)
|
|
58
|
+
]), m(() => {
|
|
59
|
+
if (!C.current || D.current) return;
|
|
60
|
+
let { elements: e, typeListObj: t, relationListObj: r } = n(o, {
|
|
61
|
+
typeObj: j,
|
|
62
|
+
relationObj: N,
|
|
63
|
+
graphInfo: x
|
|
64
|
+
});
|
|
65
|
+
M(t), E(e), P(r), document.addEventListener("contextmenu", function(e) {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
});
|
|
68
|
+
let s = _({
|
|
69
|
+
container: C.current,
|
|
70
|
+
elements: e,
|
|
71
|
+
style: l({ elements: e }),
|
|
72
|
+
autounselectify: !1,
|
|
73
|
+
autolock: !1,
|
|
74
|
+
layout: { name: "preset" }
|
|
75
|
+
});
|
|
76
|
+
if (D.current = s, x?.searchNodes?.length === 2) a(s, x.searchNodes[0], x.searchNodes[1]);
|
|
77
|
+
else {
|
|
78
|
+
let e = s.layout(i());
|
|
79
|
+
e.run(), e.on("layoutstop", () => {
|
|
80
|
+
s.fit(void 0, 50), s.center();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return s.on("mouseover", "edge", (e) => {
|
|
84
|
+
e.target.hasClass("path-edge") || e.target.style({
|
|
85
|
+
"line-color": "#1890ff",
|
|
86
|
+
"target-arrow-color": "#1890ff",
|
|
87
|
+
opacity: .8
|
|
88
|
+
});
|
|
89
|
+
}), s.on("mouseout", "edge", (e) => {
|
|
90
|
+
e.target.hasClass("path-edge") || e.target.style({
|
|
91
|
+
"line-color": "#ccc",
|
|
92
|
+
"target-arrow-color": "#ccc",
|
|
93
|
+
opacity: 1
|
|
94
|
+
});
|
|
95
|
+
}), s.on("mouseover", "node", (e) => {
|
|
96
|
+
let t = e.target;
|
|
97
|
+
t.hasClass("selected") || t.addClass("hover");
|
|
98
|
+
}), s.on("mouseover", "node", (e) => {
|
|
99
|
+
let t = e.target, n = t.renderedPosition(), r = t.data("name") || "";
|
|
100
|
+
t.addClass("hover"), W({
|
|
101
|
+
visible: !0,
|
|
102
|
+
x: n.x,
|
|
103
|
+
y: n.y - 60,
|
|
104
|
+
content: r
|
|
105
|
+
});
|
|
106
|
+
}), s.on("mouseout", "node", (e) => {
|
|
107
|
+
e.target.removeClass("hover"), W((e) => ({
|
|
108
|
+
...e,
|
|
109
|
+
visible: !1
|
|
110
|
+
}));
|
|
111
|
+
}), s.on("cxttap", "node", (e) => {
|
|
112
|
+
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), e.originalEvent && (e.originalEvent.preventDefault(), e.originalEvent.stopPropagation(), e.originalEvent.stopImmediatePropagation());
|
|
113
|
+
let t = e.target, n = t.renderedPosition();
|
|
114
|
+
console.log("renderedPos:::", t.data(), t.style("background-color")), H({
|
|
115
|
+
visible: !0,
|
|
116
|
+
x: n.x - 90,
|
|
117
|
+
y: n.y - 90,
|
|
118
|
+
targetNode: t,
|
|
119
|
+
bgColor: t.style("background-color")
|
|
120
|
+
});
|
|
121
|
+
}), D.current = s, s.on("click", "node", (e) => {
|
|
122
|
+
let t = e.target;
|
|
123
|
+
s.nodes().removeClass("selected grayed highlighted"), s.edges().removeClass("selected grayed highlighted"), t.addClass("selected");
|
|
124
|
+
let n = t.neighborhood().nodes().add(t), r = n.edgesWith(n);
|
|
125
|
+
console.log("cy.nodes().not(relatedNodes):::", n), s.nodes().not(n).addClass("grayed"), s.edges().not(r).addClass("grayed"), n.addClass("highlighted"), r.addClass("highlighted");
|
|
126
|
+
}), s.on("tap", (e) => {
|
|
127
|
+
e.target === s && (H((e) => ({
|
|
128
|
+
...e,
|
|
129
|
+
visible: !1
|
|
130
|
+
})), s.nodes().removeClass("grayed highlighted highlight selected correlationStyle path-node level-highlight level-selected level-grayed"), s.edges().removeClass("grayed highlighted highlight selected correlationStyle path-edge level-highlightedge level-grayed"));
|
|
131
|
+
}), () => {
|
|
132
|
+
D.current &&= (D.current.destroy(), null);
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
let K = async (e) => {
|
|
136
|
+
let { id: t, kgId: r } = e, a = D.current;
|
|
137
|
+
if (!a) return;
|
|
138
|
+
let o = a.$(`#${t}`);
|
|
139
|
+
if (!o || o.length === 0) {
|
|
140
|
+
console.error("当前节点不存在");
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
let s = a.nodes().filter((n) => n.data("parentId") ? (n.data("parentId") === t || n.data("idLabel") === `${t}-${n.data("name")}`) && n.data("zktype") === e.zktype : !1);
|
|
144
|
+
if (s.length > 0) {
|
|
145
|
+
let r = s.map((e) => e.id()), i = s.connectedEdges(), c = a.edges().filter((e) => e.data("source") === t && r.includes(e.data("target"))), l = a.edges().filter((e) => e.data("appendedBy") === t), u = i.merge(c).merge(l).filter((t) => t.data().zktype === e.zktype);
|
|
146
|
+
s.animate({ style: { opacity: 0 } }, {
|
|
147
|
+
duration: 200,
|
|
148
|
+
complete: () => {
|
|
149
|
+
a.remove(s), a.remove(u), E((i) => {
|
|
150
|
+
let a = i.filter((n) => {
|
|
151
|
+
let i = n.data.zktype;
|
|
152
|
+
if (n.group === "nodes" && r.includes(n.data?.id) && i && i === e.zktype) return !1;
|
|
153
|
+
if (n.group === "edges" && i && i === e.zktype) {
|
|
154
|
+
let e = Array.from(l).map((e) => {
|
|
155
|
+
let t = e.data();
|
|
156
|
+
return `${t.source}-${t.target}-${t.label}`;
|
|
157
|
+
}), r = n.data, i = e.includes(`${r.source}-${r.target}-${r.label}`), a = n.data?.appendedBy === t;
|
|
158
|
+
return !i && !a;
|
|
159
|
+
}
|
|
160
|
+
return !0;
|
|
161
|
+
}), { typeListObj: o, relationListObj: s } = n({}, {
|
|
162
|
+
graphData: a,
|
|
163
|
+
typeObj: {},
|
|
164
|
+
relationObj: {},
|
|
165
|
+
isOnlyStatic: !0
|
|
166
|
+
});
|
|
167
|
+
return M(o), P(s), a;
|
|
168
|
+
}), o.data("appendedNodes", []), o.data("isExpanded", !1);
|
|
169
|
+
}
|
|
170
|
+
}), setTimeout(() => {
|
|
171
|
+
o.removed() || (o.style("border-width", ""), o.style("border-color", ""));
|
|
172
|
+
}, 300);
|
|
173
|
+
} else {
|
|
174
|
+
try {
|
|
175
|
+
A(!0), S.open({
|
|
176
|
+
type: "loading",
|
|
177
|
+
content: "正在展开...",
|
|
178
|
+
duration: 0
|
|
179
|
+
});
|
|
180
|
+
let { elements: s, typeListObj: l, relationListObj: u } = n((await c({
|
|
181
|
+
uri: t,
|
|
182
|
+
queryType: 1,
|
|
183
|
+
kgId: r,
|
|
184
|
+
zktype: e.zktype
|
|
185
|
+
})).data, {
|
|
186
|
+
graphData: T,
|
|
187
|
+
typeObj: j,
|
|
188
|
+
relationObj: N,
|
|
189
|
+
zktype: e.zktype
|
|
190
|
+
});
|
|
191
|
+
if (M(l), P(u), console.log(555e3, s), !(s?.length > 0)) {
|
|
192
|
+
S.warning("暂无数据"), setTimeout(() => {
|
|
193
|
+
S.destroy();
|
|
194
|
+
}, 2e3);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (s?.length > 0) {
|
|
198
|
+
let n = a.layoutUtilities({
|
|
199
|
+
...i(),
|
|
200
|
+
idealEdgeLength: 80,
|
|
201
|
+
offset: 30
|
|
202
|
+
}), r = s.map((n) => n.group === "nodes" ? {
|
|
203
|
+
...n,
|
|
204
|
+
style: {
|
|
205
|
+
opacity: 0,
|
|
206
|
+
width: 80,
|
|
207
|
+
height: 80
|
|
208
|
+
},
|
|
209
|
+
data: {
|
|
210
|
+
...n.data,
|
|
211
|
+
parentId: t,
|
|
212
|
+
appendedBy: t,
|
|
213
|
+
idLabel: t + "-" + n.data.label,
|
|
214
|
+
zktype: e.zktype,
|
|
215
|
+
isAppended: !0,
|
|
216
|
+
baseWidth: 80,
|
|
217
|
+
baseHeight: 80
|
|
218
|
+
}
|
|
219
|
+
} : {
|
|
220
|
+
...n,
|
|
221
|
+
data: {
|
|
222
|
+
...n.data,
|
|
223
|
+
appendedBy: t,
|
|
224
|
+
zktype: e.zktype
|
|
225
|
+
}
|
|
226
|
+
}), c = a.add(r);
|
|
227
|
+
E([...T, ...r]);
|
|
228
|
+
let l = c.filter(":node"), u = l.map((e) => e.id());
|
|
229
|
+
o.data("appendedNodes", u), o.data("isExpanded", !0);
|
|
230
|
+
let d = a.nodes().difference(l);
|
|
231
|
+
d.forEach((e) => e.lock()), n.placeNewNodes(l), a.layout({
|
|
232
|
+
name: "cose-bilkent",
|
|
233
|
+
randomize: !1,
|
|
234
|
+
animate: !0,
|
|
235
|
+
animationDuration: 500,
|
|
236
|
+
fit: !1,
|
|
237
|
+
nodeRepulsion: 1005e3,
|
|
238
|
+
idealEdgeLength: 100,
|
|
239
|
+
edgeElasticity: .3,
|
|
240
|
+
numIter: 800,
|
|
241
|
+
gravity: .6
|
|
242
|
+
}).run(), setTimeout(() => {
|
|
243
|
+
d.forEach((e) => e.unlock());
|
|
244
|
+
}, 2e3), l.animate({ style: {
|
|
245
|
+
opacity: 1,
|
|
246
|
+
width: 20,
|
|
247
|
+
height: 30
|
|
248
|
+
} }, {
|
|
249
|
+
duration: 400,
|
|
250
|
+
easing: "ease-out",
|
|
251
|
+
complete: () => {
|
|
252
|
+
l.style("opacity", ""), l.style("width", ""), l.style("height", "");
|
|
253
|
+
}
|
|
254
|
+
}), setTimeout(() => {
|
|
255
|
+
o.removed() || (o.style("border-width", ""), o.style("border-color", ""), a.center(o), a.zoom(a.zoom()));
|
|
256
|
+
}, 600);
|
|
257
|
+
} else console.log("没有找到相关节点数据");
|
|
258
|
+
} catch (e) {
|
|
259
|
+
console.error("请求接口失败:", e);
|
|
260
|
+
}
|
|
261
|
+
A(!1), S.destroy();
|
|
262
|
+
}
|
|
263
|
+
H({ visible: !1 });
|
|
264
|
+
}, q = {
|
|
265
|
+
expanded: "typed-literal",
|
|
266
|
+
contract: "uri"
|
|
267
|
+
}, J = (e) => {
|
|
268
|
+
if (console.log("handleMenuAction:::", e), V.targetNode) {
|
|
269
|
+
let t = e.ids, n = V.targetNode.data();
|
|
270
|
+
if (["expanded", "contract"].includes(t)) K({
|
|
271
|
+
kgId: 3,
|
|
272
|
+
...n,
|
|
273
|
+
zktype: q[t]
|
|
274
|
+
});
|
|
275
|
+
else if (t === "nodeInfo") {
|
|
276
|
+
let e = V.targetNode, t = {
|
|
277
|
+
id: e.id(),
|
|
278
|
+
data: e.data(),
|
|
279
|
+
position: e.position(),
|
|
280
|
+
degree: e.degree(),
|
|
281
|
+
inDegree: e.degree(!0),
|
|
282
|
+
outDegree: e.degree(!1),
|
|
283
|
+
classes: e.classes(),
|
|
284
|
+
style: e.style()
|
|
285
|
+
};
|
|
286
|
+
L.current.open(t);
|
|
287
|
+
} else if (t === "knowledgeCard") {
|
|
288
|
+
let e = V.targetNode;
|
|
289
|
+
R.current.open(e.data());
|
|
290
|
+
}
|
|
291
|
+
e.action(V.targetNode), H({
|
|
292
|
+
visible: !1,
|
|
293
|
+
x: 0,
|
|
294
|
+
y: 0,
|
|
295
|
+
targetNode: null
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
return /* @__PURE__ */ (0, w.jsx)(r, {
|
|
300
|
+
value: {
|
|
301
|
+
pathNodes: z,
|
|
302
|
+
setPathNodes: B,
|
|
303
|
+
graphInfo: x,
|
|
304
|
+
graphData: T,
|
|
305
|
+
layoutType: F,
|
|
306
|
+
setLayoutType: I
|
|
307
|
+
},
|
|
308
|
+
children: /* @__PURE__ */ (0, w.jsxs)("div", {
|
|
309
|
+
className: "cytoscape-container",
|
|
310
|
+
style: { position: "relative" },
|
|
311
|
+
children: [
|
|
312
|
+
/* @__PURE__ */ (0, w.jsx)("div", { className: "btn-group" }),
|
|
313
|
+
/* @__PURE__ */ (0, w.jsx)(s, {
|
|
314
|
+
ref: O,
|
|
315
|
+
cyRef: D,
|
|
316
|
+
graphInfo: x,
|
|
317
|
+
initNodeScale: 1,
|
|
318
|
+
cyContainerRef: C,
|
|
319
|
+
typeObj: j,
|
|
320
|
+
relationObj: N
|
|
321
|
+
}),
|
|
322
|
+
/* @__PURE__ */ (0, w.jsxs)("div", {
|
|
323
|
+
style: { position: "relative" },
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ (0, w.jsx)("div", {
|
|
326
|
+
ref: C,
|
|
327
|
+
className: "cy-container"
|
|
328
|
+
}),
|
|
329
|
+
V.visible && V.targetNode && /* @__PURE__ */ (0, w.jsx)("div", {
|
|
330
|
+
style: {
|
|
331
|
+
position: "absolute",
|
|
332
|
+
left: `${V.x}px`,
|
|
333
|
+
top: `${V.y}px`,
|
|
334
|
+
zIndex: 1e4,
|
|
335
|
+
minWidth: "120px",
|
|
336
|
+
padding: "4px 0",
|
|
337
|
+
pointerEvents: "auto",
|
|
338
|
+
width: "200px",
|
|
339
|
+
height: "200px",
|
|
340
|
+
overflow: "hidden"
|
|
341
|
+
},
|
|
342
|
+
onClick: (e) => e.stopPropagation(),
|
|
343
|
+
children: /* @__PURE__ */ (0, w.jsx)(d, {
|
|
344
|
+
items: G,
|
|
345
|
+
centerImage: V?.targetNode?.data().image,
|
|
346
|
+
onClick: (e) => J(e)
|
|
347
|
+
})
|
|
348
|
+
}),
|
|
349
|
+
U.visible && /* @__PURE__ */ (0, w.jsx)("div", {
|
|
350
|
+
style: {
|
|
351
|
+
position: "absolute",
|
|
352
|
+
left: `${U.x}px`,
|
|
353
|
+
top: `${U.y}px`,
|
|
354
|
+
transform: "translateX(-50%)",
|
|
355
|
+
backgroundColor: "rgba(0, 0, 0, 0.85)",
|
|
356
|
+
color: "#fff",
|
|
357
|
+
padding: "6px 12px",
|
|
358
|
+
borderRadius: "4px",
|
|
359
|
+
fontSize: "14px",
|
|
360
|
+
whiteSpace: "nowrap",
|
|
361
|
+
zIndex: 9999,
|
|
362
|
+
pointerEvents: "none",
|
|
363
|
+
maxWidth: "1000px",
|
|
364
|
+
overflow: "hidden",
|
|
365
|
+
textOverflow: "ellipsis"
|
|
366
|
+
},
|
|
367
|
+
children: U.content
|
|
368
|
+
})
|
|
369
|
+
]
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ (0, w.jsx)(f, { ref: L }),
|
|
372
|
+
/* @__PURE__ */ (0, w.jsx)(p, { ref: R })
|
|
373
|
+
]
|
|
374
|
+
})
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
//#endregion
|
|
378
|
+
export { T as default };
|