Skip to content

Commit

Permalink
Merge branch 'main' into fix/array-field-options
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/form-core/src/FieldApi.ts
#	packages/form-core/src/FormApi.ts
  • Loading branch information
crutchcorn committed Jun 3, 2024
2 parents acca2f6 + ecae7bb commit c505773
Show file tree
Hide file tree
Showing 43 changed files with 777 additions and 98 deletions.
14 changes: 7 additions & 7 deletions docs/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Feature/Capability Key:
| Feature | TanStack Form | Formik | Redux Form | React Hook Form | Final Form |
| ------------------------------------------------- |----------------------------------------------| ------------------------------ | -------------------------------------- | ------------------------------------------------ | -------------------------------------- |
| Github Repo / Stars | [![][stars-tanstack-form]][gh-tanstack-form] | [![][stars-formik]][gh-formik] | [![][stars-redux-form]][gh-redux-form] | [![][stars-react-hook-form]][gh-react-hook-form] | [![][stars-final-form]][gh-final-form] |
| Supported Frameworks | React, Vue, Angular, Solid, Lit | React | React | React | React |
| Supported Frameworks | React, Vue, Angular, Solid, Lit | React | React | React | React, Vue, Angular, Solid, Vanilla JS |
| Bundle Size | [![][bp-tanstack-form]][bpl-tanstack-form] | [![][bp-formik]][bpl-formik] | [![][bp-redux-form]][bpl-redux-form] | [![][bp-react-hook-form]][bpl-react-hook-form] | [![][bp-final-form]][bpl-final-form] |
| First-class TypeScript support ||||| |
| Fully Inferred TypeScript (Including Deep Fields) ||||| |
| First-class TypeScript support ||||| |
| Fully Inferred TypeScript (Including Deep Fields) ||||| 🛑 |
| Headless UI components ||||||
| Framework agnostic |||| 🛑 | |
| Granular reactivity ||||| |
| Nested object/array fields ||||*(1) | |
| Async validation ||||| |
| Framework agnostic |||| 🛑 | |
| Granular reactivity ||||| |
| Nested object/array fields ||||*(1) | |
| Async validation ||||| |
| Built-in async validation debounce ||||||
| Schema-based Validation ||||||

Expand Down
4 changes: 2 additions & 2 deletions docs/framework/react/guides/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ id: ssr
title: Next.js Usage
---

Before reading this guide, it's suggested you understand how React Server Components and React Server Actions work. [Check out this blog series for more information](https://unicorn-utterances.com/collections/react-beyond-the-render)

> ⚠ This feature is highly experimental and is subject to change. Currently, this example [leaks backend code the frontend through `onServerValidate`](https://github.com/TanStack/form/issues/710). We are working on changes to the API, and will update this guide and provide migration steps when a solution is available. ⚠
Before reading this guide, it's suggested you understand how React Server Components and React Server Actions work. [Check out this blog series for more information](https://unicorn-utterances.com/collections/react-beyond-the-render)

# Using TanStack Form in a Next.js App Router

Expand Down
7 changes: 6 additions & 1 deletion docs/reference/fieldApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ A class representing the API for managing a form field.
insertValue(index: number, value: TData, opts?: { touch?: boolean }): void
```

- Inserts a value at the specified index.
- Inserts a value at the specified index, shifting the subsequent values to the right.

- ```tsx
replaceValue(index: number, value: TData): void
```
- Replaces a value at the specified index.

- ```tsx
removeValue(index: number, opts?: { touch?: boolean }): Promise<void>
Expand Down
14 changes: 13 additions & 1 deletion docs/reference/formApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ A class representing the Form API. It handles the logic and interactions with th
validateAllFields(cause: ValidationCause): Promise<ValidationError[]>
```
- Validates all fields in the form using the correct handlers for a given validation type.
- ```tsx
validateArrayFieldsStartingFrom<TField extends DeepKeys<TFormData>>(field: TField, index: number, cause: ValidationCause): ValidationError[] | Promise<ValidationError[]>
```
- 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.
- ```tsx
validateField<TField extends DeepKeys<TFormData>>(field: TField, cause: ValidationCause): ValidationError[] | Promise<ValidationError[]>
```
- Validates a specified field in the form using the correct handlers for a given validation type.
- ```tsx
handleSubmit()
Expand Down Expand Up @@ -169,7 +177,11 @@ A class representing the Form API. It handles the logic and interactions with th
- ```tsx
insertFieldValue<TField extends DeepKeys<TFormData>>(field: TField, index: number, value: DeepValue<TFormData, TField>, opts?: { touch?: boolean })
```
- Inserts a value into an array field at the specified index.
- Inserts a value into an array field at the specified index, shifting the subsequent values to the right.
- ```tsx
replaceFieldValue<TField extends DeepKeys<TFormData>>(field: TField, index: number, value: DeepValue<TFormData, TField>, opts?: { touch?: boolean })
```
- Replaces a value into an array field at the specified index.
- ```tsx
removeFieldValue<TField extends DeepKeys<TFormData>>(field: TField, index: number, opts?: { touch?: boolean })
```
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/array/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"private": true,
"dependencies": {
"@tanstack/angular-form": "^0.20.2",
"@tanstack/angular-form": "^0.20.3",
"@angular/animations": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"private": true,
"dependencies": {
"@tanstack/angular-form": "^0.20.2",
"@tanstack/angular-form": "^0.20.3",
"@angular/animations": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"private": true,
"dependencies": {
"@tanstack/angular-form": "^0.20.2",
"@tanstack/valibot-form-adapter": "^0.20.2",
"@tanstack/angular-form": "^0.20.3",
"@tanstack/valibot-form-adapter": "^0.20.3",
"@angular/animations": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/yup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"private": true,
"dependencies": {
"@tanstack/angular-form": "^0.20.2",
"@tanstack/yup-form-adapter": "^0.20.2",
"@tanstack/angular-form": "^0.20.3",
"@tanstack/yup-form-adapter": "^0.20.3",
"@angular/animations": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"private": true,
"dependencies": {
"@tanstack/angular-form": "^0.20.2",
"@tanstack/zod-form-adapter": "^0.20.2",
"@tanstack/angular-form": "^0.20.3",
"@tanstack/zod-form-adapter": "^0.20.3",
"@angular/animations": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/lit/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/lit-form": "^0.20.2",
"@tanstack/lit-form": "^0.20.3",
"lit": "^3.1.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/lit/ui-libraries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/lit-form": "^0.20.2",
"@tanstack/lit-form": "^0.20.3",
"lit": "^3.1.1",
"@material/web": "^1.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react/array/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-form": "^0.20.2",
"@tanstack/react-form": "^0.20.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next-server-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"next": "14.0.4",
"@tanstack/react-form": "^0.20.2"
"@tanstack/react-form": "^0.20.3"
},
"devDependencies": {
"typescript": "5.4.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/query-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@tanstack/react-query": "^5.32.0",
"@tanstack/react-form": "^0.20.2",
"@tanstack/react-form": "^0.20.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-form": "^0.20.2",
"@tanstack/react-form": "^0.20.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react/ui-libraries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@mantine/core": "7.3.2",
"@mantine/hooks": "7.3.2",
"@mui/material": "5.15.2",
"@tanstack/react-form": "^0.20.2",
"@tanstack/react-form": "^0.20.3",
"@yme/lay-postcss": "0.1.0",
"postcss": "8.4.32",
"postcss-preset-mantine": "1.12.2",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-form": "^0.20.2",
"@tanstack/valibot-form-adapter": "^0.20.2",
"@tanstack/react-form": "^0.20.3",
"@tanstack/valibot-form-adapter": "^0.20.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"valibot": "^0.20.1"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/yup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-form": "^0.20.2",
"@tanstack/yup-form-adapter": "^0.20.2",
"@tanstack/react-form": "^0.20.3",
"@tanstack/yup-form-adapter": "^0.20.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"yup": "^1.3.2"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-form": "^0.20.2",
"@tanstack/zod-form-adapter": "^0.20.2",
"@tanstack/react-form": "^0.20.3",
"@tanstack/zod-form-adapter": "^0.20.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"zod": "^3.22.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/solid/array/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/solid-form": "^0.20.2",
"@tanstack/solid-form": "^0.20.3",
"solid-js": "^1.7.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/solid/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/solid-form": "^0.20.2",
"@tanstack/solid-form": "^0.20.3",
"solid-js": "^1.7.8"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/solid/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/solid-form": "^0.20.2",
"@tanstack/valibot-form-adapter": "^0.20.2",
"@tanstack/solid-form": "^0.20.3",
"@tanstack/valibot-form-adapter": "^0.20.3",
"solid-js": "^1.7.8",
"valibot": "^0.20.1"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/solid/yup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/solid-form": "^0.20.2",
"@tanstack/yup-form-adapter": "^0.20.2",
"@tanstack/solid-form": "^0.20.3",
"@tanstack/yup-form-adapter": "^0.20.3",
"solid-js": "^1.7.8",
"yup": "^1.3.2"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/solid/zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/solid-form": "^0.20.2",
"@tanstack/zod-form-adapter": "^0.20.2",
"@tanstack/solid-form": "^0.20.3",
"@tanstack/zod-form-adapter": "^0.20.3",
"solid-js": "^1.7.8",
"zod": "^3.22.4"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/array/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"serve": "vite preview"
},
"dependencies": {
"@tanstack/vue-form": "^0.20.2",
"@tanstack/vue-form": "^0.20.3",
"vue": "^3.3.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"serve": "vite preview"
},
"dependencies": {
"@tanstack/vue-form": "^0.20.2",
"@tanstack/vue-form": "^0.20.3",
"vue": "^3.3.4"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/vue/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"serve": "vite preview"
},
"dependencies": {
"@tanstack/vue-form": "^0.20.2",
"@tanstack/valibot-form-adapter": "^0.20.2",
"@tanstack/vue-form": "^0.20.3",
"@tanstack/valibot-form-adapter": "^0.20.3",
"vue": "^3.3.4",
"valibot": "^0.20.1"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/vue/yup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"serve": "vite preview"
},
"dependencies": {
"@tanstack/vue-form": "^0.20.2",
"@tanstack/yup-form-adapter": "^0.20.2",
"@tanstack/vue-form": "^0.20.3",
"@tanstack/yup-form-adapter": "^0.20.3",
"vue": "^3.3.4",
"yup": "^1.3.2"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/vue/zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"serve": "vite preview"
},
"dependencies": {
"@tanstack/vue-form": "^0.20.2",
"@tanstack/zod-form-adapter": "^0.20.2",
"@tanstack/vue-form": "^0.20.3",
"@tanstack/zod-form-adapter": "^0.20.3",
"vue": "^3.3.4",
"zod": "^3.22.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/angular-form",
"version": "0.20.2",
"version": "0.20.3",
"description": "Powerful, type-safe forms for Angular.",
"author": "tannerlinsley",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/form-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/form-core",
"version": "0.20.2",
"version": "0.20.3",
"description": "Powerful, type-safe, framework agnostic forms.",
"author": "tannerlinsley",
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions packages/form-core/src/FieldApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,12 @@ export class FieldApi<
opts?: { touch?: boolean },
) => this.form.insertFieldValue(this.name, index, value as any, opts)

replaceValue = (
index: number,
value: TData extends any[] ? TData[number] : never,
opts?: { touch?: boolean },
) => this.form.replaceFieldValue(this.name, index, value as any, opts)

removeValue = (index: number, opts?: { touch: boolean }) =>
this.form.removeFieldValue(this.name, index, opts)

Expand Down
Loading

0 comments on commit c505773

Please sign in to comment.