@formio/js 5.0.0-dev.5846.796fec1 → 5.0.0-dev.5847.72f1bf3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -710,7 +710,6 @@ class Webform extends NestedDataComponent_1.default {
710
710
  */
711
711
  onSetSubmission(submission, flags = {}) {
712
712
  this.submissionSet = true;
713
- flags.submission = structuredClone(submission);
714
713
  this.triggerChange(flags);
715
714
  this.emit('beforeSetSubmission', submission);
716
715
  this.setValue(submission, flags);
@@ -1248,10 +1247,9 @@ class Webform extends NestedDataComponent_1.default {
1248
1247
  this.pristine = false;
1249
1248
  }
1250
1249
  this.checkData(value.data, flags);
1251
- let shouldValidate = flags.noValidate ? false :
1252
- lodash_1.default.isUndefined(flags.noValidate) ||
1253
- flags.fromIframe ||
1254
- (flags.fromSubmission && this.rootPristine && this.pristine);
1250
+ const shouldValidate = !flags.noValidate ||
1251
+ flags.fromIframe ||
1252
+ (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1255
1253
  const errors = shouldValidate
1256
1254
  ? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change' }))
1257
1255
  : [];
@@ -2456,6 +2456,7 @@ class Component extends Element_1.default {
2456
2456
  return;
2457
2457
  }
2458
2458
  lodash_1.default.set(this._data, this.key, value);
2459
+ return;
2459
2460
  }
2460
2461
  /**
2461
2462
  * Splice a value from the dataValue.
@@ -2958,19 +2959,17 @@ class Component extends Element_1.default {
2958
2959
  * @returns {boolean} - TRUE if the component is valid.
2959
2960
  */
2960
2961
  showValidationErrors(errors, data, row, flags) {
2961
- var _a;
2962
2962
  if (flags.silentCheck) {
2963
2963
  return [];
2964
2964
  }
2965
- let dirty = this.dirty || flags.dirty;
2966
2965
  if (this.options.alwaysDirty) {
2967
- dirty = true;
2966
+ flags.dirty = true;
2968
2967
  }
2969
- if (flags.fromSubmission && !lodash_1.default.isUndefined(lodash_1.default.get((_a = flags === null || flags === void 0 ? void 0 : flags.submission) === null || _a === void 0 ? void 0 : _a.data, this.key)) && !(this.pristine && this.protected)) {
2970
- dirty = true;
2968
+ if (flags.fromSubmission && this.hasValue(data)) {
2969
+ flags.dirty = this.pristine && this.component.protected ? false : true;
2971
2970
  }
2972
- this.setDirty(dirty);
2973
- return this.setComponentValidity(errors, dirty, flags.silentCheck, flags.fromSubmission);
2971
+ this.setDirty(flags.dirty);
2972
+ return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
2974
2973
  }
2975
2974
  /**
2976
2975
  * Perform a component validation.
@@ -827,23 +827,22 @@ class NestedComponent extends Field_1.default {
827
827
  }
828
828
  setNestedValue(component, value, flags = {}) {
829
829
  component._data = this.componentContext(component);
830
- let componentFlags = Object.assign({}, flags);
831
830
  if (component.type === 'button') {
832
831
  return false;
833
832
  }
834
833
  if (component.type === 'components') {
835
834
  if (component.tree && component.hasValue(value)) {
836
- return component.setValue(lodash_1.default.get(value, component.key), componentFlags);
835
+ return component.setValue(lodash_1.default.get(value, component.key), flags);
837
836
  }
838
- return component.setValue(value, componentFlags);
837
+ return component.setValue(value, flags);
839
838
  }
840
839
  else if (value && component.hasValue(value)) {
841
- return component.setValue(lodash_1.default.get(value, component.key), componentFlags);
840
+ return component.setValue(lodash_1.default.get(value, component.key), flags);
842
841
  }
843
842
  else if ((!this.rootPristine || component.visible) && component.shouldAddDefaultValue) {
844
- componentFlags.noValidate = !componentFlags.dirty;
845
- componentFlags.resetValue = true;
846
- return component.setValue(component.defaultValue, componentFlags);
843
+ flags.noValidate = !flags.dirty;
844
+ flags.resetValue = true;
845
+ return component.setValue(component.defaultValue, flags);
847
846
  }
848
847
  }
849
848
  setValue(value, flags = {}) {
@@ -983,7 +983,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
983
983
  editRow.state === EditRowState.New ||
984
984
  editRow.state === EditRowState.Editing ||
985
985
  editRow.alerts ||
986
- this.dirty ||
987
986
  dirty;
988
987
  }
989
988
  validateRow(editRow, dirty, forceSilentCheck) {
@@ -708,7 +708,6 @@ export default class Webform extends NestedDataComponent {
708
708
  */
709
709
  onSetSubmission(submission, flags = {}) {
710
710
  this.submissionSet = true;
711
- flags.submission = structuredClone(submission);
712
711
  this.triggerChange(flags);
713
712
  this.emit('beforeSetSubmission', submission);
714
713
  this.setValue(submission, flags);
@@ -1250,10 +1249,9 @@ export default class Webform extends NestedDataComponent {
1250
1249
  this.pristine = false;
1251
1250
  }
1252
1251
  this.checkData(value.data, flags);
1253
- let shouldValidate = flags.noValidate ? false :
1254
- _.isUndefined(flags.noValidate) ||
1255
- flags.fromIframe ||
1256
- (flags.fromSubmission && this.rootPristine && this.pristine);
1252
+ const shouldValidate = !flags.noValidate ||
1253
+ flags.fromIframe ||
1254
+ (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1257
1255
  const errors = shouldValidate
1258
1256
  ? this.validate(value.data, {
1259
1257
  ...flags,
@@ -2422,6 +2422,7 @@ export default class Component extends Element {
2422
2422
  return;
2423
2423
  }
2424
2424
  _.set(this._data, this.key, value);
2425
+ return;
2425
2426
  }
2426
2427
  /**
2427
2428
  * Splice a value from the dataValue.
@@ -2925,15 +2926,14 @@ export default class Component extends Element {
2925
2926
  if (flags.silentCheck) {
2926
2927
  return [];
2927
2928
  }
2928
- let dirty = this.dirty || flags.dirty;
2929
2929
  if (this.options.alwaysDirty) {
2930
- dirty = true;
2930
+ flags.dirty = true;
2931
2931
  }
2932
- if (flags.fromSubmission && !_.isUndefined(_.get(flags?.submission?.data, this.key)) && !(this.pristine && this.protected)) {
2933
- dirty = true;
2932
+ if (flags.fromSubmission && this.hasValue(data)) {
2933
+ flags.dirty = this.pristine && this.component.protected ? false : true;
2934
2934
  }
2935
- this.setDirty(dirty);
2936
- return this.setComponentValidity(errors, dirty, flags.silentCheck, flags.fromSubmission);
2935
+ this.setDirty(flags.dirty);
2936
+ return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
2937
2937
  }
2938
2938
  /**
2939
2939
  * Perform a component validation.
@@ -822,23 +822,22 @@ export default class NestedComponent extends Field {
822
822
  }
823
823
  setNestedValue(component, value, flags = {}) {
824
824
  component._data = this.componentContext(component);
825
- let componentFlags = { ...flags };
826
825
  if (component.type === 'button') {
827
826
  return false;
828
827
  }
829
828
  if (component.type === 'components') {
830
829
  if (component.tree && component.hasValue(value)) {
831
- return component.setValue(_.get(value, component.key), componentFlags);
830
+ return component.setValue(_.get(value, component.key), flags);
832
831
  }
833
- return component.setValue(value, componentFlags);
832
+ return component.setValue(value, flags);
834
833
  }
835
834
  else if (value && component.hasValue(value)) {
836
- return component.setValue(_.get(value, component.key), componentFlags);
835
+ return component.setValue(_.get(value, component.key), flags);
837
836
  }
838
837
  else if ((!this.rootPristine || component.visible) && component.shouldAddDefaultValue) {
839
- componentFlags.noValidate = !componentFlags.dirty;
840
- componentFlags.resetValue = true;
841
- return component.setValue(component.defaultValue, componentFlags);
838
+ flags.noValidate = !flags.dirty;
839
+ flags.resetValue = true;
840
+ return component.setValue(component.defaultValue, flags);
842
841
  }
843
842
  }
844
843
  setValue(value, flags = {}) {
@@ -973,7 +973,6 @@ export default class EditGridComponent extends NestedArrayComponent {
973
973
  editRow.state === EditRowState.New ||
974
974
  editRow.state === EditRowState.Editing ||
975
975
  editRow.alerts ||
976
- this.dirty ||
977
976
  dirty;
978
977
  }
979
978
  validateRow(editRow, dirty, forceSilentCheck) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5846.796fec1",
3
+ "version": "5.0.0-dev.5847.72f1bf3",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {