@formio/js 5.0.0-dev.5875.f359435 → 5.0.0-dev.5879.21c1482

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.
@@ -1533,7 +1533,7 @@ class Webform extends NestedDataComponent_1.default {
1533
1533
  return;
1534
1534
  }
1535
1535
  const captchaComponent = [];
1536
- (0, formUtils_1.eachComponentData)(this.components, {}, (component) => {
1536
+ (0, formUtils_1.eachComponent)(this.components, (component) => {
1537
1537
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1538
1538
  captchaComponent.push(component);
1539
1539
  }
package/lib/cjs/Wizard.js CHANGED
@@ -916,7 +916,7 @@ class Wizard extends Webform_1.default {
916
916
  const components = !currentPageOnly || this.isLastPage()
917
917
  ? this.getComponents()
918
918
  : this.currentPage.components;
919
- return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, childErrors) && check, true);
919
+ return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
920
920
  }
921
921
  get errors() {
922
922
  if (!this.isLastPage()) {
@@ -11,6 +11,7 @@ export default class DayComponent extends Field {
11
11
  operators: string[];
12
12
  };
13
13
  static savedValueTypes(schema: any): string[];
14
+ static oldEmptyValue: string;
14
15
  static get serverConditionSettings(): {
15
16
  operators: string[];
16
17
  };
@@ -104,6 +104,12 @@ class DayComponent extends Field_1.default {
104
104
  info.changeEvent = 'input';
105
105
  return info;
106
106
  }
107
+ isEmpty(value = this.dataValue) {
108
+ if (value === DayComponent.oldEmptyValue) {
109
+ return true;
110
+ }
111
+ return super.isEmpty(value);
112
+ }
107
113
  inputDefinition(name) {
108
114
  let min, max;
109
115
  if (name === 'day') {
@@ -337,6 +343,10 @@ class DayComponent extends Field_1.default {
337
343
  }
338
344
  }
339
345
  normalizeValue(value) {
346
+ // Adjust the value from old to new format
347
+ if (value === DayComponent.oldEmptyValue) {
348
+ value = '';
349
+ }
340
350
  if (!value || this.valueMask.test(value)) {
341
351
  return value;
342
352
  }
@@ -643,4 +653,6 @@ class DayComponent extends Field_1.default {
643
653
  return validationFormat;
644
654
  }
645
655
  }
656
+ // Empty value used before 9.3.x
657
+ DayComponent.oldEmptyValue = '00/00/0000';
646
658
  exports.default = DayComponent;
@@ -13,7 +13,6 @@ const utils_1 = require("../../utils/utils");
13
13
  const EditRowState = {
14
14
  New: 'new',
15
15
  Editing: 'editing',
16
- Saving: 'saving',
17
16
  Saved: 'saved',
18
17
  Viewing: 'viewing',
19
18
  Removed: 'removed',
@@ -809,10 +808,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
809
808
  if (!this.component.rowDrafts) {
810
809
  editRow.components.forEach((comp) => comp.setPristine(false));
811
810
  }
812
- // Mark the row with a 'Saving' state to trigger validation for future row changes
813
- if (editRow.state === EditRowState.New) {
814
- editRow.state = EditRowState.Saving;
815
- }
816
811
  const errors = this.validateRow(editRow, true);
817
812
  if (!this.component.rowDrafts) {
818
813
  if (errors.length) {
@@ -825,7 +820,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
825
820
  this.root.focusedComponent = null;
826
821
  }
827
822
  switch (editRow.state) {
828
- case EditRowState.Saving: {
823
+ case EditRowState.New: {
829
824
  const newIndex = dataValue.length;
830
825
  dataValue.push(editRow.data);
831
826
  editRow.components.forEach(component => component.rowIndex = newIndex);
@@ -985,7 +980,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
985
980
  }
986
981
  shouldValidateRow(editRow, dirty, fromSubmission) {
987
982
  return this.shouldValidateDraft(editRow) ||
988
- editRow.state === EditRowState.Saving ||
983
+ editRow.state === EditRowState.New ||
989
984
  editRow.state === EditRowState.Editing ||
990
985
  editRow.alerts ||
991
986
  fromSubmission ||
@@ -1001,7 +996,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1001
996
  editGridValue[editRow.rowIndex] = editRow.data;
1002
997
  lodash_1.default.set(rootValue, this.path, editGridValue);
1003
998
  const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
1004
- editRow.errors = (0, process_1.processSync)({
999
+ const errors = (0, process_1.processSync)({
1005
1000
  components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {
1006
1001
  component.parentPath = `${this.path}[${editRow.rowIndex}]`;
1007
1002
  return component;
@@ -1018,6 +1013,9 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1018
1013
  }
1019
1014
  ]
1020
1015
  }).errors;
1016
+ editRow.errors = (this.component.modal || this.component.rowDrafts)
1017
+ ? errors
1018
+ : errors.filter((err) => lodash_1.default.find(this.visibleErrors, ['component.id', err.component.id]));
1021
1019
  }
1022
1020
  // TODO: this is essentially running its own custom validation and should be moved into a validation rule
1023
1021
  if (this.component.validate && this.component.validate.row) {
@@ -7,7 +7,7 @@ import { Formio } from "./Formio";
7
7
  import Components from "./components/Components";
8
8
  import NestedDataComponent from "./components/_classes/nesteddata/NestedDataComponent";
9
9
  import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from "./utils/utils";
10
- import { eachComponent, eachComponentData } from "./utils/formUtils";
10
+ import { eachComponent } from "./utils/formUtils";
11
11
  // We need this here because dragula pulls in CustomEvent class that requires global to exist.
12
12
  if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
13
13
  window.global = window;
@@ -1536,7 +1536,7 @@ export default class Webform extends NestedDataComponent {
1536
1536
  return;
1537
1537
  }
1538
1538
  const captchaComponent = [];
1539
- eachComponentData(this.components, {}, (component) => {
1539
+ eachComponent(this.components, (component) => {
1540
1540
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1541
1541
  captchaComponent.push(component);
1542
1542
  }
package/lib/mjs/Wizard.js CHANGED
@@ -903,7 +903,7 @@ export default class Wizard extends Webform {
903
903
  const components = !currentPageOnly || this.isLastPage()
904
904
  ? this.getComponents()
905
905
  : this.currentPage.components;
906
- return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, childErrors) && check, true);
906
+ return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
907
907
  }
908
908
  get errors() {
909
909
  if (!this.isLastPage()) {
@@ -11,6 +11,7 @@ export default class DayComponent extends Field {
11
11
  operators: string[];
12
12
  };
13
13
  static savedValueTypes(schema: any): string[];
14
+ static oldEmptyValue: string;
14
15
  static get serverConditionSettings(): {
15
16
  operators: string[];
16
17
  };
@@ -49,6 +49,8 @@ export default class DayComponent extends Field {
49
49
  schema = schema || {};
50
50
  return getComponentSavedTypes(schema) || [componentValueTypes.string];
51
51
  }
52
+ // Empty value used before 9.3.x
53
+ static oldEmptyValue = '00/00/0000';
52
54
  constructor(component, options, data) {
53
55
  if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
54
56
  component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
@@ -102,6 +104,12 @@ export default class DayComponent extends Field {
102
104
  info.changeEvent = 'input';
103
105
  return info;
104
106
  }
107
+ isEmpty(value = this.dataValue) {
108
+ if (value === DayComponent.oldEmptyValue) {
109
+ return true;
110
+ }
111
+ return super.isEmpty(value);
112
+ }
105
113
  inputDefinition(name) {
106
114
  let min, max;
107
115
  if (name === 'day') {
@@ -335,6 +343,10 @@ export default class DayComponent extends Field {
335
343
  }
336
344
  }
337
345
  normalizeValue(value) {
346
+ // Adjust the value from old to new format
347
+ if (value === DayComponent.oldEmptyValue) {
348
+ value = '';
349
+ }
338
350
  if (!value || this.valueMask.test(value)) {
339
351
  return value;
340
352
  }
@@ -8,7 +8,6 @@ import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } fr
8
8
  const EditRowState = {
9
9
  New: 'new',
10
10
  Editing: 'editing',
11
- Saving: 'saving',
12
11
  Saved: 'saved',
13
12
  Viewing: 'viewing',
14
13
  Removed: 'removed',
@@ -799,10 +798,6 @@ export default class EditGridComponent extends NestedArrayComponent {
799
798
  if (!this.component.rowDrafts) {
800
799
  editRow.components.forEach((comp) => comp.setPristine(false));
801
800
  }
802
- // Mark the row with a 'Saving' state to trigger validation for future row changes
803
- if (editRow.state === EditRowState.New) {
804
- editRow.state = EditRowState.Saving;
805
- }
806
801
  const errors = this.validateRow(editRow, true);
807
802
  if (!this.component.rowDrafts) {
808
803
  if (errors.length) {
@@ -815,7 +810,7 @@ export default class EditGridComponent extends NestedArrayComponent {
815
810
  this.root.focusedComponent = null;
816
811
  }
817
812
  switch (editRow.state) {
818
- case EditRowState.Saving: {
813
+ case EditRowState.New: {
819
814
  const newIndex = dataValue.length;
820
815
  dataValue.push(editRow.data);
821
816
  editRow.components.forEach(component => component.rowIndex = newIndex);
@@ -975,7 +970,7 @@ export default class EditGridComponent extends NestedArrayComponent {
975
970
  }
976
971
  shouldValidateRow(editRow, dirty, fromSubmission) {
977
972
  return this.shouldValidateDraft(editRow) ||
978
- editRow.state === EditRowState.Saving ||
973
+ editRow.state === EditRowState.New ||
979
974
  editRow.state === EditRowState.Editing ||
980
975
  editRow.alerts ||
981
976
  fromSubmission ||
@@ -990,7 +985,7 @@ export default class EditGridComponent extends NestedArrayComponent {
990
985
  editGridValue[editRow.rowIndex] = editRow.data;
991
986
  _.set(rootValue, this.path, editGridValue);
992
987
  const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
993
- editRow.errors = processSync({
988
+ const errors = processSync({
994
989
  components: fastCloneDeep(this.component.components).map((component) => {
995
990
  component.parentPath = `${this.path}[${editRow.rowIndex}]`;
996
991
  return component;
@@ -1007,6 +1002,9 @@ export default class EditGridComponent extends NestedArrayComponent {
1007
1002
  }
1008
1003
  ]
1009
1004
  }).errors;
1005
+ editRow.errors = (this.component.modal || this.component.rowDrafts)
1006
+ ? errors
1007
+ : errors.filter((err) => _.find(this.visibleErrors, ['component.id', err.component.id]));
1010
1008
  }
1011
1009
  // TODO: this is essentially running its own custom validation and should be moved into a validation rule
1012
1010
  if (this.component.validate && this.component.validate.row) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5875.f359435",
3
+ "version": "5.0.0-dev.5879.21c1482",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {