@shopify/react-form-state
Advanced tools
Comparing version 0.12.4 to 0.12.5
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -14,4 +16,2 @@ value: true | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -39,3 +39,3 @@ | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -42,0 +42,0 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -14,4 +16,2 @@ value: true | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -39,3 +39,3 @@ | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -42,0 +42,0 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -18,4 +20,2 @@ value: true | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -59,3 +59,3 @@ | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -259,2 +259,56 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
}, { | ||
key: "formData", | ||
get: function get() { | ||
var errors = this.state.errors; | ||
var _this$props$externalE = this.props.externalErrors, | ||
externalErrors = _this$props$externalE === void 0 ? [] : _this$props$externalE; | ||
var fields = this.fields, | ||
dirty = this.dirty, | ||
valid = this.valid; | ||
return { | ||
dirty: dirty, | ||
valid: valid, | ||
errors: [].concat(_toConsumableArray(errors), _toConsumableArray(externalErrors)), | ||
fields: fields | ||
}; | ||
} | ||
}, { | ||
key: "dirty", | ||
get: function get() { | ||
return this.state.dirtyFields.length > 0; | ||
} | ||
}, { | ||
key: "valid", | ||
get: function get() { | ||
var _this$state = this.state, | ||
errors = _this$state.errors, | ||
externalErrors = _this$state.externalErrors; | ||
return !this.hasClientErrors && errors.length === 0 && externalErrors.length === 0; | ||
} | ||
}, { | ||
key: "hasClientErrors", | ||
get: function get() { | ||
var fields = this.state.fields; | ||
return Object.keys(fields).some(function (fieldPath) { | ||
var field = fields[fieldPath]; | ||
return field.error != null; | ||
}); | ||
} | ||
}, { | ||
key: "clientErrors", | ||
get: function get() { | ||
var fields = this.state.fields; | ||
return (0, _utilities.flatMap)(Object.values(fields), function (_ref2) { | ||
var error = _ref2.error; | ||
return collectErrors(error); | ||
}); | ||
} | ||
}, { | ||
key: "fields", | ||
get: function get() { | ||
var fields = this.state.fields; | ||
var fieldDescriptors = (0, _utilities.mapObject)(fields, this.fieldWithHandlers); | ||
return fieldDescriptors; | ||
} | ||
}, { | ||
key: "updateField", | ||
@@ -264,5 +318,5 @@ value: function updateField(fieldPath, value) { | ||
this.setState(function (_ref2) { | ||
var fields = _ref2.fields, | ||
dirtyFields = _ref2.dirtyFields; | ||
this.setState(function (_ref3) { | ||
var fields = _ref3.fields, | ||
dirtyFields = _ref3.dirtyFields; | ||
var field = fields[fieldPath]; | ||
@@ -291,6 +345,6 @@ var newValue = typeof value === 'function' ? value(field.value) : value; | ||
key: "getUpdatedDirtyFields", | ||
value: function getUpdatedDirtyFields(_ref3) { | ||
var fieldPath = _ref3.fieldPath, | ||
dirty = _ref3.dirty, | ||
dirtyFields = _ref3.dirtyFields; | ||
value: function getUpdatedDirtyFields(_ref4) { | ||
var fieldPath = _ref4.fieldPath, | ||
dirty = _ref4.dirty, | ||
dirtyFields = _ref4.dirtyFields; | ||
var dirtyFieldsSet = new Set(dirtyFields); | ||
@@ -309,7 +363,7 @@ | ||
key: "getUpdatedField", | ||
value: function getUpdatedField(_ref4) { | ||
var fieldPath = _ref4.fieldPath, | ||
field = _ref4.field, | ||
value = _ref4.value, | ||
dirty = _ref4.dirty; | ||
value: function getUpdatedField(_ref5) { | ||
var fieldPath = _ref5.fieldPath, | ||
field = _ref5.field, | ||
value = _ref5.value, | ||
dirty = _ref5.dirty; | ||
// We only want to update errors as the user types if they already have an error. | ||
@@ -354,5 +408,5 @@ // https://polaris.shopify.com/patterns/error-messages#section-form-validation | ||
key: "validateFieldValue", | ||
value: function validateFieldValue(fieldPath, _ref5) { | ||
var value = _ref5.value, | ||
dirty = _ref5.dirty; | ||
value: function validateFieldValue(fieldPath, _ref6) { | ||
var value = _ref6.value, | ||
dirty = _ref6.dirty; | ||
@@ -371,5 +425,5 @@ if (!dirty) { | ||
value: function updateRemoteErrors(errors) { | ||
this.setState(function (_ref6) { | ||
var fields = _ref6.fields, | ||
externalErrors = _ref6.externalErrors; | ||
this.setState(function (_ref7) { | ||
var fields = _ref7.fields, | ||
externalErrors = _ref7.externalErrors; | ||
return { | ||
@@ -381,56 +435,2 @@ errors: errors, | ||
} | ||
}, { | ||
key: "formData", | ||
get: function get() { | ||
var errors = this.state.errors; | ||
var _this$props$externalE = this.props.externalErrors, | ||
externalErrors = _this$props$externalE === void 0 ? [] : _this$props$externalE; | ||
var fields = this.fields, | ||
dirty = this.dirty, | ||
valid = this.valid; | ||
return { | ||
dirty: dirty, | ||
valid: valid, | ||
errors: [].concat(_toConsumableArray(errors), _toConsumableArray(externalErrors)), | ||
fields: fields | ||
}; | ||
} | ||
}, { | ||
key: "dirty", | ||
get: function get() { | ||
return this.state.dirtyFields.length > 0; | ||
} | ||
}, { | ||
key: "valid", | ||
get: function get() { | ||
var _this$state = this.state, | ||
errors = _this$state.errors, | ||
externalErrors = _this$state.externalErrors; | ||
return !this.hasClientErrors && errors.length === 0 && externalErrors.length === 0; | ||
} | ||
}, { | ||
key: "hasClientErrors", | ||
get: function get() { | ||
var fields = this.state.fields; | ||
return Object.keys(fields).some(function (fieldPath) { | ||
var field = fields[fieldPath]; | ||
return field.error != null; | ||
}); | ||
} | ||
}, { | ||
key: "clientErrors", | ||
get: function get() { | ||
var fields = this.state.fields; | ||
return (0, _utilities.flatMap)(Object.values(fields), function (_ref7) { | ||
var error = _ref7.error; | ||
return collectErrors(error); | ||
}); | ||
} | ||
}, { | ||
key: "fields", | ||
get: function get() { | ||
var fields = this.state.fields; | ||
var fieldDescriptors = (0, _utilities.mapObject)(fields, this.fieldWithHandlers); | ||
return fieldDescriptors; | ||
} | ||
}], [{ | ||
@@ -437,0 +437,0 @@ key: "getDerivedStateFromProps", |
@@ -32,2 +32,3 @@ "use strict"; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _FormState[key]) return; | ||
Object.defineProperty(exports, key, { | ||
@@ -48,2 +49,3 @@ enumerable: true, | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _validators[key]) return; | ||
Object.defineProperty(exports, key, { | ||
@@ -62,2 +64,3 @@ enumerable: true, | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _types[key]) return; | ||
Object.defineProperty(exports, key, { | ||
@@ -64,0 +67,0 @@ enumerable: true, |
@@ -30,2 +30,3 @@ "use strict"; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _FormState[key]) return; | ||
Object.defineProperty(exports, key, { | ||
@@ -46,2 +47,3 @@ enumerable: true, | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _validators[key]) return; | ||
Object.defineProperty(exports, key, { | ||
@@ -60,2 +62,3 @@ enumerable: true, | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _types[key]) return; | ||
Object.defineProperty(exports, key, { | ||
@@ -62,0 +65,0 @@ enumerable: true, |
@@ -10,2 +10,6 @@ # Changelog | ||
## 0.12.5 - 2021-04-22 | ||
- [Patch] Remove TypeScript type from distributed mjs [#1845](https://github.com/Shopify/quilt/pull/1845) | ||
## 0.12.4 - 2021-04-13 | ||
@@ -12,0 +16,0 @@ |
{ | ||
"name": "@shopify/react-form-state", | ||
"version": "0.12.4", | ||
"version": "0.12.5", | ||
"license": "MIT", | ||
@@ -31,3 +31,3 @@ "description": "Manage React forms tersely and type-safely with no magic", | ||
"@shopify/enzyme-utilities": "^2.2.4", | ||
"@shopify/useful-types": "^2.3.4", | ||
"@shopify/useful-types": "^2.4.0", | ||
"faker": "^4.1.0" | ||
@@ -34,0 +34,0 @@ }, |
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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
179261
3407