mobx-easy-form
Version:
Simple and performant form library built with MobX
32 lines (31 loc) • 1.01 kB
TypeScript
import type { Field } from "./createField";
export declare type OnSubmitArg = {
fields: Record<string, Field<any>>;
rawValues: Record<string, any>;
values: Record<string, any>;
};
export declare type OnSubmitFn = (props: OnSubmitArg) => any;
export declare type CreateFormArgs = {
onSubmit: OnSubmitFn;
};
export declare type Form = ReturnType<typeof createForm>;
export declare function createForm({ onSubmit }: CreateFormArgs): {
fields: Record<string, Field<any, any>>;
state: {
isSubmitting: boolean;
valuesAtLastSubmit: string | undefined;
submitCount: number;
};
computed: {
readonly isDirty: boolean;
readonly errorList: (string | undefined)[];
readonly isError: boolean;
readonly isValid: boolean;
readonly valueList: string;
readonly isChangedSinceLastSubmit: boolean;
};
actions: {
add(field: Field<any>): void;
submit: () => any;
};
};