@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
@@ -3,7 +3,7 @@
3
3
 
4
4
  color: var(--cf-text);
5
5
 
6
- .ant-segmented-group {
6
+ :global(.ant-segmented-group) {
7
7
  height: 100%;
8
8
 
9
9
  font-family: inherit;
@@ -17,7 +17,7 @@
17
17
  font-weight: inherit;
18
18
  color: inherit;
19
19
 
20
- .ant-segmented-item-label {
20
+ :global(.ant-segmented-item-label) {
21
21
  display: flex;
22
22
  align-items: center;
23
23
  justify-content: center;
@@ -1,7 +1,7 @@
1
1
  .upload {
2
2
  height: 100%;
3
3
 
4
- .ant-upload {
4
+ :global(.ant-upload) {
5
5
  height: max-content;
6
6
 
7
7
  .upBtn {
@@ -15,7 +15,7 @@
15
15
  column-gap: 10px;
16
16
  }
17
17
 
18
- .ant-upload-disabled {
18
+ :global(.ant-upload-disabled) {
19
19
  .singleFile {
20
20
  cursor: not-allowed;
21
21
 
@@ -97,7 +97,7 @@
97
97
  }
98
98
  }
99
99
 
100
- &.ant-upload-drag {
100
+ &:global(.ant-upload-drag) {
101
101
  height: 180px;
102
102
 
103
103
  border-radius: 8px;
@@ -134,7 +134,7 @@
134
134
  }
135
135
 
136
136
  .FormUpload {
137
- .ant-form-item-control-input-content {
137
+ :global(.ant-form-item-control-input-content) {
138
138
  > span {
139
139
  width: 100%;
140
140
  }
@@ -19,15 +19,15 @@
19
19
  cursor: pointer;
20
20
  }
21
21
 
22
- .ant-picker {
22
+ :global(.ant-picker) {
23
23
  width: 100%;
24
24
  }
25
25
 
26
- .ant-form-item-row {
26
+ :global(.ant-form-item-row) {
27
27
  width: 100%;
28
28
  height: 100%;
29
29
 
30
- .ant-form-item-control {
30
+ :global(.ant-form-item-control) {
31
31
  display: flex;
32
32
  flex-direction: column;
33
33
  row-gap: 5px;
@@ -35,11 +35,11 @@
35
35
  width: var(--input-width) !important;
36
36
  max-width: 100%;
37
37
 
38
- .ant-form-item-control-input {
38
+ :global(.ant-form-item-control-input) {
39
39
  height: var(--input-height);
40
40
  min-height: var(--input-min-height);
41
41
 
42
- .ant-form-item-control-input-content {
42
+ :global(.ant-form-item-control-input-content) {
43
43
  display: flex;
44
44
  align-items: center;
45
45
 
@@ -54,7 +54,7 @@
54
54
  }
55
55
  }
56
56
 
57
- .ant-form-item-label {
57
+ :global(.ant-form-item-label) {
58
58
  flex: 0 1 auto !important;
59
59
  display: inline-flex;
60
60
  align-items: center;
@@ -156,7 +156,7 @@
156
156
  cursor: pointer;
157
157
  }
158
158
 
159
- &.ant-form-item-no-colon {
159
+ &:global(.ant-form-item-no-colon) {
160
160
  .label {
161
161
  &::after {
162
162
  content: none;
@@ -175,7 +175,7 @@
175
175
  content: none !important;
176
176
  }
177
177
 
178
- &.ant-form-item-required {
178
+ &:global(.ant-form-item-required) {
179
179
  .label {
180
180
  &::before {
181
181
  content: "*";
@@ -212,7 +212,7 @@
212
212
  }
213
213
 
214
214
  &.after {
215
- label.ant-form-item-required {
215
+ label:global(.ant-form-item-required) {
216
216
  .label {
217
217
  &::before {
218
218
  content: none !important;
@@ -241,7 +241,7 @@
241
241
  }
242
242
 
243
243
  &.hasLabelContent {
244
- label.ant-form-item-required {
244
+ label:global(.ant-form-item-required) {
245
245
  &::after {
246
246
  content: none;
247
247
  }
@@ -266,7 +266,7 @@
266
266
  }
267
267
 
268
268
  &.hideRequired {
269
- label.ant-form-item-required {
269
+ label:global(.ant-form-item-required) {
270
270
  .label {
271
271
  &::before {
272
272
  content: none !important;
@@ -281,7 +281,7 @@
281
281
  }
282
282
 
283
283
  &.after {
284
- label.ant-form-item-required {
284
+ label:global(.ant-form-item-required) {
285
285
  .label {
286
286
  &::after {
287
287
  content: none !important;
@@ -292,11 +292,11 @@
292
292
  }
293
293
 
294
294
  &.horizontal {
295
- .ant-form-item-row {
295
+ :global(.ant-form-item-row) {
296
296
  flex-wrap: nowrap;
297
297
  column-gap: 5px;
298
298
 
299
- .ant-form-item-control {
299
+ :global(.ant-form-item-control) {
300
300
  flex: 1 !important;
301
301
  flex-grow: var(--input-horizontal-flex-grow) !important;
302
302
 
@@ -305,13 +305,13 @@
305
305
  }
306
306
 
307
307
  &.start {
308
- .ant-form-item-control-input-content {
308
+ :global(.ant-form-item-control-input-content) {
309
309
  text-align: left;
310
310
  }
311
311
  }
312
312
 
313
313
  &.between {
314
- .ant-form-item-control-input-content {
314
+ :global(.ant-form-item-control-input-content) {
315
315
  text-align: right;
316
316
  }
317
317
  }
@@ -320,13 +320,13 @@
320
320
  &.vertical {
321
321
  --label-height: max-content;
322
322
 
323
- .ant-form-item-row {
323
+ :global(.ant-form-item-row) {
324
324
  flex-direction: column;
325
325
  row-gap: 5px;
326
326
 
327
327
  height: max-content;
328
328
 
329
- .ant-form-item-label {
329
+ :global(.ant-form-item-label) {
330
330
  text-align: start;
331
331
 
332
332
  width: 100%;
@@ -353,7 +353,7 @@
353
353
  }
354
354
  }
355
355
 
356
- .ant-form-item-control {
356
+ :global(.ant-form-item-control) {
357
357
  flex: 0 1 auto !important;
358
358
  display: flex;
359
359
  flex-direction: column;
@@ -364,8 +364,8 @@
364
364
  }
365
365
 
366
366
  &.legacyHasLabelExtra {
367
- .ant-form-item-row {
368
- .ant-form-item-label {
367
+ :global(.ant-form-item-row) {
368
+ :global(.ant-form-item-label) {
369
369
  label {
370
370
  flex-direction: column;
371
371
  flex-wrap: nowrap;
@@ -380,7 +380,7 @@
380
380
  }
381
381
 
382
382
  &.hideAdditiona {
383
- .ant-form-item-additional {
383
+ :global(.ant-form-item-additional) {
384
384
  display: none;
385
385
  }
386
386
  }
@@ -8,10 +8,468 @@ title: FormItem 表单项
8
8
 
9
9
  # FormItem 表单项
10
10
 
11
- > `FormItem` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 通过 `type` 字段驱动的统一表单项组件,根据类型渲染对应的输入 / 选择 / 上传等控件,需配合 antd `Form` 使用。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { FormItem } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ `FormItem` 通过 `type` 指定控件类型,业务参数统一放在 `componentProps` 中,需置于 antd `Form` 之内。下面按类型分别演示:
22
+
23
+ ### 输入类
24
+
25
+ #### INPUT 输入框
26
+
27
+ ```tsx
28
+ import React from "react";
29
+ import { FormItem } from "@hsu-react/ui";
30
+ import { Form } from "antd";
31
+
32
+ export default () => (
33
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
34
+ <FormItem type="INPUT" name="input" label="输入框" required />
35
+ </Form>
36
+ );
37
+ ```
38
+
39
+ #### TEXTAREA 多行文本
40
+
41
+ ```tsx
42
+ import React from "react";
43
+ import { FormItem } from "@hsu-react/ui";
44
+ import { Form } from "antd";
45
+
46
+ export default () => (
47
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
48
+ <FormItem type="TEXTAREA" name="textarea" label="多行文本" />
49
+ </Form>
50
+ );
51
+ ```
52
+
53
+ #### PASSWORD 密码
54
+
55
+ ```tsx
56
+ import React from "react";
57
+ import { FormItem } from "@hsu-react/ui";
58
+ import { Form } from "antd";
59
+
60
+ export default () => (
61
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
62
+ <FormItem type="PASSWORD" name="password" label="密码" />
63
+ </Form>
64
+ );
65
+ ```
66
+
67
+ #### PASSWORDSTRENGTH 密码强度
68
+
69
+ ```tsx
70
+ import React from "react";
71
+ import { FormItem } from "@hsu-react/ui";
72
+ import { Form } from "antd";
73
+
74
+ export default () => (
75
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
76
+ <FormItem type="PASSWORDSTRENGTH" name="pwd" label="密码强度" />
77
+ </Form>
78
+ );
79
+ ```
80
+
81
+ #### INPUTNUMBER 数字
82
+
83
+ ```tsx
84
+ import React from "react";
85
+ import { FormItem } from "@hsu-react/ui";
86
+ import { Form } from "antd";
87
+
88
+ export default () => (
89
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
90
+ <FormItem type="INPUTNUMBER" name="number" label="数字" componentProps={{ min: 0, max: 100 }} />
91
+ </Form>
92
+ );
93
+ ```
94
+
95
+ #### RANGEINPUT 范围输入
96
+
97
+ ```tsx
98
+ import React from "react";
99
+ import { FormItem } from "@hsu-react/ui";
100
+ import { Form } from "antd";
101
+
102
+ export default () => (
103
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
104
+ <FormItem type="RANGEINPUT" name="range" label="范围输入" />
105
+ </Form>
106
+ );
107
+ ```
108
+
109
+ #### SLIDER 滑块
110
+
111
+ ```tsx
112
+ import React from "react";
113
+ import { FormItem } from "@hsu-react/ui";
114
+ import { Form } from "antd";
115
+
116
+ export default () => (
117
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
118
+ <FormItem type="SLIDER" name="slider" label="滑块" />
119
+ </Form>
120
+ );
121
+ ```
122
+
123
+ #### TEXT 只读文本
124
+
125
+ ```tsx
126
+ import React from "react";
127
+ import { FormItem } from "@hsu-react/ui";
128
+ import { Form } from "antd";
129
+
130
+ export default () => (
131
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
132
+ <FormItem type="TEXT" name="text" label="只读文本" componentProps={{ value: "只读文本内容" }} />
133
+ </Form>
134
+ );
135
+ ```
136
+
137
+ #### AUTO 自定义控件
138
+
139
+ ```tsx
140
+ import React from "react";
141
+ import { FormItem } from "@hsu-react/ui";
142
+ import { Form, Input } from "antd";
143
+
144
+ export default () => (
145
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
146
+ <FormItem type="AUTO" name="auto" label="自定义控件" element={<Input placeholder="任意自定义控件" />} />
147
+ </Form>
148
+ );
149
+ ```
150
+
151
+ ### 选择类
152
+
153
+ #### SELECT 选择器
154
+
155
+ ```tsx
156
+ import React from "react";
157
+ import { FormItem } from "@hsu-react/ui";
158
+ import { Form } from "antd";
159
+
160
+ const options = [
161
+ { label: "选项一", value: "1" },
162
+ { label: "选项二", value: "2" },
163
+ { label: "选项三", value: "3" },
164
+ ];
165
+
166
+ export default () => (
167
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
168
+ <FormItem type="SELECT" name="select" label="选择器" componentProps={{ options }} />
169
+ </Form>
170
+ );
171
+ ```
172
+
173
+ #### AUTOCOMPLETESELECT 自动完成
174
+
175
+ ```tsx
176
+ import React from "react";
177
+ import { FormItem } from "@hsu-react/ui";
178
+ import { Form } from "antd";
179
+
180
+ const options = [
181
+ { label: "选项一", value: "1" },
182
+ { label: "选项二", value: "2" },
183
+ { label: "选项三", value: "3" },
184
+ ];
185
+
186
+ export default () => (
187
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
188
+ <FormItem type="AUTOCOMPLETESELECT" name="ac" label="自动完成" componentProps={{ options }} />
189
+ </Form>
190
+ );
191
+ ```
192
+
193
+ #### TREESELECT 树选择
194
+
195
+ ```tsx
196
+ import React from "react";
197
+ import { FormItem } from "@hsu-react/ui";
198
+ import { Form } from "antd";
199
+
200
+ const treeData = [
201
+ {
202
+ title: "父节点",
203
+ value: "0",
204
+ key: "0",
205
+ children: [
206
+ { title: "子节点 1", value: "0-1", key: "0-1" },
207
+ { title: "子节点 2", value: "0-2", key: "0-2" },
208
+ ],
209
+ },
210
+ ];
211
+
212
+ export default () => (
213
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
214
+ <FormItem type="TREESELECT" name="treeSelect" label="树选择" componentProps={{ treeData }} />
215
+ </Form>
216
+ );
217
+ ```
218
+
219
+ #### ICONSELECT 图标选择
220
+
221
+ ```tsx
222
+ import React from "react";
223
+ import { FormItem } from "@hsu-react/ui";
224
+ import { Form } from "antd";
225
+
226
+ export default () => (
227
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
228
+ <FormItem type="ICONSELECT" name="icon" label="图标选择" />
229
+ </Form>
230
+ );
231
+ ```
232
+
233
+ #### SEGMENTED 分段控制
234
+
235
+ ```tsx
236
+ import React from "react";
237
+ import { FormItem } from "@hsu-react/ui";
238
+ import { Form } from "antd";
239
+
240
+ const options = [
241
+ { label: "选项一", value: "1" },
242
+ { label: "选项二", value: "2" },
243
+ { label: "选项三", value: "3" },
244
+ ];
245
+
246
+ export default () => (
247
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
248
+ <FormItem type="SEGMENTED" name="segmented" label="分段控制" componentProps={{ options }} />
249
+ </Form>
250
+ );
251
+ ```
252
+
253
+ #### RADIO 单选
254
+
255
+ ```tsx
256
+ import React from "react";
257
+ import { FormItem } from "@hsu-react/ui";
258
+ import { Form } from "antd";
259
+
260
+ const options = [
261
+ { label: "选项一", value: "1" },
262
+ { label: "选项二", value: "2" },
263
+ { label: "选项三", value: "3" },
264
+ ];
265
+
266
+ export default () => (
267
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
268
+ <FormItem type="RADIO" name="radio" label="单选" componentProps={{ options }} />
269
+ </Form>
270
+ );
271
+ ```
272
+
273
+ #### CHECKBOX 单个多选框
274
+
275
+ ```tsx
276
+ import React from "react";
277
+ import { FormItem } from "@hsu-react/ui";
278
+ import { Form } from "antd";
279
+
280
+ export default () => (
281
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
282
+ <FormItem type="CHECKBOX" name="checkbox" label="多选框" />
283
+ </Form>
284
+ );
285
+ ```
286
+
287
+ #### CHECKBOXGROUP 多选组
288
+
289
+ ```tsx
290
+ import React from "react";
291
+ import { FormItem } from "@hsu-react/ui";
292
+ import { Form } from "antd";
293
+
294
+ const options = [
295
+ { label: "选项一", value: "1" },
296
+ { label: "选项二", value: "2" },
297
+ { label: "选项三", value: "3" },
298
+ ];
299
+
300
+ export default () => (
301
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
302
+ <FormItem type="CHECKBOXGROUP" name="checkboxGroup" label="多选组" componentProps={{ options }} />
303
+ </Form>
304
+ );
305
+ ```
306
+
307
+ #### SWITCH 开关
308
+
309
+ ```tsx
310
+ import React from "react";
311
+ import { FormItem } from "@hsu-react/ui";
312
+ import { Form } from "antd";
313
+
314
+ export default () => (
315
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
316
+ <FormItem type="SWITCH" name="switch" label="开关" />
317
+ </Form>
318
+ );
319
+ ```
320
+
321
+ #### DATEPICKER 日期
322
+
323
+ ```tsx
324
+ import React from "react";
325
+ import { FormItem } from "@hsu-react/ui";
326
+ import { Form } from "antd";
327
+
328
+ export default () => (
329
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
330
+ <FormItem type="DATEPICKER" name="date" label="日期" />
331
+ </Form>
332
+ );
333
+ ```
334
+
335
+ #### RANGEPICKER 日期范围
336
+
337
+ ```tsx
338
+ import React from "react";
339
+ import { FormItem } from "@hsu-react/ui";
340
+ import { Form } from "antd";
341
+
342
+ export default () => (
343
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
344
+ <FormItem type="RANGEPICKER" name="dateRange" label="日期范围" />
345
+ </Form>
346
+ );
347
+ ```
348
+
349
+ #### STEPPICKER 步进日期
350
+
351
+ ```tsx
352
+ import React from "react";
353
+ import { FormItem } from "@hsu-react/ui";
354
+ import { Form } from "antd";
355
+
356
+ export default () => (
357
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
358
+ <FormItem type="STEPPICKER" name="step" label="步进日期" />
359
+ </Form>
360
+ );
361
+ ```
362
+
363
+ #### TREE 树形控件
364
+
365
+ ```tsx
366
+ import React from "react";
367
+ import { FormItem } from "@hsu-react/ui";
368
+ import { Form } from "antd";
369
+
370
+ const treeData = [
371
+ {
372
+ title: "父节点",
373
+ value: "0",
374
+ key: "0",
375
+ children: [
376
+ { title: "子节点 1", value: "0-1", key: "0-1" },
377
+ { title: "子节点 2", value: "0-2", key: "0-2" },
378
+ ],
379
+ },
380
+ ];
381
+
382
+ export default () => (
383
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
384
+ <FormItem type="TREE" name="tree" label="树形控件" componentProps={{ treeData }} />
385
+ </Form>
386
+ );
387
+ ```
388
+
389
+ ### 富文本 / 代码
390
+
391
+ #### EDITOR 富文本
392
+
393
+ ```tsx
394
+ import React from "react";
395
+ import { FormItem } from "@hsu-react/ui";
396
+ import { Form } from "antd";
397
+
398
+ export default () => (
399
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
400
+ <FormItem type="EDITOR" name="editor" label="富文本" />
401
+ </Form>
402
+ );
403
+ ```
404
+
405
+ #### CODEMIRROR 代码
406
+
407
+ ```tsx
408
+ import React from "react";
409
+ import { FormItem } from "@hsu-react/ui";
410
+ import { Form } from "antd";
411
+
412
+ export default () => (
413
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
414
+ <FormItem type="CODEMIRROR" name="code" label="代码" componentProps={{ language: "json" }} />
415
+ </Form>
416
+ );
417
+ ```
418
+
419
+ ### 上传类
420
+
421
+ #### FILE 文件上传
422
+
423
+ ```tsx
424
+ import React from "react";
425
+ import { FormItem } from "@hsu-react/ui";
426
+ import { Form } from "antd";
427
+
428
+ export default () => (
429
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
430
+ <FormItem type="FILE" name="file" label="文件上传" componentProps={{ action: "/api/upload" }} />
431
+ </Form>
432
+ );
433
+ ```
434
+
435
+ #### IMAGEFILE 图片上传
436
+
437
+ ```tsx
438
+ import React from "react";
439
+ import { FormItem } from "@hsu-react/ui";
440
+ import { Form } from "antd";
441
+
442
+ export default () => (
443
+ <Form layout="vertical" style={{ maxWidth: 420 }}>
444
+ <FormItem type="IMAGEFILE" name="image" label="图片上传" componentProps={{ action: "/api/upload" }} />
445
+ </Form>
446
+ );
447
+ ```
448
+
449
+ ## API
450
+
451
+ `FormItemProps` 是按 `type` 区分的联合类型:`{ type } & BaseFormItem & 对应控件 Props`。除 `type`、`visible` 外,其余通用属性继承自 `ItemContainerProps`(扩展自 antd `FormItemProps`),各控件的专有参数通过 `componentProps` 传入。
452
+
453
+ | 属性 | 说明 | 类型 | 默认值 |
454
+ | --- | --- | --- | --- |
455
+ | type | 表单项类型,决定渲染的控件 | `FormItemType` | - |
456
+ | visible | 是否渲染该项,为 `false` 时不渲染 | `boolean` | `true` |
457
+ | name | 字段名(antd Form 字段) | `NamePath` | - |
458
+ | label | 标签内容 | `ReactNode` | - |
459
+ | componentProps | 透传给底层控件的属性(如 `options`、`placeholder` 等) | 对应控件 Props | - |
460
+ | labelWidth | 标签宽度 | `string \| number` | - |
461
+ | layout | 标签与控件的排列方向 | `'horizontal' \| 'vertical'` | `'horizontal'` |
462
+ | requiredMsg | 必填校验提示文案 | `string` | - |
463
+ | tips | 标签旁的提示气泡(antd `TooltipProps` + 图标配置) | `TipsProps & TooltipProps` | - |
464
+ | hasPermi | 权限码;无权限时不渲染 | `string[]` | - |
465
+ | disabled | 是否禁用 | `boolean` | - |
466
+ | en | 是否使用英文占位文案 | `boolean` | - |
467
+ | hideLabel | 是否隐藏标签 | `boolean` | `false` |
468
+
469
+ `type` 可选值(`FormItemType`):
470
+
471
+ - 输入类:`AUTO`、`INPUT`、`TEXTAREA`、`PASSWORD`、`PASSWORDSTRENGTH`、`INPUTNUMBER`、`RANGEINPUT`、`SLIDER`、`EDITOR`、`CODEMIRROR`、`TEXT`
472
+ - 选择类:`SELECT`、`TREESELECT`、`AUTOCOMPLETESELECT`、`SEGMENTED`、`SWITCH`、`RADIO`、`CHECKBOX`、`CHECKBOXGROUP`、`DATEPICKER`、`RANGEPICKER`、`STEPPICKER`、`TREE`、`ICONSELECT`
473
+ - 上传类:`FILE`、`IMAGEFILE`
474
+
475
+ > 同时导出 `FormItemContainer`(即 `ItemContainer`)及类型 `FormItemType`、`FormItemProps`、`PlaceholderDict` / `PlaceholderDictEn` 占位文案字典。