# Form

> 统一管理表单草稿、校验、异步保存与重置，用字段配置快速搭建参数表单。

网页来源：/components/form

版本：@quirekit/ui 0.3.1；源码修订：d79a6b48d00e+worktree。此文档对应当前源码构建，接入方式以开始使用为准。

接入前置：[开始使用](/raw/components/getting-started.md)（Vue、样式、主题与图标 Provider）。

管理表单草稿、字段校验、提交与重置。手写字段用 `QuireForm` 与 `QuireFormField`，配置化表单用 `QuireSchemaForm`。

## 基础用法

`initialValues` 提供初值，FormField 用 `name` 注册字段。将插槽的 `controlProps` 完整绑定到控件；文本模型通过 `String(value ?? '')` 收窄类型。保存函数由 `:on-submit` 传入。

### 示例：form/simple

文件：`simple.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { QuireButton, QuireForm, QuireFormField, QuireInput } from "@quirekit/ui/vue";
import type { QuireKitFormValues } from "@quirekit/ui/vue";

const initialValues = { name: "项目周报" };
const saved = ref("");

/** 保存通过校验的文档名称。
 * @param values - 表单提交快照。
 */
function save(values: QuireKitFormValues): void {
  saved.value = String(values.name);
}
</script>

<template>
  <div class="mx-auto grid w-full min-w-0 max-w-md gap-4 p-qk-surface">
    <QuireForm :initial-values="initialValues" :on-submit="save" aria-label="保存文档名称">
      <QuireFormField v-slot="{ controlProps, value }" name="name" label="名称" required required-message="请输入名称。">
        <QuireInput v-bind="controlProps" :model-value="String(value ?? '')" width="100%" />
      </QuireFormField>
      <template #actions>
        <QuireButton type="submit" color="primary" variant="solid">保存名称</QuireButton>
      </template>
    </QuireForm>
    <p class="m-0 break-words text-qk-helper text-qk-text-secondary" role="status">{{ saved ? `已保存：${saved}` : "修改名称后保存。" }}</p>
  </div>
</template>
```

## 校验与异步提交

`required` 检查非空，`rules` 返回 `true` 或错误文本。默认失焦校验，已显示错误的字段会在修改后重验；`validateOn` 可选 `blur`、`change`、`submit`。

Form 等待 `onSubmit` 返回的 Promise，并在校验和保存期间锁定草稿。`isSubmitting` 可用于禁用操作；失败提交默认聚焦首个可操作的错误字段。

### 示例：form/basic

文件：`basic.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { QuireButton, QuireForm, QuireFormField, QuireInput, QuireTextarea } from "@quirekit/ui/vue";
import type { QuireKitFormRule, QuireKitFormValues } from "@quirekit/ui/vue";

const initialValues: QuireKitFormValues = { title: "季度设计回顾", description: "记录本季度的设计决策与下一步计划。" };
const saved = ref("");

/** 检查标题长度，空值由 required 处理。
 * @param value - 表单持有的标题草稿。
 * @returns 校验结果或可操作的反馈。
 */
const titleRule: QuireKitFormRule = (value) => String(value ?? "").trim().length >= 4 || "标题至少需要 4 个字符。";

/** 模拟保存快照；初始值仍是显式重置基线。
 * @param values - 通过校验的表单快照。
 * @returns 本地保存完成信号。
 */
async function save(values: QuireKitFormValues): Promise<void> {
  await new Promise((resolve) => setTimeout(resolve, 650));
  saved.value = String(values.title).trim();
}
</script>

<template>
  <div class="mx-auto w-full min-w-0 max-w-md p-qk-surface">
    <QuireForm :initial-values="initialValues" :on-submit="save" aria-label="文档信息">
      <template #default="{ meta }">
        <header>
          <h3 class="m-0 text-qk-body font-semibold">文档信息</h3>
          <p class="mb-0 mt-1 text-qk-helper text-qk-text-secondary">让协作者快速了解这份文档。</p>
        </header>
        <QuireFormField v-slot="{ controlProps, value }" name="title" label="文档标题"
          required required-message="请输入文档标题。" description="至少 4 个字符。" :rules="titleRule">
          <QuireInput v-bind="controlProps" :model-value="String(value ?? '')" width="100%" />
        </QuireFormField>
        <QuireFormField v-slot="{ controlProps, value }" name="description" label="简介" description="可选，简要说明文档内容。">
          <QuireTextarea v-bind="controlProps" :model-value="String(value ?? '')" width="100%" :rows="3" />
        </QuireFormField>
        <p class="m-0 text-qk-helper text-qk-text-tertiary">{{ meta.dirty ? "已修改初始内容" : "当前为初始内容" }}</p>
      </template>
      <template #actions="{ isSubmitting, resetForm }">
        <QuireButton type="submit" color="primary" variant="solid" :disabled="isSubmitting">{{ isSubmitting ? "正在保存…" : "保存文档" }}</QuireButton>
        <QuireButton type="button" variant="outline" :disabled="isSubmitting" @click="resetForm()">恢复初始值</QuireButton>
      </template>
    </QuireForm>
    <p class="mb-0 mt-4 break-words text-qk-helper text-qk-text-secondary" role="status">{{ saved ? `最近保存：${saved}` : "尚未保存" }}</p>
  </div>
</template>
```

`success`、`invalidSubmit`、`error`、`reset` 用于监听结果；异步保存请使用 `:on-submit`，不要用 `@submit` 代替。`requiredMessage` 定义空值提示；布尔字段必填时必须为 `true`。

## 加载记录与重置

`initialValues` 只捕获一次。加载另一条记录时调用 `resetForm({ values: record })`，同时替换草稿和重置基线。`resetForm()` 或 `type="reset"` 恢复当前基线，并清除错误、交互状态和提交次数。

### 示例：form/records

文件：`records.vue`

```vue
<script setup lang="ts">
import { QuireButton, QuireForm, QuireFormField, QuireInput } from "@quirekit/ui/vue";

const firstRecord = { title: "产品路线图" };
const secondRecord = { title: "用户研究计划" };
</script>

<template>
  <div class="mx-auto w-full min-w-0 max-w-md p-qk-surface">
    <QuireForm :initial-values="firstRecord" aria-label="切换编辑记录">
      <template #default="{ meta, resetForm }">
        <div class="flex flex-wrap gap-2" role="group" aria-label="加载记录">
          <QuireButton variant="outline" @click="resetForm({ values: firstRecord })">加载路线图</QuireButton>
          <QuireButton variant="outline" @click="resetForm({ values: secondRecord })">加载研究计划</QuireButton>
        </div>
        <QuireFormField v-slot="{ controlProps, value }" name="title" label="记录标题" required required-message="请输入记录标题。">
          <QuireInput v-bind="controlProps" :model-value="String(value ?? '')" width="100%" />
        </QuireFormField>
        <p class="m-0 text-qk-helper text-qk-text-secondary" role="status">{{ meta.dirty ? "有未保存的修改" : "与当前记录一致" }}</p>
      </template>
      <template #actions>
        <QuireButton type="reset" variant="outline">撤销当前修改</QuireButton>
      </template>
    </QuireForm>
  </div>
</template>
```

提交期间 `resetForm`、`setFieldValue`、`setValues` 返回 `false`。需要回填保存结果时，等待提交结束后再调用；普通字段编辑使用插槽绑定即可。

## 配置化表单与条件字段

`fields` 接收字段和分组树：字段声明 `name`、`label`、`control`；分组声明 `key`、`legend`、`children`。内置控件有 `input`、`textarea`、`number`、`select`、`checkbox`、`switch`。

`visible`、`disabled`、`readOnly` 可读取当前 `values`。关闭下方“邮件通知”会隐藏邮箱并停止该字段的校验，再次开启时恢复草稿。

### 示例：form/parameters

文件：`parameters.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { QuireButton, QuireSchemaForm } from "@quirekit/ui/vue";
import type { QuireKitFormRule, QuireKitFormValues, QuireKitSchemaNode } from "@quirekit/ui/vue";

const saved = ref("");
// 数字输入保留字符串草稿，只有经过校验后才转换为业务数值。
const initialValues: QuireKitFormValues = { name: "每周项目摘要", audience: "team", limit: "12", notify: true, email: "design@example.com" };

/** 校验摘要条数，避免将空字符串当成零。
 * @param value - 数字控件的字符串草稿。
 * @returns 是否为范围内整数，或错误反馈。
 */
const limitRule: QuireKitFormRule = (value) => {
  const number = Number(value);
  return (String(value ?? "").trim() !== "" && Number.isInteger(number) && number >= 1 && number <= 30) || "请输入 1–30 之间的整数。";
};

/** 检查收件地址的基本格式。
 * @param value - 地址草稿。
 * @returns 格式检查结果。
 */
const emailRule: QuireKitFormRule = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(value ?? "")) || "请输入完整的邮箱地址。";

// 分组、控件选项与条件都集中在可信配置中，模板只保留表单和动作。
const fields: readonly QuireKitSchemaNode[] = [
  { key: "content", legend: "摘要内容", children: [
    { name: "name", label: "任务名称", control: "input", required: true, requiredMessage: "请输入任务名称。" },
    { name: "audience", label: "阅读范围", control: "select", props: { items: [
      { value: "team", label: "项目成员" }, { value: "private", label: "仅自己" }
    ] } },
    { name: "limit", label: "最多条数", control: "number", rules: limitRule, props: { min: 1, max: 30, step: 1 }, description: "每次摘要保留 1–30 条进展。" }
  ] },
  { key: "notification", legend: "完成通知", children: [
    { name: "notify", label: "邮件通知", control: "switch", description: "摘要生成后发送一封邮件。" },
    { name: "email", label: "收件邮箱", control: "input", required: true, requiredMessage: "请输入收件邮箱。",
      rules: emailRule, visible: (values) => values.notify === true, props: { type: "email" } }
  ] }
];

/** 将已校验的草稿投影为业务结果，按通知开关决定是否使用保留地址。
 * @param values - 表单提交快照，可能包含隐藏字段的保留值。
 * @returns 本地保存完成信号。
 */
async function save(values: QuireKitFormValues): Promise<void> {
  await new Promise((resolve) => setTimeout(resolve, 550));
  const limit = Number(values.limit);
  saved.value = `${String(values.name)} · 最多 ${limit} 条 · ${values.notify ? `通知 ${String(values.email)}` : "不发送邮件"}`;
}
</script>

<template>
  <div class="mx-auto w-full min-w-0 max-w-md p-qk-surface">
    <QuireSchemaForm :fields="fields" :initial-values="initialValues" :on-submit="save" aria-label="摘要参数">
      <template #actions="{ isSubmitting, resetForm }">
        <QuireButton type="submit" color="primary" variant="solid" :disabled="isSubmitting">{{ isSubmitting ? "正在保存…" : "保存参数" }}</QuireButton>
        <QuireButton type="button" variant="outline" :disabled="isSubmitting" @click="resetForm()">恢复初始值</QuireButton>
      </template>
    </QuireSchemaForm>
    <p class="mb-0 mt-4 break-words text-qk-helper text-qk-text-secondary" role="status">{{ saved || "设置摘要内容与通知方式。" }}</p>
  </div>
</template>
```

`number` 模型保持字符串，以容纳清空和编辑中的输入；验证后再转换为业务数值。本地化数字需按所选格式解析。隐藏字段默认保留值，`keepValueOnUnmount: false` 可在卸载时清除；禁用字段跳过字段校验，只读字段继续校验。

