@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
@@ -34,9 +34,7 @@ export default class DataGridComponent extends NestedArrayComponent {
34
34
  this.components = this.components || [];
35
35
  // Add new values based on minLength.
36
36
  this.rows = [];
37
- this.columns = [
38
- ...this.component.components,
39
- ];
37
+ this.columns = [...this.component.components];
40
38
  if (this.initRows || !_.isEqual(this.dataValue, this.emptyValue)) {
41
39
  this.createRows(true);
42
40
  }
@@ -64,11 +62,7 @@ export default class DataGridComponent extends NestedArrayComponent {
64
62
  return this.builderMode || this.path === 'defaultValue' || !this.initEmpty;
65
63
  }
66
64
  get emptyValue() {
67
- return this.initEmpty
68
- ? []
69
- : [
70
- {},
71
- ];
65
+ return this.initEmpty ? [] : [{}];
72
66
  }
73
67
  get addAnotherPosition() {
74
68
  return _.get(this.component, 'addAnotherPosition', 'bottom');
@@ -86,11 +80,7 @@ export default class DataGridComponent extends NestedArrayComponent {
86
80
  const isEmptyInit = this.initEmpty;
87
81
  // Ensure we have one and only one row in builder mode.
88
82
  if (isBuilderMode || (isEmptyInit && !this.dataValue.length)) {
89
- return isEmptyInit && !isBuilderMode
90
- ? []
91
- : [
92
- {},
93
- ];
83
+ return isEmptyInit && !isBuilderMode ? [] : [{}];
94
84
  }
95
85
  const value = super.defaultValue;
96
86
  let defaultValue;
@@ -98,9 +88,7 @@ export default class DataGridComponent extends NestedArrayComponent {
98
88
  defaultValue = value;
99
89
  }
100
90
  else if (value && typeof value === 'object') {
101
- defaultValue = [
102
- value,
103
- ];
91
+ defaultValue = [value];
104
92
  }
105
93
  else {
106
94
  defaultValue = this.emptyValue;
@@ -160,22 +148,10 @@ export default class DataGridComponent extends NestedArrayComponent {
160
148
  * @returns {Array<T[]>} - The chunked rows
161
149
  */
162
150
  getRowChunks(groups, rows) {
163
- const [, chunks,] = groups.reduce(([startIndex, acc,], size) => {
151
+ const [, chunks] = groups.reduce(([startIndex, acc], size) => {
164
152
  const endIndex = startIndex + size;
165
- return [
166
- endIndex,
167
- [
168
- ...acc,
169
- [
170
- startIndex,
171
- endIndex,
172
- ],
173
- ],
174
- ];
175
- }, [
176
- 0,
177
- [],
178
- ]);
153
+ return [endIndex, [...acc, [startIndex, endIndex]]];
154
+ }, [0, []]);
179
155
  return chunks.map((range) => _.slice(rows, ...range));
180
156
  }
181
157
  /**
@@ -189,9 +165,7 @@ export default class DataGridComponent extends NestedArrayComponent {
189
165
  const indexes = sizes.reduce((groupIndexes, size) => {
190
166
  const last = groupIndexes[groupIndexes.length - 1];
191
167
  return groupIndexes.concat(last + size);
192
- }, [
193
- 0,
194
- ]);
168
+ }, [0]);
195
169
  return groups.reduce((gidxs, group, idx) => {
196
170
  return {
197
171
  ...gidxs,
@@ -227,18 +201,10 @@ export default class DataGridComponent extends NestedArrayComponent {
227
201
  this.dataValue.length > _.get(this.component, 'validate.minLength', 0));
228
202
  }
229
203
  hasTopSubmit() {
230
- return (this.hasAddButton() &&
231
- [
232
- 'top',
233
- 'both',
234
- ].includes(this.addAnotherPosition));
204
+ return this.hasAddButton() && ['top', 'both'].includes(this.addAnotherPosition);
235
205
  }
236
206
  hasBottomSubmit() {
237
- return (this.hasAddButton() &&
238
- [
239
- 'bottom',
240
- 'both',
241
- ].includes(this.addAnotherPosition));
207
+ return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);
242
208
  }
243
209
  get canAddColumn() {
244
210
  return this.builderMode && !this.options.design;
@@ -315,9 +281,7 @@ export default class DataGridComponent extends NestedArrayComponent {
315
281
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
316
282
  row.dragInfo = { index };
317
283
  });
318
- this.dragula = dragula([
319
- this.refs[`${this.datagridKey}-tbody`],
320
- ], {
284
+ this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
321
285
  moves: (_draggedElement, _oldParent, clickedElement) => {
322
286
  const clickedElementKey = clickedElement.getAttribute('data-key');
323
287
  const oldParentKey = _oldParent.getAttribute('data-key');
@@ -361,9 +325,7 @@ export default class DataGridComponent extends NestedArrayComponent {
361
325
  this.rows.forEach((row, rowIndex) => {
362
326
  let columnIndex = 0;
363
327
  columns.forEach((col) => {
364
- this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [
365
- this.rows[rowIndex][col.key],
366
- ], this.getComponentsContainer());
328
+ this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [this.rows[rowIndex][col.key]], this.getComponentsContainer());
367
329
  columnIndex++;
368
330
  });
369
331
  });
@@ -392,7 +354,7 @@ export default class DataGridComponent extends NestedArrayComponent {
392
354
  }
393
355
  onReorder(element, _target, _source, sibling) {
394
356
  if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
395
- console.warn('There is no Drag Info available for either dragged or sibling element');
357
+ console.warn(this.t('noDragInfoError'));
396
358
  return;
397
359
  }
398
360
  const oldPosition = element.dragInfo.index;
@@ -484,10 +446,15 @@ export default class DataGridComponent extends NestedArrayComponent {
484
446
  }
485
447
  removeRow(index) {
486
448
  const makeEmpty = index === 0 && this.rows.length === 1;
487
- const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
449
+ const flags = {
450
+ isReordered: !makeEmpty,
451
+ resetValue: makeEmpty,
452
+ modified: true,
453
+ noPristineChangeOnModified: true,
454
+ };
488
455
  this.splice(index, flags);
489
456
  this.emit('dataGridDeleteRow', { index });
490
- const [row,] = this.rows.splice(index, 1);
457
+ const [row] = this.rows.splice(index, 1);
491
458
  this.removeSubmissionMetadataRow(index);
492
459
  this.removeRowComponents(row);
493
460
  this.updateRowsComponents(index);
@@ -609,10 +576,7 @@ export default class DataGridComponent extends NestedArrayComponent {
609
576
  !!visibility[key] ||
610
577
  (col.checkConditions(data, flags, dataValue[rowIndex]) && col.type !== 'hidden');
611
578
  if (col.component.logic && firstRowCheck) {
612
- const compIndex = _.findIndex(this.columns, [
613
- 'key',
614
- key,
615
- ]);
579
+ const compIndex = _.findIndex(this.columns, ['key', key]);
616
580
  const equalColumns = _.isEqualWith(this.columns[compIndex], col.component, (col1, col2, key) => {
617
581
  // Don't compare columns by their auto-generated ids.
618
582
  if (key === 'id') {
@@ -656,15 +620,11 @@ export default class DataGridComponent extends NestedArrayComponent {
656
620
  }
657
621
  if (!Array.isArray(value)) {
658
622
  if (typeof value === 'object') {
659
- value = [
660
- value,
661
- ];
623
+ value = [value];
662
624
  }
663
625
  else {
664
626
  this.createRows();
665
- value = [
666
- {},
667
- ];
627
+ value = [{}];
668
628
  }
669
629
  }
670
630
  // Make sure we always have at least one row.
@@ -45,9 +45,7 @@ export default class DataMapComponent extends DataGridComponent {
45
45
  return _.omit(schema, 'components');
46
46
  }
47
47
  static savedValueTypes(schema) {
48
- return (getComponentSavedTypes(schema) || [
49
- componentValueTypes.object,
50
- ]);
48
+ return getComponentSavedTypes(schema) || [componentValueTypes.object];
51
49
  }
52
50
  constructor(component, options, data) {
53
51
  super(component, options, data);
@@ -101,9 +99,7 @@ export default class DataMapComponent extends DataGridComponent {
101
99
  getRowValues() {
102
100
  const dataValue = this.dataValue;
103
101
  if (this.builderMode) {
104
- return [
105
- dataValue,
106
- ];
102
+ return [dataValue];
107
103
  }
108
104
  if (_.isEmpty(dataValue)) {
109
105
  return [];
@@ -120,7 +116,7 @@ export default class DataMapComponent extends DataGridComponent {
120
116
  return this.rows.map((row) => {
121
117
  return {
122
118
  components: row,
123
- data: _.mapValues(row, (comp) => comp.dataValue)
119
+ data: _.mapValues(row, (comp) => comp.dataValue),
124
120
  };
125
121
  });
126
122
  }
@@ -141,15 +137,7 @@ export default class DataMapComponent extends DataGridComponent {
141
137
  const valueSchema = Object.assign({}, this.component.valueComponent);
142
138
  keySchema.hideLabel = false;
143
139
  valueSchema.hideLabel = false;
144
- return this.component.keyBeforeValue
145
- ? [
146
- keySchema,
147
- valueSchema,
148
- ]
149
- : [
150
- valueSchema,
151
- keySchema,
152
- ];
140
+ return this.component.keyBeforeValue ? [keySchema, valueSchema] : [valueSchema, keySchema];
153
141
  }
154
142
  getRowKey(rowIndex) {
155
143
  const keys = Object.keys(this.dataValue);
@@ -273,13 +261,19 @@ export default class DataMapComponent extends DataGridComponent {
273
261
  if (this.submissionTimezone) {
274
262
  componentOptions.submissionTimezone = this.submissionTimezone;
275
263
  if (valueComponent.type === 'datetime') {
276
- valueComponent.widget = { ...valueComponent.widget, submissionTimezone: this.submissionTimezone };
264
+ valueComponent.widget = {
265
+ ...valueComponent.widget,
266
+ submissionTimezone: this.submissionTimezone,
267
+ };
277
268
  }
278
269
  }
279
270
  const createdComponent = this.createComponent(valueComponent, componentOptions, this.dataValue);
280
271
  // Ensure submissionTimezone is set on datetime component instance's widget and options
281
272
  if (createdComponent?.type === 'datetime' && this.submissionTimezone) {
282
- createdComponent.component.widget = { ...createdComponent.component.widget, submissionTimezone: this.submissionTimezone };
273
+ createdComponent.component.widget = {
274
+ ...createdComponent.component.widget,
275
+ submissionTimezone: this.submissionTimezone,
276
+ };
283
277
  createdComponent.options.submissionTimezone = this.submissionTimezone;
284
278
  }
285
279
  components[this.valueKey] = createdComponent;
@@ -77,9 +77,7 @@ export default class DateTimeComponent extends Input {
77
77
  }
78
78
  static savedValueTypes(schema) {
79
79
  schema = schema || {};
80
- return (getComponentSavedTypes(schema) || [
81
- componentValueTypes.date,
82
- ]);
80
+ return getComponentSavedTypes(schema) || [componentValueTypes.date];
83
81
  }
84
82
  constructor(component, options, data) {
85
83
  super(component, options, data);
@@ -201,9 +199,7 @@ export default class DateTimeComponent extends Input {
201
199
  let format = FormioUtils.convertFormatToMoment(this.component.format);
202
200
  format += format.match(/z$/) ? '' : ' z';
203
201
  const timezone = this.timezone;
204
- const useTimezoneAwareFormat = value &&
205
- timezone &&
206
- (this.options.pdf || options?.email);
202
+ const useTimezoneAwareFormat = value && timezone && (this.options.pdf || options?.email);
207
203
  if (useTimezoneAwareFormat) {
208
204
  if (Array.isArray(value) && this.component.multiple) {
209
205
  return value
@@ -34,10 +34,7 @@ export default [
34
34
  template: '<span>{{ item.label }}</span>',
35
35
  conditional: {
36
36
  json: {
37
- '===': [
38
- { var: 'data.displayInTimezone' },
39
- 'location',
40
- ],
37
+ '===': [{ var: 'data.displayInTimezone' }, 'location'],
41
38
  },
42
39
  },
43
40
  },
@@ -57,9 +57,7 @@ export default class DayComponent extends Field {
57
57
  }
58
58
  static savedValueTypes(schema) {
59
59
  schema = schema || {};
60
- return (getComponentSavedTypes(schema) || [
61
- componentValueTypes.string,
62
- ]);
60
+ return getComponentSavedTypes(schema) || [componentValueTypes.string];
63
61
  }
64
62
  // Empty value used before 9.3.x
65
63
  static oldEmptyValue = '00/00/0000';
@@ -166,9 +164,7 @@ export default class DayComponent extends Field {
166
164
  };
167
165
  }
168
166
  get days() {
169
- const days = [
170
- { value: '', label: _.get(this.component, 'fields.day.placeholder', '') },
171
- ];
167
+ const days = [{ value: '', label: _.get(this.component, 'fields.day.placeholder', '') }];
172
168
  for (let x = 1; x <= 31; x++) {
173
169
  days.push({
174
170
  value: x,
@@ -182,7 +178,7 @@ export default class DayComponent extends Field {
182
178
  {
183
179
  value: '',
184
180
  label: _.get(this.component, 'fields.month.placeholder') ||
185
- (this.hideInputLabels ? this.t('Month') : ''),
181
+ (this.hideInputLabels ? this.t('month') : ''),
186
182
  },
187
183
  { value: 1, label: 'January' },
188
184
  { value: 2, label: 'February' },
@@ -200,9 +196,7 @@ export default class DayComponent extends Field {
200
196
  return months;
201
197
  }
202
198
  get years() {
203
- const years = [
204
- { value: '', label: _.get(this.component, 'fields.year.placeholder', '') },
205
- ];
199
+ const years = [{ value: '', label: _.get(this.component, 'fields.year.placeholder', '') }];
206
200
  const minYears = _.get(this.component, 'fields.year.minYear', 1900) || 1900;
207
201
  const maxYears = _.get(this.component, 'fields.year.maxYear', 2030) || 2030;
208
202
  for (let x = minYears; x <= maxYears; x++) {
@@ -215,18 +209,10 @@ export default class DayComponent extends Field {
215
209
  }
216
210
  setErrorClasses(elements, dirty, hasError) {
217
211
  super.setErrorClasses(elements, dirty, hasError);
218
- super.setErrorClasses([
219
- this.refs.day,
220
- this.refs.month,
221
- this.refs.year,
222
- ], dirty, hasError);
212
+ super.setErrorClasses([this.refs.day, this.refs.month, this.refs.year], dirty, hasError);
223
213
  }
224
214
  removeInputError(elements) {
225
- super.removeInputError([
226
- this.refs.day,
227
- this.refs.month,
228
- this.refs.year,
229
- ]);
215
+ super.removeInputError([this.refs.day, this.refs.month, this.refs.year]);
230
216
  super.removeInputError(elements);
231
217
  }
232
218
  init() {
@@ -282,7 +268,7 @@ export default class DayComponent extends Field {
282
268
  this.saveCaretPosition(element, name);
283
269
  }
284
270
  catch (err) {
285
- console.warn('An error occurred while trying to save caret position', err);
271
+ console.warn(this.t('caretPositionSavingError'), err);
286
272
  }
287
273
  this.updateValue(null, {
288
274
  modified: true,
@@ -317,11 +303,7 @@ export default class DayComponent extends Field {
317
303
  this.addEventListener(this.refs.input, this.info.changeEvent, () => this.updateValue(null, {
318
304
  modified: true,
319
305
  }));
320
- [
321
- this.refs.day,
322
- this.refs.month,
323
- this.refs.year,
324
- ]
306
+ [this.refs.day, this.refs.month, this.refs.year]
325
307
  .filter((element) => !!element)
326
308
  .forEach((element) => {
327
309
  super.addFocusBlurEvents(element);
@@ -374,17 +356,7 @@ export default class DayComponent extends Field {
374
356
  }
375
357
  const dateParts = [];
376
358
  const valueParts = value.split('/');
377
- const [DAY, MONTH, YEAR,] = this.component.dayFirst
378
- ? [
379
- 0,
380
- 1,
381
- 2,
382
- ]
383
- : [
384
- 1,
385
- 0,
386
- 2,
387
- ];
359
+ const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
388
360
  const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
389
361
  let defaultDay = '';
390
362
  let defaultMonth = '';
@@ -461,17 +433,7 @@ export default class DayComponent extends Field {
461
433
  }
462
434
  }
463
435
  getDayWithHiddenFields(parts) {
464
- let [DAY, MONTH, YEAR,] = this.component.dayFirst
465
- ? [
466
- 0,
467
- 1,
468
- 2,
469
- ]
470
- : [
471
- 1,
472
- 0,
473
- 2,
474
- ];
436
+ let [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
475
437
  if (!this.showDay) {
476
438
  MONTH = MONTH === 0 ? 0 : MONTH - 1;
477
439
  YEAR = YEAR - 1;
@@ -532,17 +494,7 @@ export default class DayComponent extends Field {
532
494
  getDate(value) {
533
495
  let defaults = [], day, month, year;
534
496
  // Map positions to identifiers to get default values for each part of day
535
- const [DAY, MONTH, YEAR,] = this.component.dayFirst
536
- ? [
537
- 0,
538
- 1,
539
- 2,
540
- ]
541
- : [
542
- 1,
543
- 0,
544
- 2,
545
- ];
497
+ const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
546
498
  const defaultValue = value || this.component.defaultValue;
547
499
  if (defaultValue) {
548
500
  defaults = defaultValue.split('/').map((x) => parseInt(x, 10));
@@ -686,17 +638,7 @@ export default class DayComponent extends Field {
686
638
  if (!value) {
687
639
  return true;
688
640
  }
689
- const [DAY, MONTH, YEAR,] = this.component.dayFirst
690
- ? [
691
- 0,
692
- 1,
693
- 2,
694
- ]
695
- : [
696
- 1,
697
- 0,
698
- 2,
699
- ];
641
+ const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
700
642
  const values = value.split('/');
701
643
  if (values.length < 3) {
702
644
  return true;
@@ -38,9 +38,7 @@ export default [
38
38
  if (data.defaultValue) {
39
39
  const defaultValueParts = data.defaultValue.split('/');
40
40
  if (!data.fields.day.hide && defaultValueParts.length !== 3) {
41
- const newDefaultValue = [
42
- '00',
43
- ];
41
+ const newDefaultValue = ['00'];
44
42
  if (!data.fields.month.hide) {
45
43
  data.dayFirst
46
44
  ? newDefaultValue.push(defaultValueParts[0])
@@ -38,9 +38,7 @@ export default [
38
38
  if (data.defaultValue) {
39
39
  const defaultValueParts = data.defaultValue.split('/');
40
40
  if (!data.fields.month.hide && defaultValueParts.length !== 3) {
41
- const newDefaultValue = [
42
- '00',
43
- ];
41
+ const newDefaultValue = ['00'];
44
42
  if (!data.fields.day.hide) {
45
43
  data.dayFirst
46
44
  ? newDefaultValue.unshift(defaultValueParts[0])
@@ -42,6 +42,7 @@ export default class EditGridComponent extends NestedArrayComponent {
42
42
  get iteratableRows(): any;
43
43
  get defaultValue(): any[];
44
44
  hasRemoveButtons(): boolean;
45
+ checkData(data: any, flags: any, row: any): Promise<void> | undefined;
45
46
  editRows: any;
46
47
  checkRowVariableTypeComponents(editRow: any, rowIndex: any): void;
47
48
  setVariableTypeComponents(): void;
@@ -4,7 +4,7 @@ import { editgrid as templates } from '@formio/bootstrap/components';
4
4
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
5
5
  import Component from '../_classes/component/Component';
6
6
  import Alert from '../alert/Alert';
7
- import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent, screenReaderSpeech } from '../../utils';
7
+ import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent, screenReaderSpeech, } from '../../utils';
8
8
  const EditRowState = {
9
9
  New: 'new',
10
10
  Editing: 'editing',
@@ -115,10 +115,10 @@ export default class EditGridComponent extends NestedArrayComponent {
115
115
  }
116
116
  get defaultDialogTemplate() {
117
117
  return `
118
- <h3 ${this._referenceAttributeName}="dialogHeader">${this.t('Do you want to clear data?')}</h3>
118
+ <h3 ${this._referenceAttributeName}="dialogHeader">${this.t('wantToClearData')}</h3>
119
119
  <div style="display:flex; justify-content: flex-end;">
120
- <button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('Cancel')}">${this.t('Cancel')}</button>
121
- <button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('Yes, delete it')}">${this.t('Yes, delete it')}</button>
120
+ <button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('cancel')}">${this.t('cancel')}</button>
121
+ <button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('yesDelete')}">${this.t('yesDelete')}</button>
122
122
  </div>
123
123
  `;
124
124
  }
@@ -253,6 +253,12 @@ export default class EditGridComponent extends NestedArrayComponent {
253
253
  this.fullMode &&
254
254
  this.dataValue.length > _.get(this.component, 'validate.minLength', 0));
255
255
  }
256
+ checkData(data, flags, row) {
257
+ super.checkData(data, flags, row);
258
+ if (this.type === 'editgrid' && flags?.fromSubmission) {
259
+ return this.redraw();
260
+ }
261
+ }
256
262
  init() {
257
263
  if (this.builderMode) {
258
264
  this.editRows = [];
@@ -302,19 +308,11 @@ export default class EditGridComponent extends NestedArrayComponent {
302
308
  });
303
309
  }
304
310
  isOpen(editRow) {
305
- return [
306
- EditRowState.New,
307
- EditRowState.Editing,
308
- EditRowState.Viewing,
309
- ].includes(editRow.state);
311
+ return [EditRowState.New, EditRowState.Editing, EditRowState.Viewing].includes(editRow.state);
310
312
  }
311
313
  isComponentVisibleInSomeRow(component) {
312
314
  const rows = this.editRows;
313
- const savedStates = [
314
- EditRowState.Saved,
315
- EditRowState.Editing,
316
- EditRowState.Draft,
317
- ];
315
+ const savedStates = [EditRowState.Saved, EditRowState.Editing, EditRowState.Draft];
318
316
  const savedRows = rows.filter((row) => _.includes(savedStates, row.state));
319
317
  this.visibleInHeader = this.visibleInHeader || [];
320
318
  const changeVisibleInHeader = (component, isVisible) => {
@@ -335,9 +333,7 @@ export default class EditGridComponent extends NestedArrayComponent {
335
333
  comp.checkConditions();
336
334
  });
337
335
  const isVisible = checkComponent ? checkComponent.visible : true;
338
- [
339
- ...this.components,
340
- ].forEach((comp) => this.removeComponent(comp, this.components));
336
+ [...this.components].forEach((comp) => this.removeComponent(comp, this.components));
341
337
  changeVisibleInHeader(component, isVisible);
342
338
  return isVisible;
343
339
  }
@@ -477,10 +473,7 @@ export default class EditGridComponent extends NestedArrayComponent {
477
473
  const elements = row.getElementsByClassName(className);
478
474
  Array.prototype.forEach.call(elements, (element) => {
479
475
  if (this.options.pdf &&
480
- _.intersection(element.classList, [
481
- 'editRow',
482
- 'removeRow',
483
- ]).length) {
476
+ _.intersection(element.classList, ['editRow', 'removeRow']).length) {
484
477
  element.style.display = 'none';
485
478
  }
486
479
  else {
@@ -536,7 +529,7 @@ export default class EditGridComponent extends NestedArrayComponent {
536
529
  flattenedComponents,
537
530
  displayValue: (component) => this.displayComponentValue(component),
538
531
  isVisibleInRow: (component) => this.isComponentVisibleInRow(component, flattenedComponents),
539
- getView: (component, data) => {
532
+ getView: (component, _data) => {
540
533
  const instance = flattenedComponents[component.key];
541
534
  const view = instance ? instance.getView(instance.dataValue) : '';
542
535
  // If there is an html tag in view, don't allow it to be injected in template
@@ -1047,10 +1040,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1047
1040
  editRow.errors =
1048
1041
  this.component.modal || this.component.rowDrafts
1049
1042
  ? errors
1050
- : errors.filter((err) => _.find(this.visibleErrors, [
1051
- 'component.id',
1052
- err.component.id,
1053
- ]));
1043
+ : errors.filter((err) => _.find(this.visibleErrors, ['component.id', err.component.id]));
1054
1044
  }
1055
1045
  // TODO: this is essentially running its own custom validation and should be moved into a validation rule
1056
1046
  if (this.component.validate && this.component.validate.row) {
@@ -1068,7 +1058,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1068
1058
  if (valid === null) {
1069
1059
  editRow.errors.push({
1070
1060
  type: 'error',
1071
- message: `Invalid row validation for ${this.key}`,
1061
+ message: this.t('componentInvalidRowValidation', { componentKey: this.key })
1072
1062
  });
1073
1063
  }
1074
1064
  }
@@ -1145,20 +1135,6 @@ export default class EditGridComponent extends NestedArrayComponent {
1145
1135
  errors.push(...this._errors);
1146
1136
  return false;
1147
1137
  }
1148
- // TODO: this is the only place invalidMessage gets called, and it's not clear why it's needed - we already validate the editGrid
1149
- // component above with super.checkComponentValidity
1150
- const message = this.invalid || this.invalidMessage(data, dirty, false, row, options);
1151
- if (allRowErrors.length && this.root?.submitted && !message) {
1152
- this._errors = this.setCustomValidity(message, dirty);
1153
- errors.push(...this._errors);
1154
- this.root?.showErrors([
1155
- message,
1156
- ]);
1157
- }
1158
- else {
1159
- this._errors = this.setCustomValidity(message, dirty);
1160
- errors.push(...this._errors);
1161
- }
1162
1138
  return superValid;
1163
1139
  }
1164
1140
  setRowInvalid(ref, index) {
@@ -1186,9 +1162,7 @@ export default class EditGridComponent extends NestedArrayComponent {
1186
1162
  }
1187
1163
  if (!Array.isArray(value)) {
1188
1164
  if (typeof value === 'object') {
1189
- value = [
1190
- value,
1191
- ];
1165
+ value = [value];
1192
1166
  }
1193
1167
  else {
1194
1168
  return false;
@@ -13,10 +13,7 @@ export default [
13
13
  input: true,
14
14
  conditional: {
15
15
  json: {
16
- '!==': [
17
- { var: 'data.modal' },
18
- true,
19
- ],
16
+ '!==': [{ var: 'data.modal' }, true],
20
17
  },
21
18
  },
22
19
  },