import { Component, ComponentType } from "react";
import { Validator } from "../index";
interface _BaseFieldArrayProps
{
name: string;
component: ComponentType & P>;
validate?: Validator | Validator[] | undefined;
warn?: Validator | Validator[] | undefined;
withRef?: boolean | undefined;
rerenderOnEveryChange?: boolean | undefined;
}
export type BaseFieldArrayProps = (P | { props?: P }) & _BaseFieldArrayProps
;
export interface GenericFieldArray extends Component> {
name: string;
valid: boolean;
getRenderedComponent(): Component & P>;
}
export class FieldArray extends Component>
implements GenericFieldArray
{
name: string;
valid: boolean;
getRenderedComponent(): Component & P>;
}
export interface WrappedFieldArrayProps {
fields: FieldArrayFieldsProps;
meta: FieldArrayMetaProps;
}
export type FieldIterate = (
name: string,
index: number,
fields: FieldArrayFieldsProps,
) => R;
export interface FieldArrayFieldsProps {
forEach(callback: FieldIterate): void;
get(index: number): FieldValue;
getAll(): FieldValue[];
removeAll(): void;
insert(index: number, value: FieldValue): void;
name: string;
length: number;
map(callback: FieldIterate): R[];
pop(): FieldValue;
push(value: FieldValue): void;
remove(index: number): void;
shift(): FieldValue;
splice(index: number, removeNum: number | null, value: FieldValue): void;
swap(indexA: number, indexB: number): void;
move(from: number, to: number): void;
unshift(value: FieldValue): void;
}
export interface FieldArrayMetaProps {
dirty: boolean;
error?: any;
form: string;
invalid: boolean;
pristine: boolean;
submitFailed: boolean;
submitting: boolean;
valid: boolean;
warning?: any;
}