@hsu-react/ui 0.0.1 → 0.0.2
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/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 +1 -1
- package/es/components/Form/DrawerForm/index.module.less +2 -2
- 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/Search/index.module.less +5 -5
- package/es/components/Input/TextArea/index.module.less +5 -5
- package/es/components/Input/index.module.less +4 -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/index.module.less +34 -34
- package/es/components/Slider/index.module.less +4 -4
- package/es/components/Spreadsheet/index.module.less +4 -4
- 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/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 +1 -1
- package/lib/components/Form/DrawerForm/index.module.less +2 -2
- 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/Search/index.module.less +5 -5
- package/lib/components/Input/TextArea/index.module.less +5 -5
- package/lib/components/Input/index.module.less +4 -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/index.module.less +34 -34
- package/lib/components/Slider/index.module.less +4 -4
- package/lib/components/Spreadsheet/index.module.less +4 -4
- 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 +2 -3
- package/src/components/ChainGraph/index.md +66 -1
- package/src/components/ChainGraph/index.module.less +1 -1
- package/src/components/Chart/index.md +78 -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 +97 -1
- package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
- package/src/components/Checkbox/index.md +53 -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/DatePicker/RangePicker/index.module.less +1 -1
- package/src/components/DatePicker/StepPicker/index.module.less +1 -1
- package/src/components/DatePicker/index.md +43 -1
- package/src/components/DatePicker/index.module.less +1 -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 +92 -1
- 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 +459 -1
- package/src/components/Icon/index.md +21 -3
- 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/Search/index.module.less +5 -5
- package/src/components/Input/TextArea/index.module.less +5 -5
- package/src/components/Input/index.md +35 -1
- package/src/components/Input/index.module.less +4 -4
- package/src/components/Markdown/index.md +71 -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 +146 -1
- package/src/components/Search/index.md +73 -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/index.md +47 -1
- package/src/components/Select/index.module.less +34 -34
- package/src/components/Slider/index.md +29 -1
- package/src/components/Slider/index.module.less +4 -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/TabBar/index.md +53 -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,56 @@ title: Select 选择器
|
|
|
8
8
|
|
|
9
9
|
# Select 选择器
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 antd `Select` 封装的选择器,默认开启搜索与清除,支持前后缀、箭头动画、下拉宽度自适应内容、`label` 与 `value` 组合展示,并对中文输入法搜索做了优化。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Select } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Select } from "@hsu-react/ui";
|
|
24
|
+
|
|
25
|
+
const options = [
|
|
26
|
+
{ label: "苹果", value: "apple" },
|
|
27
|
+
{ label: "香蕉", value: "banana" },
|
|
28
|
+
{ label: "橙子", value: "orange" },
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export default () => {
|
|
32
|
+
const [value, setValue] = React.useState("apple");
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Select
|
|
36
|
+
style={{ width: 200 }}
|
|
37
|
+
options={options}
|
|
38
|
+
value={value}
|
|
39
|
+
onChange={setValue}
|
|
40
|
+
placeholder="请选择"
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
在 [antd SelectProps](https://ant.design/components/select-cn) 基础上扩展(移除了 `placement`、`filterOption` 并重新定义):
|
|
49
|
+
|
|
50
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| options | 选项数据 | `SelectOption[]` | `[]` |
|
|
53
|
+
| prefix | 选择框前缀内容 | `ReactNode` | - |
|
|
54
|
+
| suffix | 选择框后缀内容 | `ReactNode` | - |
|
|
55
|
+
| selectClassName | 内层 antd Select 的类名 | `string` | - |
|
|
56
|
+
| arrowAnimation | 是否启用箭头展开动画 | `boolean` | `true` |
|
|
57
|
+
| popupMatchContentWidth | 下拉面板宽度是否自适应内容 | `boolean` | - |
|
|
58
|
+
| placement | 下拉弹出位置 | `'bottomLeft' \| 'topLeft'` | `'bottomLeft'` |
|
|
59
|
+
| filterOption | 自定义搜索过滤 | `(searchValue: string, option?: DefaultOptionType) => boolean` | - |
|
|
60
|
+
| optionFontSize | 选项字体大小,用于计算自适应宽度 | `number` | `14` |
|
|
61
|
+
| valueInlabel | 在标签/选项中同时展示 value 的位置 | `'before' \| 'after'` | - |
|
|
62
|
+
|
|
63
|
+
> `SelectOption` 形如 `{ label: string; value: number \| string; disabled?: boolean }`,并可携带额外字段。
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
.antdSelect {
|
|
31
31
|
cursor: not-allowed;
|
|
32
32
|
|
|
33
|
-
.ant-select-selection-item {
|
|
33
|
+
:global(.ant-select-selection-item) {
|
|
34
34
|
color: var(--cf-text-3);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
.ant-select-arrow {
|
|
37
|
+
:global(.ant-select-arrow) {
|
|
38
38
|
cursor: not-allowed;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
margin-inline-start: 4px;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
&:has(> .ant-select-status-error) {
|
|
80
|
+
&:has(> :global(.ant-select-status-error)) {
|
|
81
81
|
border: 1px solid #ff4d4f;
|
|
82
82
|
|
|
83
83
|
.prefix,
|
|
@@ -113,20 +113,20 @@
|
|
|
113
113
|
font-weight: inherit;
|
|
114
114
|
color: inherit !important;
|
|
115
115
|
|
|
116
|
-
&:has(> .ant-select-arrow),
|
|
117
|
-
&:has(> .ant-select-clear) {
|
|
118
|
-
.ant-select-selector {
|
|
116
|
+
&:has(> :global(.ant-select-arrow)),
|
|
117
|
+
&:has(> :global(.ant-select-clear)) {
|
|
118
|
+
:global(.ant-select-selector) {
|
|
119
119
|
padding-right: 20px;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
&.legacyHasArrowOrClear {
|
|
124
|
-
.ant-select-selector {
|
|
124
|
+
:global(.ant-select-selector) {
|
|
125
125
|
padding-right: 20px;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
.ant-select-selector {
|
|
129
|
+
:global(.ant-select-selector) {
|
|
130
130
|
width: 100%;
|
|
131
131
|
height: 100%;
|
|
132
132
|
padding: 0;
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
content: none;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
.ant-select-selection-wrap {
|
|
148
|
+
:global(.ant-select-selection-wrap) {
|
|
149
149
|
height: 100%;
|
|
150
150
|
|
|
151
151
|
font-family: inherit;
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
color: inherit;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
.ant-select-selection-search {
|
|
157
|
+
:global(.ant-select-selection-search) {
|
|
158
158
|
inset-inline-start: 0px;
|
|
159
159
|
inset-inline-end: 0px;
|
|
160
160
|
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
.ant-select-selection-placeholder {
|
|
176
|
+
:global(.ant-select-selection-placeholder) {
|
|
177
177
|
display: inline-flex;
|
|
178
178
|
align-items: center;
|
|
179
179
|
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
font-weight: inherit;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
.ant-select-selection-item {
|
|
188
|
+
:global(.ant-select-selection-item) {
|
|
189
189
|
padding-inline-end: 0px;
|
|
190
190
|
|
|
191
191
|
font-family: inherit;
|
|
@@ -194,8 +194,8 @@
|
|
|
194
194
|
color: inherit;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
.ant-select-selection-overflow-item {
|
|
198
|
-
.ant-select-selection-item {
|
|
197
|
+
:global(.ant-select-selection-overflow-item) {
|
|
198
|
+
:global(.ant-select-selection-item) {
|
|
199
199
|
line-height: normal;
|
|
200
200
|
|
|
201
201
|
padding-inline-end: 4px;
|
|
@@ -203,34 +203,34 @@
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
.ant-select-selector {
|
|
206
|
+
&:global(.ant-select-focused) {
|
|
207
|
+
:global(.ant-select-selector) {
|
|
208
208
|
border: none !important;
|
|
209
209
|
|
|
210
210
|
box-shadow: none !important;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
.ant-select-arrow {
|
|
214
|
+
&:global(.ant-select-open) {
|
|
215
|
+
:global(.ant-select-arrow) {
|
|
216
216
|
transform: rotate(-180deg) translateY(50%);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
&.noArrowAnimation {
|
|
220
|
-
.ant-select-arrow {
|
|
220
|
+
:global(.ant-select-arrow) {
|
|
221
221
|
transform: translateY(-50%);
|
|
222
222
|
transition: none !important;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
.ant-select-selector {
|
|
227
|
+
&:global(.ant-select-status-error) {
|
|
228
|
+
:global(.ant-select-selector) {
|
|
229
229
|
border: none !important;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
.ant-select-arrow {
|
|
233
|
+
:global(.ant-select-arrow) {
|
|
234
234
|
width: 14px;
|
|
235
235
|
height: 14px;
|
|
236
236
|
margin-top: 0px;
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
pointer-events: all;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
.ant-select-clear {
|
|
247
|
+
:global(.ant-select-clear) {
|
|
248
248
|
width: 14px;
|
|
249
249
|
height: 14px;
|
|
250
250
|
margin-top: 0px;
|
|
@@ -256,17 +256,17 @@
|
|
|
256
256
|
inset-inline-end: 0px;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
|
|
260
|
-
> .ant-select-selector {
|
|
261
|
-
> .ant-select-selection-overflow {
|
|
262
|
-
.ant-select-selection-search {
|
|
259
|
+
&:global(.ant-select-multiple) {
|
|
260
|
+
> :global(.ant-select-selector) {
|
|
261
|
+
> :global(.ant-select-selection-overflow) {
|
|
262
|
+
:global(.ant-select-selection-search) {
|
|
263
263
|
width: 0px !important;
|
|
264
264
|
|
|
265
265
|
margin-inline-start: 0px;
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
> .ant-select-selection-placeholder {
|
|
269
|
+
> :global(.ant-select-selection-placeholder) {
|
|
270
270
|
inset-inline-start: 0px;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
@@ -274,14 +274,14 @@
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
&.popupMatchContentWidth {
|
|
277
|
-
.ant-select-dropdown {
|
|
277
|
+
:global(.ant-select-dropdown) {
|
|
278
278
|
[class="rc-virtual-list-holder-inner"] {
|
|
279
279
|
position: relative !important;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
.ant-select-dropdown {
|
|
284
|
+
:global(.ant-select-dropdown) {
|
|
285
285
|
position: fixed;
|
|
286
286
|
|
|
287
287
|
font-family: inherit;
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
|
|
292
292
|
border-radius: inherit;
|
|
293
293
|
|
|
294
|
-
.ant-select-item {
|
|
294
|
+
:global(.ant-select-item) {
|
|
295
295
|
font-family: inherit;
|
|
296
296
|
font-size: inherit;
|
|
297
297
|
font-weight: inherit;
|
|
@@ -300,9 +300,9 @@
|
|
|
300
300
|
border-radius: inherit;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
.ant-select-item-empty,
|
|
304
|
-
.ant-empty,
|
|
305
|
-
.ant-empty-description {
|
|
303
|
+
:global(.ant-select-item-empty),
|
|
304
|
+
:global(.ant-empty),
|
|
305
|
+
:global(.ant-empty-description) {
|
|
306
306
|
font-family: inherit;
|
|
307
307
|
font-size: inherit;
|
|
308
308
|
font-weight: inherit;
|
|
@@ -8,10 +8,38 @@ title: Slider 滑动输入
|
|
|
8
8
|
|
|
9
9
|
# Slider 滑动输入
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 antd 单值 `Slider` 封装的滑动输入条,内部维护受控值、默认关闭 Tooltip,并支持通过 `topValue` 从外部强制更新当前值。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Slider } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Slider } from "@hsu-react/ui";
|
|
24
|
+
|
|
25
|
+
export default () => {
|
|
26
|
+
const [value, setValue] = React.useState(30);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ width: 240 }}>
|
|
30
|
+
<Slider value={value} onChange={setValue} />
|
|
31
|
+
<div style={{ marginTop: 12 }}>当前值:{value}</div>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
在 [antd SliderSingleProps](https://ant.design/components/slider-cn) 基础上扩展:
|
|
40
|
+
|
|
41
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
42
|
+
| --- | --- | --- | --- |
|
|
43
|
+
| topValue | 外部强制同步的当前值,优先级高于 `value` | `number` | - |
|
|
44
|
+
| value | 当前值 | `number` | `0` |
|
|
45
|
+
| onChange | 值变化回调 | `(value: number) => void` | - |
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
overflow-x: hidden;
|
|
7
7
|
overflow-y: visible;
|
|
8
8
|
|
|
9
|
-
.ant-slider-step,
|
|
10
|
-
.ant-slider-track,
|
|
11
|
-
.ant-slider-rail {
|
|
9
|
+
:global(.ant-slider-step),
|
|
10
|
+
:global(.ant-slider-track),
|
|
11
|
+
:global(.ant-slider-rail) {
|
|
12
12
|
top: 0px;
|
|
13
13
|
height: 100% !important;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.ant-slider-handle {
|
|
16
|
+
:global(.ant-slider-handle) {
|
|
17
17
|
position: relative;
|
|
18
18
|
top: 50%;
|
|
19
19
|
transform: translate(calc(-50% - 4px), calc(-50% + 1px)) !important;
|
|
@@ -8,10 +8,51 @@ title: Spreadsheet 电子表格
|
|
|
8
8
|
|
|
9
9
|
# Spreadsheet 电子表格
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 `x-data-spreadsheet` 封装的电子表格组件,接收 `xlsx` 的 `WorkBook` 数据并自动转换为表格内容渲染。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Spreadsheet } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Spreadsheet } from "@hsu-react/ui";
|
|
24
|
+
import { utils } from "xlsx";
|
|
25
|
+
|
|
26
|
+
// 用 xlsx 工具构建一个 WorkBook(实际项目中通常由 read() 读取文件得到)
|
|
27
|
+
const aoa = [
|
|
28
|
+
["姓名", "部门", "工资"],
|
|
29
|
+
["张三", "研发部", 12000],
|
|
30
|
+
["李四", "市场部", 9500],
|
|
31
|
+
["王五", "财务部", 8800],
|
|
32
|
+
];
|
|
33
|
+
const ws = utils.aoa_to_sheet(aoa);
|
|
34
|
+
const workbook = utils.book_new();
|
|
35
|
+
utils.book_append_sheet(workbook, ws, "员工表");
|
|
36
|
+
|
|
37
|
+
export default () => (
|
|
38
|
+
<div style={{ height: 320, width: "100%" }}>
|
|
39
|
+
<Spreadsheet data={workbook} xOptions={{ showBottomTool: true }} />
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| data | 表格数据,xlsx 的 `WorkBook` 对象 | `WorkBook` | - |
|
|
49
|
+
| xOptions | x-data-spreadsheet 配置项(在其 `Options` 基础上扩展,已忽略 `view`) | `XOptions` | `{}` |
|
|
50
|
+
| className | 容器类名 | `string` | - |
|
|
51
|
+
|
|
52
|
+
### XOptions
|
|
53
|
+
|
|
54
|
+
继承 x-data-spreadsheet 的 `Options`(`view` 由组件内部接管),并扩展:
|
|
55
|
+
|
|
56
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
57
|
+
| --- | --- | --- | --- |
|
|
58
|
+
| showBottomTool | 是否显示底部工具栏(sheet 切换栏) | `boolean` | `true` |
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
overflow: hidden;
|
|
6
6
|
|
|
7
|
-
.x-spreadsheet-toolbar,
|
|
8
|
-
.x-spreadsheet-bottombar {
|
|
7
|
+
:global(.x-spreadsheet-toolbar),
|
|
8
|
+
:global(.x-spreadsheet-bottombar) {
|
|
9
9
|
width: 100% !important;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
background-size: auto;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.x-spreadsheet-menu {
|
|
16
|
+
:global(.x-spreadsheet-menu) {
|
|
17
17
|
> li:first-child {
|
|
18
18
|
display: none;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
&.showBottomTool {
|
|
23
|
-
.x-spreadsheet-menu {
|
|
23
|
+
:global(.x-spreadsheet-menu) {
|
|
24
24
|
> li:first-child {
|
|
25
25
|
display: list-item;
|
|
26
26
|
}
|
|
@@ -8,10 +8,42 @@ title: Switch 开关
|
|
|
8
8
|
|
|
9
9
|
# Switch 开关
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 antd `Switch` 封装的开关,可通过 `options` 配合 `trueValue`/`falseValue` 自动生成开启与关闭状态的文案。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Switch } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Switch } from "@hsu-react/ui";
|
|
24
|
+
|
|
25
|
+
const options = [
|
|
26
|
+
{ label: "启用", value: 1 },
|
|
27
|
+
{ label: "停用", value: 0 },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export default () => (
|
|
31
|
+
<div style={{ display: "flex", gap: 16, alignItems: "center" }}>
|
|
32
|
+
<Switch defaultChecked />
|
|
33
|
+
<Switch options={options} trueValue={1} falseValue={0} defaultChecked />
|
|
34
|
+
<Switch disabled />
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
在 [antd SwitchProps](https://ant.design/components/switch-cn) 基础上扩展:
|
|
42
|
+
|
|
43
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
44
|
+
| --- | --- | --- | --- |
|
|
45
|
+
| options | 选项数据,用于匹配选中/未选中文案 | `SelectOption[]` | - |
|
|
46
|
+
| trueValue | 开启状态对应的 value,从 `options` 中取其 `label` 作为 `checkedChildren` | `number \| string` | - |
|
|
47
|
+
| falseValue | 关闭状态对应的 value,从 `options` 中取其 `label` 作为 `unCheckedChildren` | `number \| string` | - |
|
|
48
|
+
|
|
49
|
+
> 若直接传入 `checkedChildren` / `unCheckedChildren`,则优先使用传入值。
|
|
@@ -8,10 +8,62 @@ title: TabBar 标签栏
|
|
|
8
8
|
|
|
9
9
|
# TabBar 标签栏
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
轻量级标签切换栏,支持受控/非受控、`default` 与 `outline` 两种样式,并可结合路由实现页签跳转。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { TabBar } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
通过 `tabGroup` 配置页签,`onTabChange` 监听切换。
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import React, { useState } from "react";
|
|
25
|
+
import { TabBar } from "@hsu-react/ui";
|
|
26
|
+
|
|
27
|
+
export default () => {
|
|
28
|
+
const [tab, setTab] = useState<string | number>("1");
|
|
29
|
+
|
|
30
|
+
const tabGroup = [
|
|
31
|
+
{ title: "全部", key: "1" },
|
|
32
|
+
{ title: "进行中", key: "2" },
|
|
33
|
+
{ title: "已完成", key: "3" },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div>
|
|
38
|
+
<TabBar tabGroup={tabGroup} tab={tab} onTabChange={setTab} />
|
|
39
|
+
<TabBar
|
|
40
|
+
variant="outline"
|
|
41
|
+
tabGroup={tabGroup}
|
|
42
|
+
defaultTab="1"
|
|
43
|
+
className="demo-tabbar-outline"
|
|
44
|
+
/>
|
|
45
|
+
<p style={{ marginTop: 12 }}>当前选中:{tab}</p>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
54
|
+
| --- | --- | --- | --- |
|
|
55
|
+
| tabGroup | 页签数据 | `TabGroup[]` | - |
|
|
56
|
+
| tab | 受控选中项的 key | `string \| number` | - |
|
|
57
|
+
| defaultTab | 默认选中项的 key(非受控) | `string \| number` | - |
|
|
58
|
+
| onTabChange | 切换页签时触发 | `(key: string \| number) => void` | - |
|
|
59
|
+
| variant | 样式风格 | `'default' \| 'outline'` | `'default'` |
|
|
60
|
+
| router | 是否在切换时按 key 进行路由跳转 | `boolean` | - |
|
|
61
|
+
| className | 自定义类名 | `string` | - |
|
|
62
|
+
|
|
63
|
+
`TabGroup` 结构:
|
|
64
|
+
|
|
65
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
66
|
+
| --- | --- | --- | --- |
|
|
67
|
+
| title | 页签标题 | `string` | - |
|
|
68
|
+
| key | 页签唯一标识 | `string \| number` | - |
|
|
69
|
+
| onClick | 点击该页签时的回调 | `() => void` | - |
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
justify-content: flex-end;
|
|
5
5
|
column-gap: 8px;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
&:global(.ant-pagination-start) {
|
|
8
8
|
justify-content: flex-start;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
&:global(.ant-pagination-center) {
|
|
12
12
|
justify-content: center;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
width: 100%;
|
|
26
26
|
height: 100%;
|
|
27
27
|
|
|
28
|
-
.ant-pagination-item-container {
|
|
28
|
+
:global(.ant-pagination-item-container) {
|
|
29
29
|
width: 100%;
|
|
30
30
|
|
|
31
|
-
.ant-pagination-item-ellipsis {
|
|
31
|
+
:global(.ant-pagination-item-ellipsis) {
|
|
32
32
|
width: 100%;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
justify-content: center;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
.ant-pagination-options-size-changer,
|
|
45
|
-
.ant-pagination-options-quick-jumper {
|
|
43
|
+
&:global(.ant-pagination-options) {
|
|
44
|
+
:global(.ant-pagination-options-size-changer),
|
|
45
|
+
:global(.ant-pagination-options-quick-jumper) {
|
|
46
46
|
height: 100% !important;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.ant-pagination-options-size-changer {
|
|
50
|
-
.ant-select-selector {
|
|
49
|
+
:global(.ant-pagination-options-size-changer) {
|
|
50
|
+
:global(.ant-select-selector) {
|
|
51
51
|
height: 100% !important;
|
|
52
52
|
|
|
53
|
-
.ant-select-selection-item {
|
|
53
|
+
:global(.ant-select-selection-item) {
|
|
54
54
|
display: flex;
|
|
55
55
|
align-items: center;
|
|
56
56
|
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.ant-select-arrow {
|
|
61
|
+
:global(.ant-select-arrow) {
|
|
62
62
|
margin-top: 0px;
|
|
63
63
|
|
|
64
64
|
transform: translateY(-50%);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.ant-pagination-options-quick-jumper {
|
|
68
|
+
:global(.ant-pagination-options-quick-jumper) {
|
|
69
69
|
display: inline-flex;
|
|
70
70
|
align-items: center;
|
|
71
71
|
|
|
@@ -78,18 +78,18 @@
|
|
|
78
78
|
|
|
79
79
|
&.bordered {
|
|
80
80
|
> li {
|
|
81
|
-
&:not(.ant-pagination-options):not(.ant-pagination-total-text) {
|
|
81
|
+
&:not(:global(.ant-pagination-options)):not(:global(.ant-pagination-total-text)) {
|
|
82
82
|
border: 1px solid var(--cf-border);
|
|
83
83
|
border-radius: 4px;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
&:global(.ant-pagination-item) {
|
|
87
87
|
margin: 0px 4px 0px 0px;
|
|
88
88
|
|
|
89
|
-
&:not(.ant-pagination-item-active):not(
|
|
90
|
-
.ant-pagination-item-disabled
|
|
89
|
+
&:not(:global(.ant-pagination-item-active)):not(
|
|
90
|
+
:global(.ant-pagination-item-disabled)
|
|
91
91
|
):hover,
|
|
92
|
-
|
|
92
|
+
&:global(.ant-pagination-item-active) {
|
|
93
93
|
background-color: var(--primary-color, #1890ff);
|
|
94
94
|
border-color: var(--primary-color, #1890ff);
|
|
95
95
|
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
&:not(.ant-pagination-item-active):not(.ant-pagination-item-disabled) {
|
|
101
|
+
&:not(:global(.ant-pagination-item-active)):not(:global(.ant-pagination-item-disabled)) {
|
|
102
102
|
border-color: var(--cf-border);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
&:not(.ant-pagination-item-active).ant-pagination-item-disabled {
|
|
105
|
+
&:not(:global(.ant-pagination-item-active)):global(.ant-pagination-item-disabled) {
|
|
106
106
|
cursor: not-allowed;
|
|
107
107
|
|
|
108
108
|
&:hover {
|
|
@@ -117,16 +117,16 @@
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
&:global(.ant-pagination-prev) {
|
|
121
121
|
margin-right: 4px;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
&:global(.ant-pagination-options) {
|
|
125
125
|
margin-left: 4px;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
&:global(.ant-pagination-jump-next),
|
|
129
|
+
&:global(.ant-pagination-jump-prev) {
|
|
130
130
|
margin-right: 4px;
|
|
131
131
|
}
|
|
132
132
|
}
|