@tanstack/form-core 1.27.0 → 1.27.2

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.
package/src/FormApi.ts CHANGED
@@ -748,7 +748,9 @@ export interface FormState<
748
748
  in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
749
749
  in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
750
750
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
751
- > extends BaseFormState<
751
+ >
752
+ extends
753
+ BaseFormState<
752
754
  TFormData,
753
755
  TOnMount,
754
756
  TOnChange,
@@ -870,6 +872,11 @@ export type AnyFormApi = FormApi<
870
872
  any
871
873
  >
872
874
 
875
+ /**
876
+ * We cannot use methods and must use arrow functions. Otherwise, our React adapters
877
+ * will break due to loss of the method when using spread.
878
+ */
879
+
873
880
  /**
874
881
  * A class representing the Form API. It handles the logic and interactions with the form state.
875
882
  *
@@ -890,8 +897,7 @@ export class FormApi<
890
897
  in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
891
898
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
892
899
  in out TSubmitMeta = never,
893
- > implements FieldManipulator<TFormData, TSubmitMeta>
894
- {
900
+ > implements FieldManipulator<TFormData, TSubmitMeta> {
895
901
  /**
896
902
  * The options for the form.
897
903
  */
@@ -1179,8 +1185,8 @@ export class FormApi<
1179
1185
  const hasOnMountError = Boolean(
1180
1186
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1181
1187
  currBaseStore.errorMap?.onMount ||
1182
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1183
- fieldMetaValues.some((f) => f?.errorMap?.onMount),
1188
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1189
+ fieldMetaValues.some((f) => f?.errorMap?.onMount),
1184
1190
  )
1185
1191
 
1186
1192
  const isValidating = !!isFieldsValidating
@@ -2016,12 +2022,17 @@ export class FormApi<
2016
2022
  return this.validateAsync(cause)
2017
2023
  }
2018
2024
 
2025
+ // Needs to edgecase in the React adapter specifically to avoid type errors
2026
+ handleSubmit(): Promise<void>
2027
+ handleSubmit(submitMeta: TSubmitMeta): Promise<void>
2028
+ handleSubmit(submitMeta?: TSubmitMeta): Promise<void> {
2029
+ return this._handleSubmit(submitMeta)
2030
+ }
2031
+
2019
2032
  /**
2020
2033
  * Handles the form submission, performs validation, and calls the appropriate onSubmit or onSubmitInvalid callbacks.
2021
2034
  */
2022
- handleSubmit(): Promise<void>
2023
- handleSubmit(submitMeta: TSubmitMeta): Promise<void>
2024
- async handleSubmit(submitMeta?: TSubmitMeta): Promise<void> {
2035
+ _handleSubmit = async (submitMeta?: TSubmitMeta): Promise<void> => {
2025
2036
  this.baseStore.setState((old) => ({
2026
2037
  ...old,
2027
2038
  // Submission attempts mark the form as not submitted
@@ -2539,7 +2550,7 @@ export class FormApi<
2539
2550
  /**
2540
2551
  * Updates the form's errorMap
2541
2552
  */
2542
- setErrorMap(
2553
+ setErrorMap = (
2543
2554
  errorMap: FormValidationErrorMap<
2544
2555
  TFormData,
2545
2556
  UnwrapFormValidateOrFn<TOnMount>,
@@ -2553,7 +2564,7 @@ export class FormApi<
2553
2564
  UnwrapFormAsyncValidateOrFn<TOnDynamicAsync>,
2554
2565
  UnwrapFormAsyncValidateOrFn<TOnServer>
2555
2566
  >,
2556
- ) {
2567
+ ) => {
2557
2568
  batch(() => {
2558
2569
  Object.entries(errorMap).forEach(([key, value]) => {
2559
2570
  const errorMapKey = key as ValidationErrorMapKeys
package/src/util-types.ts CHANGED
@@ -119,8 +119,9 @@ export type DeepKeyAndValueObject<
119
119
  export type UnknownAccessor<TParent extends AnyDeepKeyAndValue> =
120
120
  TParent['key'] extends never ? string : `${TParent['key']}.${string}`
121
121
 
122
- export interface UnknownDeepKeyAndValue<TParent extends AnyDeepKeyAndValue>
123
- extends AnyDeepKeyAndValue {
122
+ export interface UnknownDeepKeyAndValue<
123
+ TParent extends AnyDeepKeyAndValue,
124
+ > extends AnyDeepKeyAndValue {
124
125
  key: UnknownAccessor<TParent>
125
126
  value: unknown
126
127
  }