UNPKG

1.24 kBTypeScriptView Raw
1import { Component, ComponentType } from "react";
2import { Formatter, Parser, Validator, WrappedFieldProps } from "../index";
3
4export type FieldsWarnerOrValidator =
5 | Validator
6 | Validator[]
7 | { [name: string]: Validator | Validator[] };
8
9interface BaseFieldsProps<P = {}> {
10 names: string[];
11 component?: ComponentType<any> | undefined;
12 format?: Formatter | null | undefined;
13 props?: P | undefined;
14 parse?: Parser | undefined;
15 forwardRef?: boolean | undefined;
16 validate?: FieldsWarnerOrValidator | undefined;
17 warn?: FieldsWarnerOrValidator | undefined;
18}
19
20export interface GenericFields<P> extends Component<BaseFieldsProps<P> & P> {
21 dirty: boolean;
22 names: string[];
23 pristine: boolean;
24 values: { [name: string]: any };
25 getRenderedComponent(): Component<BaseFieldsProps & WrappedFieldsProps & P>;
26}
27
28export class Fields<P = {}> extends Component<BaseFieldsProps<P> & P> implements GenericFields<P> {
29 dirty: boolean;
30 names: string[];
31 pristine: boolean;
32 values: { [name: string]: any };
33 getRenderedComponent(): Component<BaseFieldsProps & WrappedFieldsProps & P>;
34}
35
36interface WrappedFieldsProps {
37 [name: string]: WrappedFieldsProps & WrappedFieldProps;
38}