UNPKG

@shopify/react-form-state

Version:
25 lines (24 loc) 715 B
export interface FieldState<Value> { name: string; initialValue: Value; value: Value; dirty: boolean; changed: boolean; error?: any; } export interface ValidationFunction<Value, Fields> { (value: Value, fields: FieldStates<Fields>): any; } export interface FieldDescriptor<Value> extends FieldState<Value> { onChange(newValue: Value | ValueMapper<Value>): void; onBlur(): void; } export declare type FieldDescriptors<Fields> = { [FieldPath in keyof Fields]: FieldDescriptor<Fields[FieldPath]>; }; export interface ValueMapper<Value> { (value: Value): Value; } export declare type FieldStates<Fields> = { [FieldPath in keyof Fields]: FieldState<Fields[FieldPath]>; };