react-kggraph 0.0.11 → 0.0.12

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.es13.js CHANGED
@@ -1,72 +1,226 @@
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
- ] });
69
- };
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
+ import { forwardRef as h, useState as s, useImperativeHandle as b } from "react";
3
+ import { Drawer as x } from "antd";
4
+ const N = h((y, d) => {
5
+ const [c, t] = s(!1), [a, o] = s({ style: {}, data: {} });
6
+ b(d, () => ({
7
+ open: (n) => {
8
+ t(!0), o(n);
9
+ },
10
+ close: () => t(!1)
11
+ }));
12
+ const i = () => {
13
+ t(!1);
14
+ }, l = (n) => {
15
+ const { name: p, value: m } = n.target;
16
+ o((u) => ({ ...u, [p]: m }));
17
+ };
18
+ return /* @__PURE__ */ e(
19
+ x,
20
+ {
21
+ title: "节点配置",
22
+ closable: { "aria-label": "Close Button" },
23
+ onClose: i,
24
+ open: c,
25
+ getContainer: !1,
26
+ children: /* @__PURE__ */ e("div", { className: "h-full overflow-y-auto z-50", children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
27
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
28
+ /* @__PURE__ */ e("label", { className: "w-40", children: "名称" }),
29
+ /* @__PURE__ */ e(
30
+ "input",
31
+ {
32
+ name: "name",
33
+ value: a.data.name,
34
+ onChange: l,
35
+ readOnly: !0,
36
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"
37
+ }
38
+ )
39
+ ] }),
40
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
41
+ /* @__PURE__ */ e("label", { className: "w-40", children: "类型" }),
42
+ /* @__PURE__ */ r(
43
+ "select",
44
+ {
45
+ name: "type",
46
+ value: a.type,
47
+ disabled: !0,
48
+ onChange: l,
49
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-white",
50
+ children: [
51
+ /* @__PURE__ */ e("option", { value: "圆形", children: "圆形" }),
52
+ /* @__PURE__ */ e("option", { value: "矩形", children: "矩形" })
53
+ ]
54
+ }
55
+ )
56
+ ] }),
57
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
58
+ /* @__PURE__ */ e("label", { className: "w-40", children: "颜色" }),
59
+ /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 items-center", children: [
60
+ /* @__PURE__ */ e(
61
+ "input",
62
+ {
63
+ name: "color",
64
+ readOnly: !0,
65
+ value: a.style.color,
66
+ onChange: l,
67
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded h-30px"
68
+ }
69
+ ),
70
+ /* @__PURE__ */ e(
71
+ "input",
72
+ {
73
+ type: "color",
74
+ readOnly: !0,
75
+ value: a.style.color,
76
+ onChange: (n) => o({ ...a, color: n.target.value }),
77
+ className: "h-20px w-20px rounded cursor-pointer border"
78
+ }
79
+ )
80
+ ] })
81
+ ] }),
82
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
83
+ /* @__PURE__ */ e("label", { className: "w-40", children: "大小" }),
84
+ /* @__PURE__ */ e(
85
+ "input",
86
+ {
87
+ type: "number",
88
+ name: "size",
89
+ readOnly: !0,
90
+ value: parseInt(a.style.height),
91
+ onChange: l,
92
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded "
93
+ }
94
+ )
95
+ ] }),
96
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
97
+ /* @__PURE__ */ e("label", { className: "w-40", children: "边框宽度" }),
98
+ /* @__PURE__ */ e(
99
+ "input",
100
+ {
101
+ type: "number",
102
+ name: "borderWidth",
103
+ readOnly: !0,
104
+ value: parseInt(a.style.borderWidth),
105
+ onChange: l,
106
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded "
107
+ }
108
+ )
109
+ ] }),
110
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
111
+ /* @__PURE__ */ e("label", { className: "w-40", children: "边框虚线" }),
112
+ /* @__PURE__ */ r(
113
+ "select",
114
+ {
115
+ name: "borderDash",
116
+ value: a.style.borderDash,
117
+ disabled: !0,
118
+ onChange: l,
119
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-white",
120
+ children: [
121
+ /* @__PURE__ */ e("option", { value: "否", children: "否" }),
122
+ /* @__PURE__ */ e("option", { value: "是", children: "是" })
123
+ ]
124
+ }
125
+ )
126
+ ] }),
127
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
128
+ /* @__PURE__ */ e("label", { className: "w-40", children: "边框颜色" }),
129
+ /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 items-center", children: [
130
+ /* @__PURE__ */ e(
131
+ "input",
132
+ {
133
+ name: "borderColor",
134
+ value: a.style.borderColor,
135
+ readOnly: !0,
136
+ onChange: l,
137
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded h-30px"
138
+ }
139
+ ),
140
+ /* @__PURE__ */ e(
141
+ "input",
142
+ {
143
+ type: "color",
144
+ value: a.borderColor,
145
+ readOnly: !0,
146
+ onChange: (n) => o({ ...a, borderColor: n.target.value }),
147
+ className: "h-20px w-20px rounded cursor-pointer border"
148
+ }
149
+ )
150
+ ] })
151
+ ] }),
152
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
153
+ /* @__PURE__ */ e("label", { className: "w-40", children: "字体位置" }),
154
+ /* @__PURE__ */ r(
155
+ "select",
156
+ {
157
+ name: "fontPosition",
158
+ value: a.style.textValign,
159
+ disabled: !0,
160
+ onChange: l,
161
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-white",
162
+ children: [
163
+ /* @__PURE__ */ e("option", { value: "center", children: "居中" }),
164
+ /* @__PURE__ */ e("option", { value: "bottom", children: "底部" }),
165
+ /* @__PURE__ */ e("option", { value: "top", children: "顶部" })
166
+ ]
167
+ }
168
+ )
169
+ ] }),
170
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
171
+ /* @__PURE__ */ e("label", { className: "w-40", children: "字体样式" }),
172
+ /* @__PURE__ */ e(
173
+ "input",
174
+ {
175
+ name: "fontStyle",
176
+ value: a.style.fontStyle,
177
+ readOnly: !0,
178
+ onChange: l,
179
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded "
180
+ }
181
+ )
182
+ ] }),
183
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
184
+ /* @__PURE__ */ e("label", { className: "w-40", children: "字体颜色" }),
185
+ /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 items-center", children: [
186
+ /* @__PURE__ */ e(
187
+ "input",
188
+ {
189
+ name: "fontColor",
190
+ readOnly: !0,
191
+ value: a.style.textBorderColor,
192
+ onChange: l,
193
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded h-30px"
194
+ }
195
+ ),
196
+ /* @__PURE__ */ e(
197
+ "input",
198
+ {
199
+ type: "color",
200
+ readOnly: !0,
201
+ value: a.style["font-color"],
202
+ onChange: (n) => o({ ...a, fontColor: n.target.value }),
203
+ className: "h-20px w-20px rounded cursor-pointer border"
204
+ }
205
+ )
206
+ ] })
207
+ ] }),
208
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
209
+ /* @__PURE__ */ e("label", { className: "w-40", children: "字体背色" }),
210
+ /* @__PURE__ */ e(
211
+ "input",
212
+ {
213
+ type: "text",
214
+ readOnly: !0,
215
+ value: a.style.textBackgroundColor,
216
+ className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-gray-50 text-gray-400 cursor-not-allowed"
217
+ }
218
+ )
219
+ ] })
220
+ ] }) })
221
+ }
222
+ );
223
+ });
70
224
  export {
71
- L as default
225
+ N as default
72
226
  };
package/lib/index.es14.js CHANGED
@@ -1,226 +1,6 @@
1
- import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
- import { forwardRef as h, useState as s, useImperativeHandle as b } from "react";
3
- import { Drawer as x } from "antd";
4
- const N = h((y, d) => {
5
- const [c, t] = s(!1), [a, o] = s({ style: {}, data: {} });
6
- b(d, () => ({
7
- open: (n) => {
8
- t(!0), o(n);
9
- },
10
- close: () => t(!1)
11
- }));
12
- const i = () => {
13
- t(!1);
14
- }, l = (n) => {
15
- const { name: p, value: m } = n.target;
16
- o((u) => ({ ...u, [p]: m }));
17
- };
18
- return /* @__PURE__ */ e(
19
- x,
20
- {
21
- title: "节点配置",
22
- closable: { "aria-label": "Close Button" },
23
- onClose: i,
24
- open: c,
25
- getContainer: !1,
26
- children: /* @__PURE__ */ e("div", { className: "h-full overflow-y-auto z-50", children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
27
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
28
- /* @__PURE__ */ e("label", { className: "w-40", children: "名称" }),
29
- /* @__PURE__ */ e(
30
- "input",
31
- {
32
- name: "name",
33
- value: a.data.name,
34
- onChange: l,
35
- readOnly: !0,
36
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"
37
- }
38
- )
39
- ] }),
40
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
41
- /* @__PURE__ */ e("label", { className: "w-40", children: "类型" }),
42
- /* @__PURE__ */ r(
43
- "select",
44
- {
45
- name: "type",
46
- value: a.type,
47
- disabled: !0,
48
- onChange: l,
49
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-white",
50
- children: [
51
- /* @__PURE__ */ e("option", { value: "圆形", children: "圆形" }),
52
- /* @__PURE__ */ e("option", { value: "矩形", children: "矩形" })
53
- ]
54
- }
55
- )
56
- ] }),
57
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
58
- /* @__PURE__ */ e("label", { className: "w-40", children: "颜色" }),
59
- /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 items-center", children: [
60
- /* @__PURE__ */ e(
61
- "input",
62
- {
63
- name: "color",
64
- readOnly: !0,
65
- value: a.style.color,
66
- onChange: l,
67
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded h-30px"
68
- }
69
- ),
70
- /* @__PURE__ */ e(
71
- "input",
72
- {
73
- type: "color",
74
- readOnly: !0,
75
- value: a.style.color,
76
- onChange: (n) => o({ ...a, color: n.target.value }),
77
- className: "h-20px w-20px rounded cursor-pointer border"
78
- }
79
- )
80
- ] })
81
- ] }),
82
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
83
- /* @__PURE__ */ e("label", { className: "w-40", children: "大小" }),
84
- /* @__PURE__ */ e(
85
- "input",
86
- {
87
- type: "number",
88
- name: "size",
89
- readOnly: !0,
90
- value: parseInt(a.style.height),
91
- onChange: l,
92
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded "
93
- }
94
- )
95
- ] }),
96
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
97
- /* @__PURE__ */ e("label", { className: "w-40", children: "边框宽度" }),
98
- /* @__PURE__ */ e(
99
- "input",
100
- {
101
- type: "number",
102
- name: "borderWidth",
103
- readOnly: !0,
104
- value: parseInt(a.style.borderWidth),
105
- onChange: l,
106
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded "
107
- }
108
- )
109
- ] }),
110
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
111
- /* @__PURE__ */ e("label", { className: "w-40", children: "边框虚线" }),
112
- /* @__PURE__ */ r(
113
- "select",
114
- {
115
- name: "borderDash",
116
- value: a.style.borderDash,
117
- disabled: !0,
118
- onChange: l,
119
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-white",
120
- children: [
121
- /* @__PURE__ */ e("option", { value: "否", children: "否" }),
122
- /* @__PURE__ */ e("option", { value: "是", children: "是" })
123
- ]
124
- }
125
- )
126
- ] }),
127
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
128
- /* @__PURE__ */ e("label", { className: "w-40", children: "边框颜色" }),
129
- /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 items-center", children: [
130
- /* @__PURE__ */ e(
131
- "input",
132
- {
133
- name: "borderColor",
134
- value: a.style.borderColor,
135
- readOnly: !0,
136
- onChange: l,
137
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded h-30px"
138
- }
139
- ),
140
- /* @__PURE__ */ e(
141
- "input",
142
- {
143
- type: "color",
144
- value: a.borderColor,
145
- readOnly: !0,
146
- onChange: (n) => o({ ...a, borderColor: n.target.value }),
147
- className: "h-20px w-20px rounded cursor-pointer border"
148
- }
149
- )
150
- ] })
151
- ] }),
152
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
153
- /* @__PURE__ */ e("label", { className: "w-40", children: "字体位置" }),
154
- /* @__PURE__ */ r(
155
- "select",
156
- {
157
- name: "fontPosition",
158
- value: a.style.textValign,
159
- disabled: !0,
160
- onChange: l,
161
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-white",
162
- children: [
163
- /* @__PURE__ */ e("option", { value: "center", children: "居中" }),
164
- /* @__PURE__ */ e("option", { value: "bottom", children: "底部" }),
165
- /* @__PURE__ */ e("option", { value: "top", children: "顶部" })
166
- ]
167
- }
168
- )
169
- ] }),
170
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
171
- /* @__PURE__ */ e("label", { className: "w-40", children: "字体样式" }),
172
- /* @__PURE__ */ e(
173
- "input",
174
- {
175
- name: "fontStyle",
176
- value: a.style.fontStyle,
177
- readOnly: !0,
178
- onChange: l,
179
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded "
180
- }
181
- )
182
- ] }),
183
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
184
- /* @__PURE__ */ e("label", { className: "w-40", children: "字体颜色" }),
185
- /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 items-center", children: [
186
- /* @__PURE__ */ e(
187
- "input",
188
- {
189
- name: "fontColor",
190
- readOnly: !0,
191
- value: a.style.textBorderColor,
192
- onChange: l,
193
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded h-30px"
194
- }
195
- ),
196
- /* @__PURE__ */ e(
197
- "input",
198
- {
199
- type: "color",
200
- readOnly: !0,
201
- value: a.style["font-color"],
202
- onChange: (n) => o({ ...a, fontColor: n.target.value }),
203
- className: "h-20px w-20px rounded cursor-pointer border"
204
- }
205
- )
206
- ] })
207
- ] }),
208
- /* @__PURE__ */ r("div", { className: "flex items-center gap-4 !mb-20px", children: [
209
- /* @__PURE__ */ e("label", { className: "w-40", children: "字体背色" }),
210
- /* @__PURE__ */ e(
211
- "input",
212
- {
213
- type: "text",
214
- readOnly: !0,
215
- value: a.style.textBackgroundColor,
216
- className: "flex-1 px-3 py-1.5 border border-gray-300 rounded bg-gray-50 text-gray-400 cursor-not-allowed"
217
- }
218
- )
219
- ] })
220
- ] }) })
221
- }
222
- );
223
- });
1
+ import { createContext as r } from "react";
2
+ const o = r({}), e = o.Provider;
224
3
  export {
225
- N as default
4
+ o as GraphContext,
5
+ e as GraphProvider
226
6
  };
