@tanstack/form-core 1.15.1 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/FieldApi.cjs +48 -40
  2. package/dist/cjs/FieldApi.cjs.map +1 -1
  3. package/dist/cjs/FieldApi.d.cts +33 -30
  4. package/dist/cjs/FieldGroupApi.cjs.map +1 -1
  5. package/dist/cjs/FieldGroupApi.d.cts +6 -6
  6. package/dist/cjs/FormApi.cjs +85 -72
  7. package/dist/cjs/FormApi.cjs.map +1 -1
  8. package/dist/cjs/FormApi.d.cts +42 -35
  9. package/dist/cjs/ValidationLogic.cjs +106 -0
  10. package/dist/cjs/ValidationLogic.cjs.map +1 -0
  11. package/dist/cjs/ValidationLogic.d.cts +47 -0
  12. package/dist/cjs/formOptions.cjs.map +1 -1
  13. package/dist/cjs/formOptions.d.cts +1 -1
  14. package/dist/cjs/index.cjs +3 -0
  15. package/dist/cjs/index.cjs.map +1 -1
  16. package/dist/cjs/index.d.cts +1 -0
  17. package/dist/cjs/mergeForm.cjs.map +1 -1
  18. package/dist/cjs/mergeForm.d.cts +1 -1
  19. package/dist/cjs/metaHelper.cjs.map +1 -1
  20. package/dist/cjs/metaHelper.d.cts +1 -1
  21. package/dist/cjs/standardSchemaValidator.cjs.map +1 -1
  22. package/dist/cjs/types.d.cts +6 -3
  23. package/dist/cjs/utils.cjs +51 -63
  24. package/dist/cjs/utils.cjs.map +1 -1
  25. package/dist/cjs/utils.d.cts +11 -5
  26. package/dist/esm/FieldApi.d.ts +33 -30
  27. package/dist/esm/FieldApi.js +48 -40
  28. package/dist/esm/FieldApi.js.map +1 -1
  29. package/dist/esm/FieldGroupApi.d.ts +6 -6
  30. package/dist/esm/FieldGroupApi.js.map +1 -1
  31. package/dist/esm/FormApi.d.ts +42 -35
  32. package/dist/esm/FormApi.js +85 -72
  33. package/dist/esm/FormApi.js.map +1 -1
  34. package/dist/esm/ValidationLogic.d.ts +47 -0
  35. package/dist/esm/ValidationLogic.js +106 -0
  36. package/dist/esm/ValidationLogic.js.map +1 -0
  37. package/dist/esm/formOptions.d.ts +1 -1
  38. package/dist/esm/formOptions.js.map +1 -1
  39. package/dist/esm/index.d.ts +1 -0
  40. package/dist/esm/index.js +3 -0
  41. package/dist/esm/index.js.map +1 -1
  42. package/dist/esm/mergeForm.d.ts +1 -1
  43. package/dist/esm/mergeForm.js.map +1 -1
  44. package/dist/esm/metaHelper.d.ts +1 -1
  45. package/dist/esm/metaHelper.js.map +1 -1
  46. package/dist/esm/standardSchemaValidator.js.map +1 -1
  47. package/dist/esm/types.d.ts +6 -3
  48. package/dist/esm/utils.d.ts +11 -5
  49. package/dist/esm/utils.js +51 -63
  50. package/dist/esm/utils.js.map +1 -1
  51. package/package.json +16 -3
  52. package/src/FieldApi.ts +185 -14
  53. package/src/FieldGroupApi.ts +14 -0
  54. package/src/FormApi.ts +141 -6
  55. package/src/ValidationLogic.ts +200 -0
  56. package/src/formOptions.ts +1 -1
  57. package/src/index.ts +1 -0
  58. package/src/mergeForm.ts +16 -1
  59. package/src/metaHelper.ts +4 -0
  60. package/src/types.ts +17 -1
  61. package/src/utils.ts +159 -109
package/src/FormApi.ts CHANGED
@@ -11,12 +11,14 @@ import {
11
11
  isNonEmptyArray,
12
12
  setBy,
13
13
  } from './utils'
14
+ import { defaultValidationLogic } from './ValidationLogic'
14
15
 
