@shopify/react-form-state
Advanced tools
Comparing version 1.0.0 to 1.0.1-address-mocks-minified-beta.0
@@ -14,3 +14,3 @@ import React from 'react'; | ||
const { field: { onChange }, } = this.props; | ||
onChange(value => { | ||
onChange((value) => { | ||
const existingItem = value[index]; | ||
@@ -17,0 +17,0 @@ const newItem = Object.assign(Object.assign({}, existingItem), { [key]: typeof newValue === 'function' |
@@ -13,3 +13,3 @@ import React from 'react'; | ||
const { field: { onChange }, } = this.props; | ||
onChange(value => { | ||
onChange((value) => { | ||
return Object.assign(Object.assign({}, value), { [key]: typeof newValue === 'function' | ||
@@ -16,0 +16,0 @@ ? newValue(value[key]) |
@@ -40,3 +40,3 @@ import React from 'react'; | ||
fields: FieldStates<Fields>; | ||
dirtyFields: Array<keyof Fields>; | ||
dirtyFields: (keyof Fields)[]; | ||
errors: RemoteError[]; | ||
@@ -43,0 +43,0 @@ externalErrors: RemoteError[]; |
@@ -13,3 +13,3 @@ /* eslint-disable no-case-declarations */ | ||
this.reset = () => { | ||
return new Promise(resolve => { | ||
return new Promise((resolve) => { | ||
this.setState((_state, props) => createFormState(props.initialValues, props.externalErrors), () => resolve()); | ||
@@ -103,3 +103,3 @@ }); | ||
validateForm() { | ||
return new Promise(resolve => { | ||
return new Promise((resolve) => { | ||
this.setState(runAllValidators, () => resolve()); | ||
@@ -130,3 +130,3 @@ }); | ||
const { fields } = this.state; | ||
return Object.keys(fields).some(fieldPath => { | ||
return Object.keys(fields).some((fieldPath) => { | ||
const field = fields[fieldPath]; | ||
@@ -204,3 +204,3 @@ return field.error != null; | ||
} | ||
this.setState(state => ({ | ||
this.setState((state) => ({ | ||
fields: Object.assign(Object.assign({}, state.fields), { [fieldPath]: Object.assign(Object.assign({}, state.fields[fieldPath]), { error }) }), | ||
@@ -258,3 +258,3 @@ })); | ||
function createFormState(values, externalErrors = []) { | ||
const fields = mapObject(values, value => { | ||
const fields = mapObject(values, (value) => { | ||
return { | ||
@@ -285,4 +285,4 @@ value, | ||
const errors = validate | ||
.map(validator => validator(value, fields)) | ||
.filter(input => input != null); | ||
.map((validator) => validator(value, fields)) | ||
.filter((input) => input != null); | ||
if (errors.length === 0) { | ||
@@ -312,5 +312,5 @@ return; | ||
if (Array.isArray(message)) { | ||
return flatMap(message, itemError => collectErrors(itemError)); | ||
return flatMap(message, (itemError) => collectErrors(itemError)); | ||
} | ||
return flatMap(Object.values(message), nestedError => collectErrors(nestedError)); | ||
return flatMap(Object.values(message), (nestedError) => collectErrors(nestedError)); | ||
} |
@@ -17,4 +17,4 @@ import { lengthLessThan, lengthMoreThan, notEmpty, notEmptyString, isEmpty, notNumericString, isNumericString, isPositiveNumericString, } from '@shopify/predicates'; | ||
const errors = validate | ||
.map(validator => validator(value, fields)) | ||
.filter(input => input != null); | ||
.map((validator) => validator(value, fields)) | ||
.filter((input) => input != null); | ||
if (errors.length === 0) { | ||
@@ -26,4 +26,4 @@ return; | ||
const anyErrors = Object.keys(errors) | ||
.map(key => errors[key]) | ||
.some(value => value != null); | ||
.map((key) => errors[key]) | ||
.some((value) => value != null); | ||
if (anyErrors) { | ||
@@ -37,4 +37,4 @@ return errors; | ||
return (input, fields) => { | ||
const errors = input.map(item => validateItem(item, fields)); | ||
if (errors.some(error => error != null)) { | ||
const errors = input.map((item) => validateItem(item, fields)); | ||
if (errors.some((error) => error != null)) { | ||
return errors; | ||
@@ -41,0 +41,0 @@ } |
{ | ||
"name": "@shopify/react-form-state", | ||
"version": "1.0.0", | ||
"version": "1.0.1-address-mocks-minified-beta.0", | ||
"license": "MIT", | ||
@@ -34,3 +34,3 @@ "description": "Manage React forms tersely and type-safely with no magic", | ||
"@shopify/enzyme-utilities": "^3.0.0", | ||
"@shopify/useful-types": "^3.0.0", | ||
"@shopify/useful-types": "^3.0.1-address-mocks-minified-beta.0", | ||
"faker": "^4.1.0" | ||
@@ -57,3 +57,3 @@ }, | ||
}, | ||
"gitHead": "40de4af181104f298cbab42d2d3d68e228a9a31a" | ||
"gitHead": "1a19759d10db9ca65d346141b10e7b0654e023e6" | ||
} |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
112591
0
1