@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,523 @@ 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
+ `FormItem` 通过 `type` 指定控件类型,业务参数统一放在 `componentProps` 中,需置于 antd `Form` 之内。下面按类型分别演示:
20
+
21
+ ## 输入框
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { FormItem } from "@hsu-react/ui";
26
+ import { Form } from "antd";
27
+
28
+ export default () => (
29
+ <Form>
30
+ <FormItem type="INPUT" name="input" label="输入框" />
31
+ </Form>
32
+ );
33
+ ```
34
+
35
+ ## 多行文本
36
+
37
+ ```tsx
38
+ import React from "react";
39
+ import { FormItem } from "@hsu-react/ui";
40
+ import { Form } from "antd";
41
+
42
+ export default () => (
43
+ <Form>
44
+ <FormItem type="TEXTAREA" name="textarea" label="多行文本" />
45
+ </Form>
46
+ );
47
+ ```
48
+
49
+ ## 密码
50
+
51
+ ```tsx
52
+ import React from "react";
53
+ import { FormItem } from "@hsu-react/ui";
54
+ import { Form } from "antd";
55
+
56
+ export default () => (
57
+ <Form>
58
+ <FormItem type="PASSWORD" name="password" label="密码" />
59
+ </Form>
60
+ );
61
+ ```
62
+
63
+ ## 密码强度
64
+
65
+ ```tsx
66
+ import React from "react";
67
+ import { FormItem } from "@hsu-react/ui";
68
+ import { Form } from "antd";
69
+
70
+ export default () => (
71
+ <Form>
72
+ <FormItem type="PASSWORDSTRENGTH" name="pwd" label="密码强度" />
73
+ </Form>
74
+ );
75
+ ```
76
+
77
+ ## 数字
78
+
79
+ ```tsx
80
+ import React from "react";
81
+ import { FormItem } from "@hsu-react/ui";
82
+ import { Form } from "antd";
83
+
84
+ export default () => (
85
+ <Form>
86
+ <FormItem
87
+ type="INPUTNUMBER"
88
+ name="number"
89
+ label="数字"
90
+ componentProps={{ min: 0, max: 100 }}
91
+ />
92
+ </Form>
93
+ );
94
+ ```
95
+
96
+ ## 范围输入
97
+
98
+ ```tsx
99
+ import React from "react";
100
+ import { FormItem } from "@hsu-react/ui";
101
+ import { Form } from "antd";
102
+
103
+ export default () => (
104
+ <Form>
105
+ <FormItem type="RANGEINPUT" name="range" label="范围输入" />
106
+ </Form>
107
+ );
108
+ ```
109
+
110
+ ## 滑块
111
+
112
+ ```tsx
113
+ import React from "react";
114
+ import { FormItem } from "@hsu-react/ui";
115
+ import { Form } from "antd";
116
+
117
+ export default () => (
118
+ <Form>
119
+ <FormItem type="SLIDER" name="slider" label="滑块" initialValue={30} />
120
+ </Form>
121
+ );
122
+ ```
123
+
124
+ ## 只读文本
125
+
126
+ ```tsx
127
+ import React from "react";
128
+ import { FormItem } from "@hsu-react/ui";
129
+ import { Form } from "antd";
130
+
131
+ export default () => (
132
+ <Form>
133
+ <FormItem
134
+ type="TEXT"
135
+ name="text"
136
+ label="只读文本"
137
+ initialValue="只读文本内容"
138
+ />
139
+ </Form>
140
+ );
141
+ ```
142
+
143
+ ## 自定义控件
144
+
145
+ ```tsx
146
+ import React from "react";
147
+ import { FormItem } from "@hsu-react/ui";
148
+ import { Form, Input } from "antd";
149
+
150
+ export default () => (
151
+ <Form>
152
+ <FormItem
153
+ type="AUTO"
154
+ name="auto"
155
+ label="自定义控件"
156
+ element={<Input placeholder="任意自定义控件" />}
157
+ />
158
+ </Form>
159
+ );
160
+ ```
161
+
162
+ ## 下拉选择
163
+
164
+ ```tsx
165
+ import React from "react";
166
+ import { FormItem } from "@hsu-react/ui";
167
+ import { Form } from "antd";
168
+
169
+ const options = [
170
+ { label: "选项一", value: "1" },
171
+ { label: "选项二", value: "2" },
172
+ { label: "选项三", value: "3" },
173
+ ];
174
+
175
+ export default () => (
176
+ <Form>
177
+ <FormItem
178
+ type="SELECT"
179
+ name="select"
180
+ label="选择器"
181
+ componentProps={{ options }}
182
+ />
183
+ </Form>
184
+ );
185
+ ```
186
+
187
+ ## 自动完成
188
+
189
+ ```tsx
190
+ import React from "react";
191
+ import { FormItem } from "@hsu-react/ui";
192
+ import { Form } from "antd";
193
+
194
+ const options = [
195
+ { label: "选项一", value: "1" },
196
+ { label: "选项二", value: "2" },
197
+ { label: "选项三", value: "3" },
198
+ ];
199
+
200
+ export default () => (
201
+ <Form>
202
+ <FormItem
203
+ type="AUTOCOMPLETESELECT"
204
+ name="ac"
205
+ label="自动完成"
206
+ componentProps={{ options }}
207
+ />
208
+ </Form>
209
+ );
210
+ ```
211
+
212
+ ## 树选择
213
+
214
+ ```tsx
215
+ import React from "react";
216
+ import { FormItem } from "@hsu-react/ui";
217
+ import { Form } from "antd";
218
+
219
+ const treeData = [
220
+ {
221
+ title: "父节点",
222
+ value: "0",
223
+ key: "0",
224
+ children: [
225
+ { title: "子节点 1", value: "0-1", key: "0-1" },
226
+ { title: "子节点 2", value: "0-2", key: "0-2" },
227
+ ],
228
+ },
229
+ ];
230
+
231
+ export default () => (
232
+ <Form>
233
+ <FormItem
234
+ type="TREESELECT"
235
+ name="treeSelect"
236
+ label="树选择"
237
+ componentProps={{ treeData }}
238
+ />
239
+ </Form>
240
+ );
241
+ ```
242
+
243
+ ## 图标选择
244
+
245
+ ```tsx
246
+ import React from "react";
247
+ import { FormItem } from "@hsu-react/ui";
248
+ import { Form } from "antd";
249
+
250
+ export default () => (
251
+ <Form>
252
+ <FormItem type="ICONSELECT" name="icon" label="图标选择" />
253
+ </Form>
254
+ );
255
+ ```
256
+
257
+ ## 分段控制
258
+
259
+ ```tsx
260
+ import React from "react";
261
+ import { FormItem } from "@hsu-react/ui";
262
+ import { Form } from "antd";
263
+
264
+ const options = [
265
+ { label: "选项一", value: "1" },
266
+ { label: "选项二", value: "2" },
267
+ { label: "选项三", value: "3" },
268
+ ];
269
+
270
+ export default () => (
271
+ <Form>
272
+ <FormItem
273
+ type="SEGMENTED"
274
+ name="segmented"
275
+ label="分段控制"
276
+ componentProps={{ options }}
277
+ />
278
+ </Form>
279
+ );
280
+ ```
281
+
282
+ ## 单选
283
+
284
+ ```tsx
285
+ import React from "react";
286
+ import { FormItem } from "@hsu-react/ui";
287
+ import { Form } from "antd";
288
+
289
+ const options = [
290
+ { label: "选项一", value: "1" },
291
+ { label: "选项二", value: "2" },
292
+ { label: "选项三", value: "3" },
293
+ ];
294
+
295
+ export default () => (
296
+ <Form>
297
+ <FormItem
298
+ type="RADIO"
299
+ name="radio"
300
+ label="单选"
301
+ componentProps={{ options }}
302
+ />
303
+ </Form>
304
+ );
305
+ ```
306
+
307
+ ## 单个多选框
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>
316
+ <FormItem type="CHECKBOX" name="checkbox" label="多选框" />
317
+ </Form>
318
+ );
319
+ ```
320
+
321
+ ## 多选组
322
+
323
+ ```tsx
324
+ import React from "react";
325
+ import { FormItem } from "@hsu-react/ui";
326
+ import { Form } from "antd";
327
+
328
+ const options = [
329
+ { label: "选项一", value: "1" },
330
+ { label: "选项二", value: "2" },
331
+ { label: "选项三", value: "3" },
332
+ ];
333
+
334
+ export default () => (
335
+ <Form>
336
+ <FormItem
337
+ type="CHECKBOXGROUP"
338
+ name="checkboxGroup"
339
+ label="多选组"
340
+ componentProps={{ options }}
341
+ />
342
+ </Form>
343
+ );
344
+ ```
345
+
346
+ ## 开关
347
+
348
+ ```tsx
349
+ import React from "react";
350
+ import { FormItem } from "@hsu-react/ui";
351
+ import { Form } from "antd";
352
+
353
+ export default () => (
354
+ <Form>
355
+ <FormItem type="SWITCH" name="switch" label="开关" />
356
+ </Form>
357
+ );
358
+ ```
359
+
360
+ ## 日期选择
361
+
362
+ ```tsx
363
+ import React from "react";
364
+ import { FormItem } from "@hsu-react/ui";
365
+ import { Form } from "antd";
366
+
367
+ export default () => (
368
+ <Form>
369
+ <FormItem type="DATEPICKER" name="date" label="日期" />
370
+ </Form>
371
+ );
372
+ ```
373
+
374
+ ## 日期范围
375
+
376
+ ```tsx
377
+ import React from "react";
378
+ import { FormItem } from "@hsu-react/ui";
379
+ import { Form } from "antd";
380
+
381
+ export default () => (
382
+ <Form>
383
+ <FormItem type="RANGEPICKER" name="dateRange" label="日期范围" />
384
+ </Form>
385
+ );
386
+ ```
387
+
388
+ ## 步进日期
389
+
390
+ ```tsx
391
+ import React from "react";
392
+ import { FormItem } from "@hsu-react/ui";
393
+ import { Form } from "antd";
394
+
395
+ export default () => (
396
+ <Form>
397
+ <FormItem type="STEPPICKER" name="step" label="步进日期" />
398
+ </Form>
399
+ );
400
+ ```
401
+
402
+ ## 树形控件
403
+
404
+ ```tsx
405
+ import React from "react";
406
+ import { FormItem } from "@hsu-react/ui";
407
+ import { Form } from "antd";
408
+
409
+ const treeData = [
410
+ {
411
+ title: "父节点",
412
+ value: "0",
413
+ key: "0",
414
+ children: [
415
+ { title: "子节点 1", value: "0-1", key: "0-1" },
416
+ { title: "子节点 2", value: "0-2", key: "0-2" },
417
+ ],
418
+ },
419
+ ];
420
+
421
+ export default () => (
422
+ <Form>
423
+ <FormItem
424
+ type="TREE"
425
+ name="tree"
426
+ label="树形控件"
427
+ componentProps={{ treeData }}
428
+ />
429
+ </Form>
430
+ );
431
+ ```
432
+
433
+ ## 富文本
434
+
435
+ ```tsx
436
+ import React from "react";
437
+ import { FormItem } from "@hsu-react/ui";
438
+ import { Form } from "antd";
439
+
440
+ export default () => (
441
+ <Form>
442
+ <FormItem type="EDITOR" name="editor" label="富文本" />
443
+ </Form>
444
+ );
445
+ ```
446
+
447
+ ## 代码
448
+
449
+ ```tsx
450
+ import React from "react";
451
+ import { FormItem } from "@hsu-react/ui";
452
+ import { Form } from "antd";
453
+
454
+ export default () => (
455
+ <Form>
456
+ <FormItem
457
+ type="CODEMIRROR"
458
+ name="code"
459
+ label="代码"
460
+ componentProps={{ language: "json" }}
461
+ />
462
+ </Form>
463
+ );
464
+ ```
465
+
466
+ ## 文件上传
467
+
468
+ ```tsx
469
+ import React from "react";
470
+ import { FormItem } from "@hsu-react/ui";
471
+ import { Form } from "antd";
472
+
473
+ export default () => (
474
+ <Form>
475
+ <FormItem
476
+ type="FILE"
477
+ name="file"
478
+ label="文件上传"
479
+ componentProps={{ action: "/api/upload" }}
480
+ />
481
+ </Form>
482
+ );
483
+ ```
484
+
485
+ ## 图片上传
486
+
487
+ ```tsx
488
+ import React from "react";
489
+ import { FormItem } from "@hsu-react/ui";
490
+ import { Form } from "antd";
491
+
492
+ export default () => (
493
+ <Form>
494
+ <FormItem
495
+ type="IMAGEFILE"
496
+ name="image"
497
+ label="图片上传"
498
+ componentProps={{ action: "/api/upload" }}
499
+ />
500
+ </Form>
501
+ );
502
+ ```
503
+
504
+ ## API
505
+
506
+ `FormItemProps` 是按 `type` 区分的联合类型:`{ type } & BaseFormItem & 对应控件 Props`。除 `type`、`visible` 外,其余通用属性继承自 `ItemContainerProps`(扩展自 antd `FormItemProps`),各控件的专有参数通过 `componentProps` 传入。
507
+
508
+ | 属性 | 说明 | 类型 | 默认值 |
509
+ | -------------- | ------------------------------------------------------ | ---------------------------- | -------------- |
510
+ | type | 表单项类型,决定渲染的控件 | `FormItemType` | - |
511
+ | visible | 是否渲染该项,为 `false` 时不渲染 | `boolean` | `true` |
512
+ | name | 字段名(antd Form 字段) | `NamePath` | - |
513
+ | label | 标签内容 | `ReactNode` | - |
514
+ | componentProps | 透传给底层控件的属性(如 `options`、`placeholder` 等) | 对应控件 Props | - |
515
+ | labelWidth | 标签宽度 | `string \| number` | - |
516
+ | layout | 标签与控件的排列方向 | `'horizontal' \| 'vertical'` | `'horizontal'` |
517
+ | requiredMsg | 必填校验提示文案 | `string` | - |
518
+ | tips | 标签旁的提示气泡(antd `TooltipProps` + 图标配置) | `TipsProps & TooltipProps` | - |
519
+ | hasPermi | 权限码;无权限时不渲染 | `string[]` | - |
520
+ | disabled | 是否禁用 | `boolean` | - |
521
+ | en | 是否使用英文占位文案 | `boolean` | - |
522
+ | hideLabel | 是否隐藏标签 | `boolean` | `false` |
523
+
524
+ `type` 可选值(`FormItemType`):
525
+
526
+ - 输入类:`AUTO`、`INPUT`、`TEXTAREA`、`PASSWORD`、`PASSWORDSTRENGTH`、`INPUTNUMBER`、`RANGEINPUT`、`SLIDER`、`EDITOR`、`CODEMIRROR`、`TEXT`
527
+ - 选择类:`SELECT`、`TREESELECT`、`AUTOCOMPLETESELECT`、`SEGMENTED`、`SWITCH`、`RADIO`、`CHECKBOX`、`CHECKBOXGROUP`、`DATEPICKER`、`RANGEPICKER`、`STEPPICKER`、`TREE`、`ICONSELECT`
528
+ - 上传类:`FILE`、`IMAGEFILE`
529
+
530
+ > 同时导出 `FormItemContainer`(即 `ItemContainer`)及类型 `FormItemType`、`FormItemProps`、`PlaceholderDict` / `PlaceholderDictEn` 占位文案字典。
@@ -16,20 +16,40 @@ title: Icon 图标
16
16
  import { Icon } from "@hsu-react/ui";
