@@ -18,6 +18,50 @@ function pickerDefined(obj) {
18
18
function preventDefault ( e ) {
19
19
e . preventDefault ( ) ;
20
20
}
21
+ const getNewChildren = ( children , props ) => {
22
+ const {
23
+ size,
24
+ device,
25
+ labelAlign,
26
+ labelTextAlign,
27
+ labelCol,
28
+ wrapperCol,
29
+ responsive,
30
+ } = props ;
31
+
32
+ return React . Children . map ( children , child => {
33
+ if ( obj . isReactFragment ( child ) ) {
34
+ return getNewChildren ( child . props . children , props ) ;
35
+ }
36
+
37
+ if (
38
+ child &&
39
+ typeof child . type === 'function' &&
40
+ child . type . _typeMark === 'form_item'
41
+ ) {
42
+ const childrenProps = {
43
+ labelCol : child . props . labelCol
44
+ ? child . props . labelCol
45
+ : labelCol ,
46
+ wrapperCol : child . props . wrapperCol
47
+ ? child . props . wrapperCol
48
+ : wrapperCol ,
49
+ labelAlign : child . props . labelAlign
50
+ ? child . props . labelAlign
51
+ : device === 'phone'
52
+ ? 'top'
53
+ : labelAlign ,
54
+ labelTextAlign : child . props . labelTextAlign
55
+ ? child . props . labelTextAlign
56
+ : labelTextAlign ,
57
+ size : child . props . size ? child . props . size : size ,
58
+ responsive : responsive ,
59
+ } ;
60
+ return React . cloneElement ( child , pickerDefined ( childrenProps ) ) ;
61
+ }
62
+ return child ;
63
+ } ) ;
64
+ } ;
21
65
22
66
/** Form */
23
67
export default class Form extends React . Component {
@@ -214,34 +258,7 @@ export default class Form extends React.Component {
214
258
[ className ] : ! ! className ,
215
259
} ) ;
216
260
217
- const newChildren = React . Children . map ( children , child => {
218
- if (
219
- child &&
220
- typeof child . type === 'function' &&
221
- child . type . _typeMark === 'form_item'
222
- ) {
223
- const childrenProps = {
224
- labelCol : child . props . labelCol
225
- ? child . props . labelCol
226
- : labelCol ,
227
- wrapperCol : child . props . wrapperCol
228
- ? child . props . wrapperCol
229
- : wrapperCol ,
230
- labelAlign : child . props . labelAlign
231
- ? child . props . labelAlign
232
- : device === 'phone'
233
- ? 'top'
234
- : labelAlign ,
235
- labelTextAlign : child . props . labelTextAlign
236
- ? child . props . labelTextAlign
237
- : labelTextAlign ,
238
- size : child . props . size ? child . props . size : size ,
239
- responsive : responsive ,
240
- } ;
241
- return React . cloneElement ( child , pickerDefined ( childrenProps ) ) ;
242
- }
243
- return child ;
244
- } ) ;
261
+ const newChildren = getNewChildren ( children , this . props ) ;
245
262
246
263
return (
247
264
< Tag
0 commit comments