mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-26 18:00:43 +01:00
test(Form): fix (#2153)
This commit is contained in:
@@ -46,7 +46,7 @@ const props = withDefaults(defineProps<FormProps<T>>(), {
|
||||
const emits = defineEmits<FormEmits<T>>()
|
||||
defineSlots<FormSlots>()
|
||||
|
||||
const formId = props.id ?? useId()
|
||||
const formId = props.id ?? useId() as string
|
||||
|
||||
const bus = useEventBus<FormEvent>(`form-${formId}`)
|
||||
const parentBus = inject(
|
||||
|
||||
@@ -39,7 +39,7 @@ export interface FormFieldSlots {
|
||||
import { computed, ref, inject, provide, type Ref, useId } from 'vue'
|
||||
import { Label } from 'radix-vue'
|
||||
import { formFieldInjectionKey } from '../composables/useFormField'
|
||||
import type { FormError } from '../types/form'
|
||||
import type { FormError, FormFieldInjectedOptions } from '../types/form'
|
||||
|
||||
const props = defineProps<FormFieldProps>()
|
||||
const slots = defineSlots<FormFieldSlots>()
|
||||
@@ -51,12 +51,7 @@ const ui = computed(() => formField({
|
||||
|
||||
const formErrors = inject<Ref<FormError[]> | null>('form-errors', null)
|
||||
|
||||
const error = computed(() => {
|
||||
return (props.error && typeof props.error === 'string')
|
||||
|| typeof props.error === 'boolean'
|
||||
? props.error
|
||||
: formErrors?.value?.find(error => error.name === props.name)?.message
|
||||
})
|
||||
const error = computed(() => props.error || formErrors?.value?.find(error => error.name === props.name)?.message)
|
||||
|
||||
const id = ref(useId())
|
||||
|
||||
@@ -67,7 +62,7 @@ provide(formFieldInjectionKey, computed(() => ({
|
||||
size: props.size,
|
||||
eagerValidation: props.eagerValidation,
|
||||
validateOnInputDelay: props.validateOnInputDelay
|
||||
})))
|
||||
}) as FormFieldInjectedOptions<FormFieldProps>))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user