15
16
  import {
16
17
  isStandardSchemaValidator,
17
18
  standardSchemaValidators,
18
19
  } from './standardSchemaValidator'
19
20
  import { defaultFieldMeta, metaHelper } from './metaHelper'
21
+ import type { ValidationLogicFn } from './ValidationLogic'
20
22
  import type {
21
23
  StandardSchemaV1,
22
24
  StandardSchemaV1Issue,
@@ -84,6 +86,8 @@ export type FormValidateFn<TFormData> = (props: {
84
86
  any,
85
87
  any,
86
88
  any,
89
+ any,
90
+ any,
87
91
  any
88
92
  >
89
93
  }) => unknown
@@ -120,6 +124,8 @@ export type FormValidateAsyncFn<TFormData> = (props: {
120
124
  any,
121
125
  any,
122
126
  any,
127
+ any,
128
+ any,
123
129
  any
124
130
  >
125
131
  signal: AbortSignal
@@ -164,6 +170,8 @@ export interface FormValidators<
164
170
  TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
165
171
  TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
166
172
  TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
173
+ TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
174
+ TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
167
175
  > {
168
176
  /**
169
177
  * Optional function that fires as soon as the component mounts.
@@ -195,6 +203,9 @@ export interface FormValidators<
195
203
  onBlurAsyncDebounceMs?: number
196
204
  onSubmit?: TOnSubmit
197
205
  onSubmitAsync?: TOnSubmitAsync
206
+ onDynamic?: TOnDynamic
207
+ onDynamicAsync?: TOnDynamicAsync
208
+ onDynamicAsyncDebounceMs?: number
198
209
  }
199
210
 
200
211
  /**
@@ -209,6 +220,8 @@ export interface FormTransform<
209
220
  TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
210
221
  TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
211
222
  TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
223
+ TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
224
+ TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
212
225
  TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
213
226
  TSubmitMeta = never,
214
227
  > {
@@ -222,6 +235,8 @@ export interface FormTransform<
222
235
  TOnBlurAsync,
223
236
  TOnSubmit,
224
237
  TOnSubmitAsync,
238
+ TOnDynamic,
239
+ TOnDynamicAsync,
225
240
  TOnServer,
226
241
  TSubmitMeta
227
242
  >,
@@ -234,6 +249,8 @@ export interface FormTransform<
234
249
  TOnBlurAsync,
235
250
  TOnSubmit,
236
251
  TOnSubmitAsync,
252
+ TOnDynamic,
253
+ TOnDynamicAsync,
237
254
  TOnServer,
238
255
  TSubmitMeta
239
256
  >
@@ -249,6 +266,8 @@ export interface FormListeners<
249
266
  TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
250
267
  TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
251
268
  TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
269
+ TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
270
+ TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
252
271
  TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
253
272
  TSubmitMeta = never,
254
273
  > {
@@ -262,6 +281,8 @@ export interface FormListeners<
262
281
  TOnBlurAsync,
263
282
  TOnSubmit,
264
283
  TOnSubmitAsync,
284
+ TOnDynamic,
285
+ TOnDynamicAsync,
265
286
  TOnServer,
266
287
  TSubmitMeta
267
288
  >
@@ -279,6 +300,8 @@ export interface FormListeners<
279
300
  TOnBlurAsync,
280
301
  TOnSubmit,
281
302
  TOnSubmitAsync,
303
+ TOnDynamic,
304
+ TOnDynamicAsync,
282
305
  TOnServer,
283
306
  TSubmitMeta
284
307
  >
@@ -296,6 +319,8 @@ export interface FormListeners<
296
319
  TOnBlurAsync,
297
320
  TOnSubmit,
298
321
  TOnSubmitAsync,
322
+ TOnDynamic,
323
+ TOnDynamicAsync,
299
324
  TOnServer,
300
325
  TSubmitMeta
301
326
  >
@@ -311,9 +336,12 @@ export interface FormListeners<
311
336
  TOnBlurAsync,
312
337
  TOnSubmit,
313
338
  TOnSubmitAsync,
339
+ TOnDynamic,
340
+ TOnDynamicAsync,
314
341
  TOnServer,
315
342
  TSubmitMeta
316
343
  >
344
+ meta: TSubmitMeta
317
345
  }) => void
318
346
  }
319
347
 
@@ -343,6 +371,8 @@ export interface FormOptions<
343
371
  in out TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
344
372
  in out TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
345
373
  in out TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
374
+ in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
375
+ in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
346
376
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
347
377
  in out TSubmitMeta = never,
348
378
  > extends BaseFormOptions<TFormData, TSubmitMeta> {
@@ -359,6 +389,8 @@ export interface FormOptions<
359
389
  TOnBlurAsync,
360
390
  TOnSubmit,
361
391
  TOnSubmitAsync,
392
+ TOnDynamic,
393
+ TOnDynamicAsync,
362
394
  TOnServer
363
395
  >
364
396
  >
@@ -385,9 +417,13 @@ export interface FormOptions<
385
417
  TOnBlur,
386
418
  TOnBlurAsync,
387
419
  TOnSubmit,
388
- TOnSubmitAsync
420
+ TOnSubmitAsync,
421
+ TOnDynamic,
422
+ TOnDynamicAsync
389
423
  >
390
424
 
425
+ validationLogic?: ValidationLogicFn
426
+
391
427
  /**
392
428
  * form level listeners
393
429
  */
@@ -400,6 +436,8 @@ export interface FormOptions<
400
436
  TOnBlurAsync,
401
437
  TOnSubmit,
402
438
  TOnSubmitAsync,
439
+ TOnDynamic,
440
+ TOnDynamicAsync,
403
441
  TOnServer,
404
442
  TSubmitMeta
405
443
  >
@@ -418,6 +456,8 @@ export interface FormOptions<
418
456
  TOnBlurAsync,
419
457
  TOnSubmit,
420
458
  TOnSubmitAsync,
459
+ TOnDynamic,
460
+ TOnDynamicAsync,
421
461
  TOnServer,
422
462
  TSubmitMeta
423
463
  >
@@ -437,9 +477,12 @@ export interface FormOptions<
437
477
  TOnBlurAsync,
438
478
  TOnSubmit,
439
479
  TOnSubmitAsync,
480
+ TOnDynamic,
481
+ TOnDynamicAsync,
440
482
  TOnServer,
441
483
  TSubmitMeta
442
484
  >
485
+ meta: TSubmitMeta
443
486
  }) => void
444
487
  transform?: FormTransform<
445
488
  NoInfer<TFormData>,
@@ -450,6 +493,8 @@ export interface FormOptions<
450
493
  NoInfer<TOnBlurAsync>,
451
494
  NoInfer<TOnSubmit>,
452
495
  NoInfer<TOnSubmitAsync>,
496
+ NoInfer<TOnDynamic>,
497
+ NoInfer<TOnDynamicAsync>,
453
498
  NoInfer<TOnServer>,
454
499
  NoInfer<TSubmitMeta>
455
500
  >
@@ -491,6 +536,10 @@ export type FieldInfo<TFormData> = {
491
536
  any,
492
537
  any,
493
538
  any,
539
+ any,
540
+ any,
541
+ any,
542
+ any,
494
543
  any
495
544
  > | null
496
545
  /**
@@ -511,6 +560,8 @@ export type BaseFormState<
511
560
  in out TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
512
561
  in out TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
513
562
  in out TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
563
+ in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
564
+ in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
514
565
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
515
566
  > = {
516
567
  /**
@@ -528,6 +579,8 @@ export type BaseFormState<
528
579
  UnwrapFormAsyncValidateOrFn<TOnBlurAsync>,
529
580
  UnwrapFormValidateOrFn<TOnSubmit>,
530
581
  UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>,
582
+ UnwrapFormValidateOrFn<TOnDynamic>,
583
+ UnwrapFormAsyncValidateOrFn<TOnDynamicAsync>,
531
584
  UnwrapFormAsyncValidateOrFn<TOnServer>
532
585
  >
533
586
  /**
@@ -586,6 +639,8 @@ export type DerivedFormState<
586
639
  in out TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
587
640
  in out TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
588
641
  in out TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
642
+ in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
643
+ in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
589
644
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
590
645
  > = {
591
646
  /**
@@ -607,6 +662,8 @@ export type DerivedFormState<
607
662
  | UnwrapFormAsyncValidateOrFn<TOnBlurAsync>
608
663
  | UnwrapFormValidateOrFn<TOnSubmit>
609
664
  | UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>
665
+ | UnwrapFormValidateOrFn<TOnDynamic>
666
+ | UnwrapFormAsyncValidateOrFn<TOnDynamicAsync>
610
667
  | UnwrapFormAsyncValidateOrFn<TOnServer>
611
668
  >
612
669
  /**
@@ -660,6 +717,8 @@ export interface FormState<
660
717
  in out TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
661
718
  in out TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
662
719
  in out TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
720
+ in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
721
+ in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
663
722
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
664
723
  > extends BaseFormState<
665
724
  TFormData,
@@ -670,6 +729,8 @@ export interface FormState<
670
729
  TOnBlurAsync,
671
730
  TOnSubmit,
672
731
  TOnSubmitAsync,
732
+ TOnDynamic,
733
+ TOnDynamicAsync,
673
734
  TOnServer
674
735
  >,
675
736
  DerivedFormState<
@@ -681,6 +742,8 @@ export interface FormState<
681
742
  TOnBlurAsync,
682
743
  TOnSubmit,
683
744
  TOnSubmitAsync,
745
+ TOnDynamic,
746
+ TOnDynamicAsync,
684
747
  TOnServer
685
748
  > {}
686
749
 
@@ -693,6 +756,8 @@ export type AnyFormState = FormState<
693
756
  any,
694
757
  any,
695
758
  any,
759
+ any,
760
+ any,
696
761
  any
697
762
  >
698
763
 
@@ -705,6 +770,8 @@ function getDefaultFormState<
705
770
  TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
706
771
  TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
707
772
  TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
773
+ TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
774
+ TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
708
775
  TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
709
776
  >(
710
777
  defaultState: Partial<
@@ -717,6 +784,8 @@ function getDefaultFormState<
717
784
  TOnBlurAsync,
718
785
  TOnSubmit,
719
786
  TOnSubmitAsync,
787
+ TOnDynamic,
788
+ TOnDynamicAsync,
720
789
  TOnServer
721
790
  >
722
791
  >,
@@ -729,6 +798,8 @@ function getDefaultFormState<
729
798
  TOnBlurAsync,
730
799
  TOnSubmit,
731
800
  TOnSubmitAsync,
801
+ TOnDynamic,
802
+ TOnDynamicAsync,
732
803
  TOnServer
733
804
  > {
734
805
  return {
@@ -746,6 +817,7 @@ function getDefaultFormState<
746
817
  onSubmit: undefined,
747
818
  onMount: undefined,
748
819
  onServer: undefined,
820
+ onDynamic: undefined,
749
821
  },
750
822
  }
751
823
  }
@@ -765,6 +837,8 @@ export type AnyFormApi = FormApi<
765
837
  any,
766
838
  any,
767
839
  any,
840
+ any,
841
+ any,
768
842
  any
769
843
  >
770
844
 
@@ -784,6 +858,8 @@ export class FormApi<
784
858
  in out TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
785
859
  in out TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
786
860
  in out TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
861
+ in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
862
+ in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
787
863
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
788
864
  in out TSubmitMeta = never,
789
865
  > implements FieldManipulator<TFormData, TSubmitMeta>
@@ -800,6 +876,8 @@ export class FormApi<
800
876
  TOnBlurAsync,
801
877
  TOnSubmit,
802
878
  TOnSubmitAsync,
879
+ TOnDynamic,
880
+ TOnDynamicAsync,
803
881
  TOnServer,
804
882
  TSubmitMeta
805
883
  > = {}
@@ -813,6 +891,8 @@ export class FormApi<
813
891
  TOnBlurAsync,
814
892
  TOnSubmit,
815
893
  TOnSubmitAsync,
894
+ TOnDynamic,
895
+ TOnDynamicAsync,
816
896
  TOnServer
817
897
  >
818
898
  >
@@ -827,6 +907,8 @@ export class FormApi<
827
907
  TOnBlurAsync,
828
908
  TOnSubmit,
829
909
  TOnSubmitAsync,
910
+ TOnDynamic,
911
+ TOnDynamicAsync,
830
912
  TOnServer
831
913
  >
832
914
  >
@@ -857,6 +939,8 @@ export class FormApi<
857
939
  TOnBlurAsync,
858
940
  TOnSubmit,
859
941
  TOnSubmitAsync,
942
+ TOnDynamic,
943
+ TOnDynamicAsync,
860
944
  TOnServer,
861
945
  TSubmitMeta
862
946
  >,
@@ -889,6 +973,8 @@ export class FormApi<
889
973
  TOnBlurAsync,
890
974
  TOnSubmit,
891
975
  TOnSubmitAsync,
976
+ TOnDynamic,
977
+ TOnDynamicAsync,
892
978
  TOnServer
893
979
  >['fieldMeta']
894
980
 
@@ -990,6 +1076,8 @@ export class FormApi<
990
1076
  TOnBlurAsync,
991
1077
  TOnSubmit,
992
1078
  TOnSubmitAsync,
1079
+ TOnDynamic,
1080
+ TOnDynamicAsync,
993
1081
  TOnServer
994
1082
  >
995
1083
  | undefined
@@ -1122,6 +1210,8 @@ export class FormApi<
1122
1210
  TOnBlurAsync,
1123
1211
  TOnSubmit,
1124
1212
  TOnSubmitAsync,
1213
+ TOnDynamic,
1214
+ TOnDynamicAsync,
1125
1215
  TOnServer
1126
1216
  >
1127
1217
 
@@ -1203,6 +1293,8 @@ export class FormApi<
1203
1293
  TOnBlurAsync,
1204
1294
  TOnSubmit,
1205
1295
  TOnSubmitAsync,
1296
+ TOnDynamic,
1297
+ TOnDynamicAsync,
1206
1298
  TOnServer,
1207
1299
  TSubmitMeta
1208
1300
  >,
@@ -1394,7 +1486,12 @@ export class FormApi<
1394
1486
  TOnSubmitAsync
1395
1487
  >
1396
1488
  } => {
1397
- const validates = getSyncValidatorArray(cause, this.options)
1489
+ const validates = getSyncValidatorArray(cause, {
1490
+ ...this.options,
1491
+ form: this,
1492
+ validationLogic: this.options.validationLogic || defaultValidationLogic,
1493
+ })
1494
+
1398
1495
  let hasErrored = false as boolean
1399
1496
 
1400
1497
  // This map will only include fields that have errors in the current validation cycle
@@ -1510,6 +1607,26 @@ export class FormApi<
1510
1607
  },
1511
1608
  }))
1512
1609
  }
1610
+
1611
+ /**
1612
+ * when we have an error for onServer in the state, we want
1613
+ * to clear the error as soon as the user enters a valid value in the field
1614
+ */
1615
+ const serverErrKey = getErrorMapKey('server')
1616
+ if (
1617
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1618
+ this.state.errorMap?.[serverErrKey] &&
1619
+ cause !== 'server' &&
1620
+ !hasErrored
1621
+ ) {
1622
+ this.baseStore.setState((prev) => ({
1623
+ ...prev,
1624
+ errorMap: {
1625
+ ...prev.errorMap,
1626
+ [serverErrKey]: undefined,
1627
+ },
1628
+ }))
1629
+ }
1513
1630
  })
1514
1631
 
1515
1632
  return { hasErrored, fieldsErrorMap: currentValidationErrorMap }
@@ -1532,7 +1649,11 @@ export class FormApi<
1532
1649
  TOnSubmitAsync
1533
1650
  >
1534
1651
  > => {
1535
- const validates = getAsyncValidatorArray(cause, this.options)
1652
+ const validates = getAsyncValidatorArray(cause, {
1653
+ ...this.options,
1654
+ form: this,
1655
+ validationLogic: this.options.validationLogic || defaultValidationLogic,
1656
+ })
1536
1657
 
1537
1658
  if (!this.state.isFormValidating) {
1538
1659
  this.baseStore.setState((prev) => ({ ...prev, isFormValidating: true }))
@@ -1772,6 +1893,9 @@ export class FormApi<
1772
1893
 
1773
1894
  if (!this.state.canSubmit) return
1774
1895
 
1896
+ const submitMetaArg =
1897
+ submitMeta ?? (this.options.onSubmitMeta as TSubmitMeta)
1898
+
1775
1899
  this.baseStore.setState((d) => ({ ...d, isSubmitting: true }))
1776
1900
 
1777
1901
  const done = () => {
@@ -1785,6 +1909,7 @@ export class FormApi<
1785
1909
  this.options.onSubmitInvalid?.({
1786
1910
  value: this.state.values,
1787
1911
  formApi: this,
1912
+ meta: submitMetaArg,
1788
1913
  })
1789
1914
  return
1790
1915
  }
@@ -1797,6 +1922,7 @@ export class FormApi<
1797
1922
  this.options.onSubmitInvalid?.({
1798
1923
  value: this.state.values,
1799
1924
  formApi: this,
1925
+ meta: submitMetaArg,
1800
1926
  })
1801
1927
  return
1802
1928
  }
@@ -1812,15 +1938,15 @@ export class FormApi<
1812
1938
  )
1813
1939
  })
