Skip to content

Commit

Permalink
Merge branch 'main' into fix/array-insert-value
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/form-core/src/FieldApi.ts
#	packages/form-core/src/tests/FormApi.spec.ts
  • Loading branch information
crutchcorn committed Jun 3, 2024
2 parents af4d5e8 + 8076d16 commit 9a4107b
Show file tree
Hide file tree
Showing 52 changed files with 10,633 additions and 7,690 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ jobs:
with:
fetch-depth: '0'
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
link-workspace-packages=true
prefer-workspace-packages=true
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
2 changes: 1 addition & 1 deletion docs/framework/react/guides/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function App() {
form.handleSubmit()
}}
>
<form.Field name="people">
<form.Field name="people" mode="array">
{(field) => {
return (
<div>
Expand Down
6 changes: 5 additions & 1 deletion docs/framework/react/guides/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ import { z } from 'zod'

## Reactivity

`@tanstack/react-form` offers various ways to subscribe to form and field state changes, such as the `form.useStore` hook, the `form.Subscribe` component, and the `form.useField` hook. These methods allow you to optimize your form's rendering performance by only updating components when necessary.
`@tanstack/react-form` offers various ways to subscribe to form and field state changes, most notably the `form.useStore` hook and the `form.Subscribe` component. These methods allow you to optimize your form's rendering performance by only updating components when necessary.

Example:

```tsx
const firstName = form.useStore((state) => state.values.firstName)
//...
<form.Subscribe
selector={(state) => [state.canSubmit, state.isSubmitting]}
children={([canSubmit, isSubmitting]) => (
Expand All @@ -190,6 +192,8 @@ Example:
/>
```

Note: The usage of the `form.useField` hook to achieve reactivity is discouraged since it is designed to be used thoughtfully within the `form.Field` component. You might want to use `form.useStore` instead.

## Array Fields

Array fields allow you to manage a list of values within a form, such as a list of hobbies. You can create an array field using the `form.Field` component with the `mode="array"` prop.
Expand Down
6 changes: 3 additions & 3 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 All @@ -25,7 +25,7 @@ _Remix Support Coming soon_



# App Router intergration
# App Router integration

- To use TanStack Form, the component containing the form should be a client component. This requires adding the `"use client"` directive. Wrap this client component within a server component like so:

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/fieldApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ A class representing the API for managing a form field.
- Replaces a value at the specified index.

- ```tsx
removeValue(index: number): void
removeValue(index: number): Promise<void>
```

- Removes a value at the specified index.
Expand Down
8 changes: 8 additions & 0 deletions 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
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.19.4",
"@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.19.4",
"@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.19.4",
"@tanstack/valibot-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/yup-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/zod-form-adapter": "^0.19.4",
"@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.19.4",
"@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.19.4",
"@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.19.4",
"@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.19.4"
"@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.19.4",
"@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.19.4",
"@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.19.4",
"@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.19.4",
"@tanstack/valibot-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/yup-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/zod-form-adapter": "^0.19.4",
"@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.19.4",
"@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.19.4",
"@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.19.4",
"@tanstack/valibot-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/yup-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/zod-form-adapter": "^0.19.4",
"@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.19.4",
"@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.19.4",
"@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.19.4",
"@tanstack/valibot-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/yup-form-adapter": "^0.19.4",
"@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.19.4",
"@tanstack/zod-form-adapter": "^0.19.4",
"@tanstack/vue-form": "^0.20.3",
"@tanstack/zod-form-adapter": "^0.20.3",
"vue": "^3.3.4",
"zod": "^3.22.4"
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "form",
"private": true,
"repository": "https://github.com/tanstack/form.git",
"packageManager": "pnpm@8.12.1",
"packageManager": "pnpm@9.0.6",
"type": "module",
"scripts": {
"clean": "pnpm --filter \"./packages/**\" run clean",
Expand Down Expand Up @@ -37,7 +37,7 @@
"namespace": "@tanstack",
"devDependencies": {
"@solidjs/testing-library": "^0.8.6",
"@tanstack/config": "^0.6.0",
"@tanstack/config": "^0.7.4",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@testing-library/user-event": "^14.5.2",
Expand Down

0 comments on commit 9a4107b

Please sign in to comment.