diff --git a/docs/content/docs/2.components/chat-prompt.md b/docs/content/docs/2.components/chat-prompt.md index 0bfb0b20f9..7243d79c37 100644 --- a/docs/content/docs/2.components/chat-prompt.md +++ b/docs/content/docs/2.components/chat-prompt.md @@ -186,6 +186,14 @@ async function onSubmit() { :component-emits +### Expose + +When accessing the component via a template ref, you can use the following: + +| Name | Type | +| ---- | ---- | +| `textareaRef`{lang="ts-type"} | `Ref`{lang="ts-type"} | + ## Theme :component-theme diff --git a/docs/content/docs/2.components/content-search.md b/docs/content/docs/2.components/content-search.md index 568bd85b79..3a0617ba4d 100644 --- a/docs/content/docs/2.components/content-search.md +++ b/docs/content/docs/2.components/content-search.md @@ -151,6 +151,14 @@ It is recommended to wrap the `ContentSearch` component in a [ClientOnly](https: :component-emits +### Expose + +When accessing the component via a template ref, you can use the following: + +| Name | Type | +| ---- | ---- | +| `commandPaletteRef`{lang="ts-type"} | `Ref \| null>`{lang="ts-type"} | + ## Theme :component-theme diff --git a/docs/content/docs/2.components/dashboard-search.md b/docs/content/docs/2.components/dashboard-search.md index d0064d7183..d5af5f2cdf 100644 --- a/docs/content/docs/2.components/dashboard-search.md +++ b/docs/content/docs/2.components/dashboard-search.md @@ -89,6 +89,14 @@ You can disable this behavior by setting the `color-mode` prop to `false`: :component-emits +### Expose + +When accessing the component via a template ref, you can use the following: + +| Name | Type | +| ---- | ---- | +| `commandPaletteRef`{lang="ts-type"} | `Ref \| null>`{lang="ts-type"} | + ## Theme :component-theme diff --git a/docs/content/docs/2.components/form.md b/docs/content/docs/2.components/form.md index 626fd5dbf3..cce978fda4 100644 --- a/docs/content/docs/2.components/form.md +++ b/docs/content/docs/2.components/form.md @@ -209,19 +209,19 @@ const form = useTemplateRef('form') This will give you access to the following: -| Name | Type | -|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `submit()`{lang="ts-type"} | `Promise`{lang="ts-type"}

Triggers form submission.

| -| `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.

| -| `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.

| -| `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. | +| Name | Type | +| ---- | ---- | +| `submit()`{lang="ts-type"} | `Promise`{lang="ts-type"}

Triggers form submission.

| +| `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.

| +| `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.

| +| `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. | ## Theme diff --git a/docs/content/docs/2.components/input-menu.md b/docs/content/docs/2.components/input-menu.md index b7007973a6..4366caa2d8 100644 --- a/docs/content/docs/2.components/input-menu.md +++ b/docs/content/docs/2.components/input-menu.md @@ -855,7 +855,7 @@ When accessing the component via a template ref, you can use the following: | Name | Type | | ---- | ---- | -| `inputRef`{lang="ts-type"} | `Ref \| null>`{lang="ts-type"} | +| `inputRef`{lang="ts-type"} | `Ref`{lang="ts-type"} | ## Theme diff --git a/docs/content/docs/2.components/input-number.md b/docs/content/docs/2.components/input-number.md index 97dde5648e..e49c4de841 100644 --- a/docs/content/docs/2.components/input-number.md +++ b/docs/content/docs/2.components/input-number.md @@ -296,9 +296,9 @@ name: 'input-number-slots-example' When accessing the component via a template ref, you can use the following: -| Name | Type | -| -------------------------- | ----------------------------------------------- | -| `inputRef`{lang="ts-type"} | `Ref \| null>`{lang="ts-type"} | +| Name | Type | +| ---- | ---- | +| `inputRef`{lang="ts-type"} | `Ref`{lang="ts-type"} | ## Theme diff --git a/docs/content/docs/2.components/input-tags.md b/docs/content/docs/2.components/input-tags.md index 02074d5422..639ac4653b 100644 --- a/docs/content/docs/2.components/input-tags.md +++ b/docs/content/docs/2.components/input-tags.md @@ -286,9 +286,9 @@ name: 'input-tags-form-field-example' When accessing the component via a template ref, you can use the following: -| Name | Type | -| -------------------------- | ----------------------------------------------- | -| `inputRef`{lang="ts-type"} | `Ref \| null>`{lang="ts-type"} | +| Name | Type | +| ---- | ---- | +| `inputRef`{lang="ts-type"} | `Ref`{lang="ts-type"} | ## Theme diff --git a/docs/content/docs/2.components/select-menu.md b/docs/content/docs/2.components/select-menu.md index 3ead44e8bf..d3a9e60fe4 100644 --- a/docs/content/docs/2.components/select-menu.md +++ b/docs/content/docs/2.components/select-menu.md @@ -896,7 +896,7 @@ When accessing the component via a template ref, you can use the following: | Name | Type | | ---- | ---- | -| `triggerRef`{lang="ts-type"} | `Ref \| null>`{lang="ts-type"} | +| `triggerRef`{lang="ts-type"} | `Ref`{lang="ts-type"} | ## Theme diff --git a/docs/content/docs/2.components/select.md b/docs/content/docs/2.components/select.md index 723a71e444..2907f839ef 100644 --- a/docs/content/docs/2.components/select.md +++ b/docs/content/docs/2.components/select.md @@ -771,7 +771,7 @@ When accessing the component via a template ref, you can use the following: | Name | Type | | ---- | ---- | -| `triggerRef`{lang="ts-type"} | `Ref \| null>`{lang="ts-type"} | +| `triggerRef`{lang="ts-type"} | `Ref`{lang="ts-type"} | ## Theme diff --git a/docs/content/docs/2.components/table.md b/docs/content/docs/2.components/table.md index 1c5ed14563..a4c24886f7 100644 --- a/docs/content/docs/2.components/table.md +++ b/docs/content/docs/2.components/table.md @@ -678,7 +678,7 @@ This will give you access to the following: | Name | Type | | ---- | ---- | | `tableRef`{lang="ts-type"} | `Ref`{lang="ts-type"} | -| `tableApi`{lang="ts-type"} | [`Ref`{lang="ts-type"}](https://tanstack.com/table/latest/docs/api/core/table#table-api) | +| `tableApi`{lang="ts-type"} | [`Table`{lang="ts-type"}](https://tanstack.com/table/latest/docs/api/core/table#table-api) | ## Theme diff --git a/docs/content/docs/2.components/toast.md b/docs/content/docs/2.components/toast.md index e40d7e1514..a5917f30ae 100644 --- a/docs/content/docs/2.components/toast.md +++ b/docs/content/docs/2.components/toast.md @@ -338,6 +338,14 @@ In this example, we use the `AppConfig` to configure the `expand` prop of the `T :component-emits +### Expose + +When accessing the component via a template ref, you can use the following: + +| Name | Type | +| ---- | ---- | +| `height`{lang="ts-type"} | `Ref`{lang="ts-type"} | + ## Theme :component-theme diff --git a/src/runtime/components/AuthForm.vue b/src/runtime/components/AuthForm.vue index b1975551c5..5fef98b680 100644 --- a/src/runtime/components/AuthForm.vue +++ b/src/runtime/components/AuthForm.vue @@ -148,17 +148,12 @@ const slots = defineSlots>() const { t } = useLocale() const appConfig = useAppConfig() as AuthForm['AppConfig'] -const formRef = useTemplateRef('formRef') -const passwordVisibility = ref(false) -const passwordRef = useTemplateRef('passwordRef') - // eslint-disable-next-line vue/no-dupe-keys const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.authForm || {}) })()) -defineExpose({ - formRef, - state -}) +const formRef = useTemplateRef('formRef') +const passwordVisibility = ref(false) +const passwordRef = useTemplateRef('passwordRef') function pickFieldProps(field: F) { const fields = ['name', 'errorPattern', 'help', 'error', 'hint', 'size', 'required', 'eagerValidation', 'validateOnInputDelay'] as (keyof F)[] @@ -186,6 +181,11 @@ function omitFieldProps(field: F) { return omit(field, [...fields, 'label', 'description']) } + +defineExpose({ + formRef, + state +})