@formio/js 5.0.0-dev.5922.87eeb2f → 5.0.0-dev.5925.ef39512

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,13 +901,16 @@ class WebformBuilder extends Component_1.default {
901
901
  keyboardActionsEnabled = keyboardActionsEnabled === 'true';
902
902
  }
903
903
  this.keyboardActionsEnabled = keyboardActionsEnabled;
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)));
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);
909
912
  // Ensure there is at least a submit button.
910
- if (isShowSubmitButton) {
913
+ if (!noDefaultSubmitButton && shouldAddSubmitButton) {
911
914
  form.components.push({
912
915
  type: 'button',
913
916
  label: 'Submit',
@@ -1056,6 +1059,7 @@ class WebformBuilder extends Component_1.default {
1056
1059
  'conditional',
1057
1060
  'customConditional',
1058
1061
  'id',
1062
+ 'logic',
1059
1063
  'fields.day.required',
1060
1064
  'fields.month.required',
1061
1065
  'fields.year.required',
package/lib/cjs/Wizard.js CHANGED
@@ -602,10 +602,7 @@ class Wizard extends Webform_1.default {
602
602
  }
603
603
  this.redraw().then(() => {
604
604
  this.checkData(this.submission.data);
605
- const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
606
- if (this.alert) {
607
- this.showErrors(errors, true, true);
608
- }
605
+ this.validateCurrentPage();
609
606
  });
610
607
  return Promise.resolve();
611
608
  }
@@ -702,11 +699,9 @@ class Wizard extends Webform_1.default {
702
699
  });
703
700
  });
704
701
  }
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) {
702
+ // Validate the form, before go to the next page
703
+ const errors = this.validateCurrentPage({ dirty: true });
704
+ if (errors.length === 0) {
710
705
  this.checkData(this.submission.data);
711
706
  return this.beforePage(true).then(() => {
712
707
  return this.setPage(this.getNextPage()).then(() => {
@@ -721,7 +716,7 @@ class Wizard extends Webform_1.default {
721
716
  else {
722
717
  this.currentPage.components.forEach((comp) => comp.setPristine(false));
723
718
  this.scrollIntoView(this.element, true);
724
- return Promise.reject(this.showErrors(errors, true));
719
+ return Promise.reject(super.showErrors(errors, true));
725
720
  }
726
721
  }
727
722
  validateCurrentPage(flags = {}) {
@@ -926,7 +921,10 @@ class Wizard extends Webform_1.default {
926
921
  return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
927
922
  }
928
923
  get errors() {
929
- return !this.isLastPage() && !this.submitted ? this.currentPage.errors : super.errors;
924
+ if (!this.isLastPage()) {
925
+ return this.currentPage.errors;
926
+ }
927
+ return super.errors;
930
928
  }
931
929
  focusOnComponent(key) {
932
930
  const component = this.getComponent(key);
@@ -1,7 +1,8 @@
1
1
  export default class SelectBoxesComponent extends RadioComponent {
2
2
  static savedValueTypes(schema: any): string[];
3
3
  constructor(...args: any[]);
4
- get emptyValue(): any;
4
+ get emptyValue(): {};
5
+ get defaultValue(): {};
5
6
  /**
6
7
  * Only empty if the values are all false.
7
8
  * @param {any} value - The value to check if empty.
@@ -65,12 +65,7 @@ class SelectBoxesComponent extends Radio_1.default {
65
65
  return info;
66
66
  }
67
67
  get emptyValue() {
68
- return this.component.values.reduce((prev, value) => {
69
- if (value.value) {
70
- prev[value.value] = false;
71
- }
72
- return prev;
73
- }, {});
68
+ return {};
74
69
  }
75
70
  get defaultValue() {
76
71
  let defaultValue = this.emptyValue;
@@ -267,7 +262,6 @@ class SelectBoxesComponent extends Radio_1.default {
267
262
  else {
268
263
  return super.setCustomValidity(messages, dirty, external);
269
264
  }
270
- ;
271
265
  }
272
266
  validateValueAvailability(setting, value) {
273
267
  if (!(0, utils_1.boolValue)(setting) || !value) {
@@ -885,13 +885,16 @@ export default class WebformBuilder extends Component {
885
885
  keyboardActionsEnabled = keyboardActionsEnabled === 'true';
886
886
  }
887
887
  this.keyboardActionsEnabled = keyboardActionsEnabled;
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)));
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);
893
896
  // Ensure there is at least a submit button.
894
- if (isShowSubmitButton) {
897
+ if (!noDefaultSubmitButton && shouldAddSubmitButton) {
895
898
  form.components.push({
896
899
  type: 'button',
897
900
  label: 'Submit',
@@ -1040,6 +1043,7 @@ export default class WebformBuilder extends Component {
1040
1043
  'conditional',
1041
1044
  'customConditional',
1042
1045
  'id',
1046
+ 'logic',
1043
1047
  'fields.day.required',
1044
1048
  'fields.month.required',
1045
1049
  'fields.year.required',
package/lib/mjs/Wizard.js CHANGED
@@ -594,10 +594,7 @@ export default class Wizard extends Webform {
594
594
  }
595
595
  this.redraw().then(() => {
596
596
  this.checkData(this.submission.data);
597
- const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
598
- if (this.alert) {
599
- this.showErrors(errors, true, true);
600
- }
597
+ this.validateCurrentPage();
601
598
  });
602
599
  return Promise.resolve();
603
600
  }
@@ -692,11 +689,9 @@ export default class Wizard extends Webform {
692
689
  });
693
690
  });
694
691
  }
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) {
692
+ // Validate the form, before go to the next page
693
+ const errors = this.validateCurrentPage({ dirty: true });
694
+ if (errors.length === 0) {
700
695
  this.checkData(this.submission.data);
701
696
  return this.beforePage(true).then(() => {
702
697
  return this.setPage(this.getNextPage()).then(() => {
@@ -711,7 +706,7 @@ export default class Wizard extends Webform {
711
706
  else {
712
707
  this.currentPage.components.forEach((comp) => comp.setPristine(false));
713
708
  this.scrollIntoView(this.element, true);
714
- return Promise.reject(this.showErrors(errors, true));
709
+ return Promise.reject(super.showErrors(errors, true));
715
710
  }
716
711
  }
717
712
  validateCurrentPage(flags = {}) {
@@ -913,7 +908,10 @@ export default class Wizard extends Webform {
913
908
  return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
914
909
  }
915
910
  get errors() {
916
- return !this.isLastPage() && !this.submitted ? this.currentPage.errors : super.errors;
911
+ if (!this.isLastPage()) {
912
+ return this.currentPage.errors;
913
+ }
914
+ return super.errors;
917
915
  }
918
916
  focusOnComponent(key) {
919
917
  const component = this.getComponent(key);
@@ -1,7 +1,8 @@
1
1
  export default class SelectBoxesComponent extends RadioComponent {
2
2
  static savedValueTypes(schema: any): string[];
3
3
  constructor(...args: any[]);
4
- get emptyValue(): any;
4
+ get emptyValue(): {};
5
+ get defaultValue(): {};
5
6
  /**
6
7
  * Only empty if the values are all false.
7
8
  * @param {any} value - The value to check if empty.
@@ -67,12 +67,7 @@ export default class SelectBoxesComponent extends RadioComponent {
67
67
  return info;
68
68
  }
69
69
  get emptyValue() {
70
- return this.component.values.reduce((prev, value) => {
71
- if (value.value) {
72
- prev[value.value] = false;
73
- }
74
- return prev;
75
- }, {});
70
+ return {};
76
71
  }
77
72
  get defaultValue() {
78
73
  let defaultValue = this.emptyValue;
@@ -268,7 +263,6 @@ export default class SelectBoxesComponent extends RadioComponent {
268
263
  else {
269
264
  return super.setCustomValidity(messages, dirty, external);
270
265
  }
271
- ;
272
266
  }
273
267
  validateValueAvailability(setting, value) {
274
268
  if (!boolValue(setting) || !value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5922.87eeb2f",
3
+ "version": "5.0.0-dev.5925.ef39512",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {