Skip to content

Commit

Permalink
Merge pull request #472 from jaredhan418/master
Browse files Browse the repository at this point in the history
add more function types define.
  • Loading branch information
joepuzzo authored Apr 10, 2024
2 parents eb38a74 + 5b21310 commit 1dfe27f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -398,6 +403,17 @@ export function useConditional(params: {
native: boolean;
}): unknown;

export function useArrayField(params: {
name: string;
initialValue: any;
defaultValue: any;
arrayFieldApiRef: React.MutableRefObject<any>;
}): {
render: (children: any) => JSX.Element;
arrayFieldState: ArrayFieldState;
arrayFieldApi: ArrayFieldApi;
};

export function useArrayFieldApi(): ArrayFieldApi;

export function useArrayFieldItemApi(): ArrayFieldItemApi;
Expand All @@ -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<any>;
Expand Down
2 changes: 2 additions & 0 deletions src/components/ArrayField.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,6 @@ ArrayField.Items = ({ children }) => {
});
};

ArrayField.Items.displayName = 'ArrayField.Items';

export { ArrayField };

0 comments on commit 1dfe27f

Please sign in to comment.