///
import { CheckboxFieldProps, RadioGroupFieldProps, NumberFieldProps, PatternFieldProps } from '@superdispatch/ui';
import { FieldValidator, FormikValues, FormikConfig, FormikErrors, FormikContextType } from 'formik';
import { ChangeEvent, ForwardRefExoticComponent, RefAttributes, ReactNode, ReactElement, PropsWithChildren } from 'react';
import { DateFieldProps, DatePayload } from '@superdispatch/dates';
import { PhoneFieldProps, PhoneService } from '@superdispatch/phones';
import { ButtonBaseProps, StandardTextFieldProps } from '@material-ui/core';
interface FormikCheckboxFieldProps extends CheckboxFieldProps {
name: string;
validate?: FieldValidator;
format?: (value: unknown, checked: boolean | undefined) => boolean | undefined;
parse?: (event: ChangeEvent, checked: boolean) => unknown;
}
declare const FormikCheckboxField: ForwardRefExoticComponent;
interface FormikDateFieldProps extends Omit {
name: string;
validate?: (info: DatePayload) => void | string;
}
declare const FormikDateField: ForwardRefExoticComponent>;
interface FormikEnhancedConfig extends Omit, 'onSubmit'> {
/**
* Resets form when input value changes
*/
key?: unknown;
/**
* Override initial status type
*/
initialStatus?: FormikEnhancedStatus;
/**
* Extracts errors from the submission error
*/
getFormErrors?: (error: Error) => FormikErrors;
onSubmit: (values: TValues) => TResponse | PromiseLike;
onSubmitSuccess?: (response: TResponse, values: TValues) => void;
onSubmitFailure?: (error: Error, values: TValues) => void;
}
declare type FormikEnhancedStatus = {
type: 'initial';
payload?: undefined;
} | {
type: 'submitted';
payload: TResponse;
} | {
type: 'rejected';
payload: Error;
};
interface FormikContextTypeEnhanced extends FormikContextType {
status: FormikEnhancedStatus;
setStatus: (status: FormikEnhancedStatus) => void;
}
declare function useFormikEnhanced({ key, onSubmit, onSubmitSuccess, onSubmitFailure, getFormErrors: getFormErrorsOption, enableReinitialize, initialStatus, ...config }: FormikEnhancedConfig): FormikContextTypeEnhanced;
interface FormikEnhancedProps extends FormikEnhancedConfig {
children?: ReactNode | ((formik: FormikContextTypeEnhanced) => ReactNode);
}
declare function FormikEnhanced({ children, ...config }: FormikEnhancedProps): null | ReactElement;
interface FormsContext {
getFormErrors?: (error: unknown) => FormikErrors;
}
declare function useFormsContext(): FormsContext;
declare function FormsProvider({ children, getFormErrors, }: PropsWithChildren): ReactElement;
interface FormikPhoneFieldProps extends Omit {
name: string;
validate?: (value: unknown, service: PhoneService) => string | void | Promise;
}
declare const FormikPhoneField: ForwardRefExoticComponent>;
interface SuspendedFormikPhoneFieldProps extends FormikPhoneFieldProps {
suspenseFallback?: ReactNode;
}
declare const SuspendedFormikPhoneField: ForwardRefExoticComponent>;
interface FormikRadioCardFieldProps extends Omit {
name: string;
value: string;
label: string;
caption?: string;
icon?: React.ReactNode;
}
declare const FormikRadioCardField: ForwardRefExoticComponent;
interface FormikRadioGroupFieldProps extends Omit {
name: string;
validate?: FieldValidator;
}
declare const FormikRadioGroupField: ForwardRefExoticComponent;
declare const EMPTY_ERROR_MESSAGE = "EMPTY_ERROR_MESSAGE";
declare type NumberValue = number | undefined;
interface FormikCurrencyFieldProps extends NumberFieldProps {
name: string;
validate?: FieldValidator;
format?: (value: NumberValue) => NumberValue;
parse?: (value: NumberValue) => NumberValue;
formatError?: (error: string) => ReactNode;
}
declare const FormikCurrencyField: ForwardRefExoticComponent;
interface FormikTextFieldProps extends StandardTextFieldProps {
name: string;
validate?: FieldValidator;
formatError?: (error: string) => ReactNode;
format?: (value: any) => string;
parse?: (event: ChangeEvent) => unknown;
}
declare const FormikTextField: ForwardRefExoticComponent;
interface Props extends FormikTextFieldProps {
maxLength?: number;
}
declare const FormikMaxLengthTextField: ForwardRefExoticComponent;
interface FormikNumberFieldProps extends NumberFieldProps {
name: string;
validate?: FieldValidator;
formatError?: (error: string) => ReactNode;
}
declare const FormikNumberField: ForwardRefExoticComponent;
declare const FormikPasswordField: ForwardRefExoticComponent;
interface FormikPatternFieldProps extends PatternFieldProps {
name: string;
validate?: FieldValidator;
formatError?: (error: string) => ReactNode;
}
declare const FormikPatternField: ForwardRefExoticComponent;
export { EMPTY_ERROR_MESSAGE, FormikCheckboxField, FormikCheckboxFieldProps, FormikContextTypeEnhanced, FormikCurrencyField, FormikCurrencyFieldProps, FormikDateField, FormikDateFieldProps, FormikEnhanced, FormikEnhancedConfig, FormikEnhancedProps, FormikEnhancedStatus, FormikMaxLengthTextField, FormikNumberField, FormikNumberFieldProps, FormikPasswordField, FormikPatternField, FormikPatternFieldProps, FormikPhoneField, FormikRadioCardField, FormikRadioCardFieldProps, FormikRadioGroupField, FormikRadioGroupFieldProps, FormikTextField, FormikTextFieldProps, FormsContext, FormsProvider, SuspendedFormikPhoneField, SuspendedFormikPhoneFieldProps, useFormikEnhanced, useFormsContext };