feat(Form): add errors slot prop (#2188)

This commit is contained in:
Romain Hamel
2024-09-12 11:14:32 +02:00
committed by GitHub
parent bf32baaab0
commit 67c6a74ed1

View File

@@ -1,11 +1,11 @@
<template> <template>
<form @submit.prevent="onSubmit"> <form @submit.prevent="onSubmit">
<slot /> <slot v-bind="{ errors }" />
</form> </form>
</template> </template>
<script lang="ts"> <script lang="ts">
import { provide, ref, type PropType, defineComponent, onUnmounted, onMounted } from 'vue' import { provide, ref, type PropType, defineComponent, onUnmounted, onMounted, readonly } from 'vue'
import { useEventBus } from '@vueuse/core' import { useEventBus } from '@vueuse/core'
import type { ZodSchema } from 'zod' import type { ZodSchema } from 'zod'
import type { ValidationError as JoiError, Schema as JoiSchema } from 'joi' import type { ValidationError as JoiError, Schema as JoiSchema } from 'joi'
@@ -181,7 +181,8 @@ export default defineComponent({
} as Form<any>) } as Form<any>)
return { return {
onSubmit onSubmit,
errors: readonly(errors)
} }
} }
}) })