@formio/js 5.0.0-dev.5920.f58ae24 → 5.0.0-dev.5922.23f0b78

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.
@@ -105,7 +105,6 @@ declare class Wizard extends Webform {
105
105
  pageId(page: any): any;
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
- showErrors(errors: any, triggerEvent: any): void | any[];
109
108
  focusOnComponent(key: any): void | Promise<void>;
110
109
  }
111
110
  declare namespace Wizard {
package/lib/cjs/Wizard.js CHANGED
@@ -602,7 +602,10 @@ class Wizard extends Webform_1.default {
602
602
  }
603
603
  this.redraw().then(() => {
604
604
  this.checkData(this.submission.data);
605
- this.validateCurrentPage();
605
+ const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
606
+ if (this.alert) {
607
+ this.showErrors(errors, true, true);
608
+ }
606
609
  });
607
610
  return Promise.resolve();
608
611
  }
@@ -699,9 +702,11 @@ class Wizard extends Webform_1.default {
699
702
  });
700
703
  });
701
704
  }
702
- // Validate the form, before go to the next page
703
- const errors = this.validateCurrentPage({ dirty: true });
704
- if (errors.length === 0) {
705
+ // Validate the form before going to the next page
706
+ const currentPageErrors = this.validateCurrentPage({ dirty: true });
707
+ const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : currentPageErrors;
708
+ // allow going to the next page if the current page is valid, even if there are form level errors
709
+ if (currentPageErrors.length === 0) {
705
710
  this.checkData(this.submission.data);
706
711
  return this.beforePage(true).then(() => {
707
712
  return this.setPage(this.getNextPage()).then(() => {
@@ -716,7 +721,7 @@ class Wizard extends Webform_1.default {
716
721
  else {
717
722
  this.currentPage.components.forEach((comp) => comp.setPristine(false));
718
723
  this.scrollIntoView(this.element, true);
719
- return Promise.reject(super.showErrors(errors, true));
724
+ return Promise.reject(this.showErrors(errors, true));
720
725
  }
721
726
  }
722
727
  validateCurrentPage(flags = {}) {
@@ -866,7 +871,7 @@ class Wizard extends Webform_1.default {
866
871
  var _a, _b;
867
872
  super.onChange(flags, changed, modified, changes);
868
873
  // The onChange loop doesn't need all components for wizards
869
- const errors = this.submitted ? this.validate(this.localData, { dirty: false }) : this.validateCurrentPage();
874
+ const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
870
875
  if (this.alert) {
871
876
  this.showErrors(errors, true, true);
872
877
  }
@@ -921,20 +926,7 @@ class Wizard extends Webform_1.default {
921
926
  return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
922
927
  }
923
928
  get errors() {
924
- if (!this.isLastPage()) {
925
- return this.currentPage.errors;
926
- }
927
- return super.errors;
928
- }
929
- showErrors(errors, triggerEvent) {
930
- // if (this.hasExtraPages) {
931
- // this.subWizards.forEach((subWizard) => {
932
- // if(Array.isArray(subWizard.errors)) {
933
- // errors = [...errors, ...subWizard.errors]
934
- // }
935
- // })
936
- // }
937
- return super.showErrors(errors, triggerEvent);
929
+ return !this.isLastPage() && !this.submitted ? this.currentPage.errors : super.errors;
938
930
  }
939
931
  focusOnComponent(key) {
940
932
  const component = this.getComponent(key);
@@ -105,7 +105,6 @@ declare class Wizard extends Webform {
105
105
  pageId(page: any): any;
106
106
  onChange(flags: any, changed: any, modified: any, changes: any): void;
107
107
  checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
108
- showErrors(errors: any, triggerEvent: any): void | any[];
109
108
  focusOnComponent(key: any): void | Promise<void>;
110
109
  }
111
110
  declare namespace Wizard {
package/lib/mjs/Wizard.js CHANGED
@@ -594,7 +594,10 @@ export default class Wizard extends Webform {
594
594
  }
595
595
  this.redraw().then(() => {
596
596
  this.checkData(this.submission.data);
597
- this.validateCurrentPage();
597
+ const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
598
+ if (this.alert) {
599
+ this.showErrors(errors, true, true);
600
+ }
598
601
  });
599
602
  return Promise.resolve();
600
603
  }
@@ -689,9 +692,11 @@ export default class Wizard extends Webform {
689
692
  });
690
693
  });
691
694
  }
692
- // Validate the form, before go to the next page
693
- const errors = this.validateCurrentPage({ dirty: true });
694
- if (errors.length === 0) {
695
+ // Validate the form before going to the next page
696
+ const currentPageErrors = this.validateCurrentPage({ dirty: true });
697
+ const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : currentPageErrors;
698
+ // allow going to the next page if the current page is valid, even if there are form level errors
699
+ if (currentPageErrors.length === 0) {
695
700
  this.checkData(this.submission.data);
696
701
  return this.beforePage(true).then(() => {
697
702
  return this.setPage(this.getNextPage()).then(() => {
@@ -706,7 +711,7 @@ export default class Wizard extends Webform {
706
711
  else {
707
712
  this.currentPage.components.forEach((comp) => comp.setPristine(false));
708
713
  this.scrollIntoView(this.element, true);
709
- return Promise.reject(super.showErrors(errors, true));
714
+ return Promise.reject(this.showErrors(errors, true));
710
715
  }
711
716
  }
712
717
  validateCurrentPage(flags = {}) {
@@ -854,7 +859,7 @@ export default class Wizard extends Webform {
854
859
  onChange(flags, changed, modified, changes) {
855
860
  super.onChange(flags, changed, modified, changes);
856
861
  // The onChange loop doesn't need all components for wizards
857
- const errors = this.submitted ? this.validate(this.localData, { dirty: false }) : this.validateCurrentPage();
862
+ const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
858
863
  if (this.alert) {
859
864
  this.showErrors(errors, true, true);
860
865
  }
@@ -908,20 +913,7 @@ export default class Wizard extends Webform {
908
913
  return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
909
914
  }
910
915
  get errors() {
911
- if (!this.isLastPage()) {
912
- return this.currentPage.errors;
913
- }
914
- return super.errors;
915
- }
916
- showErrors(errors, triggerEvent) {
917
- // if (this.hasExtraPages) {
918
- // this.subWizards.forEach((subWizard) => {
919
- // if(Array.isArray(subWizard.errors)) {
920
- // errors = [...errors, ...subWizard.errors]
921
- // }
922
- // })
923
- // }
924
- return super.showErrors(errors, triggerEvent);
916
+ return !this.isLastPage() && !this.submitted ? this.currentPage.errors : super.errors;
925
917
  }
926
918
  focusOnComponent(key) {
927
919
  const component = this.getComponent(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5920.f58ae24",
3
+ "version": "5.0.0-dev.5922.23f0b78",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {