mobx-react-form
Advanced tools
Comparing version 6.3.6 to 6.3.7
@@ -22,3 +22,3 @@ import { ObservableMap } from "mobx"; | ||
execHook: (name: string, fallback?: any) => any; | ||
execHandler: (name: string, args: any, fallback?: any, hook?: any) => any; | ||
execHandler: (name: string, args: any, fallback?: any, hook?: any, execHook?: boolean) => any; | ||
get resetting(): boolean; | ||
@@ -25,0 +25,0 @@ get clearing(): boolean; |
@@ -109,7 +109,7 @@ "use strict"; | ||
writable: true, | ||
value: (name, args, fallback = null, hook = null) => [ | ||
value: (name, args, fallback = null, hook = null, execHook = true) => [ | ||
(0, utils_1.$try)(this.$handlers[name] && this.$handlers[name].apply(this, [this]), this.handlers && | ||
this.handlers.apply(this, [this])[name] && | ||
this.handlers.apply(this, [this])[name].apply(this, [this]), fallback, this.noop).apply(this, [...args]), | ||
this.execHook(hook || name), | ||
execHook && this.execHook(hook || name), | ||
] | ||
@@ -172,4 +172,4 @@ }); | ||
(0, utils_1.isEvent)(e) && e.preventDefault(); | ||
this.submit(o, { execOnSubmitHook: false }); | ||
}) | ||
this.submit(o); | ||
}, null, false) | ||
}); | ||
@@ -356,3 +356,4 @@ /** | ||
submit(hooks = {}, { execOnSubmitHook = true, execValidationHooks = true, validate = true } = {}) { | ||
execOnSubmitHook && this.execHook(FieldProps_1.FieldPropsEnum.onSubmit, hooks); | ||
const execOnSubmit = () => this.execHook(FieldProps_1.FieldPropsEnum.onSubmit, hooks); | ||
const submit = execOnSubmitHook ? execOnSubmit() : undefined; | ||
this.$submitting = true; | ||
@@ -362,4 +363,8 @@ this.$submitted += 1; | ||
return Promise | ||
.resolve(this) | ||
.resolve(submit) | ||
.then((0, mobx_1.action)(() => (this.$submitting = false))) | ||
.catch((0, mobx_1.action)((err) => { | ||
this.$submitting = false; | ||
throw err; | ||
})) | ||
.then(() => this); | ||
@@ -376,3 +381,3 @@ } | ||
if (isValid) | ||
return handler; | ||
return Promise.all([submit, handler]); | ||
const $err = this.state.options.get(OptionsModel_1.OptionsEnum.defaultGenericError, this); | ||
@@ -382,5 +387,4 @@ const $throw = this.state.options.get(OptionsModel_1.OptionsEnum.submitThrowsError, this); | ||
this.invalidate(); | ||
return handler; | ||
return Promise.all([submit, handler]); | ||
}) | ||
// eslint-disable-next-line | ||
.then((0, mobx_1.action)(() => (this.$submitting = false))) | ||
@@ -387,0 +391,0 @@ .catch((0, mobx_1.action)((err) => { |
{ | ||
"name": "mobx-react-form", | ||
"license": "MIT", | ||
"version": "6.3.6", | ||
"version": "6.3.7", | ||
"author": "Claudio Savino <claudio.savino@me.com> (https://twitter.com/foxhound87)", | ||
@@ -6,0 +6,0 @@ "description": "Automagically manage React forms state and automatic validation with MobX.", |
@@ -192,13 +192,4 @@ | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/0/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/0/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/1/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/1/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/2/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/2/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/3/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/3/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/4/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/4/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/5/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/5/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/6/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/6/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/7/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/7/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/8/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/8/avatar.svg"></a> | ||
<a href="https://opencollective.com/mobx-react-form/sponsor/9/website" target="_blank"><img src="https://opencollective.com/mobx-react-form/sponsor/9/avatar.svg"></a> | ||
<img src="https://opencollective.com/mobx-react-form/sponsors.svg"/> | ||
@@ -105,3 +105,3 @@ import { | ||
execHandler = (name: string, args: any, fallback: any = null, hook = null): any => [ | ||
execHandler = (name: string, args: any, fallback: any = null, hook = null, execHook = true): any => [ | ||
$try( | ||
@@ -115,3 +115,3 @@ this.$handlers[name] && this.$handlers[name].apply(this, [this]), | ||
).apply(this, [...args]), | ||
this.execHook(hook || name), | ||
execHook && this.execHook(hook || name), | ||
]; | ||
@@ -205,4 +205,4 @@ | ||
isEvent(e) && e.preventDefault(); | ||
this.submit(o, { execOnSubmitHook: false }); | ||
}); | ||
this.submit(o); | ||
}, null, false); | ||
@@ -342,3 +342,4 @@ /** | ||
} = {}): Promise<any> { | ||
execOnSubmitHook && this.execHook(FieldPropsEnum.onSubmit, hooks); | ||
const execOnSubmit = () => this.execHook(FieldPropsEnum.onSubmit, hooks); | ||
const submit = execOnSubmitHook ? execOnSubmit() : undefined; | ||
this.$submitting = true; | ||
@@ -349,5 +350,11 @@ this.$submitted += 1; | ||
return Promise | ||
.resolve(this) | ||
.resolve(submit) | ||
.then(action(() => (this.$submitting = false))) | ||
.then(() => this); | ||
.catch( | ||
action((err: any) => { | ||
this.$submitting = false; | ||
throw err; | ||
}) | ||
) | ||
.then(() => this) | ||
} | ||
@@ -365,9 +372,8 @@ | ||
const handler = execValidationHooks ? exec(isValid) : undefined; | ||
if (isValid) return handler; | ||
if (isValid) return Promise.all([submit, handler]); | ||
const $err = this.state.options.get(OptionsEnum.defaultGenericError, this); | ||
const $throw = this.state.options.get(OptionsEnum.submitThrowsError, this); | ||
if ($throw && $err) (this as any).invalidate(); | ||
return handler; | ||
return Promise.all([submit, handler]); | ||
}) | ||
// eslint-disable-next-line | ||
.then(action(() => (this.$submitting = false))) | ||
@@ -374,0 +380,0 @@ .catch( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1204753
13913
195