@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
|
@@ -18,18 +18,36 @@ import { Icon } from "@hsu-react/ui";
|
|
|
18
18
|
|
|
19
19
|
## 基础用法
|
|
20
20
|
|
|
21
|
+
antd 图标名(驼峰):
|
|
22
|
+
|
|
21
23
|
```tsx
|
|
22
24
|
import React from "react";
|
|
23
25
|
import { Icon } from "@hsu-react/ui";
|
|
24
|
-
import { Space } from "antd";
|
|
25
26
|
|
|
26
27
|
export default () => (
|
|
27
|
-
<
|
|
28
|
+
<div style={{ display: "flex", gap: 20, alignItems: "center", fontSize: 22 }}>
|
|
28
29
|
<Icon icon="UserOutlined" />
|
|
29
30
|
<Icon icon="SettingOutlined" />
|
|
30
31
|
<Icon icon="HomeOutlined" />
|
|
31
32
|
<Icon icon="HeartFilled" style={{ color: "#eb2f96" }} />
|
|
32
|
-
</
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
iconify 图标名(`集合:名称`,需先注册对应图标集):
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import React from "react";
|
|
41
|
+
import { Icon } from "@hsu-react/ui";
|
|
42
|
+
|
|
43
|
+
export default () => (
|
|
44
|
+
<div style={{ display: "flex", gap: 20, alignItems: "center", fontSize: 22 }}>
|
|
45
|
+
<Icon icon="ph:user-bold" />
|
|
46
|
+
<Icon icon="mdi:home" />
|
|
47
|
+
<Icon icon="tabler:settings" />
|
|
48
|
+
<Icon icon="solar:heart-bold" style={{ color: "#eb2f96" }} />
|
|
49
|
+
<Icon icon="carbon:document" />
|
|
50
|
+
</div>
|
|
33
51
|
);
|
|
34
52
|
```
|
|
35
53
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
IconProps as IconifyProps,
|
|
5
5
|
} from "@iconify/react";
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import * as AntdIcons from "@ant-design/icons";
|
|
8
8
|
import React, { useEffect, useRef } from "react";
|
|
9
9
|
import classNames from "classnames";
|
|
10
10
|
import styles from "./index.module.less";
|
|
@@ -74,46 +74,18 @@ const Icon: React.FC<IconProps> = (props) => {
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// iconify 图标:直接用 span 承载 Iconify 自带的 svg,避免把它嵌套进 antd Icon
|
|
78
|
+
// 的 svg(其 viewBox 会把内层 svg 缩放成极小值导致图标不可见)。
|
|
77
79
|
return (
|
|
78
|
-
<
|
|
80
|
+
<span
|
|
79
81
|
{...iconConfig}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
className={classNames([styles.icon, className])}
|
|
82
|
+
role="img"
|
|
83
|
+
ref={ref as unknown as React.Ref<HTMLSpanElement>}
|
|
84
|
+
className={classNames(["anticon", styles.icon, className])}
|
|
83
85
|
style={mergedStyle}
|
|
84
|
-
ref={ref}
|
|
85
86
|
>
|
|
86
|
-
<Iconify
|
|
87
|
-
|
|
88
|
-
icon={icon}
|
|
89
|
-
width="1em"
|
|
90
|
-
height="1em"
|
|
91
|
-
onLoad={() => {
|
|
92
|
-
setTimeout(() => {
|
|
93
|
-
if (ref.current) {
|
|
94
|
-
const svg = ref.current.childNodes[0] as SVGSVGElement;
|
|
95
|
-
const svg_i = svg.childNodes[0] as SVGSVGElement;
|
|
96
|
-
|
|
97
|
-
const { height } = svg.getBoundingClientRect();
|
|
98
|
-
const { height: height_i } = svg_i.getBoundingClientRect();
|
|
99
|
-
|
|
100
|
-
const viewBox_i = svg_i.getAttribute("viewBox");
|
|
101
|
-
const viewBox_i_height = viewBox_i?.split(" ")[3];
|
|
102
|
-
|
|
103
|
-
if (Number(viewBox_i_height) <= 24) return;
|
|
104
|
-
|
|
105
|
-
const y_i =
|
|
106
|
-
Number(viewBox_i_height) - (Number(height) - Number(height_i));
|
|
107
|
-
|
|
108
|
-
svg_i.setAttribute(
|
|
109
|
-
"viewBox",
|
|
110
|
-
`0 0 ${viewBox_i?.split(" ")[2]} ${y_i.toFixed(0)}`
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
}, 1);
|
|
114
|
-
}}
|
|
115
|
-
/>
|
|
116
|
-
</AntdIcon>
|
|
87
|
+
<Iconify {...iconProps} icon={icon} width="1em" height="1em" />
|
|
88
|
+
</span>
|
|
117
89
|
);
|
|
118
90
|
};
|
|
119
91
|
|
|
@@ -10,22 +10,22 @@
|
|
|
10
10
|
width: 100%;
|
|
11
11
|
height: 100%;
|
|
12
12
|
|
|
13
|
-
.ant-input-number-wrapper {
|
|
13
|
+
:global(.ant-input-number-wrapper) {
|
|
14
14
|
height: 100%;
|
|
15
15
|
min-height: inherit;
|
|
16
16
|
|
|
17
|
-
> .ant-input-number,
|
|
18
|
-
> .ant-input-number-affix-wrapper {
|
|
17
|
+
> :global(.ant-input-number),
|
|
18
|
+
> :global(.ant-input-number-affix-wrapper) {
|
|
19
19
|
height: 100%;
|
|
20
20
|
min-height: inherit;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
> .ant-input-number {
|
|
24
|
-
> .ant-input-number-input-wrap {
|
|
23
|
+
> :global(.ant-input-number) {
|
|
24
|
+
> :global(.ant-input-number-input-wrap) {
|
|
25
25
|
height: 100%;
|
|
26
26
|
min-height: inherit;
|
|
27
27
|
|
|
28
|
-
> .ant-input-number-input {
|
|
28
|
+
> :global(.ant-input-number-input) {
|
|
29
29
|
height: 100%;
|
|
30
30
|
min-height: inherit;
|
|
31
31
|
}
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
> .ant-input-number-input-wrap {
|
|
36
|
+
> :global(.ant-input-number-input-wrap) {
|
|
37
37
|
height: 100%;
|
|
38
38
|
min-height: inherit;
|
|
39
39
|
|
|
40
|
-
> .ant-input-number-input {
|
|
40
|
+
> :global(.ant-input-number-input) {
|
|
41
41
|
height: 100%;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// 当存在 addonAfter 时,调整清除图标位置
|
|
69
|
-
// Ant Design 的 addonAfter 会生成 .ant-input-number-group-addon
|
|
69
|
+
// Ant Design 的 addonAfter 会生成 :global(.ant-input-number-group-addon)
|
|
70
70
|
// 清除图标需要向左偏移,避免与 addon 重叠
|
|
71
71
|
// 使用 CSS 变量来动态设置 addon 宽度,默认值 60px 是合理的估算
|
|
72
72
|
// 通过 JS 动态计算实际宽度并设置 CSS 变量来覆盖
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
width: 100%;
|
|
3
3
|
height: 100%;
|
|
4
4
|
|
|
5
|
-
.ant-input-wrapper {
|
|
5
|
+
:global(.ant-input-wrapper) {
|
|
6
6
|
height: 100%;
|
|
7
7
|
min-height: inherit;
|
|
8
8
|
|
|
9
|
-
> .ant-input,
|
|
10
|
-
> .ant-input-affix-wrapper {
|
|
9
|
+
> :global(.ant-input),
|
|
10
|
+
> :global(.ant-input-affix-wrapper) {
|
|
11
11
|
height: 100%;
|
|
12
12
|
min-height: inherit;
|
|
13
13
|
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
width: 100%;
|
|
3
3
|
height: 100%;
|
|
4
4
|
|
|
5
|
-
.ant-input-wrapper {
|
|
5
|
+
:global(.ant-input-wrapper) {
|
|
6
6
|
height: 100%;
|
|
7
7
|
min-height: inherit;
|
|
8
8
|
|
|
9
|
-
> .ant-input,
|
|
10
|
-
> .ant-input-affix-wrapper {
|
|
9
|
+
> :global(.ant-input),
|
|
10
|
+
> :global(.ant-input-affix-wrapper) {
|
|
11
11
|
height: 100%;
|
|
12
12
|
min-height: inherit;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
> .ant-input-group-addon {
|
|
16
|
-
> .ant-btn {
|
|
15
|
+
> :global(.ant-input-group-addon) {
|
|
16
|
+
> :global(.ant-btn) {
|
|
17
17
|
height: 100%;
|
|
18
18
|
min-height: inherit;
|
|
19
19
|
}
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
background-color: transparent !important;
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
&:global(.ant-input-textarea-affix-wrapper) {
|
|
65
65
|
position: relative;
|
|
66
66
|
|
|
67
67
|
padding: 0px;
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
font-family: inherit;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
.ant-input-suffix {
|
|
79
|
+
:global(.ant-input-suffix) {
|
|
80
80
|
position: absolute;
|
|
81
81
|
top: 50%;
|
|
82
82
|
right: 10px;
|
|
83
83
|
transform: translateY(-50%);
|
|
84
84
|
|
|
85
|
-
.ant-input-data-count {
|
|
85
|
+
:global(.ant-input-data-count) {
|
|
86
86
|
position: relative;
|
|
87
87
|
bottom: auto;
|
|
88
88
|
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
font-size: 14px;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
.ant-input-clear-icon {
|
|
93
|
+
:global(.ant-input-clear-icon) {
|
|
94
94
|
position: relative;
|
|
95
95
|
|
|
96
96
|
inset-inline-end: 0;
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
|
|
122
122
|
box-shadow: 0 0 0 2px rgba(255, 38, 5, 0.06);
|
|
123
123
|
|
|
124
|
-
.ant-input-status-error {
|
|
124
|
+
:global(.ant-input-status-error) {
|
|
125
125
|
border: none !important;
|
|
126
126
|
|
|
127
127
|
box-shadow: none !important;
|
|
@@ -8,10 +8,44 @@ title: Input 输入框
|
|
|
8
8
|
|
|
9
9
|
# Input 输入框
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
基于 antd `Input` 封装的受控输入框,内置中文输入法合成处理、防抖 `onChange`(返回纯字符串)、自动 `allowClear`、可选 `Tooltip` 及字符转义能力。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Input } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Input } from "@hsu-react/ui";
|
|
24
|
+
|
|
25
|
+
export default () => {
|
|
26
|
+
const [value, setValue] = React.useState("");
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 12, width: 240 }}>
|
|
30
|
+
<Input placeholder="请输入" value={value} onChange={setValue} />
|
|
31
|
+
<Input placeholder="禁用状态" disabled />
|
|
32
|
+
<div>当前值:{value}</div>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
在 [antd InputProps](https://ant.design/components/input-cn) 基础上扩展(并移除了 `onCompositionStart`、`onCompositionEnd`、`ref`,重写了 `onChange`):
|
|
41
|
+
|
|
42
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
43
|
+
| --- | --- | --- | --- |
|
|
44
|
+
| onChange | 值变化回调,经过合成与防抖处理后返回纯字符串 | `(value: string) => void` | - |
|
|
45
|
+
| getRef | 获取内部 antd `InputRef` 的回调 | `(ref: InputRef \| null) => void` | - |
|
|
46
|
+
| en | 是否英文模式,开启后不受 `maxLength` 限制 | `boolean` | `false` |
|
|
47
|
+
| word | 是否为字数/单词相关模式 | `boolean` | - |
|
|
48
|
+
| tooltip | 透传给外层 `Tooltip` 的配置 | `TooltipProps` | - |
|
|
49
|
+
| escapeCharacters | 需要自动转义/去转义的字符列表 | `string[]` | - |
|
|
50
|
+
|
|
51
|
+
> 另提供子组件:`Input.Search`、`Input.TextArea`、`Input.Password`、`Input.Number`(数字输入,`onChange` 返回字符串)、`Input.Range`(范围输入)。
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
width: 100%;
|
|
3
3
|
height: 100%;
|
|
4
4
|
|
|
5
|
-
.ant-input-clear-icon {
|
|
5
|
+
:global(.ant-input-clear-icon) {
|
|
6
6
|
font-size: 14px;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.ant-input-wrapper {
|
|
9
|
+
:global(.ant-input-wrapper) {
|
|
10
10
|
height: 100%;
|
|
11
11
|
min-height: inherit;
|
|
12
12
|
|
|
13
|
-
> .ant-input,
|
|
14
|
-
> .ant-input-affix-wrapper {
|
|
13
|
+
> :global(.ant-input),
|
|
14
|
+
> :global(.ant-input-affix-wrapper) {
|
|
15
15
|
height: 100%;
|
|
16
16
|
min-height: inherit;
|
|
17
17
|
}
|
|
@@ -8,10 +8,80 @@ title: Markdown 渲染
|
|
|
8
8
|
|
|
9
9
|
# Markdown 渲染
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Markdown 渲染与编辑组件,`Markdown.Views` 用于渲染展示(支持 GFM、KaTeX 公式、代码高亮、Mermaid 图与 HTML/SVG Artifacts 预览),`Markdown.Editor` 提供所见即所得编辑器。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Markdown } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
`Markdown.Views` 渲染(依赖 KaTeX / highlight.js / Mermaid 等样式,建议在应用环境内使用):
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import React from "react";
|
|
25
|
+
import { Markdown } from "@hsu-react/ui";
|
|
26
|
+
|
|
27
|
+
const content = `# 标题
|
|
28
|
+
|
|
29
|
+
这是一段包含 **加粗** 文本的说明。
|
|
30
|
+
|
|
31
|
+
- 列表项一
|
|
32
|
+
- 列表项二
|
|
33
|
+
- 列表项三
|
|
34
|
+
|
|
35
|
+
\`\`\`ts
|
|
36
|
+
const a = 1;
|
|
37
|
+
const b = a + 1;
|
|
38
|
+
\`\`\`
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export default () => <Markdown.Views>{content}</Markdown.Views>;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`Markdown.Editor` 编辑:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import React from "react";
|
|
48
|
+
import { Markdown } from "@hsu-react/ui";
|
|
49
|
+
|
|
50
|
+
export default () => {
|
|
51
|
+
const [value, setValue] = React.useState("# Hello\n\n开始编辑 **Markdown** 内容吧。");
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div style={{ height: 240 }}>
|
|
55
|
+
<Markdown.Editor
|
|
56
|
+
value={value}
|
|
57
|
+
onChange={setValue}
|
|
58
|
+
view={{ menu: true, md: true, html: true }}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## API
|
|
66
|
+
|
|
67
|
+
### Markdown.Views
|
|
68
|
+
|
|
69
|
+
继承 [react-markdown Options](https://github.com/remarkjs/react-markdown)(markdown 文本通过 `children` 传入),新增属性:
|
|
70
|
+
|
|
71
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
72
|
+
| --- | --- | --- | --- |
|
|
73
|
+
| children | 待渲染的 markdown 文本 | `string` | - |
|
|
74
|
+
| copyProps | 代码块复制按钮配置 | `Omit<CopyProps, 'id'>` | - |
|
|
75
|
+
| className | 自定义类名 | `string` | - |
|
|
76
|
+
|
|
77
|
+
### Markdown.Editor
|
|
78
|
+
|
|
79
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
80
|
+
| --- | --- | --- | --- |
|
|
81
|
+
| value | 编辑器内容 | `string` | `''` |
|
|
82
|
+
| onChange | 内容变化回调 | `(value: string) => void` | - |
|
|
83
|
+
| buttonGroup | 顶部自定义按钮组 | `ButtonProps[]` | - |
|
|
84
|
+
| className | 自定义类名 | `string` | - |
|
|
85
|
+
| disabled | 是否禁用 | `boolean` | - |
|
|
86
|
+
| readOnly | 是否只读 | `boolean` | - |
|
|
87
|
+
| view | 视图区域配置 | `{ menu?: boolean; md?: boolean; html?: boolean }` | `{ menu: true, md: true, html: true }` |
|
|
@@ -8,10 +8,52 @@ title: Modal 对话框
|
|
|
8
8
|
|
|
9
9
|
# Modal 对话框
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
在 antd `Modal` 之上增强:默认垂直居中、可拖拽移动、边缘检测、一键全屏,并支持在标题区放置按钮组。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Modal } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
通过 `open` 受控显隐,配合 `Button` 切换状态。默认弹窗可按住标题栏拖动。
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import React, { useState } from "react";
|
|
25
|
+
import { Modal, Button } from "@hsu-react/ui";
|
|
26
|
+
|
|
27
|
+
export default () => {
|
|
28
|
+
const [open, setOpen] = useState(false);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<Button type="primary" onClick={() => setOpen(true)}>
|
|
33
|
+
打开对话框
|
|
34
|
+
</Button>
|
|
35
|
+
<Modal
|
|
36
|
+
title="标题"
|
|
37
|
+
open={open}
|
|
38
|
+
onOk={() => setOpen(false)}
|
|
39
|
+
onCancel={() => setOpen(false)}
|
|
40
|
+
>
|
|
41
|
+
<p>这是一段对话框内容,可按住标题栏拖动弹窗。</p>
|
|
42
|
+
</Modal>
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
在 [antd ModalProps](https://ant.design/components/modal-cn) 基础上扩展:
|
|
51
|
+
|
|
52
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
53
|
+
| --- | --- | --- | --- |
|
|
54
|
+
| moveable | 是否可拖拽标题栏移动弹窗 | `boolean` | `true` |
|
|
55
|
+
| edgeDetection | 拖拽时是否进行边缘检测,防止拖出视口 | `boolean` | `true` |
|
|
56
|
+
| full | 是否以全屏方式展示 | `boolean` | `false` |
|
|
57
|
+
| titleButtonGroup | 标题区右侧的按钮组配置 | `ButtonProps[]` | - |
|
|
58
|
+
|
|
59
|
+
> 其余属性(`open`、`onOk`、`onCancel`、`footer`、`width` 等)与 antd `Modal` 一致;`destroyOnClose` 默认为 `true`。
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
padding: 0px 0px 15px;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.ant-modal-close {
|
|
27
|
+
:global(.ant-modal-close) {
|
|
28
28
|
top: 15px;
|
|
29
29
|
inset-inline-end: 10px;
|
|
30
30
|
}
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.ant-modal-title {
|
|
50
|
+
:global(.ant-modal-title) {
|
|
51
51
|
display: flex;
|
|
52
52
|
align-items: center;
|
|
53
53
|
justify-content: space-between;
|
|
@@ -8,10 +8,52 @@ title: Operate 操作
|
|
|
8
8
|
|
|
9
9
|
# Operate 操作
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
表格操作列组件,支持单个操作按钮或一组操作按钮,内置二次确认、权限过滤,并在数量超出时自动收纳到「更多」下拉中。
|
|
12
12
|
|
|
13
13
|
## 引入
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { Operate } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { Operate } from "@hsu-react/ui";
|
|
24
|
+
import { message } from "antd";
|
|
25
|
+
|
|
26
|
+
export default () => (
|
|
27
|
+
<Operate
|
|
28
|
+
title="更多"
|
|
29
|
+
menu={[
|
|
30
|
+
{ title: "查看", onClick: () => message.info("查看") },
|
|
31
|
+
{ title: "编辑", onClick: () => message.info("编辑") },
|
|
32
|
+
{
|
|
33
|
+
title: "删除",
|
|
34
|
+
delete: true,
|
|
35
|
+
onConfirm: () => message.success("已删除"),
|
|
36
|
+
},
|
|
37
|
+
]}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
在 antd `ButtonProps`(已排除 `children`、`title`、`onClick`、`hasPermi`)基础上扩展:
|
|
45
|
+
|
|
46
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| title | 按钮文本 | `ReactNode` | - |
|
|
49
|
+
| menu | 操作项列表(递归同 `OperateProps`),存在时渲染为按钮组 | `OperateProps[]` | `[]` |
|
|
50
|
+
| onClick | 点击回调 | `() => void` | - |
|
|
51
|
+
| onConfirm | 二次确认回调,存在时点击弹出 Popconfirm | `() => void` | - |
|
|
52
|
+
| icon | 自定义图标,`false` 时不显示 | `ReactNode \| false` | - |
|
|
53
|
+
| delete | 是否为删除操作(红色样式,默认删除图标) | `boolean` | - |
|
|
54
|
+
| popconfirm | Popconfirm 配置 | `Omit<PopconfirmProps, 'title'> & { title?: ReactNode }` | - |
|
|
55
|
+
| hidden | 是否隐藏(不渲染) | `boolean` | - |
|
|
56
|
+
| hasPermi | 权限码;无权限时不渲染 | `string[]` | - |
|
|
57
|
+
| maxVisible | 收纳前最多展示的操作数量 | `number` | `3` |
|
|
58
|
+
| enableEllipsis | 操作超出时是否启用「更多」收纳 | `boolean` | `true` |
|
|
59
|
+
| moreIcon | 「更多」按钮自定义图标,`false` 时不显示 | `ReactNode \| false` | - |
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.moreButton {
|
|
45
|
-
|
|
45
|
+
&:global(.ant-btn-icon-only) {
|
|
46
46
|
width: max-content;
|
|
47
47
|
|
|
48
48
|
padding-inline: 4px;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.ant-btn-icon {
|
|
51
|
+
:global(.ant-btn-icon) {
|
|
52
52
|
display: inline-flex;
|
|
53
53
|
align-items: center;
|
|
54
54
|
|