-
-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: complete form factory functionality, docs
- Loading branch information
1 parent
b274bcc
commit c444704
Showing
7 changed files
with
103 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
id: createFormFactory | ||
title: createFormFactory | ||
--- | ||
|
||
### `createFormFactory` | ||
|
||
```tsx | ||
export function createFormFactory<TFormData>( | ||
opts?: FormOptions<TFormData>, | ||
): FormFactory<TFormData> | ||
``` | ||
|
||
A function that creates a new `FormFactory<TFormData>` instance. | ||
|
||
- `opts` | ||
- Optional form options and a `listen` function to be called with the form state. | ||
|
||
### `FormFactory<TFormData>` | ||
|
||
A type representing a form factory. Form factories provide a type-safe way to interact with the form API as opposed to using the globally exported form utilities. | ||
|
||
```tsx | ||
export type FormFactory<TFormData> = { | ||
useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData> | ||
useField: UseField<TFormData> | ||
Field: FieldComponent<TFormData> | ||
} | ||
``` | ||
|
||
- `useForm` | ||
- A custom hook that creates and returns a new instance of the `FormApi<TFormData>` class. | ||
- `useField` | ||
- A custom hook that returns an instance of the `FieldApi<TFormData>` class. | ||
- `Field` | ||
- A form field component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
export * from '@tanstack/form-core' | ||
export * from './useForm' | ||
export * from './Field' | ||
export * from './useField' | ||
export * from './createFormFactory' | ||
export type { | ||
ChangeProps, | ||
DeepKeys, | ||
DeepValue, | ||
FieldApiOptions, | ||
FieldInfo, | ||
FieldMeta, | ||
FieldOptions, | ||
FieldState, | ||
FormOptions, | ||
FormState, | ||
InputProps, | ||
RequiredByKey, | ||
Updater, | ||
UpdaterFn, | ||
UserChangeProps, | ||
UserInputProps, | ||
ValidationCause, | ||
ValidationError, | ||
ValidationMeta, | ||
} from '@tanstack/form-core' | ||
|
||
export { FormApi, FieldApi, functionalUpdate } from '@tanstack/form-core' | ||
|
||
export type { FormComponent, FormProps } from './useForm' | ||
export { useForm } from './useForm' | ||
|
||
export type { FieldComponent } from './Field' | ||
export { Field } from './Field' | ||
|
||
export type { UseField } from './useField' | ||
export { useField } from './useField' | ||
|
||
export type { FormFactory } from './createFormFactory' | ||
export { createFormFactory } from './createFormFactory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters