@hsu-react/ui 0.0.1 → 0.0.3
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 +2 -0
- package/es/components/ChainGraph/_components/SearchSelect/index.js +13 -10
- package/es/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/es/components/ChainGraph/index.module.less +1 -1
- package/es/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
- package/es/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
- package/es/components/Chat/ChatInput/index.module.less +2 -2
- package/es/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
- package/es/components/Checkbox/CheckboxGroup/index.module.less +16 -16
- package/es/components/Checkbox/index.module.less +13 -13
- package/es/components/CodeMirror/index.module.less +4 -4
- package/es/components/DatePicker/RangePicker/index.module.less +1 -1
- package/es/components/DatePicker/StepPicker/index.module.less +1 -1
- package/es/components/DatePicker/index.module.less +2 -1
- package/es/components/Form/DrawerForm/index.module.less +2 -2
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -2
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/es/components/FormItem/FormRadio/index.module.less +9 -9
- package/es/components/FormItem/FormSegmented/index.module.less +2 -2
- package/es/components/FormItem/FormUpload/index.module.less +4 -4
- package/es/components/FormItem/ItemContainer/index.module.less +22 -22
- package/es/components/Icon/index.js +9 -24
- package/es/components/Input/Number/index.module.less +9 -9
- package/es/components/Input/Password/index.module.less +3 -3
- package/es/components/Input/Range/index.module.less +4 -4
- package/es/components/Input/Search/index.module.less +5 -5
- package/es/components/Input/TextArea/index.module.less +5 -5
- package/es/components/Input/index.module.less +7 -4
- package/es/components/Modal/index.module.less +2 -2
- package/es/components/Operate/index.module.less +2 -2
- package/es/components/Panel/IframePanel/index.module.less +1 -1
- package/es/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
- package/es/components/Search/index.module.less +2 -2
- package/es/components/Select/AutoCompleteSelect/index.module.less +35 -35
- package/es/components/Select/IconSelect/index.module.less +3 -3
- package/es/components/Select/TreeSelect/index.module.less +17 -17
- package/es/components/Select/_utils/getElementPosition.d.ts +6 -2
- package/es/components/Select/_utils/getElementPosition.js +8 -6
- package/es/components/Select/index.module.less +37 -34
- package/es/components/Slider/index.module.less +5 -4
- package/es/components/Spreadsheet/index.module.less +4 -4
- package/es/components/Switch/index.js +12 -8
- package/es/components/Switch/index.module.less +7 -0
- package/es/components/Table/_components/Pagination/index.module.less +23 -23
- package/es/components/Table/index.module.less +61 -61
- package/es/components/Tree/index.module.less +11 -11
- package/es/components/Upload/index.module.less +3 -3
- package/es/styles/antd-overload.less +1 -1
- package/lib/components/ChainGraph/_components/SearchSelect/index.js +10 -7
- package/lib/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/lib/components/ChainGraph/index.module.less +1 -1
- package/lib/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
- package/lib/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
- package/lib/components/Chat/ChatInput/index.module.less +2 -2
- package/lib/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
- package/lib/components/Checkbox/CheckboxGroup/index.module.less +16 -16
- package/lib/components/Checkbox/index.module.less +13 -13
- package/lib/components/CodeMirror/index.module.less +4 -4
- package/lib/components/DatePicker/RangePicker/index.module.less +1 -1
- package/lib/components/DatePicker/StepPicker/index.module.less +1 -1
- package/lib/components/DatePicker/index.module.less +2 -1
- package/lib/components/Form/DrawerForm/index.module.less +2 -2
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -1
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/lib/components/FormItem/FormRadio/index.module.less +9 -9
- package/lib/components/FormItem/FormSegmented/index.module.less +2 -2
- package/lib/components/FormItem/FormUpload/index.module.less +4 -4
- package/lib/components/FormItem/ItemContainer/index.module.less +22 -22
- package/lib/components/Icon/index.js +9 -27
- package/lib/components/Input/Number/index.module.less +9 -9
- package/lib/components/Input/Password/index.module.less +3 -3
- package/lib/components/Input/Range/index.module.less +4 -4
- package/lib/components/Input/Search/index.module.less +5 -5
- package/lib/components/Input/TextArea/index.module.less +5 -5
- package/lib/components/Input/index.module.less +7 -4
- package/lib/components/Modal/index.module.less +2 -2
- package/lib/components/Operate/index.module.less +2 -2
- package/lib/components/Panel/IframePanel/index.module.less +1 -1
- package/lib/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
- package/lib/components/Search/index.module.less +2 -2
- package/lib/components/Select/AutoCompleteSelect/index.module.less +35 -35
- package/lib/components/Select/IconSelect/index.module.less +3 -3
- package/lib/components/Select/TreeSelect/index.module.less +17 -17
- package/lib/components/Select/_utils/getElementPosition.d.ts +6 -2
- package/lib/components/Select/_utils/getElementPosition.js +8 -6
- package/lib/components/Select/index.module.less +37 -34
- package/lib/components/Slider/index.module.less +5 -4
- package/lib/components/Spreadsheet/index.module.less +4 -4
- package/lib/components/Switch/index.js +8 -4
- package/lib/components/Switch/index.module.less +7 -0
- package/lib/components/Table/_components/Pagination/index.module.less +23 -23
- package/lib/components/Table/index.module.less +61 -61
- package/lib/components/Tree/index.module.less +11 -11
- package/lib/components/Upload/index.module.less +3 -3
- package/lib/styles/antd-overload.less +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.md +20 -4
- package/src/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/src/components/ChainGraph/_components/SearchSelect/index.tsx +18 -16
- package/src/components/ChainGraph/index.md +67 -1
- package/src/components/ChainGraph/index.module.less +1 -1
- package/src/components/Chart/index.md +351 -1
- package/src/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
- package/src/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
- package/src/components/Chat/ChatInput/index.module.less +2 -2
- package/src/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
- package/src/components/Chat/index.md +140 -1
- package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
- package/src/components/Checkbox/index.md +85 -1
- package/src/components/Checkbox/index.module.less +13 -13
- package/src/components/CodeMirror/index.md +41 -1
- package/src/components/CodeMirror/index.module.less +4 -4
- package/src/components/Copy/index.md +1 -1
- package/src/components/DatePicker/RangePicker/index.module.less +1 -1
- package/src/components/DatePicker/StepPicker/index.module.less +1 -1
- package/src/components/DatePicker/index.md +82 -1
- package/src/components/DatePicker/index.module.less +2 -1
- package/src/components/Descriptions/index.md +45 -1
- package/src/components/Editor/index.md +40 -1
- package/src/components/FileCol/index.md +24 -1
- package/src/components/FilePreview/index.md +45 -1
- package/src/components/FlexFill/index.md +46 -1
- package/src/components/Form/DrawerForm/index.module.less +2 -2
- package/src/components/Form/index.md +179 -1
- package/src/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/src/components/FormItem/FormInput/FormPasswordStrength/index.tsx +2 -2
- package/src/components/FormItem/FormRadio/index.module.less +9 -9
- package/src/components/FormItem/FormSegmented/index.module.less +2 -2
- package/src/components/FormItem/FormUpload/index.module.less +4 -4
- package/src/components/FormItem/ItemContainer/index.module.less +22 -22
- package/src/components/FormItem/index.md +514 -1
- package/src/components/Icon/index.md +24 -4
- package/src/components/Icon/index.tsx +9 -37
- package/src/components/Input/Number/index.module.less +9 -9
- package/src/components/Input/Password/index.module.less +3 -3
- package/src/components/Input/Range/index.module.less +4 -4
- package/src/components/Input/Search/index.module.less +5 -5
- package/src/components/Input/TextArea/index.module.less +5 -5
- package/src/components/Input/index.md +148 -1
- package/src/components/Input/index.module.less +7 -4
- package/src/components/Markdown/index.md +73 -1
- package/src/components/Modal/index.md +43 -1
- package/src/components/Modal/index.module.less +2 -2
- package/src/components/Operate/index.md +43 -1
- package/src/components/Operate/index.module.less +2 -2
- package/src/components/Panel/IframePanel/index.module.less +1 -1
- package/src/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
- package/src/components/Panel/index.md +193 -1
- package/src/components/Search/index.md +248 -1
- package/src/components/Search/index.module.less +2 -2
- package/src/components/SecondConf/index.md +39 -1
- package/src/components/Select/AutoCompleteSelect/index.module.less +35 -35
- package/src/components/Select/IconSelect/index.module.less +3 -3
- package/src/components/Select/TreeSelect/index.module.less +17 -17
- package/src/components/Select/_utils/getElementPosition.ts +8 -6
- package/src/components/Select/index.md +47 -1
- package/src/components/Select/index.module.less +37 -34
- package/src/components/Slider/index.md +28 -1
- package/src/components/Slider/index.module.less +5 -4
- package/src/components/Spreadsheet/index.md +42 -1
- package/src/components/Spreadsheet/index.module.less +4 -4
- package/src/components/Switch/index.md +33 -1
- package/src/components/Switch/index.module.less +7 -0
- package/src/components/Switch/index.tsx +14 -11
- package/src/components/TabBar/index.md +70 -1
- package/src/components/Table/_components/Pagination/index.module.less +23 -23
- package/src/components/Table/index.md +60 -1
- package/src/components/Table/index.module.less +61 -61
- package/src/components/Tags/index.md +23 -1
- package/src/components/TextEllipsis/index.md +29 -1
- package/src/components/Tree/index.md +66 -1
- package/src/components/Tree/index.module.less +11 -11
- package/src/components/Upload/index.md +72 -1
- package/src/components/Upload/index.module.less +3 -3
- package/src/styles/antd-overload.less +1 -1
|
@@ -8,10 +8,360 @@ title: Chart 图表
|
|
|
8
8
|
|
|
9
9
|
# Chart 图表
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 echarts 封装的图表集合,以 `Chart.Line`、`Chart.Bar`、`Chart.Pie` 等子组件形式提供常用图表,自动处理实例创建、容器自适应与销毁。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Chart } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 子组件一览
|
|
20
|
+
|
|
21
|
+
`Chart` 提供以下子组件:
|
|
22
|
+
|
|
23
|
+
| 子组件 | 说明 |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| Chart.Line | 折线图 |
|
|
26
|
+
| Chart.Bar | 柱状图 |
|
|
27
|
+
| Chart.Pie | 饼图(另含 `Chart.Pie.Three` 3D 饼图) |
|
|
28
|
+
| Chart.Polar | 极坐标图 |
|
|
29
|
+
| Chart.Gauge | 仪表盘 |
|
|
30
|
+
| Chart.Sankey | 桑基图 |
|
|
31
|
+
| Chart.Tree | 树图 |
|
|
32
|
+
| Chart.Bubble | 气泡图 |
|
|
33
|
+
| Chart.Heatmap | 热力图 |
|
|
34
|
+
| Chart.Radar | 雷达图 |
|
|
35
|
+
| Chart.Group | 组合图表(可在 `Line`/`Bar`/`Pie` 间切换) |
|
|
36
|
+
| Chart.Common | 通用图表,直接透传 echarts 的 `EChartsOption` |
|
|
37
|
+
|
|
38
|
+
> 以下示例均放在固定高度的容器中(echarts 需要有尺寸的容器才能渲染)。
|
|
39
|
+
|
|
40
|
+
## 折线图
|
|
41
|
+
|
|
42
|
+
以 `Chart.Line` 为例,传入 `xAxisData` 与 `seriesData` 即可渲染折线图:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import React from "react";
|
|
46
|
+
import { Chart } from "@hsu-react/ui";
|
|
47
|
+
|
|
48
|
+
export default () => (
|
|
49
|
+
<Chart.Line
|
|
50
|
+
style={{ height: 300 }}
|
|
51
|
+
legendData={["销量"]}
|
|
52
|
+
xAxisData={["周一", "周二", "周三", "周四", "周五", "周六", "周日"]}
|
|
53
|
+
seriesData={[120, 200, 150, 80, 70, 110, 130]}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 柱状图
|
|
59
|
+
|
|
60
|
+
柱状图,与 `Chart.Line` 用法一致,传入 `xAxisData` 与 `seriesData`。
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import React from "react";
|
|
64
|
+
import { Chart } from "@hsu-react/ui";
|
|
65
|
+
|
|
66
|
+
export default () => (
|
|
67
|
+
<div style={{ height: 280 }}>
|
|
68
|
+
<Chart.Bar
|
|
69
|
+
legendData={["销量"]}
|
|
70
|
+
xAxisData={["一月", "二月", "三月", "四月", "五月", "六月"]}
|
|
71
|
+
seriesData={[120, 200, 150, 80, 70, 110]}
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 饼图
|
|
78
|
+
|
|
79
|
+
饼图,`seriesData` 为 `{ name, value }` 对象数组。
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import React from "react";
|
|
83
|
+
import { Chart } from "@hsu-react/ui";
|
|
84
|
+
|
|
85
|
+
export default () => (
|
|
86
|
+
<div style={{ height: 280 }}>
|
|
87
|
+
<Chart.Pie
|
|
88
|
+
chartTitle="访问来源"
|
|
89
|
+
seriesData={[
|
|
90
|
+
{ name: "直接访问", value: 335 },
|
|
91
|
+
{ name: "搜索引擎", value: 234 },
|
|
92
|
+
{ name: "邮件营销", value: 154 },
|
|
93
|
+
{ name: "联盟广告", value: 135 },
|
|
94
|
+
]}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 雷达图
|
|
101
|
+
|
|
102
|
+
雷达图,`indicators` 定义各维度(`{ name, max }`),`data` 为对应数值数组。
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import React from "react";
|
|
106
|
+
import { Chart } from "@hsu-react/ui";
|
|
107
|
+
|
|
108
|
+
export default () => (
|
|
109
|
+
<div style={{ height: 280 }}>
|
|
110
|
+
<Chart.Radar
|
|
111
|
+
name="能力评估"
|
|
112
|
+
indicators={[
|
|
113
|
+
{ name: "研发", max: 100 },
|
|
114
|
+
{ name: "测试", max: 100 },
|
|
115
|
+
{ name: "运维", max: 100 },
|
|
116
|
+
{ name: "设计", max: 100 },
|
|
117
|
+
{ name: "产品", max: 100 },
|
|
118
|
+
]}
|
|
119
|
+
data={[80, 70, 65, 90, 75]}
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 仪表盘
|
|
126
|
+
|
|
127
|
+
仪表盘,`seriesData` 为 `{ value, name }` 数组(默认量程 0~100)。
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import React from "react";
|
|
131
|
+
import { Chart } from "@hsu-react/ui";
|
|
132
|
+
|
|
133
|
+
export default () => (
|
|
134
|
+
<div style={{ height: 280 }}>
|
|
135
|
+
<Chart.Gauge seriesData={[{ value: 72, name: "完成率" }]} />
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 桑基图
|
|
141
|
+
|
|
142
|
+
桑基图,`seriesData` 为节点 `{ name }` 数组,`seriesLinks` 为连线 `{ source, target }` 数组。
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import React from "react";
|
|
146
|
+
import { Chart } from "@hsu-react/ui";
|
|
147
|
+
|
|
148
|
+
export default () => (
|
|
149
|
+
<div style={{ height: 280 }}>
|
|
150
|
+
<Chart.Sankey
|
|
151
|
+
seriesData={[
|
|
152
|
+
{ name: "访问" },
|
|
153
|
+
{ name: "注册" },
|
|
154
|
+
{ name: "下单" },
|
|
155
|
+
{ name: "复购" },
|
|
156
|
+
]}
|
|
157
|
+
seriesLinks={[
|
|
158
|
+
{ source: "访问", target: "注册" },
|
|
159
|
+
{ source: "注册", target: "下单" },
|
|
160
|
+
{ source: "下单", target: "复购" },
|
|
161
|
+
]}
|
|
162
|
+
/>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 热力图
|
|
168
|
+
|
|
169
|
+
热力图,`data` 为 `[xIndex, yIndex, value]` 数组,配合 `xAxisData`、`yAxisData` 类目。
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import React from "react";
|
|
173
|
+
import { Chart } from "@hsu-react/ui";
|
|
174
|
+
|
|
175
|
+
export default () => (
|
|
176
|
+
<div style={{ height: 280 }}>
|
|
177
|
+
<Chart.Heatmap
|
|
178
|
+
xAxisData={["周一", "周二", "周三"]}
|
|
179
|
+
yAxisData={["上午", "下午", "晚上"]}
|
|
180
|
+
data={[
|
|
181
|
+
[0, 0, 5],
|
|
182
|
+
[0, 1, 7],
|
|
183
|
+
[0, 2, 3],
|
|
184
|
+
[1, 0, 8],
|
|
185
|
+
[1, 1, 2],
|
|
186
|
+
[1, 2, 6],
|
|
187
|
+
[2, 0, 4],
|
|
188
|
+
[2, 1, 9],
|
|
189
|
+
[2, 2, 1],
|
|
190
|
+
]}
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## 气泡图
|
|
197
|
+
|
|
198
|
+
气泡图,`data` 为 `{ name, value }` 数组,气泡大小随 `value` 自适应。
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
import React from "react";
|
|
202
|
+
import { Chart } from "@hsu-react/ui";
|
|
203
|
+
|
|
204
|
+
export default () => (
|
|
205
|
+
<div style={{ height: 280 }}>
|
|
206
|
+
<Chart.Bubble
|
|
207
|
+
data={[
|
|
208
|
+
{ name: "前端", value: 120 },
|
|
209
|
+
{ name: "后端", value: 90 },
|
|
210
|
+
{ name: "测试", value: 60 },
|
|
211
|
+
{ name: "运维", value: 40 },
|
|
212
|
+
{ name: "设计", value: 30 },
|
|
213
|
+
]}
|
|
214
|
+
/>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## 树图
|
|
220
|
+
|
|
221
|
+
树图,`seriesData` 为带 `children` 的层级节点数组(节点需含 `value` 字段)。
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import React from "react";
|
|
225
|
+
import { Chart } from "@hsu-react/ui";
|
|
226
|
+
|
|
227
|
+
export default () => (
|
|
228
|
+
<div style={{ height: 280 }}>
|
|
229
|
+
<Chart.Tree
|
|
230
|
+
seriesData={[
|
|
231
|
+
{
|
|
232
|
+
name: "根节点",
|
|
233
|
+
value: 1,
|
|
234
|
+
children: [
|
|
235
|
+
{
|
|
236
|
+
name: "分支 A",
|
|
237
|
+
value: 1,
|
|
238
|
+
children: [
|
|
239
|
+
{ name: "叶子 1", value: 1 },
|
|
240
|
+
{ name: "叶子 2", value: 1 },
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
{ name: "分支 B", value: 1 },
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
]}
|
|
247
|
+
/>
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## 极坐标图
|
|
253
|
+
|
|
254
|
+
极坐标进度环,`seriesData` 为单个 `{ name, value }` 对象(`angleAxis.max` 默认 100)。
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
import React from "react";
|
|
258
|
+
import { Chart } from "@hsu-react/ui";
|
|
259
|
+
|
|
260
|
+
export default () => (
|
|
261
|
+
<div style={{ height: 280 }}>
|
|
262
|
+
<Chart.Polar
|
|
263
|
+
title1="75%"
|
|
264
|
+
title2="完成度"
|
|
265
|
+
title1Style={{ color: "#333" }}
|
|
266
|
+
title2Style={{ color: "#999" }}
|
|
267
|
+
color={["#1675FB", "#5AB5F6"]}
|
|
268
|
+
seriesData={{ name: "完成度", value: 75 }}
|
|
269
|
+
/>
|
|
270
|
+
</div>
|
|
271
|
+
);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## 通用图表
|
|
275
|
+
|
|
276
|
+
通用图表,直接透传 echarts 原生 `EChartsOption`,适合上述封装未覆盖的场景。
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
import React from "react";
|
|
280
|
+
import { Chart } from "@hsu-react/ui";
|
|
281
|
+
|
|
282
|
+
export default () => (
|
|
283
|
+
<div style={{ height: 280 }}>
|
|
284
|
+
<Chart.Common
|
|
285
|
+
tooltip={{ trigger: "axis" }}
|
|
286
|
+
xAxis={{ type: "category", data: ["A", "B", "C", "D", "E"] }}
|
|
287
|
+
yAxis={{ type: "value" }}
|
|
288
|
+
series={[{ type: "line", smooth: true, data: [10, 22, 18, 30, 25] }]}
|
|
289
|
+
/>
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 组合图表
|
|
295
|
+
|
|
296
|
+
组合图表,通过 `chartGroup` 传入若干 `{ type, options }`,可按 `pageSize` 分页展示并在 `Line`/`Bar`/`Pie` 间组合。其内部依赖布局样式,建议在业务页面中使用:
|
|
297
|
+
|
|
298
|
+
```tsx | pure
|
|
299
|
+
import { Chart } from "@hsu-react/ui";
|
|
300
|
+
|
|
301
|
+
export default () => (
|
|
302
|
+
<Chart.Group
|
|
303
|
+
style={{ height: 320 }}
|
|
304
|
+
pageSize={2}
|
|
305
|
+
chartGroup={[
|
|
306
|
+
{
|
|
307
|
+
type: "Bar",
|
|
308
|
+
options: {
|
|
309
|
+
chartTitle: "销量",
|
|
310
|
+
xAxisData: ["一月", "二月", "三月"],
|
|
311
|
+
seriesData: [120, 200, 150],
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
type: "Pie",
|
|
316
|
+
options: {
|
|
317
|
+
chartTitle: "占比",
|
|
318
|
+
seriesData: [
|
|
319
|
+
{ name: "直接访问", value: 335 },
|
|
320
|
+
{ name: "搜索引擎", value: 234 },
|
|
321
|
+
],
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
]}
|
|
325
|
+
/>
|
|
326
|
+
);
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## API
|
|
330
|
+
|
|
331
|
+
### Chart.Line / Chart.Bar
|
|
332
|
+
|
|
333
|
+
在 echarts `EChartsOption` 基础上扩展(`Chart.Bar` 同此表):
|
|
334
|
+
|
|
335
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
336
|
+
| --- | --- | --- | --- |
|
|
337
|
+
| xAxisData | X 轴类目数据 | `string[]` | - |
|
|
338
|
+
| seriesData | 系列数据,可为数字数组或带 `name`/`series` 的对象数组 | `SeriesDataType` | - |
|
|
339
|
+
| legendData | 图例数据 | `string[]` | - |
|
|
340
|
+
| chartTitle | 图表标题 | `string` | - |
|
|
341
|
+
| scrollConfig | 滚动/缩放配置 | `ChartScrollConfig` | - |
|
|
342
|
+
| insideDataZoom | 内置型数据缩放配置 | `DataZoomComponentOption` | - |
|
|
343
|
+
| sliderDataZoom | 滑动条型数据缩放配置 | `DataZoomComponentOption` | - |
|
|
344
|
+
| enableLegendAutoScroll | 是否启用图例自动滚动 | `boolean` | `false` |
|
|
345
|
+
| legendVisibleCount | 图例每页可见数量 | `number` | `8` |
|
|
346
|
+
| legendScrollInterval | 图例滚动间隔(ms) | `number` | `1500` |
|
|
347
|
+
| onClick | 图元点击回调 | `(event: ECElementEvent) => void` | - |
|
|
348
|
+
| className | 容器类名 | `string` | - |
|
|
349
|
+
| style | 容器样式 | `ChartCSSProperties` | - |
|
|
350
|
+
|
|
351
|
+
> `Chart.Line` 额外支持 `yAxisNameOffsets?: number[]`;其余 echarts 原生配置项(`grid`、`xAxis`、`yAxis`、`tooltip`、`series` 等)均可直接透传。
|
|
352
|
+
|
|
353
|
+
### Chart.Pie
|
|
354
|
+
|
|
355
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
356
|
+
| --- | --- | --- | --- |
|
|
357
|
+
| seriesData | 系列数据 | `SeriesDataType` | - |
|
|
358
|
+
| chartTitle | 图表中心标题 | `string` | - |
|
|
359
|
+
| extendSeries | 追加的额外系列 | `Series[]` | `[]` |
|
|
360
|
+
| isSemiCircle | 是否为半圆 | `boolean` | `false` |
|
|
361
|
+
| position | 半圆贴边位置 | `'top' \| 'bottom' \| 'left' \| 'right'` | `'bottom'` |
|
|
362
|
+
| spanAngle | 显示角度 | `number` | `180` |
|
|
363
|
+
| center | 中心位置 | `[string, string]` | - |
|
|
364
|
+
| radius | 半径配置 | `[string, string]` | - |
|
|
365
|
+
| enableLegendAutoScroll | 是否启用图例自动滚动 | `boolean` | `false` |
|
|
366
|
+
| onClick | 图元点击回调 | `(event: ECElementEvent) => void` | - |
|
|
367
|
+
| onChart | 图表实例就绪回调 | `(chart: EChartsType) => void` | - |
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
opacity: 0.8;
|
|
58
58
|
width: 140px;
|
|
59
59
|
height: 100%;
|
|
60
|
-
.ant-select-selector {
|
|
60
|
+
:global(.ant-select-selector) {
|
|
61
61
|
border: none;
|
|
62
62
|
margin: 1px 0 0;
|
|
63
63
|
}
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
|
|
93
93
|
border-radius: 4px;
|
|
94
94
|
|
|
95
|
-
.ant-btn-icon {
|
|
95
|
+
:global(.ant-btn-icon) {
|
|
96
96
|
display: flex;
|
|
97
97
|
align-items: center;
|
|
98
98
|
justify-content: center;
|
|
@@ -8,10 +8,149 @@ title: Chat 对话
|
|
|
8
8
|
|
|
9
9
|
# Chat 对话
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 `@ant-design/x` 封装的 AI 对话组件集合,以 `Chat.List`(消息列表)、`Chat.Input`(输入框)、`Chat.History`(历史会话)三个子组件构成完整对话界面。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Chat } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 对话
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React, { useState } from "react";
|
|
23
|
+
import { Chat } from "@hsu-react/ui";
|
|
24
|
+
|
|
25
|
+
export default () => {
|
|
26
|
+
const [list, setList] = useState([
|
|
27
|
+
{
|
|
28
|
+
query: { query: "你好,请介绍一下你自己" },
|
|
29
|
+
answers: [
|
|
30
|
+
{ answer: "你好!我是 AI 助手,有什么可以帮你的吗?", messageId: "1" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
const handleSend = (value) => {
|
|
36
|
+
setList((prev) => [
|
|
37
|
+
...prev,
|
|
38
|
+
{
|
|
39
|
+
query: { query: value },
|
|
40
|
+
answers: [{ answer: `已收到:${value}`, messageId: String(Date.now()) }],
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ display: "flex", flexDirection: "column", height: 420 }}>
|
|
47
|
+
<div style={{ flex: 1, overflow: "auto" }}>
|
|
48
|
+
<Chat.List list={list} />
|
|
49
|
+
</div>
|
|
50
|
+
<Chat.Input onSend={handleSend} uploadEnabled={false} />
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 历史会话
|
|
57
|
+
|
|
58
|
+
历史会话列表,`historyList` 为按分组(如日期)组织的会话数据,支持新建、点击切换、重命名与删除会话。
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import React, { useState } from "react";
|
|
62
|
+
import { Chat } from "@hsu-react/ui";
|
|
63
|
+
|
|
64
|
+
export default () => {
|
|
65
|
+
const [currentChatId, setCurrentChatId] = useState("1");
|
|
66
|
+
|
|
67
|
+
const historyList = {
|
|
68
|
+
今天: [
|
|
69
|
+
{ id: "1", name: "如何学习 React", conversationId: "c1" },
|
|
70
|
+
{ id: "2", name: "TypeScript 入门", conversationId: "c2" },
|
|
71
|
+
],
|
|
72
|
+
昨天: [{ id: "3", name: "前端性能优化", conversationId: "c3" }],
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
style={{
|
|
78
|
+
height: 360,
|
|
79
|
+
width: 260,
|
|
80
|
+
border: "1px solid #f0f0f0",
|
|
81
|
+
borderRadius: 8,
|
|
82
|
+
overflow: "hidden",
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<Chat.History
|
|
86
|
+
historyList={historyList}
|
|
87
|
+
currentChatId={currentChatId}
|
|
88
|
+
width="260px"
|
|
89
|
+
onNewChat={() => setCurrentChatId("")}
|
|
90
|
+
onChatItemClick={(item) => setCurrentChatId(item.id)}
|
|
91
|
+
updateTitle={(chatId, title) => console.log("重命名", chatId, title)}
|
|
92
|
+
deleteHistory={(item) => console.log("删除", item)}
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Chat.List
|
|
100
|
+
|
|
101
|
+
消息列表,渲染用户提问与 AI 回答。
|
|
102
|
+
|
|
103
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
104
|
+
| --- | --- | --- | --- |
|
|
105
|
+
| list | 消息列表数据 | `ChatMessage[]` | `[]` |
|
|
106
|
+
| assistanting | AI 是否正在回答中 | `boolean` | - |
|
|
107
|
+
| onAgain | 重新生成回调 | `(query: string) => void` | - |
|
|
108
|
+
| onLikeChange | 点赞/点踩变化回调 | `(messageId: string, like: boolean \| null, content: string) => void` | - |
|
|
109
|
+
| hideTool | 是否隐藏消息工具栏 | `boolean` | - |
|
|
110
|
+
| defaultAnswer | 默认(空态)回答内容 | `string` | - |
|
|
111
|
+
| userName / assistantName | 用户/助手名称 | `string` | - |
|
|
112
|
+
| userAvatar / assistantAvatar | 用户/助手头像 | `ReactNode` | - |
|
|
113
|
+
| userRenderContent | 自定义用户消息内容 | `(originContent: ReactNode, item: QueryMessage) => ReactNode` | - |
|
|
114
|
+
| userRenderQuery | 自定义用户提问文本 | `(query: string \| undefined, item: QueryMessage) => string \| undefined` | - |
|
|
115
|
+
| noAnswerTip | 无回答时的提示文案 | `string` | - |
|
|
116
|
+
| className | 容器类名 | `string` | - |
|
|
117
|
+
|
|
118
|
+
> 另有 `defaultAnswerClassName`、`userClassName`、`assistantClassName`、`userHeaderClassName`、`assistantHeaderClassName` 等多个样式类名属性。
|
|
119
|
+
|
|
120
|
+
## Chat.Input
|
|
121
|
+
|
|
122
|
+
对话输入框,支持文件上传、模型切换、功能(agent)开关。
|
|
123
|
+
|
|
124
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
125
|
+
| --- | --- | --- | --- |
|
|
126
|
+
| onSend | 发送回调 | `(value: string) => void` | - |
|
|
127
|
+
| assistanting | AI 是否回答中(显示停止按钮) | `boolean` | - |
|
|
128
|
+
| onStop | 停止回答回调 | `() => void` | - |
|
|
129
|
+
| fileList | 文件列表 | `UploadFile[]` | `[]` |
|
|
130
|
+
| onFileListChange | 文件列表变化回调 | `(fileList: UploadFile[]) => void` | - |
|
|
131
|
+
| uploadEnabled | 是否启用上传 | `boolean` | `true` |
|
|
132
|
+
| uploadConfig | 上传配置 | `UploadConfig` | - |
|
|
133
|
+
| modelConfig | 模型切换配置 | `{ modelList: ModelConfig[]; modelType: string; setModelType: (value: string) => void }` | - |
|
|
134
|
+
| agents | 功能开关配置 | `AgentToggleConfig[]` | `[]` |
|
|
135
|
+
| agentsState | 功能开关状态(受控) | `AgentConfig[]` | - |
|
|
136
|
+
| onAgentsChange | 功能开关变化回调 | `(agents: AgentConfig[]) => void` | - |
|
|
137
|
+
| placeholder | 占位提示文字 | `string` | `'询问问题'` |
|
|
138
|
+
| sendIcon / stopIcon | 发送/停止图标 | `string` | - |
|
|
139
|
+
| buttonGroup | 额外按钮组 | `ButtonProps[]` | - |
|
|
140
|
+
| wrapperClassName | 容器类名 | `string` | - |
|
|
141
|
+
|
|
142
|
+
## Chat.History
|
|
143
|
+
|
|
144
|
+
历史会话列表,支持新建、重命名、删除会话。
|
|
145
|
+
|
|
146
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
147
|
+
| --- | --- | --- | --- |
|
|
148
|
+
| historyList | 分组历史会话数据 | `Record<string, ChatHistoryData[]>` | - |
|
|
149
|
+
| currentChatId | 当前选中的会话 id | `string` | - |
|
|
150
|
+
| onNewChat | 新建会话回调 | `() => void` | - |
|
|
151
|
+
| onChatItemClick | 会话点击回调 | `(item: ChatHistoryData) => void` | - |
|
|
152
|
+
| updateTitle | 重命名回调 | `(chatId: string, title: string) => void` | - |
|
|
153
|
+
| deleteHistory | 删除会话回调 | `(item?: ChatHistoryData) => void` | - |
|
|
154
|
+
| onScrollEnd | 滚动到底部回调(加载更多) | `() => void` | - |
|
|
155
|
+
| width | 容器宽度 | `string` | - |
|
|
156
|
+
| tools | 顶部自定义工具区 | `ReactNode` | - |
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
height: 100%;
|
|
11
11
|
|
|
12
12
|
// 当 hasAll 为 true 时,Group 作为子元素
|
|
13
|
-
> .ant-checkbox-group {
|
|
13
|
+
> :global(.ant-checkbox-group) {
|
|
14
14
|
display: flex;
|
|
15
15
|
flex-direction: column;
|
|
16
16
|
row-gap: 8px;
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
&.outline {
|
|
31
|
-
.ant-checkbox-wrapper {
|
|
32
|
-
.ant-checkbox {
|
|
33
|
-
.ant-checkbox-inner {
|
|
31
|
+
:global(.ant-checkbox-wrapper) {
|
|
32
|
+
:global(.ant-checkbox) {
|
|
33
|
+
:global(.ant-checkbox-inner) {
|
|
34
34
|
border-color: rgba(204, 204, 204, 1) !important;
|
|
35
35
|
|
|
36
36
|
background: transparent !important;
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
.ant-checkbox-inner {
|
|
44
|
+
&:global(.ant-checkbox-checked) {
|
|
45
|
+
:global(.ant-checkbox-inner) {
|
|
46
46
|
background: rgba(255, 255, 255, 1) !important;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
.ant-checkbox {
|
|
53
|
-
.ant-checkbox-inner {
|
|
51
|
+
&:global(.ant-checkbox-wrapper-disabled) {
|
|
52
|
+
:global(.ant-checkbox) {
|
|
53
|
+
:global(.ant-checkbox-inner) {
|
|
54
54
|
background: rgba(0, 0, 0, 0.04) !important;
|
|
55
55
|
|
|
56
56
|
&::after {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
.ant-checkbox-inner {
|
|
61
|
+
&:global(.ant-checkbox-checked) {
|
|
62
|
+
:global(.ant-checkbox-inner) {
|
|
63
63
|
background: rgba(0, 0, 0, 0.04) !important;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
.ant-checkbox-wrapper {
|
|
71
|
+
:global(.ant-checkbox-wrapper) {
|
|
72
72
|
align-items: center;
|
|
73
73
|
|
|
74
74
|
font-family: inherit;
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
font-weight: inherit;
|
|
77
77
|
color: inherit;
|
|
78
78
|
|
|
79
|
-
.ant-checkbox {
|
|
79
|
+
:global(.ant-checkbox) {
|
|
80
80
|
width: 16px;
|
|
81
81
|
min-width: 16px;
|
|
82
82
|
height: 16px;
|
|
@@ -84,12 +84,12 @@
|
|
|
84
84
|
|
|
85
85
|
border-radius: 2px;
|
|
86
86
|
|
|
87
|
-
input[type="checkbox"].ant-checkbox-input {
|
|
87
|
+
input[type="checkbox"]:global(.ant-checkbox-input) {
|
|
88
88
|
width: 100%;
|
|
89
89
|
height: 100%;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
.ant-checkbox-inner {
|
|
92
|
+
:global(.ant-checkbox-inner) {
|
|
93
93
|
width: 100%;
|
|
94
94
|
height: 100%;
|
|
95
95
|
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
&-indeterminate {
|
|
109
|
-
.ant-checkbox-inner {
|
|
109
|
+
:global(.ant-checkbox-inner) {
|
|
110
110
|
&::after {
|
|
111
111
|
left: 50%;
|
|
112
112
|
top: 50%;
|