import type { StandardSchemaV1 } from '@standard-schema/spec'; import type { ComputedRef, DeepReadonly, Ref } from 'vue'; import type { GetObjectField } from './utils'; import type { Struct as SuperstructSchema } from 'superstruct'; export interface Form { validate(opts?: { name?: keyof FormData | (keyof FormData)[]; silent?: boolean; nested?: boolean; transform?: T; }): Promise | false>; clear(path?: keyof FormData | string | RegExp): void; errors: Ref; setErrors(errs: FormError[], name?: keyof FormData | string | RegExp): void; getErrors(name?: keyof FormData | string | RegExp): FormErrorWithId[]; submit(): Promise; disabled: ComputedRef; dirty: ComputedRef; loading: Ref; dirtyFields: ReadonlySet>>; touchedFields: ReadonlySet>>; blurredFields: ReadonlySet>>; } export type FormSchema = SuperstructSchema | StandardSchemaV1; export type InferInput = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput : Schema extends SuperstructSchema ? I : Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput : never; export type InferOutput = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput : Schema extends SuperstructSchema ? O : never; export type FormData = T extends true ? InferOutput : InferInput; export type FormInputEvents = 'input' | 'blur' | 'change' | 'focus'; export interface FormError

{ name?: P; message: string; } export interface FormErrorWithId extends FormError { id?: string; } export type FormSubmitEvent = SubmitEvent & { data: T; }; export type FormValidationError = { errors: FormErrorWithId[]; children?: FormErrorWithId[]; }; export type FormErrorEvent = SubmitEvent & FormValidationError; export type FormEventType = FormInputEvents; export type FormChildAttachEvent = { type: 'attach'; formId: string | number; validate: Form['validate']; name?: string; api: Form; }; export type FormChildDetachEvent = { type: 'detach'; formId: string | number; }; export type FormInputEvent = { type: FormEventType; name: keyof T; eager?: boolean; }; export type FormEvent = FormInputEvent | FormChildAttachEvent | FormChildDetachEvent; export interface FormInjectedOptions { disabled?: boolean; validateOnInputDelay?: number; } export interface FormFieldInjectedOptions { name?: string; size?: GetObjectField; error?: string | boolean; eagerValidation?: boolean; validateOnInputDelay?: number; errorPattern?: RegExp; hint?: string; description?: string; help?: string; ariaId: string; } export interface ValidateReturnSchema { result: T; errors: FormError[] | null; } export declare class FormValidationException extends Error { formId: string | number; errors: FormErrorWithId[]; constructor(formId: string | number, errors: FormErrorWithId[]); }