@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.
Files changed (175) hide show
  1. package/README.md +2 -0
  2. package/es/components/ChainGraph/_components/SearchSelect/index.js +13 -10
  3. package/es/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  4. package/es/components/ChainGraph/index.module.less +1 -1
  5. package/es/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  6. package/es/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  7. package/es/components/Chat/ChatInput/index.module.less +2 -2
  8. package/es/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  9. package/es/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  10. package/es/components/Checkbox/index.module.less +13 -13
  11. package/es/components/CodeMirror/index.module.less +4 -4
  12. package/es/components/DatePicker/RangePicker/index.module.less +1 -1
  13. package/es/components/DatePicker/StepPicker/index.module.less +1 -1
  14. package/es/components/DatePicker/index.module.less +2 -1
  15. package/es/components/Form/DrawerForm/index.module.less +2 -2
  16. package/es/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -2
  17. package/es/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  18. package/es/components/FormItem/FormRadio/index.module.less +9 -9
  19. package/es/components/FormItem/FormSegmented/index.module.less +2 -2
  20. package/es/components/FormItem/FormUpload/index.module.less +4 -4
  21. package/es/components/FormItem/ItemContainer/index.module.less +22 -22
  22. package/es/components/Icon/index.js +9 -24
  23. package/es/components/Input/Number/index.module.less +9 -9
  24. package/es/components/Input/Password/index.module.less +3 -3
  25. package/es/components/Input/Range/index.module.less +4 -4
  26. package/es/components/Input/Search/index.module.less +5 -5
  27. package/es/components/Input/TextArea/index.module.less +5 -5
  28. package/es/components/Input/index.module.less +7 -4
  29. package/es/components/Modal/index.module.less +2 -2
  30. package/es/components/Operate/index.module.less +2 -2
  31. package/es/components/Panel/IframePanel/index.module.less +1 -1
  32. package/es/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  33. package/es/components/Search/index.module.less +2 -2
  34. package/es/components/Select/AutoCompleteSelect/index.module.less +35 -35
  35. package/es/components/Select/IconSelect/index.module.less +3 -3
  36. package/es/components/Select/TreeSelect/index.module.less +17 -17
  37. package/es/components/Select/_utils/getElementPosition.d.ts +6 -2
  38. package/es/components/Select/_utils/getElementPosition.js +8 -6
  39. package/es/components/Select/index.module.less +37 -34
  40. package/es/components/Slider/index.module.less +5 -4
  41. package/es/components/Spreadsheet/index.module.less +4 -4
  42. package/es/components/Switch/index.js +12 -8
  43. package/es/components/Switch/index.module.less +7 -0
  44. package/es/components/Table/_components/Pagination/index.module.less +23 -23
  45. package/es/components/Table/index.module.less +61 -61
  46. package/es/components/Tree/index.module.less +11 -11
  47. package/es/components/Upload/index.module.less +3 -3
  48. package/es/styles/antd-overload.less +1 -1
  49. package/lib/components/ChainGraph/_components/SearchSelect/index.js +10 -7
  50. package/lib/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  51. package/lib/components/ChainGraph/index.module.less +1 -1
  52. package/lib/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  53. package/lib/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  54. package/lib/components/Chat/ChatInput/index.module.less +2 -2
  55. package/lib/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  56. package/lib/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  57. package/lib/components/Checkbox/index.module.less +13 -13
  58. package/lib/components/CodeMirror/index.module.less +4 -4
  59. package/lib/components/DatePicker/RangePicker/index.module.less +1 -1
  60. package/lib/components/DatePicker/StepPicker/index.module.less +1 -1
  61. package/lib/components/DatePicker/index.module.less +2 -1
  62. package/lib/components/Form/DrawerForm/index.module.less +2 -2
  63. package/lib/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -1
  64. package/lib/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  65. package/lib/components/FormItem/FormRadio/index.module.less +9 -9
  66. package/lib/components/FormItem/FormSegmented/index.module.less +2 -2
  67. package/lib/components/FormItem/FormUpload/index.module.less +4 -4
  68. package/lib/components/FormItem/ItemContainer/index.module.less +22 -22
  69. package/lib/components/Icon/index.js +9 -27
  70. package/lib/components/Input/Number/index.module.less +9 -9
  71. package/lib/components/Input/Password/index.module.less +3 -3
  72. package/lib/components/Input/Range/index.module.less +4 -4
  73. package/lib/components/Input/Search/index.module.less +5 -5
  74. package/lib/components/Input/TextArea/index.module.less +5 -5
  75. package/lib/components/Input/index.module.less +7 -4
  76. package/lib/components/Modal/index.module.less +2 -2
  77. package/lib/components/Operate/index.module.less +2 -2
  78. package/lib/components/Panel/IframePanel/index.module.less +1 -1
  79. package/lib/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  80. package/lib/components/Search/index.module.less +2 -2
  81. package/lib/components/Select/AutoCompleteSelect/index.module.less +35 -35
  82. package/lib/components/Select/IconSelect/index.module.less +3 -3
  83. package/lib/components/Select/TreeSelect/index.module.less +17 -17
  84. package/lib/components/Select/_utils/getElementPosition.d.ts +6 -2
  85. package/lib/components/Select/_utils/getElementPosition.js +8 -6
  86. package/lib/components/Select/index.module.less +37 -34
  87. package/lib/components/Slider/index.module.less +5 -4
  88. package/lib/components/Spreadsheet/index.module.less +4 -4
  89. package/lib/components/Switch/index.js +8 -4
  90. package/lib/components/Switch/index.module.less +7 -0
  91. package/lib/components/Table/_components/Pagination/index.module.less +23 -23
  92. package/lib/components/Table/index.module.less +61 -61
  93. package/lib/components/Tree/index.module.less +11 -11
  94. package/lib/components/Upload/index.module.less +3 -3
  95. package/lib/styles/antd-overload.less +1 -1
  96. package/package.json +1 -1
  97. package/src/components/Button/index.md +20 -4
  98. package/src/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  99. package/src/components/ChainGraph/_components/SearchSelect/index.tsx +18 -16
  100. package/src/components/ChainGraph/index.md +67 -1
  101. package/src/components/ChainGraph/index.module.less +1 -1
  102. package/src/components/Chart/index.md +351 -1
  103. package/src/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  104. package/src/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  105. package/src/components/Chat/ChatInput/index.module.less +2 -2
  106. package/src/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  107. package/src/components/Chat/index.md +140 -1
  108. package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  109. package/src/components/Checkbox/index.md +85 -1
  110. package/src/components/Checkbox/index.module.less +13 -13
  111. package/src/components/CodeMirror/index.md +41 -1
  112. package/src/components/CodeMirror/index.module.less +4 -4
  113. package/src/components/Copy/index.md +1 -1
  114. package/src/components/DatePicker/RangePicker/index.module.less +1 -1
  115. package/src/components/DatePicker/StepPicker/index.module.less +1 -1
  116. package/src/components/DatePicker/index.md +82 -1
  117. package/src/components/DatePicker/index.module.less +2 -1
  118. package/src/components/Descriptions/index.md +45 -1
  119. package/src/components/Editor/index.md +40 -1
  120. package/src/components/FileCol/index.md +24 -1
  121. package/src/components/FilePreview/index.md +45 -1
  122. package/src/components/FlexFill/index.md +46 -1
  123. package/src/components/Form/DrawerForm/index.module.less +2 -2
  124. package/src/components/Form/index.md +179 -1
  125. package/src/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  126. package/src/components/FormItem/FormInput/FormPasswordStrength/index.tsx +2 -2
  127. package/src/components/FormItem/FormRadio/index.module.less +9 -9
  128. package/src/components/FormItem/FormSegmented/index.module.less +2 -2
  129. package/src/components/FormItem/FormUpload/index.module.less +4 -4
  130. package/src/components/FormItem/ItemContainer/index.module.less +22 -22
  131. package/src/components/FormItem/index.md +514 -1
  132. package/src/components/Icon/index.md +24 -4
  133. package/src/components/Icon/index.tsx +9 -37
  134. package/src/components/Input/Number/index.module.less +9 -9
  135. package/src/components/Input/Password/index.module.less +3 -3
  136. package/src/components/Input/Range/index.module.less +4 -4
  137. package/src/components/Input/Search/index.module.less +5 -5
  138. package/src/components/Input/TextArea/index.module.less +5 -5
  139. package/src/components/Input/index.md +148 -1
  140. package/src/components/Input/index.module.less +7 -4
  141. package/src/components/Markdown/index.md +73 -1
  142. package/src/components/Modal/index.md +43 -1
  143. package/src/components/Modal/index.module.less +2 -2
  144. package/src/components/Operate/index.md +43 -1
  145. package/src/components/Operate/index.module.less +2 -2
  146. package/src/components/Panel/IframePanel/index.module.less +1 -1
  147. package/src/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  148. package/src/components/Panel/index.md +193 -1
  149. package/src/components/Search/index.md +248 -1
  150. package/src/components/Search/index.module.less +2 -2
  151. package/src/components/SecondConf/index.md +39 -1
  152. package/src/components/Select/AutoCompleteSelect/index.module.less +35 -35
  153. package/src/components/Select/IconSelect/index.module.less +3 -3
  154. package/src/components/Select/TreeSelect/index.module.less +17 -17
  155. package/src/components/Select/_utils/getElementPosition.ts +8 -6
  156. package/src/components/Select/index.md +47 -1
  157. package/src/components/Select/index.module.less +37 -34
  158. package/src/components/Slider/index.md +28 -1
  159. package/src/components/Slider/index.module.less +5 -4
  160. package/src/components/Spreadsheet/index.md +42 -1
  161. package/src/components/Spreadsheet/index.module.less +4 -4
  162. package/src/components/Switch/index.md +33 -1
  163. package/src/components/Switch/index.module.less +7 -0
  164. package/src/components/Switch/index.tsx +14 -11
  165. package/src/components/TabBar/index.md +70 -1
  166. package/src/components/Table/_components/Pagination/index.module.less +23 -23
  167. package/src/components/Table/index.md +60 -1
  168. package/src/components/Table/index.module.less +61 -61
  169. package/src/components/Tags/index.md +23 -1
  170. package/src/components/TextEllipsis/index.md +29 -1
  171. package/src/components/Tree/index.md +66 -1
  172. package/src/components/Tree/index.module.less +11 -11
  173. package/src/components/Upload/index.md +72 -1
  174. package/src/components/Upload/index.module.less +3 -3
  175. package/src/styles/antd-overload.less +1 -1
