diff --git a/docs/zh-hans/comparison.md b/docs/zh-hans/comparison.md
index 95d01342d..bebb584ea 100644
--- a/docs/zh-hans/comparison.md
+++ b/docs/zh-hans/comparison.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:03.149Z'
id: comparison
title: 对比
---
+
> ⚠️ 本对比表格正在完善中,部分信息可能不够准确。如果您使用过其中任一库并认为信息可以改进,欢迎通过页面底部的 "Edit this page on Github" 链接提交修改建议(需附说明或证据)。
功能/能力说明:
@@ -13,23 +14,23 @@ title: 对比
- 🔶 支持且有文档,但需要用户自行编写额外代码
- 🛑 官方不支持或无文档
-| 功能 | TanStack Form | Formik | Redux Form | React Hook Form | Final Form |
-| -------------------------------------------------- | -------------------------------------------- | ------------------------------ | -------------------------------------- | ------------------------------------------------ | -------------------------------------- |
-| GitHub 仓库/星标数 | [![][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] |
-| 支持框架 | React, Vue, Angular, Solid, Lit | React | React | React | React, Vue, Angular, Solid, Vanilla JS |
-| 打包体积 | [![][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] |
-| 一流的 TypeScript 支持 | ✅ | ❓ | ❓ | ✅ | ✅ |
-| 完整的 TypeScript 类型推断(包含深层字段) | ✅ | ❓ | ❓ | ✅ | 🛑 |
-| 无头 UI 组件 (Headless UI) | ✅ | ❓ | ❓ | ✅ | ❓ |
-| 框架无关性 | ✅ | ❓ | ❓ | 🛑 | ✅ |
-| 细粒度响应式 | ✅ | ❓ | ❓ | ❓ | ✅ |
-| 嵌套对象/数组字段 | ✅ | ✅ | ❓ | ✅\*(1) | ✅ |
-| 异步验证 | ✅ | ✅ | ❓ | ✅ | ✅ |
-| 内置异步验证防抖 | ✅ | ❓ | ❓ | ❓ | ❓ |
-| 基于模式的验证 (Schema-based Validation) | ✅ | ✅ | ❓ | ✅ | ❓ |
-| 官方开发者工具 | 🛑\*(2) | 🛑 | ✅\*(3) | ✅ | ❓ |
-| 服务端渲染集成 (SSR integrations) | ✅ | 🛑 | 🛑 | 🛑 | 🛑 |
-| React 编译器支持 (React Compiler support) | ✅ | ❓ | ❓ | 🛑 | ❓ |
+| 功能 | TanStack Form | Formik | Redux Form | React Hook Form | Final Form |
+| ------------------------------------------ | -------------------------------------------- | ------------------------------ | -------------------------------------- | ------------------------------------------------ | -------------------------------------- |
+| GitHub 仓库/星标数 | [![][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] |
+| 支持框架 | React, Vue, Angular, Solid, Lit | React | React | React | React, Vue, Angular, Solid, Vanilla JS |
+| 打包体积 | [![][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] |
+| 一流的 TypeScript 支持 | ✅ | ❓ | ❓ | ✅ | ✅ |
+| 完整的 TypeScript 类型推断(包含深层字段) | ✅ | ❓ | ❓ | ✅ | 🛑 |
+| 无头 UI 组件 (Headless UI) | ✅ | ❓ | ❓ | ✅ | ❓ |
+| 框架无关性 | ✅ | ❓ | ❓ | 🛑 | ✅ |
+| 细粒度响应式 | ✅ | ❓ | ❓ | ❓ | ✅ |
+| 嵌套对象/数组字段 | ✅ | ✅ | ❓ | ✅\*(1) | ✅ |
+| 异步验证 | ✅ | ✅ | ❓ | ✅ | ✅ |
+| 内置异步验证防抖 | ✅ | ❓ | ❓ | ❓ | ❓ |
+| 基于模式的验证 (Schema-based Validation) | ✅ | ✅ | ❓ | ✅ | ❓ |
+| 官方开发者工具 | 🛑\*(2) | 🛑 | ✅\*(3) | ✅ | ❓ |
+| 服务端渲染集成 (SSR integrations) | ✅ | 🛑 | 🛑 | 🛑 | 🛑 |
+| React 编译器支持 (React Compiler support) | ✅ | ❓ | ❓ | 🛑 | ❓ |
\*(1) 对于嵌套数组,使用 TypeScript 时 react-hook-form 要求[通过字段名进行类型转换](https://react-hook-form.com/docs/usefieldarray)
diff --git a/docs/zh-hans/framework/angular/guides/arrays.md b/docs/zh-hans/framework/angular/guides/arrays.md
index fa4779538..22c9e555b 100644
--- a/docs/zh-hans/framework/angular/guides/arrays.md
+++ b/docs/zh-hans/framework/angular/guides/arrays.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:10:43.653Z'
id: arrays
title: 数组
---
+
TanStack Form 支持将数组作为表单值使用,包括数组中的子对象值。
## 基本用法
diff --git a/docs/zh-hans/framework/angular/guides/basic-concepts.md b/docs/zh-hans/framework/angular/guides/basic-concepts.md
index bbf9c80ac..924f3bb14 100644
--- a/docs/zh-hans/framework/angular/guides/basic-concepts.md
+++ b/docs/zh-hans/framework/angular/guides/basic-concepts.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:17.959Z'
id: basic-concepts
title: 基本概念
---
+
本页面介绍了 `@tanstack/angular-form` 库中使用的基本概念和术语。熟悉这些概念将帮助您更好地理解和使用该库。
## 表单实例 (Form Instance)
diff --git a/docs/zh-hans/framework/angular/guides/validation.md b/docs/zh-hans/framework/angular/guides/validation.md
index 43ce921b7..ff859c78e 100644
--- a/docs/zh-hans/framework/angular/guides/validation.md
+++ b/docs/zh-hans/framework/angular/guides/validation.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:12:19.741Z'
id: form-validation
title: 表单验证
---
+
表单与字段验证 (Form and Field Validation)
TanStack Form 的核心功能之一是验证机制。TanStack Form 提供了高度可定制的验证方式:
diff --git a/docs/zh-hans/framework/angular/quick-start.md b/docs/zh-hans/framework/angular/quick-start.md
index 6238aeecf..54a255420 100644
--- a/docs/zh-hans/framework/angular/quick-start.md
+++ b/docs/zh-hans/framework/angular/quick-start.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:25.901Z'
id: quick-start
title: 快速开始
---
+
## 快速入门
使用 TanStack Form 的最基本步骤是创建一个表单并添加字段。请注意,以下示例尚未包含任何验证或错误处理功能。
diff --git a/docs/zh-hans/framework/lit/guides/arrays.md b/docs/zh-hans/framework/lit/guides/arrays.md
index 980a7ed6e..24a00c505 100644
--- a/docs/zh-hans/framework/lit/guides/arrays.md
+++ b/docs/zh-hans/framework/lit/guides/arrays.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:36.599Z'
id: arrays
title: 数组
---
+
TanStack Form 支持将数组作为表单值使用,包括数组内的子对象值。
## 基本用法
diff --git a/docs/zh-hans/framework/lit/guides/basic-concepts.md b/docs/zh-hans/framework/lit/guides/basic-concepts.md
index 4c8cb4082..120221c20 100644
--- a/docs/zh-hans/framework/lit/guides/basic-concepts.md
+++ b/docs/zh-hans/framework/lit/guides/basic-concepts.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:24.303Z'
id: basic-concepts
title: 基本概念
---
+
本页介绍 `@tanstack/lit-form` 库中使用的基本概念和术语。熟悉这些概念将帮助您更好地理解并运用该库及其与 Lit 的配合使用。
## 表单选项 (Form Options)
diff --git a/docs/zh-hans/framework/lit/quick-start.md b/docs/zh-hans/framework/lit/quick-start.md
index 600b69985..f25b53e60 100644
--- a/docs/zh-hans/framework/lit/quick-start.md
+++ b/docs/zh-hans/framework/lit/quick-start.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:31.027Z'
id: quick-start
title: 快速开始
---
+
## 快速入门
开始使用 TanStack Form 的最低要求是创建一个 `TanstackFormController`,如下所示,我们使用 `Employee` 接口作为测试表单的数据结构:
diff --git a/docs/zh-hans/framework/react/community/balastrong-tutorial.md b/docs/zh-hans/framework/react/community/balastrong-tutorial.md
index 9e9549532..c045ec953 100644
--- a/docs/zh-hans/framework/react/community/balastrong-tutorial.md
+++ b/docs/zh-hans/framework/react/community/balastrong-tutorial.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:14:38.417Z'
id: balastrong-tutorial
title: Balastrong的教程
---
+
TanStack Form 维护者 [Balastrong](https://bsky.app/profile/leonardomontini.dev) 制作了一系列视频教程,展示了该库最核心的功能。通过这些循序渐进的指南,您将深入了解如何使用 TanStack Form 构建功能,并获取实用技巧。
[观看完整播放列表](https://www.youtube.com/playlist?list=PLOQjd5dsGSxInTKUWTxyqSKwZCjDIUs0Y)
diff --git a/docs/zh-hans/framework/react/guides/arrays.md b/docs/zh-hans/framework/react/guides/arrays.md
index 25f5bf6da..fa0c2b0ba 100644
--- a/docs/zh-hans/framework/react/guides/arrays.md
+++ b/docs/zh-hans/framework/react/guides/arrays.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:53.544Z'
id: arrays
title: 数组
---
+
TanStack Form 支持将数组作为表单值,包括数组内的子对象值。
## 基础用法
diff --git a/docs/zh-hans/framework/react/guides/async-initial-values.md b/docs/zh-hans/framework/react/guides/async-initial-values.md
index a6075ff09..a91ec2adb 100644
--- a/docs/zh-hans/framework/react/guides/async-initial-values.md
+++ b/docs/zh-hans/framework/react/guides/async-initial-values.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:42.790Z'
id: async-initial-values
title: 异步初始值
---
+
## 异步初始值
假设您需要从 API 获取数据并将其作为表单的初始值。
diff --git a/docs/zh-hans/framework/react/guides/basic-concepts.md b/docs/zh-hans/framework/react/guides/basic-concepts.md
index 35d7c5059..d198b5ad5 100644
--- a/docs/zh-hans/framework/react/guides/basic-concepts.md
+++ b/docs/zh-hans/framework/react/guides/basic-concepts.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:47.860Z'
id: basic-concepts
title: 基本概念
---
+
本页面介绍 `@tanstack/react-form` 库中使用的基本概念和术语。熟悉这些概念将帮助您更好地理解和使用该库。
## 表单选项 (Form Options)
diff --git a/docs/zh-hans/framework/react/guides/custom-errors.md b/docs/zh-hans/framework/react/guides/custom-errors.md
index 0a45713ed..0794ef818 100644
--- a/docs/zh-hans/framework/react/guides/custom-errors.md
+++ b/docs/zh-hans/framework/react/guides/custom-errors.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:56.557Z'
id: custom-errors
title: 自定义错误
---
+
TanStack Form 为验证器返回的错误值类型提供了完全的灵活性。字符串错误是最常见且易于处理的类型,但该库允许您从验证器中返回任何类型的值。
作为通用规则,任何真值(truthy value)都会被视作错误,并将表单或字段标记为无效;而假值(falsy values,如 `false`、`undefined`、`null` 等)则表示没有错误,表单或字段有效。
@@ -32,8 +33,7 @@ const form = useForm({
onChange: ({ value }) => {
return {
fields: {
- username:
- value.username.length < 3 ? '用户名过短' : undefined,
+ username: value.username.length < 3 ? '用户名过短' : undefined,
email: !value.email.includes('@') ? '无效的邮箱地址' : undefined,
},
}
@@ -73,9 +73,7 @@ const form = useForm({
{
/* TypeScript 会根据验证器推断错误类型为数字 */
}
-;
- 您还需要 {field.state.meta.errors[0]} 年才符合资格
-
+;您还需要 {field.state.meta.errors[0]} 年才符合资格
```
### 布尔类型
diff --git a/docs/zh-hans/framework/react/guides/debugging.md b/docs/zh-hans/framework/react/guides/debugging.md
index 32ce7940f..ca235f77a 100644
--- a/docs/zh-hans/framework/react/guides/debugging.md
+++ b/docs/zh-hans/framework/react/guides/debugging.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:26.089Z'
id: debugging
title: 调试
---
+
以下是您可能在控制台中遇到的常见错误列表及其解决方法。
## 将非受控输入更改为受控输入
diff --git a/docs/zh-hans/framework/react/guides/form-composition.md b/docs/zh-hans/framework/react/guides/form-composition.md
index 1f52b476e..42389d563 100644
--- a/docs/zh-hans/framework/react/guides/form-composition.md
+++ b/docs/zh-hans/framework/react/guides/form-composition.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:10:42.863Z'
id: form-composition
title: 表单组合
---
+
# 表单组合 (Form Composition)
对 TanStack Form 的一个常见批评是其开箱即用的冗长性。虽然这对于教育目的可能有用——有助于强化对 API 的理解——但在生产用例中并不理想。
diff --git a/docs/zh-hans/framework/react/guides/linked-fields.md b/docs/zh-hans/framework/react/guides/linked-fields.md
index 19448b911..56d1cc1be 100644
--- a/docs/zh-hans/framework/react/guides/linked-fields.md
+++ b/docs/zh-hans/framework/react/guides/linked-fields.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:50.083Z'
id: linked-fields
title: 关联字段
---
+
## 联动两个表单字段
在某些场景下,您可能需要将两个字段进行联动:当其中一个字段的值发生变化时,另一个字段需要重新验证。一个典型用例是同时存在 `password` 和 `confirm_password` 字段的情况,此时需要确保当 `password` 字段值不匹配时,`confirm_password` 字段能立即显示错误——无论哪个字段触发了值的变化。
diff --git a/docs/zh-hans/framework/react/guides/listeners.md b/docs/zh-hans/framework/react/guides/listeners.md
index 6dc1df64c..2ae3a0f0a 100644
--- a/docs/zh-hans/framework/react/guides/listeners.md
+++ b/docs/zh-hans/framework/react/guides/listeners.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:58.594Z'
id: listeners
title: 监听器
---
+
## 事件触发器的副作用处理
当您需要"影响"或"响应"某些触发行为时,可以使用监听器 (listener) API。例如,如果您作为开发者希望在某个字段变化时重置另一个表单字段,就应该使用监听器 API。
diff --git a/docs/zh-hans/framework/react/guides/react-native.md b/docs/zh-hans/framework/react/guides/react-native.md
index 2d7af0821..1f159039d 100644
--- a/docs/zh-hans/framework/react/guides/react-native.md
+++ b/docs/zh-hans/framework/react/guides/react-native.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:09.238Z'
id: react-native
title: React Native
---
+
## 动机
大多数 Web 框架并未提供全面的表单处理方案,迫使开发者要么自行实现定制方案,要么依赖功能有限的库。这往往导致一致性缺失、性能低下以及开发时间增加。TanStack Form 旨在通过提供一套强大易用的全功能表单管理方案来解决这些问题。
diff --git a/docs/zh-hans/framework/react/guides/reactivity.md b/docs/zh-hans/framework/react/guides/reactivity.md
index 1cb09b26b..b98faba5f 100644
--- a/docs/zh-hans/framework/react/guides/reactivity.md
+++ b/docs/zh-hans/framework/react/guides/reactivity.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:53.631Z'
id: reactivity
title: 响应式
---
+
Tanstack Form 在与表单交互时不会触发重新渲染。因此您可能会发现直接使用表单或字段状态值无法获得预期效果。
如需访问响应式值,您需要通过以下两种方法之一进行订阅:`useStore` 钩子或 `form.Subscribe` 组件。
diff --git a/docs/zh-hans/framework/react/guides/ssr.md b/docs/zh-hans/framework/react/guides/ssr.md
index c2a03193e..6f9ddea35 100644
--- a/docs/zh-hans/framework/react/guides/ssr.md
+++ b/docs/zh-hans/framework/react/guides/ssr.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:11.947Z'
id: ssr
title: SSR/TanStack Start/Next.js
---
+
TanStack Form 开箱即支持 React,兼容 服务端渲染 (SSR) 并保持框架无关性。但需要根据您选择的元框架进行特定配置。
目前我们支持以下元框架:
@@ -323,13 +324,13 @@ export const ClientComp = () => {
此处我们结合使用了 [React 的 useActionState 钩子](https://playfulprogramming.com/posts/what-is-use-action-state-and-form-status) 和 TanStack Form 的 useTransform 钩子来合并服务端动作返回的状态与表单状态。
> 如果在 Next.js 应用中遇到以下错误:
->
+>
> ```typescript
> x 您正在导入需要 useState 的组件。此 React 钩子仅在客户端组件中有效。解决方法是在文件(或其父级)中添加 "use client" 指令
> ```
->
+>
> 这是因为您没有从 `@tanstack/react-form/nextjs` 导入服务端代码。请确保根据运行环境导入正确的模块。
->
+>
> [这是 Next.js 的已知限制](https://github.com/phryneas/rehackt)。其他元框架通常不会出现此问题。
## 在 Remix 中使用 TanStack Form
diff --git a/docs/zh-hans/framework/react/guides/submission-handling.md b/docs/zh-hans/framework/react/guides/submission-handling.md
index e8c30ec83..a9ad01c60 100644
--- a/docs/zh-hans/framework/react/guides/submission-handling.md
+++ b/docs/zh-hans/framework/react/guides/submission-handling.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:04.203Z'
id: submission-handling
title: 提交处理
---
+
在需要处理多种表单提交类型的场景下(例如,一个表单同时包含导航至子表单的按钮和执行标准提交的按钮),可以利用 `onSubmitMeta` 属性和 `handleSubmit` 函数的重载机制。
## 基础用法
diff --git a/docs/zh-hans/framework/react/guides/ui-libraries.md b/docs/zh-hans/framework/react/guides/ui-libraries.md
index 138972088..8e4317f76 100644
--- a/docs/zh-hans/framework/react/guides/ui-libraries.md
+++ b/docs/zh-hans/framework/react/guides/ui-libraries.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:36.714Z'
id: ui-libraries
title: UI库集成
---
+
## 在 UI 库中使用 TanStack Form
TanStack Form 是一个无头 (headless) 库,为您提供完全的样式定制灵活性。它能与多种 UI 库兼容,包括 `Tailwind`、`Material UI`、`Mantine` 甚至原生 CSS。
diff --git a/docs/zh-hans/framework/react/guides/validation.md b/docs/zh-hans/framework/react/guides/validation.md
index 661fdd8be..861bbc904 100644
--- a/docs/zh-hans/framework/react/guides/validation.md
+++ b/docs/zh-hans/framework/react/guides/validation.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:10:47.393Z'
id: form-validation
title: 表单验证
---
+
表单与字段验证 (Form and Field Validation)
TanStack Form 的核心功能之一是验证机制。它提供了高度可定制的验证方式:
diff --git a/docs/zh-hans/framework/react/quick-start.md b/docs/zh-hans/framework/react/quick-start.md
index a6682d856..686c7d430 100644
--- a/docs/zh-hans/framework/react/quick-start.md
+++ b/docs/zh-hans/framework/react/quick-start.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:52.516Z'
id: quick-start
title: 快速开始
---
+
TanStack Form 与你以往使用的大多数表单库不同。它专为大规模生产环境设计,注重类型安全、性能与组合能力,旨在提供无与伦比的开发者体验。
为此,我们制定了[库的使用哲学](/form/latest/docs/philosophy),更重视可扩展性和长期开发者体验,而非简短可分享的代码片段。
@@ -109,8 +110,7 @@ const PeoplePage = () => {
name="age"
validators={{
// 可选择表单级或字段级验证器
- onChange: ({ value }) =>
- value > 13 ? undefined : '必须年满 13 岁',
+ onChange: ({ value }) => (value > 13 ? undefined : '必须年满 13 岁'),
}}
children={(field) => (
<>
diff --git a/docs/zh-hans/framework/solid/guides/arrays.md b/docs/zh-hans/framework/solid/guides/arrays.md
index 480b35329..6e6a4368f 100644
--- a/docs/zh-hans/framework/solid/guides/arrays.md
+++ b/docs/zh-hans/framework/solid/guides/arrays.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:14.180Z'
id: arrays
title: 数组
---
+
TanStack Form 支持将数组作为表单值使用,包括数组内的子对象值。
## 基本用法
diff --git a/docs/zh-hans/framework/solid/guides/async-initial-values.md b/docs/zh-hans/framework/solid/guides/async-initial-values.md
index b974b9b74..581e86352 100644
--- a/docs/zh-hans/framework/solid/guides/async-initial-values.md
+++ b/docs/zh-hans/framework/solid/guides/async-initial-values.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:00.234Z'
id: async-initial-values
title: 异步初始值
---
+
假设您需要从 API 获取数据并将其作为表单的初始值使用。
虽然这个问题表面看起来简单,但背后存在一些您可能尚未考虑到的隐藏复杂性。
diff --git a/docs/zh-hans/framework/solid/guides/basic-concepts.md b/docs/zh-hans/framework/solid/guides/basic-concepts.md
index 4196bbed6..7be6aff1f 100644
--- a/docs/zh-hans/framework/solid/guides/basic-concepts.md
+++ b/docs/zh-hans/framework/solid/guides/basic-concepts.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:10:54.326Z'
id: basic-concepts
title: 基本概念
---
+
本页面介绍了 `@tanstack/solid-form` 库中使用的基本概念和术语。熟悉这些概念将帮助您更好地理解和使用该库。
## 表单选项 (Form Options)
@@ -150,7 +151,7 @@ import { z } from 'zod'
await new Promise((resolve) => setTimeout(resolve, 1000))
return !value.includes('error')
},
- { message: '名中不能包含"error"' }
+ { message: '名中不能包含"error"' },
),
}}
/>
diff --git a/docs/zh-hans/framework/solid/guides/linked-fields.md b/docs/zh-hans/framework/solid/guides/linked-fields.md
index 24f925dcf..500e28769 100644
--- a/docs/zh-hans/framework/solid/guides/linked-fields.md
+++ b/docs/zh-hans/framework/solid/guides/linked-fields.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:07.786Z'
id: linked-fields
title: 关联字段
---
+
## 联动两个表单字段
在某些场景下,您可能需要将两个表单字段关联起来:当其中一个字段的值发生变化时,触发另一个字段的验证逻辑。
diff --git a/docs/zh-hans/framework/solid/guides/validation.md b/docs/zh-hans/framework/solid/guides/validation.md
index 9f67068df..a264b6253 100644
--- a/docs/zh-hans/framework/solid/guides/validation.md
+++ b/docs/zh-hans/framework/solid/guides/validation.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:12:06.653Z'
id: form-validation
title: 表单验证
---
+
表单与字段验证 (Form and Field Validation)
TanStack Form 的核心功能之一是高度可定制的验证机制:
diff --git a/docs/zh-hans/framework/solid/quick-start.md b/docs/zh-hans/framework/solid/quick-start.md
index c77d99773..681e03fbf 100644
--- a/docs/zh-hans/framework/solid/quick-start.md
+++ b/docs/zh-hans/framework/solid/quick-start.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:24.395Z'
id: quick-start
title: 快速开始
---
+
## 快速入门
开始使用 TanStack Form 的最低要求是创建一个表单并添加一个字段。请注意,这个示例尚未包含任何验证或错误处理功能。
diff --git a/docs/zh-hans/framework/vue/guides/arrays.md b/docs/zh-hans/framework/vue/guides/arrays.md
index f3bf722b4..da4c840d5 100644
--- a/docs/zh-hans/framework/vue/guides/arrays.md
+++ b/docs/zh-hans/framework/vue/guides/arrays.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:10:04.251Z'
id: arrays
title: 数组
---
+
TanStack Form 支持将数组作为表单值使用,包括数组内的子对象值。
## 基本用法
diff --git a/docs/zh-hans/framework/vue/guides/async-initial-values.md b/docs/zh-hans/framework/vue/guides/async-initial-values.md
index b3bd5c1d3..b5e89a7ee 100644
--- a/docs/zh-hans/framework/vue/guides/async-initial-values.md
+++ b/docs/zh-hans/framework/vue/guides/async-initial-values.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:29.672Z'
id: async-initial-values
title: 异步初始值
---
+
假设您需要从 API 获取数据并将其作为表单的初始值。
虽然这个问题表面看起来简单,但背后隐藏着您可能尚未考虑的复杂性。
diff --git a/docs/zh-hans/framework/vue/guides/basic-concepts.md b/docs/zh-hans/framework/vue/guides/basic-concepts.md
index de9427fce..f739c6133 100644
--- a/docs/zh-hans/framework/vue/guides/basic-concepts.md
+++ b/docs/zh-hans/framework/vue/guides/basic-concepts.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:10:42.406Z'
id: basic-concepts
title: 基本概念
---
+
本页介绍 `@tanstack/vue-form` 库中使用的基本概念和术语。熟悉这些概念将帮助您更好地理解和使用该库。
## 表单配置项 (Form Options)
diff --git a/docs/zh-hans/framework/vue/guides/linked-fields.md b/docs/zh-hans/framework/vue/guides/linked-fields.md
index 4c0bbb79e..517157c6d 100644
--- a/docs/zh-hans/framework/vue/guides/linked-fields.md
+++ b/docs/zh-hans/framework/vue/guides/linked-fields.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:09:57.125Z'
id: linked-fields
title: 关联字段
---
+
## 联动两个表单字段
在某些场景下,您可能需要将两个字段进行联动验证:当其中一个字段的值发生变化时,另一个字段需要重新验证。一个典型用例是同时存在 `password` 和 `confirm_password` 字段的情况,此时需要确保当 `password` 字段的值不匹配时,`confirm_password` 字段能立即显示错误——无论哪个字段触发了值的变化。
diff --git a/docs/zh-hans/framework/vue/guides/validation.md b/docs/zh-hans/framework/vue/guides/validation.md
index b7f03d8bd..f50c41e09 100644
--- a/docs/zh-hans/framework/vue/guides/validation.md
+++ b/docs/zh-hans/framework/vue/guides/validation.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:11:25.487Z'
id: form-validation
title: 表单验证
---
+
TanStack Form 的核心功能之一是验证 (validation) 概念。TanStack Form 使验证具有高度可定制性:
- 您可以控制何时执行验证(在值变更时、输入时、失焦时、提交时...)
diff --git a/docs/zh-hans/framework/vue/quick-start.md b/docs/zh-hans/framework/vue/quick-start.md
index 3eaba94c6..8edc72bac 100644
--- a/docs/zh-hans/framework/vue/quick-start.md
+++ b/docs/zh-hans/framework/vue/quick-start.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:22.956Z'
id: quick-start
title: 快速开始
---
+
## 快速开始
使用 TanStack Form 的最低要求是创建一个表单并添加一个字段。请注意,当前示例尚未包含任何验证或错误处理功能。
diff --git a/docs/zh-hans/installation.md b/docs/zh-hans/installation.md
index 7301a94b3..5fb4c3de7 100644
--- a/docs/zh-hans/installation.md
+++ b/docs/zh-hans/installation.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:27.039Z'
id: installation
title: 安装
---
+
## 安装
TanStack Form 兼容多种前端框架,包括 React、Vue 和 Solid。要结合您选用的框架使用 TanStack Form,请通过您偏好的包管理器安装对应的适配器:
diff --git a/docs/zh-hans/overview.md b/docs/zh-hans/overview.md
index 29ea87b22..c49c585fe 100644
--- a/docs/zh-hans/overview.md
+++ b/docs/zh-hans/overview.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:52.717Z'
id: overview
title: 概述
---
+
TanStack Form 是处理 Web 应用中表单的终极解决方案,提供了一种强大而灵活的表单管理方法。它具备一流的 TypeScript 支持、无头 UI 组件 (headless UI components) 和框架无关的设计 (framework-agnostic design),简化了表单处理流程,并确保在不同前端框架中都能获得无缝体验。
## 动机
diff --git a/docs/zh-hans/philosophy.md b/docs/zh-hans/philosophy.md
index a4f901bfb..9d4f34feb 100644
--- a/docs/zh-hans/philosophy.md
+++ b/docs/zh-hans/philosophy.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:37.807Z'
id: philosophy
title: 设计理念
---
+
每个成熟的项目都应具备指导其开发的核心哲学。缺乏核心理念的开发会陷入无休止的决策困境,最终导致 API 设计薄弱。
本文档阐述了驱动 TanStack Form 开发与功能设计的核心原则。
diff --git a/docs/zh-hans/typescript.md b/docs/zh-hans/typescript.md
index 7b6dc4d20..d21d9649b 100644
--- a/docs/zh-hans/typescript.md
+++ b/docs/zh-hans/typescript.md
@@ -4,6 +4,7 @@ translation-updated-at: '2025-04-12T04:08:19.788Z'
id: typescript
title: TypeScript
---
+
TanStack Form 完全采用 **TypeScript** 编写,具备最高质量的泛型、约束和接口设计,确保该库与您的项目实现最大程度的类型安全!
注意事项:
diff --git a/docs/zh-hant/comparison.md b/docs/zh-hant/comparison.md
new file mode 100644
index 000000000..d50d45d48
--- /dev/null
+++ b/docs/zh-hant/comparison.md
@@ -0,0 +1,60 @@
+---
+source-updated-at: '2025-03-05T09:46:22.000Z'
+translation-updated-at: '2025-04-25T20:31:55.484Z'
+id: comparison
+title: 比較
+---
+
+> ⚠️ 此比較表格正在建構中,內容尚未完全準確。如果您使用過其中任何函式庫並認為資訊可以改進,歡迎透過頁面底部的「Edit this page on Github」連結提出修改建議(需附上說明或佐證資料)。
+
+功能/能力對照說明:
+
+- ✅ 原生支援、內建功能,無需額外設定或程式碼即可使用
+- 🟡 支援,但需透過非官方的第三方或社群函式庫/貢獻
+- 🔶 支援且有文件說明,但需要使用者自行撰寫額外程式碼來實作
+- 🛑 官方不支援或無相關文件
+
+| 功能 | TanStack Form | Formik | Redux Form | React Hook Form | Final Form |
+| -------------------------------------------- | -------------------------------------------- | ------------------------------ | -------------------------------------- | ------------------------------------------------ | -------------------------------------- |
+| GitHub 儲存庫/星數 | [![][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] |
+| 支援的框架 | React, Vue, Angular, Solid, Lit | React | React | React | React, Vue, Angular, Solid, Vanilla JS |
+| 套件大小 | [![][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] |
+| 完善的 TypeScript 支援 | ✅ | ❓ | ❓ | ✅ | ✅ |
+| 完整的 TypeScript 型別推論(包含深層欄位) | ✅ | ❓ | ❓ | ✅ | 🛑 |
+| 無頭 UI 元件 (Headless UI) | ✅ | ❓ | ❓ | ✅ | ❓ |
+| 框架無關性 | ✅ | ❓ | ❓ | 🛑 | ✅ |
+| 細粒度響應式更新 | ✅ | ❓ | ❓ | ❓ | ✅ |
+| 支援巢狀物件/陣列欄位 | ✅ | ✅ | ❓ | ✅\*(1) | ✅ |
+| 非同步驗證 | ✅ | ✅ | ❓ | ✅ | ✅ |
+| 內建非同步驗證防抖動 | ✅ | ❓ | ❓ | ❓ | ❓ |
+| 基於結構描述的驗證 (Schema-based Validation) | ✅ | ✅ | ❓ | ✅ | ❓ |
+| 官方開發者工具 | 🛑\*(2) | 🛑 | ✅\*(3) | ✅ | ❓ |
+| 伺服器渲染整合 (SSR) | ✅ | 🛑 | 🛑 | 🛑 | 🛑 |
+| React 編譯器支援 | ✅ | ❓ | ❓ | 🛑 | ❓ |
+
+\*(1) 對於巢狀陣列,若使用 TypeScript,react-hook-form 要求您[需透過欄位名稱轉換欄位陣列](https://react-hook-form.com/docs/usefieldarray)
+
+\*(2) 規劃中
+
+\*(3) 透過 Redux Devtools 實現
+
+[bpl-tanstack-form]: https://bundlephobia.com/result?p=@tanstack/react-form
+[bp-tanstack-form]: https://badgen.net/bundlephobia/minzip/@tanstack/react-form?label=💾
+[gh-tanstack-form]: https://github.com/TanStack/form
+[stars-tanstack-form]: https://img.shields.io/github/stars/TanStack/form?label=%F0%9F%8C%9F
+[bpl-formik]: https://bundlephobia.com/result?p=formik
+[bp-formik]: https://badgen.net/bundlephobia/minzip/formik?label=💾
+[gh-formik]: https://github.com/jaredpalmer/formik
+[stars-formik]: https://img.shields.io/github/stars/jaredpalmer/formik?label=%F0%9F%8C%9F
+[bpl-redux-form]: https://bundlephobia.com/result?p=redux-form
+[bp-redux-form]: https://badgen.net/bundlephobia/minzip/redux-form?label=💾
+[gh-redux-form]: https://github.com/redux-form/redux-form
+[stars-redux-form]: https://img.shields.io/github/stars/redux-form/redux-form?label=%F0%9F%8C%9F
+[bpl-react-hook-form]: https://bundlephobia.com/result?p=react-hook-form
+[bp-react-hook-form]: https://badgen.net/bundlephobia/minzip/react-hook-form?label=💾
+[gh-react-hook-form]: https://github.com/react-hook-form/react-hook-form
+[stars-react-hook-form]: https://img.shields.io/github/stars/react-hook-form/react-hook-form?label=%F0%9F%8C%9F
+[bpl-final-form]: https://bundlephobia.com/result?p=final-form
+[bp-final-form]: https://badgen.net/bundlephobia/minzip/final-form?label=💾
+[gh-final-form]: https://github.com/final-form/final-form
+[stars-final-form]: https://img.shields.io/github/stars/final-form/final-form?label=%F0%9F%8C%9F
diff --git a/docs/zh-hant/config.json b/docs/zh-hant/config.json
new file mode 100644
index 000000000..550f33c16
--- /dev/null
+++ b/docs/zh-hant/config.json
@@ -0,0 +1,612 @@
+{
+ "$schema": "https://raw.githubusercontent.com/TanStack/tanstack.com/main/tanstack-docs-config.schema.json",
+ "docSearch": {
+ "appId": "",
+ "apiKey": "",
+ "indexName": "tanstack-form"
+ },
+ "sections": [
+ {
+ "label": "入門指南",
+ "children": [
+ {
+ "label": "概述",
+ "to": "overview"
+ },
+ {
+ "label": "安裝",
+ "to": "installation"
+ },
+ {
+ "label": "設計理念",
+ "to": "philosophy"
+ },
+ {
+ "label": "比較",
+ "to": "comparison"
+ },
+ {
+ "label": "TypeScript",
+ "to": "typescript"
+ }
+ ],
+ "frameworks": [
+ {
+ "label": "react",
+ "children": [
+ {
+ "label": "快速開始",
+ "to": "framework/react/quick-start"
+ }
+ ]
+ },
+ {
+ "label": "vue",
+ "children": [
+ {
+ "label": "快速開始",
+ "to": "framework/vue/quick-start"
+ }
+ ]
+ },
+ {
+ "label": "angular",
+ "children": [
+ {
+ "label": "快速開始",
+ "to": "framework/angular/quick-start"
+ }
+ ]
+ },
+ {
+ "label": "solid",
+ "children": [
+ {
+ "label": "快速開始",
+ "to": "framework/solid/quick-start"
+ }
+ ]
+ },
+ {
+ "label": "lit",
+ "children": [
+ {
+ "label": "快速開始",
+ "to": "framework/lit/quick-start"
+ }
+ ]
+ },
+ {
+ "label": "svelte",
+ "children": [
+ {
+ "label": "快速開始",
+ "to": "framework/svelte/quick-start"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "label": "指南",
+ "children": [],
+ "frameworks": [
+ {
+ "label": "react",
+ "children": [
+ {
+ "label": "基本概念",
+ "to": "framework/react/guides/basic-concepts"
+ },
+ {
+ "label": "表單驗證",
+ "to": "framework/react/guides/validation"
+ },
+ {
+ "label": "非同步初始值",
+ "to": "framework/react/guides/async-initial-values"
+ },
+ {
+ "label": "陣列",
+ "to": "framework/react/guides/arrays"
+ },
+ {
+ "label": "關聯欄位",
+ "to": "framework/react/guides/linked-fields"
+ },
+ {
+ "label": "響應式",
+ "to": "framework/react/guides/reactivity"
+ },
+ {
+ "label": "監聽器",
+ "to": "framework/react/guides/listeners"
+ },
+ {
+ "label": "自訂錯誤",
+ "to": "framework/react/guides/custom-errors"
+ },
+ {
+ "label": "提交處理",
+ "to": "framework/react/guides/submission-handling"
+ },
+ {
+ "label": "UI 函式庫",
+ "to": "framework/react/guides/ui-libraries"
+ },
+ {
+ "label": "表單組合",
+ "to": "framework/react/guides/form-composition"
+ },
+ {
+ "label": "React Native",
+ "to": "framework/react/guides/react-native"
+ },
+ {
+ "label": "伺服器渲染 (SSR)/TanStack Start/Next.js",
+ "to": "framework/react/guides/ssr"
+ },
+ {
+ "label": "除錯",
+ "to": "framework/react/guides/debugging"
+ }
+ ]
+ },
+ {
+ "label": "vue",
+ "children": [
+ {
+ "label": "基本概念",
+ "to": "framework/vue/guides/basic-concepts"
+ },
+ {
+ "label": "表單驗證",
+ "to": "framework/vue/guides/validation"
+ },
+ {
+ "label": "非同步初始值",
+ "to": "framework/vue/guides/async-initial-values"
+ },
+ {
+ "label": "陣列",
+ "to": "framework/vue/guides/arrays"
+ },
+ {
+ "label": "關聯欄位",
+ "to": "framework/vue/guides/linked-fields"
+ }
+ ]
+ },
+ {
+ "label": "angular",
+ "children": [
+ {
+ "label": "基本概念",
+ "to": "framework/angular/guides/basic-concepts"
+ },
+ {
+ "label": "表單驗證",
+ "to": "framework/angular/guides/validation"
+ },
+ {
+ "label": "陣列",
+ "to": "framework/angular/guides/arrays"
+ }
+ ]
+ },
+ {
+ "label": "solid",
+ "children": [
+ {
+ "label": "基本概念",
+ "to": "framework/solid/guides/basic-concepts"
+ },
+ {
+ "label": "表單驗證",
+ "to": "framework/solid/guides/validation"
+ },
+ {
+ "label": "非同步初始值",
+ "to": "framework/solid/guides/async-initial-values"
+ },
+ {
+ "label": "陣列",
+ "to": "framework/solid/guides/arrays"
+ },
+ {
+ "label": "關聯欄位",
+ "to": "framework/solid/guides/linked-fields"
+ }
+ ]
+ },
+ {
+ "label": "lit",
+ "children": [
+ {
+ "label": "基本概念",
+ "to": "framework/lit/guides/basic-concepts"
+ },
+ {
+ "label": "陣列",
+ "to": "framework/lit/guides/arrays"
+ }
+ ]
+ },
+ {
+ "label": "svelte",
+ "children": [
+ {
+ "label": "基本概念",
+ "to": "framework/svelte/guides/basic-concepts"
+ },
+ {
+ "label": "表單驗證",
+ "to": "framework/svelte/guides/validation"
+ },
+ {
+ "label": "非同步初始值",
+ "to": "framework/svelte/guides/async-initial-values"
+ },
+ {
+ "label": "陣列",
+ "to": "framework/svelte/guides/arrays"
+ },
+ {
+ "label": "關聯欄位",
+ "to": "framework/svelte/guides/linked-fields"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "collapsible": true,
+ "defaultCollapsed": true,
+ "label": "API 參考",
+ "children": [
+ {
+ "label": "JavaScript 參考",
+ "to": "reference/index"
+ },
+ {
+ "label": "類別 / FieldApi",
+ "to": "reference/classes/fieldapi"
+ },
+ {
+ "label": "類別 / FormApi",
+ "to": "reference/classes/formapi"
+ },
+ {
+ "label": "函式 / formOptions",
+ "to": "reference/functions/formoptions"
+ },
+ {
+ "label": "函式 / mergeForm",
+ "to": "reference/functions/mergeform"
+ },
+ {
+ "label": "介面 / FieldApiOptions",
+ "to": "reference/interfaces/fieldapioptions"
+ },
+ {
+ "label": "介面 / FieldOptions",
+ "to": "reference/interfaces/fieldoptions"
+ },
+ {
+ "label": "介面 / FieldValidators",
+ "to": "reference/interfaces/fieldvalidators"
+ },
+ {
+ "label": "介面 / FormOptions",
+ "to": "reference/interfaces/formoptions"
+ },
+ {
+ "label": "介面 / FormValidators",
+ "to": "reference/interfaces/formvalidators"
+ },
+ {
+ "label": "類型 / DeepKeys",
+ "to": "reference/type-aliases/deepkeys"
+ },
+ {
+ "label": "類型 / DeepValue",
+ "to": "reference/type-aliases/deepvalue"
+ },
+ {
+ "label": "類型 / FieldInfo",
+ "to": "reference/type-aliases/fieldinfo"
+ },
+ {
+ "label": "類型 / FieldMeta",
+ "to": "reference/type-aliases/fieldmeta"
+ },
+ {
+ "label": "類型 / FieldState",
+ "to": "reference/type-aliases/fieldstate"
+ },
+ {
+ "label": "類型 / BaseFormState",
+ "to": "reference/type-aliases/baseformstate"
+ },
+ {
+ "label": "類型 / DerivedFormState",
+ "to": "reference/type-aliases/derivedformstate"
+ },
+ {
+ "label": "類型 / Updater",
+ "to": "reference/type-aliases/updater"
+ },
+ {
+ "label": "類型 / UpdaterFn",
+ "to": "reference/type-aliases/updaterfn"
+ },
+ {
+ "label": "類型 / ValidationError",
+ "to": "reference/type-aliases/validationerror"
+ },
+ {
+ "label": "類型 / ValidationMeta",
+ "to": "reference/type-aliases/validationmeta"
+ }
+ ],
+ "frameworks": [
+ {
+ "label": "react",
+ "children": [
+ {
+ "label": "React 參考",
+ "to": "framework/react/reference/index"
+ },
+ {
+ "label": "函式 / Field",
+ "to": "framework/react/reference/functions/field"
+ },
+ {
+ "label": "函式 / useField",
+ "to": "framework/react/reference/functions/usefield"
+ },
+ {
+ "label": "函式 / useForm",
+ "to": "framework/react/reference/functions/useform"
+ },
+ {
+ "label": "函式 / useTransform",
+ "to": "framework/react/reference/functions/usetransform"
+ },
+ {
+ "label": "類型 / FieldComponent",
+ "to": "framework/react/reference/type-aliases/fieldcomponent"
+ },
+ {
+ "label": "類型 / UseField",
+ "to": "framework/react/reference/type-aliases/usefield"
+ }
+ ]
+ },
+ {
+ "label": "vue",
+ "children": [
+ {
+ "label": "Vue 參考",
+ "to": "framework/vue/reference/index"
+ },
+ {
+ "label": "函式 / Field",
+ "to": "framework/vue/reference/functions/field"
+ },
+ {
+ "label": "函式 / useField",
+ "to": "framework/vue/reference/functions/usefield"
+ },
+ {
+ "label": "函式 / useForm",
+ "to": "framework/vue/reference/functions/useform"
+ },
+ {
+ "label": "類型 / FieldComponent",
+ "to": "framework/vue/reference/type-aliases/fieldcomponent"
+ },
+ {
+ "label": "類型 / UseField",
+ "to": "framework/vue/reference/type-aliases/usefield"
+ }
+ ]
+ },
+ {
+ "label": "solid",
+ "children": [
+ {
+ "label": "Solid 參考",
+ "to": "framework/solid/reference/index"
+ },
+ {
+ "label": "函式 / createField",
+ "to": "framework/solid/reference/functions/createfield"
+ },
+ {
+ "label": "函式 / createForm",
+ "to": "framework/solid/reference/functions/createform"
+ },
+ {
+ "label": "函式 / Field",
+ "to": "framework/solid/reference/functions/field"
+ },
+ {
+ "label": "類型 / CreateField",
+ "to": "framework/solid/reference/type-aliases/createfield"
+ },
+ {
+ "label": "類型 / FieldComponent",
+ "to": "framework/solid/reference/type-aliases/fieldcomponent"
+ }
+ ]
+ },
+ {
+ "label": "lit",
+ "children": [
+ {
+ "label": "Lit 參考",
+ "to": "framework/lit/reference/index"
+ },
+ {
+ "label": "類別 / TanStackFormController",
+ "to": "framework/lit/reference/tanstackformcontroller"
+ }
+ ]
+ },
+ {
+ "label": "angular",
+ "children": [
+ {
+ "label": "Angular 參考",
+ "to": "framework/angular/reference/index"
+ },
+ {
+ "label": "類別 / TanStackField",
+ "to": "framework/angular/reference/classes/tanstackfield"
+ },
+ {
+ "label": "函式 / injectForm",
+ "to": "framework/angular/reference/functions/injectform"
+ },
+ {
+ "label": "函式 / injectStore",
+ "to": "framework/angular/reference/functions/injectstore"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "label": "社群資源",
+ "children": [],
+ "frameworks": [
+ {
+ "label": "react",
+ "children": [
+ {
+ "label": "Balastrong 教學",
+ "to": "framework/react/community/balastrong-tutorial"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "label": "範例",
+ "children": [],
+ "frameworks": [
+ {
+ "label": "react",
+ "children": [
+ {
+ "label": "簡單範例",
+ "to": "framework/react/examples/simple"
+ },
+ {
+ "label": "陣列範例",
+ "to": "framework/react/examples/array"
+ },
+ {
+ "label": "表單組合範例",
+ "to": "framework/react/examples/large-form"
+ },
+ {
+ "label": "TanStack Query 整合範例",
+ "to": "framework/react/examples/query-integration"
+ },
+ {
+ "label": "標準結構範例",
+ "to": "framework/react/examples/standard-schema"
+ },
+ {
+ "label": "TanStack Start 範例",
+ "to": "framework/react/examples/tanstack-start"
+ },
+ {
+ "label": "Next 伺服器動作範例",
+ "to": "framework/react/examples/next-server-actions"
+ },
+ {
+ "label": "Remix 範例",
+ "to": "framework/react/examples/remix"
+ },
+ {
+ "label": "UI 函式庫範例",
+ "to": "framework/react/examples/ui-libraries"
+ },
+ {
+ "label": "表單驗證器欄位錯誤範例",
+ "to": "framework/react/examples/field-errors-from-form-validators"
+ }
+ ]
+ },
+ {
+ "label": "vue",
+ "children": [
+ {
+ "label": "簡單範例",
+ "to": "framework/vue/examples/simple"
+ },
+ {
+ "label": "陣列範例",
+ "to": "framework/vue/examples/array"
+ }
+ ]
+ },
+ {
+ "label": "angular",
+ "children": [
+ {
+ "label": "簡單範例",
+ "to": "framework/angular/examples/simple"
+ },
+ {
+ "label": "陣列範例",
+ "to": "framework/angular/examples/array"
+ }
+ ]
+ },
+ {
+ "label": "solid",
+ "children": [
+ {
+ "label": "簡單範例",
+ "to": "framework/solid/examples/simple"
+ },
+ {
+ "label": "陣列範例",
+ "to": "framework/solid/examples/array"
+ }
+ ]
+ },
+ {
+ "label": "lit",
+ "children": [
+ {
+ "label": "簡單範例",
+ "to": "framework/lit/examples/simple"
+ },
+ {
+ "label": "UI 函式庫範例",
+ "to": "framework/lit/examples/ui-libraries"
+ }
+ ]
+ },
+ {
+ "label": "svelte",
+ "children": [
+ {
+ "label": "簡單範例",
+ "to": "framework/svelte/examples/simple"
+ },
+ {
+ "label": "陣列範例",
+ "to": "framework/svelte/examples/array"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/docs/zh-hant/framework/angular/guides/validation.md b/docs/zh-hant/framework/angular/guides/validation.md
new file mode 100644
index 000000000..d96bb33af
--- /dev/null
+++ b/docs/zh-hant/framework/angular/guides/validation.md
@@ -0,0 +1,543 @@
+---
+source-updated-at: '2025-04-16T14:15:06.000Z'
+translation-updated-at: '2025-04-25T20:47:24.792Z'
+id: form-validation
+title: 表單驗證
+---
+
+TanStack Form 的核心功能之一就是驗證 (validation) 概念。TanStack Form 讓驗證變得高度可自訂:
+
+- 您可以控制何時執行驗證(變更時、輸入時、失焦時、提交時...)
+- 驗證規則可以在欄位 (field) 層級或表單 (form) 層級定義
+- 驗證可以是同步或非同步的(例如 API 呼叫的結果)
+
+## 驗證何時執行?
+
+由您決定!`[tanstackField]` 指令接受一些回調函式作為 props,例如 `onChange` 或 `onBlur`。這些回調函式會接收欄位的當前值以及 fieldAPI 物件,讓您可以執行驗證。如果發現驗證錯誤,只需將錯誤訊息作為字串返回,它就會出現在 `field.api.state.meta.errors` 中。
+
+以下是一個範例:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+ @if (age.api.state.meta.errors) {
+ {{ age.api.state.meta.errors.join(', ') }}
+ }
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateFn = ({ value }) =>
+ value < 13 ? 'You must be 13 to make an account' : undefined
+
+ // ...
+}
+```
+
+在上面的範例中,驗證在每次按鍵時執行 (`onChange`)。如果我們希望驗證在欄位失焦時執行,可以這樣修改程式碼:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+
+
+ @if (age.api.state.meta.errors) {
+ {{ age.api.state.meta.errors.join(', ') }}
+ }
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateFn = ({ value }) =>
+ value < 13 ? 'You must be 13 to make an account' : undefined
+
+ // ...
+}
+```
+
+因此,您可以透過實作所需的回調函式來控制驗證的執行時機。您甚至可以在不同時間執行不同的驗證:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+
+
+ @if (age.api.state.meta.errors) {
+ {{ age.api.state.meta.errors.join(', ') }}
+ }
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateFn = ({ value }) =>
+ value < 13 ? 'You must be 13 to make an account' : undefined
+
+ minimumAgeValidator: FieldValidateFn = ({
+ value,
+ }) => (value < 0 ? 'Invalid value' : undefined)
+
+ // ...
+}
+```
+
+在上面的範例中,我們對同一個欄位在不同時間(每次按鍵和欄位失焦時)驗證不同內容。由於 `field.state.meta.errors` 是一個陣列,所有相關錯誤都會在給定時間顯示。您也可以使用 `field.state.meta.errorMap` 根據驗證執行時機(onChange、onBlur 等)取得錯誤。更多關於顯示錯誤的資訊如下。
+
+## 顯示錯誤
+
+設定好驗證後,您可以將錯誤從陣列映射到 UI 中顯示:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+ @if (age.api.state.meta.errors) {
+ {{ age.api.state.meta.errors.join(', ') }}
+ }
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateFn = ({ value }) =>
+ value < 13 ? 'You must be 13 to make an account' : undefined
+
+ // ...
+}
+```
+
+或使用 `errorMap` 屬性來存取特定錯誤:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+ @if (age.api.state.meta.errorMap['onChange']) {
+ {{ age.api.state.meta.errorMap['onChange'] }}
+ }
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateFn = ({ value }) =>
+ value < 13 ? 'You must be 13 to make an account' : undefined
+
+ // ...
+}
+```
+
+值得一提的是,我們的 `errors` 陣列和 `errorMap` 會匹配驗證器返回的類型。這意味著:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+
+ @if (!age.api.state.meta.errorMap['onChange']?.isOldEnough) {
+ The user is not old enough
+ }
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateFn = ({ value }) =>
+ value < 13 ? 'You must be 13 to make an account' : undefined
+
+ // ...
+}
+```
+
+## 欄位層級與表單層級的驗證
+
+如上所示,每個 `[tanstackField]` 透過 `onChange`、`onBlur` 等回調函式接受自己的驗證規則。也可以透過將類似的回調函式傳遞給 `injectForm()` 函式,在表單層級(而不是逐個欄位)定義驗證規則。
+
+範例:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+ @if (formErrorMap().onChange) {
+
+ There was an error on the form: {{ formErrorMap().onChange }}
+
+ }
+
+
+
+ `,
+})
+export class AppComponent {
+ form = injectForm({
+ defaultValues: {
+ age: 0,
+ },
+ onSubmit({ value }) {
+ console.log(value)
+ },
+ validators: {
+ // 以與欄位相同的方式向表單添加驗證器
+ onChange({ value }) {
+ if (value.age < 13) {
+ return 'Must be 13 or older to sign'
+ }
+ return undefined
+ },
+ },
+ })
+
+ // 訂閱表單的 errorMap,以便更新時重新渲染
+ formErrorMap = injectStore(this.form, (state) => state.errorMap)
+}
+```
+
+## 非同步函式驗證
+
+雖然我們認為大多數驗證會是同步的,但在許多情況下,透過網路呼叫或其他非同步操作進行驗證會很有用。
+
+為此,我們提供了專用的 `onChangeAsync`、`onBlurAsync` 等方法:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+ @if (age.api.state.meta.errors) {
+ {{ age.api.state.meta.errors.join(', ') }}
+ }
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateAsyncFn = async ({
+ value,
+ }) => {
+ await new Promise((resolve) => setTimeout(resolve, 1000))
+ return value < 13 ? 'You must be 13 to make an account' : undefined
+ }
+
+ // ...
+}
+```
+
+同步和非同步驗證可以共存。例如,可以在同一個欄位上定義 `onBlur` 和 `onBlurAsync`:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+ @if (age.api.state.meta.errors) {
+ {{ age.api.state.meta.errors.join(', ') }}
+ }
+
+ `,
+})
+export class AppComponent {
+ ensureAge13: FieldValidateFn = ({ value }) =>
+ value < 13 ? 'You must be at least 13' : undefined
+
+ ensureOlderAge: FieldValidateAsyncFn = async ({
+ value,
+ }) => {
+ const currentAge = await fetchCurrentAgeOnProfile()
+ return value < currentAge ? 'You can only increase the age' : undefined
+ }
+
+ // ...
+}
+```
+
+同步驗證方法 (`onBlur`) 會先執行,非同步方法 (`onBlurAsync`) 只有在同步方法 (`onBlur`) 成功時才會執行。要改變此行為,請將 `asyncAlways` 選項設為 `true`,這樣無論同步方法的結果如何,非同步方法都會執行。
+
+### 內建防抖 (Debouncing)
+
+雖然非同步呼叫是針對資料庫進行驗證的方式,但在每次按鍵時發送網路請求很容易導致資料庫遭受 DDoS 攻擊。
+
+相反地,我們提供了一個簡單的方法來防抖您的 `async` 呼叫,只需添加一個屬性:
+
+```angular-html
+
+
+
+```
+
+這將對每個非同步呼叫進行 500 毫秒的防抖處理。您甚至可以針對每個驗證屬性覆寫此設定:
+
+```angular-html
+
+
+
+```
+
+> 這將每 1500 毫秒執行一次 `onChangeAsync`,而 `onBlurAsync` 將每 500 毫秒執行一次。
+
+## 透過結構描述 (Schema) 函式庫進行驗證
+
+雖然函式提供了更多彈性和自訂驗證的方式,但它們可能有點冗長。為了解決這個問題,有一些函式庫提供了基於結構描述的驗證,使簡寫和類型嚴格的驗證變得更加容易。您還可以為整個表單定義一個結構描述並將其傳遞到表單層級,錯誤會自動傳播到欄位。
+
+### 標準結構描述函式庫
+
+TanStack Form 原生支援所有遵循 [Standard Schema 規範](https://github.com/standard-schema/standard-schema) 的函式庫,最著名的包括:
+
+- [Zod](https://zod.dev/)
+- [Valibot](https://valibot.dev/)
+- [ArkType](https://arktype.io/)
+
+_注意:_ 請確保使用結構描述函式庫的最新版本,因為舊版本可能尚未支援 Standard Schema。
+
+要使用這些函式庫的結構描述,您可以像自訂函式一樣將它們傳遞給 `validators` props:
+
+```angular-ts
+import { z } from 'zod'
+
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+ `,
+})
+export class AppComponent {
+ form = injectForm({
+ // ...
+ })
+
+ z = z
+
+ // ...
+}
+```
+
+表單和欄位層級的非同步驗證也同樣支援:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+ `,
+})
+export class AppComponent {
+ increaseAge = z.number().refine(
+ async (value) => {
+ const currentAge = await fetchCurrentAgeOnProfile()
+ return value >= currentAge
+ },
+ {
+ message: 'You can only increase the age',
+ },
+ )
+
+ // ...
+}
+```
+
+如果您需要對 Standard Schema 驗證進行更多控制,可以像這樣將 Standard Schema 與回調函式結合使用:
+
+```angular-ts
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+
+
+ `,
+})
+export class AppComponent {
+ ageValidator: FieldValidateAsyncFn = async ({
+ value,
+ fieldApi,
+ }) => {
+ const errors = fieldApi.parseValueWithSchema(
+ z.number().gte(13, 'You must be 13 to make an account'),
+ )
+ if (errors) return errors
+
+ // 繼續進行您的驗證
+ }
+
+ // ...
+}
+```
+
+## 防止提交無效表單
+
+`onChange`、`onBlur` 等回調函式也會在提交表單時執行,如果表單無效,提交會被阻止。
+
+表單狀態物件有一個 `canSubmit` 標誌,當任何欄位無效且表單已被觸碰時,該標誌為 false(即使某些欄位根據其 `onChange`/`onBlur` props「技術上」無效,`canSubmit` 在表單被觸碰之前仍
diff --git a/docs/zh-hant/framework/angular/quick-start.md b/docs/zh-hant/framework/angular/quick-start.md
new file mode 100644
index 000000000..6b7bdc372
--- /dev/null
+++ b/docs/zh-hant/framework/angular/quick-start.md
@@ -0,0 +1,63 @@
+---
+source-updated-at: '2024-07-19T07:45:40.000Z'
+translation-updated-at: '2025-04-25T20:31:42.999Z'
+id: quick-start
+title: 快速開始
+---
+
+## 快速開始
+
+使用 TanStack Form 最基本的入門步驟是建立一個表單並添加欄位。請注意,這個範例尚未包含任何驗證或錯誤處理功能...(目前僅展示基礎用法)
+
+```angular-ts
+import { Component } from '@angular/core'
+import { bootstrapApplication } from '@angular/platform-browser'
+import { TanStackField, injectForm } from '@tanstack/angular-form'
+
+@Component({
+ selector: 'app-root',
+ standalone: true,
+ imports: [TanStackField],
+ template: `
+
+ `,
+})
+export class AppComponent {
+ form = injectForm({
+ defaultValues: {
+ fullName: '',
+ },
+ onSubmit({ value }) {
+ // Do something with form data
+ console.log(value)
+ },
+ })
+
+ handleSubmit(event: SubmitEvent) {
+ event.preventDefault()
+ event.stopPropagation()
+ this.form.handleSubmit()
+ }
+}
+
+bootstrapApplication(AppComponent).catch((err) => console.error(err))
+```
+
+從這裡開始,您就可以開始探索 TanStack Form 的所有其他功能了!
diff --git a/docs/zh-hant/framework/angular/reference/classes/tanstackfield.md b/docs/zh-hant/framework/angular/reference/classes/tanstackfield.md
new file mode 100644
index 000000000..4309226a4
--- /dev/null
+++ b/docs/zh-hant/framework/angular/reference/classes/tanstackfield.md
@@ -0,0 +1,312 @@
+---
+source-updated-at: '2025-03-01T06:06:46.000Z'
+translation-updated-at: '2025-04-25T20:56:31.560Z'
+id: TanStackField
+title: 類別 / TanStackField
+---
+# 類別: TanStackField\
+
+定義於: [tanstack-field.directive.ts:31](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L31)
+
+## 型別參數
+
+• **TParentData**
+
+• **TName** *繼承自* `DeepKeys`\<`TParentData`\>
+
+• **TData** *繼承自* `DeepValue`\<`TParentData`, `TName`\>
+
+• **TOnMount** *繼承自* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
+
+• **TOnChange** *繼承自* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
+
+• **TOnChangeAsync** *繼承自* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
+
+• **TOnBlur** *繼承自* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
+
+• **TOnBlurAsync** *繼承自* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
+
+• **TOnSubmit** *繼承自* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
+
+• **TOnSubmitAsync** *繼承自* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
+
+• **TFormOnMount** *繼承自* `undefined` \| `FormValidateOrFn`\<`TParentData`\>
+
+• **TFormOnChange** *繼承自* `undefined` \| `FormValidateOrFn`\<`TParentData`\>
+
+• **TFormOnChangeAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TParentData`\>
+
+• **TFormOnBlur** *繼承自* `undefined` \| `FormValidateOrFn`\<`TParentData`\>
+
+• **TFormOnBlurAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TParentData`\>
+
+• **TFormOnSubmit** *繼承自* `undefined` \| `FormValidateOrFn`\<`TParentData`\>
+
+• **TFormOnSubmitAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TParentData`\>
+
+• **TFormOnServer** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TParentData`\>
+
+• **TSubmitMeta**
+
+## 實作
+
+- `OnInit`
+- `OnChanges`
+- `OnDestroy`
+- `FieldOptions`\<`TParentData`, `TName`, `TData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`\>
+
+## 建構函式
+
+### new TanStackField()
+
+```ts
+new TanStackField(): TanStackField
+```
+
+#### 回傳
+
+[`TanStackField`](tanstackfield.md)\<`TParentData`, `TName`, `TData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TFormOnMount`, `TFormOnChange`, `TFormOnChangeAsync`, `TFormOnBlur`, `TFormOnBlurAsync`, `TFormOnSubmit`, `TFormOnSubmitAsync`, `TFormOnServer`, `TSubmitMeta`\>
+
+## 屬性
+
+### api
+
+```ts
+api: FieldApi;
+```
+
+定義於: [tanstack-field.directive.ts:129](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L129)
+
+***
+
+### asyncAlways?
+
+```ts
+optional asyncAlways: boolean;
+```
+
+定義於: [tanstack-field.directive.ts:78](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L78)
+
+若為 `true`,即使同步驗證期間出現錯誤,仍會執行非同步驗證。
+
+#### 實作於
+
+```ts
+FieldOptions.asyncAlways
+```
+
+***
+
+### asyncDebounceMs?
+
+```ts
+optional asyncDebounceMs: number;
+```
+
+定義於: [tanstack-field.directive.ts:77](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L77)
+
+若未傳入更特定的防抖時間,則為非同步驗證的預設防抖時間。
+
+#### 實作於
+
+```ts
+FieldOptions.asyncDebounceMs
+```
+
+***
+
+### defaultMeta?
+
+```ts
+optional defaultMeta: Partial>;
+```
+
+定義於: [tanstack-field.directive.ts:106](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L106)
+
+欄位的預設中繼資料物件(可選)。
+
+#### 實作於
+
+```ts
+FieldOptions.defaultMeta
+```
+
+***
+
+### defaultValue?
+
+```ts
+optional defaultValue: NoInfer;
+```
+
+定義於: [tanstack-field.directive.ts:76](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L76)
+
+欄位的預設值(可選)。
+
+#### 實作於
+
+```ts
+FieldOptions.defaultValue
+```
+
+***
+
+### disableErrorFlat?
+
+```ts
+optional disableErrorFlat: boolean;
+```
+
+定義於: [tanstack-field.directive.ts:127](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L127)
+
+停用 `field.errors` 上的 `flat(1)` 操作。這在您希望保持錯誤結構不變時很有用。不建議大多數使用情境使用。
+
+#### 實作於
+
+```ts
+FieldOptions.disableErrorFlat
+```
+
+***
+
+### listeners?
+
+```ts
+optional listeners: NoInfer>;
+```
+
+定義於: [tanstack-field.directive.ts:105](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L105)
+
+附加到相應事件的監聽器列表
+
+#### 實作於
+
+```ts
+FieldOptions.listeners
+```
+
+***
+
+### name
+
+```ts
+name: TName;
+```
+
+定義於: [tanstack-field.directive.ts:75](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L75)
+
+欄位名稱。型別為 `DeepKeys`,以確保您的名稱是父資料集的深層鍵。
+
+#### 實作於
+
+```ts
+FieldOptions.name
+```
+
+***
+
+### tanstackField
+
+```ts
+tanstackField: FormApi;
+```
+
+定義於: [tanstack-field.directive.ts:79](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L79)
+
+***
+
+### unmount()?
+
+```ts
+optional unmount: () => void;
+```
+
+定義於: [tanstack-field.directive.ts:185](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L185)
+
+#### 回傳
+
+`void`
+
+***
+
+### validators?
+
+```ts
+optional validators: NoInfer>;
+```
+
+定義於: [tanstack-field.directive.ts:91](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L91)
+
+傳遞給欄位的驗證器列表
+
+#### 實作於
+
+```ts
+FieldOptions.validators
+```
+
+## 方法
+
+### ngOnChanges()
+
+```ts
+ngOnChanges(): void
+```
+
+定義於: [tanstack-field.directive.ts:197](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L197)
+
+一個回呼方法,在預設變更檢測器檢查資料綁定屬性(若至少有一個已變更)後立即呼叫,並在檢查視圖和內容子項之前呼叫。
+
+#### 回傳
+
+`void`
+
+#### 實作於
+
+```ts
+OnChanges.ngOnChanges
+```
+
+***
+
+### ngOnDestroy()
+
+```ts
+ngOnDestroy(): void
+```
+
+定義於: [tanstack-field.directive.ts:193](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L193)
+
+一個執行自訂清理的回呼方法,在指令、管道或服務實例被銷毀前立即呼叫。
+
+#### 回傳
+
+`void`
+
+#### 實作於
+
+```ts
+OnDestroy.ngOnDestroy
+```
+
+***
+
+### ngOnInit()
+
+```ts
+ngOnInit(): void
+```
+
+定義於: [tanstack-field.directive.ts:187](https://github.com/TanStack/form/blob/main/packages/angular-form/src/tanstack-field.directive.ts#L187)
+
+一個回呼方法,在預設變更檢測器首次檢查指令的資料綁定屬性後立即呼叫,並在檢查任何視圖或內容子項之前呼叫。僅在指令實例化時呼叫一次。
+
+#### 回傳
+
+`void`
+
+#### 實作於
+
+```ts
+OnInit.ngOnInit
+```
diff --git a/docs/zh-hant/framework/angular/reference/functions/injectform.md b/docs/zh-hant/framework/angular/reference/functions/injectform.md
new file mode 100644
index 000000000..42f1c8e99
--- /dev/null
+++ b/docs/zh-hant/framework/angular/reference/functions/injectform.md
@@ -0,0 +1,47 @@
+---
+source-updated-at: '2025-02-25T06:59:48.000Z'
+translation-updated-at: '2025-04-25T20:55:07.916Z'
+id: injectForm
+title: 函式 / injectForm
+---
+
+
+# 函式: injectForm()
+
+```ts
+function injectForm(opts?): FormApi
+```
+
+定義於: [inject-form.ts:9](https://github.com/TanStack/form/blob/main/packages/angular-form/src/inject-form.ts#L9)
+
+## 類型參數
+
+• **TFormData**
+
+• **TOnMount** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnChange** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnChangeAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TOnBlur** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnBlurAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TOnSubmit** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnSubmitAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TOnServer** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TSubmitMeta**
+
+## 參數
+
+### opts?
+
+`FormOptions`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnServer`, `TSubmitMeta`\>
+
+## 回傳值
+
+`FormApi`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnServer`, `TSubmitMeta`\>
diff --git a/docs/zh-hant/framework/angular/reference/functions/injectstore.md b/docs/zh-hant/framework/angular/reference/functions/injectstore.md
new file mode 100644
index 000000000..9684ef48a
--- /dev/null
+++ b/docs/zh-hant/framework/angular/reference/functions/injectstore.md
@@ -0,0 +1,53 @@
+---
+source-updated-at: '2025-02-25T06:59:48.000Z'
+translation-updated-at: '2025-04-25T20:55:08.950Z'
+id: injectStore
+title: 函式 / injectStore
+---
+
+
+# 函式: injectStore()
+
+```ts
+function injectStore(form, selector?): Signal
+```
+
+定義於: [inject-store.ts:9](https://github.com/TanStack/form/blob/main/packages/angular-form/src/inject-store.ts#L9)
+
+## 類型參數
+
+• **TFormData**
+
+• **TOnMount** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnChange** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnChangeAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TOnBlur** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnBlurAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TOnSubmit** *繼承自* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
+
+• **TOnSubmitAsync** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TOnServer** *繼承自* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
+
+• **TSubmitMeta**
+
+• **TSelected** = `NoInfer`\<`FormState`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnServer`\>\>
+
+## 參數
+
+### form
+
+`FormApi`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnServer`, `TSubmitMeta`\>
+
+### selector?
+
+(`state`) => `TSelected`
+
+## 回傳值
+
+`Signal`\<`TSelected`\>
diff --git a/docs/zh-hant/framework/angular/reference/index.md b/docs/zh-hant/framework/angular/reference/index.md
new file mode 100644
index 000000000..2fc65ef79
--- /dev/null
+++ b/docs/zh-hant/framework/angular/reference/index.md
@@ -0,0 +1,18 @@
+---
+source-updated-at: '2025-02-22T01:19:17.000Z'
+translation-updated-at: '2025-04-25T20:54:29.312Z'
+id: '@tanstack/angular-form'
+title: Angular 參考
+---
+
+
+# @tanstack/angular-form
+
+## 類別 (Classes)
+
+- [TanStackField](classes/tanstackfield.md)
+
+## 函式 (Functions)
+
+- [injectForm](functions/injectform.md)
+- [injectStore](functions/injectstore.md)
diff --git a/docs/zh-hant/framework/lit/guides/arrays.md b/docs/zh-hant/framework/lit/guides/arrays.md
new file mode 100644
index 000000000..2f795c38c
--- /dev/null
+++ b/docs/zh-hant/framework/lit/guides/arrays.md
@@ -0,0 +1,176 @@
+---
+source-updated-at: '2025-03-28T15:34:36.000Z'
+translation-updated-at: '2025-04-25T20:47:51.581Z'
+id: arrays
+title: 陣列
+---
+
+TanStack Form 支援將陣列 (array) 作為表單值使用,包含陣列中的子物件值。
+
+## 基本用法
+
+要使用陣列,你可以對陣列值使用 `field.state.value`,如下所示:
+
+```ts
+export class TestForm extends LitElement {
+ #form = new TanStackFormController(this, {
+ defaultValues: {
+ people: [] as Array<{ name: string; age: string }>,
+ },
+ })
+ render() {
+ return html`
+
+ `
+ }
+}
+```
+
+這會在每次對欄位執行 pushValue 時生成對應的 HTML:
+
+```html
+
+
+
+```
+
+最後,你可以像這樣使用子欄位 (subfield):
+
+```ts
+return html`
+ ${this.#form.field(
+ {
+ name: `people[${index}].name`,
+ },
+ (field) => {
+ return html`
+ {
+ const target = e.target as HTMLInputElement
+ field.handleChange(target.value)
+ }}"
+ />
+ `
+ },
+ )}
+`
+```
+
+## 完整範例
+
+```typescript
+export class TestForm extends LitElement {
+ #form = new TanStackFormController(this, {
+ defaultValues: {
+ people: [] as Array<{ name: string}>,
+ },
+ });
+ render() {
+ return html`
+
+ `;
+ }
+
+declare global {
+ interface HTMLElementTagNameMap {
+ "test-form": TestForm;
+ }
+}
+```
diff --git a/docs/zh-hant/framework/lit/guides/basic-concepts.md b/docs/zh-hant/framework/lit/guides/basic-concepts.md
new file mode 100644
index 000000000..1b220fc38
--- /dev/null
+++ b/docs/zh-hant/framework/lit/guides/basic-concepts.md
@@ -0,0 +1,104 @@
+---
+source-updated-at: '2025-03-04T11:48:41.000Z'
+translation-updated-at: '2025-04-25T20:47:50.231Z'
+id: basic-concepts
+title: 基本概念
+---
+
+本頁介紹 `@tanstack/lit-form` 函式庫中使用的基本概念與術語。熟悉這些概念將幫助您更好地理解並運用該函式庫及其與 Lit 的整合方式。
+
+## 表單選項 (Form Options)
+
+您可以使用 `formOptions` 函式建立表單選項,以便在多個表單之間共享配置。
+
+範例:
+
+```tsx
+const formOpts = formOptions({
+ defaultValues: {
+ firstName: '',
+ lastName: '',
+ employed: false,
+ jobTitle: '',
+ } as Employee,
+})
+```
+
+## 表單實例 (Form Instance)
+
+表單實例是一個代表單一表單的物件,提供操作表單的方法與屬性。您可以使用 `@tanstack/lit-form` 提供的 `TanStackFormController` 介面來建立表單實例。`TanStackFormController` 會以當前表單所屬的類別 (`this`) 與預設表單選項進行實例化,負責初始化表單狀態、處理表單提交,並提供管理表單欄位及其驗證的方法。
+
+```tsx
+#form = new TanStackFormController(this, {
+ defaultValues: {
+ firstName: '',
+ lastName: '',
+ employed: false,
+ jobTitle: '',
+ } as Employee,
+})
+```
+
+您也可以不使用 `formOptions`,直接透過獨立的 `TanStackFormController` API 建立表單實例:
+
+```tsx
+#form = new TanStackFormController(this, {
+ ...formOpts,
+})
+```
+
+## 欄位 (Field)
+
+欄位代表單一表單輸入元素,例如文字輸入框或核取方塊。欄位是透過表單實例提供的 `field(FieldOptions, callback)` 方法建立。該元件接受一個 `FieldOptions` 物件與回呼函式,回呼函式會收到一個 `FieldApi` 物件,該物件提供取得欄位當前值、處理輸入變更與處理模糊事件的方法。
+
+範例:
+
+```ts
+ ${this.#form.field(
+ {
+ name: `firstName`,
+ validators: {
+ onChange: ({ value }) =>
+ value.length < 3 ? "Not long enough" : undefined,
+ },
+ },
+ (field: FieldApi) => {
+ return html`
+
+ field.handleBlur()}"
+ .value="${field.state.value}"
+ @input="${(event: InputEvent) => {
+ if (event.currentTarget) {
+ const newValue = (event.currentTarget as HTMLInputElement).value;
+ field.handleChange(newValue);
+ }
+ }}"
+ />
+
`;
+ },
+)}
+```
+
+## 欄位狀態 (Field State)
+
+每個欄位都有自身的狀態,包含當前值、驗證狀態、錯誤訊息與其他元資料。您可以透過欄位的 `field.state` 屬性存取其狀態。
+
+```tsx
+const {
+ value,
+ meta: { errors, isValidating },
+} = field.state
+```
+
+有三種欄位狀態對於觀察使用者互動非常有用:當使用者點擊/切換至欄位時,欄位會被標記為 _"touched"_;在值被修改前保持 _"pristine"_;值變更後則標記為 _"dirty"_。您可以透過以下所示的 `isTouched`、`isPristine` 與 `isDirty` 標記來檢查這些狀態。
+
+```tsx
+const { isTouched, isPristine, isDirty } = field.state.meta
+```
+
+
diff --git a/docs/zh-hant/framework/lit/quick-start.md b/docs/zh-hant/framework/lit/quick-start.md
new file mode 100644
index 000000000..5c084e7f3
--- /dev/null
+++ b/docs/zh-hant/framework/lit/quick-start.md
@@ -0,0 +1,86 @@
+---
+source-updated-at: '2025-03-01T08:30:20.000Z'
+translation-updated-at: '2025-04-25T20:31:47.922Z'
+id: quick-start
+title: 快速開始
+---
+
+## 快速開始
+
+使用 TanStack Form 的最低要求是建立一個 `TanstackFormController`,如下所示,並使用 `Employee` 介面作為測試表單的結構:
+
+```ts
+interface Employee {
+ firstName: string
+ lastName: string
+ employed: boolean
+ jobTitle: string
+}
+
+#form = new TanStackFormController()(this, {
+ defaultValues: {
+ firstName: '',
+ lastName: '',
+ employed: false,
+ jobTitle: '',
+ },
+})
+```
+
+在此範例中,`this` 參照了您想要使用 TanStack Form 的 `LitElement` 實例。
+
+要將模板中的表單元素與 TanStack Form 連接,請使用 `TanstackFormController` 的 `field` 方法。
+
+`field` 的第一個參數是 `FieldOptions`,第二個參數是用於渲染元素的回呼函式。
+
+```ts
+field(FieldOptions, callback)
+```
+
+完成的測試表單應如下所示。該表單會從使用者輸入欄位收集名字:
+
+```ts
+export class TestForm extends LitElement {
+ #form = new TanStackFormController(this, {
+ defaultValues: {
+ firstName: '',
+ lastName: '',
+ employed: false,
+ jobTitle: '',
+ },
+ })
+ render() {
+ return html` 請輸入您的名字>
+ ${this.#form.field(
+ {
+ name: `firstName`,
+ validators: {
+ onChange: ({ value }) =>
+ value.length < 3 ? '長度不足' : undefined,
+ },
+ },
+ (field: FieldApi) => {
+ return html`
+
+ field.handleBlur()}"
+ .value="${field.getValue()}"
+ @input="${(event: InputEvent) => {
+ if (event.currentTarget) {
+ const newValue = (event.currentTarget as HTMLInputElement)
+ .value
+ field.handleChange(newValue)
+ }
+ }}"
+ />
+
`
+ },
+ )}`
+ }
+}
+```
+
+請注意,您需要自行處理元素和表單的更新,如上例所示。
diff --git a/docs/zh-hant/framework/lit/reference/index.md b/docs/zh-hant/framework/lit/reference/index.md
new file mode 100644
index 000000000..ee263777f
--- /dev/null
+++ b/docs/zh-hant/framework/lit/reference/index.md
@@ -0,0 +1,13 @@
+---
+source-updated-at: '2025-02-22T01:19:17.000Z'
+translation-updated-at: '2025-04-25T20:54:28.114Z'
+id: '@tanstack/lit-form'
+title: Lit 參考
+---
+
+
+# @tanstack/lit-form
+
+## 類別
+
+- [TanStackFormController](classes/tanstackformcontroller.md)
diff --git a/docs/zh-hant/framework/react/community/balastrong-tutorial.md b/docs/zh-hant/framework/react/community/balastrong-tutorial.md
new file mode 100644
index 000000000..961e850fe
--- /dev/null
+++ b/docs/zh-hant/framework/react/community/balastrong-tutorial.md
@@ -0,0 +1,38 @@
+---
+source-updated-at: '2025-03-15T14:42:04.000Z'
+translation-updated-at: '2025-04-25T20:55:12.761Z'
+id: balastrong-tutorial
+title: Balastrong 教學
+---
+
+TanStack Form 的維護者 [Balastrong](https://bsky.app/profile/leonardomontini.dev) 製作了一系列影片教學,展示該函式庫最核心的功能。您將找到逐步指南,深入了解如何使用 TanStack Form 建構功能,並獲得一些實用技巧與訣竅。
+
+[觀看完整播放清單](https://www.youtube.com/playlist?list=PLOQjd5dsGSxInTKUWTxyqSKwZCjDIUs0Y)
+
+## 1. [設定與驗證](https://youtu.be/Pf1qn35bgjs)
+
+學習 TanStack Form 的第一步,從函式庫設定到建立包含文字欄位與驗證(同步、防抖動與非同步)的簡單表單。[觀看影片 (8:16)](https://youtu.be/Pf1qn35bgjs)
+
+## 2. [進階驗證](https://youtu.be/Pys2ExswZT0)
+
+展示如何透過後端 API 驗證資料,同時透過控制載入狀態、錯誤訊息與關聯欄位來確保流暢的使用者體驗。[觀看影片 (8:05)](https://youtu.be/Pys2ExswZT0)
+
+## 3. [陣列欄位](https://youtu.be/0IPPHdjvrzk)
+
+如何處理包含基本型別(字串、數字)與物件(巢狀欄位)的陣列欄位,包括驗證與重新排序。[觀看影片 (6:53)](https://youtu.be/0IPPHdjvrzk)
+
+## 4. [響應式](https://youtu.be/UXRZvNCnE-s)
+
+了解表單值為何不會即時更新、這種行為的設計意圖,以及如何有效觸發 UI 更新。[觀看影片 (4:26)](https://youtu.be/UXRZvNCnE-s)
+
+## 5. [使用結構描述函式庫進行表單驗證](https://youtu.be/HSboMHfPuZA)
+
+使用 zod、yup 或 valibot 等結構描述函式庫定義驗證規則,並透過轉接器傳遞給 TanStack Form 以一次性驗證所有欄位。[觀看影片 (6:29)](https://youtu.be/HSboMHfPuZA)
+
+## 6. [副作用與監聽器](https://youtu.be/A-w2IG7DAso)
+
+類似欄位驗證器,您可以為欄位監聽器附加事件並作出反應,例如在相依欄位變更時重設特定欄位。[觀看影片 (5:50)](https://youtu.be/A-w2IG7DAso)
+
+## 7. [大型表單的可組合欄位](https://youtu.be/YJ3rW85fnKo)
+
+透過組合式 API,您可以建立可重複使用的元件,預先綁定並連接到通用表單上下文,大幅減少應用程式中所有表單實例的重複程式碼。這對於包含大量欄位的大型表單特別有用。[觀看影片 (11:01)](https://youtu.be/YJ3rW85fnKo)
diff --git a/docs/zh-hant/framework/react/guides/arrays.md b/docs/zh-hant/framework/react/guides/arrays.md
new file mode 100644
index 000000000..6739fff82
--- /dev/null
+++ b/docs/zh-hant/framework/react/guides/arrays.md
@@ -0,0 +1,126 @@
+---
+source-updated-at: '2025-03-04T11:48:41.000Z'
+translation-updated-at: '2025-04-25T20:33:38.845Z'
+id: arrays
+title: 陣列
+---
+
+TanStack Form 支援將陣列 (array) 作為表單值使用,包括陣列中的子物件值。
+
+## 基本用法
+
+要使用陣列,可以在陣列值上使用 `field.state.value`:
+
+```jsx
+function App() {
+ const form = useForm({
+ defaultValues: {
+ people: [],
+ },
+ })
+
+ return (
+
+ {(field) => (
+
+ {field.state.value.map((_, i) => {
+ // ...
+ })}
+
+ )}
+
+ )
+}
+```
+
+每次在 `field` 上執行 `pushValue` 時,都會生成對應的 JSX:
+
+```jsx
+
+```
+
+最後,可以像這樣使用子欄位 (subfield):
+
+```jsx
+
+ {(subField) => (
+ subField.handleChange(e.target.value)}
+ />
+ )}
+
+```
+
+## 完整範例
+
+```jsx
+function App() {
+ const form = useForm({
+ defaultValues: {
+ people: [],
+ },
+ onSubmit({ value }) {
+ alert(JSON.stringify(value))
+ },
+ })
+
+ return (
+
+
+ {(field) => {
+ return (
+
+ {field.state.value.map((_, i) => {
+ return (
+
+ {(subField) => {
+ return (
+
+
+
+ )
+ }}
+
+ )
+ })}
+
+
+ )
+ }}
+
+
[state.canSubmit, state.isSubmitting]}
+ children={([canSubmit, isSubmitting]) => (
+
+ )}
+ />
+
+
+ )
+}
+```
diff --git a/docs/zh-hant/framework/react/guides/async-initial-values.md b/docs/zh-hant/framework/react/guides/async-initial-values.md
new file mode 100644
index 000000000..d6f08c4d4
--- /dev/null
+++ b/docs/zh-hant/framework/react/guides/async-initial-values.md
@@ -0,0 +1,52 @@
+---
+source-updated-at: '2025-03-28T15:34:36.000Z'
+translation-updated-at: '2025-04-25T20:33:29.078Z'
+id: async-initial-values
+title: 非同步初始值
+---
+
+假設您想從 API 獲取一些資料,並將其作為表單的初始值使用。
+
+雖然這個問題表面上看起來很簡單,但背後可能隱藏著您尚未考慮到的複雜性。
+
+舉例來說,您可能希望在資料獲取期間顯示載入動畫,或是優雅地處理錯誤情況。同樣地,您也可能會尋找快取資料的方法,以避免每次渲染表單時都需要重新獲取資料。
+
+雖然我們可以從頭實作這些功能,但最終結果可能會與我們維護的另一個專案 [TanStack Query](https://tanstack.com/query) 非常相似。
+
+因此,本指南將向您展示如何結合使用 TanStack Form 與 TanStack Query 來實現所需行為。
+
+## 基本用法
+
+```tsx
+import { useForm } from '@tanstack/react-form'
+import { useQuery } from '@tanstack/react-query'
+
+export default function App() {
+ const {data, isLoading} = useQuery({
+ queryKey: ['data'],
+ queryFn: async () => {
+ await new Promise((resolve) => setTimeout(resolve, 1000))
+ return {firstName: 'FirstName', lastName: "LastName"}
+ }
+ })
+
+ const form = useForm({
+ defaultValues: {
+ firstName: data?.firstName ?? '',
+ lastName: data?.lastName ?? '',
+ },
+ onSubmit: async ({ value }) => {
+ // Do something with form data
+ console.log(value)
+ },
+ })
+
+ if (isLoading) return Loading..
+
+ return (
+ // ...
+ )
+}
+```
+
+這段程式碼會在資料獲取完成前顯示載入提示,然後使用獲取到的資料作為初始值來渲染表單。
diff --git a/docs/zh-hant/framework/react/guides/basic-concepts.md b/docs/zh-hant/framework/react/guides/basic-concepts.md
new file mode 100644
index 000000000..8e6389cce
--- /dev/null
+++ b/docs/zh-hant/framework/react/guides/basic-concepts.md
@@ -0,0 +1,362 @@
+---
+source-updated-at: '2025-04-16T08:45:06.000Z'
+translation-updated-at: '2025-04-25T20:33:31.771Z'
+id: basic-concepts
+title: 基本概念
+---
+
+本頁介紹 `@tanstack/react-form` 函式庫中使用的基本概念與術語。熟悉這些概念將幫助您更有效地理解並運用此函式庫。
+
+## 表單選項 (Form Options)
+
+您可以使用 `formOptions` 函式建立表單選項,以便在多個表單間共享設定。
+
+範例:
+
+```tsx
+interface User {
+ firstName: string
+ lastName: string
+ hobbies: Array
+}
+const defaultUser: User = { firstName: '', lastName: '', hobbies: [] }
+
+const formOpts = formOptions({
+ defaultValues: defaultUser,
+})
+```
+
+## 表單實例 (Form Instance)
+
+表單實例是一個代表單一表單的物件,提供操作表單的方法與屬性。您可透過表單選項提供的 `useForm` 鉤子來建立表單實例。此鉤子接受包含 `onSubmit` 函式的物件,該函式會在表單提交時被呼叫。
+
+```tsx
+const form = useForm({
+ ...formOpts,
+ onSubmit: async ({ value }) => {
+ // 處理表單資料
+ console.log(value)
+ },
+})
+```
+
+您也可以不使用 `formOptions`,直接透過獨立的 `useForm` API 建立表單實例:
+
+```tsx
+interface User {
+ firstName: string
+ lastName: string
+ hobbies: Array
+}
+const defaultUser: User = { firstName: '', lastName: '', hobbies: [] }
+
+const form = useForm({
+ defaultValues: defaultUser,
+ onSubmit: async ({ value }) => {
+ // 處理表單資料
+ console.log(value)
+ },
+})
+```
+
+## 欄位 (Field)
+
+欄位代表單一表單輸入元素,例如文字輸入框或核取方塊。欄位是透過表單實例提供的 `form.Field` 元件來建立。此元件接受 `name` 屬性,需與表單預設值中的鍵名匹配,以及 `children` 屬性(這是一個接收欄位物件作為參數的渲染函式)。
+
+範例:
+
+```tsx
+ (
+ <>
+ field.handleChange(e.target.value)}
+ />
+
+ >
+ )}
+/>
+```
+
+## 欄位狀態 (Field State)
+
+每個欄位都有自身的狀態,包含當前值、驗證狀態、錯誤訊息及其他元資料。您可透過 `field.state` 屬性存取欄位狀態。
+
+範例:
+
+```tsx
+const {
+ value,
+ meta: { errors, isValidating },
+} = field.state
+```
+
+有三種欄位狀態有助於觀察使用者互動:當使用者點擊/切換至欄位時為「已觸碰 _(touched)_」、使用者未改變值前為「原始狀態 _(pristine)_」、值變更後則為「已修改 _(dirty)_」。可透過以下標誌檢查這些狀態:
+
+```tsx
+const { isTouched, isPristine, isDirty } = field.state.meta
+```
+
+
+
+> **給從 `React Hook Form` 轉換的使用者重要提示**:`TanStack/form` 中的 `isDirty` 標誌與 RHF 中同名的標誌意義不同。
+> 在 RHF 中,當表單值與原始值不同時 `isDirty = true`。若使用者修改表單值後又改回與預設值相同,RHF 的 `isDirty` 會是 `false`,但在 `TanStack/form` 中會是 `true`。
+> `TanStack/form` 同時在表單與欄位層級暴露預設值 (`form.options.defaultValues`, `field.options.defaultValue`),因此若需模擬 RHF 的行為,您可以自行編寫 `isDefaultValue()` 輔助函式。
+
+## 欄位 API (Field API)
+
+欄位 API 是建立欄位時傳遞給渲染函式的物件,提供操作欄位狀態的方法。
+
+範例:
+
+```tsx
+ field.handleChange(e.target.value)}
+/>
+```
+
+## 驗證 (Validation)
+
+`@tanstack/react-form` 原生支援同步與非同步驗證。驗證函式可透過 `validators` 屬性傳遞給 `form.Field` 元件。
+
+範例:
+
+```tsx
+
+ !value
+ ? '必須填寫名字'
+ : value.length < 3
+ ? '名字至少需 3 個字元'
+ : undefined,
+ onChangeAsync: async ({ value }) => {
+ await new Promise((resolve) => setTimeout(resolve, 1000))
+ return value.includes('error') && '名字中不得包含 "error"'
+ },
+ }}
+ children={(field) => (
+ <>
+ field.handleChange(e.target.value)}
+ />
+
+ >
+ )}
+/>
+```
+
+## 使用標準結構描述函式庫驗證 (Validation with Standard Schema Libraries)
+
+除了手動驗證選項外,我們也支援 [Standard Schema](https://github.com/standard-schema/standard-schema) 規範。
+
+您可以使用任何實作此規範的函式庫定義結構描述,並將其傳遞給表單或欄位驗證器。
+
+支援的函式庫包括:
+
+- [Zod](https://zod.dev/)
+- [Valibot](https://valibot.dev/)
+- [ArkType](https://arktype.io/)
+
+```tsx
+import { z } from 'zod'
+
+const userSchema = z.object({
+ age: z.number().gte(13, '必須年滿 13 歲才能建立帳戶'),
+})
+
+function App() {
+ const form = useForm({
+ defaultValues: {
+ age: 0,
+ },
+ validators: {
+ onChange: userSchema,
+ },
+ })
+ return (
+
+
{
+ return <>{/* ... */}>
+ }}
+ />
+
+ )
+}
+```
+
+## 響應式 (Reactivity)
+
+`@tanstack/react-form` 提供多種訂閱表單與欄位狀態變更的方式,最顯著的是 `useStore(form.store)` 鉤子與 `form.Subscribe` 元件。這些方法讓您能透過僅在必要時更新元件來優化表單渲染效能。
+
+範例:
+
+```tsx
+const firstName = useStore(form.store, (state) => state.values.firstName)
+//...
+ [state.canSubmit, state.isSubmitting]}
+ children={([canSubmit, isSubmitting]) => (
+
+ )}
+/>
+```
+
+需特別注意,雖然 `useStore` 鉤子的 `selector` 屬性是可選的,但強烈建議提供此參數,因為省略它會導致不必要的重新渲染。
+
+```tsx
+// 正確用法
+const firstName = useStore(form.store, (state) => state.values.firstName)
+const errors = useStore(form.store, (state) => state.errorMap)
+// 錯誤用法
+const store = useStore(form.store)
+```
+
+注意:不建議使用 `useField` 鉤子來實現響應式,因為它設計上是供 `form.Field` 元件內部謹慎使用的。您應考慮改用 `useStore(form.store)`。
+
+## 監聽器 (Listeners)
+
+`@tanstack/react-form` 允許您對特定觸發事件作出反應並「監聽」它們以執行副作用。
+
+範例:
+
+```tsx
+ {
+ console.log(`國家已變更為: ${value}, 重置省份選項`)
+ form.setFieldValue('province', '')
+ },
+ }}
+/>
+```
+
+更多資訊請參閱 [監聽器](./listeners.md)
+
+## 陣列欄位 (Array Fields)
+
+陣列欄位讓您能管理表單中的值列表,例如興趣愛好清單。您可透過 `form.Field` 元件加上 `mode="array"` 屬性來建立陣列欄位。
+
+操作陣列欄位時,可使用欄位的 `pushValue`、`removeValue`、`swapValues` 和 `moveValue` 方法來新增、移除與交換陣列中的值。
+
+範例:
+
+```tsx
+ (
+
+ 興趣愛好
+
+ {!hobbiesField.state.value.length
+ ? '尚未新增任何興趣愛好。'
+ : hobbiesField.state.value.map((_, i) => (
+
+ ))}
+
+
+
+ )}
+/>
+```
+
+## 重設按鈕 (Reset Buttons)
+
+當結合使用 `