@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
@@ -8,10 +8,94 @@ title: Checkbox 多选框
8
8
 
9
9
  # Checkbox 多选框
10
10
 
11
- > `Checkbox` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 antd `Checkbox` 封装的多选框,额外提供 `outline` 描边样式,并附带支持全选、布局方向的 `Checkbox.Group`。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Checkbox } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 多选框
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Checkbox } 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
+ <div
36
+ style={{
37
+ display: "flex",
38
+ flexDirection: "column",
39
+ gap: 12,
40
+ alignItems: "flex-start",
41
+ }}
42
+ >
43
+ <Checkbox outline>描边多选框</Checkbox>
44
+ <Checkbox.Group options={options} value={value} onChange={setValue} />
45
+ </div>
46
+ );
47
+ };
48
+ ```
49
+
50
+ ## 多选框组
51
+
52
+ 多选框组,支持 `hasAll`(全选)、`layout`(排列方向)与 `outline`(描边样式)。
53
+
54
+ ```tsx
55
+ import React from "react";
56
+ import { Checkbox } from "@hsu-react/ui";
57
+
58
+ const options = [
59
+ { label: "苹果", value: "apple" },
60
+ { label: "香蕉", value: "banana" },
61
+ { label: "橙子", value: "orange" },
62
+ ];
63
+
64
+ export default () => {
65
+ const [value, setValue] = React.useState(["apple"]);
66
+
67
+ return (
68
+ <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
69
+ <Checkbox.Group
70
+ options={options}
71
+ value={value}
72
+ onChange={setValue}
73
+ hasAll
74
+ outline
75
+ layout="vertical"
76
+ />
77
+ </div>
78
+ );
79
+ };
80
+ ```
81
+
82
+ ## API
83
+
84
+ ### Checkbox
85
+
86
+ 在 [antd CheckboxProps](https://ant.design/components/checkbox-cn) 基础上扩展:
87
+
88
+ | 属性 | 说明 | 类型 | 默认值 |
89
+ | --- | --- | --- | --- |
90
+ | outline | 是否使用描边样式 | `boolean` | - |
91
+
92
+ ### Checkbox.Group
93
+
94
+ 在 antd `Checkbox.Group` 基础上扩展:
95
+
96
+ | 属性 | 说明 | 类型 | 默认值 |
97
+ | --- | --- | --- | --- |
98
+ | outline | 是否使用描边样式 | `boolean` | - |
99
+ | hasAll | 是否显示"全选"选项 | `boolean` | - |
100
+ | layout | 选项排列方向 | `'vertical' \| 'horizontal'` | `'horizontal'` |
101
+ | allMaxHeight | 含全选时容器最大高度(px) | `number` | - |
@@ -2,8 +2,8 @@
2
2
  align-items: center;
3
3
 
4
4
  &.outline {
5
- .ant-checkbox {
6
- .ant-checkbox-inner {
5
+ :global(.ant-checkbox) {
6
+ :global(.ant-checkbox-inner) {
7
7
  border-color: rgba(204, 204, 204, 1) !important;
8
8
 
9
9
  background: transparent !important;
@@ -14,16 +14,16 @@
14
14
  }
15
15
  }
16
16
 
17
- &.ant-checkbox-checked {
18
- .ant-checkbox-inner {
17
+ &:global(.ant-checkbox-checked) {
18
+ :global(.ant-checkbox-inner) {
19
19
  background: rgba(255, 255, 255, 1) !important;
20
20
  }
21
21
  }
22
22
  }
23
23
 
24
- &.ant-checkbox-wrapper-disabled {
25
- .ant-checkbox {
26
- .ant-checkbox-inner {
24
+ &:global(.ant-checkbox-wrapper-disabled) {
25
+ :global(.ant-checkbox) {
26
+ :global(.ant-checkbox-inner) {
27
27
  background: rgba(0, 0, 0, 0.04) !important;
28
28
 
29
29
  &::after {
@@ -31,8 +31,8 @@
31
31
  }
32
32
  }
33
33
 
34
- &.ant-checkbox-checked {
35
- .ant-checkbox-inner {
34
+ &:global(.ant-checkbox-checked) {
35
+ :global(.ant-checkbox-inner) {
36
36
  background: rgba(0, 0, 0, 0.04) !important;
37
37
  }
38
38
  }
@@ -40,7 +40,7 @@
40
40
  }
41
41
  }
42
42
 
43
- .ant-checkbox {
43
+ :global(.ant-checkbox) {
44
44
  width: 16px;
45
45
  min-width: 16px;
46
46
  height: 16px;
@@ -48,12 +48,12 @@
48
48
 
49
49
  border-radius: 2px;
50
50
 
51
- input[type="checkbox"].ant-checkbox-input {
51
+ input[type="checkbox"]:global(.ant-checkbox-input) {
52
52
  width: 100%;
53
53
  height: 100%;
54
54
  }
55
55
 
56
- .ant-checkbox-inner {
56
+ :global(.ant-checkbox-inner) {
57
57
  width: 100%;
58
58
  height: 100%;
59
59
 
@@ -70,7 +70,7 @@
70
70
  }
71
71
 
72
72
  &-indeterminate {
73
- .ant-checkbox-inner {
73
+ :global(.ant-checkbox-inner) {
74
74
  &::after {
75
75
  left: 50%;
76
76
  top: 50%;
@@ -8,10 +8,50 @@ title: CodeMirror 代码编辑
8
8
 
9
9
  # CodeMirror 代码编辑
10
10
 
11
- > `CodeMirror` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 `@uiw/react-codemirror` 封装的代码编辑器,支持 SQL / JSON 语言的按需加载、语法检查与错误提示。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { CodeMirror } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 代码编辑
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { CodeMirror } from "@hsu-react/ui";
24
+
25
+ export default () => {
26
+ const [value, setValue] = React.useState(
27
+ '{\n "name": "hsu-ui",\n "version": "1.0.0",\n "private": true\n}'
28
+ );
29
+ const [error, setError] = React.useState(null);
30
+
31
+ return (
32
+ <CodeMirror
33
+ language="json"
34
+ value={value}
35
+ enableLint
36
+ hasError={!!error}
37
+ onChange={setValue}
38
+ onLintError={setError}
39
+ />
40
+ );
41
+ };
42
+ ```
43
+
44
+ ## API
45
+
46
+ 在 [ReactCodeMirrorProps](https://uiwjs.github.io/react-codemirror/)(去除 `extensions`、`onError`)基础上扩展:
47
+
48
+ | 属性 | 说明 | 类型 | 默认值 |
49
+ | --- | --- | --- | --- |
50
+ | language | 语言类型,按需引入对应语言支持 | `'sql' \| 'json' \| 'plain'` | `'sql'` |
51
+ | enableLint | 是否启用语法检查 | `boolean` | `true` |
52
+ | onLintError | 错误信息回调,无错误时回调 `null` | `(error: string \| null) => void` | - |
53
+ | hasError | 是否显示错误边框 | `boolean` | `false` |
54
+ | translateError | 是否将错误信息翻译为中文 | `boolean` | `false` |
55
+ | allowJsonArrayRoot | JSON 校验是否允许根节点为数组 `[...]` | `boolean` | `false` |
56
+
57
+ > 其余如 `value`、`onChange`、`basicSetup`、`theme`、`minHeight` 等均继承自 `ReactCodeMirror`,默认主题为 `vscodeLight`。
@@ -7,17 +7,17 @@
7
7
 
8
8
  overflow: hidden;
9
9
 
10
- .cm-line {
10
+ :global(.cm-line) {
11
11
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
12
12
  "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
13
13
  "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
14
14
  }
15
15
 
16
- .cm-focused {
16
+ :global(.cm-focused) {
17
17
  outline: none;
18
18
  }
19
19
 
20
- .cm-lintRange-error {
20
+ :global(.cm-lintRange-error) {
21
21
  background-size: auto auto;
22
22
  }
23
23
 
@@ -28,7 +28,7 @@
28
28
  border-color: #ff4d4f;
29
29
  }
30
30
 
31
- .cm-focused {
31
+ :global(.cm-focused) {
32
32
  border-color: #ff4d4f;
33
33
  box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
34
34
  }
@@ -16,7 +16,7 @@ title: Copy 复制
16
16
  import { Copy } from "@hsu-react/ui";
17
17
  ```
18
18
 
19
- ## 基础用法
19
+ ## 复制
20
20
 
21
21
  ```tsx
22
22
  import React from "react";
@@ -25,7 +25,7 @@
25
25
  color: inherit;
26
26
  text-align: inherit;
27
27
 
28
- .ant-picker-input {
28
+ :global(.ant-picker-input) {
29
29
  font-family: inherit;
30
30
  font-size: inherit;
31
31
  font-weight: inherit;
@@ -5,7 +5,7 @@
5
5
  column-gap: 5px;
6
6
 
7
7
  .icon {
8
- &.ant-btn-icon-only {
8
+ &:global(.ant-btn-icon-only) {
9
9
  width: 32px;
10
10
  height: 32px;
11
11
  }
@@ -8,10 +8,91 @@ title: DatePicker 日期选择
8
8
 
9
9
  # DatePicker 日期选择
10
10
 
11
- > `DatePicker` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ antd `DatePicker` 基础上扩展,支持通过下拉切换日期 / 周 / 月 / 季度 / 年等粒度,`onChange` 直接返回格式化后的字符串。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { DatePicker } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 日期选择
20
+
21
+ ```tsx
22
+ import React, { useState } from "react";
23
+ import { DatePicker } from "@hsu-react/ui";
24
+
25
+ export default () => {
26
+ const [value, setValue] = useState<string>();
27
+
28
+ return (
29
+ <div
30
+ style={{
31
+ display: "flex",
32
+ flexDirection: "column",
33
+ gap: 12,
34
+ alignItems: "flex-start",
35
+ }}
36
+ >
37
+ <DatePicker value={value} onChange={(date) => setValue(date)} />
38
+ <DatePicker showPicker onChange={(date, picker) => console.log(date, picker)} />
39
+ </div>
40
+ );
41
+ };
42
+ ```
43
+
44
+ ## 日期范围选择
45
+
46
+ 区间选择,`value` / `defaultValue` 为 `string[]`,`onChange` 返回格式化后的 `string[]`,同样支持 `picker` / `showPicker` 等粒度切换。
47
+
48
+ ```tsx
49
+ import React, { useState } from "react";
50
+ import { DatePicker } from "@hsu-react/ui";
51
+
52
+ export default () => {
53
+ const [value, setValue] = useState<string[]>();
54
+
55
+ return (
56
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
57
+ <DatePicker.RangePicker value={value} onChange={(dates) => setValue(dates)} />
58
+ <DatePicker.RangePicker showPicker onChange={(dates, picker) => console.log(dates, picker)} />
59
+ </div>
60
+ );
61
+ };
62
+ ```
63
+
64
+ ## 步进日期选择
65
+
66
+ 按 `step` 步进的日期选择,支持 `picker: 'day' | 'month' | 'year'`,以及 `minDate` / `maxDate` 边界限制。
67
+
68
+ ```tsx
69
+ import React, { useState } from "react";
70
+ import { DatePicker } from "@hsu-react/ui";
71
+
72
+ export default () => {
73
+ const [value, setValue] = useState<string>();
74
+
75
+ return (
76
+ <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
77
+ <DatePicker.StepPicker picker="day" step={1} onChange={(date) => setValue(date)} />
78
+ <DatePicker.StepPicker picker="month" onChange={(date) => setValue(date)} />
79
+ </div>
80
+ );
81
+ };
82
+ ```
83
+
84
+ ## API
85
+
86
+ 在 [antd DatePickerProps](https://ant.design/components/date-picker-cn) 基础上扩展(重写了 `picker`、`onChange`):
87
+
88
+ | 属性 | 说明 | 类型 | 默认值 |
89
+ | --- | --- | --- | --- |
90
+ | picker | 日期选择粒度 | `'date' \| 'week' \| 'month' \| 'quarter' \| 'year' \| 'time'` | `'date'` |
91
+ | showPicker | 是否在前方显示粒度切换下拉框 | `boolean` | `false` |
92
+ | pickerHide | 在粒度下拉框中隐藏的选项 | `Picker[]` | `[]` |
93
+ | pickerSelectProps | 透传给粒度下拉框的 `Select` 属性 | `SelectProps` | - |
94
+ | pickerOptions | 自定义粒度下拉框的选项 | `SelectOption[]` | - |
95
+ | dataPickerCls | 内部日期选择器的自定义类名 | `string` | - |
96
+ | onChange | 值变化回调,返回格式化字符串与当前粒度 | `(date?: string, picker?: Picker) => void` | - |
97
+
98
+ > 另提供 `DatePicker.RangePicker`(区间选择,`onChange` 返回 `string[]`,同样支持 `picker` / `showPicker` 等)与 `DatePicker.StepPicker`(按 `step` 步进的日期选择,支持 `picker: 'day' \| 'month' \| 'year'`、`minDate` / `maxDate`)。
@@ -5,6 +5,7 @@
5
5
 
6
6
  width: 100%;
7
7
  height: 100%;
8
+ min-height: 32px;
8
9
  max-height: max-content;
9
10
 
10
11
  border-radius: 6px;
@@ -20,7 +21,7 @@
20
21
  min-width: 80px;
21
22
  }
22
23
 
23
- .ant-picker {
24
+ :global(.ant-picker) {
24
25
  height: 100%;
25
26
  width: 100%;
26
27
 
@@ -8,10 +8,54 @@ title: Descriptions 描述列表
8
8
 
9
9
  # Descriptions 描述列表
10
10
 
11
- > `Descriptions` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ antd `Descriptions` 之上支持以 `columns` + `dataSource` 的方式声明式渲染,内置权限过滤、排序与标签宽度自适应。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Descriptions } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 描述列表
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Descriptions } from "@hsu-react/ui";
24
+
25
+ export default () => (
26
+ <Descriptions
27
+ column={2}
28
+ columns={[
29
+ { title: "姓名", dataIndex: "name" },
30
+ { title: "年龄", dataIndex: "age" },
31
+ { title: "手机号", dataIndex: "phone" },
32
+ {
33
+ title: "状态",
34
+ dataIndex: "status",
35
+ render: (value) => (value === 1 ? "启用" : "停用"),
36
+ },
37
+ ]}
38
+ dataSource={{ name: "张三", age: 28, phone: "13800000000", status: 1 }}
39
+ />
40
+ );
41
+ ```
42
+
43
+ ## API
44
+
45
+ 在 [antd DescriptionsProps](https://ant.design/components/descriptions-cn) 基础上扩展:
46
+
47
+ | 属性 | 说明 | 类型 | 默认值 |
48
+ | --- | --- | --- | --- |
49
+ | columns | 列配置,声明式描述每项内容 | `ColumnsType[]` | - |
50
+ | dataSource | 数据源,配合 `columns` 的 `dataIndex` 取值 | `Record<string, unknown>` | `{}` |
51
+
52
+ `ColumnsType` 字段:
53
+
54
+ | 属性 | 说明 | 类型 | 默认值 |
55
+ | --- | --- | --- | --- |
56
+ | title | 标签文本 | `string` | - |
57
+ | dataIndex | 取值字段 | `string` | - |
58
+ | hidded | 是否隐藏该项 | `boolean` | - |
59
+ | sort | 排序权重(升序) | `number` | - |
60
+ | hasPermi | 权限码;无权限时不渲染该项 | `string[]` | - |
61
+ | render | 自定义渲染内容 | `(value: unknown, record: Record<string, unknown>) => ReactNode` | - |
@@ -8,10 +8,49 @@ title: Editor 富文本
8
8
 
9
9
  # Editor 富文本
10
10
 
11
- > `Editor` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 wangEditor 封装的富文本编辑器,受控输出 HTML 字符串,并提供 `Editor.Content` 用于只读展示富文本内容。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Editor } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 富文本
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Editor } from "@hsu-react/ui";
24
+
25
+ export default () => {
26
+ const [html, setHtml] = React.useState(
27
+ "<p>这是一段<strong>富文本</strong>内容,可以编辑。</p>"
28
+ );
29
+
30
+ return (
31
+ <>
32
+ <Editor value={html} onChange={setHtml} height={240} />
33
+ {/* 只读展示 */}
34
+ <Editor.Content value={html} />
35
+ </>
36
+ );
37
+ };
38
+ ```
39
+
40
+ ## API
41
+
42
+ | 属性 | 说明 | 类型 | 默认值 |
43
+ | --- | --- | --- | --- |
44
+ | value | 编辑器内容(HTML 字符串) | `string` | - |
45
+ | onChange | 内容变化回调 | `(html: string) => void` | - |
46
+ | placeholder | 占位提示文字 | `string` | `'请输入内容...'` |
47
+ | height | 编辑区高度(px) | `number` | `500` |
48
+ | disabled | 是否禁用(只读,隐藏工具栏) | `boolean` | `false` |
49
+
50
+ ### Editor.Content
51
+
52
+ 只读展示组件,仅用于渲染富文本内容。
53
+
54
+ | 属性 | 说明 | 类型 | 默认值 |
55
+ | --- | --- | --- | --- |
56
+ | value | 待展示的 HTML 字符串 | `string` | `''` |
@@ -8,10 +8,33 @@ title: FileCol 文件列
8
8
 
9
9
  # FileCol 文件列
10
10
 
11
- > `FileCol` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 展示文件列表,对支持预览的文件类型提供「查看」入口,常用于表格中的文件列。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { FileCol } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 文件列
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { FileCol } from "@hsu-react/ui";
24
+
25
+ export default () => (
26
+ <FileCol
27
+ item={[
28
+ { uid: "1", name: "设计稿.png", url: "https://example.com/a.png" },
29
+ { uid: "2", name: "需求文档.pdf", url: "https://example.com/b.pdf" },
30
+ ]}
31
+ />
32
+ );
33
+ ```
34
+
35
+ ## API
36
+
37
+ | 属性 | 说明 | 类型 | 默认值 |
38
+ | --- | --- | --- | --- |
39
+ | item | 文件列表 | `UploadFile[]` | `[]` |
40
+ | hideNm | 是否隐藏文件名 | `boolean` | - |
@@ -8,10 +8,54 @@ title: FilePreview 文件预览
8
8
 
9
9
  # FilePreview 文件预览
10
10
 
11
- > `FilePreview` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 根据文件类型展示对应预览(视频、PDF、图片、文本、Markdown、Excel),通过 `open` 控制显隐。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { FilePreview } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 文件预览
20
+
21
+ 文本 / Markdown 类型通过 `text` 传入内容,无需远程地址即可预览;视频 / PDF / 图片 / Excel 类型则通过 `fileUrl` 传入文件地址。
22
+
23
+ ```tsx
24
+ import React, { useState } from "react";
25
+ import { FilePreview } from "@hsu-react/ui";
26
+ import { Button } from "antd";
27
+
28
+ export default () => {
29
+ const [open, setOpen] = useState(false);
30
+
31
+ return (
32
+ <>
33
+ <Button type="primary" onClick={() => setOpen(true)}>
34
+ 预览文本
35
+ </Button>
36
+ <FilePreview
37
+ open={open}
38
+ fileType="txt"
39
+ fileName="说明.txt"
40
+ text={"第一行:这是一段示例文本内容。\n第二行:点击右上角关闭按钮可退出预览。\n第三行:txt / md 类型通过 text 传入,无需网络请求。"}
41
+ onClose={() => setOpen(false)}
42
+ />
43
+ </>
44
+ );
45
+ };
46
+ ```
47
+
48
+ ## API
49
+
50
+ | 属性 | 说明 | 类型 | 默认值 |
51
+ | --- | --- | --- | --- |
52
+ | open | 是否展示预览(为 `false` 时不渲染) | `boolean` | - |
53
+ | fileType | 文件类型,决定使用哪种预览器 | `'mp4' \| 'pdf' \| 'jpg' \| 'jpeg' \| 'png' \| 'gif' \| 'txt' \| 'md' \| 'xlsx' \| string` | - |
54
+ | fileUrl | 文件地址(视频/PDF/图片/Excel) | `string` | - |
55
+ | fileName | 文件名 | `string` | - |
56
+ | text | 文本内容(`txt` / `md` 类型使用) | `string` | - |
57
+ | pagination | PDF 是否显示分页 | `boolean` | - |
58
+ | className | 自定义类名 | `string` | - |
59
+ | onClose | 关闭回调 | `() => void` | - |
60
+
61
+ > 另导出类型 `FilePreviewType` 与常量 `FilePreviewTypeArr`(支持的文件类型数组)。
@@ -8,10 +8,55 @@ title: FlexFill 自适应填充
8
8
 
9
9
  # FlexFill 自适应填充
10
10
 
11
- > `FlexFill` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ `flex` + `justify-content: space-between` 的多行弹性布局中,用于占位补齐最后一行,避免末行元素被两端对齐拉散。组件渲染 10 个高度近似为 0 的占位块。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { FlexFill } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 自适应填充
20
+
21
+ 将 `FlexFill` 放在弹性容器的子元素末尾,即可让最后一行的卡片按正常间距左对齐排列。
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { FlexFill } from "@hsu-react/ui";
26
+
27
+ export default () => (
28
+ <div
29
+ style={{
30
+ display: "flex",
31
+ flexWrap: "wrap",
32
+ justifyContent: "space-between",
33
+ gap: "12px 0",
34
+ }}
35
+ >
36
+ {[1, 2, 3, 4, 5].map((item) => (
37
+ <div
38
+ key={item}
39
+ style={{
40
+ width: 120,
41
+ height: 60,
42
+ lineHeight: "60px",
43
+ textAlign: "center",
44
+ background: "#f0f2f5",
45
+ borderRadius: 8,
46
+ }}
47
+ >
48
+ 卡片 {item}
49
+ </div>
50
+ ))}
51
+ <FlexFill width="120px" />
52
+ </div>
53
+ );
54
+ ```
55
+
56
+ ## API
57
+
58
+ | 属性 | 说明 | 类型 | 默认值 |
59
+ | --- | --- | --- | --- |
60
+ | width | 单个占位块的宽度,通常与列表项宽度保持一致 | `string` | `'100%'` |
61
+ | className | 占位块的自定义类名 | `string` | - |
62
+ | style | 占位块的自定义样式(支持 CSS 变量) | `CSSProperties` | - |
@@ -1,5 +1,5 @@
1
1
  .DrawerForm {
2
- .ant-drawer-title {
2
+ :global(.ant-drawer-title) {
3
3
  display: flex;
4
4
  align-items: center;
5
5
  justify-content: space-between;
@@ -43,7 +43,7 @@
43
43
  align-items: center;
44
44
  column-gap: 10px;
45
45
 
46
- .ant-btn-icon {
46
+ :global(.ant-btn-icon) {
47
47
  font-size: 16px;
48
48
  }
49
49
  }