@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.
Files changed (147) hide show
  1. package/es/components/ChainGraph/index.module.less +1 -1
  2. package/es/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  3. package/es/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  4. package/es/components/Chat/ChatInput/index.module.less +2 -2
  5. package/es/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  6. package/es/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  7. package/es/components/Checkbox/index.module.less +13 -13
  8. package/es/components/CodeMirror/index.module.less +4 -4
  9. package/es/components/DatePicker/RangePicker/index.module.less +1 -1
  10. package/es/components/DatePicker/StepPicker/index.module.less +1 -1
  11. package/es/components/DatePicker/index.module.less +1 -1
  12. package/es/components/Form/DrawerForm/index.module.less +2 -2
  13. package/es/components/FormItem/FormRadio/index.module.less +9 -9
  14. package/es/components/FormItem/FormSegmented/index.module.less +2 -2
  15. package/es/components/FormItem/FormUpload/index.module.less +4 -4
  16. package/es/components/FormItem/ItemContainer/index.module.less +22 -22
  17. package/es/components/Icon/index.js +9 -24
  18. package/es/components/Input/Number/index.module.less +9 -9
  19. package/es/components/Input/Password/index.module.less +3 -3
  20. package/es/components/Input/Search/index.module.less +5 -5
  21. package/es/components/Input/TextArea/index.module.less +5 -5
  22. package/es/components/Input/index.module.less +4 -4
  23. package/es/components/Modal/index.module.less +2 -2
  24. package/es/components/Operate/index.module.less +2 -2
  25. package/es/components/Panel/IframePanel/index.module.less +1 -1
  26. package/es/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  27. package/es/components/Search/index.module.less +2 -2
  28. package/es/components/Select/AutoCompleteSelect/index.module.less +35 -35
  29. package/es/components/Select/IconSelect/index.module.less +3 -3
  30. package/es/components/Select/TreeSelect/index.module.less +17 -17
  31. package/es/components/Select/index.module.less +34 -34
  32. package/es/components/Slider/index.module.less +4 -4
  33. package/es/components/Spreadsheet/index.module.less +4 -4
  34. package/es/components/Table/_components/Pagination/index.module.less +23 -23
  35. package/es/components/Table/index.module.less +61 -61
  36. package/es/components/Tree/index.module.less +11 -11
  37. package/es/components/Upload/index.module.less +3 -3
  38. package/es/styles/antd-overload.less +1 -1
  39. package/lib/components/ChainGraph/index.module.less +1 -1
  40. package/lib/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  41. package/lib/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  42. package/lib/components/Chat/ChatInput/index.module.less +2 -2
  43. package/lib/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  44. package/lib/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  45. package/lib/components/Checkbox/index.module.less +13 -13
  46. package/lib/components/CodeMirror/index.module.less +4 -4
  47. package/lib/components/DatePicker/RangePicker/index.module.less +1 -1
  48. package/lib/components/DatePicker/StepPicker/index.module.less +1 -1
  49. package/lib/components/DatePicker/index.module.less +1 -1
  50. package/lib/components/Form/DrawerForm/index.module.less +2 -2
  51. package/lib/components/FormItem/FormRadio/index.module.less +9 -9
  52. package/lib/components/FormItem/FormSegmented/index.module.less +2 -2
  53. package/lib/components/FormItem/FormUpload/index.module.less +4 -4
  54. package/lib/components/FormItem/ItemContainer/index.module.less +22 -22
  55. package/lib/components/Icon/index.js +9 -27
  56. package/lib/components/Input/Number/index.module.less +9 -9
  57. package/lib/components/Input/Password/index.module.less +3 -3
  58. package/lib/components/Input/Search/index.module.less +5 -5
  59. package/lib/components/Input/TextArea/index.module.less +5 -5
  60. package/lib/components/Input/index.module.less +4 -4
  61. package/lib/components/Modal/index.module.less +2 -2
  62. package/lib/components/Operate/index.module.less +2 -2
  63. package/lib/components/Panel/IframePanel/index.module.less +1 -1
  64. package/lib/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  65. package/lib/components/Search/index.module.less +2 -2
  66. package/lib/components/Select/AutoCompleteSelect/index.module.less +35 -35
  67. package/lib/components/Select/IconSelect/index.module.less +3 -3
  68. package/lib/components/Select/TreeSelect/index.module.less +17 -17
  69. package/lib/components/Select/index.module.less +34 -34
  70. package/lib/components/Slider/index.module.less +4 -4
  71. package/lib/components/Spreadsheet/index.module.less +4 -4
  72. package/lib/components/Table/_components/Pagination/index.module.less +23 -23
  73. package/lib/components/Table/index.module.less +61 -61
  74. package/lib/components/Tree/index.module.less +11 -11
  75. package/lib/components/Upload/index.module.less +3 -3
  76. package/lib/styles/antd-overload.less +1 -1
  77. package/package.json +1 -1
  78. package/src/components/Button/index.md +2 -3
  79. package/src/components/ChainGraph/index.md +66 -1
  80. package/src/components/ChainGraph/index.module.less +1 -1
  81. package/src/components/Chart/index.md +78 -1
  82. package/src/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  83. package/src/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  84. package/src/components/Chat/ChatInput/index.module.less +2 -2
  85. package/src/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  86. package/src/components/Chat/index.md +97 -1
  87. package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  88. package/src/components/Checkbox/index.md +53 -1
  89. package/src/components/Checkbox/index.module.less +13 -13
  90. package/src/components/CodeMirror/index.md +41 -1
  91. package/src/components/CodeMirror/index.module.less +4 -4
  92. package/src/components/DatePicker/RangePicker/index.module.less +1 -1
  93. package/src/components/DatePicker/StepPicker/index.module.less +1 -1
  94. package/src/components/DatePicker/index.md +43 -1
  95. package/src/components/DatePicker/index.module.less +1 -1
  96. package/src/components/Descriptions/index.md +45 -1
  97. package/src/components/Editor/index.md +40 -1
  98. package/src/components/FileCol/index.md +24 -1
  99. package/src/components/FilePreview/index.md +45 -1
  100. package/src/components/FlexFill/index.md +46 -1
  101. package/src/components/Form/DrawerForm/index.module.less +2 -2
  102. package/src/components/Form/index.md +92 -1
  103. package/src/components/FormItem/FormRadio/index.module.less +9 -9
  104. package/src/components/FormItem/FormSegmented/index.module.less +2 -2
  105. package/src/components/FormItem/FormUpload/index.module.less +4 -4
  106. package/src/components/FormItem/ItemContainer/index.module.less +22 -22
  107. package/src/components/FormItem/index.md +459 -1
  108. package/src/components/Icon/index.md +21 -3
  109. package/src/components/Icon/index.tsx +9 -37
  110. package/src/components/Input/Number/index.module.less +9 -9
  111. package/src/components/Input/Password/index.module.less +3 -3
  112. package/src/components/Input/Search/index.module.less +5 -5
  113. package/src/components/Input/TextArea/index.module.less +5 -5
  114. package/src/components/Input/index.md +35 -1
  115. package/src/components/Input/index.module.less +4 -4
  116. package/src/components/Markdown/index.md +71 -1
  117. package/src/components/Modal/index.md +43 -1
  118. package/src/components/Modal/index.module.less +2 -2
  119. package/src/components/Operate/index.md +43 -1
  120. package/src/components/Operate/index.module.less +2 -2
  121. package/src/components/Panel/IframePanel/index.module.less +1 -1
  122. package/src/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  123. package/src/components/Panel/index.md +146 -1
  124. package/src/components/Search/index.md +73 -1
  125. package/src/components/Search/index.module.less +2 -2
  126. package/src/components/SecondConf/index.md +39 -1
  127. package/src/components/Select/AutoCompleteSelect/index.module.less +35 -35
  128. package/src/components/Select/IconSelect/index.module.less +3 -3
  129. package/src/components/Select/TreeSelect/index.module.less +17 -17
  130. package/src/components/Select/index.md +47 -1
  131. package/src/components/Select/index.module.less +34 -34
  132. package/src/components/Slider/index.md +29 -1
  133. package/src/components/Slider/index.module.less +4 -4
  134. package/src/components/Spreadsheet/index.md +42 -1
  135. package/src/components/Spreadsheet/index.module.less +4 -4
  136. package/src/components/Switch/index.md +33 -1
  137. package/src/components/TabBar/index.md +53 -1
  138. package/src/components/Table/_components/Pagination/index.module.less +23 -23
  139. package/src/components/Table/index.md +60 -1
  140. package/src/components/Table/index.module.less +61 -61
  141. package/src/components/Tags/index.md +23 -1
  142. package/src/components/TextEllipsis/index.md +29 -1
  143. package/src/components/Tree/index.md +66 -1
  144. package/src/components/Tree/index.module.less +11 -11
  145. package/src/components/Upload/index.md +72 -1
  146. package/src/components/Upload/index.module.less +3 -3
  147. package/src/styles/antd-overload.less +1 -1