17
17
  ```
18
18
 
19
- ## 基础用法
19
+ ## antd 图标
20
+
21
+ antd 图标名(驼峰):
20
22
 
21
23
  ```tsx
22
24
  import React from "react";
23
25
  import { Icon } from "@hsu-react/ui";
24
- import { Space } from "antd";
25
26
 
26
27
  export default () => (
27
- <Space size="large" style={{ fontSize: 22 }}>
28
+ <div style={{ display: "flex", gap: 20, alignItems: "center", fontSize: 22 }}>
28
29
  <Icon icon="UserOutlined" />
29
30
  <Icon icon="SettingOutlined" />
30
31
  <Icon icon="HomeOutlined" />
31
32
  <Icon icon="HeartFilled" style={{ color: "#eb2f96" }} />
32
- </Space>
33
+ </div>
34
+ );
35
+ ```
36
+
37
+ ## iconify 图标
38
+
39
+ iconify 图标名(`集合:名称`,需先注册对应图标集):
40
+
41
+ ```tsx
42
+ import React from "react";
43
+ import { Icon } from "@hsu-react/ui";
44
+
45
+ export default () => (
46
+ <div style={{ display: "flex", gap: 20, alignItems: "center", fontSize: 22 }}>
47
+ <Icon icon="ph:user-bold" />
48
+ <Icon icon="mdi:home" />
49
+ <Icon icon="tabler:settings" />
50
+ <Icon icon="solar:heart-bold" style={{ color: "#eb2f96" }} />
51
+ <Icon icon="carbon:document" />
52
+ </div>
33
53
  );
