/// import { JSXElementConstructor } from "react"; import { MemoExoticComponent } from "react"; import { ReactElement } from "react"; import { ReactNode } from "react"; import { SyntheticEvent } from "react"; declare type CleanupFunction = () => void; export declare type ErrorMessage = string | boolean; export declare const Field: MemoExoticComponent< ({ children, isCheckboxElement, isMultipleElement, translateProps, }: FieldProps) => JSX.Element >; export declare const FieldErrorMessage: MemoExoticComponent< ({ name }: { name: string }) => JSX.Element >; export declare const FieldGroup: MemoExoticComponent< ({ children, id, name, }: { children: ReactNode; id: string; name: string; }) => JSX.Element >; export declare interface FieldProps { children: ReactElement; isCheckboxElement?: boolean; isMultipleElement?: boolean; translateProps?: (props: TranslateProps) => object; } export declare const FieldValue: MemoExoticComponent< ({ name }: { name: string }) => JSX.Element >; declare const enum FormChangeState { committed = "committed", staged = "staged", unchanged = "unchanged", } declare interface GroupValidation { fieldNames: string[]; groupNames: string[]; getErrorMessages: (props: { groups: Record< string, { groupId: string; groupName: string; groupString: string; } >; groupsString: string; reverseLookup: Record; validationType: ValidationType; values: Record; }) => Record; } declare interface IdentifierErrors { identifier: string; error: { errorMessages: ErrorMessage[]; symbol: symbol; }; } export declare const IfFieldErrorMessage: MemoExoticComponent< ({ children, fallback, getIsVisible, name, }: { children?: ReactNode; fallback?: ReactNode; getIsVisible?: | ((errorMessages: ErrorMessage | ErrorMessage[]) => boolean) | undefined; name: string; }) => JSX.Element >; export declare const IfFieldValue: MemoExoticComponent< ({ children, fallback, getIsVisible, name, }: { children?: ReactNode; fallback?: ReactNode; getIsVisible?: ((value: any) => boolean) | undefined; name: string; }) => JSX.Element >; export declare const IfFieldVisitation: MemoExoticComponent< ({ children, fallback, name, }: { children?: ReactNode; fallback?: ReactNode; name: string; }) => JSX.Element >; export declare const MaterialUiField: MemoExoticComponent< ({ children, ...otherProps }: FieldProps) => JSX.Element >; export declare type OnChangeHandler = (props: { fieldName: string; value: any; values: Record; }) => Record | void; export declare const OneForm: MemoExoticComponent< ({ children, errorMessages: rootErrorMessages, groupValidations: rootGroupValidations, hasFieldChangeValidation, onChange: rootOnChange, onSubmit: rootOnSubmit, updatedErrorMessages: rootUpdatedErrorMessages, updatedValues: rootUpdatedValues, validations: rootValidations, values: rootValues, }: OneFormProps) => JSX.Element >; export declare interface OneFormProps { children: ReactNode; errorMessages?: Record; groupValidations?: GroupValidation[]; hasFieldChangeValidation?: boolean; onChange?: OnChangeHandler; onSubmit?: OnSubmitHandler; updatedErrorMessages?: Record; updatedValues?: Record; validations?: Record; values?: Record; } export declare type OnSubmitHandler = Exclude< Exclude[0], undefined>["onSubmit"], undefined >; export declare type SetErrorMessagesFunction = ( identifier: string, errors: IdentifierErrors["error"] ) => void; export declare const Subfield: MemoExoticComponent< ({ children, }: SubfieldProps) => ReactElement> >; export declare interface SubfieldProps { children: ReactElement; } export declare const Subform: MemoExoticComponent< ({ errorMessages, groupValidations, onChange, onSubmit, updatedErrorMessages, updatedValues, validations, values, }: SubformProps) => null >; declare type SubformProps = Parameters[0]; declare const enum SubmissionStates { failedSubmission = "failedSubmission", invalidSubmission = "invalidSubmission", notSubmitted = "notSubmitted", pendingSubmission = "pendingSubmission", submitted = "submitted", } export declare const SubmitField: MemoExoticComponent< ({ children, fallback, getIsVisible, isDisabledWhenInvalid, }: SubmitFieldProps) => ReactElement< any, string | JSXElementConstructor > | null >; export declare interface SubmitFieldProps { children: ReactElement; fallback?: ReactElement; getIsVisible?: (props: { formChangeState: FormChangeState; isFormValid: boolean; isSubmitting: boolean; submissionState: SubmissionStates; totalErrorMessages: number; }) => boolean; isDisabledWhenInvalid?: boolean; } declare type Subscriber = (value: T) => Unsubscriber; export declare interface TranslateProps { errorMessages: string[]; fieldName: string; isChecked: boolean; isVisited: boolean; updateFieldValue: (event: SyntheticEvent | unknown) => void; value: any; visitField: (event: SyntheticEvent | unknown) => void; } declare type Unsubscriber = (() => void) | void; export declare const useField: ({ inputValue, isCheckboxElement, isMultipleElement, name, onChange, onVisit, }: UseFieldProps) => { errorMessages: string[]; fieldName: string; isChecked: boolean; isVisited: boolean; updateFieldValue: (event: SyntheticEvent | unknown) => void; value: any; visitField: (event: SyntheticEvent | unknown) => void; }; export declare const useFieldData: ({ name, }: { name: string; }) => { errorMessages: string[]; fieldName: string; isVisited: boolean; register: () => CleanupFunction; setErrorMessages: ( errorMessages: string | boolean | string[] | undefined ) => void; setValue: (value: T) => void; setVisited: () => void; value: T; }; export declare const useFieldErrorMessages: ({ name }: { name: string }) => { errorMessages: string[]; setErrorMessages: ( errorMessages: string | string[] | boolean | undefined ) => void; }; export declare const useFieldName: ({ name }: { name: string }) => { fieldName: string; }; export declare interface UseFieldProps { inputValue: string | undefined; isCheckboxElement: boolean; isMultipleElement: boolean; name: string; onChange: (event: SyntheticEvent | unknown) => void; onVisit: (event: SyntheticEvent | unknown) => void; } export declare const useFieldRegistration: ({ name }: { name: string }) => { register: () => CleanupFunction; }; export declare const useFieldValue: ({ name, }: { name: string; }) => { setValue: (value: T) => void; value: T; }; export declare const useFieldVisitation: ({ name }: { name: string }) => { isVisited: boolean; setVisited: () => void; }; export declare const useFormSubmission: ({ requiredFieldNames, }?: { requiredFieldNames?: string[] | undefined; }) => { formChangeState: FormChangeState; getAllFieldValues: () => Record; /** * @deprecated use `getErrors()` instead */ getErrorMessages: () => string[]; getErrors: () => Record; getRegisteredFieldValues: () => Record; isSubmitting: boolean; isValid: boolean; isValidForSubmission: boolean; isVisited: boolean; submissionState: SubmissionStates; submitForm: (event: SyntheticEvent) => void; totalErrorMessages: number; totalUnvisitedFields: number; totalVisitedFields: number; }; export declare const useIsCheckboxElement: ( reactElement: ReactElement ) => boolean; export declare const useIsMultipleElement: ( reactElement: ReactElement ) => boolean; export declare const useSubfield: ({ inputValue }: { inputValue: any }) => { isSelected: any; }; export declare const useSubformEffect: ({ errorMessages, groupValidations, onChange, onSubmit, updatedErrorMessages, updatedValues, validations, values, }: { errorMessages: Record; groupValidations: GroupValidation[]; onChange: OnChangeHandler; onSubmit: OnSubmitHandler; updatedErrorMessages: Record; updatedValues: Record; validations: Record; values: any[]; }) => void; declare const useSubmissionState: ({ getAllIdentifiers, getAllValues, getIsValid, onBeforeSubmit, onInvalidSubmit, onSubmit, }?: { getAllIdentifiers?: (() => Record) | undefined; getAllValues?: (() => Record) | undefined; getIsValid?: (() => boolean) | undefined; onBeforeSubmit?: (() => void) | undefined; onInvalidSubmit?: (() => void) | undefined; onSubmit?: | ((props: { allValues: Record; registeredValues: Record; }) => void | Promise) | undefined; }) => { formSubmitted: () => void; getSubmissionState: () => SubmissionStates; subscribeToSubmissionState: ( subscriber: Subscriber | undefined ) => Unsubscriber; }; declare const enum ValidationType { change = "change", submit = "submit", } export {};