import { FieldHookConfig } from 'formik'; import { FieldInputProps } from 'formik'; import { FormikHelpers } from 'formik'; import { FormikValues } from 'formik'; import { default as React_2 } from 'react'; import { ReactElement } from 'react'; export declare interface Address { isMilitaryBaseOutside?: boolean; country: string; streetAddress: string; streetAddressLine2?: string; streetAddressLine3?: string; city: string; state: string; postalCode: string; } /** * AddressField */ export declare const AddressField: (props: AddressProps) => JSX.Element; export declare type AddressProps = FieldProps & { legend: string; legendClasses: string; }; /** * The ArrayField accepts a template and a schema and renders them for each entry in whichever array field is * specified in props.name. This component provides a wrapper so end users do not * have to manage looping through their array, or working with Formik helpers, instead allowing them to * just focus on what their React components will look like. * * @param {ArrayFieldProps} props * * @returns - FieldArray component provided by Formik */ export declare const ArrayField: >(props: ArrayFieldProps) => JSX.Element; /** * The prop type for the Array Field Component * * * @param name - Name of the component * @param label - Label of the form * @param arrayFieldSchema - Schema of the type of the items in the array - an object * * with key value pairs * @param FieldArrayTemplate - JSX element template that is passed two parameters, the * * individual array item in the array field, and an index * @param minLength - optional minimum length of the array field * @param maxLength - optional maximum length of the array field * * @public */ export declare type ArrayFieldProps = FieldProps & { name: string; label: string; arrayFieldSchema: Record; FieldArrayTemplate: (props: { data: T; index: number; }) => React_2.ReactNode; minLength?: number; maxLength?: number; }; export declare const CapitalizeFirstLetter: (value: string) => string; export declare const chainArrayValidations: (props: ArrayFieldProps, validations: ValidationFunctionArray[]) => (value: T[]) => ValidationFunctionResult; export declare const chainValidations: (props: FieldProps, validations: ValidationFunction[]) => (value: T) => ValidationFunctionResult; /** * Renders the chapter contents * * @alpha */ export declare function Chapter(props: ChapterProps): JSX.Element; /** * The properties for the Chapter React component * * @alpha */ export declare interface ChapterProps { children: Array | any; title?: string; } /** * CheckboxField component is a simple form building component that displays a * checkbox for the user. * * @param {CheckboxProps} props * * @returns React.Component * * @remarks * A description can be passed in two different ways * 1 - Pass a string variable through the description prop * 2 - Inside a tag, create a child element * with a slot="description" attribute, while setting the * normal description prop to null. HTML can then be passed * through the slot and will render above the CheckboxField. */ export declare const CheckboxField: (props: CheckboxProps) => JSX.Element; export declare const CheckboxFieldGroup: (props: CheckboxGroupProps) => JSX.Element; export declare type CheckboxGroupProps = FieldProps & { options: CheckboxProps[]; }; export declare type CheckboxProps = FieldProps & { checked?: boolean; content?: string; description?: string | null; onValueChange?: (e: Event) => void; value?: boolean; }; export declare function ConditionalRoute(props: { title: string; condition: string; type: string; children: ReactElement; }): React_2.ReactElement; export declare const Countries: { value: string; label: string; }[]; export declare const CountryUSA: { value: string; label: string; }[]; export declare const DateField: (props: DateProps) => JSX.Element; export declare type DateProps = FieldProps & { isMemorableDate?: boolean; }; /** * Display the Formik state */ export declare const DebuggerView: () => JSX.Element; /** * Renders the EmailField component * * @public */ export declare const EmailField: (props: EmailProps) => JSX.Element; declare type EmailProps = FieldProps; export declare const emailRegex: RegExp; declare interface FieldObject { name: string; label: string; value?: boolean | string | undefined | number | null; options?: { label: string; value: string; }[]; type?: string; } export declare type FieldProps = Omit, 'required'> & { label: string; id?: string; onValueChange?: (e: Event) => void; /** * If `required` is true, the default message will be used. If `required` is a * string, it will be used as the error message. */ required?: boolean | string; }; export declare function FormFooter(): JSX.Element; /** * Manages form pages as routes * Parent formik insance is rendered here * @param {FormRouterProps} props * * @public */ export declare function FormRouter(props: FormRouterProps): JSX.Element; /** * The prop type for the Router React component * * * @param children - Component children * @param title - Title of the form * @param subtitle - An optional subtitle of the form * @param transformForSubmit - custom hook for transforming data before form submit * @param formData - Initial Formik data to be passed into the form from schema.js * @param uiFormData - Optional UI formik data that is not in schema.js to be * * added to formik initial validation * @param basename - router basename * * @public */ export declare interface FormRouterProps { children: ReactElement | ReactElement[]; title: string; subtitle?: string; transformForSubmit?: (values: FormikValues, actions: FormikHelpers) => any; formData: IFormData; uiFormData?: IFormData; basename: string; } /** * Form Title component is a simple wrapper * around a Form Title and subTitle using VA styles * * @param {FormTitleProps} props * * @example * Here's a simple example: * ```typescript * ; * ``` * * @returns React.Component */ export declare const FormTitle: (props: FormTitleProps) => JSX.Element; /** * FormTitle properties * * @example * ```json * { * title: 'My Example Title', * subTitle: 'My Example Sub Title for more information' * } * ``` */ export declare interface FormTitleProps { title: string; subTitle?: string; } export declare const FullNameField: (props: FullNameProps) => JSX.Element; /** * * @remarks * The `name` prop must be passed in FullNameField component as it is used as object name. * @example * Here's a simple example: * ``` * // * { * fullName: { * // fields * } * } * ``` * */ export declare type FullNameProps = FieldProps & { legend: string; legendClasses: string; }; export declare const FUTURE_DATE_MESSAGE = "Please provide a valid current or past date"; export declare const gatherFieldData: (listOfPages: PageObject[], field: FieldInputProps & { type?: string; }, props: typeList, currentPath: string) => PageObject[] | undefined; export declare function getMessage(messagePath: string): string; /** * The type for the FormData to define the flexible data object * * @public */ export declare interface IFormData { [prop: string]: unknown; } declare interface IPageContext { listOfPages: PageObject[]; setListOfPages: (pages: PageObject[]) => void; currentPath: string; } /** * Properties for Router Context * * @internal */ export declare interface IRouterContext { listOfRoutes: RouteInfo[]; currentRoute: string; previousRoute: string | null; nextRoute: string | null; } /** * This function is used to validate an date field and make sure it's not in the future * * @param dateString * @param props */ export declare const isValidDate: (dateString: T, props: FieldProps) => ValidationFunctionResult; /** * This function is used to validate an email address, while returning error messages if an email * is invalid. The logic is as follows: * * 1. Ensure the email address is a string. If it's not, return an error message * 2. Ensure that one of the following is true, else output an error message: * 2a. The field is not required -AND- the field has no entered value * 2b. The value in the field matches an email validation regular expression * * @param emailString * @param props */ export declare const isValidEmail: (emailString: T, props: FieldProps) => ValidationFunctionResult; export declare const isValidPhone: (phoneString: T, props: FieldProps) => ValidationFunctionResult; /** * Conditions for valid SSN from the original 1010ez pdf form: * '123456789' is not a valid SSN * A value where the first 3 digits are 0 is not a valid SSN * A value where the 4th and 5th digits are 0 is not a valid SSN * A value where the last 4 digits are 0 is not a valid SSN * A value with 3 digits, an optional -, 2 digits, an optional -, and 4 digits is a valid SSN * 9 of the same digits (e.g., '111111111') is not a valid SSN */ export declare const isValidSSN: (ssnString: T, props: FieldProps) => ValidationFunctionResult; export declare const maxLength: (value: T[], props: ArrayFieldProps) => ValidationFunctionResult; export declare const MilitaryCities: { label: string; value: string; }[]; export declare const MilitaryStates: { label: string; value: string; }[]; export declare const minLength: (value: T[], props: ArrayFieldProps) => ValidationFunctionResult; export declare const NumberField: (props: FieldProps) => JSX.Element; /** * OMBInfo properties * * @example * ``` * { * expDate: 'My Example Title' required * resBurden: 1 * ombNumber: '123-ABC' * } * ``` */ export declare interface OMBInfoProps { resBurden?: number; ombNumber?: string; expDate: string; } /** * Renders the page contents * * @public */ export declare function Page(props: PageProps): JSX.Element; export declare const PageContext: React_2.Context; declare interface PageContextProps { children: ReactElement | ReactElement[]; } export declare function PageContextProvider(props: PageContextProps): JSX.Element; declare interface PageObject { id: string; title: string; path: string; fields: FieldObject[]; fieldNames?: string[]; } /** * The properties for the Page React component * * @public */ export declare interface PageProps { children: JSX.Element | JSX.Element[] | Element; title: string; fieldNames?: string[]; hidePreviousButton?: boolean; nextButtonCustomText?: string; nextButtonDescribedBy?: string; } /** * A function to transform a dateString in the form yyyy-mm-dd into a javascript date object. This is necessary because * parsing the date string will result in a date one day before the expected value * * @param dateString */ export declare const parseDate: (dateString: string) => Date; /** * Renders the PhoneField component * * @public */ export declare const PhoneField: (props: PhoneProps) => JSX.Element; declare type PhoneProps = FieldProps; export declare interface ProgressBarProps { numberOfSteps: number; currentStep: number; stepTitle: string; } export declare function RadioGroup(props: RadioGroupProps): JSX.Element; export declare type RadioGroupProps = FieldProps & { name: string; options: RadioItemProps[]; onChange: (v: string) => void; }; export declare type RadioItemProps = { 'aria-describedby': string; label: string; name: string; value: string; onRadioOptionSelected: () => void; }; /** * Returns JSON string after removing all ui initial values. * * @param values - The object contains all the filled values as JSON string * @param uiInitialValues - The object initialized for ui validation contains list of key value pair. * */ export declare const removeUiInitialValues: (values: string, uiInitialValues: IFormData) => string; /** * Returns null if value is undefined, otherwise returns value * * @param value - The value can be of any type like string, boolean, object, number. * */ export declare const replaceUndefinedWithNull: (value: any) => unknown; export declare const required: (value: T, props: FieldProps) => ValidationFunctionResult; export declare const requiredLength: (value: T[], props: ArrayFieldProps) => ValidationFunctionResult; export declare function ReviewPage(props: { title: string; }): JSX.Element; /** * Indicates if a component can be routed using `react-router-dom`. The `path` * prop must be present. * * @public */ export declare interface Routable { path: string; } /** * Used for passing a list of routes into Router Context * * @public */ export declare interface RouteInfo { path: string; title: string; conditional?: boolean; isShown?: boolean | null; } export declare const RouterContext: React_2.Context; export declare interface RouterContextProps { routes: React.ReactElement | React.ReactElement[]; children: ReactElement | ReactElement[]; } export declare const SelectField: (props: SelectProps) => JSX.Element; export declare type SelectProps = FieldProps & { onVaSelect?: (e: CustomEvent) => void; children: HTMLOptionElement[] | unknown; }; /** * Renders the SSNField component * * @public */ export declare const SSNField: (props: SSNProps) => JSX.Element; declare type SSNProps = FieldProps; export declare const States: { CAN: { label: string; value: string; }[]; MEX: { label: string; value: string; }[]; USA: { label: string; value: string; }[]; }; export declare const States50AndDC: { label: string; value: string; }[]; /** * Returns the value after checking if its value is not undefined. * * @remarks * * @param key - The key is of type string * @param value - The value can be of any type like string, boolean, object, number. * */ export declare const StringifyFormReplacer: (key: string, value: any) => unknown; export declare const Suffixes: string[]; export declare const TextField: (props: FieldProps) => JSX.Element; /** * A function to transform a VA schema into a flattened, Formik compatible object * * @param schema */ export declare const transformJSONSchema: (schema: any) => {}; declare type typeList = RadioGroupProps | FieldProps | SelectProps; export declare const UsaStates: string[]; export declare type ValidationFunction = (value: T, props: FieldProps) => ValidationFunctionResult; export declare type ValidationFunctionArray = (value: T[], props: ArrayFieldProps) => ValidationFunctionResult; export declare type ValidationFunctionResult = void | undefined | string | Promise | T; export { }