## 跨字段校验与失败恢复

`rules` 支持 Promise，`dependsOn` 声明跨字段依赖。服务端字段错误用 `setErrors` 或 `setFieldError` 回填；请求失败抛出 `Error`，Form 保留草稿并显示 `submitError`。

下例保留 `design` 提交会提示名称占用；改为 `design-team` 后首次保存模拟请求失败，再点“重试保存”即可成功。`admin` 则展示异步保留名称校验。

### 示例：form/recovery

文件：`recovery.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { QuireButton, QuireSchemaForm } from "@quirekit/ui/vue";
import type { QuireKitFormContext, QuireKitFormRule, QuireKitFormValues, QuireKitSchemaNode } from "@quirekit/ui/vue";

const saved = ref("");
let unavailableOnce = true;
const initialValues: QuireKitFormValues = { code: "design", minimum: "2", maximum: "8" };

/** 模拟异步检查保留名称，不访问网络。
 * @param value - 空间标识草稿。
 * @returns 名称检查结果。
 */
const codeRule: QuireKitFormRule = async (value) => {
  await new Promise((resolve) => setTimeout(resolve, 350));
  const code = String(value ?? "");
  if (!/^[a-z][a-z0-9-]{2,19}$/.test(code)) return "使用 3–20 位小写字母、数字或连字符，以字母开头。";
  return code !== "admin" || "该名称已保留，请换一个。";
};

/** 校验成员数量。
 * @param value - 数量草稿。
 * @returns 范围内整数或反馈。
 */
const countRule: QuireKitFormRule = (value) => {
  const count = Number(value);
  return (Number.isInteger(count) && count >= 1 && count <= 30) || "请输入 1–30 之间的整数。";
};

/** 使用同一表单快照检查人数上下限。
 * @param value - 最多人数。
 * @param context - 校验时的完整表单上下文。
 * @returns 跨字段检查结果。
 */
const maximumRule: QuireKitFormRule = (value, context) => Number(value) >= Number(context.form.minimum) || "最多人数不能少于最少人数。";

const fields: readonly QuireKitSchemaNode[] = [
  { name: "code", label: "空间标识", control: "input", required: true, requiredMessage: "请输入空间标识。", rules: codeRule, description: "3–20 位小写字母、数字或连字符。" },
  { key: "members", legend: "成员规模", orientation: "horizontal", children: [
    { name: "minimum", label: "最少人数", control: "number", rules: countRule, props: { min: 1, max: 30 } },
    { name: "maximum", label: "最多人数", control: "number", rules: [countRule, maximumRule], dependsOn: ["minimum"], props: { min: 1, max: 30 } }
  ] }
];

/** 模拟字段冲突和一次保存失败，所有失败都保留草稿以便修正或重试。
 * @param values - 已通过字段校验的提交快照。
 * @param form - 用于回填服务端字段错误的表单上下文。
 * @returns 本地保存完成信号。
 */
async function save(values: QuireKitFormValues, form: QuireKitFormContext): Promise<void> {
  await new Promise((resolve) => setTimeout(resolve, 650));
  if (values.code === "design") {
    form.setErrors({ code: "这个空间标识已被占用，请换一个。" });
    return;
  }
  if (unavailableOnce) {
    unavailableOnce = false;
    throw new Error("暂时无法保存，请重试。你的输入已保留。");
  }
  saved.value = `${String(values.code)} · ${Number(values.minimum)}–${Number(values.maximum)} 人`;
}
</script>

<template>
  <div class="mx-auto w-full min-w-0 max-w-md p-qk-surface">
    <QuireSchemaForm :fields="fields" :initial-values="initialValues" :on-submit="save" aria-label="创建协作空间">
      <template #error="{ submitError }"><span>{{ submitError }}</span></template>
      <template #actions="{ isSubmitting, submitError, resetForm }">
        <QuireButton type="submit" color="primary" variant="solid" :disabled="isSubmitting">{{ isSubmitting ? "正在检查并保存…" : submitError ? "重试保存" : "创建空间" }}</QuireButton>
        <QuireButton type="button" variant="outline" :disabled="isSubmitting" @click="resetForm()">恢复初始值</QuireButton>
      </template>
    </QuireSchemaForm>
    <p class="mb-0 mt-4 break-words text-qk-helper text-qk-text-secondary" role="status">{{ saved ? `已创建：${saved}` : "为空间选择一个好记的名称。" }}</p>
  </div>
</template>
```

## 自定义控件与字段插槽

`registry` 注册已有控件，默认使用 `modelValue` / `update:modelValue`；其他模型通过 `modelProp`、`updateEvent` 和可选的值转换接入。

`field:路径` 插槽优先于注册控件。下例注册 Segmented，并通过动态插槽定制嵌套的 `delivery.subject` 字段；仍须保留 `controlProps` 的更新、状态和反馈关联。

### 示例：form/custom