@@ -31,14 +31,14 @@
31
31
  .RangeInput {
32
32
  display: flex;
33
33
  align-items: center;
34
+ column-gap: 5px;
34
35
 
35
36
  width: 100%;
36
37
  height: 100%;
37
38
 
38
- border-radius: 6px;
39
- border: 1px solid var(--cf-border);
40
-
41
- transition: border-color 0.3s, box-shadow 0.3s;
39
+ transition:
40
+ border-color 0.3s,
41
+ box-shadow 0.3s;
42
42
 
43
43
  [class*="antdInput-"] {
44
44
  border: none !important;
@@ -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
- &.ant-input-textarea-affix-wrapper {
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,157 @@ title: Input 输入框
8
8
 
9
9
  # Input 输入框
10
10
 
11
- > `Input` 组件。完整 API 见源码类型定义,下方为基础用法。
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>
33
+ );
34
+ };
35
+ ```
36
+
37
+ ## 数字输入框
38
+
39
+ 数字输入框,`onChange` 返回字符串,内置 `allowClear`、`controls={false}` 与 `stringMode`。
40
+
41
+ ```tsx
42
+ import React from "react";
43
+ import { Input } from "@hsu-react/ui";
44
+
45
+ export default () => {
46
+ const [value, setValue] = React.useState("");
47
+
48
+ return (
49
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
50
+ <Input.Number placeholder="请输入数字" value={value} onChange={setValue} />
51
+ <Input.Number placeholder="带单位" addonAfter="元" />
52
+ </div>
53
+ );
54
+ };
55
+ ```
56
+
57
+ ## 密码框
58
+
59
+ 密码输入框,支持显示/隐藏切换,`onChange` 返回纯字符串。
60
+
61
+ ```tsx
62
+ import React from "react";
63
+ import { Input } from "@hsu-react/ui";
64
+
65
+ export default () => {
66
+ const [value, setValue] = React.useState("");
67
+
68
+ return (
69
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
70
+ <Input.Password placeholder="请输入密码" value={value} onChange={setValue} />
71
+ <Input.Password placeholder="禁用状态" disabled />
72
+ </div>
73
+ );
74
+ };
75
+ ```
76
+
77
+ ## 范围输入
78
+
79
+ 范围输入框,`type` 支持 `"NUMBER"` 或 `"INPUT"`,`onChange` 返回 `[起, 止]` 元组。
80
+
81
+ ```tsx
82
+ import React from "react";
83
+ import { Input } from "@hsu-react/ui";
84
+
85
+ export default () => {
86
+ const [value, setValue] = React.useState();
87
+
88
+ return (
89
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
90
+ <Input.Range
91
+ type="NUMBER"
92
+ value={value}
93
+ onChange={setValue}
94
+ placeholder={["最小值", "最大值"]}
95
+ allowClear
96
+ />
97
+ </div>
98
+ );
99
+ };
100
+ ```
101
+
102
+ ## 搜索框
103
+
104
+ 搜索输入框,支持 `onSearch` 回调与搜索按钮,`onChange` 返回纯字符串。
105
+
106
+ ```tsx
107
+ import React from "react";
108
+ import { Input } from "@hsu-react/ui";
109
+
110
+ export default () => {
111
+ const [value, setValue] = React.useState("");
112
+
113
+ return (
114
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
115
+ <Input.Search
116
+ placeholder="请输入关键字"
117
+ value={value}
118
+ onChange={setValue}
119
+ enterButton
120
+ onSearch={(v) => console.log("search:", v)}
121
+ />
122
+ </div>
123
+ );
124
+ };
125
+ ```
126
+
127
+ ## 多行文本框
128
+
129
+ 多行文本输入框,`onChange` 返回纯字符串,支持 `autoSize`、`prefix` / `suffix`。
130
+
131
+ ```tsx
132
+ import React from "react";
133
+ import { Input } from "@hsu-react/ui";
134
+
135
+ export default () => {
136
+ const [value, setValue] = React.useState("");
137
+
138
+ return (
139
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
140
+ <Input.TextArea
141
+ placeholder="请输入内容"
142
+ value={value}
143
+ onChange={setValue}
144
+ autoSize={{ minRows: 2, maxRows: 4 }}
145
+ />
146
+ </div>
147
+ );
148
+ };
149
+ ```
150
+
151
+ ## API
152
+
153
+ 在 [antd InputProps](https://ant.design/components/input-cn) 基础上扩展(并移除了 `onCompositionStart`、`onCompositionEnd`、`ref`,重写了 `onChange`):
154
+
155
+ | 属性 | 说明 | 类型 | 默认值 |
156
+ | --- | --- | --- | --- |
157
+ | onChange | 值变化回调,经过合成与防抖处理后返回纯字符串 | `(value: string) => void` | - |
158
+ | getRef | 获取内部 antd `InputRef` 的回调 | `(ref: InputRef \| null) => void` | - |
159
+ | en | 是否英文模式,开启后不受 `maxLength` 限制 | `boolean` | `false` |
160
+ | word | 是否为字数/单词相关模式 | `boolean` | - |
161
+ | tooltip | 透传给外层 `Tooltip` 的配置 | `TooltipProps` | - |
162
+ | escapeCharacters | 需要自动转义/去转义的字符列表 | `string[]` | - |
163
+
164
+ > 另提供子组件:`Input.Search`、`Input.TextArea`、`Input.Password`、`Input.Number`(数字输入,`onChange` 返回字符串)、`Input.Range`(范围输入)。
@@ -1,17 +1,20 @@
1
1
  .antdInput {
2
2
  width: 100%;
3
3
  height: 100%;
4
+ // 父级未给定高度时(height:100% 解析为 auto),保证最小高度,避免输入框被压扁;
5
+ // 内部 .ant-input-wrapper / .ant-input 通过 min-height: inherit 继承该值。
6
+ min-height: 32px;
4
7
 
5
- .ant-input-clear-icon {
8
+ :global(.ant-input-clear-icon) {
6
9
  font-size: 14px;
7
10
  }
8
11
 
9
- .ant-input-wrapper {
12
+ :global(.ant-input-wrapper) {
10
13
  height: 100%;
11
14
  min-height: inherit;
12
15
 
13
- > .ant-input,
14
- > .ant-input-affix-wrapper {
16
+ > :global(.ant-input),
17
+ > :global(.ant-input-affix-wrapper) {
15
18
  height: 100%;
16
19
  min-height: inherit;
17
20
  }
@@ -8,10 +8,82 @@ title: Markdown 渲染
8
8
 
9
9
  # Markdown 渲染
10
10
 
11
- > `Markdown` 组件。完整 API 见源码类型定义,下方为基础用法。
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
+ ## Markdown 展示
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 编辑器
45
+
46
+ `Markdown.Editor` 编辑:
47
+
48
+ ```tsx
49
+ import React from "react";
50
+ import { Markdown } from "@hsu-react/ui";
51
+
52
+ export default () => {
53
+ const [value, setValue] = React.useState("# Hello\n\n开始编辑 **Markdown** 内容吧。");
54
+
55
+ return (
56
+ <div style={{ height: 240 }}>
57
+ <Markdown.Editor
58
+ value={value}
59
+ onChange={setValue}
60
+ view={{ menu: true, md: true, html: true }}
61
+ />
62
+ </div>
63
+ );
64
+ };
65
+ ```
66
+
67
+ ## API
68
+
69
+ ### Markdown.Views
70
+
71
+ 继承 [react-markdown Options](https://github.com/remarkjs/react-markdown)(markdown 文本通过 `children` 传入),新增属性:
72
+
73
+ | 属性 | 说明 | 类型 | 默认值 |
74
+ | --- | --- | --- | --- |
75
+ | children | 待渲染的 markdown 文本 | `string` | - |
76
+ | copyProps | 代码块复制按钮配置 | `Omit<CopyProps, 'id'>` | - |
77
+ | className | 自定义类名 | `string` | - |
78
+
79
+ ### Markdown.Editor
80
+
81
+ | 属性 | 说明 | 类型 | 默认值 |
82
+ | --- | --- | --- | --- |
83
+ | value | 编辑器内容 | `string` | `''` |
84
+ | onChange | 内容变化回调 | `(value: string) => void` | - |
85
+ | buttonGroup | 顶部自定义按钮组 | `ButtonProps[]` | - |
86
+ | className | 自定义类名 | `string` | - |
87
+ | disabled | 是否禁用 | `boolean` | - |
88
+ | readOnly | 是否只读 | `boolean` | - |
89
+ | 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
- > `Modal` 组件。完整 API 见源码类型定义,下方为基础用法。
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
- > `Operate` 组件。完整 API 见源码类型定义,下方为基础用法。
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
- &.ant-btn-icon-only {
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
 
@@ -30,7 +30,7 @@
30
30
  width: 100%;
31
31
  height: 100%;
32
32
 
33
- > .ant-spin-container {
33
+ > :global(.ant-spin-container) {
34
34
  width: 100%;
35
35
  height: 100%;
36
36
 
@@ -25,7 +25,7 @@
25
25
  }
26
26
 
27
27
  .checkbox {
28
- .ant-checkbox {
28
+ :global(.ant-checkbox) {
29
29
  width: 14px;
30
30
  min-width: 14px;
31
31
  height: 14px;