@@ -27,10 +27,8 @@ import {
27
27
} from './utils/valueUtil' ;
28
28
29
29
interface ChildProps {
30
- value ?: StoreValue ;
31
- onChange ?: ( ...args : EventArgs ) => void ;
32
- onFocus ?: ( ...args : EventArgs ) => void ;
33
- onBlur ?: ( ...args : EventArgs ) => void ;
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ [ name : string ] : any ;
34
32
}
35
33
36
34
export interface FieldProps {
@@ -52,6 +50,7 @@ export interface FieldProps {
52
50
| ( ( prevValues : Store , nextValues : Store , info : { source ?: string } ) => boolean ) ;
53
51
trigger ?: string ;
54
52
validateTrigger ?: string | string [ ] | false ;
53
+ valuePropName ?: string ;
55
54
}
56
55
57
56
export interface FieldState {
@@ -65,6 +64,7 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
65
64
public static defaultProps = {
66
65
trigger : 'onChange' ,
67
66
validateTrigger : 'onChange' ,
67
+ valuePropName : 'value' ,
68
68
} ;
69
69
70
70
public state = {
@@ -328,7 +328,7 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
328
328
} ;
329
329
330
330
public getControlled = ( childProps : ChildProps = { } ) => {
331
- const { trigger, validateTrigger, getValueFromEvent, normalize } = this . props ;
331
+ const { trigger, validateTrigger, getValueFromEvent, normalize, valuePropName } = this . props ;
332
332
const namePath = this . getNamePath ( ) ;
333
333
const { getInternalHooks, getFieldsValue } : InternalFormInstance = this . context ;
334
334
const { dispatch } = getInternalHooks ( HOOK_MARK ) ;
@@ -339,15 +339,20 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
339
339
340
340
const control = {
341
341
...childProps ,
342
- value,
342
+ [ valuePropName ] : value ,
343
343
} ;
344
344
345
345
// Add trigger
346
346
control [ trigger ] = ( ...args : EventArgs ) => {
347
347
// Mark as touched
348
348
this . touched = true ;
349
349
350
- let newValue = ( getValueFromEvent || defaultGetValueFromEvent ) ( ...args ) ;
350
+ let newValue ;
351
+ if ( getValueFromEvent ) {
352
+ newValue = getValueFromEvent ( ...args ) ;
353
+ } else {
354
+ newValue = defaultGetValueFromEvent ( valuePropName , ...args ) ;
355
+ }
351
356
352
357
if ( normalize ) {
353
358
newValue = normalize ( newValue , value , getFieldsValue ( ) ) ;
0 commit comments