/** * Store object of all fields state within the form element. * Used below to keep tracking of fields value, touched, validity and * other fields state data. */ export type FieldsMetaState = { [P in keyof FormValues]: FieldMetaState; }; export interface FieldMetaState { /** * A snapshot of the initial value of the field. */ initialValue: Value; /** * State to understand when users focused and blurred input element. */ touched: boolean; /** * State to understand when user typed some value in input element * or not. */ dirty: boolean; /** * Valid state with initial value NOT_VALIDATED, with VALID when all * validators didn't return validation error, CHECKING for when async * validation is going on, and INVALID when some validator returns * validation error. */ validState: 'VALID' | 'INVALID' | 'NOT_VALIDATED' | 'CHECKING'; /** * Last error message which has been returned from validators. * Interpreted as Markdown. */ error?: string; /** * DOM element of the form field, it's null in case of custom non-connected * fields components or in case of multiple elements field like radio group. */ input?: HTMLElement | null; }