chore(FormGroup): simplify bindings between input and form group p… (#704)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Romain Hamel
2023-09-21 23:22:55 +02:00
committed by GitHub
parent a94782d94b
commit 46879dc1b7
14 changed files with 81 additions and 65 deletions

View File

@@ -12,6 +12,7 @@ import type { ValidationError as JoiError, Schema as JoiSchema } from 'joi'
import type { ObjectSchema as YupObjectSchema, ValidationError as YupError } from 'yup'
import type { ObjectSchemaAsync as ValibotObjectSchema } from 'valibot'
import type { FormError, FormEvent, FormEventType, FormSubmitEvent, Form } from '../../types/form'
import { uid } from '../../utils/uid'
export default defineComponent({
props: {
@@ -40,8 +41,7 @@ export default defineComponent({
},
emits: ['submit'],
setup (props, { expose, emit }) {
const seed = Math.random().toString(36).substring(7)
const bus = useEventBus<FormEvent>(`form-${seed}`)
const bus = useEventBus<FormEvent>(`form-${uid()}`)
bus.on(async (event) => {
if (event.type !== 'submit' && props.validateOn?.includes(event.type)) {