feat(Form): handle @error event (#718)

Co-authored-by: Albert <albert@Alberts-MacBook-Pro.local>
Co-authored-by: Romain Hamel <romain@boilr.io>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Albert
2023-10-10 11:47:22 -04:00
committed by GitHub
parent 1df07e2b4c
commit e16379fdbd
12 changed files with 142 additions and 69 deletions

View File

@@ -1,10 +1,16 @@
export interface FormError {
path: string
import { Ref } from 'vue'
export interface FormError<T extends string = string> {
path: T
message: string
}
export interface FormErrorWithId extends FormError {
id: string
}
export interface Form<T> {
validate(path?: string, opts: { silent?: boolean }): Promise<T>
validate(path?: string, opts?: { silent?: boolean }): Promise<T>
clear(path?: string): void
errors: Ref<FormError[]>
setErrors(errs: FormError[], path?: string): void
@@ -12,17 +18,18 @@ export interface Form<T> {
}
export type FormSubmitEvent<T> = SubmitEvent & { data: T }
export type FormErrorEvent = SubmitEvent & { errors: FormErrorWithId[] }
export type FormEventType = 'blur' | 'input' | 'change' | 'submit'
export interface FormEvent {
type: FormEventType
path: string
path?: string
}
export interface InjectedFormGroupValue {
inputId: Ref<string>
inputId: Ref<string | undefined>
name: Ref<string>
size: Ref<string>
size: Ref<string | number | symbol>
error: Ref<string | boolean>
}