Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

formstate

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formstate - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.vscode/settings.json

3

CHANGELOG.md

@@ -0,1 +1,4 @@

# 1.3.0
* `.compose`d `FormState` should run its `validators` as soon as all sub fields have been *validated*. Previously it only ran when sub fields where *validated* and *changed*. This shouldn't cause any need for a refactor as normally `.validate` is only called after a user interaction with fields. [ref](https://github.com/formstate/formstate/issues/66)
# 1.2.0

@@ -2,0 +5,0 @@ * `enableAutoValidation` `enableAutoValidationAndValidate` `disableAutoValidation` functions on `FormState` should consistently always toggle the `autoValidation` state for *both* itself and its children. [ref](https://github.com/formstate/formstate/issues/67)

8

lib/core/fieldState.d.ts

@@ -108,8 +108,8 @@ import { ComposibleValidatable, Validator } from './types';

*/
on$ChangeAfterValidation: () => void;
on$Reinit: () => void;
setCompositionParent: (config: {
on$ChangeAfterValidation: () => void;
_on$ValidationPass: () => void;
_on$Reinit: () => void;
_setCompositionParent: (config: {
on$ValidationPass: () => void;
on$Reinit: () => void;
}) => void;
}

@@ -119,3 +119,3 @@ "use strict";

_this.$ = value;
_this.on$Reinit();
_this._on$Reinit();
_this.executeOnUpdate();

@@ -157,8 +157,10 @@ };

var hasError = _this.hasError;
/** If no error, copy over the value to validated value */
/** If no error */
if (!hasError) {
/** Copy over the value to validated value */
if (_this.$ !== value) {
_this.$ = value;
_this.on$ChangeAfterValidation();
}
/** Trigger any form level validations if required */
_this._on$ValidationPass();
}

@@ -196,7 +198,7 @@ /** before returning update */

*/
this.on$ChangeAfterValidation = function () { };
this.on$Reinit = function () { };
this.setCompositionParent = function (config) {
_this.on$ChangeAfterValidation = function () { return mobx_1.runInAction(config.on$ChangeAfterValidation); };
_this.on$Reinit = function () { return mobx_1.runInAction(config.on$Reinit); };
this._on$ValidationPass = function () { };
this._on$Reinit = function () { };
this._setCompositionParent = function (config) {
_this._on$ValidationPass = function () { return mobx_1.runInAction(config.on$ValidationPass); };
_this._on$Reinit = function () { return mobx_1.runInAction(config.on$Reinit); };
};

@@ -310,5 +312,5 @@ mobx_1.runInAction(function () {

mobx_1.action
], FieldState.prototype, "setCompositionParent", void 0);
], FieldState.prototype, "_setCompositionParent", void 0);
return FieldState;
}());
exports.FieldState = FieldState;

@@ -97,8 +97,8 @@ import { ComposibleValidatable, Validator } from './types';

compose(): this;
on$ChangeAfterValidation: () => void;
on$Reinit: () => void;
setCompositionParent: (config: {
on$ChangeAfterValidation: () => void;
_on$ValidationPass: () => void;
_on$Reinit: () => void;
_setCompositionParent: (config: {
on$ValidationPass: () => void;
on$Reinit: () => void;
}) => void;
}

@@ -105,7 +105,7 @@ "use strict";

this.validatedSubFields = [];
this.on$ChangeAfterValidation = function () { };
this.on$Reinit = function () { };
this.setCompositionParent = function (config) {
_this.on$ChangeAfterValidation = function () { return mobx_1.runInAction(config.on$ChangeAfterValidation); };
_this.on$Reinit = function () { return mobx_1.runInAction(config.on$Reinit); };
this._on$ValidationPass = function () { };
this._on$Reinit = function () { };
this._setCompositionParent = function (config) {
_this._on$ValidationPass = function () { return mobx_1.runInAction(config.on$ValidationPass); };
_this._on$Reinit = function () { return mobx_1.runInAction(config.on$Reinit); };
};

@@ -156,3 +156,3 @@ this.mode = mobx_1.isArrayLike($) ? 'array' : utils_1.isMapLike($) ? 'map' : 'object';

}
_this.on$ChangeAfterValidation();
_this._on$ValidationPass();
return { hasError: false, value: _this.$ };

@@ -248,7 +248,7 @@ });

