1 | import { Component, ComponentType } from "react";
|
2 | import { Formatter, Parser, Validator, WrappedFieldProps } from "../index";
|
3 |
|
4 | export type FieldsWarnerOrValidator =
|
5 | | Validator
|
6 | | Validator[]
|
7 | | { [name: string]: Validator | Validator[] };
|
8 |
|
9 | interface 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 |
|
20 | export 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 |
|
28 | export 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 |
|
36 | interface WrappedFieldsProps {
|
37 | [name: string]: WrappedFieldsProps & WrappedFieldProps;
|
38 | }
|