import * as React from 'react'; import { PathMatchingValue } from './helpers/path-helpers'; import { FieldMetaProps, FormikApi } from './types'; export declare type TypedFieldArray = (props: FieldArrayConfig) => React.ReactElement | null; export interface UseFieldArrayConfig { /** Really the path to the array field to be updated */ name: PathMatchingValue; /** Should field array validate the form AFTER array updates/changes? */ validateOnChange?: boolean; } export interface ArrayHelpers { /** Imperatively add a value to the end of an array */ push: (obj: Value) => void; /** Curried fn to add a value to the end of an array */ handlePush: (obj: Value) => () => void; /** Imperatively swap two values in an array */ swap: (indexA: number, indexB: number) => void; /** Curried fn to swap two values in an array */ handleSwap: (indexA: number, indexB: number) => () => void; /** Imperatively move an element in an array to another index */ move: (from: number, to: number) => void; /** Imperatively move an element in an array to another index */ handleMove: (from: number, to: number) => () => void; /** Imperatively insert an element at a given index into the array */ insert: (index: number, value: Value) => void; /** Curried fn to insert an element at a given index into the array */ handleInsert: (index: number, value: Value) => () => void; /** Imperatively replace a value at an index of an array */ replace: (index: number, value: Value) => void; /** Curried fn to replace an element at a given index into the array */ handleReplace: (index: number, value: Value) => () => void; /** Imperatively add an element to the beginning of an array and return its length */ unshift: (value: Value) => number; /** Curried fn to add an element to the beginning of an array */ handleUnshift: (value: Value) => () => void; /** Curried fn to remove an element at an index of an array */ handleRemove: (index: number) => () => void; /** Curried fn to remove a value from the end of the array */ handlePop: () => () => void; /** Imperatively remove and element at an index of an array */ remove(index: number): Value | undefined; /** Imperatively remove and return value from the end of the array */ pop(): Value | undefined; } export declare type FieldArrayProps = ArrayHelpers & { form: FormikApi; field: FieldMetaProps; name: PathMatchingValue; }; export declare type FieldArrayConfig = UseFieldArrayConfig & { /** * Field component to render. Can either be a string like 'select' or a component. */ component?: React.ComponentType>; /** * Render prop (works like React router's } />) */ render?: (props: FieldArrayProps) => React.ReactElement | null; /** * Children render function {props => ...}) */ children?: (props: FieldArrayProps) => React.ReactElement | null; };