11import * as React from 'react' ;
22import warning from 'rc-util/lib/warning' ;
3- import { InternalNamePath , NamePath , StoreValue } from './interface' ;
3+ import { InternalNamePath , NamePath , StoreValue , ValidatorRule , Meta } from './interface' ;
44import FieldContext from './FieldContext' ;
55import Field from './Field' ;
66import { move , getNamePath } from './utils/valueUtil' ;
@@ -19,10 +19,16 @@ interface ListOperations {
1919
2020interface ListProps {
2121 name : NamePath ;
22- children ?: ( fields : ListField [ ] , operations : ListOperations ) => JSX . Element | React . ReactNode ;
22+ rules ?: ValidatorRule [ ] ;
23+ validateTrigger ?: string | string [ ] | false ;
24+ children ?: (
25+ fields : ListField [ ] ,
26+ operations : ListOperations ,
27+ meta : Meta ,
28+ ) => JSX . Element | React . ReactNode ;
2329}
2430
25- const List : React . FunctionComponent < ListProps > = ( { name, children } ) => {
31+ const List : React . FunctionComponent < ListProps > = ( { name, children, rules , validateTrigger } ) => {
2632 const context = React . useContext ( FieldContext ) ;
2733 const keyRef = React . useRef ( {
2834 keys : [ ] ,
@@ -48,8 +54,8 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
4854
4955 return (
5056 < FieldContext . Provider value = { { ...context , prefixName } } >
51- < Field name = { [ ] } shouldUpdate = { shouldUpdate } >
52- { ( { value = [ ] , onChange } ) => {
57+ < Field name = { [ ] } shouldUpdate = { shouldUpdate } rules = { rules } validateTrigger = { validateTrigger } >
58+ { ( { value = [ ] , onChange } , meta ) => {
5359 const { getFieldValue } = context ;
5460 const getNewValue = ( ) => {
5561 const values = getFieldValue ( prefixName || [ ] ) as StoreValue [ ] ;
@@ -142,6 +148,7 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
142148 } ,
143149 ) ,
144150 operations ,
151+ meta ,
145152 ) ;
146153 } }
147154 </ Field >
0 commit comments