@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.
Files changed (215) hide show
  1. package/README.md +11 -5
  2. package/dist/formio.builder.css +1 -0
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.form.css +1 -0
  8. package/dist/formio.form.js +131 -109
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +2 -2
  12. package/dist/formio.full.css +1 -0
  13. package/dist/formio.full.js +155 -133
  14. package/dist/formio.full.min.css +1 -1
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +2 -2
  17. package/dist/formio.js +26 -26
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +2 -2
  20. package/dist/formio.utils.js +19 -19
  21. package/dist/formio.utils.min.js +1 -1
  22. package/dist/formio.utils.min.js.LICENSE.txt +2 -2
  23. package/lib/cjs/Embed.js +8 -16
  24. package/lib/cjs/Form.js +4 -4
  25. package/lib/cjs/Formio.js +2 -9
  26. package/lib/cjs/InlineEmbed.js +1 -4
  27. package/lib/cjs/PDF.js +28 -8
  28. package/lib/cjs/PDFBuilder.js +6 -10
  29. package/lib/cjs/Webform.d.ts +1 -0
  30. package/lib/cjs/Webform.js +19 -34
  31. package/lib/cjs/WebformBuilder.js +27 -68
  32. package/lib/cjs/Wizard.d.ts +1 -0
  33. package/lib/cjs/Wizard.js +44 -31
  34. package/lib/cjs/WizardBuilder.js +5 -15
  35. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
  36. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
  37. package/lib/cjs/addons/index.js +1 -3
  38. package/lib/cjs/components/_classes/component/Component.d.ts +5 -5
  39. package/lib/cjs/components/_classes/component/Component.js +60 -132
  40. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
  41. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
  42. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
  43. package/lib/cjs/components/_classes/field/Field.js +1 -4
  44. package/lib/cjs/components/_classes/input/Input.js +2 -2
  45. package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
  46. package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
  47. package/lib/cjs/components/_classes/multivalue/Multivalue.js +8 -26
  48. package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -4
  49. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
  50. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
  51. package/lib/cjs/components/address/Address.js +10 -30
  52. package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -32
  53. package/lib/cjs/components/alert/Alert.js +3 -6
  54. package/lib/cjs/components/button/Button.js +10 -17
  55. package/lib/cjs/components/button/editForm/Button.edit.display.js +8 -32
  56. package/lib/cjs/components/checkbox/Checkbox.js +4 -10
  57. package/lib/cjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
  58. package/lib/cjs/components/columns/Columns.js +5 -17
  59. package/lib/cjs/components/container/Container.js +1 -3
  60. package/lib/cjs/components/currency/Currency.js +2 -7
  61. package/lib/cjs/components/datagrid/DataGrid.js +23 -63
  62. package/lib/cjs/components/datamap/DataMap.js +4 -16
  63. package/lib/cjs/components/datetime/DateTime.js +2 -6
  64. package/lib/cjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
  65. package/lib/cjs/components/day/Day.js +12 -70
  66. package/lib/cjs/components/day/editForm/Day.edit.day.js +1 -3
  67. package/lib/cjs/components/day/editForm/Day.edit.month.js +1 -3
  68. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -0
  69. package/lib/cjs/components/editgrid/EditGrid.js +18 -44
  70. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
  71. package/lib/cjs/components/file/File.js +40 -70
  72. package/lib/cjs/components/file/editForm/File.edit.display.js +1 -5
  73. package/lib/cjs/components/file/editForm/File.edit.file.js +8 -30
  74. package/lib/cjs/components/form/Form.js +5 -7
  75. package/lib/cjs/components/html/HTML.js +1 -5
  76. package/lib/cjs/components/number/Number.js +2 -4
  77. package/lib/cjs/components/panel/editForm/Panel.edit.display.js +3 -12
  78. package/lib/cjs/components/password/Password.js +1 -4
  79. package/lib/cjs/components/radio/Radio.js +7 -17
  80. package/lib/cjs/components/radio/editForm/Radio.edit.data.js +4 -14
  81. package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -6
  82. package/lib/cjs/components/select/Select.js +48 -92
  83. package/lib/cjs/components/select/editForm/Select.edit.data.js +37 -182
  84. package/lib/cjs/components/select/editForm/Select.edit.validation.js +1 -9
  85. package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -6
  86. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  87. package/lib/cjs/components/signature/Signature.js +5 -10
  88. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +2 -6
  89. package/lib/cjs/components/survey/Survey.js +6 -17
  90. package/lib/cjs/components/survey/editForm/Survey.edit.data.js +4 -12
  91. package/lib/cjs/components/table/editForm/Table.edit.display.js +3 -3
  92. package/lib/cjs/components/tabs/Tabs.js +4 -19
  93. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
  94. package/lib/cjs/components/tags/Tags.js +4 -14
  95. package/lib/cjs/components/textarea/TextArea.js +8 -15
  96. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
  97. package/lib/cjs/components/textfield/TextField.js +4 -4
  98. package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +2 -8
  99. package/lib/cjs/components/time/Time.js +1 -4
  100. package/lib/cjs/components/time/editForm/Time.edit.display.js +1 -4
  101. package/lib/cjs/formio.form.js +5 -5
  102. package/lib/cjs/package.json +1 -1
  103. package/lib/cjs/providers/address/AddressProvider.js +1 -1
  104. package/lib/cjs/providers/address/GoogleAddressProvider.js +1 -3
  105. package/lib/cjs/providers/processor/fileProcessor.js +1 -3
  106. package/lib/cjs/providers/storage/azure.js +5 -6
  107. package/lib/cjs/providers/storage/indexeddb.js +5 -15
  108. package/lib/cjs/providers/storage/s3.js +3 -14
  109. package/lib/cjs/providers/storage/xhr.js +19 -28
  110. package/lib/cjs/templates/Templates.js +1 -0
  111. package/lib/cjs/translations/en.d.ts +237 -82
  112. package/lib/cjs/translations/en.js +9 -82
  113. package/lib/cjs/utils/ChoicesWrapper.js +1 -1
  114. package/lib/cjs/utils/builder.js +5 -26
  115. package/lib/cjs/utils/i18n.d.ts +5 -2
  116. package/lib/cjs/utils/i18n.js +33 -12
  117. package/lib/cjs/utils/utils.js +37 -47
  118. package/lib/cjs/widgets/CalendarWidget.js +2 -6
  119. package/lib/mjs/Embed.js +8 -16
  120. package/lib/mjs/Form.js +4 -4
  121. package/lib/mjs/Formio.js +2 -9
  122. package/lib/mjs/InlineEmbed.js +1 -4
  123. package/lib/mjs/PDF.js +27 -8
  124. package/lib/mjs/PDFBuilder.js +6 -10
  125. package/lib/mjs/Webform.d.ts +1 -0
  126. package/lib/mjs/Webform.js +19 -31
  127. package/lib/mjs/WebformBuilder.js +27 -68
  128. package/lib/mjs/Wizard.d.ts +1 -0
  129. package/lib/mjs/Wizard.js +39 -27
  130. package/lib/mjs/WizardBuilder.js +5 -15
  131. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +2 -6
  132. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -9
  133. package/lib/mjs/addons/index.js +1 -3
  134. package/lib/mjs/components/_classes/component/Component.d.ts +5 -5
  135. package/lib/mjs/components/_classes/component/Component.js +59 -132
  136. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -4
  137. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +4 -16
  138. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -4
  139. package/lib/mjs/components/_classes/field/Field.js +1 -4
  140. package/lib/mjs/components/_classes/input/Input.js +2 -2
  141. package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
  142. package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +6 -28
  143. package/lib/mjs/components/_classes/multivalue/Multivalue.js +8 -26
  144. package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -4
  145. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +5 -9
  146. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -3
  147. package/lib/mjs/components/address/Address.js +10 -30
  148. package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -32
  149. package/lib/mjs/components/alert/Alert.js +3 -6
  150. package/lib/mjs/components/button/Button.js +9 -16
  151. package/lib/mjs/components/button/editForm/Button.edit.display.js +8 -32
  152. package/lib/mjs/components/checkbox/Checkbox.js +4 -10
  153. package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +2 -8
  154. package/lib/mjs/components/columns/Columns.js +5 -17
  155. package/lib/mjs/components/container/Container.js +1 -3
  156. package/lib/mjs/components/currency/Currency.js +2 -7
  157. package/lib/mjs/components/datagrid/DataGrid.js +23 -63
  158. package/lib/mjs/components/datamap/DataMap.js +12 -18
  159. package/lib/mjs/components/datetime/DateTime.js +2 -6
  160. package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +1 -4
  161. package/lib/mjs/components/day/Day.js +12 -70
  162. package/lib/mjs/components/day/editForm/Day.edit.day.js +1 -3
  163. package/lib/mjs/components/day/editForm/Day.edit.month.js +1 -3
  164. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -0
  165. package/lib/mjs/components/editgrid/EditGrid.js +18 -44
  166. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -4
  167. package/lib/mjs/components/file/File.js +40 -70
  168. package/lib/mjs/components/file/editForm/File.edit.display.js +1 -5
  169. package/lib/mjs/components/file/editForm/File.edit.file.js +8 -30
  170. package/lib/mjs/components/form/Form.js +5 -7
  171. package/lib/mjs/components/html/HTML.js +1 -5
  172. package/lib/mjs/components/number/Number.js +2 -4
  173. package/lib/mjs/components/panel/editForm/Panel.edit.display.js +3 -12
  174. package/lib/mjs/components/password/Password.js +1 -4
  175. package/lib/mjs/components/radio/Radio.js +7 -17
  176. package/lib/mjs/components/radio/editForm/Radio.edit.data.js +4 -14
  177. package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -6
  178. package/lib/mjs/components/select/Select.js +51 -95
  179. package/lib/mjs/components/select/editForm/Select.edit.data.js +37 -182
  180. package/lib/mjs/components/select/editForm/Select.edit.validation.js +1 -9
  181. package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -6
  182. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  183. package/lib/mjs/components/signature/Signature.js +5 -10
  184. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +2 -6
  185. package/lib/mjs/components/survey/Survey.js +6 -17
  186. package/lib/mjs/components/survey/editForm/Survey.edit.data.js +4 -12
  187. package/lib/mjs/components/table/editForm/Table.edit.display.js +3 -3
  188. package/lib/mjs/components/tabs/Tabs.js +4 -19
  189. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +1 -3
  190. package/lib/mjs/components/tags/Tags.js +4 -14
  191. package/lib/mjs/components/textarea/TextArea.js +8 -15
  192. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +14 -56
  193. package/lib/mjs/components/textfield/TextField.js +4 -4
  194. package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +2 -8
  195. package/lib/mjs/components/time/Time.js +1 -4
  196. package/lib/mjs/components/time/editForm/Time.edit.display.js +1 -4
  197. package/lib/mjs/formio.form.js +6 -6
  198. package/lib/mjs/package.json +1 -1
  199. package/lib/mjs/providers/address/AddressProvider.js +1 -1
  200. package/lib/mjs/providers/address/GoogleAddressProvider.js +1 -3
  201. package/lib/mjs/providers/processor/fileProcessor.js +1 -3
  202. package/lib/mjs/providers/storage/azure.js +5 -6
  203. package/lib/mjs/providers/storage/indexeddb.js +5 -15
  204. package/lib/mjs/providers/storage/s3.js +3 -14
  205. package/lib/mjs/providers/storage/xhr.js +19 -32
  206. package/lib/mjs/templates/Templates.js +1 -0
  207. package/lib/mjs/translations/en.d.ts +237 -82
  208. package/lib/mjs/translations/en.js +88 -0
  209. package/lib/mjs/utils/ChoicesWrapper.js +1 -1
  210. package/lib/mjs/utils/builder.js +5 -26
  211. package/lib/mjs/utils/i18n.d.ts +5 -2
  212. package/lib/mjs/utils/i18n.js +33 -12
  213. package/lib/mjs/utils/utils.js +37 -47
  214. package/lib/mjs/widgets/CalendarWidget.js +2 -6
  215. package/package.json +6 -4
