import { type FormInstance } from "antd"; import { type NamePath } from "rc-field-form/lib/interface"; import { type INavigate } from "../router"; export type INamePath = NamePath; export interface IFormItemContext { readonly field: INamePath; readonly label: string; setValue(value: any): void; getValue(): any; setErrors(errors: string[]): void; } export type IFormFields = [INamePath, any]; export interface IFormError { readonly id: INamePath; readonly error: string; } export interface IErrorHandler { readonly error: TError; readonly formContext: IFormContext; } export type IFormErrorHandler = (error: IErrorHandler) => void; export type IFormErrorMap = Record>; export interface IFormErrors { readonly message?: string; readonly errors: IFormError[]; } export interface IFormContext { readonly translation?: string; /** * Antd form instance. */ readonly form: FormInstance; /** * Current form errors. */ readonly errors: IFormErrors; /** * Set field errors. * * @param errors */ setErrors(errors: IFormErrors): void; /** * Set form values * * @param values values being set */ setValues(values: TValues): void; setValue(value: { name: INamePath; value: any; }[]): void; /** * Reset form to the initial state. */ reset(): void; /** * Return current form values. */ values(): any; /** * Throw away all error messages of all fields. */ resetErrors(): void; } export type IToOptionMapper = (item: TItem) => IBaseSelectOption; export interface IFormValuesChanged { readonly values: TFormValues; readonly formContext: IFormContext; readonly changed: Partial; } export interface IFormChanged { readonly values: TFormValues; readonly formContext: IFormContext; } export interface IFormSuccess { /** * Handy shortcut for navigation. */ readonly navigate: INavigate; /** * Original values sent to the form. */ readonly values: TFormValues; /** * Response values got after processing form. */ readonly response: TResponse; /** * Access to the whole form context. */ readonly formContext: IFormContext; /** * Translates given string using form's translation base if provided. * @param text * @param data */ t(text: string, data?: Record): string; } export interface IFormFailure { readonly error: string; readonly formContext: IFormContext; } export interface IToFormError { readonly error: TError; readonly formContext: IFormContext; } export type IBaseSelectItem = any; export interface IBaseSelectOption { readonly value: IBaseSelectItem; readonly label: IBaseSelectItem; } //# sourceMappingURL=form.d.ts.map