diff --git a/docs/content/docs/2.components/form.md b/docs/content/docs/2.components/form.md index 14cd83d6ce..af3bb3de9e 100644 --- a/docs/content/docs/2.components/form.md +++ b/docs/content/docs/2.components/form.md @@ -248,14 +248,14 @@ This will give you access to the following: | `submit()`{lang="ts-type"} | `Promise`{lang="ts-type"}

Triggers form submission with HTML5 validation.

| | `validate(opts: { name?: keyof T \| (keyof T)[], silent?: boolean, nested?: boolean, transform?: boolean })`{lang="ts-type"} | `Promise`{lang="ts-type"}

Triggers form validation. Will raise any errors unless `opts.silent` is set to true.

| | `clear(path?: keyof T \| RegExp)`{lang="ts-type"} | `void`

Clears form errors associated with a specific path. If no path is provided, clears all form errors.

| -| `getErrors(path?: keyof T \| RegExp)`{lang="ts-type"} | `FormError[]`{lang="ts-type"}

Retrieves form errors associated with a specific path. If no path is provided, returns all form errors.

| +| `getErrors(path?: keyof T \| RegExp)`{lang="ts-type"} | `FormErrorWithId[]`{lang="ts-type"}

Retrieves form errors associated with a specific path. If no path is provided, returns all form errors.

| | `setErrors(errors: FormError[], name?: keyof T \| RegExp)`{lang="ts-type"} | `void`

Sets form errors for a given path. If no path is provided, overrides all errors.

| -| `errors`{lang="ts-type"} | `Ref`{lang="ts-type"}

A reference to the array containing validation errors. Use this to access or manipulate the error information.

| +| `errors`{lang="ts-type"} | `Ref`{lang="ts-type"}

A reference to the array containing validation errors. Use this to access or manipulate the error information.

| | `disabled`{lang="ts-type"} | `Ref`{lang="ts-type"} | | `dirty`{lang="ts-type"} | `Ref`{lang="ts-type"} `true` if at least one form field has been updated by the user. | -| `dirtyFields`{lang="ts-type"} | `DeepReadonly>`{lang="ts-type"} Tracks fields that have been modified by the user. | -| `touchedFields`{lang="ts-type"} | `DeepReadonly>`{lang="ts-type"} Tracks fields that the user interacted with. | -| `blurredFields`{lang="ts-type"} | `DeepReadonly>`{lang="ts-type"} Tracks fields blurred by the user. | +| `dirtyFields`{lang="ts-type"} | `ReadonlySet>`{lang="ts-type"} Tracks fields that have been modified by the user. | +| `touchedFields`{lang="ts-type"} | `ReadonlySet>`{lang="ts-type"} Tracks fields that the user interacted with. | +| `blurredFields`{lang="ts-type"} | `ReadonlySet>`{lang="ts-type"} Tracks fields blurred by the user. | ## Theme diff --git a/src/runtime/components/Form.vue b/src/runtime/components/Form.vue index 6bad418c4b..7efeca6af0 100644 --- a/src/runtime/components/Form.vue +++ b/src/runtime/components/Form.vue @@ -71,7 +71,7 @@ export interface FormEmits { } export interface FormSlots { - default?(props: { errors: FormError[], loading: boolean }): VNode[] + default?(props: { errors: FormErrorWithId[], loading: boolean }): VNode[] } diff --git a/src/runtime/types/form.ts b/src/runtime/types/form.ts index e86f3e1b45..4a2a45b533 100644 --- a/src/runtime/types/form.ts +++ b/src/runtime/types/form.ts @@ -6,9 +6,9 @@ import type { Struct as SuperstructSchema } from 'superstruct' export interface Form { validate(opts?: { name?: keyof FormData | (keyof FormData)[], silent?: boolean, nested?: boolean, transform?: T }): Promise | false> clear (path?: keyof FormData | string | RegExp): void - errors: Ref + errors: Ref setErrors (errs: FormError[], name?: keyof FormData | string | RegExp): void - getErrors (name?: keyof FormData | string | RegExp): FormError[] + getErrors (name?: keyof FormData | string | RegExp): FormErrorWithId[] submit (): Promise disabled: ComputedRef dirty: ComputedRef