@@ -5,79 +5,74 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
55
66function _toConsumableArray ( arr ) { if ( Array . isArray ( arr ) ) { for ( var i = 0 , arr2 = Array ( arr . length ) ; i < arr . length ; i ++ ) { arr2 [ i ] = arr [ i ] ; } return arr2 ; } else { return Array . from ( arr ) ; } }
77
8+ function _objectWithoutProperties ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
9+
810import React from "react" ;
9- import PropTypes from "prop-types" ;
1011import FormItem from "./FormItem" ;
1112
12- import { getObjectExcludedProps } from "../utils/baseUtils" ;
1313import { renderDeclarativeByName } from "../core/renders" ;
1414
15- var excludeProps = [ "children" , "componentType" ] ;
16-
1715var FormItems = function FormItems ( props ) {
1816 var items = props . items ;
19-
2017 // console.log('FormItems props => ', props);
2118
22- var getItems = function getItems ( data , antFormListParams ) {
23-
19+ var getItems = function getItems ( data , formListProps ) {
2420 return data && data . map ( function ( item , index ) {
25- var itemProps = getObjectExcludedProps ( item , excludeProps ) ;
21+ var componentType = item . componentType ,
22+ children = item . children ,
23+ itemProps = _objectWithoutProperties ( item , [ "componentType" , "children" ] ) ;
2624 // console.log('FormItems index => ', index);
2725
28- switch ( item . componentType ) {
26+
27+ switch ( componentType ) {
2928 case "Item" :
3029 var _item = _extends ( { } , item ) ;
3130 var _key = index ;
32- if ( antFormListParams && antFormListParams . field ) {
31+ if ( formListProps && formListProps . field ) {
3332 if ( _item . name ) {
3433 if ( Array . isArray ( _item . name ) ) {
35- _item . name = [ antFormListParams . field . name ] . concat ( _toConsumableArray ( _item . name ) ) ;
36- _item . fieldKey = [ antFormListParams . field . name ] . concat ( _toConsumableArray ( _item . name ) ) ;
34+ _item . name = [ formListProps . field . name ] . concat ( _toConsumableArray ( _item . name ) ) ;
35+ _item . fieldKey = [ formListProps . field . name ] . concat ( _toConsumableArray ( _item . name ) ) ;
3736 } else {
38- _item . name = [ antFormListParams . field . name , _item . name ] ;
39- _item . fieldKey = [ antFormListParams . field . name ] . concat ( _toConsumableArray ( _item . name ) ) ;
37+ _item . name = [ formListProps . field . name , _item . name ] ;
38+ _item . fieldKey = [ formListProps . field . name ] . concat ( _toConsumableArray ( _item . name ) ) ;
4039 }
4140 }
4241 }
4342 // console.log('_item ', _item.name);
44- return React . createElement ( FormItem , _extends ( { key : "" + _key } , _item , { field : _extends ( { } , antFormListParams ) } ) ) ;
43+ return React . createElement ( FormItem , _extends ( { key : "" + _key } , _item , { field : _extends ( { } , formListProps ) } ) ) ;
4544 case "ListItems" :
4645 return React . createElement (
4746 _Form . List ,
4847 _extends ( { key : index } , itemProps ) ,
4948 function ( fields , operation ) {
5049 var param = { fields : [ ] . concat ( _toConsumableArray ( fields ) ) , operation : _extends ( { } , operation ) } ;
51- return getItems ( item . children , param ) ;
50+ return getItems ( children , param ) ;
5251 }
5352 ) ;
5453 case "ListItem" :
55- // console.log('antFormListParams => ', antFormListParams );
54+ // console.log('formListProps => ', formListProps );
5655 return React . createElement (
5756 "div" ,
5857 { key : index } ,
59- antFormListParams && antFormListParams . fields && antFormListParams . fields . map ( function ( field , fIndex ) {
58+ formListProps && formListProps . fields && formListProps . fields . map ( function ( field , fIndex ) {
6059 // console.log('index field.key', index, field);
61- var param = _extends ( { field : _extends ( { } , field ) } , antFormListParams ) ;
60+ var param = _extends ( { field : _extends ( { } , field ) } , formListProps ) ;
6261 return React . createElement (
6362 "div" ,
6463 { key : field . key } ,
65- getItems ( item . children , param ) ,
64+ getItems ( children , param ) ,
6665 " "
6766 ) ;
6867 } )
6968 ) ;
7069 default :
71- return renderDeclarativeByName ( item . componentType ) ( _extends ( { key : index } , itemProps ) ) ( getItems ( item . children , antFormListParams ) ) ;
70+ return renderDeclarativeByName ( componentType ) ( _extends ( { key : index } , itemProps ) ) ( getItems ( children , formListProps ) ) ;
7271 }
7372 } ) || null ;
7473 } ;
7574
7675 return getItems ( items ) ;
7776} ;
7877
79- FormItems . propTypes = {
80- items : PropTypes . arrayOf ( PropTypes . object ) . isRequired
81- } ;
82-
8378export default FormItems ;
0 commit comments