@formio/js 5.4.0 → 5.4.2
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/README.md +11 -5
- package/dist/formio.builder.css +12 -5
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +12 -5
- package/dist/formio.form.js +2883 -2867
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -2
- package/dist/formio.full.css +12 -5
- package/dist/formio.full.js +3507 -3491
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -2
- package/dist/formio.js +1139 -1145
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -2
- package/dist/formio.utils.js +1066 -1072
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -2
- package/lib/cjs/Embed.js +8 -16
- package/lib/cjs/Form.js +4 -4
- package/lib/cjs/Formio.js +2 -9
- package/lib/cjs/InlineEmbed.js +1 -4
- package/lib/cjs/PDF.js +28 -8
- package/lib/cjs/PDFBuilder.js +6 -10
- package/lib/cjs/Webform.d.ts +1 -0
- package/lib/cjs/Webform.js +19 -34
- package/lib/cjs/WebformBuilder.js +27 -68
- package/lib/cjs/Wizard.d.ts +1 -0
- package/lib/cjs/Wizard.js +44 -31
- package/lib/cjs/WizardBuilder.js +5 -15
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
- package/lib/cjs/addons/index.js +1 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +10 -5
- package/lib/cjs/components/_classes/component/Component.js +76 -134
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
- package/lib/cjs/components/_classes/field/Field.js +1 -4
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -26
- package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -4
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
- package/lib/cjs/components/address/Address.js +10 -30
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -32
- package/lib/cjs/components/alert/Alert.js +3 -6
- package/lib/cjs/components/button/Button.d.ts +1 -0
- package/lib/cjs/components/button/Button.js +31 -17
- package/lib/cjs/components/button/editForm/Button.edit.display.js +8 -32
- package/lib/cjs/components/checkbox/Checkbox.js +4 -10
- package/lib/cjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
- package/lib/cjs/components/columns/Columns.js +5 -17
- package/lib/cjs/components/container/Container.js +1 -3
- package/lib/cjs/components/currency/Currency.js +2 -7
- package/lib/cjs/components/datagrid/DataGrid.js +27 -68
- package/lib/cjs/components/datamap/DataMap.js +4 -16
- package/lib/cjs/components/datetime/DateTime.js +2 -6
- package/lib/cjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
- package/lib/cjs/components/day/Day.js +12 -70
- package/lib/cjs/components/day/editForm/Day.edit.day.js +1 -3
- package/lib/cjs/components/day/editForm/Day.edit.month.js +1 -3
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -0
- package/lib/cjs/components/editgrid/EditGrid.js +18 -44
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
- package/lib/cjs/components/file/File.js +40 -70
- package/lib/cjs/components/file/editForm/File.edit.display.js +1 -5
- package/lib/cjs/components/file/editForm/File.edit.file.js +8 -30
- package/lib/cjs/components/form/Form.js +5 -7
- package/lib/cjs/components/html/HTML.js +1 -5
- package/lib/cjs/components/number/Number.js +2 -4
- package/lib/cjs/components/panel/editForm/Panel.edit.display.js +3 -12
- package/lib/cjs/components/password/Password.js +1 -4
- package/lib/cjs/components/radio/Radio.js +7 -17
- package/lib/cjs/components/radio/editForm/Radio.edit.data.js +4 -14
- package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -6
- package/lib/cjs/components/select/Select.js +49 -94
- package/lib/cjs/components/select/editForm/Select.edit.data.js +37 -182
- package/lib/cjs/components/select/editForm/Select.edit.validation.js +1 -9
- package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -6
- package/lib/cjs/components/signature/Signature.d.ts +1 -1
- package/lib/cjs/components/signature/Signature.js +5 -10
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +2 -6
- package/lib/cjs/components/survey/Survey.js +6 -17
- package/lib/cjs/components/survey/editForm/Survey.edit.data.js +4 -12
- package/lib/cjs/components/table/editForm/Table.edit.display.js +3 -3
- package/lib/cjs/components/tabs/Tabs.js +4 -19
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
- package/lib/cjs/components/tags/Tags.js +4 -14
- package/lib/cjs/components/textarea/TextArea.js +8 -15
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
- package/lib/cjs/components/textfield/TextField.js +4 -4
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +2 -8
- package/lib/cjs/components/time/Time.js +1 -4
- package/lib/cjs/components/time/editForm/Time.edit.display.js +1 -4
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/providers/address/AddressProvider.js +1 -1
- package/lib/cjs/providers/address/GoogleAddressProvider.js +2 -4
- package/lib/cjs/providers/processor/fileProcessor.js +1 -3
- package/lib/cjs/providers/storage/azure.js +5 -6
- package/lib/cjs/providers/storage/indexeddb.js +5 -15
- package/lib/cjs/providers/storage/s3.js +3 -14
- package/lib/cjs/providers/storage/xhr.js +19 -28
- package/lib/cjs/templates/Templates.js +1 -0
- package/lib/cjs/translations/en.d.ts +237 -81
- package/lib/cjs/translations/en.js +10 -81
- package/lib/cjs/utils/ChoicesWrapper.js +1 -1
- package/lib/cjs/utils/builder.js +5 -26
- package/lib/cjs/utils/i18n.d.ts +5 -2
- package/lib/cjs/utils/i18n.js +33 -12
- package/lib/cjs/utils/utils.js +42 -52
- package/lib/cjs/widgets/CalendarWidget.js +2 -6
- package/lib/mjs/Embed.js +8 -16
- package/lib/mjs/Form.js +4 -4
- package/lib/mjs/Formio.js +2 -9
- package/lib/mjs/InlineEmbed.js +1 -4
- package/lib/mjs/PDF.js +27 -8
- package/lib/mjs/PDFBuilder.js +6 -10
- package/lib/mjs/Webform.d.ts +1 -0
- package/lib/mjs/Webform.js +19 -31
- package/lib/mjs/WebformBuilder.js +27 -68
- package/lib/mjs/Wizard.d.ts +1 -0
- package/lib/mjs/Wizard.js +39 -27
- package/lib/mjs/WizardBuilder.js +5 -15
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
- package/lib/mjs/addons/index.js +1 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +10 -5
- package/lib/mjs/components/_classes/component/Component.js +75 -134
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
- package/lib/mjs/components/_classes/field/Field.js +1 -4
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -26
- package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -4
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
- package/lib/mjs/components/address/Address.js +10 -30
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -32
- package/lib/mjs/components/alert/Alert.js +3 -6
- package/lib/mjs/components/button/Button.d.ts +1 -0
- package/lib/mjs/components/button/Button.js +29 -16
- package/lib/mjs/components/button/editForm/Button.edit.display.js +8 -32
- package/lib/mjs/components/checkbox/Checkbox.js +4 -10
- package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
- package/lib/mjs/components/columns/Columns.js +5 -17
- package/lib/mjs/components/container/Container.js +1 -3
- package/lib/mjs/components/currency/Currency.js +2 -7
- package/lib/mjs/components/datagrid/DataGrid.js +28 -69
- package/lib/mjs/components/datamap/DataMap.js +12 -18
- package/lib/mjs/components/datetime/DateTime.js +2 -6
- package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
- package/lib/mjs/components/day/Day.js +12 -70
- package/lib/mjs/components/day/editForm/Day.edit.day.js +1 -3
- package/lib/mjs/components/day/editForm/Day.edit.month.js +1 -3
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -0
- package/lib/mjs/components/editgrid/EditGrid.js +18 -44
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
- package/lib/mjs/components/file/File.js +40 -70
- package/lib/mjs/components/file/editForm/File.edit.display.js +1 -5
- package/lib/mjs/components/file/editForm/File.edit.file.js +8 -30
- package/lib/mjs/components/form/Form.js +5 -7
- package/lib/mjs/components/html/HTML.js +1 -5
- package/lib/mjs/components/number/Number.js +2 -4
- package/lib/mjs/components/panel/editForm/Panel.edit.display.js +3 -12
- package/lib/mjs/components/password/Password.js +1 -4
- package/lib/mjs/components/radio/Radio.js +7 -17
- package/lib/mjs/components/radio/editForm/Radio.edit.data.js +4 -14
- package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -6
- package/lib/mjs/components/select/Select.js +52 -97
- package/lib/mjs/components/select/editForm/Select.edit.data.js +37 -182
- package/lib/mjs/components/select/editForm/Select.edit.validation.js +1 -9
- package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -6
- package/lib/mjs/components/signature/Signature.d.ts +1 -1
- package/lib/mjs/components/signature/Signature.js +5 -10
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +2 -6
- package/lib/mjs/components/survey/Survey.js +6 -17
- package/lib/mjs/components/survey/editForm/Survey.edit.data.js +4 -12
- package/lib/mjs/components/table/editForm/Table.edit.display.js +3 -3
- package/lib/mjs/components/tabs/Tabs.js +4 -19
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
- package/lib/mjs/components/tags/Tags.js +4 -14
- package/lib/mjs/components/textarea/TextArea.js +8 -15
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
- package/lib/mjs/components/textfield/TextField.js +4 -4
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +2 -8
- package/lib/mjs/components/time/Time.js +1 -4
- package/lib/mjs/components/time/editForm/Time.edit.display.js +1 -4
- package/lib/mjs/formio.form.js +6 -6
- package/lib/mjs/package.json +1 -1
- package/lib/mjs/providers/address/AddressProvider.js +1 -1
- package/lib/mjs/providers/address/GoogleAddressProvider.js +2 -4
- package/lib/mjs/providers/processor/fileProcessor.js +1 -3
- package/lib/mjs/providers/storage/azure.js +5 -6
- package/lib/mjs/providers/storage/indexeddb.js +5 -15
- package/lib/mjs/providers/storage/s3.js +3 -14
- package/lib/mjs/providers/storage/xhr.js +19 -32
- package/lib/mjs/templates/Templates.js +1 -0
- package/lib/mjs/translations/en.d.ts +237 -81
- package/lib/mjs/translations/en.js +91 -1
- package/lib/mjs/utils/ChoicesWrapper.js +1 -1
- package/lib/mjs/utils/builder.js +5 -26
- package/lib/mjs/utils/i18n.d.ts +5 -2
- package/lib/mjs/utils/i18n.js +33 -12
- package/lib/mjs/utils/utils.js +42 -52
- package/lib/mjs/widgets/CalendarWidget.js +2 -6
- package/package.json +8 -6
|
@@ -92,10 +92,7 @@ exports.default = [
|
|
|
92
92
|
defaultValue: true,
|
|
93
93
|
customConditional({ data = {}, buildingForm = {} }) {
|
|
94
94
|
const formSettings = buildingForm.settings || {};
|
|
95
|
-
return ![
|
|
96
|
-
data.breadcrumb,
|
|
97
|
-
formSettings.wizardBreadcrumbsType,
|
|
98
|
-
].includes('none');
|
|
95
|
+
return ![data.breadcrumb, formSettings.wizardBreadcrumbsType].includes('none');
|
|
99
96
|
},
|
|
100
97
|
},
|
|
101
98
|
{
|
|
@@ -107,10 +104,7 @@ exports.default = [
|
|
|
107
104
|
tooltip: 'Determines if the breadcrumb bar is clickable or not for visited tabs.',
|
|
108
105
|
conditional: {
|
|
109
106
|
json: {
|
|
110
|
-
'===': [
|
|
111
|
-
{ var: 'data.breadcrumbClickable' },
|
|
112
|
-
false,
|
|
113
|
-
],
|
|
107
|
+
'===': [{ var: 'data.breadcrumbClickable' }, false],
|
|
114
108
|
},
|
|
115
109
|
},
|
|
116
110
|
},
|
|
@@ -216,10 +210,7 @@ exports.default = [
|
|
|
216
210
|
input: true,
|
|
217
211
|
conditional: {
|
|
218
212
|
json: {
|
|
219
|
-
'===': [
|
|
220
|
-
{ var: 'data.collapsible' },
|
|
221
|
-
true,
|
|
222
|
-
],
|
|
213
|
+
'===': [{ var: 'data.collapsible' }, true],
|
|
223
214
|
},
|
|
224
215
|
},
|
|
225
216
|
},
|
|
@@ -26,10 +26,7 @@ class PasswordComponent extends TextField_1.default {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
get defaultSchema() {
|
|
29
|
-
return lodash_1.default.omit(PasswordComponent.schema(), [
|
|
30
|
-
'protected',
|
|
31
|
-
'tableView',
|
|
32
|
-
]);
|
|
29
|
+
return lodash_1.default.omit(PasswordComponent.schema(), ['protected', 'tableView']);
|
|
33
30
|
}
|
|
34
31
|
get inputInfo() {
|
|
35
32
|
const info = super.inputInfo;
|
|
@@ -14,9 +14,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
14
14
|
inputType: 'radio',
|
|
15
15
|
label: 'Radio',
|
|
16
16
|
key: 'radio',
|
|
17
|
-
values: [
|
|
18
|
-
{ label: '', value: '' },
|
|
19
|
-
],
|
|
17
|
+
values: [{ label: '', value: '' }],
|
|
20
18
|
data: {
|
|
21
19
|
url: '',
|
|
22
20
|
},
|
|
@@ -60,23 +58,12 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
60
58
|
return types;
|
|
61
59
|
}
|
|
62
60
|
if (dataType === 'object') {
|
|
63
|
-
return [
|
|
64
|
-
object,
|
|
65
|
-
array,
|
|
66
|
-
];
|
|
61
|
+
return [object, array];
|
|
67
62
|
}
|
|
68
63
|
if (utils_1.componentValueTypes[dataType]) {
|
|
69
|
-
return [
|
|
70
|
-
utils_1.componentValueTypes[dataType],
|
|
71
|
-
];
|
|
64
|
+
return [utils_1.componentValueTypes[dataType]];
|
|
72
65
|
}
|
|
73
|
-
return [
|
|
74
|
-
boolean,
|
|
75
|
-
string,
|
|
76
|
-
number,
|
|
77
|
-
object,
|
|
78
|
-
array,
|
|
79
|
-
];
|
|
66
|
+
return [boolean, string, number, object, array];
|
|
80
67
|
}
|
|
81
68
|
constructor(component, options, data) {
|
|
82
69
|
super(component, options, data);
|
|
@@ -417,6 +404,9 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
417
404
|
if (changed) {
|
|
418
405
|
this.previousValue = this.dataValue;
|
|
419
406
|
}
|
|
407
|
+
if (!this.visible) {
|
|
408
|
+
this.previousValue = this.emptyValue;
|
|
409
|
+
}
|
|
420
410
|
return changed;
|
|
421
411
|
}
|
|
422
412
|
// If they clicked on the radio that is currently selected, it needs to reset the value.
|
|
@@ -23,9 +23,7 @@ exports.default = [
|
|
|
23
23
|
},
|
|
24
24
|
onChange(context) {
|
|
25
25
|
if (context && context.flags && context.flags && context.flags.modified) {
|
|
26
|
-
context.data.values = [
|
|
27
|
-
{ label: '', value: '' },
|
|
28
|
-
];
|
|
26
|
+
context.data.values = [{ label: '', value: '' }];
|
|
29
27
|
}
|
|
30
28
|
},
|
|
31
29
|
},
|
|
@@ -37,9 +35,7 @@ exports.default = [
|
|
|
37
35
|
tooltip: 'The radio button values that can be picked for this field. Values are text submitted with the form data. Labels are text that appears next to the radio buttons on the form.',
|
|
38
36
|
weight: 10,
|
|
39
37
|
reorder: true,
|
|
40
|
-
defaultValue: [
|
|
41
|
-
{ label: '', value: '' },
|
|
42
|
-
],
|
|
38
|
+
defaultValue: [{ label: '', value: '' }],
|
|
43
39
|
components: [
|
|
44
40
|
{
|
|
45
41
|
label: 'Label',
|
|
@@ -78,10 +74,7 @@ exports.default = [
|
|
|
78
74
|
],
|
|
79
75
|
conditional: {
|
|
80
76
|
json: {
|
|
81
|
-
'===': [
|
|
82
|
-
{ var: 'data.dataSrc' },
|
|
83
|
-
'values',
|
|
84
|
-
],
|
|
77
|
+
'===': [{ var: 'data.dataSrc' }, 'values'],
|
|
85
78
|
},
|
|
86
79
|
},
|
|
87
80
|
},
|
|
@@ -109,10 +102,7 @@ exports.default = [
|
|
|
109
102
|
key: 'template',
|
|
110
103
|
conditional: {
|
|
111
104
|
json: {
|
|
112
|
-
'===': [
|
|
113
|
-
{ var: 'data.dataSrc' },
|
|
114
|
-
'url',
|
|
115
|
-
],
|
|
105
|
+
'===': [{ var: 'data.dataSrc' }, 'url'],
|
|
116
106
|
},
|
|
117
107
|
},
|
|
118
108
|
},
|
|
@@ -32,10 +32,7 @@ class ReCaptchaComponent extends Component_1.default {
|
|
|
32
32
|
return [];
|
|
33
33
|
}
|
|
34
34
|
static get conditionOperatorsSettings() {
|
|
35
|
-
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: [
|
|
36
|
-
'isEmpty',
|
|
37
|
-
'isNotEmpty',
|
|
38
|
-
] });
|
|
35
|
+
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: ['isEmpty', 'isNotEmpty'] });
|
|
39
36
|
}
|
|
40
37
|
static get serverConditionSettings() {
|
|
41
38
|
return ReCaptchaComponent.conditionOperatorsSettings;
|
|
@@ -62,7 +59,7 @@ class ReCaptchaComponent extends Component_1.default {
|
|
|
62
59
|
this.recaptchaApiReady = Formio_1.Formio.requireLibrary('googleRecaptcha', 'grecaptcha', recaptchaApiScriptUrl, true);
|
|
63
60
|
}
|
|
64
61
|
else {
|
|
65
|
-
console.warn('
|
|
62
|
+
console.warn(this.t('noSiteKey'));
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
}
|
|
@@ -77,7 +74,7 @@ class ReCaptchaComponent extends Component_1.default {
|
|
|
77
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
75
|
const siteKey = (0, get_1.default)((_a = this.root) === null || _a === void 0 ? void 0 : _a.form, 'settings.recaptcha.siteKey');
|
|
79
76
|
if (!siteKey) {
|
|
80
|
-
console.warn('
|
|
77
|
+
console.warn(this.t('noSiteKey'));
|
|
81
78
|
return;
|
|
82
79
|
}
|
|
83
80
|
if (!this.recaptchaApiReady) {
|
|
@@ -17,9 +17,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
17
17
|
key: 'select',
|
|
18
18
|
idPath: 'id',
|
|
19
19
|
data: {
|
|
20
|
-
values: [
|
|
21
|
-
{ label: '', value: '' },
|
|
22
|
-
],
|
|
20
|
+
values: [{ label: '', value: '' }],
|
|
23
21
|
json: '',
|
|
24
22
|
url: '',
|
|
25
23
|
resource: '',
|
|
@@ -80,12 +78,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
80
78
|
}
|
|
81
79
|
return valueComp;
|
|
82
80
|
}, dataTypeOperators: {
|
|
83
|
-
number: [
|
|
84
|
-
'lessThan',
|
|
85
|
-
'greaterThan',
|
|
86
|
-
'lessThanOrEqual',
|
|
87
|
-
'greaterThanOrEqual',
|
|
88
|
-
],
|
|
81
|
+
number: ['lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],
|
|
89
82
|
}, dataTypeValueComponents: {
|
|
90
83
|
number: {
|
|
91
84
|
lessThan: numberType,
|
|
@@ -103,28 +96,15 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
103
96
|
return types;
|
|
104
97
|
}
|
|
105
98
|
if (reference) {
|
|
106
|
-
return [
|
|
107
|
-
object,
|
|
108
|
-
];
|
|
99
|
+
return [object];
|
|
109
100
|
}
|
|
110
101
|
if (dataType === 'object') {
|
|
111
|
-
return [
|
|
112
|
-
object,
|
|
113
|
-
array,
|
|
114
|
-
];
|
|
102
|
+
return [object, array];
|
|
115
103
|
}
|
|
116
104
|
if (utils_1.componentValueTypes[dataType]) {
|
|
117
|
-
return [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
return [
|
|
122
|
-
boolean,
|
|
123
|
-
string,
|
|
124
|
-
number,
|
|
125
|
-
object,
|
|
126
|
-
array,
|
|
127
|
-
];
|
|
105
|
+
return [utils_1.componentValueTypes[dataType]];
|
|
106
|
+
}
|
|
107
|
+
return [boolean, string, number, object, array];
|
|
128
108
|
}
|
|
129
109
|
init() {
|
|
130
110
|
super.init();
|
|
@@ -276,11 +256,13 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
276
256
|
// Inside DataTable component won't have dataValue set
|
|
277
257
|
const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)
|
|
278
258
|
? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
|
|
279
|
-
: this.dataValue === this.normalizeSingleValue(value)) ||
|
|
259
|
+
: this.dataValue === this.normalizeSingleValue(value)) ||
|
|
260
|
+
(this.inDataTable && !this.element);
|
|
280
261
|
if (shouldUseSelectData) {
|
|
281
|
-
const selectData =
|
|
262
|
+
const selectData = this.inDataTable && !this.element ? this.component.selectData : this.selectData;
|
|
282
263
|
if (selectData) {
|
|
283
264
|
const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
|
|
265
|
+
const isEqualWithoutData = lodash_1.default.isEqual(data, value) && lodash_1.default.isUndefined(data.data);
|
|
284
266
|
if (!this.templateData || !this.templateData[templateValue]) {
|
|
285
267
|
this.getOptionTemplate(data, value);
|
|
286
268
|
}
|
|
@@ -293,7 +275,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
293
275
|
data = selectData;
|
|
294
276
|
}
|
|
295
277
|
// use template data for reference fields to make sure the data is updated
|
|
296
|
-
if (this.component.reference && this.templateData[templateValue]) {
|
|
278
|
+
if (this.component.reference && this.templateData[templateValue] && !isEqualWithoutData) {
|
|
297
279
|
data = this.templateData[templateValue];
|
|
298
280
|
}
|
|
299
281
|
}
|
|
@@ -376,11 +358,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
376
358
|
}
|
|
377
359
|
if (!this.selectOptions.length) {
|
|
378
360
|
// Add the currently selected choices if they don't already exist.
|
|
379
|
-
const currentChoices = Array.isArray(data) && this.component.multiple
|
|
380
|
-
? data
|
|
381
|
-
: [
|
|
382
|
-
data,
|
|
383
|
-
];
|
|
361
|
+
const currentChoices = Array.isArray(data) && this.component.multiple ? data : [data];
|
|
384
362
|
added = this.addCurrentChoices(currentChoices, items);
|
|
385
363
|
if (!added && !this.component.multiple) {
|
|
386
364
|
this.addPlaceholder();
|
|
@@ -519,7 +497,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
519
497
|
noUpdateEvent: true,
|
|
520
498
|
});
|
|
521
499
|
}
|
|
522
|
-
else if (this.shouldAddDefaultValue &&
|
|
500
|
+
else if (this.shouldAddDefaultValue &&
|
|
501
|
+
!this.options.readOnly &&
|
|
502
|
+
this.root &&
|
|
503
|
+
!this.root.submissionSet) {
|
|
523
504
|
// If a default value is provided then select it.
|
|
524
505
|
const defaultValue = this.defaultValue;
|
|
525
506
|
if (!this.isEmpty(defaultValue)) {
|
|
@@ -668,7 +649,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
668
649
|
component: this.component,
|
|
669
650
|
message: err.toString(),
|
|
670
651
|
});
|
|
671
|
-
console.warn(
|
|
652
|
+
console.warn(this.t('loadResourcesError', { componentKey: this.key }));
|
|
672
653
|
}
|
|
673
654
|
/**
|
|
674
655
|
* Get the request headers for this select dropdown.
|
|
@@ -807,7 +788,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
807
788
|
}
|
|
808
789
|
}
|
|
809
790
|
else if (this.component.dataSrc === 'url' || this.component.dataSrc === 'resource') {
|
|
810
|
-
this.addOption('', this.t('loading
|
|
791
|
+
this.addOption('', `${this.t('loading')}...`);
|
|
811
792
|
}
|
|
812
793
|
}
|
|
813
794
|
get active() {
|
|
@@ -836,7 +817,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
836
817
|
? this.component.searchEnabled
|
|
837
818
|
: true;
|
|
838
819
|
const hasPlaceholder = !!this.component.placeholder && !((_a = this.options) === null || _a === void 0 ? void 0 : _a.readOnly);
|
|
839
|
-
const placeholderValue = hasPlaceholder
|
|
820
|
+
const placeholderValue = hasPlaceholder
|
|
821
|
+
? this.sanitize(this.t(this.component.placeholder, { _userInput: true }), true)
|
|
822
|
+
: null;
|
|
840
823
|
let customOptions = this.component.customOptions || {};
|
|
841
824
|
if (typeof customOptions == 'string') {
|
|
842
825
|
try {
|
|
@@ -854,15 +837,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
854
837
|
return Object.assign({ removeItemButton: this.component.disabled
|
|
855
838
|
? false
|
|
856
839
|
: lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {
|
|
857
|
-
containerOuter: [
|
|
858
|
-
'choices',
|
|
859
|
-
'form-group',
|
|
860
|
-
'formio-choices',
|
|
861
|
-
],
|
|
840
|
+
containerOuter: ['choices', 'form-group', 'formio-choices'],
|
|
862
841
|
containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
|
|
863
|
-
}, addItemText: false, allowHTML: true, placeholder: hasPlaceholder, placeholderValue: placeholderValue, noResultsText: this.t('
|
|
864
|
-
'label',
|
|
865
|
-
]), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch
|
|
842
|
+
}, addItemText: false, allowHTML: true, placeholder: hasPlaceholder, placeholderValue: placeholderValue, noResultsText: this.t('noResultsFound'), noChoicesText: this.t('noChoices'), searchPlaceholderValue: this.t('typeToSearch'), shouldSort: false, position: this.component.dropdown || 'auto', searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', ['label']), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch
|
|
866
843
|
? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false, duplicateItemsAllowed: false }, customOptions);
|
|
867
844
|
}
|
|
868
845
|
attach(element) {
|
|
@@ -886,7 +863,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
886
863
|
}
|
|
887
864
|
this.addEventListener(input, this.inputInfo.changeEvent, () => {
|
|
888
865
|
this.updateValue(null, {
|
|
889
|
-
modified: true
|
|
866
|
+
modified: true,
|
|
890
867
|
});
|
|
891
868
|
});
|
|
892
869
|
this.attachRefreshOnBlur();
|
|
@@ -902,10 +879,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
902
879
|
}
|
|
903
880
|
this.addEventListener(input, 'keydown', (event) => {
|
|
904
881
|
const { key } = event;
|
|
905
|
-
if ([
|
|
906
|
-
'Backspace',
|
|
907
|
-
'Delete',
|
|
908
|
-
].includes(key)) {
|
|
882
|
+
if (['Backspace', 'Delete'].includes(key)) {
|
|
909
883
|
this.setValue(this.emptyValue);
|
|
910
884
|
}
|
|
911
885
|
});
|
|
@@ -1017,10 +991,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1017
991
|
// If valueProperty is set, replace the submission with the corresponding value
|
|
1018
992
|
let value = this.valueProperty ? lodash_1.default.get(submission, this.valueProperty) : submission;
|
|
1019
993
|
if (this.component.multiple) {
|
|
1020
|
-
value = [
|
|
1021
|
-
...this.dataValue,
|
|
1022
|
-
value,
|
|
1023
|
-
];
|
|
994
|
+
value = [...this.dataValue, value];
|
|
1024
995
|
}
|
|
1025
996
|
this.setValue(value);
|
|
1026
997
|
this.triggerUpdate();
|
|
@@ -1031,7 +1002,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1031
1002
|
}
|
|
1032
1003
|
// Force the disabled state with getters and setters.
|
|
1033
1004
|
this.disabled = this.shouldDisabled;
|
|
1034
|
-
this.triggerUpdate();
|
|
1005
|
+
this.triggerUpdate(null, !lodash_1.default.isEmpty(this.data[this.key]) && this.itemsFromUrl);
|
|
1035
1006
|
return superAttach;
|
|
1036
1007
|
}
|
|
1037
1008
|
setDropdownPosition() {
|
|
@@ -1089,9 +1060,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1089
1060
|
attachRefreshOnBlur() {
|
|
1090
1061
|
if (this.component.refreshOnBlur) {
|
|
1091
1062
|
this.on('blur', (instance) => {
|
|
1092
|
-
this.checkRefreshOn([
|
|
1093
|
-
{ instance, value: instance.dataValue },
|
|
1094
|
-
], { fromBlur: true });
|
|
1063
|
+
this.checkRefreshOn([{ instance, value: instance.dataValue }], { fromBlur: true });
|
|
1095
1064
|
});
|
|
1096
1065
|
}
|
|
1097
1066
|
}
|
|
@@ -1136,7 +1105,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1136
1105
|
return false;
|
|
1137
1106
|
}
|
|
1138
1107
|
const notFoundValuesToAdd = [];
|
|
1139
|
-
const added = values.reduce((defaultAdded, value) => {
|
|
1108
|
+
const added = values.reduce((defaultAdded, value, i) => {
|
|
1140
1109
|
if (!value || lodash_1.default.isEmpty(value)) {
|
|
1141
1110
|
return defaultAdded;
|
|
1142
1111
|
}
|
|
@@ -1155,6 +1124,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1155
1124
|
return false;
|
|
1156
1125
|
}
|
|
1157
1126
|
const itemValue = keyValue ? choice.value : this.itemValue(choice, isSelectOptions);
|
|
1127
|
+
if (this.component.reference && itemValue._id === value._id) {
|
|
1128
|
+
lodash_1.default.set(values, i, itemValue);
|
|
1129
|
+
value = itemValue;
|
|
1130
|
+
}
|
|
1158
1131
|
found |= lodash_1.default.isEqual(itemValue, value);
|
|
1159
1132
|
return found ? false : true;
|
|
1160
1133
|
});
|
|
@@ -1282,7 +1255,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1282
1255
|
return normalize[dataType]().value;
|
|
1283
1256
|
}
|
|
1284
1257
|
catch (err) {
|
|
1285
|
-
console.warn('
|
|
1258
|
+
console.warn(this.t('failedToNormalize'), err);
|
|
1286
1259
|
return value;
|
|
1287
1260
|
}
|
|
1288
1261
|
}
|
|
@@ -1299,8 +1272,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1299
1272
|
}
|
|
1300
1273
|
setMetadata(value, flags = {}) {
|
|
1301
1274
|
var _a, _b;
|
|
1302
|
-
if (lodash_1.default.isNil(value)
|
|
1303
|
-
(this.inDataTable && this.component.dataSrc === 'values')) {
|
|
1275
|
+
if (lodash_1.default.isNil(value)) {
|
|
1304
1276
|
return;
|
|
1305
1277
|
}
|
|
1306
1278
|
const valueIsObject = lodash_1.default.isObject(value);
|
|
@@ -1339,8 +1311,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1339
1311
|
}
|
|
1340
1312
|
lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
|
|
1341
1313
|
}
|
|
1342
|
-
else if (!this.templateData[templateValue] &&
|
|
1343
|
-
this.isEmpty(value)) {
|
|
1314
|
+
else if (!this.templateData[templateValue] && this.isEmpty(value)) {
|
|
1344
1315
|
lodash_1.default.unset(this.root.submission, `metadata.selectData.${this.path}`);
|
|
1345
1316
|
}
|
|
1346
1317
|
if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
|
|
@@ -1439,11 +1410,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1439
1410
|
if (hasValue) {
|
|
1440
1411
|
this.choices.removeActiveItems();
|
|
1441
1412
|
// Add the currently selected choices if they don't already exist.
|
|
1442
|
-
const currentChoices = Array.isArray(value) && this.component.multiple
|
|
1443
|
-
? value
|
|
1444
|
-
: [
|
|
1445
|
-
value,
|
|
1446
|
-
];
|
|
1413
|
+
const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];
|
|
1447
1414
|
if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {
|
|
1448
1415
|
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
|
1449
1416
|
}
|
|
@@ -1455,11 +1422,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1455
1422
|
}
|
|
1456
1423
|
else {
|
|
1457
1424
|
if (hasValue) {
|
|
1458
|
-
const values = Array.isArray(value)
|
|
1459
|
-
? value
|
|
1460
|
-
: [
|
|
1461
|
-
value,
|
|
1462
|
-
];
|
|
1425
|
+
const values = Array.isArray(value) ? value : [value];
|
|
1463
1426
|
if ((!lodash_1.default.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2) ||
|
|
1464
1427
|
(this.selectData && flags.fromSubmission)) {
|
|
1465
1428
|
const { value, label } = this.selectValueAndLabel(this.dataValue);
|
|
@@ -1504,7 +1467,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1504
1467
|
return JSON.stringify(normalizedOptionValue) === JSON.stringify(value);
|
|
1505
1468
|
}
|
|
1506
1469
|
catch (err) {
|
|
1507
|
-
console.warn.error('
|
|
1470
|
+
console.warn.error(this.t('failedToCompareItems'), err);
|
|
1508
1471
|
return false;
|
|
1509
1472
|
}
|
|
1510
1473
|
};
|
|
@@ -1601,11 +1564,14 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1601
1564
|
var _a;
|
|
1602
1565
|
value = value !== null && value !== void 0 ? value : this.getValue();
|
|
1603
1566
|
if (options.modalPreview ||
|
|
1604
|
-
((this.inDataTable || this.inEditGrid) &&
|
|
1567
|
+
((this.inDataTable || this.inEditGrid) &&
|
|
1568
|
+
!['values', 'custom'].includes(this.component.dataSrc))) {
|
|
1605
1569
|
if (this.inDataTable) {
|
|
1606
1570
|
value = this.undoValueTyping(value);
|
|
1607
1571
|
}
|
|
1608
|
-
const templateValue = this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)
|
|
1572
|
+
const templateValue = !lodash_1.default.isEmpty(value) && this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)
|
|
1573
|
+
? { data: value }
|
|
1574
|
+
: value;
|
|
1609
1575
|
const template = this.itemTemplate(templateValue, value, options);
|
|
1610
1576
|
return template;
|
|
1611
1577
|
}
|
|
@@ -1629,11 +1595,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1629
1595
|
return data;
|
|
1630
1596
|
};
|
|
1631
1597
|
value = convertToString(value);
|
|
1632
|
-
if ([
|
|
1633
|
-
'values',
|
|
1634
|
-
'custom',
|
|
1635
|
-
].includes(this.component.dataSrc) &&
|
|
1636
|
-
!this.asyncCustomValues()) {
|
|
1598
|
+
if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {
|
|
1637
1599
|
const { items, valueProperty } = this.component.dataSrc === 'values'
|
|
1638
1600
|
? {
|
|
1639
1601
|
items: convertToString(this.getNormalizedValues(), 'value'),
|
|
@@ -1644,10 +1606,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1644
1606
|
valueProperty: this.valueProperty,
|
|
1645
1607
|
};
|
|
1646
1608
|
const getFromValues = () => {
|
|
1647
|
-
const initialValue = lodash_1.default.find(items, [
|
|
1648
|
-
valueProperty,
|
|
1649
|
-
value,
|
|
1650
|
-
]);
|
|
1609
|
+
const initialValue = lodash_1.default.find(items, [valueProperty, value]);
|
|
1651
1610
|
const values = this.defaultSchema.data.values || [];
|
|
1652
1611
|
return lodash_1.default.isEqual(initialValue, values[0]) ? '-' : initialValue;
|
|
1653
1612
|
};
|
|
@@ -1703,14 +1662,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1703
1662
|
setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {
|
|
1704
1663
|
super.setErrorClasses(elements, dirty, hasError, hasMessages, element);
|
|
1705
1664
|
if (this.choices) {
|
|
1706
|
-
super.setErrorClasses([
|
|
1707
|
-
this.choices.containerInner.element,
|
|
1708
|
-
], dirty, hasError, hasMessages, element);
|
|
1665
|
+
super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);
|
|
1709
1666
|
}
|
|
1710
1667
|
else {
|
|
1711
|
-
super.setErrorClasses([
|
|
1712
|
-
this.refs.selectContainer,
|
|
1713
|
-
], dirty, hasError, hasMessages, element);
|
|
1668
|
+
super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);
|
|
1714
1669
|
}
|
|
1715
1670
|
}
|
|
1716
1671
|
}
|