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

@shopify/react-form-state

Package Overview
Dependencies
Maintainers
19
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/react-form-state - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

build/tsconfig.tsbuildinfo

3

build/cjs/utilities.js

@@ -12,2 +12,3 @@ 'use strict';

const _excluded = ["value"];
function mapObject(input, mapper) {

@@ -60,3 +61,3 @@ return Object.entries(input).reduce((accumulator, [key, value]) => {

} = _ref,
fieldData = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, ["value"]);
fieldData = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);

@@ -63,0 +64,0 @@ return _rollupPluginBabelHelpers.objectSpread2({

@@ -16,5 +16,8 @@ import React from 'react';

const existingItem = value[index];
const newItem = Object.assign(Object.assign({}, existingItem), { [key]: typeof newValue === 'function'
const newItem = {
...existingItem,
[key]: typeof newValue === 'function'
? newValue(value[index][key])
: newValue });
: newValue,
};
return replace(value, index, newItem);

@@ -21,0 +24,0 @@ });

@@ -14,5 +14,8 @@ import React from 'react';

onChange((value) => {
return Object.assign(Object.assign({}, value), { [key]: typeof newValue === 'function'
return {
...value,
[key]: typeof newValue === 'function'
? newValue(value[key])
: newValue });
: newValue,
};
});

@@ -19,0 +22,0 @@ };

@@ -54,3 +54,8 @@ /* eslint-disable no-case-declarations */

}
const result = Object.assign(Object.assign({}, field), { name: String(fieldPath), onChange: this.updateField.bind(this, fieldPath), onBlur: this.blurField.bind(this, fieldPath) });
const result = {
...field,
name: String(fieldPath),
onChange: this.updateField.bind(this, fieldPath),
onBlur: this.blurField.bind(this, fieldPath),
};
this.fieldsWithHandlers.set(field, result);

@@ -97,5 +102,8 @@ return result;

const { submit, reset, formData } = this;
return children(Object.assign(Object.assign({}, formData), { submit,
return children({
...formData,
submit,
reset,
submitting }));
submitting,
});
}

@@ -165,3 +173,8 @@ // eslint-disable-next-line @shopify/react-prefer-private-members

? fields
: Object.assign(Object.assign({}, fields), { [fieldPath]: updatedField }),
: {
// FieldStates<Fields> is not spreadable due to a TS bug
// https://github.com/Microsoft/TypeScript/issues/13557
...fields,
[fieldPath]: updatedField,
},
};

@@ -193,5 +206,8 @@ });

}
return Object.assign(Object.assign({}, field), { value,
return {
...field,
value,
dirty,
error });
error,
};
}

@@ -206,3 +222,11 @@ blurField(fieldPath) {

this.setState((state) => ({
fields: Object.assign(Object.assign({}, state.fields), { [fieldPath]: Object.assign(Object.assign({}, state.fields[fieldPath]), { error }) }),
fields: {
// FieldStates<Fields> is not spreadable due to a TS bug
// https://github.com/Microsoft/TypeScript/issues/13557
...state.fields,
[fieldPath]: {
...state.fields[fieldPath],
error,
},
},
}));

@@ -238,3 +262,6 @@ }

}
return Object.assign(Object.assign({}, field), { error: errorDictionary[path] });
return {
...field,
error: errorDictionary[path],
};
});

@@ -257,3 +284,7 @@ }

});
return Object.assign(Object.assign({}, oldState), { dirtyFields: Array.from(dirtyFields), fields: fieldsWithErrors(fields, externalErrors) });
return {
...oldState,
dirtyFields: Array.from(dirtyFields),
fields: fieldsWithErrors(fields, externalErrors),
};
}

@@ -301,5 +332,11 @@ function createFormState(values, externalErrors = []) {

const updatedFields = mapObject(fields, (field, path) => {
return Object.assign(Object.assign({}, field), { error: runValidator(validators[path], field.value, fields) });
return {
...field,
error: runValidator(validators[path], field.value, fields),
};
});
return Object.assign(Object.assign({}, state), { fields: updatedFields });
return {
...state,
fields: updatedFields,
};
}

@@ -306,0 +343,0 @@ function collectErrors(message) {

@@ -28,7 +28,13 @@ import isEqual from 'fast-deep-equal';

else if (path.length === 1) {
return Object.assign(Object.assign({}, rootObject), { [path[0]]: value });
return {
...rootObject,
[path[0]]: value,
};
}
else {
const [current, ...rest] = path;
return Object.assign(Object.assign({}, rootObject), { [current]: set(rootObject[current] || {}, rest, value) });
return {
...rootObject,
[current]: set(rootObject[current] || {}, rest, value),
};
}

@@ -43,5 +49,7 @@ }

*/
export function asChoiceField(_a) {
var { value: checked } = _a, fieldData = __rest(_a, ["value"]);
return Object.assign({ checked }, fieldData);
export function asChoiceField({ value: checked, ...fieldData }) {
return {
checked,
...fieldData,
};
}

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

module.exports = require("./build/cjs/index.js");
function interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
module.exports = interopRequireDefault(require("./build/cjs/index.js"));
{
"name": "@shopify/react-form-state",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",

@@ -33,3 +33,2 @@ "description": "Manage React forms tersely and type-safely with no magic",

"devDependencies": {
"@shopify/enzyme-utilities": "^3.0.0",
"@shopify/useful-types": "^3.0.1",

@@ -57,3 +56,3 @@ "faker": "^4.1.0"

},
"gitHead": "0edc9e3b7df7b6a4805cc3ff1443641cdb8e8a72"
"gitHead": "2978970ec1e7ec7d0ba41508f1ca2f71d7052b4b"
}

Sorry, the diff of this file is not supported yet

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