UNPKG

646 BTypeScriptView Raw
1import { Decorator } from 'final-form'
2
3export type FieldName = string
4
5export type FieldPattern = FieldName | RegExp | FieldName[]
6
7export type UpdatesByName = {
8 [FieldName: string]: (value: any, allValues?: Object, prevValues?: Object) => any
9}
10
11export type UpdatesForAll = (
12 value: any,
13 field: string,
14 allValues?: Object,
15 prevValues?: Object,
16) => { [FieldName: string]: any }
17
18export type Updates = UpdatesByName | UpdatesForAll
19
20export type Calculation = {
21 field: FieldPattern,
22 updates: Updates,
23 isEqual?: (a: any, b: any) => boolean,
24}
25
26export default function createDecorator(
27 ...calculations: Calculation[]
28): Decorator
29
\No newline at end of file