-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathindex.d.ts
More file actions
28 lines (21 loc) · 706 Bytes
/
index.d.ts
File metadata and controls
28 lines (21 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Decorator } from 'final-form'
export type FieldName = string
export type FieldPattern = FieldName | RegExp | (FieldName | RegExp)[]
export type UpdatesByName<T> = {
[FieldName: string]: (value: any, allValues?: T, prevValues?: T) => any
}
export type UpdatesForAll<T> = (
value: T[keyof T],
field: string,
allValues?: T,
prevValues?: T
) => { [FieldName: string]: any }
export type Updates<T> = UpdatesByName<T> | UpdatesForAll<T>
export type Calculation<T extends object = Object> = {
field: FieldPattern
updates: Updates<T>
isEqual?: (a: any, b: any) => boolean
}
export default function createDecorator<T extends Object>(
...calculations: Calculation<T>[]
): Decorator