Skip to content

Commit

Permalink
refactor!: remove touchedErrors, {touch: true} API (true by default…
Browse files Browse the repository at this point in the history
…), deprecate `field.getValue` (#812)

* refactor!: deprecate field.getValue() in favor of field.state.value

* refactor!: remove field.touchedErrors

* chore: temp disable ESLint rules

* chore: format more examples

* chore: remove touch, set default behavior to true, add dontUpdateMeta API

* chore: fix test:ci
  • Loading branch information
crutchcorn authored Jul 6, 2024
1 parent d44b9d0 commit 4e4a3ae
Show file tree
Hide file tree
Showing 79 changed files with 430 additions and 453 deletions.
2 changes: 1 addition & 1 deletion docs/framework/angular/reference/injectform.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ function injectForm<TFormData, TFormValidator>(opts?): FormApi<TFormData, TFormV

## Source

[inject-form.ts:4](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/inject-form.ts#L4)
[inject-form.ts:4](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/inject-form.ts#L4)
2 changes: 1 addition & 1 deletion docs/framework/angular/reference/injectstore.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ function injectStore<TFormData, TFormValidator, TSelected>(form, selector?): Sig

## Source

[inject-store.ts:4](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/inject-store.ts#L4)
[inject-store.ts:4](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/inject-store.ts#L4)
42 changes: 13 additions & 29 deletions docs/framework/angular/reference/tanstackfield.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ api: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>;

#### Source

[tanstack-field.directive.ts:62](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L62)
[tanstack-field.directive.ts:61](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L61)

***

Expand All @@ -57,7 +57,7 @@ optional asyncAlways: boolean;

#### Source

[tanstack-field.directive.ts:50](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L50)
[tanstack-field.directive.ts:50](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L50)

***

Expand All @@ -73,7 +73,7 @@ optional asyncDebounceMs: number;

#### Source

[tanstack-field.directive.ts:49](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L49)
[tanstack-field.directive.ts:49](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L49)

***

Expand All @@ -89,7 +89,7 @@ optional defaultMeta: Partial<FieldMeta>;

#### Source

[tanstack-field.directive.ts:60](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L60)
[tanstack-field.directive.ts:59](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L59)

***

Expand All @@ -105,7 +105,7 @@ optional defaultValue: NoInfer<TData>;

#### Source

[tanstack-field.directive.ts:48](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L48)
[tanstack-field.directive.ts:48](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L48)

***

Expand All @@ -121,23 +121,7 @@ name: TName;

#### Source

[tanstack-field.directive.ts:44](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L44)

***

### preserveValue?

```ts
optional preserveValue: boolean;
```

#### Implementation of

`FieldOptions.preserveValue`

#### Source

[tanstack-field.directive.ts:51](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L51)
[tanstack-field.directive.ts:44](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L44)

***

Expand All @@ -149,7 +133,7 @@ tanstackField: FormApi<TParentData, TFormValidator>;

#### Source

[tanstack-field.directive.ts:53](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L53)
[tanstack-field.directive.ts:52](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L52)

***

Expand All @@ -165,7 +149,7 @@ optional unmount: () => void;

#### Source

[tanstack-field.directive.ts:78](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L78)
[tanstack-field.directive.ts:76](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L76)

***

Expand All @@ -181,7 +165,7 @@ optional validatorAdapter: TFieldValidator;

#### Source

[tanstack-field.directive.ts:52](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L52)
[tanstack-field.directive.ts:51](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L51)

***

Expand All @@ -197,7 +181,7 @@ optional validators: NoInfer<FieldValidators<TParentData, TName, TFieldValidator

#### Source

[tanstack-field.directive.ts:57](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L57)
[tanstack-field.directive.ts:56](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L56)

## Methods

Expand All @@ -217,7 +201,7 @@ ngOnChanges(): void

#### Source

[tanstack-field.directive.ts:90](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L90)
[tanstack-field.directive.ts:88](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L88)

***

Expand All @@ -237,7 +221,7 @@ ngOnDestroy(): void

#### Source

[tanstack-field.directive.ts:86](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L86)
[tanstack-field.directive.ts:84](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L84)

***

Expand All @@ -257,4 +241,4 @@ ngOnInit(): void

#### Source

[tanstack-field.directive.ts:80](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/angular-form/src/tanstack-field.directive.ts#L80)
[tanstack-field.directive.ts:78](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/angular-form/src/tanstack-field.directive.ts#L78)
10 changes: 5 additions & 5 deletions docs/framework/lit/reference/tanstackformcontroller.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ new TanStackFormController<TParentData, TFormValidator>(host, config?): TanStack
#### Source
[tanstack-form-controller.ts:93](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/lit-form/src/tanstack-form-controller.ts#L93)
[tanstack-form-controller.ts:93](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/lit-form/src/tanstack-form-controller.ts#L93)
## Properties
Expand All @@ -42,7 +42,7 @@ api: FormApi<TParentData, TFormValidator>;
#### Source
[tanstack-form-controller.ts:91](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/lit-form/src/tanstack-form-controller.ts#L91)
[tanstack-form-controller.ts:91](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/lit-form/src/tanstack-form-controller.ts#L91)
## Methods
Expand Down Expand Up @@ -96,7 +96,7 @@ render: renderCallback<TParentData, TName, TFieldValidator, TFormValidator, TDat
#### Source
[tanstack-form-controller.ts:112](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/lit-form/src/tanstack-form-controller.ts#L112)
[tanstack-form-controller.ts:112](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/lit-form/src/tanstack-form-controller.ts#L112)
***
Expand All @@ -116,7 +116,7 @@ hostConnected(): void
#### Source
[tanstack-form-controller.ts:102](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/lit-form/src/tanstack-form-controller.ts#L102)
[tanstack-form-controller.ts:102](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/lit-form/src/tanstack-form-controller.ts#L102)
***
Expand All @@ -136,4 +136,4 @@ hostDisconnected(): void
#### Source
[tanstack-form-controller.ts:108](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/lit-form/src/tanstack-form-controller.ts#L108)
[tanstack-form-controller.ts:108](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/lit-form/src/tanstack-form-controller.ts#L108)
2 changes: 1 addition & 1 deletion docs/framework/react/guides/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Once you have your validation in place, you can map the errors from an array to
return (
<>
{/* ... */}
{field.state.meta.errors ? <em>{field.state.meta.errors}</em> : null}
{field.state.meta.errors.length ? <em>{field.state.meta.errors.join(",")}</em> : null}
</>
)
}}
Expand Down
23 changes: 0 additions & 23 deletions docs/framework/react/reference/createservervalidate.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/framework/react/reference/field.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ The `Field` component uses the `useField` hook internally to manage the field in

## Source

[useField.tsx:171](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/react-form/src/useField.tsx#L171)
[useField.tsx:163](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/react-form/src/useField.tsx#L163)
2 changes: 1 addition & 1 deletion docs/framework/react/reference/fieldcomponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ A type alias representing a field component for a specific form data type.

## Source

[useField.tsx:141](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/react-form/src/useField.tsx#L141)
[useField.tsx:133](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/react-form/src/useField.tsx#L133)
5 changes: 0 additions & 5 deletions docs/framework/react/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
- [FieldComponent](fieldcomponent.md)
- [UseField](usefield.md)

## Variables

- [initialFormState](initialformstate.md)

## Functions

- [Field](field.md)
- [createServerValidate](createservervalidate.md)
- [useField](usefield.md)
- [useForm](useform.md)
- [useTransform](usetransform.md)
29 changes: 0 additions & 29 deletions docs/framework/react/reference/initialformstate.md

This file was deleted.

6 changes: 3 additions & 3 deletions docs/framework/react/reference/usefield.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Function: useField()

```ts
function useField<TParentData, TName, TFieldValidator, TFormValidator, TData>(opts): FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>
function useField<TParentData, TName, TFieldValidator, TFormValidator, TData>(opts): FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData> & ReactFieldApi<TParentData, TFormValidator>
```

A hook for managing a field in a form.
Expand All @@ -26,10 +26,10 @@ An object with field options.

## Returns

`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>
`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\> & `ReactFieldApi`\<`TParentData`, `TFormValidator`\>

The `FieldApi` instance for the specified field.

## Source

[useField.tsx:60](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/react-form/src/useField.tsx#L60)
[useField.tsx:49](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/react-form/src/useField.tsx#L49)
8 changes: 4 additions & 4 deletions docs/framework/react/reference/useform.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Function: useForm()

```ts
function useForm<TFormData, TFormValidator>(opts?): FormApi<TFormData, TFormValidator>
function useForm<TFormData, TFormValidator>(opts?): FormApi<TFormData, TFormValidator> & ReactFormApi<TFormData, TFormValidator>
```

A custom React Hook that returns an instance of the `FormApi` class.
A custom React Hook that returns an extended instance of the `FormApi` class.

This API encapsulates all the necessary functionalities related to the form. It allows you to manage form state, handle submissions, and interact with form fields

Expand All @@ -20,8 +20,8 @@ This API encapsulates all the necessary functionalities related to the form. It

## Returns

`FormApi`\<`TFormData`, `TFormValidator`\>
`FormApi`\<`TFormData`, `TFormValidator`\> & `ReactFormApi`\<`TFormData`, `TFormValidator`\>

## Source

[useForm.tsx:56](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/react-form/src/useForm.tsx#L56)
[useForm.tsx:56](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/react-form/src/useForm.tsx#L56)
2 changes: 1 addition & 1 deletion docs/framework/react/reference/usetransform.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ fn: (formBase) => FormApi<TFormData, TFormValidator>;

## Source

[useTransform.ts:3](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/react-form/src/useTransform.ts#L3)
[useTransform.ts:3](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/react-form/src/useTransform.ts#L3)
2 changes: 1 addition & 1 deletion docs/framework/solid/reference/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ function Field<TParentData, TName, TFieldValidator, TFormValidator, TData>(props

## Source

[createField.tsx:166](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/solid-form/src/createField.tsx#L166)
[createField.tsx:185](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/solid-form/src/createField.tsx#L185)
6 changes: 3 additions & 3 deletions docs/framework/solid/reference/createField.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Function: createField()

```ts
function createField<TParentData, TName, TFieldValidator, TFormValidator, TData>(opts): () => FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>
function createField<TParentData, TName, TFieldValidator, TFormValidator, TData>(opts): () => never
```

## Type parameters
Expand All @@ -26,8 +26,8 @@ function createField<TParentData, TName, TFieldValidator, TFormValidator, TData>

### Returns

`FieldApi`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>
`never`

## Source

[createField.tsx:72](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/solid-form/src/createField.tsx#L72)
[createField.tsx:87](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/solid-form/src/createField.tsx#L87)
6 changes: 3 additions & 3 deletions docs/framework/solid/reference/createForm.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Function: createForm()

```ts
function createForm<TParentData, TFormValidator>(opts?): FormApi<TParentData, TFormValidator>
function createForm<TParentData, TFormValidator>(opts?): FormApi<TParentData, TFormValidator> & SolidFormApi<TParentData, TFormValidator>
```

## Type parameters
Expand All @@ -16,8 +16,8 @@ function createForm<TParentData, TFormValidator>(opts?): FormApi<TParentData, TF

## Returns

`FormApi`\<`TParentData`, `TFormValidator`\>
`FormApi`\<`TParentData`, `TFormValidator`\> & `SolidFormApi`\<`TParentData`, `TFormValidator`\>

## Source

[createForm.tsx:29](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/solid-form/src/createForm.tsx#L29)
[createForm.tsx:29](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/solid-form/src/createForm.tsx#L29)
2 changes: 1 addition & 1 deletion docs/framework/solid/reference/fieldcomponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ type FieldComponent<TParentData, TFormValidator>: <TName, TFieldValidator, TData

## Source

[createField.tsx:141](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/solid-form/src/createField.tsx#L141)
[createField.tsx:160](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/solid-form/src/createField.tsx#L160)
2 changes: 1 addition & 1 deletion docs/framework/vue/reference/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ function Field<TParentData, TName, TFieldValidator, TFormValidator, TData>(props

## Source

[packages/vue-form/src/useField.tsx:184](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/vue-form/src/useField.tsx#L184)
[packages/vue-form/src/useField.tsx:162](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/vue-form/src/useField.tsx#L162)
2 changes: 1 addition & 1 deletion docs/framework/vue/reference/fieldcomponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ type FieldComponent<TParentData, TFormValidator>: <TName, TFieldValidator, TData

## Source

[packages/vue-form/src/useField.tsx:139](https://github.com/TanStack/form/blob/5c94fa159313e0b0411d49fbdc3b117336185e63/packages/vue-form/src/useField.tsx#L139)
[packages/vue-form/src/useField.tsx:117](https://github.com/TanStack/form/blob/ada0211684adc85c41587b076e1217390ff5344e/packages/vue-form/src/useField.tsx#L117)
Loading

0 comments on commit 4e4a3ae

Please sign in to comment.