import { IValidationProps } from './validation'; import { Ref, ComputedRef, PropType, InjectionKey } from 'vue'; export interface IFormProvide { register: (item: { id: number | string; validate: () => Promise; reset: () => void; resetValidation: () => void; }) => void; unregister: (id: number | string) => void; update: (id: number | string, isValid: boolean | null, errorMessages: string[]) => void; items: Ref; isDisabled: ComputedRef; isReadonly: ComputedRef; isValidating: Ref; validateOn: Ref; } export interface IFormProps { label: string; description: string; disabled: boolean; readonly: boolean; firstFail: boolean; modelValue: boolean | null; validateOn: IValidationProps['validateOn']; } interface IFormField { id: number | string; validate: () => Promise; reset: () => void; resetValidation: () => void; isValid: boolean | null; errorMessages: string[]; } interface IFieldValidationResult { id: number | string; errorMessages: string[]; } interface IFormValidationResult { valid: boolean; errors: IFieldValidationResult[]; } export interface SubmitEventPromise extends SubmitEvent, Promise { } export declare const makeFormProps: (defaults?: Defaults | undefined) => import('../utils').AppendDefault<{ /** * Заголовок формы */ label: { type: PropType; default: string; }; /** * Описание формы */ description: { type: PropType; default: string; }; /** * Заблокировать форму */ disabled: { type: PropType; default: boolean; }; /** * Сделать форму только для чтения */ readonly: { type: PropType; default: boolean; }; /** * Остановить валидацию при первой ошибке */ firstFail: { type: PropType; default: boolean; }; /** * Значение модели */ modelValue: { type: PropType; default: null; }; /** * Событие для валидации */ validateOn: { type: PropType; default: string; }; }, Defaults>; export declare const FormKey: InjectionKey; export declare function createForm(props: IFormProps): { errors: Ref<{ id: number | string; errorMessages: string[]; }[], IFieldValidationResult[] | { id: number | string; errorMessages: string[]; }[]>; isDisabled: ComputedRef; isReadonly: ComputedRef; isValidating: Ref; model: Ref & { readonly externalValue: boolean | null; }; validate: () => Promise<{ valid: boolean; errors: { id: number | string; errorMessages: string[]; }[]; }>; reset: () => void; resetValidation: () => void; }; export declare function useForm(): IFormProvide | null; export {};