@formio/js 5.0.0-dev.5919.408636c → 5.0.0-dev.5920.f58ae24

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.
@@ -901,16 +901,13 @@ class WebformBuilder extends Component_1.default {
901
901
  keyboardActionsEnabled = keyboardActionsEnabled === 'true';
902
902
  }
903
903
  this.keyboardActionsEnabled = keyboardActionsEnabled;
904
- const { display, noAddSubmitButton, noDefaultSubmitButton } = this.options;
905
- const { _id, components } = form;
906
- const isSubmitButton = ({ type, action }) => type === 'button' && (action === 'submit' || !action);
907
- const hasSubmitButton = components.some(isSubmitButton);
908
- // Add submit button if form display was switched from wizard
909
- // Don't add if there is noAddSubmitButton flag passed, or the form has id, or the form has a submit button already
910
- const shouldAddSubmitButton = (display === 'wizard' && !hasSubmitButton) ||
911
- (!noAddSubmitButton && !_id && !hasSubmitButton);
904
+ const isSubmitButton = (comp) => {
905
+ return (comp.type === 'button') && ((comp.action === 'submit') || !comp.action);
906
+ };
907
+ const isShowSubmitButton = !this.options.noDefaultSubmitButton
908
+ && (!form.components.length || !form.components.find(comp => isSubmitButton(comp)));
912
909
  // Ensure there is at least a submit button.
