import * as React from "react";
export declare type FormInvalidMessage = {
    type: "Required";
} | {
    type: "NotInRange";
    rangeMin?: number;
    rangeMax?: number;
} | {
    type: "InvalidLength";
    lengthMin?: number;
    lengthMax?: number;
};
export interface FormConfig<FieldConfig extends {} = {}, FieldName extends string = string> {
    fields: Record<FieldName, FieldConfig & FormFieldConfig>;
}
export declare type FormFieldValidatorResult = {
    message?: FormInvalidMessage;
    valid: boolean;
    value?: string;
};
export declare type FormFieldValidator = (value: string) => FormFieldValidatorResult;
export interface FormFieldConfig {
    validate?: FormFieldValidator;
    required?: boolean;
    defaultValue?: string;
}
export interface FormData<FieldConfig extends {} = {}, FieldName extends string = string> {
    fields: FormDataField<FieldConfig>[];
    values: Record<FieldName, string>;
    valid: boolean;
}
export declare type FormDataField<FieldConfig extends {} = {}, FieldName extends string = string> = FormStateField & FieldConfig & {
    required?: boolean;
    identifier: FieldName;
    onChange(newValue: string): void;
};
interface FormStateField {
    value: string;
    valid: boolean;
    message: FormInvalidMessage | undefined;
}
export interface FormState<FieldConfig extends {}, FieldName extends string = string> {
    valid: boolean;
    fields: Record<FieldName, FormStateField>;
    config: FormConfig<FieldConfig>;
}
export declare const useForm: <FieldConfig extends FormFieldConfig = FormFieldConfig, FieldName extends string = string>(config: FormConfig<FieldConfig, FieldName>) => FormData<FieldConfig, FieldName>;
declare const Form: {
    <FieldConfig extends {}, FieldName extends string = string>(props: FormProps<FieldConfig, FieldName>): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
    displayName: string;
};
export default Form;
export interface FormProps<FieldConfig extends FormFieldConfig, FieldName extends string> extends FormConfig<FieldConfig, FieldName> {
    children(props: FormData<FieldConfig, FieldName>): React.ReactElement;
}