var values = this.getValues();
values.forEach(function (value) { return value.setCompositionParent({
values.forEach(function (value) { return value._setCompositionParent({
on$Reinit: mobx_1.action(function () {
_this.validatedSubFields = _this.validatedSubFields.filter(function (v) { return v !== value; });
}),
on$ChangeAfterValidation: mobx_1.action(function () {
on$ValidationPass: mobx_1.action(function () {
/** Always clear the form error as its no longer relevant */

@@ -337,5 +337,5 @@ if (_this.hasFormError) {

mobx_1.action
], FormState.prototype, "setCompositionParent", void 0);
], FormState.prototype, "_setCompositionParent", void 0);
return FormState;
}());
exports.FormState = FormState;

@@ -40,9 +40,9 @@ /** A truthy string or falsy values */

/** Used to tell the parent about validation */
on$ChangeAfterValidation: () => void;
on$Reinit: () => void;
_on$ValidationPass: () => void;
_on$Reinit: () => void;
/** Used by the parent to register listeners */
setCompositionParent: (config: {
on$ChangeAfterValidation: () => void;
_setCompositionParent: (config: {
on$ValidationPass: () => void;
on$Reinit: () => void;
}) => void;
}
{
"name": "formstate",
"version": "1.2.0",
"version": "1.3.0",
"description": "Painless and simple MobX form management",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -157,3 +157,3 @@ import { observable, action, computed, runInAction } from 'mobx';

this.$ = value;
this.on$Reinit();
this._on$Reinit();
this.executeOnUpdate();

@@ -206,8 +206,10 @@ }

/** If no error, copy over the value to validated value */
/** If no error */
if (!hasError) {
/** Copy over the value to validated value */
if (this.$ !== value) {
this.$ = value;
this.on$ChangeAfterValidation()
}
/** Trigger any form level validations if required */
this._on$ValidationPass();
}

@@ -249,11 +251,11 @@

*/
on$ChangeAfterValidation = () => { }
on$Reinit = () => { }
@action setCompositionParent = (config: {
on$ChangeAfterValidation: () => void;
_on$ValidationPass = () => { }
_on$Reinit = () => { }
@action _setCompositionParent = (config: {
on$ValidationPass: () => void;
on$Reinit: () => void;
}) => {
this.on$ChangeAfterValidation = () => runInAction(config.on$ChangeAfterValidation);
this.on$Reinit = () => runInAction(config.on$Reinit);
this._on$ValidationPass = () => runInAction(config.on$ValidationPass);
this._on$Reinit = () => runInAction(config.on$Reinit);
}
}

@@ -82,3 +82,3 @@ import { action, computed, isArrayLike, isObservable, observable, runInAction } from 'mobx';

this.on$ChangeAfterValidation();
this._on$ValidationPass();
return { hasError: false as false, value: this.$ };

@@ -183,3 +183,3 @@ });

const values = this.getValues();
values.forEach(value => value.setCompositionParent(
values.forEach(value => value._setCompositionParent(
{

@@ -189,3 +189,3 @@ on$Reinit: action(() => {

}),
on$ChangeAfterValidation: action(() => {
on$ValidationPass: action(() => {
/** Always clear the form error as its no longer relevant */

@@ -220,11 +220,11 @@ if (this.hasFormError) {

on$ChangeAfterValidation = () => { }
on$Reinit = () => { }
@action setCompositionParent = (config: {
on$ChangeAfterValidation: () => void;
_on$ValidationPass = () => { }
_on$Reinit = () => { }
@action _setCompositionParent = (config: {
on$ValidationPass: () => void;
on$Reinit: () => void;
}) => {
this.on$ChangeAfterValidation = () => runInAction(config.on$ChangeAfterValidation);
this.on$Reinit = () => runInAction(config.on$Reinit);
this._on$ValidationPass = () => runInAction(config.on$ValidationPass);
this._on$Reinit = () => runInAction(config.on$Reinit);
}
}

@@ -91,10 +91,10 @@ import { isPromiseLike } from "../internal/utils"

/** Used to tell the parent about validation */
on$ChangeAfterValidation: () => void;
on$Reinit: () => void;
_on$ValidationPass: () => void;
_on$Reinit: () => void;
/** Used by the parent to register listeners */
setCompositionParent: (config: {
on$ChangeAfterValidation: () => void;
_setCompositionParent: (config: {
on$ValidationPass: () => void;
on$Reinit: () => void;
}) => void;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc