feat(Form): improve form control and input validation trigger (#487)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Romain Hamel
2023-08-12 16:48:53 +02:00
committed by Benjamin Canac
parent 60bb74675c
commit 6d7973f6e1
23 changed files with 529 additions and 381 deletions

View File

@@ -4,10 +4,18 @@ export interface FormError {
}
export interface Form<T> {
validate(): Promise<T>
validate(path?: string, opts: { silent?: boolean } = { silent: false }): Promise<T>
clear(path?: string): void
errors: Ref<FormError[]>
setErrors(errs: FormError[], path?: string): void
getErrors(path?: string): FormError[]
}
export type FormSubmitEvent<T> = SubmitEvent & { data: T }
export type FormEventType = 'blur' | 'input' | 'change' | 'submit'
export interface FormEvent {
type: 'blur' // | 'change' | 'focus'
type: FormEventType
path: string
}