文件：`custom.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { QuireButton, QuireInput, QuireSchemaForm, QuireSegmented } from "@quirekit/ui/vue";
import type { QuireKitFormRule, QuireKitFormValues, QuireKitSchemaNode, QuireKitSchemaRegistry } from "@quirekit/ui/vue";

const saved = ref("");
const initialValues: QuireKitFormValues = { cadence: "weekly", delivery: { subject: "项目进展" } };
const subjectSlot = "field:delivery.subject" as const;

/** 将可选草稿转换为自定义控件的受控字符串。
 * @param value - 表单中存储的值。
 * @returns 控件使用的字符串。
 */
function textValue(value: unknown): string { return String(value ?? ""); }

/** 校验邮件主题长度。
 * @param value - 主题草稿。
 * @returns 长度校验结果。
 */
const subjectRule: QuireKitFormRule = (value) => textValue(value).trim().length >= 2 || "主题至少需要 2 个字符。";

// 显式注册已有控件；字段模型与可访问绑定仍由 SchemaForm 提供。
const registry: QuireKitSchemaRegistry = { cadence: { component: QuireSegmented, toControl: textValue } };
const fields: readonly QuireKitSchemaNode[] = [
  { name: "cadence", label: "发送频率", control: "cadence", props: { equal: true, items: [
    { value: "daily", label: "每天" }, { value: "weekly", label: "每周" }, { value: "monthly", label: "每月" }
  ] } },
  { name: "delivery.subject", label: "邮件主题", control: "input", required: true, requiredMessage: "请输入邮件主题。", rules: subjectRule, description: "前缀会自动加到发送的邮件中。" }
];

/** 从未知记录中读取嵌套字段，在消费边界完成收窄。
 * @param values - 表单提交快照。
 * @returns 本地保存完成信号。
 */
async function save(values: QuireKitFormValues): Promise<void> {
  await new Promise((resolve) => setTimeout(resolve, 450));
  const delivery = values.delivery;
  const subject = delivery !== null && typeof delivery === "object" && "subject" in delivery ? textValue(delivery.subject) : "";
  const cadence = values.cadence === "daily" ? "每天" : values.cadence === "monthly" ? "每月" : "每周";
  saved.value = `${cadence}发送 · [团队简报] ${subject}`;
}
</script>

<template>
  <div class="mx-auto w-full min-w-0 max-w-md p-qk-surface">
    <QuireSchemaForm :fields="fields" :registry="registry" :initial-values="initialValues" :on-submit="save" aria-label="简报发送设置">
      <template #[subjectSlot]="{ controlProps, value }">
        <QuireInput v-bind="controlProps" :model-value="textValue(value)" width="100%">
          <template #leading><span class="text-qk-text-tertiary">[团队简报]</span></template>
        </QuireInput>
      </template>
      <template #actions="{ isSubmitting, resetForm }">
        <QuireButton type="submit" color="primary" variant="solid" :disabled="isSubmitting">{{ isSubmitting ? "正在保存…" : "保存发送设置" }}</QuireButton>
        <QuireButton type="button" variant="outline" :disabled="isSubmitting" @click="resetForm()">恢复初始值</QuireButton>
      </template>
    </QuireSchemaForm>
    <p class="mb-0 mt-4 break-words text-qk-helper text-qk-text-secondary" role="status">{{ saved || "按团队节奏发送项目简报。" }}</p>
  </div>
</template>
```

使用其他模型时，可组合 `value`、`setValue`、`handleBlur`，无需再维护一份草稿。注册控件应支持禁用、只读、焦点和反馈关联。

## 后代组件访问表单

抽出的字段或操作组件可在 `setup` 中调用 `useQuireForm()`，复用祖先的表单状态。它必须实际位于 Form 后代中；不能在创建 Form 的同一个组件中提前调用。

```vue
<script setup lang="ts">
import { QuireButton, useQuireForm } from '@quirekit/ui/vue'

// 将此操作组件放入 Form 的 actions 插槽。
const form = useQuireForm()
const { isSubmitting } = form
</script>

<template>
  <QuireButton :disabled="isSubmitting" @click="form.resetForm()">
    恢复初始值
  </QuireButton>
</template>
```

组合函数返回的状态是 ref，脚本中读取 `.value`；Form 的作用域插槽已经解包这些状态。

## 数据与原生表单