34
54
  ```
35
55
 
@@ -4,7 +4,7 @@ import {
4
4
  IconProps as IconifyProps,
5
5
  } from "@iconify/react";
6
6
 
7
- import AntdIcon, * as AntdIcons from "@ant-design/icons";
7
+ import * as AntdIcons from "@ant-design/icons";
8
8
  import React, { useEffect, useRef } from "react";
9
9
  import classNames from "classnames";
10
10
  import styles from "./index.module.less";
@@ -74,46 +74,18 @@ const Icon: React.FC<IconProps> = (props) => {
74
74
  );
75
75
  }
76
76
 
77
+ // iconify 图标:直接用 span 承载 Iconify 自带的 svg,避免把它嵌套进 antd Icon
78
+ // 的 svg(其 viewBox 会把内层 svg 缩放成极小值导致图标不可见)。
77
79
  return (
78
- <AntdIcon
80
+ <span
79
81
  {...iconConfig}
80
- // 与 antd 缺省值一致;显式传入以消除开发态 viewBox 告警(子节点是 Iconify 自带 viewBox 的 svg)
81
- viewBox="0 0 1024 1024"
82
- className={classNames([styles.icon, className])}
82
+ role="img"
83
+ ref={ref as unknown as React.Ref<HTMLSpanElement>}
84
+ className={classNames(["anticon", styles.icon, className])}
83
85
  style={mergedStyle}
84
- ref={ref}
85
86
  >
86
- <Iconify
87
- {...iconProps}
88
- icon={icon}
89
- width="1em"
90
- height="1em"
91
- onLoad={() => {
92
- setTimeout(() => {
93
- if (ref.current) {
94
- const svg = ref.current.childNodes[0] as SVGSVGElement;
95
- const svg_i = svg.childNodes[0] as SVGSVGElement;
96
-
97
- const { height } = svg.getBoundingClientRect();
98
- const { height: height_i } = svg_i.getBoundingClientRect();
99
-
100
- const viewBox_i = svg_i.getAttribute("viewBox");
101
- const viewBox_i_height = viewBox_i?.split(" ")[3];
102
-
103
- if (Number(viewBox_i_height) <= 24) return;
104
-
105
- const y_i =
106
- Number(viewBox_i_height) - (Number(height) - Number(height_i));
107
-
108
- svg_i.setAttribute(
109
- "viewBox",
110
- `0 0 ${viewBox_i?.split(" ")[2]} ${y_i.toFixed(0)}`
111
- );
112
- }
113
- }, 1);
114
- }}
115
- />
116
- </AntdIcon>
87
+ <Iconify {...iconProps} icon={icon} width="1em" height="1em" />
88
+ </span>
117
89
  );
118
90
  };
119
91
 
@@ -10,22 +10,22 @@
10
10
  width: 100%;
11
11
  height: 100%;
12
12
 
13
- .ant-input-number-wrapper {
13
+ :global(.ant-input-number-wrapper) {
14
14
  height: 100%;
15
15
  min-height: inherit;
16
16
 
17
- > .ant-input-number,
18
- > .ant-input-number-affix-wrapper {
17
+ > :global(.ant-input-number),
18
+ > :global(.ant-input-number-affix-wrapper) {
19
19
  height: 100%;
20
20
  min-height: inherit;
21
21
  }
22
22
 
23
- > .ant-input-number {
24
- > .ant-input-number-input-wrap {
23
+ > :global(.ant-input-number) {
24
+ > :global(.ant-input-number-input-wrap) {
25
25
  height: 100%;
26
26
  min-height: inherit;
27
27
 
28
- > .ant-input-number-input {
28
+ > :global(.ant-input-number-input) {
29
29
  height: 100%;
30
30
  min-height: inherit;
31
31
  }
@@ -33,11 +33,11 @@
33
33
  }
34
34
  }
35
35
 
36
- > .ant-input-number-input-wrap {
36
+ > :global(.ant-input-number-input-wrap) {
37
37
  height: 100%;
38
38
  min-height: inherit;
39
39
 
40
- > .ant-input-number-input {
40
+ > :global(.ant-input-number-input) {
41
41
  height: 100%;
42
42
  }
43
43
  }
@@ -66,7 +66,7 @@
66
66
  }
67
67
 
68
68
  // 当存在 addonAfter 时,调整清除图标位置
69
- // Ant Design 的 addonAfter 会生成 .ant-input-number-group-addon
69
+ // Ant Design 的 addonAfter 会生成 :global(.ant-input-number-group-addon)
70
70
  // 清除图标需要向左偏移,避免与 addon 重叠
71
71
  // 使用 CSS 变量来动态设置 addon 宽度,默认值 60px 是合理的估算
72
72
  // 通过 JS 动态计算实际宽度并设置 CSS 变量来覆盖
@@ -2,12 +2,12 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
 
5
- .ant-input-wrapper {
5
+ :global(.ant-input-wrapper) {
6
6
  height: 100%;
7
7
  min-height: inherit;
8
8
 
9
- > .ant-input,
10
- > .ant-input-affix-wrapper {
9
+ > :global(.ant-input),
10
+ > :global(.ant-input-affix-wrapper) {
11
11
  height: 100%;
12
12
  min-height: inherit;
13
13
  }