@formio/js 5.4.1 → 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 +1 -0
- 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 +1 -0
- package/dist/formio.form.js +131 -109
- 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 +1 -0
- package/dist/formio.full.js +155 -133
- 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 +26 -26
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +2 -2
- package/dist/formio.utils.js +19 -19
- 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 +5 -5
- package/lib/cjs/components/_classes/component/Component.js +60 -132
- 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.js +10 -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 +23 -63
- 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 +48 -92
- 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 +1 -3
- 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 -82
- package/lib/cjs/translations/en.js +9 -82
- 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 +37 -47
- 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 +5 -5
- package/lib/mjs/components/_classes/component/Component.js +59 -132
- 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.js +9 -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 +23 -63
- 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 +51 -95
- 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 +1 -3
- 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 -82
- package/lib/mjs/translations/en.js +88 -0
- 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 +37 -47
- package/lib/mjs/widgets/CalendarWidget.js +2 -6
- package/package.json +6 -4
|
@@ -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
|
}
|
|
@@ -1365,8 +1338,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1365
1338
|
}
|
|
1366
1339
|
_.set(submission.metadata.selectData, this.path, templateData);
|
|
1367
1340
|
}
|
|
1368
|
-
else if (!this.templateData[templateValue] &&
|
|
1369
|
-
this.isEmpty(value)) {
|
|
1341
|
+
else if (!this.templateData[templateValue] && this.isEmpty(value)) {
|
|
1370
1342
|
_.unset(this.root.submission, `metadata.selectData.${this.path}`);
|
|
1371
1343
|
}
|
|
1372
1344
|
if (flags.resetValue && this.root?.submission && !this.options.readOnly) {
|
|
@@ -1465,11 +1437,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1465
1437
|
if (hasValue) {
|
|
1466
1438
|
this.choices.removeActiveItems();
|
|
1467
1439
|
// Add the currently selected choices if they don't already exist.
|
|
1468
|
-
const currentChoices = Array.isArray(value) && this.component.multiple
|
|
1469
|
-
? value
|
|
1470
|
-
: [
|
|
1471
|
-
value,
|
|
1472
|
-
];
|
|
1440
|
+
const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];
|
|
1473
1441
|
if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {
|
|
1474
1442
|
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
|
1475
1443
|
}
|
|
@@ -1481,11 +1449,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1481
1449
|
}
|
|
1482
1450
|
else {
|
|
1483
1451
|
if (hasValue) {
|
|
1484
|
-
const values = Array.isArray(value)
|
|
1485
|
-
? value
|
|
1486
|
-
: [
|
|
1487
|
-
value,
|
|
1488
|
-
];
|
|
1452
|
+
const values = Array.isArray(value) ? value : [value];
|
|
1489
1453
|
if ((!_.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2) ||
|
|
1490
1454
|
(this.selectData && flags.fromSubmission)) {
|
|
1491
1455
|
const { value, label } = this.selectValueAndLabel(this.dataValue);
|
|
@@ -1530,7 +1494,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1530
1494
|
return JSON.stringify(normalizedOptionValue) === JSON.stringify(value);
|
|
1531
1495
|
}
|
|
1532
1496
|
catch (err) {
|
|
1533
|
-
console.warn.error('
|
|
1497
|
+
console.warn.error(this.t('failedToCompareItems'), err);
|
|
1534
1498
|
return false;
|
|
1535
1499
|
}
|
|
1536
1500
|
};
|
|
@@ -1626,11 +1590,14 @@ export default class SelectComponent extends ListComponent {
|
|
|
1626
1590
|
asString(value, options = {}) {
|
|
1627
1591
|
value = value ?? this.getValue();
|
|
1628
1592
|
if (options.modalPreview ||
|
|
1629
|
-
((this.inDataTable || this.inEditGrid) &&
|
|
1593
|
+
((this.inDataTable || this.inEditGrid) &&
|
|
1594
|
+
!['values', 'custom'].includes(this.component.dataSrc))) {
|
|
1630
1595
|
if (this.inDataTable) {
|
|
1631
1596
|
value = this.undoValueTyping(value);
|
|
1632
1597
|
}
|
|
1633
|
-
const templateValue = !_.isEmpty(value) && this.isEntireObjectDisplay() && !_.isObject(value.data)
|
|
1598
|
+
const templateValue = !_.isEmpty(value) && this.isEntireObjectDisplay() && !_.isObject(value.data)
|
|
1599
|
+
? { data: value }
|
|
1600
|
+
: value;
|
|
1634
1601
|
const template = this.itemTemplate(templateValue, value, options);
|
|
1635
1602
|
return template;
|
|
1636
1603
|
}
|
|
@@ -1654,11 +1621,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1654
1621
|
return data;
|
|
1655
1622
|
};
|
|
1656
1623
|
value = convertToString(value);
|
|
1657
|
-
if ([
|
|
1658
|
-
'values',
|
|
1659
|
-
'custom',
|
|
1660
|
-
].includes(this.component.dataSrc) &&
|
|
1661
|
-
!this.asyncCustomValues()) {
|
|
1624
|
+
if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {
|
|
1662
1625
|
const { items, valueProperty } = this.component.dataSrc === 'values'
|
|
1663
1626
|
? {
|
|
1664
1627
|
items: convertToString(this.getNormalizedValues(), 'value'),
|
|
@@ -1669,10 +1632,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1669
1632
|
valueProperty: this.valueProperty,
|
|
1670
1633
|
};
|
|
1671
1634
|
const getFromValues = () => {
|
|
1672
|
-
const initialValue = _.find(items, [
|
|
1673
|
-
valueProperty,
|
|
1674
|
-
value,
|
|
1675
|
-
]);
|
|
1635
|
+
const initialValue = _.find(items, [valueProperty, value]);
|
|
1676
1636
|
const values = this.defaultSchema.data.values || [];
|
|
1677
1637
|
return _.isEqual(initialValue, values[0]) ? '-' : initialValue;
|
|
1678
1638
|
};
|
|
@@ -1727,14 +1687,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
1727
1687
|
setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {
|
|
1728
1688
|
super.setErrorClasses(elements, dirty, hasError, hasMessages, element);
|
|
1729
1689
|
if (this.choices) {
|
|
1730
|
-
super.setErrorClasses([
|
|
1731
|
-
this.choices.containerInner.element,
|
|
1732
|
-
], dirty, hasError, hasMessages, element);
|
|
1690
|
+
super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);
|
|
1733
1691
|
}
|
|
1734
1692
|
else {
|
|
1735
|
-
super.setErrorClasses([
|
|
1736
|
-
this.refs.selectContainer,
|
|
1737
|
-
], dirty, hasError, hasMessages, element);
|
|
1693
|
+
super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);
|
|
1738
1694
|
}
|
|
1739
1695
|
}
|
|
1740
1696
|
}
|