@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.slider {
|
|
2
|
+
width: 100%;
|
|
2
3
|
height: 32px;
|
|
3
4
|
margin: 0px;
|
|
4
5
|
padding-block: 0px;
|
|
@@ -6,14 +7,14 @@
|
|
|
6
7
|
overflow-x: hidden;
|
|
7
8
|
overflow-y: visible;
|
|
8
9
|
|
|
9
|
-
.ant-slider-step,
|
|
10
|
-
.ant-slider-track,
|
|
11
|
-
.ant-slider-rail {
|
|
10
|
+
:global(.ant-slider-step),
|
|
11
|
+
:global(.ant-slider-track),
|
|
12
|
+
:global(.ant-slider-rail) {
|
|
12
13
|
top: 0px;
|
|
13
14
|
height: 100% !important;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
.ant-slider-handle {
|
|
17
|
+
:global(.ant-slider-handle) {
|
|
17
18
|
position: relative;
|
|
18
19
|
top: 50%;
|
|
19
20
|
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`,则优先使用传入值。
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SwitchProps as AntSwitchProps, Switch as AntSwitch } from "antd";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { SelectOption } from "../Select";
|
|
4
|
+
import styles from "./index.module.less";
|
|
4
5
|
|
|
5
6
|
export interface SwitchProps extends AntSwitchProps {
|
|
6
7
|
options?: SelectOption[];
|
|
@@ -19,17 +20,19 @@ const Switch: React.FC<SwitchProps> = (props) => {
|
|
|
19
20
|
} = props;
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
checkedChildren
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
unCheckedChildren
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
<span className={styles.SwitchWrapper}>
|
|
24
|
+
<AntSwitch
|
|
25
|
+
{...rest}
|
|
26
|
+
checkedChildren={
|
|
27
|
+
checkedChildren ||
|
|
28
|
+
options?.find((item) => item.value === trueValue)?.label
|
|
29
|
+
}
|
|
30
|
+
unCheckedChildren={
|
|
31
|
+
unCheckedChildren ||
|
|
32
|
+
options?.find((item) => item.value === falseValue)?.label
|
|
33
|
+
}
|
|
34
|
+
/>
|
|
35
|
+
</span>
|
|
33
36
|
);
|
|
34
37
|
};
|
|
35
38
|
|
|
@@ -8,10 +8,79 @@ 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 <TabBar tabGroup={tabGroup} tab={tab} onTabChange={setTab} />;
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 描边样式
|
|
41
|
+
|
|
42
|
+
`variant="outline"` 渲染为描边胶囊样式。
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import React, { useState } from "react";
|
|
46
|
+
import { TabBar } from "@hsu-react/ui";
|
|
47
|
+
|
|
48
|
+
export default () => {
|
|
49
|
+
const [tab, setTab] = useState<string | number>("1");
|
|
50
|
+
|
|
51
|
+
const tabGroup = [
|
|
52
|
+
{ title: "全部", key: "1" },
|
|
53
|
+
{ title: "进行中", key: "2" },
|
|
54
|
+
{ title: "已完成", key: "3" },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<TabBar
|
|
59
|
+
variant="outline"
|
|
60
|
+
tabGroup={tabGroup}
|
|
61
|
+
tab={tab}
|
|
62
|
+
onTabChange={setTab}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
71
|
+
| --- | --- | --- | --- |
|
|
72
|
+
| tabGroup | 页签数据 | `TabGroup[]` | - |
|
|
73
|
+
| tab | 受控选中项的 key | `string \| number` | - |
|
|
74
|
+
| defaultTab | 默认选中项的 key(非受控) | `string \| number` | - |
|
|
75
|
+
| onTabChange | 切换页签时触发 | `(key: string \| number) => void` | - |
|
|
76
|
+
| variant | 样式风格 | `'default' \| 'outline'` | `'default'` |
|
|
77
|
+
| router | 是否在切换时按 key 进行路由跳转 | `boolean` | - |
|
|
78
|
+
| className | 自定义类名 | `string` | - |
|
|
79
|
+
|
|
80
|
+
`TabGroup` 结构:
|
|
81
|
+
|
|
82
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
83
|
+
| --- | --- | --- | --- |
|
|
84
|
+
| title | 页签标题 | `string` | - |
|
|
85
|
+
| key | 页签唯一标识 | `string \| number` | - |
|
|
86
|
+
| 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
|
}
|
|
@@ -8,10 +8,69 @@ title: Table 表格
|
|
|
8
8
|
|
|
9
9
|
# Table 表格
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
在 antd `Table` 之上封装,扩展了自定义列(权限、排序、省略 Tooltip)、内置分页、自动高度、行拖拽、自动滚动等能力。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Table } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 表格
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Table } from "@hsu-react/ui";
|
|
24
|
+
|
|
25
|
+
const columns = [
|
|
26
|
+
{ title: "姓名", dataIndex: "name", width: 120 },
|
|
27
|
+
{ title: "年龄", dataIndex: "age", width: 80 },
|
|
28
|
+
{ title: "住址", dataIndex: "address" },
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const dataSource = [
|
|
32
|
+
{ key: "1", name: "张三", age: 32, address: "西湖区湖底公园 1 号" },
|
|
33
|
+
{ key: "2", name: "李四", age: 28, address: "滨江区江南大道 100 号" },
|
|
34
|
+
{ key: "3", name: "王五", age: 45, address: "余杭区文一西路 998 号" },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export default () => (
|
|
38
|
+
<Table columns={columns} dataSource={dataSource} pagination={false} />
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
在 [antd TableProps](https://ant.design/components/table-cn) 基础上扩展(`scroll`、`pagination`、`columns` 被重写),常用新增/重写属性如下:
|
|
45
|
+
|
|
46
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| columns | 列配置,使用自定义 `ColumnsType`(支持 `hidden`、`sort`、`hasPermi`、`help`、`mergeRow`、`fixedWidth`、`ellipsisPosition` 等) | `ColumnsType<RecordType>` | `[]` |
|
|
49
|
+
| scroll | 是否开启滚动;`{ y: false }` 可关闭纵向滚动 | `boolean \| { y: boolean }` | `false` |
|
|
50
|
+
| pagination | 分页配置;为 `false` 时不展示分页 | `false \| PaginationProps` | `{}` |
|
|
51
|
+
| autoWidth | 列宽自适应 | `boolean` | - |
|
|
52
|
+
| scrollAutoHeight | 自动计算并撑满可用高度 | `boolean` | `true` |
|
|
53
|
+
| hideScrollbar | 隐藏表头滚动条 | `boolean` | `true` |
|
|
54
|
+
| thPadding | 表头单元格内边距 | `string` | - |
|
|
55
|
+
| tdPadding | 表体单元格内边距 | `string` | - |
|
|
56
|
+
| expandedCellPadding | 展开行单元格内边距 | `string` | `tdPadding` |
|
|
57
|
+
| fillPanel | 撑满父级 Panel 高度 | `boolean` | - |
|
|
58
|
+
| staticDataSource | 使用静态数据源(前端分页) | `boolean` | `false` |
|
|
59
|
+
| serialNumberColumn | 是否展示序号列 | `boolean` | `false` |
|
|
60
|
+
| hideEmpty | 隐藏空数据占位 | `boolean` | `false` |
|
|
61
|
+
| ellipsisTooltipConfig | 文本省略 Tooltip 配置 | `EllipsisTooltipConfig` | - |
|
|
62
|
+
| onDragEnd | 行拖拽结束回调(开启后启用拖拽排序) | `DragProps["onDragEnd"]` | - |
|
|
63
|
+
| autoScrolling | 是否开启内容自动滚动 | `boolean` | - |
|
|
64
|
+
| autoScrollMode | 自动滚动模式 | `'smooth' \| 'row'` | - |
|
|
65
|
+
| autoScrollingSpeed | smooth 模式滚动速度(px/s) | `number` | `25` |
|
|
66
|
+
| autoScrollLoop | 滚动到末尾后是否循环 | `boolean` | `true` |
|
|
67
|
+
| autoScrollLoopMode | 循环模式 | `'reset' \| 'seamless'` | `'reset'` |
|
|
68
|
+
| onScrollEnd | 滚动到底部回调 | `() => void` | - |
|
|
69
|
+
| onAutoScrollEndAdd | 自动滚动到底部时追加数据 | `() => Promise<boolean>` | - |
|
|
70
|
+
| order | 当前排序 | `{ k: string; t: 'asc' \| 'desc' }` | - |
|
|
71
|
+
| onOrderChange | 排序变化回调 | `(order?) => void` | - |
|
|
72
|
+
| sorter | 是否启用排序 | `boolean` | - |
|
|
73
|
+
| showTotal | 自定义分页总数展示;为 `false` 时不展示 | `false \| ((total, range) => ReactNode)` | - |
|
|
74
|
+
| isExpandedCellTable | 是否为展开行内嵌表格样式 | `boolean` | `false` |
|
|
75
|
+
|
|
76
|
+
> 另导出 `TableDrag`,用于行拖拽排序场景。
|