New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.0.2 to 1.1.0

7

CHANGELOG.md

@@ -0,6 +1,9 @@

# 1.1.0
* Added support for `Map` in `FormState` class.
# 1.0.1
* Fixed `Cannot assign to read only property 'on$ChangeAfterValidation'`. This is due to a breaking change in MobX.
* Fixed `Cannot assign to read only property 'on$ChangeAfterValidation'`. This is due to a breaking change in MobX.
# 1.0.0
* 🎉 1.0.0
* 🎉 1.0.0
* `FieldState.reinitValue` is now called `reset`. `reset` is also an operation supported on `FormState` and resets all the sub fields. ([commit](https://github.com/formstate/formstate/commit/5e6eefbe3fd8843740a905d98d6767ee35ad4963))

@@ -11,1 +11,7 @@ # Setup

* Edit `demo/README.md`
# Releasing
* Think if your change is `major (breaking api) / minor (potentially breaking but you tried your best not to) / patch (safe)`.
* See current version in `package.json` and update `CHANGELOG.md` adding the *planned release version* notes.
* Commit all your changes (including changelog)
* Run `npm version major|minor|patch`. It will automatically push to bamboo and bamboo will pulish to nexus.

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

*/
var FieldState = (function () {
var FieldState = /** @class */ (function () {
function FieldState(_initValue) {

@@ -20,0 +20,0 @@ var _this = this;

@@ -5,3 +5,7 @@ import { ComposibleValidatable, Validator } from './types';

[key: string]: ComposibleValidatable<any>;
} | ComposibleValidatable<any>[];
}
/** Mode: array */
| ComposibleValidatable<any>[]
/** Mode: map */
| Map<any, ComposibleValidatable<any>>;
/**

@@ -15,8 +19,8 @@ * Just a wrapper around the helpers for a set of FieldStates or FormStates

$: TValue;
protected mode: 'array' | 'map';
protected mode: 'object' | 'array' | 'map';
constructor(
/**
* SubItems can be any Validatable
*/
$: TValue);
/**
* SubItems can be any Validatable
*/
$: TValue);
/** Get validatable objects from $ */

@@ -23,0 +27,0 @@ protected getValues: () => ComposibleValidatable<any>[];

@@ -23,4 +23,4 @@ "use strict";

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -46,2 +46,3 @@ case 0: case 1: t = op; break;

var mobx_1 = require("mobx");
var utils_1 = require("../internal/utils");
var types_1 = require("./types");

@@ -51,11 +52,11 @@ /**

*/
var FormState = (function () {
var FormState = /** @class */ (function () {
function FormState(
/**
* SubItems can be any Validatable
*/
$) {
/**
* SubItems can be any Validatable
*/
$) {
var _this = this;
this.$ = $;
this.mode = 'map';
this.mode = 'object';
/** Get validatable objects from $ */

@@ -65,2 +66,4 @@ this.getValues = function () {

return _this.$;
if (_this.mode === 'map')
return Array.from(_this.$.values());
var keys = Object.keys(_this.$);

@@ -111,3 +114,3 @@ return keys.map(function (key) { return _this.$[key]; });

};
this.mode = mobx_1.isArrayLike($) ? 'array' : 'map';
this.mode = mobx_1.isArrayLike($) ? 'array' : utils_1.isMapLike($) ? 'map' : 'object';
/** If they didn't send in something observable make the local $ observable */

@@ -125,4 +128,4 @@ if (!mobx_1.isObservable(this.$)) {

return __awaiter(this, void 0, void 0, function () {
var values, fieldsResult, done, error, res;
var _this = this;
var values, fieldsResult, done, error, res;
return __generator(this, function (_a) {

@@ -267,3 +270,5 @@ switch (_a.label) {

!_this.hasFieldError
/** And there isn't an active validation taking place */
&& !_this.validating
/** And all subfields are validated */
&& !_this.getValues().some(function (value) { return _this.validatedSubFields.indexOf(value) === -1; })) {

@@ -270,0 +275,0 @@ _this.validate();

@@ -12,4 +12,4 @@ import { Validatable, Validator } from './types';

constructor(
/** It is a function as fields can change over time */
getFields: () => TValue);
/** It is a function as fields can change over time */
getFields: () => TValue);
validating: boolean;

@@ -16,0 +16,0 @@ protected _validators: Validator<TValue>[];

@@ -23,4 +23,4 @@ "use strict";

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -50,6 +50,6 @@ case 0: case 1: t = op; break;

*/
var FormStateLazy = (function () {
var FormStateLazy = /** @class */ (function () {
function FormStateLazy(
/** It is a function as fields can change over time */
getFields) {
/** It is a function as fields can change over time */
getFields) {
var _this = this;

@@ -81,4 +81,4 @@ this.getFields = getFields;

return __awaiter(this, void 0, void 0, function () {
var values, fieldsResult, done, error, res;
var _this = this;
var values, fieldsResult, done, error, res;
return __generator(this, function (_a) {

@@ -85,0 +85,0 @@ switch (_a.label) {

export declare function debounce<T extends Function>(func: T, milliseconds: number, immediate?: boolean): T;
export declare function isMapLike(thing: any): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
/**

@@ -41,1 +42,6 @@ * Debounce

;
function isMapLike(thing) {
return mobx_1.isObservableMap(thing)
|| (typeof Map !== 'undefined' && thing instanceof Map);
}
exports.isMapLike = isMapLike;

@@ -12,4 +12,4 @@ "use strict";

{ cmd: 'npm run docs', },
{ cmd: 'npm run demos', watch: ['src/scripts/**/*'] },
{ cmd: 'npm run demos -- --serve' },
]
});
{
"name": "formstate",
"version": "1.0.2",
"version": "1.1.0",
"description": "Painless and simple MobX form management",

@@ -12,3 +12,3 @@ "main": "./lib/index.js",

"docs": "docute ./docs",
"demos": "ts-node ./src/scripts/demos",
"demos": "eze ./src/scripts/demos",
"preversion": "npm run build",

@@ -35,25 +35,23 @@ "postversion": "git push --follow-tags && npm publish",

"devDependencies": {
"@types/fs-extra": "0.0.37",
"@types/material-ui": "^0.16.46",
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.45",
"@types/react": "15.0.32",
"@types/react-dom": "15.5.1",
"csstips": "0.2.2",
"eze": "0.6.0",
"fs-extra": "^2.0.0",
"gh-pages": "^0.11.0",
"material-ui": "0.16.6",
"mobx": "4.1.1",
"mobx-react": "5.0.0",
"mocha": "5.0.5",
"moment": "2.22.1",
"react": "15.4.2",
"react-dom": "15.4.2",
"react-tap-event-plugin": "^2.0.1",
"starts": "^0.7.0",
"ts-node": "5.0.1",
"typescript": "2.4.1",
"typestyle": "1.1.0"
"@material-ui/core": "3.9.2",
"@types/fs-extra": "5.0.5",
"@types/mocha": "^5.2.6",
"@types/node": "^11.9.5",
"@types/react": "16.8.5",
"@types/react-dom": "16.8.2",
"csstips": "0.3.0",
"eze": "0.10.10",
"fs-extra": "^7.0.1",
"gh-pages": "^2.0.1",
"mobx": "5.9.0",
"mobx-react": "5.4.3",
"mocha": "6.0.2",
"moment": "2.24.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"starts": "^0.8.0",
"ts-node": "8.0.2",
"typescript": "3.3.3333",
"typestyle": "2.0.1"
}
}

@@ -1,8 +0,13 @@

import { observable, action, computed, runInAction, isObservable, isArrayLike } from 'mobx';
import { ComposibleValidatable, Validator, applyValidators } from './types';
import { action, computed, isArrayLike, isObservable, observable, runInAction } from 'mobx';
import { isMapLike } from "../internal/utils";
import { applyValidators, ComposibleValidatable, Validator } from './types';
/** Each key of the object is a validatable */
export type ValidatableMapOrArray =
{ [key: string]: ComposibleValidatable<any> }
/** Mode: object */
| { [key: string]: ComposibleValidatable<any> }
/** Mode: array */
| ComposibleValidatable<any>[]
/** Mode: map */
| Map<any, ComposibleValidatable<any>>

@@ -13,3 +18,3 @@ /**

export class FormState<TValue extends ValidatableMapOrArray> implements ComposibleValidatable<TValue> {
protected mode: 'array' | 'map' = 'map';
protected mode: 'object' | 'array' | 'map' = 'object';
constructor(

@@ -21,3 +26,3 @@ /**

) {
this.mode = isArrayLike($) ? 'array' : 'map';
this.mode = isArrayLike($) ? 'array' : isMapLike($) ? 'map' : 'object';

@@ -33,2 +38,5 @@ /** If they didn't send in something observable make the local $ observable */

if (this.mode === 'array') return (this.$ as any);
if (this.mode === 'map') return Array.from(
(this.$ as Map<any, ComposibleValidatable<any>>).values()
);
const keys = Object.keys(this.$);

@@ -35,0 +43,0 @@ return keys.map((key) => this.$[key]);

@@ -0,1 +1,3 @@

import { isObservableMap } from "mobx"
/**

@@ -10,3 +12,3 @@ * Debounce

var later = function() {
var later = function () {
var last = now() - timestamp;

@@ -25,3 +27,3 @@

return <any>function() {
return <any>function () {
context = this;

@@ -40,1 +42,6 @@ args = arguments;

};
export function isMapLike(thing: any) {
return isObservableMap(thing)
|| (typeof Map !== 'undefined' && thing instanceof Map);
}

@@ -11,4 +11,4 @@ import { starts } from 'starts';

{ cmd: 'npm run docs', },
{ cmd: 'npm run demos', watch: ['src/scripts/**/*'] },
{ cmd: 'npm run demos -- --serve'},
]
});

@@ -7,2 +7,3 @@ {

"moduleResolution": "node",
"esModuleInterop": true,
"outDir": "./lib",

@@ -9,0 +10,0 @@ "experimentalDecorators": true,

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