@@ -172,13 +172,27 @@ export class FormStore {
172
172
return [ ] ;
173
173
} ;
174
174
175
- private isFieldsTouched = ( nameList ?: NamePath [ ] ) => {
176
- let namePathList : InternalNamePath [ ] | null = null ;
177
- if ( nameList ) {
178
- namePathList = nameList . map ( getNamePath ) ;
175
+ private isFieldsTouched = ( ...args ) => {
176
+ const [ arg0 , arg1 ] = args ;
177
+ let namePathList : InternalNamePath [ ] | null ;
178
+ let isAllFieldsTouched = false ;
179
+
180
+ if ( args . length === 0 ) {
181
+ namePathList = null ;
182
+ } else if ( args . length === 1 ) {
183
+ if ( Array . isArray ( arg0 ) ) {
184
+ namePathList = arg0 . map ( getNamePath ) ;
185
+ isAllFieldsTouched = false ;
186
+ } else {
187
+ namePathList = null ;
188
+ isAllFieldsTouched = arg0 ;
189
+ }
190
+ } else {
191
+ namePathList = arg0 . map ( getNamePath ) ;
192
+ isAllFieldsTouched = arg1 ;
179
193
}
180
194
181
- return this . getFieldEntities ( ) . some ( ( field : FieldEntity ) => {
195
+ const testTouched = ( field : FieldEntity ) => {
182
196
// Not provide `nameList` will check all the fields
183
197
if ( ! namePathList ) {
184
198
return field . isFieldTouched ( ) ;
@@ -189,7 +203,11 @@ export class FormStore {
189
203
return field . isFieldTouched ( ) ;
190
204
}
191
205
return false ;
192
- } ) ;
206
+ } ;
207
+
208
+ return isAllFieldsTouched
209
+ ? this . getFieldEntities ( ) . every ( testTouched )
210
+ : this . getFieldEntities ( ) . some ( testTouched ) ;
193
211
} ;
194
212
195
213
private isFieldTouched = ( name : NamePath ) => this . isFieldsTouched ( [ name ] ) ;
0 commit comments