@formio/js 5.0.0-dev.5923.b428b7b → 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.
- package/dist/formio.form.js +3 -3
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +4 -4
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/WebformBuilder.js +9 -6
- package/lib/cjs/Wizard.d.ts +0 -1
- package/lib/cjs/Wizard.js +5 -14
- package/lib/cjs/components/form/Form.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +2 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -7
- package/lib/mjs/WebformBuilder.js +9 -6
- package/lib/mjs/Wizard.d.ts +0 -1
- package/lib/mjs/Wizard.js +4 -13
- package/lib/mjs/components/form/Form.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +2 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -7
- package/package.json +1 -1
|
@@ -901,13 +901,16 @@ class WebformBuilder extends Component_1.default {
|
|
|
901
901
|
keyboardActionsEnabled = keyboardActionsEnabled === 'true';
|
|
902
902
|
}
|
|
903
903
|
this.keyboardActionsEnabled = keyboardActionsEnabled;
|
|
904
|
-
const
|
|
905
|
-
|
|
906
|
-
};
|
|
907
|
-
const
|
|
908
|
-
|
|
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 (
|
|
913
|
+
if (!noDefaultSubmitButton && shouldAddSubmitButton) {
|
|
911
914
|
form.components.push({
|
|
912
915
|
type: 'button',
|
|
913
916
|
label: 'Submit',
|
package/lib/cjs/Wizard.d.ts
CHANGED
|
@@ -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
|
@@ -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 (
|
|
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
|
-
|
|
868
|
+
// The onChange loop doesn't need all components for wizards
|
|
869
|
+
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
|
868
870
|
if (this.alert) {
|
|
869
871
|
this.showErrors(errors, true, true);
|
|
870
872
|
}
|
|
@@ -924,17 +926,6 @@ class Wizard extends Webform_1.default {
|
|
|
924
926
|
}
|
|
925
927
|
return super.errors;
|
|
926
928
|
}
|
|
927
|
-
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
|
-
;
|
|
936
|
-
return super.showErrors(errors, triggerEvent);
|
|
937
|
-
}
|
|
938
929
|
focusOnComponent(key) {
|
|
939
930
|
const component = this.getComponent(key);
|
|
940
931
|
if (component) {
|
|
@@ -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
|
|
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);
|
|
@@ -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():
|
|
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
|
|
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
|
|
889
|
-
|
|
890
|
-
};
|
|
891
|
-
const
|
|
892
|
-
|
|
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 (
|
|
897
|
+
if (!noDefaultSubmitButton && shouldAddSubmitButton) {
|
|
895
898
|
form.components.push({
|
|
896
899
|
type: 'button',
|
|
897
900
|
label: 'Submit',
|
package/lib/mjs/Wizard.d.ts
CHANGED
|
@@ -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
|
@@ -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(
|
|
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
|
-
|
|
856
|
+
// The onChange loop doesn't need all components for wizards
|
|
857
|
+
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
|
856
858
|
if (this.alert) {
|
|
857
859
|
this.showErrors(errors, true, true);
|
|
858
860
|
}
|
|
@@ -911,17 +913,6 @@ export default class Wizard extends Webform {
|
|
|
911
913
|
}
|
|
912
914
|
return super.errors;
|
|
913
915
|
}
|
|
914
|
-
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
|
-
;
|
|
923
|
-
return super.showErrors(errors, triggerEvent);
|
|
924
|
-
}
|
|
925
916
|
focusOnComponent(key) {
|
|
926
917
|
const component = this.getComponent(key);
|
|
927
918
|
if (component) {
|
|
@@ -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
|
|
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);
|
|
@@ -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():
|
|
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
|
|
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) {
|