Created
March 1, 2018 08:49
-
-
Save danielkcz/094f799a1eaa3e2f214941645482a00c to your computer and use it in GitHub Desktop.
Crude typescript defintion for MRF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'mobx-react-form' { | |
export default MRF.MobxReactForm | |
} | |
type Dictionary<T> = { [key: string]: T } | |
declare namespace MRF { | |
class MobxReactForm { | |
constructor(options: MRF.Options, settings?: MRF.Settings) | |
isValid: boolean | |
get(field: string): string | |
set(obj: Dictionary<string>): void | |
$(selector: string): Field | |
onSubmit(): void | |
init(obj: Dictionary<string>): void | |
validate(): void | |
values(): Dictionary<string> | |
submit<T>(handlers: { onSuccess?: Handler; onError?: Handler }): Promise<T> | |
errors(): Dictionary<string> | |
select(path: string): Field | |
submitting: boolean | |
} | |
type Handler = (form: MobxReactForm) => void | Promise<any> | |
interface Field extends FieldSpec { | |
bind(): FieldSpec | |
} | |
interface FieldSpec { | |
name?: string | |
value?: string | |
label?: string | |
placeholder?: string | |
rules?: string | |
} | |
type FieldsDefinition = string[] | Dictionary<string | FieldSpec> | |
interface Options { | |
fields?: FieldsDefinition | |
values?: Dictionary<string> | |
} | |
interface Settings { | |
plugins?: { | |
dvr: any | |
} | |
hooks?: { | |
onSuccess(form: MobxReactForm): void | |
} | |
options?: {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment