react-kggraph 0.0.11 → 0.0.13

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.es10.js CHANGED
@@ -1,188 +1,72 @@
1
- const i = [
1
+ const i = ({ cyRef: n, setContextMenu: t, onPathAnalysis: l, setPathNodes: a }) => [
2
2
  {
3
- selector: "node",
4
- style: {
5
- "text-margin-y": "5px"
3
+ label: "展收实体",
4
+ ids: "contract",
5
+ action: (e) => {
6
+ const o = n.current;
7
+ console.log("新增属性", o);
6
8
  }
7
9
  },
8
10
  {
9
- selector: "edge",
10
- style: {
11
- // 核心:默认链接线颜色(和 hover 区分开)
12
- "line-color": "#a29e9e",
13
- // 核心:默认箭头颜色(和 hover 区分开)
14
- "target-arrow-color": "#a29e9e",
15
- // 核心:默认透明度(和 hover 区分开)
16
- opacity: 1,
17
- // 箭头形状(必须配置才会显示箭头)
18
- "target-arrow-shape": "triangle",
19
- // 链接线宽度
20
- width: 2,
21
- // 曲线样式
22
- "curve-style": "bezier",
23
- // 可选:过渡动画(颜色变化更丝滑)
24
- "transition-property": "line-color, target-arrow-color, opacity",
25
- "transition-duration": "0.2s",
26
- label: "data(name)",
27
- "z-index": 9999,
28
- // 连线文字设置
29
- "text-opacity": 1,
30
- "font-size": 18,
31
- color: "#666",
32
- "text-background-color": "#fff",
33
- "text-background-opacity": 1,
34
- "text-background-shape": "roundrectangle",
35
- // 'text-border-width': 2,
36
- // 'text-border-opacity':1,
37
- // 'text-border-color': '#e9e7e7',
38
- "text-background-padding": "3px"
11
+ label: "展收属性",
12
+ ids: "expanded",
13
+ action: (e) => {
14
+ if (console.log("展开", e), !n.current) {
15
+ console.error("Cytoscape instance is not available");
16
+ return;
17
+ }
18
+ console.log("New node and edge added");
39
19
  }
40
20
  },
41
21
  {
42
- selector: ".highlight",
43
- style: {
44
- "border-color": "rgba(174, 255, 45, 0.2)",
45
- "border-width": 4
22
+ label: "节点信息",
23
+ ids: "nodeInfo",
24
+ action: (e) => {
25
+ console.log("节点信息:", e);
46
26
  }
47
27
  },
48
28
  {
49
- selector: ".path-node",
50
- style: {
51
- "background-color": "#145AFD",
52
- "border-color": "#FFEB3B"
29
+ label: "知识卡片",
30
+ ids: "knowledgeCard",
31
+ action: (e) => {
32
+ const o = n.current;
33
+ console.log("知识卡片", o);
53
34
  }
54
35
  },
36
+ // {
37
+ // label: '新增关系',
38
+ // action: (node) => {
39
+ // const cy = cyRef.current;
40
+ // console.log('新增关系', cy)
41
+ // },
42
+ // },
55
43
  {
56
- selector: ".path-edge",
57
- style: {
58
- "line-color": "#145AFD",
59
- "target-arrow-color": "#145AFD",
60
- width: 4
44
+ label: "选中关联",
45
+ ids: "selRelate",
46
+ action: (e) => {
47
+ const o = n.current;
48
+ if (!o || !e || e.removed()) {
49
+ console.error("节点或Cytoscape实例无效"), t((r) => ({ ...r, visible: !1 }));
50
+ return;
51
+ }
52
+ const s = e, c = s.neighborhood().nodes().add(s);
53
+ c.edgesWith(c), o.nodes().not(c).removeClass("correlationStyle"), c.addClass("correlationStyle"), t((r) => ({ ...r, visible: !1 }));
61
54
  }
62
55
  },
63
56
  {
64
- selector: ".grayed",
65
- style: {
66
- opacity: 0.15,
67
- "text-opacity": 0.15
57
+ label: "路径分析",
58
+ action: (e) => {
59
+ n.current, console.log(11, e.data("name")), l == null || l(), a([e.data("name"), ""]);
68
60
  }
69
61
  },
70
62
  {
71
- selector: "node.selected, edge.selected",
72
- // 选中状态的样式
73
- style: {
74
- // 'line-color': 'rgba(66, 133, 244, 0.5)', // 选中边的颜色
75
- "border-color": "rgba(174, 255, 45, 0.2)",
76
- "border-width": 4
77
- }
78
- },
79
- {
80
- selector: ".correlationStyle",
81
- style: {
82
- width: 60,
83
- height: 60,
84
- // 'background-color': '#fff',
85
- // 核心:outline(外边框)+ blur滤镜实现发光
86
- "outline-width": "10px",
87
- "outline-color": "rgba(188, 220, 255, 0.4)",
88
- "outline-style": "solid",
89
- "line-opacity": "0.2",
90
- "outline-offset": "2px",
91
- // 偏移避免遮挡节点
92
- filter: "blur(20px)",
93
- // 模糊outline,模拟发光
94
- "z-index": 9999
95
- }
96
- },
97
- {
98
- selector: ".hover",
99
- style: {
100
- "border-width": 3,
101
- "border-color": "#0d6ac2"
102
- }
103
- },
104
- // 层级分析样式 - 目标节点
105
- {
106
- selector: ".level-selected",
107
- style: {
108
- "background-color": "#f8bbd0",
109
- "border-color": "#e91e63",
110
- "border-width": 4,
111
- color: "#880e4f"
112
- }
113
- },
114
- // 层级分析样式 - 关联节点
115
- {
116
- selector: ".level-highlight",
117
- style: {
118
- "background-color": "#bbdefb",
119
- "border-color": "#2196f3",
120
- "border-width": 3,
121
- color: "#0d47a1"
122
- }
123
- },
124
- // 层级分析样式 - 边高亮
125
- {
126
- selector: ".level-highlightedge",
127
- style: {
128
- "line-color": "#1976d2",
129
- "target-arrow-color": "#1976d2",
130
- width: 3,
131
- opacity: 1
132
- }
133
- },
134
- // 层级分析样式 - 置灰
135
- {
136
- selector: ".level-grayed",
137
- style: {
138
- opacity: 0.15,
139
- "text-opacity": 0.15
63
+ label: "删除节点",
64
+ action: (e) => {
65
+ const o = n.current;
66
+ console.log("删除节点cy::::", o), e && !e.removed() && e.remove();
140
67
  }
141
68
  }
142
- ], n = ({ elements: c }) => {
143
- const o = [];
144
- c.map((e) => {
145
- var r, l, a;
146
- !o.includes((r = e == null ? void 0 : e.data) == null ? void 0 : r.type) && ((l = e == null ? void 0 : e.data) != null && l.type) && o.push((a = e.data) == null ? void 0 : a.type);
147
- });
148
- const t = [];
149
- return t.push({
150
- selector: '[properties-type="uri"]',
151
- style: {
152
- "background-color": "#f7de63",
153
- // 黄色
154
- "background-image": "data(image)",
155
- // 'background-image': sticon1,
156
- "background-fit": "cover",
157
- width: 80,
158
- height: 80,
159
- label: "data(name)",
160
- color: "black",
161
- "text-valign": "bottom",
162
- "font-size": 18,
163
- "text-max-width": "250px",
164
- "text-wrap": "ellipsis",
165
- "text-overflow-wrap": "anywhere"
166
- }
167
- }), t.push({
168
- selector: '[properties-type!="uri"]',
169
- style: {
170
- "background-color": "#1890FF",
171
- // 蓝色
172
- "background-image": "data(image)",
173
- "background-fit": "cover",
174
- width: 80,
175
- height: 80,
176
- label: "data(name)",
177
- color: "black",
178
- "text-valign": "bottom",
179
- "font-size": 18,
180
- "text-max-width": "250px",
181
- "text-wrap": "ellipsis",
182
- "text-overflow-wrap": "anywhere"
183
- }
184
- }), t.concat(i);
185
- };
69
+ ];
186
70
  export {
187
- n as edgeNodeStyles
71
+ i as menuItemsConfig
188
72
  };
package/lib/index.es11.js CHANGED
@@ -1,72 +1,32 @@
1
- const i = ({ cyRef: n, setContextMenu: t, onPathAnalysis: l, setPathNodes: a }) => [
2
- {
3
- label: "展收实体",
4
- ids: "contract",
5
- action: (e) => {
6
- const o = n.current;
7
- console.log("新增属性", o);
1
+ const t = (r) => {
2
+ if (n(r) || Array.isArray(r))
3
+ try {
4
+ return JSON.stringify(r);
5
+ } catch (e) {
6
+ console.log("JSON.stringify", e);
8
7
  }
9
- },
10
- {
11
- label: "展收属性",
12
- ids: "expanded",
13
- action: (e) => {
14
- if (console.log("展开", e), !n.current) {
15
- console.error("Cytoscape instance is not available");
16
- return;
17
- }
18
- console.log("New node and edge added");
8
+ else
9
+ return r;
10
+ }, c = (r) => {
11
+ if (n(r) || Array.isArray(r))
12
+ try {
13
+ return JSON.parse(JSON.stringify(r));
14
+ } catch (e) {
15
+ console.log("JSON.stringify-JSON.parse", e);
19
16
  }
20
- },
21
- {
22
- label: "节点信息",
23
- ids: "nodeInfo",
24
- action: (e) => {
25
- console.log("节点信息:", e);
26
- }
27
- },
28
- {
29
- label: "知识卡片",
30
- ids: "knowledgeCard",
31
- action: (e) => {
32
- const o = n.current;
33
- console.log("知识卡片", o);
34
- }
35
- },
36
- // {
37
- // label: '新增关系',
38
- // action: (node) => {
39
- // const cy = cyRef.current;
40
- // console.log('新增关系', cy)
41
- // },
42
- // },
43
- {
44
- label: "选中关联",
45
- ids: "selRelate",
46
- action: (e) => {
47
- const o = n.current;
48
- if (!o || !e || e.removed()) {
49
- console.error("节点或Cytoscape实例无效"), t((r) => ({ ...r, visible: !1 }));
50
- return;
51
- }
52
- const s = e, c = s.neighborhood().nodes().add(s);
53
- c.edgesWith(c), o.nodes().not(c).removeClass("correlationStyle"), c.addClass("correlationStyle"), t((r) => ({ ...r, visible: !1 }));
54
- }
55
- },
56
- {
57
- label: "路径分析",
58
- action: (e) => {
59
- n.current, console.log(11, e.data("name")), l == null || l(), a([e.data("name"), ""]);
60
- }
61
- },
62
- {
63
- label: "删除节点",
64
- action: (e) => {
65
- const o = n.current;
66
- console.log("删除节点cy::::", o), e && !e.removed() && e.remove();
67
- }
68
- }
69
- ];
17
+ else
18
+ return r;
19
+ };
20
+ function n(r) {
21
+ return r !== null && typeof r == "object" && !Array.isArray(r);
22
+ }
23
+ const i = (r, e) => {
24
+ const o = document.createElement("a");
25
+ o.href = r, o.download = e, document.body.appendChild(o), o.click(), document.body.removeChild(o);
26
+ };
70
27
  export {
71
- i as menuItemsConfig
28
+ i as downloadFile,
29
+ n as isObject,
30
+ t as jsonStringify,
31
+ c as jsonStringifyParse
72
32
  };
package/lib/index.es12.js CHANGED
@@ -1,32 +1,72 @@
1
- const t = (r) => {
2
- if (n(r) || Array.isArray(r))
3
- try {
4
- return JSON.stringify(r);
5
- } catch (e) {
6
- console.log("JSON.stringify", e);
7
- }
8
- else
9
- return r;
10
- }, c = (r) => {
11
- if (n(r) || Array.isArray(r))
12
- try {
13
- return JSON.parse(JSON.stringify(r));
14
- } catch (e) {
15
- console.log("JSON.stringify-JSON.parse", e);
16
- }
17
- else
18
- return r;
19
- };
20
- function n(r) {
21
- return r !== null && typeof r == "object" && !Array.isArray(r);
22
- }
23
- const i = (r, e) => {
24
- const o = document.createElement("a");
25
- o.href = r, o.download = e, document.body.appendChild(o), o.click(), document.body.removeChild(o);
1
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
+ import { useMemo as b } from "react";
3
+ /* empty css */
4
+ const L = ({
5
+ items: h = [
6
+ // { label: '知识卡片' },
7
+ // { label: '选中关联' },
8
+ // { label: '路径分析' },
9
+ // { label: '展收实体' },
10
+ // { label: '展收属性' },
11
+ // { label: '节点配置' },
12
+ ],
13
+ centerImage: f,
14
+ size: c = 200,
15
+ onClick: $
16
+ }) => {
17
+ const t = c / 2, a = c / 2 - 10, s = 30, o = 360 / h.length, p = b(() => h.map((n, r) => {
18
+ const l = (r * o - 90) * (Math.PI / 180), i = ((r + 1) * o - 90) * (Math.PI / 180), m = ((r + 0.5) * o - 90) * (Math.PI / 180), y = t + a * Math.cos(l), v = t + a * Math.sin(l), w = t + a * Math.cos(i), A = t + a * Math.sin(i), N = t + s * Math.cos(i), k = t + s * Math.sin(i), u = t + s * Math.cos(l), x = t + s * Math.sin(l), g = o > 180 ? 1 : 0, I = `M ${u} ${x} L ${y} ${v} A ${a} ${a} 0 ${g} 1 ${w} ${A} L ${N} ${k} A ${s} ${s} 0 ${g} 0 ${u} ${x}`, M = (a + s) / 2 + 5, P = t + M * Math.cos(m), R = t + M * Math.sin(m);
19
+ return {
20
+ ...n,
21
+ path: I,
22
+ textX: P,
23
+ textY: R,
24
+ rotation: (r + 0.5) * o - 90
25
+ };
26
+ }), [h, o, t, a, s]);
27
+ return /* @__PURE__ */ d("div", { className: "radial-menu", style: { width: c, height: c }, children: [
28
+ /* @__PURE__ */ d("svg", { width: c, height: c, className: "radial-svg", children: [
29
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ e("filter", { id: "shadow", x: "-20%", y: "-20%", width: "140%", height: "140%", children: /* @__PURE__ */ e("feDropShadow", { dx: "0", dy: "2", stdDeviation: "3", floodOpacity: "0.3" }) }) }),
30
+ /* @__PURE__ */ e("circle", { cx: t, cy: t, r: a, fill: "#f5f5f5", stroke: "#ddd", strokeWidth: "1" }),
31
+ p.map((n, r) => /* @__PURE__ */ d("g", { onClick: () => $(n), className: "sector-group", children: [
32
+ /* @__PURE__ */ e(
33
+ "path",
34
+ {
35
+ d: n.path,
36
+ fill: "#333",
37
+ stroke: "rgb(185, 185, 185)",
38
+ strokeWidth: "1",
39
+ filter: "url(#shadow)",
40
+ className: "sector-path"
41
+ }
42
+ ),
43
+ /* @__PURE__ */ e(
44
+ "text",
45
+ {
46
+ x: n.textX,
47
+ y: n.textY,
48
+ textAnchor: "middle",
49
+ dominantBaseline: "middle",
50
+ fill: "#fff",
51
+ fontSize: "12",
52
+ fontWeight: "500",
53
+ className: "sector-label",
54
+ children: n.label
55
+ }
56
+ )
57
+ ] }, r)),
58
+ /* @__PURE__ */ e("circle", { cx: t, cy: t, r: s + 2, fill: "#fff" })
59
+ ] }),
60
+ /* @__PURE__ */ e(
61
+ "div",
62
+ {
63
+ className: "center-avatar",
64
+ style: { width: s * 2, height: s * 2 },
65
+ children: f ? /* @__PURE__ */ e("img", { src: f, alt: "avatar" }) : /* @__PURE__ */ e("span", { className: "center-text", children: "菜单" })
66
+ }
67
+ )
68
+ ] });
26
69
  };
27
70
  export {
28
- i as downloadFile,
29
- n as isObject,
30
- t as jsonStringify,
31
- c as jsonStringifyParse
71
+ L as default
32
72
  };