@@ -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
- utils_1.componentValueTypes[dataType],
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)) || (this.inDataTable && !this.element);
259
+ : this.dataValue === this.normalizeSingleValue(value)) ||
260
+ (this.inDataTable && !this.element);
280
261
  if (shouldUseSelectData) {
281
- const selectData = (this.inDataTable && !this.element) ? this.component.selectData : this.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 && !this.options.readOnly && this.root && !this.root.submissionSet) {
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(`Unable to load resources for ${this.key}`);
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 ? this.t(this.component.placeholder, { _userInput: true }) : null;
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('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: this.component.dropdown || 'auto', searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', [
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('Failed to normalize value', err);
1258
+ console.warn(this.t('failedToNormalize'), err);
1286
1259
  return value;
1287
1260
  }
1288
1261
  }
@@ -1338,8 +1311,7 @@ class SelectComponent extends ListComponent_1.default {
1338
1311
  }
1339
1312
  lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
1340
1313
  }
1341
- else if (!this.templateData[templateValue] &&
1342
- this.isEmpty(value)) {
1314
+ else if (!this.templateData[templateValue] && this.isEmpty(value)) {
1343
1315
  lodash_1.default.unset(this.root.submission, `metadata.selectData.${this.path}`);
1344
1316
  }
1345
1317
  if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
@@ -1438,11 +1410,7 @@ class SelectComponent extends ListComponent_1.default {
1438
1410
  if (hasValue) {
1439
1411
  this.choices.removeActiveItems();
1440
1412
  // Add the currently selected choices if they don't already exist.
1441
- const currentChoices = Array.isArray(value) && this.component.multiple
1442
- ? value
1443
- : [
1444
- value,
1445
- ];
1413
+ const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];
1446
1414
  if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {
1447
1415
  this.choices.setChoices(this.selectOptions, 'value', 'label', true);
1448
1416
  }
@@ -1454,11 +1422,7 @@ class SelectComponent extends ListComponent_1.default {
1454
1422
  }
1455
1423
  else {
1456
1424
  if (hasValue) {
1457
- const values = Array.isArray(value)
1458
- ? value
1459
- : [
1460
- value,
1461
- ];
1425
+ const values = Array.isArray(value) ? value : [value];
1462
1426
  if ((!lodash_1.default.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2) ||
1463
1427
  (this.selectData && flags.fromSubmission)) {
1464
1428
  const { value, label } = this.selectValueAndLabel(this.dataValue);
@@ -1503,7 +1467,7 @@ class SelectComponent extends ListComponent_1.default {
1503
1467
  return JSON.stringify(normalizedOptionValue) === JSON.stringify(value);
1504
1468
  }
1505
1469
  catch (err) {
1506
- console.warn.error('Error while comparing items', err);
1470
+ console.warn.error(this.t('failedToCompareItems'), err);
1507
1471
  return false;
1508
1472
  }
1509
1473
  };
@@ -1600,11 +1564,14 @@ class SelectComponent extends ListComponent_1.default {
1600
1564
  var _a;
1601
1565
  value = value !== null && value !== void 0 ? value : this.getValue();
1602
1566
  if (options.modalPreview ||
1603
- ((this.inDataTable || this.inEditGrid) && !['values', 'custom'].includes(this.component.dataSrc))) {
1567
+ ((this.inDataTable || this.inEditGrid) &&
1568
+ !['values', 'custom'].includes(this.component.dataSrc))) {
1604
1569
  if (this.inDataTable) {
1605
1570
  value = this.undoValueTyping(value);
1606
1571
  }
1607
- const templateValue = !lodash_1.default.isEmpty(value) && this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data) ? { data: value } : value;
1572
+ const templateValue = !lodash_1.default.isEmpty(value) && this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)
1573
+ ? { data: value }
1574
+ : value;
1608
1575
  const template = this.itemTemplate(templateValue, value, options);
1609
1576
  return template;
1610
1577
  }
@@ -1628,11 +1595,7 @@ class SelectComponent extends ListComponent_1.default {
1628
1595
  return data;
1629
1596
  };
1630
1597
  value = convertToString(value);
1631
- if ([
1632
- 'values',
1633
- 'custom',
1634
- ].includes(this.component.dataSrc) &&
1635
- !this.asyncCustomValues()) {
1598
+ if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {
1636
1599
  const { items, valueProperty } = this.component.dataSrc === 'values'
1637
1600
  ? {
1638
1601
  items: convertToString(this.getNormalizedValues(), 'value'),
@@ -1643,10 +1606,7 @@ class SelectComponent extends ListComponent_1.default {
1643
1606
  valueProperty: this.valueProperty,
1644
1607
  };
1645
1608
  const getFromValues = () => {
1646
- const initialValue = lodash_1.default.find(items, [
1647
- valueProperty,
1648
- value,
1649
- ]);
1609
+ const initialValue = lodash_1.default.find(items, [valueProperty, value]);
1650
1610
  const values = this.defaultSchema.data.values || [];
1651
1611
  return lodash_1.default.isEqual(initialValue, values[0]) ? '-' : initialValue;
1652
1612
  };
@@ -1702,14 +1662,10 @@ class SelectComponent extends ListComponent_1.default {
1702
1662
  setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {
1703
1663
  super.setErrorClasses(elements, dirty, hasError, hasMessages, element);
1704
1664
  if (this.choices) {
1705
- super.setErrorClasses([
1706
- this.choices.containerInner.element,
1707
- ], dirty, hasError, hasMessages, element);
1665
+ super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);
1708
1666
  }
1709
1667
  else {
1710
- super.setErrorClasses([
1711
- this.refs.selectContainer,
1712
- ], dirty, hasError, hasMessages, element);
1668
+ super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);
1713
1669
  }
1714
1670
  }
1715
1671
  }