1
1
import * as React from 'react' ;
2
2
import warning from 'rc-util/lib/warning' ;
3
- import { InternalNamePath , NamePath , StoreValue } from './interface' ;
3
+ import { InternalNamePath , NamePath , StoreValue , ValidatorRule , Meta } from './interface' ;
4
4
import FieldContext from './FieldContext' ;
5
5
import Field from './Field' ;
6
6
import { move , getNamePath } from './utils/valueUtil' ;
@@ -19,10 +19,16 @@ interface ListOperations {
19
19
20
20
interface ListProps {
21
21
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 ;
23
29
}
24
30
25
- const List : React . FunctionComponent < ListProps > = ( { name, children } ) => {
31
+ const List : React . FunctionComponent < ListProps > = ( { name, children, rules , validateTrigger } ) => {
26
32
const context = React . useContext ( FieldContext ) ;
27
33
const keyRef = React . useRef ( {
28
34
keys : [ ] ,
@@ -48,8 +54,8 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
48
54
49
55
return (
50
56
< 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 ) => {
53
59
const { getFieldValue } = context ;
54
60
const getNewValue = ( ) => {
55
61
const values = getFieldValue ( prefixName || [ ] ) as StoreValue [ ] ;
@@ -142,6 +148,7 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
142
148
} ,
143
149
) ,
144
150
operations ,
151
+ meta ,
145
152
) ;
146
153
} }
147
154
</ Field >
0 commit comments