@formio/js 5.0.0-dev.5915.7385833 → 5.0.0-dev.5919.408636c
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/Changelog.md +3 -0
- package/dist/formio.form.js +2 -2
- 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 +13 -23
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/cjs/components/hidden/Hidden.d.ts +0 -1
- package/lib/cjs/components/hidden/Hidden.js +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -0
- package/lib/mjs/WebformBuilder.js +13 -23
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/mjs/components/hidden/Hidden.d.ts +0 -1
- package/lib/mjs/components/hidden/Hidden.js +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -0
- package/package.json +1 -1
|
@@ -808,31 +808,18 @@ class WebformBuilder extends Component_1.default {
|
|
|
808
808
|
// Show an error if siblings are disabled for a component and such a component already exists.
|
|
809
809
|
const compKey = (group === 'resource') ? `component-${key}` : key;
|
|
810
810
|
const draggableComponent = ((_a = this.groups[group]) === null || _a === void 0 ? void 0 : _a.components[compKey]) || {};
|
|
811
|
-
if (draggableComponent.disableSiblings) {
|
|
811
|
+
if (draggableComponent.disableSiblings || draggableComponent.uniqueComponent) {
|
|
812
812
|
let isCompAlreadyExists = false;
|
|
813
813
|
(0, formUtils_1.eachComponent)(this.webform.components, (component) => {
|
|
814
|
-
if (component.type === draggableComponent.schema.type)
|
|
814
|
+
if ((draggableComponent.disableSiblings && component.type === draggableComponent.schema.type) ||
|
|
815
|
+
(draggableComponent.uniqueComponent && component.component.key === draggableComponent.schema.key)) {
|
|
815
816
|
isCompAlreadyExists = true;
|
|
816
817
|
return;
|
|
817
818
|
}
|
|
818
819
|
}, true);
|
|
819
820
|
if (isCompAlreadyExists) {
|
|
820
821
|
this.webform.redraw();
|
|
821
|
-
this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.key} component to one page.`);
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
if (draggableComponent.uniqueComponent) {
|
|
826
|
-
let isCompAlreadyExists = false;
|
|
827
|
-
(0, formUtils_1.eachComponent)(this.webform.components, (component) => {
|
|
828
|
-
if (component.key === draggableComponent.schema.key) {
|
|
829
|
-
isCompAlreadyExists = true;
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
}, true);
|
|
833
|
-
if (isCompAlreadyExists) {
|
|
834
|
-
this.webform.redraw();
|
|
835
|
-
this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.title} component to one page.`);
|
|
822
|
+
this.webform.setAlert('danger', `You cannot add more than one ${lodash_1.default.get(draggableComponent, draggableComponent.uniqueComponent ? 'title' : 'key')} component to one page.`);
|
|
836
823
|
return;
|
|
837
824
|
}
|
|
838
825
|
}
|
|
@@ -914,13 +901,16 @@ class WebformBuilder extends Component_1.default {
|
|
|
914
901
|
keyboardActionsEnabled = keyboardActionsEnabled === 'true';
|
|
915
902
|
}
|
|
916
903
|
this.keyboardActionsEnabled = keyboardActionsEnabled;
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
};
|
|
920
|
-
const
|
|
921
|
-
|
|
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);
|
|
922
912
|
// Ensure there is at least a submit button.
|
|
923
|
-
if (
|
|
913
|
+
if (!noDefaultSubmitButton && shouldAddSubmitButton) {
|
|
924
914
|
form.components.push({
|
|
925
915
|
type: 'button',
|
|
926
916
|
label: 'Submit',
|
|
@@ -27,7 +27,7 @@ exports.default = [
|
|
|
27
27
|
weight: 100,
|
|
28
28
|
type: 'checkbox',
|
|
29
29
|
label: 'Validate When Hidden',
|
|
30
|
-
tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission.',
|
|
30
|
+
tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission. Use caution when enabling this setting, as it can cause a hidden component to be invalid with no way for the form user to correct it.',
|
|
31
31
|
key: 'validateWhenHidden',
|
|
32
32
|
input: true
|
|
33
33
|
},
|
|
@@ -1099,6 +1099,7 @@ declare const _default: ({
|
|
|
1099
1099
|
alwaysEnabled?: undefined;
|
|
1100
1100
|
} | {
|
|
1101
1101
|
key: string;
|
|
1102
|
+
type: string;
|
|
1102
1103
|
conditional: {
|
|
1103
1104
|
json: {
|
|
1104
1105
|
and: ({
|
|
@@ -1149,7 +1150,6 @@ declare const _default: ({
|
|
|
1149
1150
|
};
|
|
1150
1151
|
};
|
|
1151
1152
|
data?: undefined;
|
|
1152
|
-
type?: undefined;
|
|
1153
1153
|
weight?: undefined;
|
|
1154
1154
|
input?: undefined;
|
|
1155
1155
|
label?: undefined;
|
|
@@ -793,31 +793,18 @@ export default class WebformBuilder extends Component {
|
|
|
793
793
|
// Show an error if siblings are disabled for a component and such a component already exists.
|
|
794
794
|
const compKey = (group === 'resource') ? `component-${key}` : key;
|
|
795
795
|
const draggableComponent = this.groups[group]?.components[compKey] || {};
|
|
796
|
-
if (draggableComponent.disableSiblings) {
|
|
796
|
+
if (draggableComponent.disableSiblings || draggableComponent.uniqueComponent) {
|
|
797
797
|
let isCompAlreadyExists = false;
|
|
798
798
|
eachComponent(this.webform.components, (component) => {
|
|
799
|
-
if (component.type === draggableComponent.schema.type)
|
|
799
|
+
if ((draggableComponent.disableSiblings && component.type === draggableComponent.schema.type) ||
|
|
800
|
+
(draggableComponent.uniqueComponent && component.component.key === draggableComponent.schema.key)) {
|
|
800
801
|
isCompAlreadyExists = true;
|
|
801
802
|
return;
|
|
802
803
|
}
|
|
803
804
|
}, true);
|
|
804
805
|
if (isCompAlreadyExists) {
|
|
805
806
|
this.webform.redraw();
|
|
806
|
-
this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.key} component to one page.`);
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
if (draggableComponent.uniqueComponent) {
|
|
811
|
-
let isCompAlreadyExists = false;
|
|
812
|
-
eachComponent(this.webform.components, (component) => {
|
|
813
|
-
if (component.key === draggableComponent.schema.key) {
|
|
814
|
-
isCompAlreadyExists = true;
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
}, true);
|
|
818
|
-
if (isCompAlreadyExists) {
|
|
819
|
-
this.webform.redraw();
|
|
820
|
-
this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.title} component to one page.`);
|
|
807
|
+
this.webform.setAlert('danger', `You cannot add more than one ${_.get(draggableComponent, draggableComponent.uniqueComponent ? 'title' : 'key')} component to one page.`);
|
|
821
808
|
return;
|
|
822
809
|
}
|
|
823
810
|
}
|
|
@@ -898,13 +885,16 @@ export default class WebformBuilder extends Component {
|
|
|
898
885
|
keyboardActionsEnabled = keyboardActionsEnabled === 'true';
|
|
899
886
|
}
|
|
900
887
|
this.keyboardActionsEnabled = keyboardActionsEnabled;
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
};
|
|
904
|
-
const
|
|
905
|
-
|
|
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);
|
|
906
896
|
// Ensure there is at least a submit button.
|
|
907
|
-
if (
|
|
897
|
+
if (!noDefaultSubmitButton && shouldAddSubmitButton) {
|
|
908
898
|
form.components.push({
|
|
909
899
|
type: 'button',
|
|
910
900
|
label: 'Submit',
|
|
@@ -22,7 +22,7 @@ export default [
|
|
|
22
22
|
weight: 100,
|
|
23
23
|
type: 'checkbox',
|
|
24
24
|
label: 'Validate When Hidden',
|
|
25
|
-
tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission.',
|
|
25
|
+
tooltip: 'Validates the component when it is hidden/conditionally hidden. Vaildation errors are displayed in the error alert on the form submission. Use caution when enabling this setting, as it can cause a hidden component to be invalid with no way for the form user to correct it.',
|
|
26
26
|
key: 'validateWhenHidden',
|
|
27
27
|
input: true
|
|
28
28
|
},
|
|
@@ -1099,6 +1099,7 @@ declare const _default: ({
|
|
|
1099
1099
|
alwaysEnabled?: undefined;
|
|
1100
1100
|
} | {
|
|
1101
1101
|
key: string;
|
|
1102
|
+
type: string;
|
|
1102
1103
|
conditional: {
|
|
1103
1104
|
json: {
|
|
1104
1105
|
and: ({
|
|
@@ -1149,7 +1150,6 @@ declare const _default: ({
|
|
|
1149
1150
|
};
|
|
1150
1151
|
};
|
|
1151
1152
|
data?: undefined;
|
|
1152
|
-
type?: undefined;
|
|
1153
1153
|
weight?: undefined;
|
|
1154
1154
|
input?: undefined;
|
|
1155
1155
|
label?: undefined;
|