mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-19 22:41:42 +01:00
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:
19
src/runtime/types/form.d.ts
vendored
19
src/runtime/types/form.d.ts
vendored
@@ -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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user