Form 的提交快照可能包含隐藏、禁用字段的保留值，由保存函数筛选业务数据；它不等同于原生 `FormData`。仅需要原生字段关联和浏览器约束校验时，使用 [Field](/raw/components/field.md#原生表单)。

Form 自身渲染原生 `form`，不能嵌套；分组使用 [Fieldset](/raw/components/fieldset.md) 或 SchemaForm 的分组节点。`fields` 是可信 TypeScript 配置，远程数据应先映射到应用允许的控件与规则。

## API

### QuireForm

### QuireForm

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| initialValues | 否 | — | Initial/reset baseline, captured once; load another record with resetForm. |
| onSubmit | 否 | — | Awaited application save handler. |
| disabled | 否 | — | Disable editing and submission. |
| readOnly | 否 | — | Preserve focus/selection while disallowing field edits. |
| validateOn | 否 | — | Default field validation timing. |
| focusOnError | 否 | true | Focus the first mounted actionable error after failed submission. |

**initialValues**

```ts
QuireKitFormValues | undefined
```

```ts
undefined | QuireKitFormValues
```

**onSubmit**

```ts
QuireKitFormSubmitHandler | undefined
```

```ts
undefined | { (values: QuireKitFormValues, form: QuireKitFormContext): unknown; }
```

**disabled**

```ts
boolean | undefined
```

**readOnly**

```ts
boolean | undefined
```

**validateOn**

```ts
QuireKitFormValidateOn | undefined
```

```ts
undefined | "submit" | "blur" | "change"
```

**focusOnError**

```ts
boolean | undefined
```

#### Events

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| success | 否 | — |  |
| error | 否 | — |  |
| invalidSubmit | 否 | — |  |
| reset | 否 | — |  |

**success**

```ts
[values: QuireKitFormValues]
```

**error**

```ts
[error: unknown]
```

**invalidSubmit**

```ts
[errors: Record<string, string | undefined>]
```

**reset**

```ts
[]
```

#### Slots

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| default | 否 | — | Fields and custom content with unwrapped form state. |
| actions | 否 | — | Optional save/reset actions sharing the same native form. |
| error | 否 | — | Replaces the request failure text inside the alert. |

**default**

```ts
{ readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; }
```

**actions**

```ts
{ readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; }
```

**error**

```ts
{ readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; }
```

#### 公开实例成员

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| values | 否 | — | Read-only live values; use the setter methods to edit them. |
| errors | 否 | — | First error for each registered or server-reported path. |
| meta | 否 | — | Aggregated dirty, touched, validity and pending state. |
| isSubmitting | 否 | — | Lock spanning validation and application save. |
| isValidating | 否 | — | Whole-form validation activity. |
| submitCount | 否 | — | Number of accepted submit attempts since reset. |
| submitError | 否 | — | Recoverable request/validator failure message. |
| setFieldValue | 否 | — | Set a nested value using VeeValidate's path semantics. |
| setValues | 否 | — | Merge a set of values into the draft. |
| setErrors | 否 | — | Attach server errors without erasing the draft. |
| setFieldError | 否 | — | Set or clear a single field error. |
| setFieldTouched | 否 | — | Set interaction state for one path. |
| validate | 否 | — | Validate the complete form. |
| validateField | 否 | — | Validate one path. |
| submit | 否 | — | Validate and await save; repeat calls during the lock are ignored. |
| resetForm | 否 | — | Reset baseline and metadata; returns false while submitting. |
| focusFirstError | 否 | — | Focus the first available field error in DOM order. |
| reportError | 否 | — | Surface an unexpected asynchronous failure and emit error. |

**values**

```ts
QuireKitFormValues
```

**errors**

```ts
Partial<Record<string, string | undefined>>
```

**meta**

```ts
FormMeta<QuireKitFormValues>
```

**isSubmitting**

```ts
boolean
```

**isValidating**

```ts
boolean
```

**submitCount**

```ts
number
```

**submitError**

```ts
string | undefined
```

```ts
undefined | string
```

**setFieldValue**

```ts
(path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean
```

```ts
{ (path: string, value: unknown, shouldValidate?: boolean | undefined): boolean; }
```

**setValues**

```ts
(values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean
```

```ts
{ (values: QuireKitFormValues, shouldValidate?: boolean | undefined): boolean; }
```

**setErrors**

```ts
(fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void
```

```ts
{ (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>): void; }
```

**setFieldError**

```ts
(field: string, message: string | string[] | undefined) => void
```

```ts
{ (field: string, message: string | string[] | undefined): void; }
```

**setFieldTouched**

```ts
(field: string, isTouched: boolean) => void
```

```ts
{ (field: string, isTouched: boolean): void; }
```

**validate**

```ts
() => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>
```

```ts
{ (): Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; }
```

**validateField**

```ts
<TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>
```

```ts
{ <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions$1> | undefined): Promise<ValidationResult<unknown>>; }
```

**submit**

```ts
(event?: Event | undefined) => Promise<void>
```

```ts
{ (event?: Event | undefined): Promise<void>; }
```

**resetForm**

```ts
(state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean
```

```ts
{ (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined): boolean; }
```

**focusFirstError**

```ts
() => Promise<void>
```

```ts
{ (): Promise<void>; }
```

**reportError**

```ts
(error: unknown) => void
```

```ts
{ (error: unknown): void; }
```

### QuireFormField

### QuireFormField

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| name | 是 | — | VeeValidate path, including nested objects and array indices. |
| label | 是 | — | Visible, accessible field label. |
| id | 否 | — | Optional stable field id. |
| description | 否 | — | Help text displayed without errors. |
| disabledReason | 否 | — | Reason an explicitly disabled field cannot be edited. |
| width | 否 | — | Width of the field; defaults to its container width. |
| required | 否 | — | Enforce a nonempty value, including true for required booleans. |
| requiredMessage | 否 | — | Field-specific required feedback; defaults to the language pack's message naming the label. |
| rules | 否 | — | Function rules evaluated sequentially, stopping on the first error. |
| dependsOn | 否 | — | Explicit dependencies revalidated after interaction. |
| validateOn | 否 | — | Override form-level validation timing. |
| disabled | 否 | — | Skip field-level validation and editing. |
| readOnly | 否 | — | Prevent editing while continuing to validate. |
| keepValueOnUnmount | 否 | true | Preserve draft on unmount; true by default. |

**name**

```ts
string
```

**label**

```ts
string
```

**id**

```ts
string | undefined
```

```ts
undefined | string
```

**description**

```ts
string | undefined
```

```ts
undefined | string
```

**disabledReason**

```ts
string | undefined
```

```ts
undefined | string
```

**width**

```ts
string | number | undefined
```

```ts
undefined | string | number
```

**required**

```ts
boolean | undefined
```

**requiredMessage**

```ts
string | undefined
```

```ts
undefined | string
```

**rules**

```ts
QuireKitFormRule | readonly QuireKitFormRule[] | undefined
```

```ts
undefined | { (value: unknown, ctx: FieldValidationMetaInfo): MaybePromise<boolean | MaybeArray<string>>; } | readonly (QuireKitFormRule)[]
```

**dependsOn**

```ts
readonly string[] | undefined
```

```ts
undefined | readonly (string)[]
```

**validateOn**

```ts
QuireKitFormValidateOn | undefined
```

```ts
undefined | "submit" | "blur" | "change"
```

**disabled**

```ts
boolean | undefined
```

**readOnly**

```ts
boolean | undefined
```

**keepValueOnUnmount**

```ts
boolean | undefined
```

#### Events

无。

#### Slots

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| default | 否 | — | Render one input, binding controlProps or using the custom model actions. |
| meta | 否 | — | Short information or an action next to the label. |
| message | 否 | — | Replaces the current feedback text without removing its semantic container. |

**default**

```ts
QuireKitFormFieldSlotProps
```

```ts
{
  /** Complete standard Vue control binding. */
  controlProps: {
    /** Normalized required state for strict Vue component bindings. */
    required: boolean;
    /** Normalized disabled state for strict Vue component bindings. */
    disabled: boolean;
    /** Normalized readonly state, including the form submission lock. */
    readOnly: boolean;
    /** Native field path. */
    name: string;
    /** Controlled value, owned by VeeValidate. */
    modelValue: unknown;
    /** Controlled update listener. */
    "onUpdate:modelValue": { (value: unknown): void; };
    /** 控件默认占满字段宽度；可在绑定后显式覆盖。 */
    width?: undefined | string;
    /** 标签指向的控件 id。 */
    id: string;
    /** 当前反馈通道的关联 id。 */
    "aria-describedby"?: string | undefined;
    /** 错误反馈通道的关联 id。 */
    "aria-errormessage"?: string | undefined;
    /** 控件当前是否处于错误状态。 */
    "aria-invalid"?: undefined | "true";
    /** 字段控件的部件标识。 */
    "data-part": string;
    /** 字段控件的作用域标识。 */
    "data-scope": string;
    /** 控件当前是否处于错误状态。 */
    invalid: boolean;
  };
  /** Current field value. */
  value: unknown;
  /** Guarded update function for custom control models. */
  setValue: { (value: unknown): void; };
  /** Marks interaction and applies the configured blur policy. */
  handleBlur: { (): void; };
  /** Explicitly validates the field. */
  validate: { (): Promise<unknown>; };
  /** Live VeeValidate interaction/validation metadata. */
  meta: FieldMeta<unknown>;
  /** Current first error. */
  errorMessage: string | undefined;
  /** QuireField's single feedback lane status. */
  status: undefined | "disabled" | "description" | "busy" | "error" | "mixed";
}
```

**meta**

```ts
QuireKitFormFieldFeedbackSlotProps
```

**message**

```ts
QuireKitFormFieldFeedbackSlotProps
```

#### 公开实例成员

无。

#### 相关类型

```ts
type QuireKitFormFieldSlotProps = {
  /** Complete standard Vue control binding. */
  controlProps: {
    /** Normalized required state for strict Vue component bindings. */
    required: boolean;
    /** Normalized disabled state for strict Vue component bindings. */
    disabled: boolean;
    /** Normalized readonly state, including the form submission lock. */
    readOnly: boolean;
    /** Native field path. */
    name: string;
    /** Controlled value, owned by VeeValidate. */
    modelValue: unknown;
    /** Controlled update listener. */
    "onUpdate:modelValue": (value: unknown): void;
    /** 控件默认占满字段宽度；可在绑定后显式覆盖。 */
    width?: string | undefined;
    /** 标签指向的控件 id。 */
    id: string;
    /** 当前反馈通道的关联 id。 */
    "aria-describedby"?: string | undefined;
    /** 错误反馈通道的关联 id。 */
    "aria-errormessage"?: string | undefined;
    /** 控件当前是否处于错误状态。 */
    "aria-invalid"?: "true" | undefined;
    /** 字段控件的部件标识。 */
    "data-part": string;
    /** 字段控件的作用域标识。 */
    "data-scope": string;
    /** 控件当前是否处于错误状态。 */
    invalid: boolean;
  };
  /** Current field value. */
  value: unknown;
  /** Guarded update function for custom control models. */
  setValue: { (value: unknown): void; };
  /** Marks interaction and applies the configured blur policy. */
  handleBlur: { (): void; };
  /** Explicitly validates the field. */
  validate: { (): Promise<unknown>; };
  /** Live VeeValidate interaction/validation metadata. */
  meta: FieldMeta<unknown>;
  /** Current first error. */
  errorMessage: string | undefined;
  /** QuireField's single feedback lane status. */
  status: undefined | "disabled" | "description" | "busy" | "error" | "mixed";
};
```

```ts
type QuireKitFormControlProps = {
  /** Normalized required state for strict Vue component bindings. */
  required: boolean;
  /** Normalized disabled state for strict Vue component bindings. */
  disabled: boolean;
  /** Normalized readonly state, including the form submission lock. */
  readOnly: boolean;
  /** Native field path. */
  name: string;
  /** Controlled value, owned by VeeValidate. */
  modelValue: unknown;
  /** Controlled update listener. */
  "onUpdate:modelValue": { (value: unknown): void; };
  /** 控件默认占满字段宽度；可在绑定后显式覆盖。 */
  width?: undefined | string;
  /** 标签指向的控件 id。 */
  id: string;
  /** 当前反馈通道的关联 id。 */
  "aria-describedby"?: string | undefined;
  /** 错误反馈通道的关联 id。 */
  "aria-errormessage"?: string | undefined;
  /** 控件当前是否处于错误状态。 */
  "aria-invalid"?: undefined | "true";
  /** 字段控件的部件标识。 */
  "data-part": string;
  /** 字段控件的作用域标识。 */
  "data-scope": string;
  /** 控件当前是否处于错误状态。 */
  invalid: boolean;
};
```

### QuireSchemaForm

### QuireSchemaForm

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| fields | 是 | — | Trusted field/group tree with stable identities. |
| registry | 否 | — | Per-instance component adapters, overriding built-ins with the same key. |
| initialValues | 否 | — | Initial/reset baseline, captured once; load another record with resetForm. |
| onSubmit | 否 | — | Awaited application save handler. |
| disabled | 否 | — | Disable editing and submission. |
| readOnly | 否 | — | Preserve focus/selection while disallowing field edits. |
| validateOn | 否 | — | Default field validation timing. |
| focusOnError | 否 | true | Focus the first mounted actionable error after failed submission. |

**fields**

```ts
readonly QuireKitSchemaNode[]
```

```ts
readonly ({
  /** Stable render identity, defaulting to the field path. */
  key?: undefined | string;
  /** Built-in or explicitly registered control. A named field slot overrides it. */
  control: "number" | "input" | "textarea" | "select" | "checkbox" | "switch" | string & {};
  /** Extra control options; canonical model/state bindings take priority. */
  props?: undefined | Readonly<Record<string, unknown>>;
  /** False unmounts the field while preserving its draft by default. */
  visible?: undefined | false | true | { (values: QuireKitFormValues): boolean; };
  /** Skip field validation and editing, including inherited group disablement. */
  disabled?: QuireKitSchemaCondition | undefined;
  /** Disallow editing while continuing validation. */
  readOnly?: QuireKitSchemaCondition | undefined;
  /** Visible, accessible field label. */
  label: string;
  /** Width of the field; defaults to its container width. */
  width?: undefined | string | number;
  /** VeeValidate path, including nested objects and array indices. */
  name: string;
  /** Enforce a nonempty value, including true for required booleans. */
  required?: boolean | undefined;
  /** Help text displayed without errors. */
  description?: string | undefined;
  /** Override form-level validation timing. */
  validateOn?: undefined | "submit" | "blur" | "change";
  /** Optional stable field id. */
  id?: string | undefined;
  /** Reason an explicitly disabled field cannot be edited. */
  disabledReason?: string | undefined;
  /** Field-specific required feedback; defaults to the language pack's message naming the label. */
  requiredMessage?: string | undefined;
  /** Function rules evaluated sequentially, stopping on the first error. */
  rules?: undefined | { (value: unknown, ctx: FieldValidationMetaInfo): MaybePromise<boolean | MaybeArray<string>>; } | readonly (QuireKitFormRule)[];
  /** Explicit dependencies revalidated after interaction. */
  dependsOn?: undefined | readonly (string)[];
  /** Preserve draft on unmount; true by default. */
  keepValueOnUnmount?: boolean | undefined;
} | {
  /** Stable, sibling-unique identity independent of ordering. */
  key: string;
  /** Accessible group name. */
  legend: string;
  /** Hide the visible legend while preserving the group name. */
  legendHidden?: boolean | undefined;
  /** Optional group-level guidance. */
  description?: string | undefined;
  /** Reuse the existing plain/outline Fieldset appearance. */
  appearance?: undefined | "outline" | "plain";
  /** Fieldset's responsive field arrangement. */
  orientation?: undefined | "vertical" | "horizontal";
  /** Ordered nested groups and fields. */
  children: readonly QuireKitSchemaNode[];
  /** Hide/unmount the whole group, preserving field drafts. */
  visible?: QuireKitSchemaCondition | undefined;
  /** Inherited field disablement and validation exclusion. */
  disabled?: QuireKitSchemaCondition | undefined;
  /** Inherited editing restriction. */
  readOnly?: QuireKitSchemaCondition | undefined;
})[]
```

**registry**

```ts
Readonly<Record<string, QuireKitSchemaControl>> | undefined
```

```ts
undefined | Readonly<Record<string, QuireKitSchemaControl>>
```

**initialValues**

```ts
QuireKitFormValues | undefined
```

```ts
undefined | QuireKitFormValues
```

**onSubmit**

```ts
QuireKitFormSubmitHandler | undefined
```

```ts
undefined | { (values: QuireKitFormValues, form: QuireKitFormContext): unknown; }
```

**disabled**

```ts
boolean | undefined
```

**readOnly**

```ts
boolean | undefined
```

**validateOn**

```ts
QuireKitFormValidateOn | undefined
```

```ts
undefined | "submit" | "blur" | "change"
```

**focusOnError**

```ts
boolean | undefined
```

#### Events

无。

#### Slots

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| default | 否 | — | Extra content rendered after generated fields. |
| actions | 否 | — | Explicit consumer-provided save/reset actions. |
| error | 否 | — | Optional replacement for request error feedback. |

**default**

```ts
{ readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; }
```

**actions**

```ts
{ readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; }
```

**error**

```ts
{ readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; }
```

#### 公开实例成员

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| form | 否 | — |  |
| submit | 否 | — |  |
| resetForm | 否 | — |  |

**form**

```ts
{ readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; } | undefined
```

```ts
undefined | { readonly values: QuireKitFormValues; readonly errors: Partial<Record<string, string | undefined>>; readonly meta: FormMeta<QuireKitFormValues>; readonly isSubmitting: boolean; readonly isValidating: boolean; readonly submitCount: number; readonly submitError: string | undefined; readonly disabled: boolean; readonly readOnly: boolean; readonly validateOn: QuireKitFormValidateOn; readonly setFieldValue: (path: string, value: unknown, shouldValidate?: boolean | undefined) => boolean; readonly setValues: (values: QuireKitFormValues, shouldValidate?: boolean | undefined) => boolean; readonly setErrors: (fields: Partial<FlattenAndSetPathsType<QuireKitFormValues, string | string[] | undefined>>) => void; readonly setFieldError: (field: string, message: string | string[] | undefined) => void; readonly setFieldTouched: (field: string, isTouched: boolean) => void; readonly validate: () => Promise<FormValidationResult<QuireKitFormValues, QuireKitFormValues>>; readonly validateField: <TPath extends string>(field: TPath, opts?: Partial<ValidationOptions> | undefined) => Promise<ValidationResult<unknown>>; readonly submit: (event?: Event | undefined) => Promise<void>; readonly resetForm: (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean; readonly focusFirstError: () => Promise<void>; readonly reportError: (error: unknown) => void; }
```

**submit**

```ts
(event?: Event | undefined) => Promise<void>
```

```ts
{ (event?: Event | undefined): Promise<void>; }
```

**resetForm**

```ts
(state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined) => boolean
```

```ts
{ (state?: Partial<FormState<QuireKitFormValues>> | undefined, options?: Partial<ResetFormOpts> | undefined): boolean; }
```

#### 相关类型

```ts
type QuireKitSchemaNode = {
  /** Stable render identity, defaulting to the field path. */
  key?: undefined | string;
  /** Built-in or explicitly registered control. A named field slot overrides it. */
  control: "number" | "input" | "textarea" | "select" | "checkbox" | "switch" | string & {};
  /** Extra control options; canonical model/state bindings take priority. */
  props?: undefined | Readonly<Record<string, unknown>>;
  /** False unmounts the field while preserving its draft by default. */
  visible?: undefined | false | true | { (values: QuireKitFormValues): boolean; };
  /** Skip field validation and editing, including inherited group disablement. */
  disabled?: QuireKitSchemaCondition | undefined;
  /** Disallow editing while continuing validation. */
  readOnly?: QuireKitSchemaCondition | undefined;
  /** Visible, accessible field label. */
  label: string;
  /** Width of the field; defaults to its container width. */
  width?: undefined | string | number;
  /** VeeValidate path, including nested objects and array indices. */
  name: string;
  /** Enforce a nonempty value, including true for required booleans. */
  required?: boolean | undefined;
  /** Help text displayed without errors. */
  description?: string | undefined;
  /** Override form-level validation timing. */
  validateOn?: undefined | "submit" | "blur" | "change";
  /** Optional stable field id. */
  id?: string | undefined;
  /** Reason an explicitly disabled field cannot be edited. */
  disabledReason?: string | undefined;
  /** Field-specific required feedback; defaults to the language pack's message naming the label. */
  requiredMessage?: string | undefined;
  /** Function rules evaluated sequentially, stopping on the first error. */
  rules?: undefined | { (value: unknown, ctx: FieldValidationMetaInfo): MaybePromise<boolean | MaybeArray<string>>; } | readonly (QuireKitFormRule)[];
  /** Explicit dependencies revalidated after interaction. */
  dependsOn?: undefined | readonly (string)[];
  /** Preserve draft on unmount; true by default. */
  keepValueOnUnmount?: boolean | undefined;
} | {
  /** Stable, sibling-unique identity independent of ordering. */
  key: string;
  /** Accessible group name. */
  legend: string;
  /** Hide the visible legend while preserving the group name. */
  legendHidden?: boolean | undefined;
  /** Optional group-level guidance. */
  description?: string | undefined;
  /** Reuse the existing plain/outline Fieldset appearance. */
  appearance?: undefined | "outline" | "plain";
  /** Fieldset's responsive field arrangement. */
  orientation?: undefined | "vertical" | "horizontal";
  /** Ordered nested groups and fields. */
  children: readonly QuireKitSchemaNode[];
  /** Hide/unmount the whole group, preserving field drafts. */
  visible?: QuireKitSchemaCondition | undefined;
  /** Inherited field disablement and validation exclusion. */
  disabled?: QuireKitSchemaCondition | undefined;
  /** Inherited editing restriction. */
  readOnly?: QuireKitSchemaCondition | undefined;
};
```

```ts
type QuireKitSchemaField = {
  /** Stable render identity, defaulting to the field path. */
  key?: undefined | string;
  /** Built-in or explicitly registered control. A named field slot overrides it. */
  control: "number" | "input" | "textarea" | "select" | "checkbox" | "switch" | string & {};
  /** Extra control options; canonical model/state bindings take priority. */
  props?: undefined | Readonly<Record<string, unknown>>;
  /** False unmounts the field while preserving its draft by default. */
  visible?: undefined | false | true | { (values: QuireKitFormValues): boolean; };
  /** Skip field validation and editing, including inherited group disablement. */
  disabled?: QuireKitSchemaCondition | undefined;
  /** Disallow editing while continuing validation. */
  readOnly?: QuireKitSchemaCondition | undefined;
  /** Visible, accessible field label. */
  label: string;
  /** Width of the field; defaults to its container width. */
  width?: undefined | string | number;
  /** VeeValidate path, including nested objects and array indices. */
  name: string;
  /** Enforce a nonempty value, including true for required booleans. */
  required?: boolean | undefined;
  /** Help text displayed without errors. */
  description?: string | undefined;
  /** Override form-level validation timing. */
  validateOn?: undefined | "submit" | "blur" | "change";
  /** Optional stable field id. */
  id?: string | undefined;
  /** Reason an explicitly disabled field cannot be edited. */
  disabledReason?: string | undefined;
  /** Field-specific required feedback; defaults to the language pack's message naming the label. */
  requiredMessage?: string | undefined;
  /** Function rules evaluated sequentially, stopping on the first error. */
  rules?: undefined | { (value: unknown, ctx: FieldValidationMetaInfo): MaybePromise<boolean | MaybeArray<string>>; } | readonly (QuireKitFormRule)[];
  /** Explicit dependencies revalidated after interaction. */
  dependsOn?: undefined | readonly (string)[];
  /** Preserve draft on unmount; true by default. */
  keepValueOnUnmount?: boolean | undefined;
};
```

```ts
type QuireKitSchemaGroup = {
  /** Stable, sibling-unique identity independent of ordering. */
  key: string;
  /** Accessible group name. */
  legend: string;
  /** Hide the visible legend while preserving the group name. */
  legendHidden?: boolean | undefined;
  /** Optional group-level guidance. */
  description?: string | undefined;
  /** Reuse the existing plain/outline Fieldset appearance. */
  appearance?: undefined | "outline" | "plain";
  /** Fieldset's responsive field arrangement. */
  orientation?: undefined | "vertical" | "horizontal";
  /** Ordered nested groups and fields. */
  children: readonly QuireKitSchemaNode[];
  /** Hide/unmount the whole group, preserving field drafts. */
  visible?: QuireKitSchemaCondition | undefined;
  /** Inherited field disablement and validation exclusion. */
  disabled?: QuireKitSchemaCondition | undefined;
  /** Inherited editing restriction. */
  readOnly?: QuireKitSchemaCondition | undefined;
};
```