913
- if (!noDefaultSubmitButton && shouldAddSubmitButton) {
910
+ if (isShowSubmitButton) {
914
911
  form.components.push({
915
912
  type: 'button',
916
913
  label: 'Submit',
package/lib/cjs/Wizard.js CHANGED
@@ -720,9 +720,10 @@ class Wizard extends Webform_1.default {
720
720
  }
721
721
  }
722
722
  validateCurrentPage(flags = {}) {
723
- var _a;
723
+ var _a, _b;
724
+ const components = (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components.map((component) => component.component);
724
725
  // Accessing the parent ensures the right instance (whether it's the parent Wizard or a nested Wizard) performs its validation
725
- return (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.parent.validateComponents(this.currentPage.component.components, this.currentPage.parent.data, flags);
726
+ return (_b = this.currentPage) === null || _b === void 0 ? void 0 : _b.parent.validateComponents(components, this.currentPage.parent.data, flags);
726
727
  }
727
728
  emitPrevPage() {
728
729
  this.emit('prevPage', { page: this.page, submission: this.submission });
@@ -864,7 +865,8 @@ class Wizard extends Webform_1.default {
864
865
  onChange(flags, changed, modified, changes) {
865
866
  var _a, _b;
866
867
  super.onChange(flags, changed, modified, changes);
867
- const errors = this.validate(this.localData, { dirty: false });
868
+ // The onChange loop doesn't need all components for wizards
869
+ const errors = this.submitted ? this.validate(this.localData, { dirty: false }) : this.validateCurrentPage();
868
870
  if (this.alert) {
869
871
  this.showErrors(errors, true, true);
870
872
  }
@@ -925,14 +927,13 @@ class Wizard extends Webform_1.default {
925
927
  return super.errors;
926
928
  }
927
929
  showErrors(errors, triggerEvent) {
928
- if (this.hasExtraPages) {
929
- this.subWizards.forEach((subWizard) => {
930
- if (Array.isArray(subWizard.errors)) {
931
- errors = [...errors, ...subWizard.errors];
932
- }
933
- });
934
- }
935
- ;
930
+ // if (this.hasExtraPages) {
931
+ // this.subWizards.forEach((subWizard) => {
932
+ // if(Array.isArray(subWizard.errors)) {
933
+ // errors = [...errors, ...subWizard.errors]
934
+ // }
935
+ // })
936
+ // }
936
937
  return super.showErrors(errors, triggerEvent);
937
938
  }
938
939
  focusOnComponent(key) {
@@ -476,7 +476,7 @@ class FormComponent extends Component_1.default {
476
476
  checkComponentValidity(data, dirty, row, options, errors = []) {
477
477
  options = options || {};
478
478
  const silentCheck = options.silentCheck || false;
479
- if (this.subForm && !this.isNestedWizard) {
479
+ if (this.subForm) {
480
480
  return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
481
481
  }
482
482
  return super.checkComponentValidity(data, dirty, row, options, errors);
@@ -885,16 +885,13 @@ export default class WebformBuilder extends Component {
885
885
  keyboardActionsEnabled = keyboardActionsEnabled === 'true';
886
886
  }
887
887
  this.keyboardActionsEnabled = keyboardActionsEnabled;
888
- const { display, noAddSubmitButton, noDefaultSubmitButton } = this.options;
889
- const { _id, components } = form;
890
- const isSubmitButton = ({ type, action }) => type === 'button' && (action === 'submit' || !action);
891
- const hasSubmitButton = components.some(isSubmitButton);
892
- // Add submit button if form display was switched from wizard
893
- // Don't add if there is noAddSubmitButton flag passed, or the form has id, or the form has a submit button already
894
- const shouldAddSubmitButton = (display === 'wizard' && !hasSubmitButton) ||
895
- (!noAddSubmitButton && !_id && !hasSubmitButton);
888
+ const isSubmitButton = (comp) => {
889
+ return (comp.type === 'button') && ((comp.action === 'submit') || !comp.action);
890
+ };
891
+ const isShowSubmitButton = !this.options.noDefaultSubmitButton
892
+ && (!form.components.length || !form.components.find(comp => isSubmitButton(comp)));
896
893
  // Ensure there is at least a submit button.
897
- if (!noDefaultSubmitButton && shouldAddSubmitButton) {
894
+ if (isShowSubmitButton) {
898
895
  form.components.push({
899
896
  type: 'button',
900
897
  label: 'Submit',
package/lib/mjs/Wizard.js CHANGED
@@ -710,8 +710,9 @@ export default class Wizard extends Webform {
710
710
  }
711
711
  }
712
712
  validateCurrentPage(flags = {}) {
713
+ const components = this.currentPage?.components.map((component) => component.component);
713
714
  // Accessing the parent ensures the right instance (whether it's the parent Wizard or a nested Wizard) performs its validation
714
- return this.currentPage?.parent.validateComponents(this.currentPage.component.components, this.currentPage.parent.data, flags);
715
+ return this.currentPage?.parent.validateComponents(components, this.currentPage.parent.data, flags);
715
716
  }
716
717
  emitPrevPage() {
717
718
  this.emit('prevPage', { page: this.page, submission: this.submission });
@@ -852,7 +853,8 @@ export default class Wizard extends Webform {
852
853
  }
853
854
  onChange(flags, changed, modified, changes) {
854
855
  super.onChange(flags, changed, modified, changes);
855
- const errors = this.validate(this.localData, { dirty: false });
856
+ // The onChange loop doesn't need all components for wizards
857
+ const errors = this.submitted ? this.validate(this.localData, { dirty: false }) : this.validateCurrentPage();
856
858
  if (this.alert) {
857
859
  this.showErrors(errors, true, true);
858
860
  }
@@ -912,14 +914,13 @@ export default class Wizard extends Webform {
912
914
  return super.errors;
913
915
  }
914
916
  showErrors(errors, triggerEvent) {
915
- if (this.hasExtraPages) {
916
- this.subWizards.forEach((subWizard) => {
917
- if (Array.isArray(subWizard.errors)) {
918
- errors = [...errors, ...subWizard.errors];
919
- }
920
- });
921
- }
922
- ;
917
+ // if (this.hasExtraPages) {
918
+ // this.subWizards.forEach((subWizard) => {
919
+ // if(Array.isArray(subWizard.errors)) {
920
+ // errors = [...errors, ...subWizard.errors]
921
+ // }
922
+ // })
923
+ // }
923
924
  return super.showErrors(errors, triggerEvent);
924
925
  }
925
926
  focusOnComponent(key) {
@@ -470,7 +470,7 @@ export default class FormComponent extends Component {
470
470
  checkComponentValidity(data, dirty, row, options, errors = []) {
471
471
  options = options || {};
472
472
  const silentCheck = options.silentCheck || false;
473
- if (this.subForm && !this.isNestedWizard) {
473
+ if (this.subForm) {
474
474
  return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
475
475
  }
476
476
  return super.checkComponentValidity(data, dirty, row, options, errors);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5919.408636c",
3
+ "version": "5.0.0-dev.5920.f58ae24",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {