diff --git a/index.d.ts b/index.d.ts index b0b036e3..badaf697 100644 --- a/index.d.ts +++ b/index.d.ts @@ -133,6 +133,11 @@ export type MultistepState = { previousStep: string; }; +export type ArrayFieldState = { + fields: any[]; + name: string; +} + export type ArrayFieldApi = { add: (amount?: number) => void; remove: (index: number) => void; @@ -398,6 +403,17 @@ export function useConditional(params: { native: boolean; }): unknown; +export function useArrayField(params: { + name: string; + initialValue: any; + defaultValue: any; + arrayFieldApiRef: React.MutableRefObject; +}): { + render: (children: any) => JSX.Element; + arrayFieldState: ArrayFieldState; + arrayFieldApi: ArrayFieldApi; +}; + export function useArrayFieldApi(): ArrayFieldApi; export function useArrayFieldItemApi(): ArrayFieldItemApi; @@ -423,7 +439,7 @@ declare function ArrayField({ initialValue, arrayFieldApiRef }: { - children: (arrayFieldItemApi: ArrayFieldApi) => JSX.Element; + children: (arrayFieldApi: ArrayFieldApi & ArrayFieldState) => JSX.Element; name: string; initialValue?: [unknown]; arrayFieldApiRef?: React.MutableRefObject; diff --git a/src/components/ArrayField.js b/src/components/ArrayField.js index f269c936..2a62794c 100644 --- a/src/components/ArrayField.js +++ b/src/components/ArrayField.js @@ -238,4 +238,6 @@ ArrayField.Items = ({ children }) => { }); }; +ArrayField.Items.displayName = 'ArrayField.Items'; + export { ArrayField };