From bfa94fc24a9acedb845cb27d3bdbd69407f79b16 Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Wed, 26 Feb 2020 00:26:22 -0500 Subject: [PATCH] Updated build packages for alpha 2 --- dist/formulate.esm.js | 25 +++++++++++++++++-------- dist/formulate.min.js | 25 +++++++++++++++++-------- dist/formulate.umd.js | 25 +++++++++++++++++-------- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/dist/formulate.esm.js b/dist/formulate.esm.js index 532f4f6..d15d8ba 100644 --- a/dist/formulate.esm.js +++ b/dist/formulate.esm.js @@ -458,7 +458,7 @@ function cloneDeep (obj) { var newObj = {}; for (var key in obj) { if (obj[key] instanceof FileUpload || isValueType(obj[key])) { - newObj[key] = obj; + newObj[key] = obj[key]; } else { newObj[key] = cloneDeep(obj[key]); } @@ -1664,10 +1664,10 @@ FormSubmission.prototype.values = function values () { return new Promise(function (resolve, reject) { var pending = []; - var values = cloneDeep(this$1.form.internalModelProxy); + var values = cloneDeep(this$1.form.internalFormModelProxy); for (var key in values) { - if (typeof this$1.form.internalModelProxy[key] === 'object' && this$1.form.internalModelProxy[key] instanceof FileUpload) { - pending.push(this$1.form.internalModelProxy[key].upload()); + if (typeof this$1.form.internalFormModelProxy[key] === 'object' && this$1.form.internalFormModelProxy[key] instanceof FileUpload) { + pending.push(this$1.form.internalFormModelProxy[key].upload()); } } /** @@ -1759,11 +1759,20 @@ var script$1 = { }, register: function register (field, component) { this.registry[field] = component; - if (!component.$options.propsData.hasOwnProperty('formulateValue') && this.hasFormulateValue && this.formulateValue[field]) { + var hasVModelValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'formulateValue'); + var hasValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'value'); + if ( + !hasVModelValue && + this.hasFormulateValue && + this.formulateValue[field] + ) { // In the case that the form is carrying an initial value and the // element is not, set it directly. component.context.model = this.formulateValue[field]; - } else if (component.$options.propsData.hasOwnProperty('formulateValue') && !shallowEqualObjects(component.internalModelProxy, this.formulateValue[field])) { + } else if ( + (hasVModelValue || hasValue) && + !shallowEqualObjects(component.internalModelProxy, this.formulateValue[field]) + ) { this.setFieldValue(field, component.internalModelProxy); } }, @@ -1774,9 +1783,9 @@ var script$1 = { this.showErrors(); var submission = new FormSubmission(this); this.$emit('submit-raw', submission); - submission.hasValidationErrors() + return submission.hasValidationErrors() .then(function (hasErrors) { return hasErrors ? false : submission.values(); }) - .then(function (json) { return json !== false ? this$1.$emit('submit', json) : null; }); + .then(function (json) { return json !== false ? this$1.$emit('submit', json) : null; }) }, showErrors: function showErrors () { for (var fieldName in this.registry) { diff --git a/dist/formulate.min.js b/dist/formulate.min.js index d952c83..971ed2c 100644 --- a/dist/formulate.min.js +++ b/dist/formulate.min.js @@ -461,7 +461,7 @@ var Formulate = (function (exports, isUrl, nanoid, isPlainObject) { var newObj = {}; for (var key in obj) { if (obj[key] instanceof FileUpload || isValueType(obj[key])) { - newObj[key] = obj; + newObj[key] = obj[key]; } else { newObj[key] = cloneDeep(obj[key]); } @@ -1667,10 +1667,10 @@ var Formulate = (function (exports, isUrl, nanoid, isPlainObject) { return new Promise(function (resolve, reject) { var pending = []; - var values = cloneDeep(this$1.form.internalModelProxy); + var values = cloneDeep(this$1.form.internalFormModelProxy); for (var key in values) { - if (typeof this$1.form.internalModelProxy[key] === 'object' && this$1.form.internalModelProxy[key] instanceof FileUpload) { - pending.push(this$1.form.internalModelProxy[key].upload()); + if (typeof this$1.form.internalFormModelProxy[key] === 'object' && this$1.form.internalFormModelProxy[key] instanceof FileUpload) { + pending.push(this$1.form.internalFormModelProxy[key].upload()); } } /** @@ -1762,11 +1762,20 @@ var Formulate = (function (exports, isUrl, nanoid, isPlainObject) { }, register: function register (field, component) { this.registry[field] = component; - if (!component.$options.propsData.hasOwnProperty('formulateValue') && this.hasFormulateValue && this.formulateValue[field]) { + var hasVModelValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'formulateValue'); + var hasValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'value'); + if ( + !hasVModelValue && + this.hasFormulateValue && + this.formulateValue[field] + ) { // In the case that the form is carrying an initial value and the // element is not, set it directly. component.context.model = this.formulateValue[field]; - } else if (component.$options.propsData.hasOwnProperty('formulateValue') && !shallowEqualObjects(component.internalModelProxy, this.formulateValue[field])) { + } else if ( + (hasVModelValue || hasValue) && + !shallowEqualObjects(component.internalModelProxy, this.formulateValue[field]) + ) { this.setFieldValue(field, component.internalModelProxy); } }, @@ -1777,9 +1786,9 @@ var Formulate = (function (exports, isUrl, nanoid, isPlainObject) { this.showErrors(); var submission = new FormSubmission(this); this.$emit('submit-raw', submission); - submission.hasValidationErrors() + return submission.hasValidationErrors() .then(function (hasErrors) { return hasErrors ? false : submission.values(); }) - .then(function (json) { return json !== false ? this$1.$emit('submit', json) : null; }); + .then(function (json) { return json !== false ? this$1.$emit('submit', json) : null; }) }, showErrors: function showErrors () { for (var fieldName in this.registry) { diff --git a/dist/formulate.umd.js b/dist/formulate.umd.js index ceb73c8..806c0ce 100644 --- a/dist/formulate.umd.js +++ b/dist/formulate.umd.js @@ -464,7 +464,7 @@ var newObj = {}; for (var key in obj) { if (obj[key] instanceof FileUpload || isValueType(obj[key])) { - newObj[key] = obj; + newObj[key] = obj[key]; } else { newObj[key] = cloneDeep(obj[key]); } @@ -1670,10 +1670,10 @@ return new Promise(function (resolve, reject) { var pending = []; - var values = cloneDeep(this$1.form.internalModelProxy); + var values = cloneDeep(this$1.form.internalFormModelProxy); for (var key in values) { - if (typeof this$1.form.internalModelProxy[key] === 'object' && this$1.form.internalModelProxy[key] instanceof FileUpload) { - pending.push(this$1.form.internalModelProxy[key].upload()); + if (typeof this$1.form.internalFormModelProxy[key] === 'object' && this$1.form.internalFormModelProxy[key] instanceof FileUpload) { + pending.push(this$1.form.internalFormModelProxy[key].upload()); } } /** @@ -1765,11 +1765,20 @@ }, register: function register (field, component) { this.registry[field] = component; - if (!component.$options.propsData.hasOwnProperty('formulateValue') && this.hasFormulateValue && this.formulateValue[field]) { + var hasVModelValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'formulateValue'); + var hasValue = Object.prototype.hasOwnProperty.call(component.$options.propsData, 'value'); + if ( + !hasVModelValue && + this.hasFormulateValue && + this.formulateValue[field] + ) { // In the case that the form is carrying an initial value and the // element is not, set it directly. component.context.model = this.formulateValue[field]; - } else if (component.$options.propsData.hasOwnProperty('formulateValue') && !shallowEqualObjects(component.internalModelProxy, this.formulateValue[field])) { + } else if ( + (hasVModelValue || hasValue) && + !shallowEqualObjects(component.internalModelProxy, this.formulateValue[field]) + ) { this.setFieldValue(field, component.internalModelProxy); } }, @@ -1780,9 +1789,9 @@ this.showErrors(); var submission = new FormSubmission(this); this.$emit('submit-raw', submission); - submission.hasValidationErrors() + return submission.hasValidationErrors() .then(function (hasErrors) { return hasErrors ? false : submission.values(); }) - .then(function (json) { return json !== false ? this$1.$emit('submit', json) : null; }); + .then(function (json) { return json !== false ? this$1.$emit('submit', json) : null; }) }, showErrors: function showErrors () { for (var fieldName in this.registry) {