diff --git a/docs/framework/angular/reference/classes/tanstackfield.md b/docs/framework/angular/reference/classes/tanstackfield.md index 8d8f6dbaa..7571dc233 100644 --- a/docs/framework/angular/reference/classes/tanstackfield.md +++ b/docs/framework/angular/reference/classes/tanstackfield.md @@ -3,7 +3,7 @@ id: TanStackField title: TanStackField --- -# Class: TanStackField\ +# Class: TanStackField\ Defined in: [tanstack-field.directive.ts:25](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L25) @@ -21,34 +21,36 @@ Defined in: [tanstack-field.directive.ts:25](https://github.com/TanStack/form/bl • **TData** *extends* `DeepValue`\<`TParentData`, `TName`\> = `DeepValue`\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Implements - `OnInit` - `OnChanges` - `OnDestroy` -- `FieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +- `FieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ## Constructors ### new TanStackField() ```ts -new TanStackField(): TanStackField +new TanStackField(): TanStackField ``` #### Returns -[`TanStackField`](tanstackfield.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +[`TanStackField`](tanstackfield.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ## Properties ### api ```ts -api: FieldApi; +api: FieldApi; ``` -Defined in: [tanstack-field.directive.ts:62](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L62) +Defined in: [tanstack-field.directive.ts:85](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L85) *** @@ -58,7 +60,7 @@ Defined in: [tanstack-field.directive.ts:62](https://github.com/TanStack/form/bl optional asyncAlways: boolean; ``` -Defined in: [tanstack-field.directive.ts:48](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L48) +Defined in: [tanstack-field.directive.ts:56](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L56) If `true`, always run async validation, even if there are errors emitted during synchronous validation. @@ -76,7 +78,7 @@ FieldOptions.asyncAlways optional asyncDebounceMs: number; ``` -Defined in: [tanstack-field.directive.ts:47](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L47) +Defined in: [tanstack-field.directive.ts:55](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L55) The default time to debounce async validation if there is not a more specific debounce time passed. @@ -94,7 +96,7 @@ FieldOptions.asyncDebounceMs optional defaultMeta: Partial; ``` -Defined in: [tanstack-field.directive.ts:60](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L60) +Defined in: [tanstack-field.directive.ts:83](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L83) An optional object with default metadata for the field. @@ -112,7 +114,7 @@ FieldOptions.defaultMeta optional defaultValue: NoInfer; ``` -Defined in: [tanstack-field.directive.ts:46](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L46) +Defined in: [tanstack-field.directive.ts:54](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L54) An optional default value for the field. @@ -127,10 +129,10 @@ FieldOptions.defaultValue ### listeners? ```ts -optional listeners: NoInfer>; +optional listeners: NoInfer>; ``` -Defined in: [tanstack-field.directive.ts:57](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L57) +Defined in: [tanstack-field.directive.ts:73](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L73) A list of listeners which attach to the corresponding events @@ -148,7 +150,7 @@ FieldOptions.listeners name: TName; ``` -Defined in: [tanstack-field.directive.ts:42](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L42) +Defined in: [tanstack-field.directive.ts:50](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L50) The field name. The type will be `DeepKeys` to ensure your name is a deep key of the parent dataset. @@ -163,10 +165,10 @@ FieldOptions.name ### tanstackField ```ts -tanstackField: FormApi; +tanstackField: FormApi; ``` -Defined in: [tanstack-field.directive.ts:50](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L50) +Defined in: [tanstack-field.directive.ts:58](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L58) *** @@ -176,7 +178,7 @@ Defined in: [tanstack-field.directive.ts:50](https://github.com/TanStack/form/bl optional unmount: () => void; ``` -Defined in: [tanstack-field.directive.ts:78](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L78) +Defined in: [tanstack-field.directive.ts:108](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L108) #### Returns @@ -190,7 +192,7 @@ Defined in: [tanstack-field.directive.ts:78](https://github.com/TanStack/form/bl optional validatorAdapter: TFieldValidator; ``` -Defined in: [tanstack-field.directive.ts:49](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L49) +Defined in: [tanstack-field.directive.ts:57](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L57) A validator provided by an extension, like `yupValidator` from `@tanstack/yup-form-adapter` @@ -205,10 +207,10 @@ FieldOptions.validatorAdapter ### validators? ```ts -optional validators: NoInfer>; +optional validators: NoInfer>; ``` -Defined in: [tanstack-field.directive.ts:54](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L54) +Defined in: [tanstack-field.directive.ts:63](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L63) A list of validators to pass to the field @@ -226,7 +228,7 @@ FieldOptions.validators ngOnChanges(): void ``` -Defined in: [tanstack-field.directive.ts:90](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L90) +Defined in: [tanstack-field.directive.ts:120](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L120) A callback method that is invoked immediately after the default change detector has checked data-bound properties @@ -251,7 +253,7 @@ OnChanges.ngOnChanges ngOnDestroy(): void ``` -Defined in: [tanstack-field.directive.ts:86](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L86) +Defined in: [tanstack-field.directive.ts:116](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L116) A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed. @@ -274,7 +276,7 @@ OnDestroy.ngOnDestroy ngOnInit(): void ``` -Defined in: [tanstack-field.directive.ts:80](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L80) +Defined in: [tanstack-field.directive.ts:110](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L110) A callback method that is invoked immediately after the default change detector has checked the directive's diff --git a/docs/framework/angular/reference/functions/injectform.md b/docs/framework/angular/reference/functions/injectform.md index 05b89cd61..7a2ee130e 100644 --- a/docs/framework/angular/reference/functions/injectform.md +++ b/docs/framework/angular/reference/functions/injectform.md @@ -6,7 +6,7 @@ title: injectForm # Function: injectForm() ```ts -function injectForm(opts?): FormApi +function injectForm(opts?): FormApi ``` Defined in: [inject-form.ts:5](https://github.com/TanStack/form/blob/main/packages/angular-form/src/inject-form.ts#L5) @@ -17,12 +17,14 @@ Defined in: [inject-form.ts:5](https://github.com/TanStack/form/blob/main/packag • **TFormValidator** *extends* `undefined` \| `Validator`\<`TFormData`, `unknown`\> = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### opts? -`FormOptions`\<`TFormData`, `TFormValidator`\> +`FormOptions`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ## Returns -`FormApi`\<`TFormData`, `TFormValidator`\> +`FormApi`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> diff --git a/docs/framework/angular/reference/functions/injectstore.md b/docs/framework/angular/reference/functions/injectstore.md index d66d6302a..e081114cd 100644 --- a/docs/framework/angular/reference/functions/injectstore.md +++ b/docs/framework/angular/reference/functions/injectstore.md @@ -6,7 +6,7 @@ title: injectStore # Function: injectStore() ```ts -function injectStore(form, selector?): Signal +function injectStore(form, selector?): Signal ``` Defined in: [inject-store.ts:4](https://github.com/TanStack/form/blob/main/packages/angular-form/src/inject-store.ts#L4) @@ -19,11 +19,13 @@ Defined in: [inject-store.ts:4](https://github.com/TanStack/form/blob/main/packa • **TSelected** = `NoInfer`\<`FormState`\<`TFormData`\>\> +• **TFormSubmitMeta** = `never` + ## Parameters ### form -`FormApi`\<`TFormData`, `TFormValidator`\> +`FormApi`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ### selector? diff --git a/docs/framework/lit/reference/classes/tanstackformcontroller.md b/docs/framework/lit/reference/classes/tanstackformcontroller.md index b5be60c77..a0ce0c7fa 100644 --- a/docs/framework/lit/reference/classes/tanstackformcontroller.md +++ b/docs/framework/lit/reference/classes/tanstackformcontroller.md @@ -3,9 +3,9 @@ id: TanStackFormController title: TanStackFormController --- -# Class: TanStackFormController\ +# Class: TanStackFormController\ -Defined in: [tanstack-form-controller.ts:81](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L81) +Defined in: [tanstack-form-controller.ts:88](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L88) ## Type Parameters @@ -13,6 +13,8 @@ Defined in: [tanstack-form-controller.ts:81](https://github.com/TanStack/form/bl • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Implements - `ReactiveController` @@ -22,10 +24,10 @@ Defined in: [tanstack-form-controller.ts:81](https://github.com/TanStack/form/bl ### new TanStackFormController() ```ts -new TanStackFormController(host, config?): TanStackFormController +new TanStackFormController(host, config?): TanStackFormController ``` -Defined in: [tanstack-form-controller.ts:93](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L93) +Defined in: [tanstack-form-controller.ts:101](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L101) #### Parameters @@ -35,21 +37,21 @@ Defined in: [tanstack-form-controller.ts:93](https://github.com/TanStack/form/bl ##### config? -`FormOptions`\<`TParentData`, `TFormValidator`\> +`FormOptions`\<`TParentData`, `TFormValidator`, `TParentMetaExtension`\> #### Returns -[`TanStackFormController`](tanstackformcontroller.md)\<`TParentData`, `TFormValidator`\> +[`TanStackFormController`](tanstackformcontroller.md)\<`TParentData`, `TFormValidator`, `TParentMetaExtension`\> ## Properties ### api ```ts -api: FormApi; +api: FormApi; ``` -Defined in: [tanstack-form-controller.ts:91](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L91) +Defined in: [tanstack-form-controller.ts:99](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L99) ## Methods @@ -59,7 +61,7 @@ Defined in: [tanstack-form-controller.ts:91](https://github.com/TanStack/form/bl field(fieldConfig, render): object ``` -Defined in: [tanstack-form-controller.ts:112](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L112) +Defined in: [tanstack-form-controller.ts:122](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L122) #### Type Parameters @@ -75,11 +77,11 @@ Defined in: [tanstack-form-controller.ts:112](https://github.com/TanStack/form/b ##### fieldConfig -`FieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +`FieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ##### render -`renderCallback`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +`renderCallback`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> #### Returns @@ -94,19 +96,19 @@ values: object; ###### values.form ```ts -form: FormApi; +form: FormApi; ``` ###### values.options ```ts -options: FieldOptions; +options: FieldOptions; ``` ###### values.render ```ts -render: renderCallback; +render: renderCallback; ``` *** @@ -117,7 +119,7 @@ render: renderCallback(__namedParameters): ReactNode +function Field(__namedParameters): ReactNode ``` -Defined in: [packages/react-form/src/useField.tsx:164](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L164) +Defined in: [packages/react-form/src/useField.tsx:194](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L194) A function component that takes field options and a render function as children and returns a React component. @@ -29,11 +29,13 @@ The `Field` component uses the `useField` hook internally to manage the field in • **TData** = `DeepValue`\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Parameters ### \_\_namedParameters -`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ## Returns diff --git a/docs/framework/react/reference/functions/usefield.md b/docs/framework/react/reference/functions/usefield.md index 72bc66835..055ec5405 100644 --- a/docs/framework/react/reference/functions/usefield.md +++ b/docs/framework/react/reference/functions/usefield.md @@ -6,10 +6,10 @@ title: useField # Function: useField() ```ts -function useField(opts): FieldApi & ReactFieldApi +function useField(opts): FieldApi & ReactFieldApi ``` -Defined in: [packages/react-form/src/useField.tsx:50](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L50) +Defined in: [packages/react-form/src/useField.tsx:66](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L66) A hook for managing a field in a form. @@ -27,16 +27,18 @@ A hook for managing a field in a form. • **TData** = `DeepValue`\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Parameters ### opts -`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> An object with field options. ## Returns -`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> & `ReactFieldApi`\<`TParentData`, `TFormValidator`\> +`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> & `ReactFieldApi`\<`TParentData`, `TFormValidator`, `TParentMetaExtension`\> The `FieldApi` instance for the specified field. diff --git a/docs/framework/react/reference/functions/useform.md b/docs/framework/react/reference/functions/useform.md index 826335c33..b6f34b7e8 100644 --- a/docs/framework/react/reference/functions/useform.md +++ b/docs/framework/react/reference/functions/useform.md @@ -6,10 +6,10 @@ title: useForm # Function: useForm() ```ts -function useForm(opts?): ReactFormExtendedApi +function useForm(opts?): ReactFormExtendedApi ``` -Defined in: [packages/react-form/src/useForm.tsx:57](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L57) +Defined in: [packages/react-form/src/useForm.tsx:60](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L60) A custom React Hook that returns an extended instance of the `FormApi` class. @@ -21,12 +21,14 @@ This API encapsulates all the necessary functionalities related to the form. It • **TFormValidator** *extends* `undefined` \| `Validator`\<`TFormData`, `unknown`\> = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### opts? -`FormOptions`\<`TFormData`, `TFormValidator`\> +`FormOptions`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ## Returns -[`ReactFormExtendedApi`](../type-aliases/reactformextendedapi.md)\<`TFormData`, `TFormValidator`\> +[`ReactFormExtendedApi`](../type-aliases/reactformextendedapi.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> diff --git a/docs/framework/react/reference/functions/usetransform.md b/docs/framework/react/reference/functions/usetransform.md index 737c8c8af..b7e2148e0 100644 --- a/docs/framework/react/reference/functions/usetransform.md +++ b/docs/framework/react/reference/functions/usetransform.md @@ -6,7 +6,7 @@ title: useTransform # Function: useTransform() ```ts -function useTransform(fn, deps): FormTransform +function useTransform(fn, deps): FormTransform ``` Defined in: [packages/react-form/src/useTransform.ts:3](https://github.com/TanStack/form/blob/main/packages/react-form/src/useTransform.ts#L3) @@ -17,11 +17,13 @@ Defined in: [packages/react-form/src/useTransform.ts:3](https://github.com/TanSt • **TFormValidator** *extends* `undefined` \| `Validator`\<`TFormData`, `unknown`\> = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### fn -(`formBase`) => `FormApi`\<`TFormData`, `TFormValidator`\> +(`formBase`) => `FormApi`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ### deps @@ -29,4 +31,4 @@ Defined in: [packages/react-form/src/useTransform.ts:3](https://github.com/TanSt ## Returns -`FormTransform`\<`TFormData`, `TFormValidator`\> +`FormTransform`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> diff --git a/docs/framework/react/reference/interfaces/reactformapi.md b/docs/framework/react/reference/interfaces/reactformapi.md index b53804b8d..aa99ba623 100644 --- a/docs/framework/react/reference/interfaces/reactformapi.md +++ b/docs/framework/react/reference/interfaces/reactformapi.md @@ -3,7 +3,7 @@ id: ReactFormApi title: ReactFormApi --- -# Interface: ReactFormApi\ +# Interface: ReactFormApi\ Defined in: [packages/react-form/src/useForm.tsx:14](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L14) @@ -15,15 +15,17 @@ Fields that are added onto the `FormAPI` from `@tanstack/form-core` and returned • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Properties ### Field ```ts -Field: FieldComponent; +Field: FieldComponent; ``` -Defined in: [packages/react-form/src/useForm.tsx:21](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L21) +Defined in: [packages/react-form/src/useForm.tsx:22](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L22) A React component to render form fields. With this, you can render and manage individual form fields. @@ -35,7 +37,7 @@ A React component to render form fields. With this, you can render and manage in Subscribe: (props) => ReactNode; ``` -Defined in: [packages/react-form/src/useForm.tsx:25](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L25) +Defined in: [packages/react-form/src/useForm.tsx:26](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L26) A `Subscribe` function that allows you to listen and react to changes in the form's state. It's especially useful when you need to execute side effects or render specific components in response to state updates. diff --git a/docs/framework/react/reference/type-aliases/fieldcomponent.md b/docs/framework/react/reference/type-aliases/fieldcomponent.md index 00fc39ca7..cfe651494 100644 --- a/docs/framework/react/reference/type-aliases/fieldcomponent.md +++ b/docs/framework/react/reference/type-aliases/fieldcomponent.md @@ -3,16 +3,16 @@ id: FieldComponent title: FieldComponent --- -# Type Alias: FieldComponent()\ +# Type Alias: FieldComponent()\ ```ts -type FieldComponent = ({ +type FieldComponent = ({ children, ...fieldOptions }) => ReactNode; ``` -Defined in: [packages/react-form/src/useField.tsx:134](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L134) +Defined in: [packages/react-form/src/useField.tsx:162](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L162) A type alias representing a field component for a specific form data type. @@ -22,6 +22,8 @@ A type alias representing a field component for a specific form data type. • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Type Parameters • **TName** *extends* `DeepKeys`\<`TParentData`\> @@ -39,7 +41,7 @@ A type alias representing a field component for a specific form data type. ...fieldOptions \} -`Omit`\<`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>, `"form"`\> +`Omit`\<`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>, `"form"`\> ## Returns diff --git a/docs/framework/react/reference/type-aliases/reactformextendedapi.md b/docs/framework/react/reference/type-aliases/reactformextendedapi.md index ec56e7c0d..7a432a37a 100644 --- a/docs/framework/react/reference/type-aliases/reactformextendedapi.md +++ b/docs/framework/react/reference/type-aliases/reactformextendedapi.md @@ -3,13 +3,13 @@ id: ReactFormExtendedApi title: ReactFormExtendedApi --- -# Type Alias: ReactFormExtendedApi\ +# Type Alias: ReactFormExtendedApi\ ```ts -type ReactFormExtendedApi = FormApi & ReactFormApi; +type ReactFormExtendedApi = FormApi & ReactFormApi; ``` -Defined in: [packages/react-form/src/useForm.tsx:34](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L34) +Defined in: [packages/react-form/src/useForm.tsx:35](https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx#L35) An extended version of the `FormApi` class that includes React-specific functionalities from `ReactFormApi` @@ -18,3 +18,5 @@ An extended version of the `FormApi` class that includes React-specific function • **TFormData** • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` + +• **TFormSubmitMeta** = `never` diff --git a/docs/framework/react/reference/type-aliases/usefield.md b/docs/framework/react/reference/type-aliases/usefield.md index 6ebd1f268..12d9ef373 100644 --- a/docs/framework/react/reference/type-aliases/usefield.md +++ b/docs/framework/react/reference/type-aliases/usefield.md @@ -3,13 +3,13 @@ id: UseField title: UseField --- -# Type Alias: UseField()\ +# Type Alias: UseField()\ ```ts -type UseField = (opts) => FieldApi; +type UseField = (opts) => FieldApi; ``` -Defined in: [packages/react-form/src/useField.tsx:26](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L26) +Defined in: [packages/react-form/src/useField.tsx:27](https://github.com/TanStack/form/blob/main/packages/react-form/src/useField.tsx#L27) A type representing a hook for using a field in a form with the given form data type. @@ -21,6 +21,8 @@ A function that takes an optional object with a `name` property and field option • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Type Parameters • **TName** *extends* `DeepKeys`\<`TParentData`\> @@ -35,8 +37,8 @@ A function that takes an optional object with a `name` property and field option ### opts -`Omit`\<`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>, `"form"`\> +`Omit`\<`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>, `"form"`\> ## Returns -`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> diff --git a/docs/framework/solid/reference/functions/createfield.md b/docs/framework/solid/reference/functions/createfield.md index 6befedc54..06feba2df 100644 --- a/docs/framework/solid/reference/functions/createfield.md +++ b/docs/framework/solid/reference/functions/createfield.md @@ -6,10 +6,10 @@ title: createField # Function: createField() ```ts -function createField(opts): () => never +function createField(opts): () => never ``` -Defined in: [packages/solid-form/src/createField.tsx:87](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L87) +Defined in: [packages/solid-form/src/createField.tsx:100](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L100) ## Type Parameters @@ -25,11 +25,13 @@ Defined in: [packages/solid-form/src/createField.tsx:87](https://github.com/TanS • **TData** = `DeepValue`\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Parameters ### opts -() => `CreateFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +() => `CreateFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ## Returns diff --git a/docs/framework/solid/reference/functions/createform.md b/docs/framework/solid/reference/functions/createform.md index 4408204c0..dc552839f 100644 --- a/docs/framework/solid/reference/functions/createform.md +++ b/docs/framework/solid/reference/functions/createform.md @@ -6,10 +6,10 @@ title: createForm # Function: createForm() ```ts -function createForm(opts?): FormApi & SolidFormApi +function createForm(opts?): FormApi & SolidFormApi ``` -Defined in: [packages/solid-form/src/createForm.tsx:26](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L26) +Defined in: [packages/solid-form/src/createForm.tsx:27](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L27) ## Type Parameters @@ -17,12 +17,14 @@ Defined in: [packages/solid-form/src/createForm.tsx:26](https://github.com/TanSt • **TFormValidator** *extends* `undefined` \| `Validator`\<`TParentData`, `unknown`\> = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### opts? -() => `FormOptions`\<`TParentData`, `TFormValidator`\> +() => `FormOptions`\<`TParentData`, `TFormValidator`, `TFormSubmitMeta`\> ## Returns -`FormApi`\<`TParentData`, `TFormValidator`\> & [`SolidFormApi`](../interfaces/solidformapi.md)\<`TParentData`, `TFormValidator`\> +`FormApi`\<`TParentData`, `TFormValidator`, `TFormSubmitMeta`\> & [`SolidFormApi`](../interfaces/solidformapi.md)\<`TParentData`, `TFormValidator`, `TFormSubmitMeta`\> diff --git a/docs/framework/solid/reference/functions/field.md b/docs/framework/solid/reference/functions/field.md index 7cb6956d1..624616b4e 100644 --- a/docs/framework/solid/reference/functions/field.md +++ b/docs/framework/solid/reference/functions/field.md @@ -6,10 +6,10 @@ title: Field # Function: Field() ```ts -function Field(props): Element +function Field(props): Element ``` -Defined in: [packages/solid-form/src/createField.tsx:196](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L196) +Defined in: [packages/solid-form/src/createField.tsx:217](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L217) ## Type Parameters @@ -25,11 +25,13 @@ Defined in: [packages/solid-form/src/createField.tsx:196](https://github.com/Tan • **TData** = `DeepValue`\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Parameters ### props -`object` & `FieldApiOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> & `object` +`object` & `FieldApiOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> & `object` ## Returns diff --git a/docs/framework/solid/reference/interfaces/solidformapi.md b/docs/framework/solid/reference/interfaces/solidformapi.md index a0ae50053..1fedf3e6f 100644 --- a/docs/framework/solid/reference/interfaces/solidformapi.md +++ b/docs/framework/solid/reference/interfaces/solidformapi.md @@ -3,7 +3,7 @@ id: SolidFormApi title: SolidFormApi --- -# Interface: SolidFormApi\ +# Interface: SolidFormApi\ Defined in: [packages/solid-form/src/createForm.tsx:11](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L11) @@ -13,25 +13,27 @@ Defined in: [packages/solid-form/src/createForm.tsx:11](https://github.com/TanSt • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Properties ### createField ```ts -createField: CreateField; +createField: CreateField; ``` -Defined in: [packages/solid-form/src/createForm.tsx:16](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L16) +Defined in: [packages/solid-form/src/createForm.tsx:17](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L17) *** ### Field ```ts -Field: FieldComponent; +Field: FieldComponent; ``` -Defined in: [packages/solid-form/src/createForm.tsx:15](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L15) +Defined in: [packages/solid-form/src/createForm.tsx:16](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L16) *** @@ -41,7 +43,7 @@ Defined in: [packages/solid-form/src/createForm.tsx:15](https://github.com/TanSt Subscribe: (props) => Element; ``` -Defined in: [packages/solid-form/src/createForm.tsx:20](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L20) +Defined in: [packages/solid-form/src/createForm.tsx:21](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L21) #### Type Parameters @@ -71,7 +73,7 @@ Defined in: [packages/solid-form/src/createForm.tsx:20](https://github.com/TanSt useStore: (selector?) => () => TSelected; ``` -Defined in: [packages/solid-form/src/createForm.tsx:17](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L17) +Defined in: [packages/solid-form/src/createForm.tsx:18](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx#L18) #### Type Parameters diff --git a/docs/framework/solid/reference/type-aliases/createfield.md b/docs/framework/solid/reference/type-aliases/createfield.md index 3c91dcf69..20c888c9f 100644 --- a/docs/framework/solid/reference/type-aliases/createfield.md +++ b/docs/framework/solid/reference/type-aliases/createfield.md @@ -3,13 +3,13 @@ id: CreateField title: CreateField --- -# Type Alias: CreateField()\ +# Type Alias: CreateField()\ ```ts -type CreateField = (opts) => () => FieldApi & SolidFieldApi; +type CreateField = (opts) => () => FieldApi & SolidFieldApi; ``` -Defined in: [packages/solid-form/src/createField.tsx:29](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L29) +Defined in: [packages/solid-form/src/createField.tsx:30](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L30) ## Type Parameters @@ -17,6 +17,8 @@ Defined in: [packages/solid-form/src/createField.tsx:29](https://github.com/TanS • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Type Parameters • **TName** *extends* `DeepKeys`\<`TParentData`\> @@ -31,7 +33,7 @@ Defined in: [packages/solid-form/src/createField.tsx:29](https://github.com/TanS ### opts -() => `object` & `Omit`\<`CreateFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>, `"form"`\> +() => `object` & `Omit`\<`CreateFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>, `"form"`\> ## Returns @@ -39,4 +41,4 @@ Defined in: [packages/solid-form/src/createField.tsx:29](https://github.com/TanS ### Returns -`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> & `SolidFieldApi`\<`TParentData`, `TFormValidator`\> +`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> & `SolidFieldApi`\<`TParentData`, `TFormValidator`, `TParentMetaExtension`\> diff --git a/docs/framework/solid/reference/type-aliases/fieldcomponent.md b/docs/framework/solid/reference/type-aliases/fieldcomponent.md index d0464a4ea..1cefe4a88 100644 --- a/docs/framework/solid/reference/type-aliases/fieldcomponent.md +++ b/docs/framework/solid/reference/type-aliases/fieldcomponent.md @@ -3,16 +3,16 @@ id: FieldComponent title: FieldComponent --- -# Type Alias: FieldComponent()\ +# Type Alias: FieldComponent()\ ```ts -type FieldComponent = ({ +type FieldComponent = ({ children, ...fieldOptions }) => JSXElement; ``` -Defined in: [packages/solid-form/src/createField.tsx:171](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L171) +Defined in: [packages/solid-form/src/createField.tsx:190](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx#L190) ## Type Parameters @@ -20,6 +20,8 @@ Defined in: [packages/solid-form/src/createField.tsx:171](https://github.com/Tan • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Type Parameters • **TName** *extends* `DeepKeys`\<`TParentData`\> @@ -37,7 +39,7 @@ Defined in: [packages/solid-form/src/createField.tsx:171](https://github.com/Tan ...fieldOptions \} -`Omit`\<`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>, `"form"`\> +`Omit`\<`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>, `"form"`\> ## Returns diff --git a/docs/framework/vue/reference/functions/usefield.md b/docs/framework/vue/reference/functions/usefield.md index 2f06fddb5..46d822368 100644 --- a/docs/framework/vue/reference/functions/usefield.md +++ b/docs/framework/vue/reference/functions/usefield.md @@ -6,10 +6,10 @@ title: useField # Function: useField() ```ts -function useField(opts): object +function useField(opts): object ``` -Defined in: [packages/vue-form/src/useField.tsx:49](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L49) +Defined in: [packages/vue-form/src/useField.tsx:66](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L66) ## Type Parameters @@ -25,11 +25,13 @@ Defined in: [packages/vue-form/src/useField.tsx:49](https://github.com/TanStack/ • **TData** = `DeepValue`\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Parameters ### opts -`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ## Returns @@ -38,7 +40,7 @@ Defined in: [packages/vue-form/src/useField.tsx:49](https://github.com/TanStack/ ### api ```ts -readonly api: FieldApi & VueFieldApi = fieldApi; +readonly api: FieldApi & VueFieldApi = fieldApi; ``` ### state diff --git a/docs/framework/vue/reference/functions/useform.md b/docs/framework/vue/reference/functions/useform.md index 2d67b6719..4308bb46e 100644 --- a/docs/framework/vue/reference/functions/useform.md +++ b/docs/framework/vue/reference/functions/useform.md @@ -6,10 +6,10 @@ title: useForm # Function: useForm() ```ts -function useForm(opts?): FormApi & VueFormApi +function useForm(opts?): FormApi & VueFormApi ``` -Defined in: [packages/vue-form/src/useForm.tsx:30](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L30) +Defined in: [packages/vue-form/src/useForm.tsx:31](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L31) ## Type Parameters @@ -17,12 +17,14 @@ Defined in: [packages/vue-form/src/useForm.tsx:30](https://github.com/TanStack/f • **TFormValidator** *extends* `undefined` \| `Validator`\<`TFormData`, `unknown`\> = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### opts? -`FormOptions`\<`TFormData`, `TFormValidator`\> +`FormOptions`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ## Returns -`FormApi`\<`TFormData`, `TFormValidator`\> & [`VueFormApi`](../interfaces/vueformapi.md)\<`TFormData`, `TFormValidator`\> +`FormApi`\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> & [`VueFormApi`](../interfaces/vueformapi.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> diff --git a/docs/framework/vue/reference/interfaces/vuefieldapi.md b/docs/framework/vue/reference/interfaces/vuefieldapi.md index 5b638938c..b3ba8f093 100644 --- a/docs/framework/vue/reference/interfaces/vuefieldapi.md +++ b/docs/framework/vue/reference/interfaces/vuefieldapi.md @@ -3,7 +3,7 @@ id: VueFieldApi title: VueFieldApi --- -# Interface: VueFieldApi\ +# Interface: VueFieldApi\ Defined in: [packages/vue-form/src/useField.tsx:8](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L8) @@ -13,12 +13,14 @@ Defined in: [packages/vue-form/src/useField.tsx:8](https://github.com/TanStack/f • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Properties ### Field ```ts -Field: FieldComponent; +Field: FieldComponent; ``` -Defined in: [packages/vue-form/src/useField.tsx:14](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L14) +Defined in: [packages/vue-form/src/useField.tsx:15](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L15) diff --git a/docs/framework/vue/reference/interfaces/vueformapi.md b/docs/framework/vue/reference/interfaces/vueformapi.md index 9cd097244..df7cccb0a 100644 --- a/docs/framework/vue/reference/interfaces/vueformapi.md +++ b/docs/framework/vue/reference/interfaces/vueformapi.md @@ -3,7 +3,7 @@ id: VueFormApi title: VueFormApi --- -# Interface: VueFormApi\ +# Interface: VueFormApi\ Defined in: [packages/vue-form/src/useForm.tsx:10](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L10) @@ -13,15 +13,17 @@ Defined in: [packages/vue-form/src/useForm.tsx:10](https://github.com/TanStack/f • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Properties ### Field ```ts -Field: FieldComponent; +Field: FieldComponent; ``` -Defined in: [packages/vue-form/src/useForm.tsx:14](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L14) +Defined in: [packages/vue-form/src/useForm.tsx:15](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L15) *** @@ -31,7 +33,7 @@ Defined in: [packages/vue-form/src/useForm.tsx:14](https://github.com/TanStack/f Subscribe: (props, context) => any; ``` -Defined in: [packages/vue-form/src/useForm.tsx:19](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L19) +Defined in: [packages/vue-form/src/useForm.tsx:20](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L20) #### Type Parameters @@ -60,10 +62,10 @@ Defined in: [packages/vue-form/src/useForm.tsx:19](https://github.com/TanStack/f ### useField ```ts -useField: UseField; +useField: UseField; ``` -Defined in: [packages/vue-form/src/useForm.tsx:15](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L15) +Defined in: [packages/vue-form/src/useForm.tsx:16](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L16) *** @@ -73,7 +75,7 @@ Defined in: [packages/vue-form/src/useForm.tsx:15](https://github.com/TanStack/f useStore: (selector?) => Readonly>; ``` -Defined in: [packages/vue-form/src/useForm.tsx:16](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L16) +Defined in: [packages/vue-form/src/useForm.tsx:17](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L17) #### Type Parameters diff --git a/docs/framework/vue/reference/type-aliases/fieldcomponent.md b/docs/framework/vue/reference/type-aliases/fieldcomponent.md index 15179546d..48aa77afe 100644 --- a/docs/framework/vue/reference/type-aliases/fieldcomponent.md +++ b/docs/framework/vue/reference/type-aliases/fieldcomponent.md @@ -3,13 +3,13 @@ id: FieldComponent title: FieldComponent --- -# Type Alias: FieldComponent()\ +# Type Alias: FieldComponent()\ ```ts -type FieldComponent = (fieldOptions, context) => any; +type FieldComponent = (fieldOptions, context) => any; ``` -Defined in: [packages/vue-form/src/useField.tsx:117](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L117) +Defined in: [packages/vue-form/src/useField.tsx:145](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L145) ## Type Parameters @@ -17,6 +17,8 @@ Defined in: [packages/vue-form/src/useField.tsx:117](https://github.com/TanStack • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Type Parameters • **TName** *extends* `DeepKeys`\<`TParentData`\> @@ -31,14 +33,14 @@ Defined in: [packages/vue-form/src/useField.tsx:117](https://github.com/TanStack ### fieldOptions -`Omit`\<`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>, `"form"`\> +`Omit`\<`FieldComponentProps`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>, `"form"`\> ### context `SetupContext`\<\{\}, `SlotsType`\<\{ `default`: \{ - `field`: `FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>; - `state`: `FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>\[`"state"`\]; + `field`: `FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>; + `state`: `FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>\[`"state"`\]; \}; \}\>\> diff --git a/docs/framework/vue/reference/type-aliases/usefield.md b/docs/framework/vue/reference/type-aliases/usefield.md index 5fb33846e..186058f4b 100644 --- a/docs/framework/vue/reference/type-aliases/usefield.md +++ b/docs/framework/vue/reference/type-aliases/usefield.md @@ -3,13 +3,13 @@ id: UseField title: UseField --- -# Type Alias: UseField()\ +# Type Alias: UseField()\ ```ts -type UseField = (opts) => object; +type UseField = (opts) => object; ``` -Defined in: [packages/vue-form/src/useField.tsx:17](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L17) +Defined in: [packages/vue-form/src/useField.tsx:18](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L18) ## Type Parameters @@ -17,6 +17,8 @@ Defined in: [packages/vue-form/src/useField.tsx:17](https://github.com/TanStack/ • **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined` +• **TParentMetaExtension** = `never` + ## Type Parameters • **TName** *extends* `DeepKeys`\<`TParentData`\> @@ -31,7 +33,7 @@ Defined in: [packages/vue-form/src/useField.tsx:17](https://github.com/TanStack/ ### opts -`Omit`\<`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>, `"form"`\> +`Omit`\<`UseFieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\>, `"form"`\> ## Returns @@ -40,11 +42,11 @@ Defined in: [packages/vue-form/src/useField.tsx:17](https://github.com/TanStack/ ### api ```ts -api: FieldApi & VueFieldApi; +api: FieldApi & VueFieldApi; ``` ### state ```ts -state: Readonly["state"]>>; +state: Readonly["state"]>>; ``` diff --git a/docs/framework/vue/reference/variables/field.md b/docs/framework/vue/reference/variables/field.md index 8b9c3092d..01c1b426d 100644 --- a/docs/framework/vue/reference/variables/field.md +++ b/docs/framework/vue/reference/variables/field.md @@ -6,17 +6,17 @@ title: Field # Variable: Field() ```ts -const Field: (props) => CreateComponentPublicInstanceWithMixins & object & {} | {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, ComponentProvideOptions, OptionTypesType<{}, {}, {}, {}, {}, {}>, object & FieldApiOptions & { mode?: "value" | ... 1 more ... | undefined; } & ({ ...; } | { ...; }), {}, {}, {}, {}, {}>; +const Field: (props) => CreateComponentPublicInstanceWithMixins & object & {} | {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, ComponentProvideOptions, OptionTypesType<{}, {}, {}, {}, {}, {}>, object & FieldApiOptions & { ...; } & ({ ...; } | { ...; }), {}, {}, {}, {}, {}>; ``` -Defined in: [packages/vue-form/src/useField.tsx:162](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L162) +Defined in: [packages/vue-form/src/useField.tsx:194](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L194) ## Parameters ### props -FieldApiOptions\ & \{ mode?: "value" \| ... 1 more ... \| undefined; \} & (\{ ...; \} \| \{ ...; \}) & `VNodeProps` & `AllowedComponentProps` & `ComponentCustomProps` +FieldApiOptions\ & \{ ...; \} & (\{ ...; \} \| \{ ...; \}) & `VNodeProps` & `AllowedComponentProps` & `ComponentCustomProps` ## Returns -`CreateComponentPublicInstanceWithMixins`\<`FieldApiOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> & `object` & \{\} \| \{\}, \{\}, \{\}, \{\}, \{\}, `ComponentOptionsMixin`, `ComponentOptionsMixin`, `EmitsOptions`, `PublicProps`, \{\}, `false`, \{\}, \{\}, \{\}, \{\}, `string`, \{\}, `any`, `ComponentProvideOptions`, `OptionTypesType`\<\{\}, \{\}, \{\}, \{\}, \{\}, \{\}\>, `object` & FieldApiOptions\ & \{ mode?: "value" \| ... 1 more ... \| undefined; \} & (\{ ...; \} \| \{ ...; \}), \{\}, \{\}, \{\}, \{\}, \{\}\> +`CreateComponentPublicInstanceWithMixins`\<`FieldApiOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> & `object` & \{\} \| \{\}, \{\}, \{\}, \{\}, \{\}, `ComponentOptionsMixin`, `ComponentOptionsMixin`, `EmitsOptions`, `PublicProps`, \{\}, `false`, \{\}, \{\}, \{\}, \{\}, `string`, \{\}, `any`, `ComponentProvideOptions`, `OptionTypesType`\<\{\}, \{\}, \{\}, \{\}, \{\}, \{\}\>, `object` & FieldApiOptions\ & \{ ...; \} & (\{ ...; \} \| \{ ...; \}), \{\}, \{\}, \{\}, \{\}, \{\}\> diff --git a/docs/reference/classes/fieldapi.md b/docs/reference/classes/fieldapi.md index 5821b91af..fd188d54d 100644 --- a/docs/reference/classes/fieldapi.md +++ b/docs/reference/classes/fieldapi.md @@ -3,9 +3,9 @@ id: FieldApi title: FieldApi --- -# Class: FieldApi\ +# Class: FieldApi\ -Defined in: [packages/form-core/src/FieldApi.ts:427](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L427) +Defined in: [packages/form-core/src/FieldApi.ts:475](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L475) A class representing the API for managing a form field. @@ -29,15 +29,17 @@ the `new FieldApi` constructor. • **TData** *extends* [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> = [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Constructors ### new FieldApi() ```ts -new FieldApi(opts): FieldApi +new FieldApi(opts): FieldApi ``` -Defined in: [packages/form-core/src/FieldApi.ts:477](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L477) +Defined in: [packages/form-core/src/FieldApi.ts:528](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L528) Initializes a new `FieldApi` instance. @@ -45,21 +47,21 @@ Initializes a new `FieldApi` instance. ##### opts -[`FieldApiOptions`](../interfaces/fieldapioptions.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +[`FieldApiOptions`](../interfaces/fieldapioptions.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> #### Returns -[`FieldApi`](fieldapi.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +[`FieldApi`](fieldapi.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ## Properties ### form ```ts -form: FormApi; +form: FormApi; ``` -Defined in: [packages/form-core/src/FieldApi.ts:441](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L441) +Defined in: [packages/form-core/src/FieldApi.ts:490](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L490) A reference to the form API instance. @@ -71,7 +73,7 @@ A reference to the form API instance. name: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple ? PrefixTupleAccessor, AllowedIndexes, never>, []> : TParentData extends any[] ? PrefixArrayAccessor, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor, []> : TParentData extends string | number | bigint | boolean ? "" : never; ``` -Defined in: [packages/form-core/src/FieldApi.ts:451](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L451) +Defined in: [packages/form-core/src/FieldApi.ts:501](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L501) The field name. @@ -80,10 +82,10 @@ The field name. ### options ```ts -options: FieldApiOptions; +options: FieldApiOptions; ``` -Defined in: [packages/form-core/src/FieldApi.ts:455](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L455) +Defined in: [packages/form-core/src/FieldApi.ts:505](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L505) The field options. @@ -95,7 +97,7 @@ The field options. store: Derived>; ``` -Defined in: [packages/form-core/src/FieldApi.ts:465](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L465) +Defined in: [packages/form-core/src/FieldApi.ts:516](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L516) The field state store. @@ -107,7 +109,7 @@ The field state store. timeoutIds: Record; ``` -Defined in: [packages/form-core/src/FieldApi.ts:472](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L472) +Defined in: [packages/form-core/src/FieldApi.ts:523](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L523) ## Accessors @@ -119,7 +121,7 @@ Defined in: [packages/form-core/src/FieldApi.ts:472](https://github.com/TanStack get state(): FieldState ``` -Defined in: [packages/form-core/src/FieldApi.ts:469](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L469) +Defined in: [packages/form-core/src/FieldApi.ts:520](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L520) The current field state. @@ -132,16 +134,16 @@ The current field state. ### getInfo() ```ts -getInfo(): FieldInfo +getInfo(): FieldInfo ``` -Defined in: [packages/form-core/src/FieldApi.ts:673](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L673) +Defined in: [packages/form-core/src/FieldApi.ts:728](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L728) Gets the field information object. #### Returns -[`FieldInfo`](../type-aliases/fieldinfo.md)\<`TParentData`, `TFormValidator`\> +[`FieldInfo`](../type-aliases/fieldinfo.md)\<`TParentData`, `TFormValidator`, `never`\> *** @@ -151,7 +153,7 @@ Gets the field information object. getMeta(): FieldMeta ``` -Defined in: [packages/form-core/src/FieldApi.ts:662](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L662) +Defined in: [packages/form-core/src/FieldApi.ts:717](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L717) #### Returns @@ -165,7 +167,7 @@ Defined in: [packages/form-core/src/FieldApi.ts:662](https://github.com/TanStack getValue(): TData ``` -Defined in: [packages/form-core/src/FieldApi.ts:644](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L644) +Defined in: [packages/form-core/src/FieldApi.ts:699](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L699) Gets the current field value. @@ -185,7 +187,7 @@ Use `field.state.value` instead. handleBlur(): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:1025](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1025) +Defined in: [packages/form-core/src/FieldApi.ts:1089](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1089) Handles the blur event. @@ -201,7 +203,7 @@ Handles the blur event. handleChange(updater): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:1018](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1018) +Defined in: [packages/form-core/src/FieldApi.ts:1082](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1082) Handles the change event. @@ -226,7 +228,7 @@ insertValue( opts?): Promise ``` -Defined in: [packages/form-core/src/FieldApi.ts:686](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L686) +Defined in: [packages/form-core/src/FieldApi.ts:741](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L741) Inserts a value at the specified index, shifting the subsequent values to the right. @@ -256,7 +258,7 @@ Inserts a value at the specified index, shifting the subsequent values to the ri mount(): () => void ``` -Defined in: [packages/form-core/src/FieldApi.ts:567](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L567) +Defined in: [packages/form-core/src/FieldApi.ts:621](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L621) Mounts the field instance to the form. @@ -279,7 +281,7 @@ moveValue( opts?): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:716](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L716) +Defined in: [packages/form-core/src/FieldApi.ts:771](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L771) Moves the value at the first specified index to the second specified index. @@ -309,7 +311,7 @@ Moves the value at the first specified index to the second specified index. pushValue(value, opts?): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:678](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L678) +Defined in: [packages/form-core/src/FieldApi.ts:733](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L733) Pushes a new value to the field. @@ -335,7 +337,7 @@ Pushes a new value to the field. removeValue(index, opts?): Promise ``` -Defined in: [packages/form-core/src/FieldApi.ts:704](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L704) +Defined in: [packages/form-core/src/FieldApi.ts:759](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L759) Removes a value at the specified index. @@ -364,7 +366,7 @@ replaceValue( opts?): Promise ``` -Defined in: [packages/form-core/src/FieldApi.ts:695](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L695) +Defined in: [packages/form-core/src/FieldApi.ts:750](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L750) Replaces a value at the specified index. @@ -394,7 +396,7 @@ Replaces a value at the specified index. setErrorMap(errorMap): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:1045](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1045) +Defined in: [packages/form-core/src/FieldApi.ts:1109](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1109) Updates the field's errorMap @@ -416,7 +418,7 @@ Updates the field's errorMap setMeta(updater): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:667](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L667) +Defined in: [packages/form-core/src/FieldApi.ts:722](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L722) Sets the field metadata. @@ -438,7 +440,7 @@ Sets the field metadata. setValue(updater, options?): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:651](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L651) +Defined in: [packages/form-core/src/FieldApi.ts:706](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L706) Sets the field value and run the `change` validator. @@ -467,7 +469,7 @@ swapValues( opts?): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:710](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L710) +Defined in: [packages/form-core/src/FieldApi.ts:765](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L765) Swaps the values at the specified indices. @@ -497,7 +499,7 @@ Swaps the values at the specified indices. update(opts): void ``` -Defined in: [packages/form-core/src/FieldApi.ts:606](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L606) +Defined in: [packages/form-core/src/FieldApi.ts:660](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L660) Updates the field instance with new options. @@ -505,7 +507,7 @@ Updates the field instance with new options. ##### opts -[`FieldApiOptions`](../interfaces/fieldapioptions.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +[`FieldApiOptions`](../interfaces/fieldapioptions.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> #### Returns @@ -521,7 +523,7 @@ validate(cause): | Promise ``` -Defined in: [packages/form-core/src/FieldApi.ts:990](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L990) +Defined in: [packages/form-core/src/FieldApi.ts:1054](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1054) Validates the field value. diff --git a/docs/reference/classes/formapi.md b/docs/reference/classes/formapi.md index 5ec82b4d3..cf486b7a1 100644 --- a/docs/reference/classes/formapi.md +++ b/docs/reference/classes/formapi.md @@ -3,9 +3,9 @@ id: FormApi title: FormApi --- -# Class: FormApi\ +# Class: FormApi\ -Defined in: [packages/form-core/src/FormApi.ts:361](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L361) +Defined in: [packages/form-core/src/FormApi.ts:396](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L396) A class representing the Form API. It handles the logic and interactions with the form state. @@ -19,15 +19,17 @@ However, if you need to create a new instance manually, you can do so by calling • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Constructors ### new FormApi() ```ts -new FormApi(opts?): FormApi +new FormApi(opts?): FormApi ``` -Defined in: [packages/form-core/src/FormApi.ts:390](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L390) +Defined in: [packages/form-core/src/FormApi.ts:426](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L426) Constructs a new `FormApi` instance with the given form options. @@ -35,11 +37,11 @@ Constructs a new `FormApi` instance with the given form options. ##### opts? -[`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`\> +[`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> #### Returns -[`FormApi`](formapi.md)\<`TFormData`, `TFormValidator`\> +[`FormApi`](formapi.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ## Properties @@ -49,17 +51,17 @@ Constructs a new `FormApi` instance with the given form options. baseStore: Store, (cb) => BaseFormState>; ``` -Defined in: [packages/form-core/src/FormApi.ts:369](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L369) +Defined in: [packages/form-core/src/FormApi.ts:405](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L405) *** ### fieldInfo ```ts -fieldInfo: Record ? PrefixTupleAccessor, AllowedIndexes, never>, []> : TFormData extends any[] ? PrefixArrayAccessor, [any]> : TFormData extends Date ? never : TFormData extends object ? PrefixObjectAccessor, []> : TFormData extends string | number | bigint | boolean ? "" : never, FieldInfo>; +fieldInfo: Record ? PrefixTupleAccessor, AllowedIndexes, never>, []> : TFormData extends any[] ? PrefixArrayAccessor, [any]> : TFormData extends Date ? never : TFormData extends object ? PrefixObjectAccessor, []> : TFormData extends string | number | bigint | boolean ? "" : never, FieldInfo>; ``` -Defined in: [packages/form-core/src/FormApi.ts:375](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L375) +Defined in: [packages/form-core/src/FormApi.ts:411](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L411) A record of field information for each field in the form. @@ -71,17 +73,17 @@ A record of field information for each field in the form. fieldMetaDerived: Derived ? PrefixTupleAccessor, AllowedIndexes, never>, []> : TFormData extends any[] ? PrefixArrayAccessor, [any]> : TFormData extends Date ? never : TFormData extends object ? PrefixObjectAccessor, []> : TFormData extends string | number | bigint | boolean ? "" : never, FieldMeta>>; ``` -Defined in: [packages/form-core/src/FormApi.ts:370](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L370) +Defined in: [packages/form-core/src/FormApi.ts:406](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L406) *** ### options ```ts -options: FormOptions = {}; +options: FormOptions = {}; ``` -Defined in: [packages/form-core/src/FormApi.ts:368](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L368) +Defined in: [packages/form-core/src/FormApi.ts:404](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L404) The options for the form. @@ -93,7 +95,7 @@ The options for the form. store: Derived>; ``` -Defined in: [packages/form-core/src/FormApi.ts:371](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L371) +Defined in: [packages/form-core/src/FormApi.ts:407](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L407) ## Accessors @@ -105,7 +107,7 @@ Defined in: [packages/form-core/src/FormApi.ts:371](https://github.com/TanStack/ get state(): FormState ``` -Defined in: [packages/form-core/src/FormApi.ts:378](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L378) +Defined in: [packages/form-core/src/FormApi.ts:414](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L414) ##### Returns @@ -119,7 +121,7 @@ Defined in: [packages/form-core/src/FormApi.ts:378](https://github.com/TanStack/ deleteField(field): void ``` -Defined in: [packages/form-core/src/FormApi.ts:1227](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1227) +Defined in: [packages/form-core/src/FormApi.ts:1274](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1274) #### Type Parameters @@ -140,10 +142,10 @@ Defined in: [packages/form-core/src/FormApi.ts:1227](https://github.com/TanStack ### getFieldInfo() ```ts -getFieldInfo(field): FieldInfo +getFieldInfo(field): FieldInfo ``` -Defined in: [packages/form-core/src/FormApi.ts:1136](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1136) +Defined in: [packages/form-core/src/FormApi.ts:1183](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1183) Gets the field info of the specified field. @@ -159,7 +161,7 @@ Gets the field info of the specified field. #### Returns -[`FieldInfo`](../type-aliases/fieldinfo.md)\<`TFormData`, `TFormValidator`\> +[`FieldInfo`](../type-aliases/fieldinfo.md)\<`TFormData`, `TFormValidator`, `never`\> *** @@ -169,7 +171,7 @@ Gets the field info of the specified field. getFieldMeta(field): undefined | FieldMeta ``` -Defined in: [packages/form-core/src/FormApi.ts:1127](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1127) +Defined in: [packages/form-core/src/FormApi.ts:1174](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1174) Gets the metadata of the specified field. @@ -195,7 +197,7 @@ Gets the metadata of the specified field. getFieldValue(field): DeepValue> ``` -Defined in: [packages/form-core/src/FormApi.ts:1120](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1120) +Defined in: [packages/form-core/src/FormApi.ts:1167](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1167) Gets the value of the specified field. @@ -217,15 +219,37 @@ Gets the value of the specified field. ### handleSubmit() +#### Call Signature + ```ts handleSubmit(): Promise ``` -Defined in: [packages/form-core/src/FormApi.ts:1061](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1061) +Defined in: [packages/form-core/src/FormApi.ts:1101](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1101) Handles the form submission, performs validation, and calls the appropriate onSubmit or onInvalidSubmit callbacks. -#### Returns +##### Returns + +`Promise`\<`void`\> + +#### Call Signature + +```ts +handleSubmit(submitMeta): Promise +``` + +Defined in: [packages/form-core/src/FormApi.ts:1102](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1102) + +Handles the form submission, performs validation, and calls the appropriate onSubmit or onInvalidSubmit callbacks. + +##### Parameters + +###### submitMeta + +`TFormSubmitMeta` + +##### Returns `Promise`\<`void`\> @@ -241,7 +265,7 @@ insertFieldValue( opts?): Promise ``` -Defined in: [packages/form-core/src/FormApi.ts:1259](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1259) +Defined in: [packages/form-core/src/FormApi.ts:1306](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1306) Inserts a value into an array field at the specified index, shifting the subsequent values to the right. @@ -279,7 +303,7 @@ Inserts a value into an array field at the specified index, shifting the subsequ mount(): () => void ``` -Defined in: [packages/form-core/src/FormApi.ts:638](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L638) +Defined in: [packages/form-core/src/FormApi.ts:676](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L676) #### Returns @@ -301,7 +325,7 @@ moveFieldValues( opts?): void ``` -Defined in: [packages/form-core/src/FormApi.ts:1377](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1377) +Defined in: [packages/form-core/src/FormApi.ts:1424](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1424) Moves the value at the first specified index to the second specified index within an array field. @@ -342,7 +366,7 @@ pushFieldValue( opts?): void ``` -Defined in: [packages/form-core/src/FormApi.ts:1241](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1241) +Defined in: [packages/form-core/src/FormApi.ts:1288](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1288) Pushes a value into an array field. @@ -379,7 +403,7 @@ removeFieldValue( opts?): Promise ``` -Defined in: [packages/form-core/src/FormApi.ts:1312](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1312) +Defined in: [packages/form-core/src/FormApi.ts:1359](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1359) Removes a value from an array field at the specified index. @@ -417,7 +441,7 @@ replaceFieldValue( opts?): Promise ``` -Defined in: [packages/form-core/src/FormApi.ts:1286](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1286) +Defined in: [packages/form-core/src/FormApi.ts:1333](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1333) Replaces a value into an array field at the specified index. @@ -455,7 +479,7 @@ Replaces a value into an array field at the specified index. reset(values?, opts?): void ``` -Defined in: [packages/form-core/src/FormApi.ts:701](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L701) +Defined in: [packages/form-core/src/FormApi.ts:741](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L741) Resets the form state to the default values. If values are provided, the form will be reset to those values instead and the default values will be updated. @@ -488,7 +512,7 @@ Optional options to control the reset behavior. resetFieldMeta(fieldMeta): Record ``` -Defined in: [packages/form-core/src/FormApi.ts:1173](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1173) +Defined in: [packages/form-core/src/FormApi.ts:1220](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1220) #### Type Parameters @@ -512,7 +536,7 @@ Defined in: [packages/form-core/src/FormApi.ts:1173](https://github.com/TanStack setErrorMap(errorMap): void ``` -Defined in: [packages/form-core/src/FormApi.ts:1401](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1401) +Defined in: [packages/form-core/src/FormApi.ts:1448](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1448) Updates the form's errorMap @@ -534,7 +558,7 @@ Updates the form's errorMap setFieldMeta(field, updater): void ``` -Defined in: [packages/form-core/src/FormApi.ts:1155](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1155) +Defined in: [packages/form-core/src/FormApi.ts:1202](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1202) Updates the metadata of the specified field. @@ -567,7 +591,7 @@ setFieldValue( opts?): void ``` -Defined in: [packages/form-core/src/FormApi.ts:1197](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1197) +Defined in: [packages/form-core/src/FormApi.ts:1244](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1244) Sets the value of the specified field and optionally updates the touched state. @@ -605,7 +629,7 @@ swapFieldValues( opts?): void ``` -Defined in: [packages/form-core/src/FormApi.ts:1351](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1351) +Defined in: [packages/form-core/src/FormApi.ts:1398](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1398) Swaps the values at the specified indices within an array field. @@ -643,7 +667,7 @@ Swaps the values at the specified indices within an array field. update(options?): void ``` -Defined in: [packages/form-core/src/FormApi.ts:655](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L655) +Defined in: [packages/form-core/src/FormApi.ts:693](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L693) Updates the form options and form state. @@ -651,7 +675,7 @@ Updates the form options and form state. ##### options? -[`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`\> +[`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> #### Returns @@ -665,7 +689,7 @@ Updates the form options and form state. validateAllFields(cause): Promise ``` -Defined in: [packages/form-core/src/FormApi.ts:727](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L727) +Defined in: [packages/form-core/src/FormApi.ts:767](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L767) Validates form and all fields in using the correct handlers for a given validation cause. @@ -690,7 +714,7 @@ validateArrayFieldsStartingFrom( cause): Promise ``` -Defined in: [packages/form-core/src/FormApi.ts:755](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L755) +Defined in: [packages/form-core/src/FormApi.ts:795](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L795) Validates the children of a specified array in the form starting from a given index until the end using the correct handlers for a given validation type. @@ -726,7 +750,7 @@ validateField(field, cause): | Promise ``` -Defined in: [packages/form-core/src/FormApi.ts:794](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L794) +Defined in: [packages/form-core/src/FormApi.ts:834](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L834) Validates a specified field in the form using the correct handlers for a given validation type. diff --git a/docs/reference/functions/formoptions.md b/docs/reference/functions/formoptions.md index 9b3ff5ea1..915748f5e 100644 --- a/docs/reference/functions/formoptions.md +++ b/docs/reference/functions/formoptions.md @@ -6,9 +6,9 @@ title: formOptions # Function: formOptions() ```ts -function formOptions(defaultOpts?): +function formOptions(defaultOpts?): | undefined -| FormOptions +| FormOptions ``` Defined in: [packages/form-core/src/formOptions.ts:4](https://github.com/TanStack/form/blob/main/packages/form-core/src/formOptions.ts#L4) @@ -19,13 +19,15 @@ Defined in: [packages/form-core/src/formOptions.ts:4](https://github.com/TanStac • **TFormValidator** *extends* `undefined` \| `Validator`\<`TFormData`, `unknown`\> = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### defaultOpts? -[`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`\> +[`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ## Returns \| `undefined` - \| [`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`\> + \| [`FormOptions`](../interfaces/formoptions.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> diff --git a/docs/reference/functions/mergeform.md b/docs/reference/functions/mergeform.md index 103beee34..8e0682b52 100644 --- a/docs/reference/functions/mergeform.md +++ b/docs/reference/functions/mergeform.md @@ -6,7 +6,7 @@ title: mergeForm # Function: mergeForm() ```ts -function mergeForm(baseForm, state): FormApi, NoInfer> +function mergeForm(baseForm, state): FormApi, NoInfer, NoInfer> ``` Defined in: [packages/form-core/src/mergeForm.ts:36](https://github.com/TanStack/form/blob/main/packages/form-core/src/mergeForm.ts#L36) @@ -17,11 +17,13 @@ Defined in: [packages/form-core/src/mergeForm.ts:36](https://github.com/TanStack • **TFormValidator** *extends* `undefined` \| `Validator`\<`TFormData`, `unknown`\> = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### baseForm -[`FormApi`](../classes/formapi.md)\<`NoInfer`\<`TFormData`\>, `NoInfer`\<`TFormValidator`\>\> +[`FormApi`](../classes/formapi.md)\<`NoInfer`\<`TFormData`\>, `NoInfer`\<`TFormValidator`\>, `NoInfer`\<`TFormSubmitMeta`\>\> ### state @@ -29,4 +31,4 @@ Defined in: [packages/form-core/src/mergeForm.ts:36](https://github.com/TanStack ## Returns -[`FormApi`](../classes/formapi.md)\<`NoInfer`\<`TFormData`\>, `NoInfer`\<`TFormValidator`\>\> +[`FormApi`](../classes/formapi.md)\<`NoInfer`\<`TFormData`\>, `NoInfer`\<`TFormValidator`\>, `NoInfer`\<`TFormSubmitMeta`\>\> diff --git a/docs/reference/interfaces/fieldapioptions.md b/docs/reference/interfaces/fieldapioptions.md index 842ab2292..f990faf89 100644 --- a/docs/reference/interfaces/fieldapioptions.md +++ b/docs/reference/interfaces/fieldapioptions.md @@ -3,15 +3,15 @@ id: FieldApiOptions title: FieldApiOptions --- -# Interface: FieldApiOptions\ +# Interface: FieldApiOptions\ -Defined in: [packages/form-core/src/FieldApi.ts:345](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L345) +Defined in: [packages/form-core/src/FieldApi.ts:391](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L391) An object type representing the required options for the FieldApi class. ## Extends -- [`FieldOptions`](fieldoptions.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> +- [`FieldOptions`](fieldoptions.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`, `TParentMetaExtension`\> ## Type Parameters @@ -27,6 +27,8 @@ An object type representing the required options for the FieldApi class. • **TData** *extends* [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> = [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Properties ### asyncAlways? @@ -35,7 +37,7 @@ An object type representing the required options for the FieldApi class. optional asyncAlways: boolean; ``` -Defined in: [packages/form-core/src/FieldApi.ts:311](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L311) +Defined in: [packages/form-core/src/FieldApi.ts:355](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L355) If `true`, always run async validation, even if there are errors emitted during synchronous validation. @@ -51,7 +53,7 @@ If `true`, always run async validation, even if there are errors emitted during optional asyncDebounceMs: number; ``` -Defined in: [packages/form-core/src/FieldApi.ts:307](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L307) +Defined in: [packages/form-core/src/FieldApi.ts:351](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L351) The default time to debounce async validation if there is not a more specific debounce time passed. @@ -67,7 +69,7 @@ The default time to debounce async validation if there is not a more specific de optional defaultMeta: Partial; ``` -Defined in: [packages/form-core/src/FieldApi.ts:329](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L329) +Defined in: [packages/form-core/src/FieldApi.ts:374](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L374) An optional object with default metadata for the field. @@ -83,7 +85,7 @@ An optional object with default metadata for the field. optional defaultValue: NoInfer; ``` -Defined in: [packages/form-core/src/FieldApi.ts:303](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L303) +Defined in: [packages/form-core/src/FieldApi.ts:347](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L347) An optional default value for the field. @@ -96,20 +98,20 @@ An optional default value for the field. ### form ```ts -form: FormApi; +form: FormApi; ``` -Defined in: [packages/form-core/src/FieldApi.ts:362](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L362) +Defined in: [packages/form-core/src/FieldApi.ts:410](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L410) *** ### listeners? ```ts -optional listeners: FieldListeners; +optional listeners: FieldListeners; ``` -Defined in: [packages/form-core/src/FieldApi.ts:333](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L333) +Defined in: [packages/form-core/src/FieldApi.ts:378](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L378) A list of listeners which attach to the corresponding events @@ -125,7 +127,7 @@ A list of listeners which attach to the corresponding events name: TName; ``` -Defined in: [packages/form-core/src/FieldApi.ts:299](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L299) +Defined in: [packages/form-core/src/FieldApi.ts:343](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L343) The field name. The type will be `DeepKeys` to ensure your name is a deep key of the parent dataset. @@ -141,7 +143,7 @@ The field name. The type will be `DeepKeys` to ensure your name is optional validatorAdapter: TFieldValidator; ``` -Defined in: [packages/form-core/src/FieldApi.ts:315](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L315) +Defined in: [packages/form-core/src/FieldApi.ts:359](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L359) A validator provided by an extension, like `yupValidator` from `@tanstack/yup-form-adapter` @@ -154,10 +156,10 @@ A validator provided by an extension, like `yupValidator` from `@tanstack/yup-fo ### validators? ```ts -optional validators: FieldValidators; +optional validators: FieldValidators; ``` -Defined in: [packages/form-core/src/FieldApi.ts:319](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L319) +Defined in: [packages/form-core/src/FieldApi.ts:363](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L363) A list of validators to pass to the field diff --git a/docs/reference/interfaces/fieldlisteners.md b/docs/reference/interfaces/fieldlisteners.md index c72b78d03..fe45a7b0f 100644 --- a/docs/reference/interfaces/fieldlisteners.md +++ b/docs/reference/interfaces/fieldlisteners.md @@ -3,9 +3,9 @@ id: FieldListeners title: FieldListeners --- -# Interface: FieldListeners\ +# Interface: FieldListeners\ -Defined in: [packages/form-core/src/FieldApi.ts:241](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L241) +Defined in: [packages/form-core/src/FieldApi.ts:279](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L279) ## Type Parameters @@ -21,42 +21,44 @@ Defined in: [packages/form-core/src/FieldApi.ts:241](https://github.com/TanStack • **TData** *extends* [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> = [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Properties ### onBlur? ```ts -optional onBlur: FieldListenerFn; +optional onBlur: FieldListenerFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:259](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L259) +Defined in: [packages/form-core/src/FieldApi.ts:299](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L299) *** ### onChange? ```ts -optional onChange: FieldListenerFn; +optional onChange: FieldListenerFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:252](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L252) +Defined in: [packages/form-core/src/FieldApi.ts:291](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L291) *** ### onMount? ```ts -optional onMount: FieldListenerFn; +optional onMount: FieldListenerFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:266](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L266) +Defined in: [packages/form-core/src/FieldApi.ts:307](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L307) *** ### onSubmit? ```ts -optional onSubmit: FieldListenerFn; +optional onSubmit: FieldListenerFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:273](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L273) +Defined in: [packages/form-core/src/FieldApi.ts:315](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L315) diff --git a/docs/reference/interfaces/fieldoptions.md b/docs/reference/interfaces/fieldoptions.md index cdcdaaa80..c229a378a 100644 --- a/docs/reference/interfaces/fieldoptions.md +++ b/docs/reference/interfaces/fieldoptions.md @@ -3,9 +3,9 @@ id: FieldOptions title: FieldOptions --- -# Interface: FieldOptions\ +# Interface: FieldOptions\ -Defined in: [packages/form-core/src/FieldApi.ts:285](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L285) +Defined in: [packages/form-core/src/FieldApi.ts:328](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L328) An object type representing the options for a field in a form. @@ -27,6 +27,8 @@ An object type representing the options for a field in a form. • **TData** *extends* [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> = [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Properties ### asyncAlways? @@ -35,7 +37,7 @@ An object type representing the options for a field in a form. optional asyncAlways: boolean; ``` -Defined in: [packages/form-core/src/FieldApi.ts:311](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L311) +Defined in: [packages/form-core/src/FieldApi.ts:355](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L355) If `true`, always run async validation, even if there are errors emitted during synchronous validation. @@ -47,7 +49,7 @@ If `true`, always run async validation, even if there are errors emitted during optional asyncDebounceMs: number; ``` -Defined in: [packages/form-core/src/FieldApi.ts:307](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L307) +Defined in: [packages/form-core/src/FieldApi.ts:351](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L351) The default time to debounce async validation if there is not a more specific debounce time passed. @@ -59,7 +61,7 @@ The default time to debounce async validation if there is not a more specific de optional defaultMeta: Partial; ``` -Defined in: [packages/form-core/src/FieldApi.ts:329](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L329) +Defined in: [packages/form-core/src/FieldApi.ts:374](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L374) An optional object with default metadata for the field. @@ -71,7 +73,7 @@ An optional object with default metadata for the field. optional defaultValue: NoInfer; ``` -Defined in: [packages/form-core/src/FieldApi.ts:303](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L303) +Defined in: [packages/form-core/src/FieldApi.ts:347](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L347) An optional default value for the field. @@ -80,10 +82,10 @@ An optional default value for the field. ### listeners? ```ts -optional listeners: FieldListeners; +optional listeners: FieldListeners; ``` -Defined in: [packages/form-core/src/FieldApi.ts:333](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L333) +Defined in: [packages/form-core/src/FieldApi.ts:378](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L378) A list of listeners which attach to the corresponding events @@ -95,7 +97,7 @@ A list of listeners which attach to the corresponding events name: TName; ``` -Defined in: [packages/form-core/src/FieldApi.ts:299](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L299) +Defined in: [packages/form-core/src/FieldApi.ts:343](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L343) The field name. The type will be `DeepKeys` to ensure your name is a deep key of the parent dataset. @@ -107,7 +109,7 @@ The field name. The type will be `DeepKeys` to ensure your name is optional validatorAdapter: TFieldValidator; ``` -Defined in: [packages/form-core/src/FieldApi.ts:315](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L315) +Defined in: [packages/form-core/src/FieldApi.ts:359](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L359) A validator provided by an extension, like `yupValidator` from `@tanstack/yup-form-adapter` @@ -116,9 +118,9 @@ A validator provided by an extension, like `yupValidator` from `@tanstack/yup-fo ### validators? ```ts -optional validators: FieldValidators; +optional validators: FieldValidators; ``` -Defined in: [packages/form-core/src/FieldApi.ts:319](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L319) +Defined in: [packages/form-core/src/FieldApi.ts:363](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L363) A list of validators to pass to the field diff --git a/docs/reference/interfaces/fieldvalidators.md b/docs/reference/interfaces/fieldvalidators.md index 2f34e46a9..725221961 100644 --- a/docs/reference/interfaces/fieldvalidators.md +++ b/docs/reference/interfaces/fieldvalidators.md @@ -3,9 +3,9 @@ id: FieldValidators title: FieldValidators --- -# Interface: FieldValidators\ +# Interface: FieldValidators\ -Defined in: [packages/form-core/src/FieldApi.ts:119](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L119) +Defined in: [packages/form-core/src/FieldApi.ts:153](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L153) ## Type Parameters @@ -21,15 +21,17 @@ Defined in: [packages/form-core/src/FieldApi.ts:119](https://github.com/TanStack • **TData** *extends* [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> = [`DeepValue`](../type-aliases/deepvalue.md)\<`TParentData`, `TName`\> +• **TParentMetaExtension** = `never` + ## Properties ### onBlur? ```ts -optional onBlur: FieldValidateOrFn; +optional onBlur: FieldValidateOrFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:182](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L182) +Defined in: [packages/form-core/src/FieldApi.ts:218](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L218) An optional function, that runs on the blur event of input. If `validatorAdapter` is passed, this may also accept a property from the respective adapter @@ -45,10 +47,10 @@ z.string().min(1) // if `zodAdapter` is passed ### onBlurAsync? ```ts -optional onBlurAsync: FieldAsyncValidateOrFn; +optional onBlurAsync: FieldAsyncValidateOrFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:195](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L195) +Defined in: [packages/form-core/src/FieldApi.ts:231](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L231) An optional property similar to `onBlur` but async validation. If `validatorAdapter` is passed, this may also accept a property from the respective adapter @@ -67,7 +69,7 @@ z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // optional onBlurAsyncDebounceMs: number; ``` -Defined in: [packages/form-core/src/FieldApi.ts:208](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L208) +Defined in: [packages/form-core/src/FieldApi.ts:245](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L245) An optional number to represent how long the `onBlurAsync` should wait before running @@ -81,7 +83,7 @@ If set to a number larger than 0, will debounce the async validation event by th optional onBlurListenTo: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple ? PrefixTupleAccessor, AllowedIndexes, never>, []> : TParentData extends any[] ? PrefixArrayAccessor, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor, []> : TParentData extends string | number | bigint | boolean ? "" : never[]; ``` -Defined in: [packages/form-core/src/FieldApi.ts:212](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L212) +Defined in: [packages/form-core/src/FieldApi.ts:249](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L249) An optional list of field names that should trigger this field's `onBlur` and `onBlurAsync` events when its value changes @@ -90,10 +92,10 @@ An optional list of field names that should trigger this field's `onBlur` and `o ### onChange? ```ts -optional onChange: FieldValidateOrFn; +optional onChange: FieldValidateOrFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:146](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L146) +Defined in: [packages/form-core/src/FieldApi.ts:181](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L181) An optional property that takes a `ValidateFn` which is a generic of `TData` and `TParentData`. If `validatorAdapter` is passed, this may also accept a property from the respective adapter @@ -109,10 +111,10 @@ z.string().min(1) // if `zodAdapter` is passed ### onChangeAsync? ```ts -optional onChangeAsync: FieldAsyncValidateOrFn; +optional onChangeAsync: FieldAsyncValidateOrFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:159](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L159) +Defined in: [packages/form-core/src/FieldApi.ts:194](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L194) An optional property similar to `onChange` but async validation. If `validatorAdapter` is passed, this may also accept a property from the respective adapter @@ -131,7 +133,7 @@ z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // optional onChangeAsyncDebounceMs: number; ``` -Defined in: [packages/form-core/src/FieldApi.ts:171](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L171) +Defined in: [packages/form-core/src/FieldApi.ts:207](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L207) An optional number to represent how long the `onChangeAsync` should wait before running @@ -145,7 +147,7 @@ If set to a number larger than 0, will debounce the async validation event by th optional onChangeListenTo: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple ? PrefixTupleAccessor, AllowedIndexes, never>, []> : TParentData extends any[] ? PrefixArrayAccessor, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor, []> : TParentData extends string | number | bigint | boolean ? "" : never[]; ``` -Defined in: [packages/form-core/src/FieldApi.ts:175](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L175) +Defined in: [packages/form-core/src/FieldApi.ts:211](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L211) An optional list of field names that should trigger this field's `onChange` and `onChangeAsync` events when its value changes @@ -154,10 +156,10 @@ An optional list of field names that should trigger this field's `onChange` and ### onMount? ```ts -optional onMount: FieldValidateOrFn; +optional onMount: FieldValidateOrFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:133](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L133) +Defined in: [packages/form-core/src/FieldApi.ts:168](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L168) An optional function that takes a param of `formApi` which is a generic type of `TData` and `TParentData` @@ -166,10 +168,10 @@ An optional function that takes a param of `formApi` which is a generic type of ### onSubmit? ```ts -optional onSubmit: FieldValidateOrFn; +optional onSubmit: FieldValidateOrFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:219](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L219) +Defined in: [packages/form-core/src/FieldApi.ts:256](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L256) An optional function, that runs on the submit event of form. If `validatorAdapter` is passed, this may also accept a property from the respective adapter @@ -185,10 +187,10 @@ z.string().min(1) // if `zodAdapter` is passed ### onSubmitAsync? ```ts -optional onSubmitAsync: FieldAsyncValidateOrFn; +optional onSubmitAsync: FieldAsyncValidateOrFn; ``` -Defined in: [packages/form-core/src/FieldApi.ts:232](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L232) +Defined in: [packages/form-core/src/FieldApi.ts:269](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L269) An optional property similar to `onSubmit` but async validation. If `validatorAdapter` is passed, this may also accept a property from the respective adapter diff --git a/docs/reference/interfaces/formoptions.md b/docs/reference/interfaces/formoptions.md index f9069e928..b9af52940 100644 --- a/docs/reference/interfaces/formoptions.md +++ b/docs/reference/interfaces/formoptions.md @@ -3,9 +3,9 @@ id: FormOptions title: FormOptions --- -# Interface: FormOptions\ +# Interface: FormOptions\ -Defined in: [packages/form-core/src/FormApi.ts:149](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L149) +Defined in: [packages/form-core/src/FormApi.ts:167](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L167) An object representing the options for a form. @@ -15,6 +15,8 @@ An object representing the options for a form. • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Properties ### asyncAlways? @@ -23,7 +25,7 @@ An object representing the options for a form. optional asyncAlways: boolean; ``` -Defined in: [packages/form-core/src/FormApi.ts:164](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L164) +Defined in: [packages/form-core/src/FormApi.ts:183](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L183) If true, always run async validation, even when sync validation has produced an error. Defaults to undefined. @@ -35,7 +37,7 @@ If true, always run async validation, even when sync validation has produced an optional asyncDebounceMs: number; ``` -Defined in: [packages/form-core/src/FormApi.ts:168](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L168) +Defined in: [packages/form-core/src/FormApi.ts:187](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L187) Optional time in milliseconds if you want to introduce a delay before firing off an async action. @@ -47,7 +49,7 @@ Optional time in milliseconds if you want to introduce a delay before firing off optional defaultState: Partial>; ``` -Defined in: [packages/form-core/src/FormApi.ts:160](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L160) +Defined in: [packages/form-core/src/FormApi.ts:179](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L179) The default state for the form. @@ -59,7 +61,7 @@ The default state for the form. optional defaultValues: TFormData; ``` -Defined in: [packages/form-core/src/FormApi.ts:156](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L156) +Defined in: [packages/form-core/src/FormApi.ts:175](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L175) Set initial values for your form. @@ -71,7 +73,7 @@ Set initial values for your form. optional onSubmit: (props) => any; ``` -Defined in: [packages/form-core/src/FormApi.ts:180](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L180) +Defined in: [packages/form-core/src/FormApi.ts:199](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L199) A function to be called when the form is submitted, what should happen once the user submits a valid form returns `any` or a promise `Promise` @@ -79,13 +81,7 @@ A function to be called when the form is submitted, what should happen once the ##### props -###### formApi - -[`FormApi`](../classes/formapi.md)\<`TFormData`, `TFormValidator`\> - -###### value - -`TFormData` +\[`TFormSubmitMeta`\] *extends* \[`never`\] ? `object` : `object` #### Returns @@ -99,7 +95,7 @@ A function to be called when the form is submitted, what should happen once the optional onSubmitInvalid: (props) => void; ``` -Defined in: [packages/form-core/src/FormApi.ts:187](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L187) +Defined in: [packages/form-core/src/FormApi.ts:214](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L214) Specify an action for scenarios where the user tries to submit an invalid form. @@ -109,7 +105,7 @@ Specify an action for scenarios where the user tries to submit an invalid form. ###### formApi -[`FormApi`](../classes/formapi.md)\<`TFormData`, `TFormValidator`\> +[`FormApi`](../classes/formapi.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> ###### value @@ -121,13 +117,25 @@ Specify an action for scenarios where the user tries to submit an invalid form. *** +### onSubmitMeta? + +```ts +optional onSubmitMeta: TFormSubmitMeta; +``` + +Defined in: [packages/form-core/src/FormApi.ts:221](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L221) + +onSubmitMeta, the data passed from the handleSubmit handler, to the onSubmit function props + +*** + ### transform? ```ts -optional transform: FormTransform; +optional transform: FormTransform; ``` -Defined in: [packages/form-core/src/FormApi.ts:191](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L191) +Defined in: [packages/form-core/src/FormApi.ts:223](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L223) *** @@ -137,7 +145,7 @@ Defined in: [packages/form-core/src/FormApi.ts:191](https://github.com/TanStack/ optional validatorAdapter: TFormValidator; ``` -Defined in: [packages/form-core/src/FormApi.ts:172](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L172) +Defined in: [packages/form-core/src/FormApi.ts:191](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L191) A validator adapter to support usage of extra validation types (IE: Zod, Yup, or Valibot usage) @@ -146,9 +154,9 @@ A validator adapter to support usage of extra validation types (IE: Zod, Yup, or ### validators? ```ts -optional validators: FormValidators; +optional validators: FormValidators; ``` -Defined in: [packages/form-core/src/FormApi.ts:176](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L176) +Defined in: [packages/form-core/src/FormApi.ts:195](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L195) A list of validators to pass to the form diff --git a/docs/reference/interfaces/formvalidators.md b/docs/reference/interfaces/formvalidators.md index 68f93bfbb..923521887 100644 --- a/docs/reference/interfaces/formvalidators.md +++ b/docs/reference/interfaces/formvalidators.md @@ -3,9 +3,9 @@ id: FormValidators title: FormValidators --- -# Interface: FormValidators\ +# Interface: FormValidators\ -Defined in: [packages/form-core/src/FormApi.ts:97](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L97) +Defined in: [packages/form-core/src/FormApi.ts:101](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L101) ## Type Parameters @@ -13,15 +13,17 @@ Defined in: [packages/form-core/src/FormApi.ts:97](https://github.com/TanStack/f • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Properties ### onBlur? ```ts -optional onBlur: FormValidateOrFn; +optional onBlur: FormValidateOrFn; ``` -Defined in: [packages/form-core/src/FormApi.ts:120](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L120) +Defined in: [packages/form-core/src/FormApi.ts:129](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L129) Optional function that validates the form data when a field loses focus, returns a `FormValidationError` @@ -30,10 +32,10 @@ Optional function that validates the form data when a field loses focus, returns ### onBlurAsync? ```ts -optional onBlurAsync: FormAsyncValidateOrFn; +optional onBlurAsync: FormAsyncValidateOrFn; ``` -Defined in: [packages/form-core/src/FormApi.ts:124](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L124) +Defined in: [packages/form-core/src/FormApi.ts:133](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L133) Optional onBlur asynchronous validation method for when a field loses focus returns a ` FormValidationError` or a promise of `Promise` @@ -45,7 +47,7 @@ Optional onBlur asynchronous validation method for when a field loses focus retu optional onBlurAsyncDebounceMs: number; ``` -Defined in: [packages/form-core/src/FormApi.ts:128](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L128) +Defined in: [packages/form-core/src/FormApi.ts:141](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L141) The default time in milliseconds that if set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds. @@ -54,10 +56,10 @@ The default time in milliseconds that if set to a number larger than 0, will deb ### onChange? ```ts -optional onChange: FormValidateOrFn; +optional onChange: FormValidateOrFn; ``` -Defined in: [packages/form-core/src/FormApi.ts:108](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L108) +Defined in: [packages/form-core/src/FormApi.ts:113](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L113) Optional function that checks the validity of your data whenever a value changes @@ -66,10 +68,10 @@ Optional function that checks the validity of your data whenever a value changes ### onChangeAsync? ```ts -optional onChangeAsync: FormAsyncValidateOrFn; +optional onChangeAsync: FormAsyncValidateOrFn; ``` -Defined in: [packages/form-core/src/FormApi.ts:112](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L112) +Defined in: [packages/form-core/src/FormApi.ts:117](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L117) Optional onChange asynchronous counterpart to onChange. Useful for more complex validation logic that might involve server requests. @@ -81,7 +83,7 @@ Optional onChange asynchronous counterpart to onChange. Useful for more complex optional onChangeAsyncDebounceMs: number; ``` -Defined in: [packages/form-core/src/FormApi.ts:116](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L116) +Defined in: [packages/form-core/src/FormApi.ts:125](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L125) The default time in milliseconds that if set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds. @@ -90,10 +92,10 @@ The default time in milliseconds that if set to a number larger than 0, will deb ### onMount? ```ts -optional onMount: FormValidateOrFn; +optional onMount: FormValidateOrFn; ``` -Defined in: [packages/form-core/src/FormApi.ts:104](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L104) +Defined in: [packages/form-core/src/FormApi.ts:109](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L109) Optional function that fires as soon as the component mounts. @@ -102,17 +104,17 @@ Optional function that fires as soon as the component mounts. ### onSubmit? ```ts -optional onSubmit: FormValidateOrFn; +optional onSubmit: FormValidateOrFn; ``` -Defined in: [packages/form-core/src/FormApi.ts:129](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L129) +Defined in: [packages/form-core/src/FormApi.ts:142](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L142) *** ### onSubmitAsync? ```ts -optional onSubmitAsync: FormAsyncValidateOrFn; +optional onSubmitAsync: FormAsyncValidateOrFn; ``` -Defined in: [packages/form-core/src/FormApi.ts:130](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L130) +Defined in: [packages/form-core/src/FormApi.ts:143](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L143) diff --git a/docs/reference/type-aliases/baseformstate.md b/docs/reference/type-aliases/baseformstate.md index b34b491c0..972aac7d4 100644 --- a/docs/reference/type-aliases/baseformstate.md +++ b/docs/reference/type-aliases/baseformstate.md @@ -9,7 +9,7 @@ title: BaseFormState type BaseFormState = object; ``` -Defined in: [packages/form-core/src/FormApi.ts:229](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L229) +Defined in: [packages/form-core/src/FormApi.ts:264](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L264) An object representing the current state of the form. diff --git a/docs/reference/type-aliases/derivedformstate.md b/docs/reference/type-aliases/derivedformstate.md index ac8d4803d..3d2446327 100644 --- a/docs/reference/type-aliases/derivedformstate.md +++ b/docs/reference/type-aliases/derivedformstate.md @@ -9,7 +9,7 @@ title: DerivedFormState type DerivedFormState = object; ``` -Defined in: [packages/form-core/src/FormApi.ts:273](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L273) +Defined in: [packages/form-core/src/FormApi.ts:308](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L308) ## Type Parameters diff --git a/docs/reference/type-aliases/fieldinfo.md b/docs/reference/type-aliases/fieldinfo.md index 6cc6ebab2..9738b0e49 100644 --- a/docs/reference/type-aliases/fieldinfo.md +++ b/docs/reference/type-aliases/fieldinfo.md @@ -3,13 +3,13 @@ id: FieldInfo title: FieldInfo --- -# Type Alias: FieldInfo\ +# Type Alias: FieldInfo\ ```ts -type FieldInfo = object; +type FieldInfo = object; ``` -Defined in: [packages/form-core/src/FormApi.ts:207](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L207) +Defined in: [packages/form-core/src/FormApi.ts:239](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L239) An object representing the field information for a specific field within the form. @@ -19,13 +19,15 @@ An object representing the field information for a specific field within the for • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Type declaration ### instance ```ts instance: - | FieldApi | undefined, TFormValidator> + | FieldApi | undefined, TFormValidator, any, TFormSubmitMeta> | null; ``` diff --git a/docs/reference/type-aliases/fieldmeta.md b/docs/reference/type-aliases/fieldmeta.md index 92d188bea..ee587a83f 100644 --- a/docs/reference/type-aliases/fieldmeta.md +++ b/docs/reference/type-aliases/fieldmeta.md @@ -9,6 +9,6 @@ title: FieldMeta type FieldMeta = FieldMetaBase & FieldMetaDerived; ``` -Defined in: [packages/form-core/src/FieldApi.ts:402](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L402) +Defined in: [packages/form-core/src/FieldApi.ts:450](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L450) An object type representing the metadata of a field in a form. diff --git a/docs/reference/type-aliases/fieldmetabase.md b/docs/reference/type-aliases/fieldmetabase.md index a09bbb5cf..4c45eb141 100644 --- a/docs/reference/type-aliases/fieldmetabase.md +++ b/docs/reference/type-aliases/fieldmetabase.md @@ -9,7 +9,7 @@ title: FieldMetaBase type FieldMetaBase = object; ``` -Defined in: [packages/form-core/src/FieldApi.ts:365](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L365) +Defined in: [packages/form-core/src/FieldApi.ts:413](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L413) ## Type declaration diff --git a/docs/reference/type-aliases/fieldmetaderived.md b/docs/reference/type-aliases/fieldmetaderived.md index 1228a198f..d8a8de4a6 100644 --- a/docs/reference/type-aliases/fieldmetaderived.md +++ b/docs/reference/type-aliases/fieldmetaderived.md @@ -9,7 +9,7 @@ title: FieldMetaDerived type FieldMetaDerived = object; ``` -Defined in: [packages/form-core/src/FieldApi.ts:388](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L388) +Defined in: [packages/form-core/src/FieldApi.ts:436](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L436) ## Type declaration diff --git a/docs/reference/type-aliases/fieldstate.md b/docs/reference/type-aliases/fieldstate.md index 30edf86ef..6d6ae0ff8 100644 --- a/docs/reference/type-aliases/fieldstate.md +++ b/docs/reference/type-aliases/fieldstate.md @@ -9,7 +9,7 @@ title: FieldState type FieldState = object; ``` -Defined in: [packages/form-core/src/FieldApi.ts:407](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L407) +Defined in: [packages/form-core/src/FieldApi.ts:455](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L455) An object type representing the state of a field. diff --git a/docs/reference/type-aliases/formstate.md b/docs/reference/type-aliases/formstate.md index 85858015d..2099b6561 100644 --- a/docs/reference/type-aliases/formstate.md +++ b/docs/reference/type-aliases/formstate.md @@ -9,7 +9,7 @@ title: FormState type FormState = BaseFormState & DerivedFormState; ``` -Defined in: [packages/form-core/src/FormApi.ts:324](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L324) +Defined in: [packages/form-core/src/FormApi.ts:359](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L359) ## Type Parameters diff --git a/docs/reference/type-aliases/formvalidatefn.md b/docs/reference/type-aliases/formvalidatefn.md index 16a31e848..15e06ac9a 100644 --- a/docs/reference/type-aliases/formvalidatefn.md +++ b/docs/reference/type-aliases/formvalidatefn.md @@ -3,10 +3,10 @@ id: FormValidateFn title: FormValidateFn --- -# Type Alias: FormValidateFn()\ +# Type Alias: FormValidateFn()\ ```ts -type FormValidateFn = (props) => FormValidationError; +type FormValidateFn = (props) => FormValidationError; ``` Defined in: [packages/form-core/src/FormApi.ts:36](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L36) @@ -17,13 +17,15 @@ Defined in: [packages/form-core/src/FormApi.ts:36](https://github.com/TanStack/f • **TFormValidator** *extends* `Validator`\<`TFormData`, `unknown`\> \| `undefined` = `undefined` +• **TFormSubmitMeta** = `never` + ## Parameters ### props #### formApi -[`FormApi`](../classes/formapi.md)\<`TFormData`, `TFormValidator`\> +[`FormApi`](../classes/formapi.md)\<`TFormData`, `TFormValidator`, `TFormSubmitMeta`\> #### value diff --git a/docs/reference/type-aliases/formvalidator.md b/docs/reference/type-aliases/formvalidator.md index 1aa49177e..d0388d3f7 100644 --- a/docs/reference/type-aliases/formvalidator.md +++ b/docs/reference/type-aliases/formvalidator.md @@ -9,7 +9,7 @@ title: FormValidator type FormValidator = object; ``` -Defined in: [packages/form-core/src/FormApi.ts:69](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L69) +Defined in: [packages/form-core/src/FormApi.ts:72](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L72) ## Type Parameters diff --git a/docs/reference/type-aliases/validationmeta.md b/docs/reference/type-aliases/validationmeta.md index fdba89873..6376c1523 100644 --- a/docs/reference/type-aliases/validationmeta.md +++ b/docs/reference/type-aliases/validationmeta.md @@ -9,7 +9,7 @@ title: ValidationMeta type ValidationMeta = object; ``` -Defined in: [packages/form-core/src/FormApi.ts:197](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L197) +Defined in: [packages/form-core/src/FormApi.ts:229](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L229) An object representing the validation metadata for a field. Not intended for public usage. diff --git a/packages/angular-form/src/inject-form.ts b/packages/angular-form/src/inject-form.ts index 4c5ac3a64..1215aa420 100644 --- a/packages/angular-form/src/inject-form.ts +++ b/packages/angular-form/src/inject-form.ts @@ -5,8 +5,9 @@ import type { FormOptions, Validator } from '@tanstack/form-core' export function injectForm< TFormData, TFormValidator extends Validator | undefined = undefined, ->(opts?: FormOptions) { - const api = new FormApi(opts) + TFormSubmitMeta = never, +>(opts?: FormOptions) { + const api = new FormApi(opts) injectStore(api.store, (state) => state.isSubmitting) diff --git a/packages/angular-form/src/inject-store.ts b/packages/angular-form/src/inject-store.ts index 5d499d836..eb630e7ad 100644 --- a/packages/angular-form/src/inject-store.ts +++ b/packages/angular-form/src/inject-store.ts @@ -5,8 +5,9 @@ export function injectStore< TFormData, TFormValidator extends Validator | undefined = undefined, TSelected = NoInfer>, + TFormSubmitMeta = never, >( - form: FormApi, + form: FormApi, selector?: (state: NoInfer>) => TSelected, ) { return injectAngularStore(form.store, selector) diff --git a/packages/angular-form/src/tanstack-field.directive.ts b/packages/angular-form/src/tanstack-field.directive.ts index c23fa9189..5af2d21e4 100644 --- a/packages/angular-form/src/tanstack-field.directive.ts +++ b/packages/angular-form/src/tanstack-field.directive.ts @@ -32,12 +32,20 @@ export class TanStackField< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > implements OnInit, OnChanges, OnDestroy, - FieldOptions + FieldOptions< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > { @Input({ required: true }) name!: TName // Setting as NoInferHack as it's the same internal type cast as TanStack Form Core @@ -49,17 +57,39 @@ export class TanStackField< @Input() validatorAdapter?: TFieldValidator @Input({ required: true }) tanstackField!: FormApi< TParentData, - TFormValidator + TFormValidator, + TParentMetaExtension > @Input() validators?: NoInfer< - FieldValidators + FieldValidators< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > > @Input() listeners?: NoInfer< - FieldListeners + FieldListeners< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > > @Input() defaultMeta?: Partial - api!: FieldApi + api!: FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > private getOptions() { return { diff --git a/packages/form-core/src/FieldApi.ts b/packages/form-core/src/FieldApi.ts index ddb7c993c..daf20f442 100644 --- a/packages/form-core/src/FieldApi.ts +++ b/packages/form-core/src/FieldApi.ts @@ -30,9 +30,17 @@ export type FieldValidateFn< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = (props: { value: TData - fieldApi: FieldApi + fieldApi: FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > }) => ValidationError /** @@ -48,10 +56,18 @@ export type FieldValidateOrFn< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = | (TFieldValidator extends Validator ? TFN : never) | (TFormValidator extends Validator ? FFN : never) - | FieldValidateFn + | FieldValidateFn< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > | StandardSchemaV1 /** @@ -67,9 +83,17 @@ export type FieldValidateAsyncFn< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = (options: { value: TData - fieldApi: FieldApi + fieldApi: FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > signal: AbortSignal }) => ValidationError | Promise @@ -86,6 +110,7 @@ export type FieldAsyncValidateOrFn< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = | (TFieldValidator extends Validator ? TFN : never) | (TFormValidator extends Validator ? FFN : never) @@ -94,7 +119,8 @@ export type FieldAsyncValidateOrFn< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > | StandardSchemaV1 @@ -111,9 +137,17 @@ export type FieldListenerFn< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = (props: { value: TData - fieldApi: FieldApi + fieldApi: FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > }) => void export interface FieldValidators< @@ -126,6 +160,7 @@ export interface FieldValidators< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > { /** * An optional function that takes a param of `formApi` which is a generic type of `TData` and `TParentData` @@ -161,7 +196,8 @@ export interface FieldValidators< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > /** * An optional number to represent how long the `onChangeAsync` should wait before running @@ -197,7 +233,8 @@ export interface FieldValidators< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > /** @@ -234,7 +271,8 @@ export interface FieldValidators< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > } @@ -248,34 +286,39 @@ export interface FieldListeners< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > { onChange?: FieldListenerFn< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > onBlur?: FieldListenerFn< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > onMount?: FieldListenerFn< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > onSubmit?: FieldListenerFn< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > } @@ -292,6 +335,7 @@ export interface FieldOptions< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > { /** * The field name. The type will be `DeepKeys` to ensure your name is a deep key of the parent dataset. @@ -321,7 +365,8 @@ export interface FieldOptions< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > /** * An optional object with default metadata for the field. @@ -335,7 +380,8 @@ export interface FieldOptions< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > } @@ -352,14 +398,16 @@ export interface FieldApiOptions< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > extends FieldOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > { - form: FormApi + form: FormApi } export type FieldMetaBase = { @@ -434,6 +482,7 @@ export class FieldApi< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > { /** * A reference to the form API instance. @@ -443,7 +492,8 @@ export class FieldApi< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >['form'] /** * The field name. @@ -457,7 +507,8 @@ export class FieldApi< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > = {} as any /** * The field state store. @@ -480,7 +531,8 @@ export class FieldApi< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) { this.form = opts.form as never @@ -523,14 +575,14 @@ export class FieldApi< runValidator< TValue extends { value: TData - fieldApi: FieldApi + fieldApi: FieldApi validationSource: ValidationSource }, TType extends 'validate' | 'validateAsync', >(props: { validate: TType extends 'validate' - ? FieldValidateOrFn - : FieldAsyncValidateOrFn + ? FieldValidateOrFn + : FieldAsyncValidateOrFn value: TValue type: TType // When `api` is 'field', the return type cannot be `FormValidationError` @@ -558,7 +610,9 @@ export class FieldApi< ) as never } - return (props.validate as FieldValidateFn)(props.value) as never + return (props.validate as FieldValidateFn)( + props.value, + ) as never } /** @@ -578,7 +632,7 @@ export class FieldApi< validate: onMount, value: { value: this.state.value, - fieldApi: this, + fieldApi: this as FieldApi, validationSource: 'field', }, type: 'validate', @@ -594,7 +648,7 @@ export class FieldApi< this.options.listeners?.onMount?.({ value: this.state.value, - fieldApi: this, + fieldApi: this as FieldApi, }) return cleanup @@ -609,7 +663,8 @@ export class FieldApi< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) => { // Default Value @@ -762,7 +817,9 @@ export class FieldApi< }) return acc.concat(fieldValidates as never) }, - [] as Array & { field: FieldApi }>, + [] as Array< + SyncValidator & { field: FieldApi } + >, ) // Needs type cast as eslint errantly believes this is always falsy @@ -770,7 +827,7 @@ export class FieldApi< batch(() => { const validateFieldFn = ( - field: FieldApi, + field: FieldApi, validateObj: SyncValidator, ) => { const errorMapKey = getErrorMapKey(validateObj.cause) @@ -813,7 +870,10 @@ export class FieldApi< } for (const validateObj of validates) { - validateFieldFn(this, validateObj) + validateFieldFn( + this as FieldApi, + validateObj, + ) } for (const fieldValitateObj of linkedFieldValidates) { if (!fieldValitateObj.validate) continue @@ -868,7 +928,7 @@ export class FieldApi< return acc.concat(fieldValidates as never) }, [] as Array< - AsyncValidator & { field: FieldApi } + AsyncValidator & { field: FieldApi } >, ) @@ -888,7 +948,7 @@ export class FieldApi< const linkedPromises: Promise[] = [] const validateFieldAsyncFn = ( - field: FieldApi, + field: FieldApi, validateObj: AsyncValidator, promises: Promise[], ) => { @@ -958,7 +1018,11 @@ export class FieldApi< // TODO: Dedupe this logic to reduce bundle size for (const validateObj of validates) { if (!validateObj.validate) continue - validateFieldAsyncFn(this, validateObj, validatesPromises) + validateFieldAsyncFn( + this as FieldApi, + validateObj, + validatesPromises, + ) } for (const fieldValitateObj of linkedFieldValidates) { if (!fieldValitateObj.validate) continue diff --git a/packages/form-core/src/FormApi.ts b/packages/form-core/src/FormApi.ts index b95db5ef4..783115457 100644 --- a/packages/form-core/src/FormApi.ts +++ b/packages/form-core/src/FormApi.ts @@ -36,9 +36,10 @@ export type FieldsErrorMapFromValidator = Partial< export type FormValidateFn< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > = (props: { value: TFormData - formApi: FormApi + formApi: FormApi }) => FormValidationError /** @@ -47,11 +48,12 @@ export type FormValidateFn< export type FormValidateOrFn< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > = TFormValidator extends Validator - ? TFN | FormValidateFn + ? TFN | FormValidateFn : - | FormValidateFn + | FormValidateFn | StandardSchemaV1 /** @@ -60,9 +62,10 @@ export type FormValidateOrFn< export type FormValidateAsyncFn< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > = (props: { value: TFormData - formApi: FormApi + formApi: FormApi signal: AbortSignal }) => FormValidationError | Promise> @@ -87,29 +90,35 @@ type ValidationPromiseResult = export type FormAsyncValidateOrFn< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > = TFormValidator extends Validator - ? FFN | FormValidateAsyncFn + ? FFN | FormValidateAsyncFn : - | FormValidateAsyncFn + | FormValidateAsyncFn | StandardSchemaV1 export interface FormValidators< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > { /** * Optional function that fires as soon as the component mounts. */ - onMount?: FormValidateOrFn + onMount?: FormValidateOrFn /** * Optional function that checks the validity of your data whenever a value changes */ - onChange?: FormValidateOrFn + onChange?: FormValidateOrFn /** * Optional onChange asynchronous counterpart to onChange. Useful for more complex validation logic that might involve server requests. */ - onChangeAsync?: FormAsyncValidateOrFn + onChangeAsync?: FormAsyncValidateOrFn< + TFormData, + TFormValidator, + TFormSubmitMeta + > /** * The default time in milliseconds that if set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds. */ @@ -117,17 +126,25 @@ export interface FormValidators< /** * Optional function that validates the form data when a field loses focus, returns a `FormValidationError` */ - onBlur?: FormValidateOrFn + onBlur?: FormValidateOrFn /** * Optional onBlur asynchronous validation method for when a field loses focus returns a ` FormValidationError` or a promise of `Promise` */ - onBlurAsync?: FormAsyncValidateOrFn + onBlurAsync?: FormAsyncValidateOrFn< + TFormData, + TFormValidator, + TFormSubmitMeta + > /** * The default time in milliseconds that if set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds. */ onBlurAsyncDebounceMs?: number - onSubmit?: FormValidateOrFn - onSubmitAsync?: FormAsyncValidateOrFn + onSubmit?: FormValidateOrFn + onSubmitAsync?: FormAsyncValidateOrFn< + TFormData, + TFormValidator, + TFormSubmitMeta + > } /** @@ -136,10 +153,11 @@ export interface FormValidators< export interface FormTransform< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > { fn: ( - formBase: FormApi, - ) => FormApi + formBase: FormApi, + ) => FormApi deps: unknown[] } @@ -149,6 +167,7 @@ export interface FormTransform< export interface FormOptions< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > { /** * Set initial values for your form. @@ -173,22 +192,35 @@ export interface FormOptions< /** * A list of validators to pass to the form */ - validators?: FormValidators + validators?: FormValidators /** * A function to be called when the form is submitted, what should happen once the user submits a valid form returns `any` or a promise `Promise` */ - onSubmit?: (props: { - value: TFormData - formApi: FormApi - }) => any | Promise + onSubmit?: ( + props: [TFormSubmitMeta] extends [never] + ? { + value: TFormData + formApi: FormApi + } + : { + value: TFormData + formApi: FormApi + meta: TFormSubmitMeta + }, + ) => any | Promise /** * Specify an action for scenarios where the user tries to submit an invalid form. */ onSubmitInvalid?: (props: { value: TFormData - formApi: FormApi + formApi: FormApi }) => void - transform?: FormTransform + /** + * onSubmitMeta, the data passed from the handleSubmit handler, to the onSubmit function props + */ + onSubmitMeta?: TFormSubmitMeta + + transform?: FormTransform } /** @@ -207,6 +239,7 @@ export type ValidationMeta = { export type FieldInfo< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > = { /** * An instance of the FieldAPI. @@ -215,7 +248,9 @@ export type FieldInfo< TFormData, any, Validator | undefined, - TFormValidator + TFormValidator, + any, + TFormSubmitMeta > | null /** * A record of field validation internal handling. @@ -361,11 +396,12 @@ const isFormValidationError = ( export class FormApi< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > { /** * The options for the form. */ - options: FormOptions = {} + options: FormOptions = {} baseStore!: Store> fieldMetaDerived!: Derived, FieldMeta>> store!: Derived> @@ -387,7 +423,7 @@ export class FormApi< /** * Constructs a new `FormApi` instance with the given form options. */ - constructor(opts?: FormOptions) { + constructor(opts?: FormOptions) { this.baseStore = new Store( getDefaultFormState({ ...(opts?.defaultState as any), @@ -606,14 +642,14 @@ export class FormApi< runValidator< TValue extends { value: TFormData - formApi: FormApi + formApi: FormApi validationSource: ValidationSource }, TType extends 'validate' | 'validateAsync', >(props: { validate: TType extends 'validate' - ? FormValidateOrFn - : FormAsyncValidateOrFn + ? FormValidateOrFn + : FormAsyncValidateOrFn value: TValue type: TType }): ReturnType>[TType]> { @@ -632,7 +668,9 @@ export class FormApi< ) as never } - return (props.validate as FormValidateFn)(props.value) as never + return (props.validate as FormValidateFn)( + props.value as any, + ) as never } mount = () => { @@ -652,7 +690,9 @@ export class FormApi< /** * Updates the form options and form state. */ - update = (options?: FormOptions) => { + update = ( + options?: FormOptions, + ) => { if (!options) return const oldOptions = this.options @@ -1058,7 +1098,9 @@ export class FormApi< /** * Handles the form submission, performs validation, and calls the appropriate onSubmit or onInvalidSubmit callbacks. */ - handleSubmit = async () => { + handleSubmit(): Promise + handleSubmit(submitMeta: TFormSubmitMeta): Promise + async handleSubmit(submitMeta?: TFormSubmitMeta): Promise { this.baseStore.setState((old) => ({ ...old, // Submission attempts mark the form as not submitted @@ -1102,7 +1144,12 @@ export class FormApi< try { // Run the submit code - await this.options.onSubmit?.({ value: this.state.values, formApi: this }) + + await this.options.onSubmit?.({ + value: this.state.values, + formApi: this, + ...(submitMeta ? { meta: submitMeta } : {}), + } as any) batch(() => { this.baseStore.setState((prev) => ({ ...prev, isSubmitted: true })) diff --git a/packages/form-core/src/formOptions.ts b/packages/form-core/src/formOptions.ts index 6089cec87..2fe53ba64 100644 --- a/packages/form-core/src/formOptions.ts +++ b/packages/form-core/src/formOptions.ts @@ -4,6 +4,7 @@ import type { FormOptions } from './FormApi' export function formOptions< TFormData, TFormValidator extends Validator | undefined = undefined, ->(defaultOpts?: FormOptions) { + TFormSubmitMeta = never, +>(defaultOpts?: FormOptions) { return defaultOpts } diff --git a/packages/form-core/src/mergeForm.ts b/packages/form-core/src/mergeForm.ts index 992301951..86272c2f7 100644 --- a/packages/form-core/src/mergeForm.ts +++ b/packages/form-core/src/mergeForm.ts @@ -36,9 +36,14 @@ export function mutateMergeDeep(target: object, source: object): object { export function mergeForm< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, >( - baseForm: FormApi, NoInfer>, - state: Partial['state']>, + baseForm: FormApi< + NoInfer, + NoInfer, + NoInfer + >, + state: Partial['state']>, ) { mutateMergeDeep(baseForm.state, state) return baseForm diff --git a/packages/form-core/src/utils.ts b/packages/form-core/src/utils.ts index b2a52d496..fcd2b25b2 100644 --- a/packages/form-core/src/utils.ts +++ b/packages/form-core/src/utils.ts @@ -195,11 +195,11 @@ export interface AsyncValidator { export function getAsyncValidatorArray( cause: ValidationCause, options: AsyncValidatorArrayPartialOptions, -): T extends FieldValidators +): T extends FieldValidators ? Array< AsyncValidator > - : T extends FormValidators + : T extends FormValidators ? Array< AsyncValidator< T['onChangeAsync'] | T['onBlurAsync'] | T['onSubmitAsync'] @@ -214,8 +214,8 @@ export function getAsyncValidatorArray( onBlurAsyncDebounceMs, onChangeAsyncDebounceMs, } = (options.validators || {}) as - | FieldValidators - | FormValidators + | FieldValidators + | FormValidators const defaultDebounceMs = asyncDebounceMs ?? 0 @@ -279,11 +279,11 @@ export interface SyncValidator { export function getSyncValidatorArray( cause: ValidationCause, options: SyncValidatorArrayPartialOptions, -): T extends FieldValidators +): T extends FieldValidators ? Array< SyncValidator > - : T extends FormValidators + : T extends FormValidators ? Array< SyncValidator< T['onChange'] | T['onBlur'] | T['onSubmit'] | T['onMount'] @@ -291,8 +291,8 @@ export function getSyncValidatorArray( > : never { const { onChange, onBlur, onSubmit, onMount } = (options.validators || {}) as - | FieldValidators - | FormValidators + | FieldValidators + | FormValidators const changeValidator = { cause: 'change', validate: onChange } as const const blurValidator = { cause: 'blur', validate: onBlur } as const diff --git a/packages/form-core/tests/FieldApi.spec.ts b/packages/form-core/tests/FieldApi.spec.ts index 157bda920..265c57792 100644 --- a/packages/form-core/tests/FieldApi.spec.ts +++ b/packages/form-core/tests/FieldApi.spec.ts @@ -1744,6 +1744,10 @@ describe('field api', () => { defaultValues: { name: '', }, + onSubmitMeta: {} as { dino: string }, + onSubmit: async ({ meta }) => { + expect(meta.dino).toEqual('Stegosaurus') + }, }) form.mount() @@ -1758,6 +1762,7 @@ describe('field api', () => { }) nameField.mount() + expect(nameField.getMeta().errors).toEqual(['THERE IS AN ERROR']) }) }) diff --git a/packages/form-core/tests/FormApi.spec.ts b/packages/form-core/tests/FormApi.spec.ts index 1a6570981..e1bf86980 100644 --- a/packages/form-core/tests/FormApi.spec.ts +++ b/packages/form-core/tests/FormApi.spec.ts @@ -2197,3 +2197,14 @@ it('should not change the onBlur state of the fields when the form is submitted' expect(firstNameField.state.meta.isBlurred).toBe(true) expect(lastNameField.state.meta.isBlurred).toBe(false) }) + +it('should pass the handleSubmit meta data to onSubmit', async () => { + const form = new FormApi({ + onSubmitMeta: {} as { dinosaur: string }, + onSubmit: async ({ meta }) => { + expect(meta.dinosaur).toEqual('Stegosaurus') + }, + }) + + await form.handleSubmit({ dinosaur: 'Stegosaurus' }) +}) diff --git a/packages/form-core/tests/FormApi.test-d.ts b/packages/form-core/tests/FormApi.test-d.ts new file mode 100644 index 000000000..bcaaf22a3 --- /dev/null +++ b/packages/form-core/tests/FormApi.test-d.ts @@ -0,0 +1,31 @@ +import { assertType, it } from 'vitest' +import { FormApi } from '../src/index' + +it('should type handleSubmit as never when onSubmitMeta is not passed', () => { + const form = new FormApi({ + defaultValues: { + name: 'test', + }, + } as const) + + assertType<() => Promise>(form.handleSubmit) +}) + +type OnSubmitMeta = { + group: string +} + +it('should type handleChange correctly', () => { + const form = new FormApi({ + defaultValues: { + name: 'test', + }, + onSubmitMeta: {} as OnSubmitMeta, + } as const) + + form.handleSubmit({ group: 'track' }) + + assertType<(submitMeta: { group: string }) => Promise>( + form.handleSubmit, + ) +}) diff --git a/packages/lit-form/src/tanstack-form-controller.ts b/packages/lit-form/src/tanstack-form-controller.ts index f248007b2..ebfea17c1 100644 --- a/packages/lit-form/src/tanstack-form-controller.ts +++ b/packages/lit-form/src/tanstack-form-controller.ts @@ -22,13 +22,15 @@ type renderCallback< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = ( fieldOptions: FieldApi< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) => unknown @@ -42,6 +44,7 @@ type fieldDirectiveType< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = ( form: FormApi, options: FieldOptions< @@ -49,31 +52,35 @@ type fieldDirectiveType< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, render: renderCallback< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) => { values: { - form: FormApi + form: FormApi options: FieldOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > render: renderCallback< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > } } @@ -83,20 +90,23 @@ export class TanStackFormController< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > implements ReactiveController { #host: ReactiveControllerHost #subscription?: () => void - api: FormApi + api: FormApi constructor( host: ReactiveControllerHost, - config?: FormOptions, + config?: FormOptions, ) { ;(this.#host = host).addController(this) - this.api = new FormApi(config) + this.api = new FormApi( + config, + ) } hostConnected() { @@ -121,14 +131,16 @@ export class TanStackFormController< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, render: renderCallback< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) { return ( @@ -137,9 +149,10 @@ export class TanStackFormController< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > - )(this.api, fieldConfig, render) + )(this.api as never, fieldConfig, render) } } @@ -153,9 +166,17 @@ class FieldDirective< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > extends AsyncDirective { #registered = false - #field?: FieldApi + #field?: FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > #unmount?: () => void constructor(partInfo: PartInfo) { @@ -198,20 +219,22 @@ class FieldDirective< } render( - _form: FormApi, + _form: FormApi, _fieldConfig: FieldOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, _renderCallback: renderCallback< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) { if (this.#field) { diff --git a/packages/react-form/src/types.ts b/packages/react-form/src/types.ts index 8f39d95cb..ad1e1414f 100644 --- a/packages/react-form/src/types.ts +++ b/packages/react-form/src/types.ts @@ -19,12 +19,14 @@ export type UseFieldOptions< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = FieldApiOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > & { mode?: 'value' | 'array' } diff --git a/packages/react-form/src/useField.tsx b/packages/react-form/src/useField.tsx index 681351dc6..316f63865 100644 --- a/packages/react-form/src/useField.tsx +++ b/packages/react-form/src/useField.tsx @@ -11,11 +11,12 @@ interface ReactFieldApi< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > { /** * A pre-bound and type-safe sub-field component using this field as a root. */ - Field: FieldComponent + Field: FieldComponent } /** @@ -28,6 +29,7 @@ export type UseField< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > = < TName extends DeepKeys, TFieldValidator extends @@ -36,10 +38,24 @@ export type UseField< TData extends DeepValue = DeepValue, >( opts: Omit< - UseFieldOptions, + UseFieldOptions< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + >, 'form' >, -) => FieldApi +) => FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension +> /** * A hook for managing a field in a form. @@ -57,13 +73,15 @@ export function useField< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, >( opts: UseFieldOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) { const [fieldApi] = useState(() => { @@ -73,7 +91,8 @@ export function useField< name: opts.name, }) - const extendedApi: typeof api & ReactFieldApi = + const extendedApi: typeof api & + ReactFieldApi = api as never extendedApi.Field = Field as never @@ -116,6 +135,7 @@ type FieldComponentProps< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = { children: ( fieldApi: FieldApi< @@ -123,10 +143,18 @@ type FieldComponentProps< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) => ReactNode -} & UseFieldOptions +} & UseFieldOptions< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension +> /** * A type alias representing a field component for a specific form data type. @@ -136,6 +164,7 @@ export type FieldComponent< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > = < TName extends DeepKeys, TFieldValidator extends @@ -151,7 +180,8 @@ export type FieldComponent< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, 'form' >) => ReactNode @@ -171,6 +201,7 @@ export const Field = (< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, >({ children, ...fieldOptions @@ -179,7 +210,8 @@ export const Field = (< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >): ReactNode => { const fieldApi = useField(fieldOptions as any) @@ -194,4 +226,6 @@ export const Field = (< [children, fieldApi, fieldApi.state.value, fieldApi.state.meta], ) return (<>{jsxToDisplay}) as never -}) satisfies FunctionComponent> +}) satisfies FunctionComponent< + FieldComponentProps +> diff --git a/packages/react-form/src/useForm.tsx b/packages/react-form/src/useForm.tsx index d3a4eafbe..811df8cfd 100644 --- a/packages/react-form/src/useForm.tsx +++ b/packages/react-form/src/useForm.tsx @@ -14,11 +14,12 @@ import type { FormOptions, FormState, Validator } from '@tanstack/form-core' export interface ReactFormApi< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > { /** * A React component to render form fields. With this, you can render and manage individual form fields. */ - Field: FieldComponent + Field: FieldComponent /** * A `Subscribe` function that allows you to listen and react to changes in the form's state. It's especially useful when you need to execute side effects or render specific components in response to state updates. */ @@ -34,14 +35,16 @@ export interface ReactFormApi< export type ReactFormExtendedApi< TFormData, TFormValidator extends Validator | undefined = undefined, -> = FormApi & ReactFormApi + TFormSubmitMeta = never, +> = FormApi & + ReactFormApi function LocalSubscribe({ form, selector, children, }: PropsWithChildren<{ - form: FormApi + form: FormApi selector: (state: FormState) => FormState }>) { const data = useStore(form.store, selector) @@ -57,12 +60,16 @@ function LocalSubscribe({ export function useForm< TFormData, TFormValidator extends Validator | undefined = undefined, ->(opts?: FormOptions) { + TFormSubmitMeta = never, +>(opts?: FormOptions) { const [formApi] = useState(() => { - const api = new FormApi(opts) + const api = new FormApi(opts) - const extendedApi: ReactFormExtendedApi = - api as never + const extendedApi: ReactFormExtendedApi< + TFormData, + TFormValidator, + TFormSubmitMeta + > = api as never extendedApi.Field = function APIField(props) { return } diff --git a/packages/react-form/src/useTransform.ts b/packages/react-form/src/useTransform.ts index 35905370a..4f6cf039f 100644 --- a/packages/react-form/src/useTransform.ts +++ b/packages/react-form/src/useTransform.ts @@ -3,10 +3,13 @@ import type { FormApi, FormTransform, Validator } from '@tanstack/form-core' export function useTransform< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, >( - fn: (formBase: FormApi) => FormApi, + fn: ( + formBase: FormApi, + ) => FormApi, deps: unknown[], -): FormTransform { +): FormTransform { return { fn, deps, diff --git a/packages/solid-form/src/createField.tsx b/packages/solid-form/src/createField.tsx index 338d20c26..27504f407 100644 --- a/packages/solid-form/src/createField.tsx +++ b/packages/solid-form/src/createField.tsx @@ -22,8 +22,9 @@ interface SolidFieldApi< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > { - Field: FieldComponent + Field: FieldComponent } export type CreateField< @@ -31,6 +32,7 @@ export type CreateField< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > = < TName extends DeepKeys, TFieldValidator extends @@ -44,7 +46,8 @@ export type CreateField< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, 'form' >, @@ -53,9 +56,10 @@ export type CreateField< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > & - SolidFieldApi + SolidFieldApi // ugly way to trick solid into triggering updates for changes on the fieldApi function makeFieldReactive< @@ -68,14 +72,23 @@ function makeFieldReactive< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, FieldApiT extends FieldApi< TParentData, TName, TFieldValidator, TFormValidator, - TData - > = FieldApi & - SolidFieldApi, + TData, + TParentMetaExtension + > = FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > & + SolidFieldApi, >(fieldApi: FieldApiT): () => FieldApiT { const [flag, setFlag] = createSignal(false) const fieldApiMemo = createMemo(() => [flag(), fieldApi] as const) @@ -94,20 +107,23 @@ export function createField< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, >( opts: () => CreateFieldOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) { const options = opts() const api = new FieldApi(options) - const extendedApi: typeof api & SolidFieldApi = + const extendedApi: typeof api & + SolidFieldApi = api as never extendedApi.Field = Field as never @@ -147,6 +163,7 @@ type FieldComponentProps< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = { children: ( fieldApi: () => FieldApi< @@ -154,7 +171,8 @@ type FieldComponentProps< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) => JSXElement } & Omit< @@ -163,7 +181,8 @@ type FieldComponentProps< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, 'form' > @@ -173,6 +192,7 @@ export type FieldComponent< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > = < TName extends DeepKeys, TFieldValidator extends @@ -188,7 +208,8 @@ export type FieldComponent< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, 'form' >) => JSXElement @@ -203,6 +224,7 @@ export function Field< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, >( props: { children: ( @@ -211,7 +233,8 @@ export function Field< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) => JSXElement } & CreateFieldOptions< @@ -219,7 +242,8 @@ export function Field< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) { const fieldApi = createField< @@ -227,7 +251,8 @@ export function Field< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >(() => { const { children, ...fieldOptions } = props return fieldOptions diff --git a/packages/solid-form/src/createForm.tsx b/packages/solid-form/src/createForm.tsx index 5a25cd967..0f916dbea 100644 --- a/packages/solid-form/src/createForm.tsx +++ b/packages/solid-form/src/createForm.tsx @@ -11,9 +11,10 @@ type NoInfer = [T][T extends any ? 0 : never] export interface SolidFormApi< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > { - Field: FieldComponent - createField: CreateField + Field: FieldComponent + createField: CreateField useStore: >>( selector?: (state: NoInfer>) => TSelected, ) => () => TSelected @@ -28,11 +29,12 @@ export function createForm< TFormValidator extends | Validator | undefined = undefined, ->(opts?: () => FormOptions) { + TFormSubmitMeta = never, +>(opts?: () => FormOptions) { const options = opts?.() - const api = new FormApi(options) - const extendedApi: typeof api & SolidFormApi = - api as never + const api = new FormApi(options) + const extendedApi: typeof api & + SolidFormApi = api as never extendedApi.Field = (props) => extendedApi.createField = (props) => diff --git a/packages/solid-form/src/types.ts b/packages/solid-form/src/types.ts index 959b7d936..e699fd189 100644 --- a/packages/solid-form/src/types.ts +++ b/packages/solid-form/src/types.ts @@ -15,12 +15,14 @@ export type CreateFieldOptions< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = FieldApiOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > & { mode?: 'value' | 'array' } diff --git a/packages/vue-form/src/types.ts b/packages/vue-form/src/types.ts index 8a19e8af4..4f84038df 100644 --- a/packages/vue-form/src/types.ts +++ b/packages/vue-form/src/types.ts @@ -15,12 +15,14 @@ export type UseFieldOptions< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, > = FieldApiOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > & { mode?: 'value' | 'array' } diff --git a/packages/vue-form/src/useField.tsx b/packages/vue-form/src/useField.tsx index 059f3c17e..e2e30cd11 100644 --- a/packages/vue-form/src/useField.tsx +++ b/packages/vue-form/src/useField.tsx @@ -10,8 +10,9 @@ export interface VueFieldApi< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > { - Field: FieldComponent + Field: FieldComponent } export type UseField< @@ -19,6 +20,7 @@ export type UseField< TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > = < TName extends DeepKeys, TFieldValidator extends @@ -27,12 +29,26 @@ export type UseField< TData extends DeepValue = DeepValue, >( opts: Omit< - UseFieldOptions, + UseFieldOptions< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + >, 'form' >, ) => { - api: FieldApi & - VueFieldApi + api: FieldApi< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension + > & + VueFieldApi state: Readonly< Ref< FieldApi< @@ -40,7 +56,8 @@ export type UseField< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >['state'] > > @@ -56,13 +73,15 @@ export function useField< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, >( opts: UseFieldOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, ) { const fieldApi = (() => { @@ -72,7 +91,8 @@ export function useField< name: opts.name, }) - const extendedApi: typeof api & VueFieldApi = + const extendedApi: typeof api & + VueFieldApi = api as never extendedApi.Field = Field as never @@ -112,13 +132,22 @@ type FieldComponentProps< | Validator | undefined = undefined, TData extends DeepValue = DeepValue, -> = UseFieldOptions + TParentMetaExtension = never, +> = UseFieldOptions< + TParentData, + TName, + TFieldValidator, + TFormValidator, + TData, + TParentMetaExtension +> export type FieldComponent< TParentData, TFormValidator extends | Validator | undefined = undefined, + TParentMetaExtension = never, > = < TName extends DeepKeys, TFieldValidator extends @@ -132,7 +161,8 @@ export type FieldComponent< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, 'form' >, @@ -145,14 +175,16 @@ export type FieldComponent< TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension > state: FieldApi< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >['state'] } }> @@ -170,13 +202,15 @@ export const Field = defineComponent( | Validator | undefined = undefined, TData extends DeepValue = DeepValue, + TParentMetaExtension = never, >( fieldOptions: UseFieldOptions< TParentData, TName, TFieldValidator, TFormValidator, - TData + TData, + TParentMetaExtension >, context: SetupContext, ) => { diff --git a/packages/vue-form/src/useForm.tsx b/packages/vue-form/src/useForm.tsx index 1538a0498..bbcc18224 100644 --- a/packages/vue-form/src/useForm.tsx +++ b/packages/vue-form/src/useForm.tsx @@ -10,9 +10,10 @@ import type { FieldComponent, UseField } from './useField' export interface VueFormApi< TFormData, TFormValidator extends Validator | undefined = undefined, + TFormSubmitMeta = never, > { - Field: FieldComponent - useField: UseField + Field: FieldComponent + useField: UseField useStore: >>( selector?: (state: NoInfer>) => TSelected, ) => Readonly> @@ -30,12 +31,13 @@ export interface VueFormApi< export function useForm< TFormData, TFormValidator extends Validator | undefined = undefined, ->(opts?: FormOptions) { + TFormSubmitMeta = never, +>(opts?: FormOptions) { const formApi = (() => { - const api = new FormApi(opts) + const api = new FormApi(opts) - const extendedApi: typeof api & VueFormApi = - api as never + const extendedApi: typeof api & + VueFormApi = api as never extendedApi.Field = defineComponent( (props, context) => { return () =>