import React, { Dispatch, FormEvent, MutableRefObject, SetStateAction } from 'react'; import { FORMALIZER_ID_DATA_ATTRIBUTE } from './use-form-input'; interface FormalizerSettingsType { invalidAttr?: { [key: string]: any; }; helperTextAttr?: string; keepUnknownAttributes?: boolean; } export declare const FormalizerSettings: FormalizerSettingsType; export interface SingleErrorPerInput { [key: string]: string; } export interface ErrorByValidatorKey { [key: string]: string; } export interface MultipleErrorsPerInput { [key: string]: ErrorByValidatorKey; } export declare const GlobalValidators: { [key: string]: InputValidationConfig | string; }; export declare const DEFAULT_VALIDATION_ERROR_MESSAGE = "This field is not valid."; export declare type ValidatorFunction = (value: any, options: ValidatorFunctionOptions) => string | boolean | undefined; export interface InputValidationConfig { key?: string; errorMessage?: string | ErrorMessageFunction; negate?: boolean; options?: InputValidationOptions; validator?: ValidatorFunction | string; } export declare const isInputValidationConfig: (value: any) => value is InputValidationConfig; declare type FormSubmitHandler = (formValues: T, e?: Event) => void; export declare type ErrorMessageFunction = (value: string, formData: T) => string; export interface InputValidationByKey { [key: string]: InputValidationConfig | string; } export interface ValidationSettings { reportMultipleErrors?: boolean; omitTypeAttribute?: boolean; } export interface ValidationSettingsWithTypeOmitted { omitTypeAttribute: true; } declare type InputValidation = InputValidationConfig | string; export declare type ValidationErrorCleaner = (name: string, reportMultipleErrors: boolean, ruleKey?: string) => void; export declare type ValidationErrorReporter = (name: string, reportMultipleErrors: boolean, ruleKey: string, errorMessage: string) => void; export declare type SupportedInputTypes = 'text' | 'checkbox' | 'radio' | 'button'; export interface FormInputParams { name: string; errors: SingleErrorPerInput | MultipleErrorsPerInput; formHandler: [T, Dispatch>]; formRef: MutableRefObject; clearError: ValidationErrorCleaner; reportError: ValidationErrorReporter; invalidAttr?: object; inputType: I; inputValueAttributeVal?: string; submitHandler?: FormSubmitHandler; validation: Array> | string; helperTextAttr?: string; validationSettings?: ValidationSettings; } export interface FormInputData { inputAttr: InputAttributes; runValidations: () => boolean; } export interface InputAttributes { value?: any; checked?: boolean; name: string; onKeyPress: (e: React.KeyboardEvent | KeyboardEvent) => void; onChange: (e: React.ChangeEvent | FormEvent) => void; onBlur: () => any; helperTextObj?: { [key: string]: string; }; invalidAttr?: object; type?: I | undefined; [FORMALIZER_ID_DATA_ATTRIBUTE]: string; } export interface InputValidationOptions { [key: string]: any; } export interface ValidatorFunctionOptions extends InputValidationOptions { formData: T; } export declare function setupForMaterialUI(): void; export interface Formalizer { errors: SingleErrorPerInput | MultipleErrorsPerInput; formRef: React.MutableRefObject; formValues: T; isValid: boolean; performValidations: () => boolean; setValues: (formValues: T) => void; useCheckboxInput: (name: string, options?: V | undefined) => InputAttributes; useInput: (name: string, validationConfigs?: string | Array> | undefined, options?: V | undefined) => InputAttributes; useRadioInput: (name: string, value: string, options?: V | undefined) => InputAttributes; useToggleInput: (name: string, options?: V | undefined) => InputAttributes; } export declare const useFormalizer: >(submitHandler?: FormSubmitHandler | undefined, initialValues?: N | undefined, settings?: FormalizerSettingsType | undefined) => Formalizer; export {};