@formio/js 5.0.0-dev.5914.479573c → 5.0.0-dev.5914.e8a58b3
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 +13 -13
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +14 -14
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +2 -2
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/WebformBuilder.js +10 -6
- package/lib/cjs/Wizard.d.ts +0 -1
- package/lib/cjs/Wizard.js +5 -13
- package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
- package/lib/cjs/components/form/Form.js +2 -1
- package/lib/mjs/WebformBuilder.js +10 -6
- package/lib/mjs/Wizard.d.ts +0 -1
- package/lib/mjs/Wizard.js +4 -12
- package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
- package/lib/mjs/components/form/Form.js +2 -1
- package/package.json +3 -3
|
@@ -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',
|
|
@@ -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.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
|
@@ -722,9 +722,10 @@ class Wizard extends Webform_1.default {
|
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
724
|
validateCurrentPage(flags = {}) {
|
|
725
|
-
var _a;
|
|
725
|
+
var _a, _b;
|
|
726
|
+
const components = (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.components.map((component) => component.component);
|
|
726
727
|
// Accessing the parent ensures the right instance (whether it's the parent Wizard or a nested Wizard) performs its validation
|
|
727
|
-
return (
|
|
728
|
+
return (_b = this.currentPage) === null || _b === void 0 ? void 0 : _b.parent.validateComponents(components, this.root.data, flags);
|
|
728
729
|
}
|
|
729
730
|
emitPrevPage() {
|
|
730
731
|
this.emit('prevPage', { page: this.page, submission: this.submission });
|
|
@@ -866,7 +867,8 @@ class Wizard extends Webform_1.default {
|
|
|
866
867
|
onChange(flags, changed, modified, changes) {
|
|
867
868
|
var _a, _b;
|
|
868
869
|
super.onChange(flags, changed, modified, changes);
|
|
869
|
-
|
|
870
|
+
// The onChange loop doesn't need all components for wizards
|
|
871
|
+
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
|
870
872
|
if (this.alert) {
|
|
871
873
|
this.showErrors(errors, true, true);
|
|
872
874
|
}
|
|
@@ -919,16 +921,6 @@ class Wizard extends Webform_1.default {
|
|
|
919
921
|
}
|
|
920
922
|
return super.errors;
|
|
921
923
|
}
|
|
922
|
-
showErrors(errors, triggerEvent) {
|
|
923
|
-
if (this.hasExtraPages) {
|
|
924
|
-
this.subWizards.forEach((subWizard) => {
|
|
925
|
-
if (Array.isArray(subWizard.errors)) {
|
|
926
|
-
errors = [...errors, ...subWizard.errors];
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
}
|
|
930
|
-
return super.showErrors(errors, triggerEvent);
|
|
931
|
-
}
|
|
932
924
|
focusOnComponent(key) {
|
|
933
925
|
const component = this.getComponent(key);
|
|
934
926
|
if (component) {
|
|
@@ -294,7 +294,7 @@ class FormComponent extends Component_1.default {
|
|
|
294
294
|
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
|
295
295
|
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
|
296
296
|
this.componentModal = new ComponentModal_1.default(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
|
297
|
-
this.subForm.element = this.componentModal.refs.
|
|
297
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
|
298
298
|
this.setOpenModalElement();
|
|
299
299
|
}
|
|
300
300
|
this.calculateValue();
|
|
@@ -396,6 +396,7 @@ class FormComponent extends Component_1.default {
|
|
|
396
396
|
const componentsMap = this.componentsMap;
|
|
397
397
|
const formComponentsMap = this.subForm.componentsMap;
|
|
398
398
|
lodash_1.default.assign(componentsMap, formComponentsMap);
|
|
399
|
+
this.component.components = this.subForm.components.map((comp) => comp.component);
|
|
399
400
|
this.subForm.parent = this;
|
|
400
401
|
this.subForm.parentVisible = this.visible;
|
|
401
402
|
this.subForm.on('change', () => {
|
|
@@ -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',
|
|
@@ -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.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
|
@@ -712,8 +712,9 @@ export default class Wizard extends Webform {
|
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
714
|
validateCurrentPage(flags = {}) {
|
|
715
|
+
const components = this.currentPage?.components.map((component) => component.component);
|
|
715
716
|
// Accessing the parent ensures the right instance (whether it's the parent Wizard or a nested Wizard) performs its validation
|
|
716
|
-
return this.currentPage?.parent.validateComponents(
|
|
717
|
+
return this.currentPage?.parent.validateComponents(components, this.root.data, flags);
|
|
717
718
|
}
|
|
718
719
|
emitPrevPage() {
|
|
719
720
|
this.emit('prevPage', { page: this.page, submission: this.submission });
|
|
@@ -854,7 +855,8 @@ export default class Wizard extends Webform {
|
|
|
854
855
|
}
|
|
855
856
|
onChange(flags, changed, modified, changes) {
|
|
856
857
|
super.onChange(flags, changed, modified, changes);
|
|
857
|
-
|
|
858
|
+
// The onChange loop doesn't need all components for wizards
|
|
859
|
+
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
|
858
860
|
if (this.alert) {
|
|
859
861
|
this.showErrors(errors, true, true);
|
|
860
862
|
}
|
|
@@ -907,16 +909,6 @@ export default class Wizard extends Webform {
|
|
|
907
909
|
}
|
|
908
910
|
return super.errors;
|
|
909
911
|
}
|
|
910
|
-
showErrors(errors, triggerEvent) {
|
|
911
|
-
if (this.hasExtraPages) {
|
|
912
|
-
this.subWizards.forEach((subWizard) => {
|
|
913
|
-
if (Array.isArray(subWizard.errors)) {
|
|
914
|
-
errors = [...errors, ...subWizard.errors];
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
return super.showErrors(errors, triggerEvent);
|
|
919
|
-
}
|
|
920
912
|
focusOnComponent(key) {
|
|
921
913
|
const component = this.getComponent(key);
|
|
922
914
|
if (component) {
|
|
@@ -291,7 +291,7 @@ export default class FormComponent extends Component {
|
|
|
291
291
|
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
|
292
292
|
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
|
293
293
|
this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
|
294
|
-
this.subForm.element = this.componentModal.refs.
|
|
294
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
|
295
295
|
this.setOpenModalElement();
|
|
296
296
|
}
|
|
297
297
|
this.calculateValue();
|
|
@@ -392,6 +392,7 @@ export default class FormComponent extends Component {
|
|
|
392
392
|
const componentsMap = this.componentsMap;
|
|
393
393
|
const formComponentsMap = this.subForm.componentsMap;
|
|
394
394
|
_.assign(componentsMap, formComponentsMap);
|
|
395
|
+
this.component.components = this.subForm.components.map((comp) => comp.component);
|
|
395
396
|
this.subForm.parent = this;
|
|
396
397
|
this.subForm.parentVisible = this.visible;
|
|
397
398
|
this.subForm.on('change', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.0.0-dev.5914.
|
|
3
|
+
"version": "5.0.0-dev.5914.e8a58b3",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
},
|
|
81
81
|
"homepage": "https://github.com/formio/formio.js#readme",
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@formio/bootstrap": "3.0.0-dev.
|
|
83
|
+
"@formio/bootstrap": "3.0.0-dev.111.ae7f187",
|
|
84
84
|
"@formio/choices.js": "^10.2.1",
|
|
85
|
-
"@formio/core": "2.1.0-dev.193.
|
|
85
|
+
"@formio/core": "2.1.0-dev.193.68cf8c3",
|
|
86
86
|
"@formio/text-mask-addons": "3.8.0-formio.4",
|
|
87
87
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
|
88
88
|
"abortcontroller-polyfill": "^1.7.5",
|