@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
@@ -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
- componentValueTypes[dataType],
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)) || (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?._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 && !this.options.readOnly && this.root && !this.root.submissionSet) {
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(`Unable to load resources for ${this.key}`);
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 ? 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 {
@@ -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('No results found'),
872
- noChoicesText: this.t('No choices to choose from'),
873
- searchPlaceholderValue: this.t('Type to search'),
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('Failed to normalize value', err);
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('Error while comparing items', err);
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) && !['values', 'custom'].includes(this.component.dataSrc))) {
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) ? { data: value } : value;
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
  }