UNPKG

@shopify/react-form-state

Version:

Manage React forms tersely and type-safely with no magic

25 lines 1.22 kB
import isEqual from 'fast-deep-equal'; import { FieldDescriptor } from './types'; export { isEqual }; export declare function mapObject<Input, Output>(input: Input, mapper: (value: any, key: keyof Input) => any): Output; export declare function push<T>(array: T[], ...values: T[]): T[]; export declare function remove<T>(array: T[], targetIndex: number): T[]; export declare function replace<T>(array: T[], targetIndex: number, newValue: T): T[]; export declare function set<InputType extends object>(rootObject: InputType, path: string[], value: any): any; export declare function flatMap<T>(array: any[], mapper: (item: any, index?: number) => T | T[]): T[]; /** * Transforms a boolean FieldDescriptor object to work with checkboxes and radios. * @param field */ export declare function asChoiceField({ value: checked, ...fieldData }: FieldDescriptor<boolean>): { onChange(newValue: boolean | import("./types").ValueMapper<boolean>): void; onBlur(): void; name: string; initialValue: boolean; dirty: boolean; changed: boolean; error?: any; checked: boolean; }; export declare type ChoiceFieldDescriptor = ReturnType<typeof asChoiceField>; //# sourceMappingURL=utilities.d.ts.map