@@ -23,6 +23,8 @@ import type {
23
23
InternalValidateOptions ,
24
24
ValuedNotifyInfo ,
25
25
WatchCallBack ,
26
+ FilterFunc ,
27
+ GetFieldsValueConfig ,
26
28
} from './interface' ;
27
29
import { allPromiseFinish } from './utils/asyncUtil' ;
28
30
import { merge } from 'rc-util/lib/utils/set' ;
@@ -265,15 +267,31 @@ export class FormStore {
265
267
} ) ;
266
268
} ;
267
269
268
- private getFieldsValue = ( nameList ?: NamePath [ ] | true , filterFunc ?: ( meta : Meta ) => boolean ) => {
270
+ private getFieldsValue = (
271
+ nameList ?: NamePath [ ] | true | GetFieldsValueConfig ,
272
+ filterFunc ?: FilterFunc ,
273
+ ) => {
269
274
this . warningUnhooked ( ) ;
270
275
271
- if ( nameList === true && ! filterFunc ) {
276
+ // Fill args
277
+ let mergedNameList : NamePath [ ] | true ;
278
+ let mergedFilterFunc : FilterFunc ;
279
+ let mergedStrict : boolean ;
280
+
281
+ if ( nameList === true || Array . isArray ( nameList ) ) {
282
+ mergedNameList = nameList ;
283
+ mergedFilterFunc = filterFunc ;
284
+ } else if ( nameList && typeof nameList === 'object' ) {
285
+ mergedStrict = nameList . strict ;
286
+ mergedFilterFunc = nameList . filter ;
287
+ }
288
+
289
+ if ( mergedNameList === true && ! mergedFilterFunc ) {
272
290
return this . store ;
273
291
}
274
292
275
293
const fieldEntities = this . getFieldEntitiesForNamePathList (
276
- Array . isArray ( nameList ) ? nameList : null ,
294
+ Array . isArray ( mergedNameList ) ? mergedNameList : null ,
277
295
) ;
278
296
279
297
const filteredNameList : NamePath [ ] = [ ] ;
@@ -283,15 +301,19 @@ export class FormStore {
283
301
284
302
// Ignore when it's a list item and not specific the namePath,
285
303
// since parent field is already take in count
286
- if ( ! nameList && ( entity as FieldEntity ) . isListField ?.( ) ) {
304
+ if ( mergedStrict ) {
305
+ if ( ( entity as FieldEntity ) . isList ?.( ) ) {
306
+ return ;
307
+ }
308
+ } else if ( ! mergedNameList && ( entity as FieldEntity ) . isListField ?.( ) ) {
287
309
return ;
288
310
}
289
311
290
- if ( ! filterFunc ) {
312
+ if ( ! mergedFilterFunc ) {
291
313
filteredNameList . push ( namePath ) ;
292
314
} else {
293
315
const meta : Meta = 'getMeta' in entity ? entity . getMeta ( ) : null ;
294
- if ( filterFunc ( meta ) ) {
316
+ if ( mergedFilterFunc ( meta ) ) {
295
317
filteredNameList . push ( namePath ) ;
296
318
}
297
319
}
0 commit comments