@formio/js 5.0.0-dev.5859.acbf6fa → 5.0.0-dev.5860.a296208

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.
@@ -1757,12 +1757,12 @@ class Component extends Element_1.default {
1757
1757
  var _a, _b, _c;
1758
1758
  if ((_a = this.root) === null || _a === void 0 ? void 0 : _a.currentSelection) {
1759
1759
  if ((_b = this.refs.input) === null || _b === void 0 ? void 0 : _b.length) {
1760
- const { index } = this.root.currentSelection;
1760
+ const { selection, index } = this.root.currentSelection;
1761
1761
  let input = this.refs.input[index];
1762
1762
  const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test((i === null || i === void 0 ? void 0 : i.type) || '');
1763
1763
  if (input) {
1764
1764
  if (isInputRangeSelectable(input)) {
1765
- input.setSelectionRange(input.value.length, input.value.length);
1765
+ input.setSelectionRange(...selection);
1766
1766
  }
1767
1767
  }
1768
1768
  else {
@@ -2962,14 +2962,12 @@ class Component extends Element_1.default {
2962
2962
  if (flags.silentCheck) {
2963
2963
  return [];
2964
2964
  }
2965
+ let isDirty = this.dirty || flags.dirty;
2965
2966
  if (this.options.alwaysDirty) {
2966
- flags.dirty = true;
2967
+ isDirty = true;
2967
2968
  }
2968
- if (flags.fromSubmission && this.hasValue(data)) {
2969
- flags.dirty = this.pristine && this.component.protected ? false : true;
2970
- }
2971
- this.setDirty(flags.dirty);
2972
- return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
2969
+ this.setDirty(isDirty);
2970
+ return this.setComponentValidity(errors, isDirty, flags.silentCheck, flags.fromSubmission);
2973
2971
  }
2974
2972
  /**
2975
2973
  * Perform a component validation.
@@ -89,8 +89,8 @@ export default class EditGridComponent extends NestedArrayComponent {
89
89
  hasOpenRows(): any;
90
90
  getAttachedData(data?: null): any;
91
91
  shouldValidateDraft(editRow: any): any;
92
- shouldValidateRow(editRow: any, dirty: any): any;
93
- validateRow(editRow: any, dirty: any, forceSilentCheck: any): any;
92
+ shouldValidateRow(editRow: any, dirty: any, fromSubmission: any): any;
93
+ validateRow(editRow: any, dirty: any, forceSilentCheck: any, fromSubmission: any): any;
94
94
  showRowErrorAlerts(editRow: any, errors: any): void;
95
95
  /**
96
96
  * @returns {boolean} - Return that this component processes its own validation.
@@ -983,17 +983,18 @@ class EditGridComponent extends NestedArrayComponent_1.default {
983
983
  !this.hasOpenRows()) ||
984
984
  ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted);
985
985
  }
986
- shouldValidateRow(editRow, dirty) {
986
+ shouldValidateRow(editRow, dirty, fromSubmission) {
987
987
  return this.shouldValidateDraft(editRow) ||
988
988
  editRow.state === EditRowState.Saving ||
989
989
  editRow.state === EditRowState.Editing ||
990
990
  editRow.alerts ||
991
+ fromSubmission ||
991
992
  dirty;
992
993
  }
993
- validateRow(editRow, dirty, forceSilentCheck) {
994
+ validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
994
995
  var _a;
995
996
  editRow.errors = [];
996
- if (this.shouldValidateRow(editRow, dirty)) {
997
+ if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
997
998
  const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
998
999
  const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);
999
1000
  const editGridValue = lodash_1.default.get(rootValue, this.path, []);
@@ -1065,7 +1066,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1065
1066
  }
1066
1067
  checkComponentValidity(data, dirty, row, options = {}, errors = []) {
1067
1068
  var _a, _b;
1068
- const { silentCheck } = options;
1069
+ const { silentCheck, fromSubmission } = options;
1069
1070
  const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
1070
1071
  // If super tells us that component invalid and there is no need to update alerts, just return false
1071
1072
  if (!superValid && (!this.alert && !this.hasOpenRows())) {
@@ -1075,7 +1076,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1075
1076
  const allRowErrors = [];
1076
1077
  this.editRows.forEach((editRow, index) => {
1077
1078
  // Trigger all errors on the row.
1078
- const rowErrors = this.validateRow(editRow, dirty, silentCheck);
1079
+ const rowErrors = this.validateRow(editRow, dirty, silentCheck, fromSubmission);
1079
1080
  errors.push(...rowErrors);
1080
1081
  allRowErrors.push(...rowErrors);
1081
1082
  if (this.rowRefs) {
@@ -1720,12 +1720,12 @@ export default class Component extends Element {
1720
1720
  restoreCaretPosition() {
1721
1721
  if (this.root?.currentSelection) {
1722
1722
  if (this.refs.input?.length) {
1723
- const { index } = this.root.currentSelection;
1723
+ const { selection, index } = this.root.currentSelection;
1724
1724
  let input = this.refs.input[index];
1725
1725
  const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test(i?.type || '');
1726
1726
  if (input) {
1727
1727
  if (isInputRangeSelectable(input)) {
1728
- input.setSelectionRange(input.value.length, input.value.length);
1728
+ input.setSelectionRange(...selection);
1729
1729
  }
1730
1730
  }
1731
1731
  else {
@@ -2926,14 +2926,12 @@ export default class Component extends Element {
2926
2926
  if (flags.silentCheck) {
2927
2927
  return [];
2928
2928
  }
2929
+ let isDirty = this.dirty || flags.dirty;
2929
2930
  if (this.options.alwaysDirty) {
2930
- flags.dirty = true;
2931
+ isDirty = true;
2931
2932
  }
2932
- if (flags.fromSubmission && this.hasValue(data)) {
2933
- flags.dirty = this.pristine && this.component.protected ? false : true;
2934
- }
2935
- this.setDirty(flags.dirty);
2936
- return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
2933
+ this.setDirty(isDirty);
2934
+ return this.setComponentValidity(errors, isDirty, flags.silentCheck, flags.fromSubmission);
2937
2935
  }
2938
2936
  /**
2939
2937
  * Perform a component validation.
@@ -89,8 +89,8 @@ export default class EditGridComponent extends NestedArrayComponent {
89
89
  hasOpenRows(): any;
90
90
  getAttachedData(data?: null): any;
91
91
  shouldValidateDraft(editRow: any): any;
92
- shouldValidateRow(editRow: any, dirty: any): any;
93
- validateRow(editRow: any, dirty: any, forceSilentCheck: any): any;
92
+ shouldValidateRow(editRow: any, dirty: any, fromSubmission: any): any;
93
+ validateRow(editRow: any, dirty: any, forceSilentCheck: any, fromSubmission: any): any;
94
94
  showRowErrorAlerts(editRow: any, errors: any): void;
95
95
  /**
96
96
  * @returns {boolean} - Return that this component processes its own validation.
@@ -973,16 +973,17 @@ export default class EditGridComponent extends NestedArrayComponent {
973
973
  !this.hasOpenRows()) ||
974
974
  this.root?.submitted;
975
975
  }
976
- shouldValidateRow(editRow, dirty) {
976
+ shouldValidateRow(editRow, dirty, fromSubmission) {
977
977
  return this.shouldValidateDraft(editRow) ||
978
978
  editRow.state === EditRowState.Saving ||
979
979
  editRow.state === EditRowState.Editing ||
980
980
  editRow.alerts ||
981
+ fromSubmission ||
981
982
  dirty;
982
983
  }
983
- validateRow(editRow, dirty, forceSilentCheck) {
984
+ validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
984
985
  editRow.errors = [];
985
- if (this.shouldValidateRow(editRow, dirty)) {
986
+ if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
986
987
  const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;
987
988
  const rootValue = fastCloneDeep(this.rootValue);
988
989
  const editGridValue = _.get(rootValue, this.path, []);
@@ -1053,7 +1054,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1053
1054
  return true;
1054
1055
  }
1055
1056
  checkComponentValidity(data, dirty, row, options = {}, errors = []) {
1056
- const { silentCheck } = options;
1057
+ const { silentCheck, fromSubmission } = options;
1057
1058
  const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
1058
1059
  // If super tells us that component invalid and there is no need to update alerts, just return false
1059
1060
  if (!superValid && (!this.alert && !this.hasOpenRows())) {
@@ -1063,7 +1064,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1063
1064
  const allRowErrors = [];
1064
1065
  this.editRows.forEach((editRow, index) => {
1065
1066
  // Trigger all errors on the row.
1066
- const rowErrors = this.validateRow(editRow, dirty, silentCheck);
1067
+ const rowErrors = this.validateRow(editRow, dirty, silentCheck, fromSubmission);
1067
1068
  errors.push(...rowErrors);
1068
1069
  allRowErrors.push(...rowErrors);
1069
1070
  if (this.rowRefs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5859.acbf6fa",
3
+ "version": "5.0.0-dev.5860.a296208",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {