@shopify/react-form-state
Advanced tools
Comparing version 0.12.0-sk-next-beta.0 to 0.12.0-sk-next-beta.1
@@ -20,2 +20,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -41,4 +43,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var List = /*#__PURE__*/function (_React$PureComponent) { | ||
@@ -59,6 +59,5 @@ _inherits(List, _React$PureComponent); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.changeHandlers = new Map(); | ||
_defineProperty(_assertThisInitialized(_this), "changeHandlers", new Map()); | ||
_defineProperty(_assertThisInitialized(_this), "handleChange", function (_ref) { | ||
_this.handleChange = function (_ref) { | ||
var index = _ref.index, | ||
@@ -86,3 +85,3 @@ key = _ref.key; | ||
return handler; | ||
}); | ||
}; | ||
@@ -89,0 +88,0 @@ return _this; |
@@ -20,2 +20,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -41,4 +43,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var Nested = /*#__PURE__*/function (_React$PureComponent) { | ||
@@ -59,6 +59,5 @@ _inherits(Nested, _React$PureComponent); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.changeHandlers = new Map(); | ||
_defineProperty(_assertThisInitialized(_this), "changeHandlers", new Map()); | ||
_defineProperty(_assertThisInitialized(_this), "handleChange", function (key) { | ||
_this.handleChange = function (key) { | ||
if (_this.changeHandlers.has(key)) { | ||
@@ -78,3 +77,3 @@ return _this.changeHandlers.get(key); | ||
return handler; | ||
}); | ||
}; | ||
@@ -81,0 +80,0 @@ return _this; |
@@ -36,2 +36,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
@@ -61,4 +63,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var FormState = /*#__PURE__*/function (_React$PureComponent) { | ||
@@ -79,10 +79,7 @@ _inherits(FormState, _React$PureComponent); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.state = createFormState(_this.props.initialValues, _this.props.externalErrors); | ||
_this.mounted = false; | ||
_this.fieldsWithHandlers = new WeakMap(); | ||
_defineProperty(_assertThisInitialized(_this), "state", createFormState(_this.props.initialValues, _this.props.externalErrors)); | ||
_defineProperty(_assertThisInitialized(_this), "mounted", false); | ||
_defineProperty(_assertThisInitialized(_this), "fieldsWithHandlers", new WeakMap()); | ||
_defineProperty(_assertThisInitialized(_this), "reset", function () { | ||
_this.reset = function () { | ||
return new Promise(function (resolve) { | ||
@@ -95,5 +92,5 @@ _this.setState(function (_state, props) { | ||
}); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_this), "submit", /*#__PURE__*/function () { | ||
_this.submit = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(event) { | ||
@@ -205,5 +202,5 @@ var _this$props, onSubmit, validateOnSubmit, _assertThisInitialize, formData, clientErrors, errors; | ||
}; | ||
}()); | ||
}(); | ||
_defineProperty(_assertThisInitialized(_this), "fieldWithHandlers", function (field, fieldPath) { | ||
_this.fieldWithHandlers = function (field, fieldPath) { | ||
if (_this.fieldsWithHandlers.has(field)) { | ||
@@ -222,3 +219,3 @@ return _this.fieldsWithHandlers.get(field); | ||
return result; | ||
}); | ||
}; | ||
@@ -474,7 +471,5 @@ return _this; | ||
exports["default"] = FormState; | ||
FormState.List = _components.List; | ||
FormState.Nested = _components.Nested; | ||
_defineProperty(FormState, "List", _components.List); | ||
_defineProperty(FormState, "Nested", _components.Nested); | ||
function fieldsWithErrors(fields, errors) { | ||
@@ -481,0 +476,0 @@ var errorDictionary = errors.reduce(function (accumulator, _ref8) { |
@@ -14,11 +14,8 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class List extends _react.default.PureComponent { | ||
constructor(...args) { | ||
super(...args); | ||
this.changeHandlers = new Map(); | ||
_defineProperty(this, "changeHandlers", new Map()); | ||
_defineProperty(this, "handleChange", ({ | ||
this.handleChange = ({ | ||
index, | ||
@@ -50,3 +47,3 @@ key | ||
return handler; | ||
}); | ||
}; | ||
} | ||
@@ -53,0 +50,0 @@ |
@@ -14,11 +14,8 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class Nested extends _react.default.PureComponent { | ||
constructor(...args) { | ||
super(...args); | ||
this.changeHandlers = new Map(); | ||
_defineProperty(this, "changeHandlers", new Map()); | ||
_defineProperty(this, "handleChange", key => { | ||
this.handleChange = key => { | ||
if (this.changeHandlers.has(key)) { | ||
@@ -43,3 +40,3 @@ return this.changeHandlers.get(key); | ||
return handler; | ||
}); | ||
}; | ||
} | ||
@@ -46,0 +43,0 @@ |
@@ -16,21 +16,17 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/* eslint-disable no-case-declarations */ | ||
class FormState extends _react.default.PureComponent { | ||
constructor(...args) { | ||
super(...args); | ||
this.state = createFormState(this.props.initialValues, this.props.externalErrors); | ||
this.mounted = false; | ||
this.fieldsWithHandlers = new WeakMap(); | ||
_defineProperty(this, "state", createFormState(this.props.initialValues, this.props.externalErrors)); | ||
_defineProperty(this, "mounted", false); | ||
_defineProperty(this, "fieldsWithHandlers", new WeakMap()); | ||
_defineProperty(this, "reset", () => { | ||
this.reset = () => { | ||
return new Promise(resolve => { | ||
this.setState((_state, props) => createFormState(props.initialValues, props.externalErrors), () => resolve()); | ||
}); | ||
}); | ||
}; | ||
_defineProperty(this, "submit", async event => { | ||
this.submit = async event => { | ||
const { | ||
@@ -90,5 +86,5 @@ onSubmit, | ||
} | ||
}); | ||
}; | ||
_defineProperty(this, "fieldWithHandlers", (field, fieldPath) => { | ||
this.fieldWithHandlers = (field, fieldPath) => { | ||
if (this.fieldsWithHandlers.has(field)) { | ||
@@ -105,3 +101,3 @@ return this.fieldsWithHandlers.get(field); | ||
return result; | ||
}); | ||
}; | ||
} | ||
@@ -358,7 +354,5 @@ | ||
exports.default = FormState; | ||
FormState.List = _components.List; | ||
FormState.Nested = _components.Nested; | ||
_defineProperty(FormState, "List", _components.List); | ||
_defineProperty(FormState, "Nested", _components.Nested); | ||
function fieldsWithErrors(fields, errors) { | ||
@@ -365,0 +359,0 @@ const errorDictionary = errors.reduce((accumulator, { |
{ | ||
"name": "@shopify/react-form-state", | ||
"version": "0.12.0-sk-next-beta.0", | ||
"version": "0.12.0-sk-next-beta.1", | ||
"license": "MIT", | ||
@@ -26,3 +26,3 @@ "description": "Manage React forms tersely and type-safely with no magic", | ||
"dependencies": { | ||
"@shopify/predicates": "^1.3.0-sk-next-beta.0", | ||
"@shopify/predicates": "^1.3.0-sk-next-beta.1", | ||
"fast-deep-equal": "^2.0.1", | ||
@@ -35,4 +35,4 @@ "tslib": "^1.14.1" | ||
"devDependencies": { | ||
"@shopify/enzyme-utilities": "^2.2.0-sk-next-beta.0", | ||
"@shopify/useful-types": "^2.3.0-sk-next-beta.0", | ||
"@shopify/enzyme-utilities": "^2.2.0-sk-next-beta.1", | ||
"@shopify/useful-types": "^2.3.0-sk-next-beta.1", | ||
"faker": "^4.1.0" | ||
@@ -39,0 +39,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
Sorry, the diff of this file is not supported yet
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
0
185759
3522