@@ -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
  }
@@ -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,52 @@ 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>当前值:{value || "(空)"}</div>
40
+ </div>
41
+ );
42
+ };
43
+ ```
44
+
45
+ ## API
46
+
47
+ 在 [antd DatePickerProps](https://ant.design/components/date-picker-cn) 基础上扩展(重写了 `picker`、`onChange`):
48
+
49
+ | 属性 | 说明 | 类型 | 默认值 |
50
+ | --- | --- | --- | --- |
51
+ | picker | 日期选择粒度 | `'date' \| 'week' \| 'month' \| 'quarter' \| 'year' \| 'time'` | `'date'` |
52
+ | showPicker | 是否在前方显示粒度切换下拉框 | `boolean` | `false` |
53
+ | pickerHide | 在粒度下拉框中隐藏的选项 | `Picker[]` | `[]` |
54
+ | pickerSelectProps | 透传给粒度下拉框的 `Select` 属性 | `SelectProps` | - |
55
+ | pickerOptions | 自定义粒度下拉框的选项 | `SelectOption[]` | - |
56
+ | dataPickerCls | 内部日期选择器的自定义类名 | `string` | - |
57
+ | onChange | 值变化回调,返回格式化字符串与当前粒度 | `(date?: string, picker?: Picker) => void` | - |
58
+
59
+ > 另提供 `DatePicker.RangePicker`(区间选择,`onChange` 返回 `string[]`,同样支持 `picker` / `showPicker` 等)与 `DatePicker.StepPicker`(按 `step` 步进的日期选择,支持 `picker: 'day' \| 'month' \| 'year'`、`minDate` / `maxDate`)。
@@ -20,7 +20,7 @@
20
20
  min-width: 80px;
21
21
  }
22
22
 
23
- .ant-picker {
23
+ :global(.ant-picker) {
24
24
  height: 100%;
25
25
  width: 100%;
26
26
 
@@ -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
  }
@@ -8,10 +8,101 @@ title: Form 表单
8
8
 
9
9
  # Form 表单
10
10
 
11
- > `Form` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 配置驱动的表单集合,通过 `formItems` 描述表单项,提供弹窗表单、抽屉表单、导入表单三种形态及 `useForm`。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Form } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ `Form` 是一个命名空间对象,常用 `Form.Modal` 渲染弹窗表单,表单项通过 `formItems` 配置。点击下方按钮试试:
22
+
23
+ ```tsx
24
+ import React, { useState } from "react";
25
+ import { Form } from "@hsu-react/ui";
26
+ import { Button, message } from "antd";
27
+
28
+ export default () => {
29
+ const [open, setOpen] = useState(false);
30
+
31
+ const formItems = [
32
+ { type: "INPUT", name: "name", label: "姓名", required: true },
33
+ {
34
+ type: "SELECT",
35
+ name: "role",
36
+ label: "角色",
37
+ componentProps: {
38
+ options: [
39
+ { label: "管理员", value: "admin" },
40
+ { label: "访客", value: "guest" },
41
+ ],
42
+ },
43
+ },
44
+ {
45
+ type: "INPUTNUMBER",
46
+ name: "age",
47
+ label: "年龄",
48
+ componentProps: { min: 0, max: 120 },
49
+ },
50
+ { type: "SWITCH", name: "enabled", label: "启用" },
51
+ ];
52
+
53
+ return (
54
+ <>
55
+ <Button type="primary" onClick={() => setOpen(true)}>
56
+ 新增用户
57
+ </Button>
58
+ <Form.Modal
59
+ open={open}
60
+ title="新增用户"
61
+ formItems={formItems}
62
+ onOk={(data) => {
63
+ message.success("提交数据:" + JSON.stringify(data));
64
+ setOpen(false);
65
+ }}
66
+ onCancel={() => setOpen(false)}
67
+ />
68
+ </>
69
+ );
70
+ };
71
+ ```
72
+
73
+ ## API
74
+
75
+ `Form` 是一个对象,包含以下成员:
76
+
77
+ | 成员 | 说明 | 类型 |
78
+ | --- | --- | --- |
79
+ | Form.Modal | 弹窗表单 | `React.FC<ModalFormProps>` |
80
+ | Form.Drawer | 抽屉表单 | `React.FC<DrawerFormProps>` |
81
+ | Form.Import | 导入表单(上传文件) | `React.FC<ImportFormProps>` |
82
+ | Form.useForm | antd `Form.useForm`,创建表单实例 | `typeof AntdForm.useForm` |
83
+
84
+ ### Form.Modal(ModalFormProps)
85
+
86
+ 在 `Modal`(antd `ModalProps`,`onCancel` / `onOk` 已重写)基础上扩展:
87
+
88
+ | 属性 | 说明 | 类型 | 默认值 |
89
+ | --- | --- | --- | --- |
90
+ | formItems | 表单项配置;传对象时按分组渲染 | `FormItemProps[] \| Record<string, FormItemProps[]>` | `[]` |
91
+ | extraFormItems | 额外的自定义表单项节点 | `ExtraFormItem[]` | - |
92
+ | externalForm | 外部传入的表单实例 | `FormInstance` | - |
93
+ | value | 表单回填值 | `Record<string, unknown>` | - |
94
+ | onOk | 校验通过后的提交回调 | `(data, form: FormInstance) => void` | - |
95
+ | onCancel | 取消回调 | `() => void` | - |
96
+ | hasPermi | 权限码 | `string[]` | - |
97
+ | layout / formItemLayout | 表单 / 表单项布局方向 | `'horizontal' \| 'vertical'` | - |
98
+ | columnNum | 表单列数 | `number` | - |
99
+ | disabled | 是否禁用整个表单 | `boolean` | - |
100
+ | onValuesChange | 表单值变化回调 | `(value, values) => void` | - |
101
+
102
+ ### Form.Drawer(DrawerFormProps)
103
+
104
+ 在 antd `DrawerProps`(`onClose` 已重写)基础上扩展:`formItems`、`extraFormItems`、`externalForm`、`value`、`hasPermi`、`buttonGroup`(底部按钮组 `ButtonProps[]`)、`onClose`、`reset`。
105
+
106
+ ### Form.Import(ImportFormProps)
107
+
108
+ 在 `Modal`(`onCancel` / `onOk` 已重写)基础上扩展:`open`、`title`、`onCancel`、`uploadAction`(上传地址)、`template`(模板下载地址)、`templateName`、`hasPermi`、`formClassName`、`formItemClassName`、`uploadProps`。
@@ -18,7 +18,7 @@
18
18
 
19
19
  &.rect {
20
20
  > label {
21
- > span.ant-radio {
21
+ > span:global(.ant-radio) {
22
22
  width: 24px;
23
23
  min-width: 24px;
24
24
  height: 24px;
@@ -26,12 +26,12 @@
26
26
 
27
27
  border-radius: 2px;
28
28
 
29
- input[type="radio"].ant-radio-input {
29
+ input[type="radio"]:global(.ant-radio-input) {
30
30
  width: 100%;
31
31
  height: 100%;
32
32
  }
33
33
 
34
- .ant-radio-inner {
34
+ :global(.ant-radio-inner) {
35
35
  width: 100%;
36
36
  height: 100%;
37
37
 
@@ -65,8 +65,8 @@
65
65
  }
66
66
  }
67
67
 
68
- &.ant-radio-checked {
69
- .ant-radio-inner {
68
+ &:global(.ant-radio-checked) {
69
+ :global(.ant-radio-inner) {
70
70
  background: rgba(255, 255, 255, 1) !important;
71
71
 
72
72
  &::after {
@@ -77,8 +77,8 @@
77
77
  }
78
78
  }
79
79
 
80
- &.ant-radio-disabled {
81
- .ant-radio-inner {
80
+ &:global(.ant-radio-disabled) {
81
+ :global(.ant-radio-inner) {
82
82
  background: rgba(0, 0, 0, 0.04) !important;
83
83
 
84
84
  &::after {
@@ -86,8 +86,8 @@
86
86
  }
87
87
  }
88
88
 
89
- &.ant-radio-checked {
90
- .ant-radio-inner {
89
+ &:global(.ant-radio-checked) {
90
+ :global(.ant-radio-inner) {
91
91
  background: rgba(0, 0, 0, 0.04) !important;
92
92
  }
93
93
  }