@hsu-react/ui 0.0.2 → 0.0.4
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/DatePicker/index.module.less +1 -0
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -2
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/es/components/Input/Range/index.module.less +4 -4
- package/es/components/Input/index.module.less +3 -0
- package/es/components/Panel/ListPanel/index.d.ts +2 -0
- package/es/components/Panel/ListPanel/index.js +3 -2
- 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 +3 -0
- package/es/components/Slider/index.module.less +1 -0
- package/es/components/Switch/index.js +12 -8
- package/es/components/Switch/index.module.less +7 -0
- package/lib/components/ChainGraph/_components/SearchSelect/index.js +10 -7
- package/lib/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/lib/components/DatePicker/index.module.less +1 -0
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -1
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/lib/components/Input/Range/index.module.less +4 -4
- package/lib/components/Input/index.module.less +3 -0
- package/lib/components/Panel/ListPanel/index.d.ts +2 -0
- package/lib/components/Panel/ListPanel/index.js +4 -1
- 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 +3 -0
- package/lib/components/Slider/index.module.less +1 -0
- package/lib/components/Switch/index.js +8 -4
- package/lib/components/Switch/index.module.less +7 -0
- package/package.json +1 -1
- package/src/components/Button/index.md +18 -1
- 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 +2 -1
- package/src/components/Chart/index.md +290 -17
- package/src/components/Chat/index.md +44 -1
- package/src/components/Checkbox/index.md +33 -1
- package/src/components/CodeMirror/index.md +1 -1
- package/src/components/Copy/index.md +1 -1
- package/src/components/DatePicker/index.md +41 -2
- package/src/components/DatePicker/index.module.less +1 -0
- package/src/components/Descriptions/index.md +1 -1
- package/src/components/Editor/index.md +1 -1
- package/src/components/FileCol/index.md +1 -1
- package/src/components/FilePreview/index.md +1 -1
- package/src/components/FlexFill/index.md +1 -1
- package/src/components/Form/index.md +88 -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/index.md +147 -92
- package/src/components/Icon/index.md +3 -1
- package/src/components/Input/Range/index.module.less +4 -4
- package/src/components/Input/index.md +115 -2
- package/src/components/Input/index.module.less +3 -0
- package/src/components/Markdown/index.md +3 -1
- package/src/components/Modal/index.md +1 -1
- package/src/components/Operate/index.md +1 -1
- package/src/components/Panel/ListPanel/index.tsx +6 -0
- package/src/components/Panel/index.md +68 -21
- package/src/components/Search/index.md +184 -9
- package/src/components/SecondConf/index.md +1 -1
- package/src/components/Select/_utils/getElementPosition.ts +8 -6
- package/src/components/Select/index.md +1 -1
- package/src/components/Select/index.module.less +3 -0
- package/src/components/Slider/index.md +1 -2
- package/src/components/Slider/index.module.less +1 -0
- package/src/components/Spreadsheet/index.md +1 -1
- package/src/components/Switch/index.md +1 -1
- package/src/components/Switch/index.module.less +7 -0
- package/src/components/Switch/index.tsx +14 -11
- package/src/components/TabBar/index.md +28 -11
- package/src/components/Table/index.md +1 -1
- package/src/components/Tags/index.md +1 -1
- package/src/components/TextEllipsis/index.md +1 -1
- package/src/components/Tree/index.md +1 -1
- package/src/components/Upload/index.md +1 -1
|
@@ -16,7 +16,28 @@ title: Chart 图表
|
|
|
16
16
|
import { Chart } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
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
|
+
## 折线图
|
|
20
41
|
|
|
21
42
|
以 `Chart.Line` 为例,传入 `xAxisData` 与 `seriesData` 即可渲染折线图:
|
|
22
43
|
|
|
@@ -34,24 +55,276 @@ export default () => (
|
|
|
34
55
|
);
|
|
35
56
|
```
|
|
36
57
|
|
|
37
|
-
##
|
|
58
|
+
## 柱状图
|
|
38
59
|
|
|
39
|
-
`Chart`
|
|
60
|
+
柱状图,与 `Chart.Line` 用法一致,传入 `xAxisData` 与 `seriesData`。
|
|
40
61
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
+
```
|
|
55
328
|
|
|
56
329
|
## API
|
|
57
330
|
|
|
@@ -16,7 +16,7 @@ title: Chat 对话
|
|
|
16
16
|
import { Chat } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 对话
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
22
|
import React, { useState } from "react";
|
|
@@ -53,6 +53,49 @@ export default () => {
|
|
|
53
53
|
};
|
|
54
54
|
```
|
|
55
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
|
+
|
|
56
99
|
## Chat.List
|
|
57
100
|
|
|
58
101
|
消息列表,渲染用户提问与 AI 回答。
|
|
@@ -16,7 +16,7 @@ title: Checkbox 多选框
|
|
|
16
16
|
import { Checkbox } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 多选框
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
22
|
import React from "react";
|
|
@@ -47,6 +47,38 @@ export default () => {
|
|
|
47
47
|
};
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## 多选框组
|
|
51
|
+
|
|
52
|
+
多选框组,支持 `hasAll`(全选)、`layout`(排列方向)与 `outline`(描边样式)。
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import React from "react";
|
|
56
|
+
import { Checkbox } from "@hsu-react/ui";
|
|
57
|
+
|
|
58
|
+
const options = [
|
|
59
|
+
{ label: "苹果", value: "apple" },
|
|
60
|
+
{ label: "香蕉", value: "banana" },
|
|
61
|
+
{ label: "橙子", value: "orange" },
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export default () => {
|
|
65
|
+
const [value, setValue] = React.useState(["apple"]);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
|
|
69
|
+
<Checkbox.Group
|
|
70
|
+
options={options}
|
|
71
|
+
value={value}
|
|
72
|
+
onChange={setValue}
|
|
73
|
+
hasAll
|
|
74
|
+
outline
|
|
75
|
+
layout="vertical"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
50
82
|
## API
|
|
51
83
|
|
|
52
84
|
### Checkbox
|
|
@@ -16,7 +16,7 @@ title: DatePicker 日期选择
|
|
|
16
16
|
import { DatePicker } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 日期选择
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
22
|
import React, { useState } from "react";
|
|
@@ -36,7 +36,46 @@ export default () => {
|
|
|
36
36
|
>
|
|
37
37
|
<DatePicker value={value} onChange={(date) => setValue(date)} />
|
|
38
38
|
<DatePicker showPicker onChange={(date, picker) => console.log(date, picker)} />
|
|
39
|
-
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 日期范围选择
|
|
45
|
+
|
|
46
|
+
区间选择,`value` / `defaultValue` 为 `string[]`,`onChange` 返回格式化后的 `string[]`,同样支持 `picker` / `showPicker` 等粒度切换。
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import React, { useState } from "react";
|
|
50
|
+
import { DatePicker } from "@hsu-react/ui";
|
|
51
|
+
|
|
52
|
+
export default () => {
|
|
53
|
+
const [value, setValue] = useState<string[]>();
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
|
|
57
|
+
<DatePicker.RangePicker value={value} onChange={(dates) => setValue(dates)} />
|
|
58
|
+
<DatePicker.RangePicker showPicker onChange={(dates, picker) => console.log(dates, picker)} />
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 步进日期选择
|
|
65
|
+
|
|
66
|
+
按 `step` 步进的日期选择,支持 `picker: 'day' | 'month' | 'year'`,以及 `minDate` / `maxDate` 边界限制。
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import React, { useState } from "react";
|
|
70
|
+
import { DatePicker } from "@hsu-react/ui";
|
|
71
|
+
|
|
72
|
+
export default () => {
|
|
73
|
+
const [value, setValue] = useState<string>();
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
|
|
77
|
+
<DatePicker.StepPicker picker="day" step={1} onChange={(date) => setValue(date)} />
|
|
78
|
+
<DatePicker.StepPicker picker="month" onChange={(date) => setValue(date)} />
|
|
40
79
|
</div>
|
|
41
80
|
);
|
|
42
81
|
};
|
|
@@ -16,7 +16,7 @@ title: Form 表单
|
|
|
16
16
|
import { Form } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 弹窗表单
|
|
20
20
|
|
|
21
21
|
`Form` 是一个命名空间对象,常用 `Form.Modal` 渲染弹窗表单,表单项通过 `formItems` 配置。点击下方按钮试试:
|
|
22
22
|
|
|
@@ -70,6 +70,93 @@ export default () => {
|
|
|
70
70
|
};
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
## 抽屉表单
|
|
74
|
+
|
|
75
|
+
抽屉形态的表单,用法与 `Form.Modal` 一致,通过 `formItems` 配置表单项,适合内容较多的录入场景。
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import React, { useState } from "react";
|
|
79
|
+
import { Form } from "@hsu-react/ui";
|
|
80
|
+
import { Button, message } from "antd";
|
|
81
|
+
|
|
82
|
+
export default () => {
|
|
83
|
+
const [open, setOpen] = useState(false);
|
|
84
|
+
|
|
85
|
+
const formItems = [
|
|
86
|
+
{ type: "INPUT", name: "name", label: "姓名", required: true },
|
|
87
|
+
{
|
|
88
|
+
type: "SELECT",
|
|
89
|
+
name: "role",
|
|
90
|
+
label: "角色",
|
|
91
|
+
componentProps: {
|
|
92
|
+
options: [
|
|
93
|
+
{ label: "管理员", value: "admin" },
|
|
94
|
+
{ label: "访客", value: "guest" },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{ type: "TEXTAREA", name: "remark", label: "备注" },
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
<Button type="primary" onClick={() => setOpen(true)}>
|
|
104
|
+
打开抽屉表单
|
|
105
|
+
</Button>
|
|
106
|
+
<Form.Drawer
|
|
107
|
+
open={open}
|
|
108
|
+
title="编辑用户"
|
|
109
|
+
formItems={formItems}
|
|
110
|
+
onClose={() => setOpen(false)}
|
|
111
|
+
buttonGroup={[
|
|
112
|
+
{
|
|
113
|
+
title: "取消",
|
|
114
|
+
onClick: () => setOpen(false),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
title: "确定",
|
|
118
|
+
type: "primary",
|
|
119
|
+
onClick: () => {
|
|
120
|
+
message.success("已提交");
|
|
121
|
+
setOpen(false);
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
]}
|
|
125
|
+
/>
|
|
126
|
+
</>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 导入表单
|
|
132
|
+
|
|
133
|
+
导入表单,弹窗内提供文件上传,可配置上传地址 `uploadAction` 与模板下载地址 `template`。
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import React, { useState } from "react";
|
|
137
|
+
import { Form } from "@hsu-react/ui";
|
|
138
|
+
import { Button } from "antd";
|
|
139
|
+
|
|
140
|
+
export default () => {
|
|
141
|
+
const [open, setOpen] = useState(false);
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<>
|
|
145
|
+
<Button type="primary" onClick={() => setOpen(true)}>
|
|
146
|
+
导入数据
|
|
147
|
+
</Button>
|
|
148
|
+
<Form.Import
|
|
149
|
+
open={open}
|
|
150
|
+
title="导入数据"
|
|
151
|
+
uploadAction="https://example.com/api/upload"
|
|
152
|
+
templateName="导入模板.xlsx"
|
|
153
|
+
onCancel={() => setOpen(false)}
|
|
154
|
+
/>
|
|
155
|
+
</>
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
73
160
|
## API
|
|
74
161
|
|
|
75
162
|
`Form` 是一个对象,包含以下成员:
|
|
@@ -16,7 +16,7 @@ const PasswordStrength: React.FC<InputProps> = (props) => {
|
|
|
16
16
|
const [fraction, setFraction] = useState<number>(0);
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
|
|
19
|
+
<div className={styles.passwordStrength}>
|
|
20
20
|
<Input.Password
|
|
21
21
|
{...inputConfig}
|
|
22
22
|
placeholder={placeholder ?? "请输入"}
|
|
@@ -38,7 +38,7 @@ const PasswordStrength: React.FC<InputProps> = (props) => {
|
|
|
38
38
|
value={fraction}
|
|
39
39
|
className={styles.strengthBar}
|
|
40
40
|
/>
|
|
41
|
-
|
|
41
|
+
</div>
|
|
42
42
|
);
|
|
43
43
|
};
|
|
44
44
|
|