import React, { ComponentClass } from 'react'; import { WrapperProps, WrapperState } from './withFormsy'; export interface Values { [key: string]: any; } export type IModel = any; export type IResetModel = (model?: IModel) => void; export type IUpdateInputsWithValue = (values: { [key: string]: V }, validate?: boolean) => void; export type IUpdateInputsWithError = (errors: { [key: string]: ValidationError }, invalidate?: boolean) => void; export type ValidationError = string | React.ReactNode; export type ValidationFunction = (values: Values, value: V, extra?: any) => boolean | ValidationError; export type Validation = string | boolean | ValidationFunction; export type Validations = ValidationsStructure | string | object; export interface ValidationsStructure { [key: string]: Validation; } export type RequiredValidation = boolean | Validations; export interface ComponentWithStaticAttributes extends ComponentClass { defaultValue?: any; } export type WrappedComponentClass = React.FC | ComponentWithStaticAttributes; export interface InputComponent extends React.Component, WrapperState> { validations?: Validations; requiredValidations?: Validations; } export interface FormsyContextInterface { attachToForm: (component: InputComponent) => void; detachFromForm: (component: InputComponent) => void; isFormDisabled: boolean; isValidValue: (component: InputComponent, value: any) => boolean; validate: (component: InputComponent) => void; runValidation: (component: InputComponent) => { isRequired: boolean; isValid: boolean; validationError: ValidationError[]; }; }