1814
1940
 
1815
- this.options.listeners?.onSubmit?.({ formApi: this })
1941
+ this.options.listeners?.onSubmit?.({ formApi: this, meta: submitMetaArg })
1816
1942
 
1817
1943
  try {
1818
1944
  // Run the submit code
1819
1945
  await this.options.onSubmit?.({
1820
1946
  value: this.state.values,
1821
1947
  formApi: this,
1822
- meta: submitMeta ?? this.options.onSubmitMeta,
1823
- } as any)
1948
+ meta: submitMetaArg,
1949
+ })
1824
1950
 
1825
1951
  batch(() => {
1826
1952
  this.baseStore.setState((prev) => ({
@@ -1871,6 +1997,7 @@ export class FormApi<
1871
1997
  onSubmit: undefined,
1872
1998
  onMount: undefined,
1873
1999
  onServer: undefined,
2000
+ onDynamic: undefined,
1874
2001
  },
1875
2002
  })
1876
2003
  }
@@ -2191,6 +2318,8 @@ export class FormApi<
2191
2318
  UnwrapFormAsyncValidateOrFn<TOnBlurAsync>,
2192
2319
  UnwrapFormValidateOrFn<TOnSubmit>,
2193
2320
  UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>,
2321
+ UnwrapFormValidateOrFn<TOnDynamic>,
2322
+ UnwrapFormAsyncValidateOrFn<TOnDynamicAsync>,
2194
2323
  UnwrapFormAsyncValidateOrFn<TOnServer>
2195
2324
  >,
2196
2325
  ) {
@@ -2253,6 +2382,8 @@ export class FormApi<
2253
2382
  | UnwrapFormAsyncValidateOrFn<TOnBlurAsync>
2254
2383
  | UnwrapFormValidateOrFn<TOnSubmit>
2255
2384
  | UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>
2385
+ | UnwrapFormValidateOrFn<TOnDynamic>
2386
+ | UnwrapFormAsyncValidateOrFn<TOnDynamicAsync>
2256
2387
  | UnwrapFormAsyncValidateOrFn<TOnServer>
2257
2388
  >
2258
2389
  errorMap: ValidationErrorMap<
@@ -2263,6 +2394,8 @@ export class FormApi<
2263
2394
  UnwrapFormAsyncValidateOrFn<TOnBlurAsync>,
2264
2395
  UnwrapFormValidateOrFn<TOnSubmit>,
2265
2396
  UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>,
2397
+ UnwrapFormValidateOrFn<TOnDynamic>,
2398
+ UnwrapFormAsyncValidateOrFn<TOnDynamicAsync>,
2266
2399
  UnwrapFormAsyncValidateOrFn<TOnServer>
2267
2400
  >
2268
2401
  }
@@ -2352,6 +2485,8 @@ function getErrorMapKey(cause: ValidationCause) {
2352
2485
  return 'onMount'
2353
2486
  case 'server':
2354
2487
  return 'onServer'
2488
+ case 'dynamic':
2489
+ return 'onDynamic'
2355
2490
  case 'change':
2356
2491
  default:
2357
2492
  return 'onChange'