package/lib/index.es15.js CHANGED
@@ -1,6 +1,37 @@
1
- import { createContext as r } from "react";
2
- const o = r({}), e = o.Provider;
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as g, useContext as m, useState as o, useRef as w, useEffect as C, useImperativeHandle as h } from "react";
3
+ import { Drawer as x } from "antd";
4
+ import { GraphContext as y } from "./index.es14.js";
5
+ const E = g((I, l) => {
6
+ const { graphInfo: d, knowledgeCardApi: f } = m(y), [t, a] = o(!1), [k, s] = o(!1), [D, c] = o(!1), [v, p] = o({ style: {}, data: {} }), r = w(null);
7
+ C(() => {
8
+ t && r.current && (r.current.scrollTop = 0);
9
+ }, [t]), h(l, () => ({
10
+ open: (e) => {
11
+ a(!0), p(e), i(e);
12
+ },
13
+ close: () => a(!1)
14
+ }));
15
+ const i = async (e) => {
16
+ s(!0);
17
+ const u = await f({ kgId: d.kgId, uri: e.id });
18
+ console.log(44, e), c(u.data), s(!1);
19
+ };
20
+ return /* @__PURE__ */ n(
21
+ x,
22
+ {
23
+ title: "知识卡片",
24
+ onClose: () => {
25
+ a(!1);
26
+ },
27
+ open: t,
28
+ getContainer: !1,
29
+ className: "knowledge-card-drawer",
30
+ bodyStyle: { padding: "0 20px", overflow: "auto" },
31
+ children: /* @__PURE__ */ n("div", { ref: r, style: { height: "100%" } })
32
+ }
33
+ );
34
+ });
3
35
  export {
4
- o as GraphContext,
5
- e as GraphProvider
36
+ E as default
6
37
  };