@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
|
@@ -87,10 +87,7 @@ export default [
|
|
|
87
87
|
defaultValue: true,
|
|
88
88
|
customConditional({ data = {}, buildingForm = {} }) {
|
|
89
89
|
const formSettings = buildingForm.settings || {};
|
|
90
|
-
return ![
|
|
91
|
-
data.breadcrumb,
|
|
92
|
-
formSettings.wizardBreadcrumbsType,
|
|
93
|
-
].includes('none');
|
|
90
|
+
return ![data.breadcrumb, formSettings.wizardBreadcrumbsType].includes('none');
|
|
94
91
|
},
|
|
95
92
|
},
|
|
96
93
|
{
|
|
@@ -102,10 +99,7 @@ export default [
|
|
|
102
99
|
tooltip: 'Determines if the breadcrumb bar is clickable or not for visited tabs.',
|
|
103
100
|
conditional: {
|
|
104
101
|
json: {
|
|
105
|
-
'===': [
|
|
106
|
-
{ var: 'data.breadcrumbClickable' },
|
|
107
|
-
false,
|
|
108
|
-
],
|
|
102
|
+
'===': [{ var: 'data.breadcrumbClickable' }, false],
|
|
109
103
|
},
|
|
110
104
|
},
|
|
111
105
|
},
|
|
@@ -211,10 +205,7 @@ export default [
|
|
|
211
205
|
input: true,
|
|
212
206
|
conditional: {
|
|
213
207
|
json: {
|
|
214
|
-
'===': [
|
|
215
|
-
{ var: 'data.collapsible' },
|
|
216
|
-
true,
|
|
217
|
-
],
|
|
208
|
+
'===': [{ var: 'data.collapsible' }, true],
|
|
218
209
|
},
|
|
219
210
|
},
|
|
220
211
|
},
|
|
@@ -21,10 +21,7 @@ export default class PasswordComponent extends TextFieldComponent {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
get defaultSchema() {
|
|
24
|
-
return _.omit(PasswordComponent.schema(), [
|
|
25
|
-
'protected',
|
|
26
|
-
'tableView',
|
|
27
|
-
]);
|
|
24
|
+
return _.omit(PasswordComponent.schema(), ['protected', 'tableView']);
|
|
28
25
|
}
|
|
29
26
|
get inputInfo() {
|
|
30
27
|
const info = super.inputInfo;
|
|
@@ -9,9 +9,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
9
9
|
inputType: 'radio',
|
|
10
10
|
label: 'Radio',
|
|
11
11
|
key: 'radio',
|
|
12
|
-
values: [
|
|
13
|
-
{ label: '', value: '' },
|
|
14
|
-
],
|
|
12
|
+
values: [{ label: '', value: '' }],
|
|
15
13
|
data: {
|
|
16
14
|
url: '',
|
|
17
15
|
},
|
|
@@ -61,23 +59,12 @@ export default class RadioComponent extends ListComponent {
|
|
|
61
59
|
return types;
|
|
62
60
|
}
|
|
63
61
|
if (dataType === 'object') {
|
|
64
|
-
return [
|
|
65
|
-
object,
|
|
66
|
-
array,
|
|
67
|
-
];
|
|
62
|
+
return [object, array];
|
|
68
63
|
}
|
|
69
64
|
if (componentValueTypes[dataType]) {
|
|
70
|
-
return [
|
|
71
|
-
componentValueTypes[dataType],
|
|
72
|
-
];
|
|
65
|
+
return [componentValueTypes[dataType]];
|
|
73
66
|
}
|
|
74
|
-
return [
|
|
75
|
-
boolean,
|
|
76
|
-
string,
|
|
77
|
-
number,
|
|
78
|
-
object,
|
|
79
|
-
array,
|
|
80
|
-
];
|
|
67
|
+
return [boolean, string, number, object, array];
|
|
81
68
|
}
|
|
82
69
|
constructor(component, options, data) {
|
|
83
70
|
super(component, options, data);
|
|
@@ -415,6 +402,9 @@ export default class RadioComponent extends ListComponent {
|
|
|
415
402
|
if (changed) {
|
|
416
403
|
this.previousValue = this.dataValue;
|
|
417
404
|
}
|
|
405
|
+
if (!this.visible) {
|
|
406
|
+
this.previousValue = this.emptyValue;
|
|
407
|
+
}
|
|
418
408
|
return changed;
|
|
419
409
|
}
|
|
420
410
|
// If they clicked on the radio that is currently selected, it needs to reset the value.
|
|
@@ -18,9 +18,7 @@ export default [
|
|
|
18
18
|
},
|
|
19
19
|
onChange(context) {
|
|
20
20
|
if (context && context.flags && context.flags && context.flags.modified) {
|
|
21
|
-
context.data.values = [
|
|
22
|
-
{ label: '', value: '' },
|
|
23
|
-
];
|
|
21
|
+
context.data.values = [{ label: '', value: '' }];
|
|
24
22
|
}
|
|
25
23
|
},
|
|
26
24
|
},
|
|
@@ -32,9 +30,7 @@ export default [
|
|
|
32
30
|
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.',
|
|
33
31
|
weight: 10,
|
|
34
32
|
reorder: true,
|
|
35
|
-
defaultValue: [
|
|
36
|
-
{ label: '', value: '' },
|
|
37
|
-
],
|
|
33
|
+
defaultValue: [{ label: '', value: '' }],
|
|
38
34
|
components: [
|
|
39
35
|
{
|
|
40
36
|
label: 'Label',
|
|
@@ -73,10 +69,7 @@ export default [
|
|
|
73
69
|
],
|
|
74
70
|
conditional: {
|
|
75
71
|
json: {
|
|
76
|
-
'===': [
|
|
77
|
-
{ var: 'data.dataSrc' },
|
|
78
|
-
'values',
|
|
79
|
-
],
|
|
72
|
+
'===': [{ var: 'data.dataSrc' }, 'values'],
|
|
80
73
|
},
|
|
81
74
|
},
|
|
82
75
|
},
|
|
@@ -104,10 +97,7 @@ export default [
|
|
|
104
97
|
key: 'template',
|
|
105
98
|
conditional: {
|
|
106
99
|
json: {
|
|
107
|
-
'===': [
|
|
108
|
-
{ var: 'data.dataSrc' },
|
|
109
|
-
'url',
|
|
110
|
-
],
|
|
100
|
+
'===': [{ var: 'data.dataSrc' }, 'url'],
|
|
111
101
|
},
|
|
112
102
|
},
|
|
113
103
|
},
|
|
@@ -20,10 +20,7 @@ export default class ReCaptchaComponent extends Component {
|
|
|
20
20
|
static get conditionOperatorsSettings() {
|
|
21
21
|
return {
|
|
22
22
|
...super.conditionOperatorsSettings,
|
|
23
|
-
operators: [
|
|
24
|
-
'isEmpty',
|
|
25
|
-
'isNotEmpty',
|
|
26
|
-
],
|
|
23
|
+
operators: ['isEmpty', 'isNotEmpty'],
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
26
|
static get serverConditionSettings() {
|
|
@@ -50,7 +47,7 @@ export default class ReCaptchaComponent extends Component {
|
|
|
50
47
|
this.recaptchaApiReady = Formio.requireLibrary('googleRecaptcha', 'grecaptcha', recaptchaApiScriptUrl, true);
|
|
51
48
|
}
|
|
52
49
|
else {
|
|
53
|
-
console.warn('
|
|
50
|
+
console.warn(this.t('noSiteKey'));
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
}
|
|
@@ -63,7 +60,7 @@ export default class ReCaptchaComponent extends Component {
|
|
|
63
60
|
async verify(actionName) {
|
|
64
61
|
const siteKey = _get(this.root?.form, 'settings.recaptcha.siteKey');
|
|
65
62
|
if (!siteKey) {
|
|
66
|
-
console.warn('
|
|
63
|
+
console.warn(this.t('noSiteKey'));
|
|
67
64
|
return;
|
|
68
65
|
}
|
|
69
66
|
if (!this.recaptchaApiReady) {
|
|
@@ -12,9 +12,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
12
12
|
key: 'select',
|
|
13
13
|
idPath: 'id',
|
|
14
14
|
data: {
|
|
15
|
-
values: [
|
|
16
|
-
{ label: '', value: '' },
|
|
17
|
-
],
|
|
15
|
+
values: [{ label: '', value: '' }],
|
|
18
16
|
json: '',
|
|
19
17
|
url: '',
|
|
20
18
|
resource: '',
|
|
@@ -78,12 +76,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
78
76
|
return valueComp;
|
|
79
77
|
},
|
|
80
78
|
dataTypeOperators: {
|
|
81
|
-
number: [
|
|
82
|
-
'lessThan',
|
|
83
|
-
'greaterThan',
|
|
84
|
-
'lessThanOrEqual',
|
|
85
|
-
'greaterThanOrEqual',
|
|
86
|
-
],
|
|
79
|
+
number: ['lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],
|
|
87
80
|
},
|
|
88
81
|
dataTypeValueComponents: {
|
|
89
82
|
number: {
|
|
@@ -103,28 +96,15 @@ export default class SelectComponent extends ListComponent {
|
|
|
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 (componentValueTypes[dataType]) {
|
|
117
|
-
return [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
return [
|
|
122
|
-
boolean,
|
|
123
|
-
string,
|
|
124
|
-
number,
|
|
125
|
-
object,
|
|
126
|
-
array,
|
|
127
|
-
];
|
|
105
|
+
return [componentValueTypes[dataType]];
|
|
106
|
+
}
|
|
107
|
+
return [boolean, string, number, object, array];
|
|
128
108
|
}
|
|
129
109
|
init() {
|
|
130
110
|
super.init();
|
|
@@ -276,11 +256,13 @@ export default class SelectComponent extends ListComponent {
|
|
|
276
256
|
// Inside DataTable component won't have dataValue set
|
|
277
257
|
const shouldUseSelectData = (this.component.multiple && _.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?._id ? value._id.toString() : value;
|
|
265
|
+
const isEqualWithoutData = _.isEqual(data, value) && _.isUndefined(data.data);
|
|
284
266
|
if (!this.templateData || !this.templateData[templateValue]) {
|
|
285
267
|
this.getOptionTemplate(data, value);
|
|
286
268
|
}
|
|
@@ -293,7 +275,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
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
|
}
|
|
@@ -380,11 +362,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
380
362
|
}
|
|
381
363
|
if (!this.selectOptions.length) {
|
|
382
364
|
// Add the currently selected choices if they don't already exist.
|
|
383
|
-
const currentChoices = Array.isArray(data) && this.component.multiple
|
|
384
|
-
? data
|
|
385
|
-
: [
|
|
386
|
-
data,
|
|
387
|
-
];
|
|
365
|
+
const currentChoices = Array.isArray(data) && this.component.multiple ? data : [data];
|
|
388
366
|
added = this.addCurrentChoices(currentChoices, items);
|
|
389
367
|
if (!added && !this.component.multiple) {
|
|
390
368
|
this.addPlaceholder();
|
|
@@ -522,7 +500,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
522
500
|
noUpdateEvent: true,
|
|
523
501
|
});
|
|
524
502
|
}
|
|
525
|
-
else if (this.shouldAddDefaultValue &&
|
|
503
|
+
else if (this.shouldAddDefaultValue &&
|
|
504
|
+
!this.options.readOnly &&
|
|
505
|
+
this.root &&
|
|
506
|
+
!this.root.submissionSet) {
|
|
526
507
|
// If a default value is provided then select it.
|
|
527
508
|
const defaultValue = this.defaultValue;
|
|
528
509
|
if (!this.isEmpty(defaultValue)) {
|
|
@@ -670,7 +651,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
670
651
|
component: this.component,
|
|
671
652
|
message: err.toString(),
|
|
672
653
|
});
|
|
673
|
-
console.warn(
|
|
654
|
+
console.warn(this.t('loadResourcesError', { componentKey: this.key }));
|
|
674
655
|
}
|
|
675
656
|
/**
|
|
676
657
|
* Get the request headers for this select dropdown.
|
|
@@ -808,7 +789,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
808
789
|
}
|
|
809
790
|
}
|
|
810
791
|
else if (this.component.dataSrc === 'url' || this.component.dataSrc === 'resource') {
|
|
811
|
-
this.addOption('', this.t('loading
|
|
792
|
+
this.addOption('', `${this.t('loading')}...`);
|
|
812
793
|
}
|
|
813
794
|
}
|
|
814
795
|
get active() {
|
|
@@ -836,7 +817,9 @@ export default class SelectComponent extends ListComponent {
|
|
|
836
817
|
? this.component.searchEnabled
|
|
837
818
|
: true;
|
|
838
819
|
const hasPlaceholder = !!this.component.placeholder && !this.options?.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 {
|
|
@@ -857,27 +840,21 @@ export default class SelectComponent extends ListComponent {
|
|
|
857
840
|
: _.get(this.component, 'removeItemButton', true),
|
|
858
841
|
itemSelectText: '',
|
|
859
842
|
classNames: {
|
|
860
|
-
containerOuter: [
|
|
861
|
-
'choices',
|
|
862
|
-
'form-group',
|
|
863
|
-
'formio-choices',
|
|
864
|
-
],
|
|
843
|
+
containerOuter: ['choices', 'form-group', 'formio-choices'],
|
|
865
844
|
containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
|
|
866
845
|
},
|
|
867
846
|
addItemText: false,
|
|
868
847
|
allowHTML: true,
|
|
869
848
|
placeholder: hasPlaceholder,
|
|
870
849
|
placeholderValue: placeholderValue,
|
|
871
|
-
noResultsText: this.t('
|
|
872
|
-
noChoicesText: this.t('
|
|
873
|
-
searchPlaceholderValue: this.t('
|
|
850
|
+
noResultsText: this.t('noResultsFound'),
|
|
851
|
+
noChoicesText: this.t('noChoices'),
|
|
852
|
+
searchPlaceholderValue: this.t('typeToSearch'),
|
|
874
853
|
shouldSort: false,
|
|
875
854
|
position: this.component.dropdown || 'auto',
|
|
876
855
|
searchEnabled: useSearch,
|
|
877
856
|
searchChoices: !this.component.searchField,
|
|
878
|
-
searchFields: _.get(this, 'component.searchFields', [
|
|
879
|
-
'label',
|
|
880
|
-
]),
|
|
857
|
+
searchFields: _.get(this, 'component.searchFields', ['label']),
|
|
881
858
|
shadowRoot: this.root ? this.root.shadowRoot : null,
|
|
882
859
|
fuseOptions: this.component.useExactSearch
|
|
883
860
|
? {
|
|
@@ -916,7 +893,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
916
893
|
}
|
|
917
894
|
this.addEventListener(input, this.inputInfo.changeEvent, () => {
|
|
918
895
|
this.updateValue(null, {
|
|
919
|
-
modified: true
|
|
896
|
+
modified: true,
|
|
920
897
|
});
|
|
921
898
|
});
|
|
922
899
|
this.attachRefreshOnBlur();
|
|
@@ -932,10 +909,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
932
909
|
}
|
|
933
910
|
this.addEventListener(input, 'keydown', (event) => {
|
|
934
911
|
const { key } = event;
|
|
935
|
-
if ([
|
|
936
|
-
'Backspace',
|
|
937
|
-
'Delete',
|
|
938
|
-
].includes(key)) {
|
|
912
|
+
if (['Backspace', 'Delete'].includes(key)) {
|
|
939
913
|
this.setValue(this.emptyValue);
|
|
940
914
|
}
|
|
941
915
|
});
|
|
@@ -1047,10 +1021,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1047
1021
|
// If valueProperty is set, replace the submission with the corresponding value
|
|
1048
1022
|
let value = this.valueProperty ? _.get(submission, this.valueProperty) : submission;
|
|
1049
1023
|
if (this.component.multiple) {
|
|
1050
|
-
value = [
|
|
1051
|
-
...this.dataValue,
|
|
1052
|
-
value,
|
|
1053
|
-
];
|
|
1024
|
+
value = [...this.dataValue, value];
|
|
1054
1025
|
}
|
|
1055
1026
|
this.setValue(value);
|
|
1056
1027
|
this.triggerUpdate();
|
|
@@ -1061,7 +1032,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1061
1032
|
}
|
|
1062
1033
|
// Force the disabled state with getters and setters.
|
|
1063
1034
|
this.disabled = this.shouldDisabled;
|
|
1064
|
-
this.triggerUpdate();
|
|
1035
|
+
this.triggerUpdate(null, !_.isEmpty(this.data[this.key]) && this.itemsFromUrl);
|
|
1065
1036
|
return superAttach;
|
|
1066
1037
|
}
|
|
1067
1038
|
setDropdownPosition() {
|
|
@@ -1117,9 +1088,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1117
1088
|
attachRefreshOnBlur() {
|
|
1118
1089
|
if (this.component.refreshOnBlur) {
|
|
1119
1090
|
this.on('blur', (instance) => {
|
|
1120
|
-
this.checkRefreshOn([
|
|
1121
|
-
{ instance, value: instance.dataValue },
|
|
1122
|
-
], { fromBlur: true });
|
|
1091
|
+
this.checkRefreshOn([{ instance, value: instance.dataValue }], { fromBlur: true });
|
|
1123
1092
|
});
|
|
1124
1093
|
}
|
|
1125
1094
|
}
|
|
@@ -1164,7 +1133,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1164
1133
|
return false;
|
|
1165
1134
|
}
|
|
1166
1135
|
const notFoundValuesToAdd = [];
|
|
1167
|
-
const added = values.reduce((defaultAdded, value) => {
|
|
1136
|
+
const added = values.reduce((defaultAdded, value, i) => {
|
|
1168
1137
|
if (!value || _.isEmpty(value)) {
|
|
1169
1138
|
return defaultAdded;
|
|
1170
1139
|
}
|
|
@@ -1183,6 +1152,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
1183
1152
|
return false;
|
|
1184
1153
|
}
|
|
1185
1154
|
const itemValue = keyValue ? choice.value : this.itemValue(choice, isSelectOptions);
|
|
1155
|
+
if (this.component.reference && itemValue._id === value._id) {
|
|
1156
|
+
_.set(values, i, itemValue);
|
|
1157
|
+
value = itemValue;
|
|
1158
|
+
}
|
|
1186
1159
|
found |= _.isEqual(itemValue, value);
|
|
1187
1160
|
return found ? false : true;
|
|
1188
1161
|
});
|
|
@@ -1310,7 +1283,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1310
1283
|
return normalize[dataType]().value;
|
|
1311
1284
|
}
|
|
1312
1285
|
catch (err) {
|
|
1313
|
-
console.warn('
|
|
1286
|
+
console.warn(this.t('failedToNormalize'), err);
|
|
1314
1287
|
return value;
|
|
1315
1288
|
}
|
|
1316
1289
|
}
|
|
@@ -1326,8 +1299,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1326
1299
|
return super.normalizeValue(this.normalizeSingleValue(value));
|
|
1327
1300
|
}
|
|
1328
1301
|
setMetadata(value, flags = {}) {
|
|
1329
|
-
if (_.isNil(value)
|
|
1330
|
-
(this.inDataTable && this.component.dataSrc === 'values')) {
|
|
1302
|
+
if (_.isNil(value)) {
|
|
1331
1303
|
return;
|
|
1332
1304
|
}
|
|
1333
1305
|
const valueIsObject = _.isObject(value);
|
|
@@ -1366,8 +1338,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1366
1338
|
}
|
|
1367
1339
|
_.set(submission.metadata.selectData, this.path, templateData);
|
|
1368
1340
|
}
|
|
1369
|
-
else if (!this.templateData[templateValue] &&
|
|
1370
|
-
this.isEmpty(value)) {
|
|
1341
|
+
else if (!this.templateData[templateValue] && this.isEmpty(value)) {
|
|
1371
1342
|
_.unset(this.root.submission, `metadata.selectData.${this.path}`);
|
|
1372
1343
|
}
|
|
1373
1344
|
if (flags.resetValue && this.root?.submission && !this.options.readOnly) {
|
|
@@ -1466,11 +1437,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1466
1437
|
if (hasValue) {
|
|
1467
1438
|
this.choices.removeActiveItems();
|
|
1468
1439
|
// Add the currently selected choices if they don't already exist.
|
|
1469
|
-
const currentChoices = Array.isArray(value) && this.component.multiple
|
|
1470
|
-
? value
|
|
1471
|
-
: [
|
|
1472
|
-
value,
|
|
1473
|
-
];
|
|
1440
|
+
const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];
|
|
1474
1441
|
if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {
|
|
1475
1442
|
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
|
1476
1443
|
}
|
|
@@ -1482,11 +1449,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1482
1449
|
}
|
|
1483
1450
|
else {
|
|
1484
1451
|
if (hasValue) {
|
|
1485
|
-
const values = Array.isArray(value)
|
|
1486
|
-
? value
|
|
1487
|
-
: [
|
|
1488
|
-
value,
|
|
1489
|
-
];
|
|
1452
|
+
const values = Array.isArray(value) ? value : [value];
|
|
1490
1453
|
if ((!_.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2) ||
|
|
1491
1454
|
(this.selectData && flags.fromSubmission)) {
|
|
1492
1455
|
const { value, label } = this.selectValueAndLabel(this.dataValue);
|
|
@@ -1531,7 +1494,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1531
1494
|
return JSON.stringify(normalizedOptionValue) === JSON.stringify(value);
|
|
1532
1495
|
}
|
|
1533
1496
|
catch (err) {
|
|
1534
|
-
console.warn.error('
|
|
1497
|
+
console.warn.error(this.t('failedToCompareItems'), err);
|
|
1535
1498
|
return false;
|
|
1536
1499
|
}
|
|
1537
1500
|
};
|
|
@@ -1627,11 +1590,14 @@ export default class SelectComponent extends ListComponent {
|
|
|
1627
1590
|
asString(value, options = {}) {
|
|
1628
1591
|
value = value ?? this.getValue();
|
|
1629
1592
|
if (options.modalPreview ||
|
|
1630
|
-
((this.inDataTable || this.inEditGrid) &&
|
|
1593
|
+
((this.inDataTable || this.inEditGrid) &&
|
|
1594
|
+
!['values', 'custom'].includes(this.component.dataSrc))) {
|
|
1631
1595
|
if (this.inDataTable) {
|
|
1632
1596
|
value = this.undoValueTyping(value);
|
|
1633
1597
|
}
|
|
1634
|
-
const templateValue = this.isEntireObjectDisplay() && !_.isObject(value.data)
|
|
1598
|
+
const templateValue = !_.isEmpty(value) && this.isEntireObjectDisplay() && !_.isObject(value.data)
|
|
1599
|
+
? { data: value }
|
|
1600
|
+
: value;
|
|
1635
1601
|
const template = this.itemTemplate(templateValue, value, options);
|
|
1636
1602
|
return template;
|
|
1637
1603
|
}
|
|
@@ -1655,11 +1621,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1655
1621
|
return data;
|
|
1656
1622
|
};
|
|
1657
1623
|
value = convertToString(value);
|
|
1658
|
-
if ([
|
|
1659
|
-
'values',
|
|
1660
|
-
'custom',
|
|
1661
|
-
].includes(this.component.dataSrc) &&
|
|
1662
|
-
!this.asyncCustomValues()) {
|
|
1624
|
+
if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {
|
|
1663
1625
|
const { items, valueProperty } = this.component.dataSrc === 'values'
|
|
1664
1626
|
? {
|
|
1665
1627
|
items: convertToString(this.getNormalizedValues(), 'value'),
|
|
@@ -1670,10 +1632,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1670
1632
|
valueProperty: this.valueProperty,
|
|
1671
1633
|
};
|
|
1672
1634
|
const getFromValues = () => {
|
|
1673
|
-
const initialValue = _.find(items, [
|
|
1674
|
-
valueProperty,
|
|
1675
|
-
value,
|
|
1676
|
-
]);
|
|
1635
|
+
const initialValue = _.find(items, [valueProperty, value]);
|
|
1677
1636
|
const values = this.defaultSchema.data.values || [];
|
|
1678
1637
|
return _.isEqual(initialValue, values[0]) ? '-' : initialValue;
|
|
1679
1638
|
};
|
|
@@ -1728,14 +1687,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
1728
1687
|
setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {
|
|
1729
1688
|
super.setErrorClasses(elements, dirty, hasError, hasMessages, element);
|
|
1730
1689
|
if (this.choices) {
|
|
1731
|
-
super.setErrorClasses([
|
|
1732
|
-
this.choices.containerInner.element,
|
|
1733
|
-
], dirty, hasError, hasMessages, element);
|
|
1690
|
+
super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);
|
|
1734
1691
|
}
|
|
1735
1692
|
else {
|
|
1736
|
-
super.setErrorClasses([
|
|
1737
|
-
this.refs.selectContainer,
|
|
1738
|
-
], dirty, hasError, hasMessages, element);
|
|
1693
|
+
super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);
|
|
1739
1694
|
}
|
|
1740
1695
|
}
|
|
1741
1696
|
}
|