@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
@@ -109,13 +109,8 @@ class CurrencyComponent extends Number_1.default {
109
109
  const isNegative = value.includes(negativeValueSymbol) || false;
110
110
  value = this.stripPrefixSuffix(isNegative ? value.replace(negativeValueSymbol, '') : value);
111
111
  if (value.includes(this.decimalSeparator)) {
112
- [
113
- integerPart,
114
- decimalPart,
115
- ] = value.split(this.decimalSeparator);
116
- decimalPartNumbers = [
117
- ...decimalPart.split(''),
118
- ];
112
+ [integerPart, decimalPart] = value.split(this.decimalSeparator);
113
+ decimalPartNumbers = [...decimalPart.split('')];
119
114
  }
120
115
  else {
121
116
  integerPart = value;
@@ -39,9 +39,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
39
39
  this.components = this.components || [];
40
40
  // Add new values based on minLength.
41
41
  this.rows = [];
42
- this.columns = [
43
- ...this.component.components,
44
- ];
42
+ this.columns = [...this.component.components];
45
43
  if (this.initRows || !lodash_1.default.isEqual(this.dataValue, this.emptyValue)) {
46
44
  this.createRows(true);
47
45
  }
@@ -69,11 +67,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
69
67
  return this.builderMode || this.path === 'defaultValue' || !this.initEmpty;
70
68
  }
71
69
  get emptyValue() {
72
- return this.initEmpty
73
- ? []
74
- : [
75
- {},
76
- ];
70
+ return this.initEmpty ? [] : [{}];
77
71
  }
78
72
  get addAnotherPosition() {
79
73
  return lodash_1.default.get(this.component, 'addAnotherPosition', 'bottom');
@@ -91,11 +85,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
91
85
  const isEmptyInit = this.initEmpty;
92
86
  // Ensure we have one and only one row in builder mode.
93
87
  if (isBuilderMode || (isEmptyInit && !this.dataValue.length)) {
94
- return isEmptyInit && !isBuilderMode
95
- ? []
96
- : [
97
- {},
98
- ];
88
+ return isEmptyInit && !isBuilderMode ? [] : [{}];
99
89
  }
100
90
  const value = super.defaultValue;
101
91
  let defaultValue;
@@ -103,9 +93,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
103
93
  defaultValue = value;
104
94
  }
105
95
  else if (value && typeof value === 'object') {
106
- defaultValue = [
107
- value,
108
- ];
96
+ defaultValue = [value];
109
97
  }
110
98
  else {
111
99
  defaultValue = this.emptyValue;
@@ -167,22 +155,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
167
155
  * @returns {Array<T[]>} - The chunked rows
168
156
  */
169
157
  getRowChunks(groups, rows) {
170
- const [, chunks,] = groups.reduce(([startIndex, acc,], size) => {
158
+ const [, chunks] = groups.reduce(([startIndex, acc], size) => {
171
159
  const endIndex = startIndex + size;
172
- return [
173
- endIndex,
174
- [
175
- ...acc,
176
- [
177
- startIndex,
178
- endIndex,
179
- ],
180
- ],
181
- ];
182
- }, [
183
- 0,
184
- [],
185
- ]);
160
+ return [endIndex, [...acc, [startIndex, endIndex]]];
161
+ }, [0, []]);
186
162
  return chunks.map((range) => lodash_1.default.slice(rows, ...range));
187
163
  }
188
164
  /**
@@ -196,9 +172,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
196
172
  const indexes = sizes.reduce((groupIndexes, size) => {
197
173
  const last = groupIndexes[groupIndexes.length - 1];
198
174
  return groupIndexes.concat(last + size);
199
- }, [
200
- 0,
201
- ]);
175
+ }, [0]);
202
176
  return groups.reduce((gidxs, group, idx) => {
203
177
  return Object.assign(Object.assign({}, gidxs), { [indexes[idx]]: group });
204
178
  }, {});
@@ -231,18 +205,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
231
205
  this.dataValue.length > lodash_1.default.get(this.component, 'validate.minLength', 0));
232
206
  }
233
207
  hasTopSubmit() {
234
- return (this.hasAddButton() &&
235
- [
236
- 'top',
237
- 'both',
238
- ].includes(this.addAnotherPosition));
208
+ return this.hasAddButton() && ['top', 'both'].includes(this.addAnotherPosition);
239
209
  }
240
210
  hasBottomSubmit() {
241
- return (this.hasAddButton() &&
242
- [
243
- 'bottom',
244
- 'both',
245
- ].includes(this.addAnotherPosition));
211
+ return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);
246
212
  }
247
213
  get canAddColumn() {
248
214
  return this.builderMode && !this.options.design;
@@ -319,9 +285,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
319
285
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
320
286
  row.dragInfo = { index };
321
287
  });
322
- this.dragula = (0, dragula_1.default)([
323
- this.refs[`${this.datagridKey}-tbody`],
324
- ], {
288
+ this.dragula = (0, dragula_1.default)([this.refs[`${this.datagridKey}-tbody`]], {
325
289
  moves: (_draggedElement, _oldParent, clickedElement) => {
326
290
  const clickedElementKey = clickedElement.getAttribute('data-key');
327
291
  const oldParentKey = _oldParent.getAttribute('data-key');
@@ -365,9 +329,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
365
329
  this.rows.forEach((row, rowIndex) => {
366
330
  let columnIndex = 0;
367
331
  columns.forEach((col) => {
368
- this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [
369
- this.rows[rowIndex][col.key],
370
- ], this.getComponentsContainer());
332
+ this.attachComponents(this.refs[this.datagridKey][rowIndex * rowLength + columnIndex], [this.rows[rowIndex][col.key]], this.getComponentsContainer());
371
333
  columnIndex++;
372
334
  });
373
335
  });
@@ -396,7 +358,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
396
358
  }
397
359
  onReorder(element, _target, _source, sibling) {
398
360
  if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
399
- console.warn('There is no Drag Info available for either dragged or sibling element');
361
+ console.warn(this.t('noDragInfoError'));
400
362
  return;
401
363
  }
402
364
  const oldPosition = element.dragInfo.index;
@@ -490,10 +452,15 @@ class DataGridComponent extends NestedArrayComponent_1.default {
490
452
  }
491
453
  removeRow(index) {
492
454
  const makeEmpty = index === 0 && this.rows.length === 1;
493
- const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
455
+ const flags = {
456
+ isReordered: !makeEmpty,
457
+ resetValue: makeEmpty,
458
+ modified: true,
459
+ noPristineChangeOnModified: true,
460
+ };
494
461
  this.splice(index, flags);
495
462
  this.emit('dataGridDeleteRow', { index });
496
- const [row,] = this.rows.splice(index, 1);
463
+ const [row] = this.rows.splice(index, 1);
497
464
  this.removeSubmissionMetadataRow(index);
498
465
  this.removeRowComponents(row);
499
466
  this.updateRowsComponents(index);
@@ -613,10 +580,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
613
580
  !!visibility[key] ||
614
581
  (col.checkConditions(data, flags, dataValue[rowIndex]) && col.type !== 'hidden');
615
582
  if (col.component.logic && firstRowCheck) {
616
- const compIndex = lodash_1.default.findIndex(this.columns, [
617
- 'key',
618
- key,
619
- ]);
583
+ const compIndex = lodash_1.default.findIndex(this.columns, ['key', key]);
620
584
  const equalColumns = lodash_1.default.isEqualWith(this.columns[compIndex], col.component, (col1, col2, key) => {
621
585
  // Don't compare columns by their auto-generated ids.
622
586
  if (key === 'id') {
@@ -660,15 +624,11 @@ class DataGridComponent extends NestedArrayComponent_1.default {
660
624
  }
661
625
  if (!Array.isArray(value)) {
662
626
  if (typeof value === 'object') {
663
- value = [
664
- value,
665
- ];
627
+ value = [value];
666
628
  }
667
629
  else {
668
630
  this.createRows();
669
- value = [
670
- {},
671
- ];
631
+ value = [{}];
672
632
  }
673
633
  }
674
634
  // Make sure we always have at least one row.
@@ -50,9 +50,7 @@ class DataMapComponent extends DataGrid_1.default {
50
50
  return lodash_1.default.omit(schema, 'components');
51
51
  }
52
52
  static savedValueTypes(schema) {
53
- return ((0, utils_1.getComponentSavedTypes)(schema) || [
54
- utils_1.componentValueTypes.object,
55
- ]);
53
+ return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.object];
56
54
  }
57
55
  constructor(component, options, data) {
58
56
  super(component, options, data);
@@ -106,9 +104,7 @@ class DataMapComponent extends DataGrid_1.default {
106
104
  getRowValues() {
107
105
  const dataValue = this.dataValue;
108
106
  if (this.builderMode) {
109
- return [
110
- dataValue,
111
- ];
107
+ return [dataValue];
112
108
  }
113
109
  if (lodash_1.default.isEmpty(dataValue)) {
114
110
  return [];
@@ -125,7 +121,7 @@ class DataMapComponent extends DataGrid_1.default {
125
121
  return this.rows.map((row) => {
126
122
  return {
127
123
  components: row,
128
- data: lodash_1.default.mapValues(row, (comp) => comp.dataValue)
124
+ data: lodash_1.default.mapValues(row, (comp) => comp.dataValue),
129
125
  };
130
126
  });
131
127
  }
@@ -146,15 +142,7 @@ class DataMapComponent extends DataGrid_1.default {
146
142
  const valueSchema = Object.assign({}, this.component.valueComponent);
147
143
  keySchema.hideLabel = false;
148
144
  valueSchema.hideLabel = false;
149
- return this.component.keyBeforeValue
150
- ? [
151
- keySchema,
152
- valueSchema,
153
- ]
154
- : [
155
- valueSchema,
156
- keySchema,
157
- ];
145
+ return this.component.keyBeforeValue ? [keySchema, valueSchema] : [valueSchema, keySchema];
158
146
  }
159
147
  getRowKey(rowIndex) {
160
148
  const keys = Object.keys(this.dataValue);
@@ -75,9 +75,7 @@ class DateTimeComponent extends Input_1.default {
75
75
  }
76
76
  static savedValueTypes(schema) {
77
77
  schema = schema || {};
78
- return ((0, utils_2.getComponentSavedTypes)(schema) || [
79
- utils_2.componentValueTypes.date,
80
- ]);
78
+ return (0, utils_2.getComponentSavedTypes)(schema) || [utils_2.componentValueTypes.date];
81
79
  }
82
80
  constructor(component, options, data) {
83
81
  super(component, options, data);
@@ -177,9 +175,7 @@ class DateTimeComponent extends Input_1.default {
177
175
  let format = utils_1.default.convertFormatToMoment(this.component.format);
178
176
  format += format.match(/z$/) ? '' : ' z';
179
177
  const timezone = this.timezone;
180
- const useTimezoneAwareFormat = value &&
181
- timezone &&
182
- (this.options.pdf || (options === null || options === void 0 ? void 0 : options.email));
178
+ const useTimezoneAwareFormat = value && timezone && (this.options.pdf || (options === null || options === void 0 ? void 0 : options.email));
183
179
  if (useTimezoneAwareFormat) {
184
180
  if (Array.isArray(value) && this.component.multiple) {
185
181
  return value
@@ -36,10 +36,7 @@ exports.default = [
36
36
  template: '<span>{{ item.label }}</span>',
37
37
  conditional: {
38
38
  json: {
39
- '===': [
40
- { var: 'data.displayInTimezone' },
41
- 'location',
42
- ],
39
+ '===': [{ var: 'data.displayInTimezone' }, 'location'],
43
40
  },
44
41
  },
45
42
  },
@@ -59,9 +59,7 @@ class DayComponent extends Field_1.default {
59
59
  }
60
60
  static savedValueTypes(schema) {
61
61
  schema = schema || {};
62
- return ((0, utils_1.getComponentSavedTypes)(schema) || [
63
- utils_1.componentValueTypes.string,
64
- ]);
62
+ return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
65
63
  }
66
64
  constructor(component, options, data) {
67
65
  if (options && !options.inFormBuilder && !options.building) {
@@ -166,9 +164,7 @@ class DayComponent extends Field_1.default {
166
164
  };
167
165
  }
168
166
  get days() {
169
- const days = [
170
- { value: '', label: lodash_1.default.get(this.component, 'fields.day.placeholder', '') },
171
- ];
167
+ const days = [{ value: '', label: lodash_1.default.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 @@ class DayComponent extends Field_1.default {
182
178
  {
183
179
  value: '',
184
180
  label: lodash_1.default.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 @@ class DayComponent extends Field_1.default {
200
196
  return months;
201
197
  }
202
198
  get years() {
203
- const years = [
204
- { value: '', label: lodash_1.default.get(this.component, 'fields.year.placeholder', '') },
205
- ];
199
+ const years = [{ value: '', label: lodash_1.default.get(this.component, 'fields.year.placeholder', '') }];
206
200
  const minYears = lodash_1.default.get(this.component, 'fields.year.minYear', 1900) || 1900;
207
201
  const maxYears = lodash_1.default.get(this.component, 'fields.year.maxYear', 2030) || 2030;
208
202
  for (let x = minYears; x <= maxYears; x++) {
@@ -215,18 +209,10 @@ class DayComponent extends Field_1.default {
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 @@ class DayComponent extends Field_1.default {
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 @@ class DayComponent extends Field_1.default {
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 @@ class DayComponent extends Field_1.default {
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 @@ class DayComponent extends Field_1.default {
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;
@@ -533,17 +495,7 @@ class DayComponent extends Field_1.default {
533
495
  var _a;
534
496
  let defaults = [], day, month, year;
535
497
  // Map positions to identifiers to get default values for each part of day
536
- const [DAY, MONTH, YEAR,] = this.component.dayFirst
537
- ? [
538
- 0,
539
- 1,
540
- 2,
541
- ]
542
- : [
543
- 1,
544
- 0,
545
- 2,
546
- ];
498
+ const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
547
499
  const defaultValue = value || this.component.defaultValue;
548
500
  if (defaultValue) {
549
501
  defaults = defaultValue.split('/').map((x) => parseInt(x, 10));
@@ -689,17 +641,7 @@ class DayComponent extends Field_1.default {
689
641
  if (!value) {
690
642
  return true;
691
643
  }
692
- const [DAY, MONTH, YEAR,] = this.component.dayFirst
693
- ? [
694
- 0,
695
- 1,
696
- 2,
697
- ]
698
- : [
699
- 1,
700
- 0,
701
- 2,
702
- ];
644
+ const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
703
645
  const values = value.split('/');
704
646
  if (values.length < 3) {
705
647
  return true;
@@ -43,9 +43,7 @@ exports.default = [
43
43
  if (data.defaultValue) {
44
44
  const defaultValueParts = data.defaultValue.split('/');
45
45
  if (!data.fields.day.hide && defaultValueParts.length !== 3) {
46
- const newDefaultValue = [
47
- '00',
48
- ];
46
+ const newDefaultValue = ['00'];
49
47
  if (!data.fields.month.hide) {
50
48
  data.dayFirst
51
49
  ? newDefaultValue.push(defaultValueParts[0])
@@ -43,9 +43,7 @@ exports.default = [
43
43
  if (data.defaultValue) {
44
44
  const defaultValueParts = data.defaultValue.split('/');
45
45
  if (!data.fields.month.hide && defaultValueParts.length !== 3) {
46
- const newDefaultValue = [
47
- '00',
48
- ];
46
+ const newDefaultValue = ['00'];
49
47
  if (!data.fields.day.hide) {
50
48
  data.dayFirst
51
49
  ? 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;
@@ -120,10 +120,10 @@ class EditGridComponent extends NestedArrayComponent_1.default {
120
120
  }
121
121
  get defaultDialogTemplate() {
122
122
  return `
123
- <h3 ${this._referenceAttributeName}="dialogHeader">${this.t('Do you want to clear data?')}</h3>
123
+ <h3 ${this._referenceAttributeName}="dialogHeader">${this.t('wantToClearData')}</h3>
124
124
  <div style="display:flex; justify-content: flex-end;">
125
- <button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('Cancel')}">${this.t('Cancel')}</button>
126
- <button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('Yes, delete it')}">${this.t('Yes, delete it')}</button>
125
+ <button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('cancel')}">${this.t('cancel')}</button>
126
+ <button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('yesDelete')}">${this.t('yesDelete')}</button>
127
127
  </div>
128
128
  `;
129
129
  }
@@ -258,6 +258,12 @@ class EditGridComponent extends NestedArrayComponent_1.default {
258
258
  this.fullMode &&
259
259
  this.dataValue.length > lodash_1.default.get(this.component, 'validate.minLength', 0));
260
260
  }
261
+ checkData(data, flags, row) {
262
+ super.checkData(data, flags, row);
263
+ if (this.type === 'editgrid' && (flags === null || flags === void 0 ? void 0 : flags.fromSubmission)) {
264
+ return this.redraw();
265
+ }
266
+ }
261
267
  init() {
262
268
  if (this.builderMode) {
263
269
  this.editRows = [];
@@ -307,19 +313,11 @@ class EditGridComponent extends NestedArrayComponent_1.default {
307
313
  });
308
314
  }
309
315
  isOpen(editRow) {
310
- return [
311
- EditRowState.New,
312
- EditRowState.Editing,
313
- EditRowState.Viewing,
314
- ].includes(editRow.state);
316
+ return [EditRowState.New, EditRowState.Editing, EditRowState.Viewing].includes(editRow.state);
315
317
  }
316
318
  isComponentVisibleInSomeRow(component) {
317
319
  const rows = this.editRows;
318
- const savedStates = [
319
- EditRowState.Saved,
320
- EditRowState.Editing,
321
- EditRowState.Draft,
322
- ];
320
+ const savedStates = [EditRowState.Saved, EditRowState.Editing, EditRowState.Draft];
323
321
  const savedRows = rows.filter((row) => lodash_1.default.includes(savedStates, row.state));
324
322
  this.visibleInHeader = this.visibleInHeader || [];
325
323
  const changeVisibleInHeader = (component, isVisible) => {
@@ -340,9 +338,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
340
338
  comp.checkConditions();
341
339
  });
342
340
  const isVisible = checkComponent ? checkComponent.visible : true;
343
- [
344
- ...this.components,
345
- ].forEach((comp) => this.removeComponent(comp, this.components));
341
+ [...this.components].forEach((comp) => this.removeComponent(comp, this.components));
346
342
  changeVisibleInHeader(component, isVisible);
347
343
  return isVisible;
348
344
  }
@@ -483,10 +479,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
483
479
  const elements = row.getElementsByClassName(className);
484
480
  Array.prototype.forEach.call(elements, (element) => {
485
481
  if (this.options.pdf &&
486
- lodash_1.default.intersection(element.classList, [
487
- 'editRow',
488
- 'removeRow',
489
- ]).length) {
482
+ lodash_1.default.intersection(element.classList, ['editRow', 'removeRow']).length) {
490
483
  element.style.display = 'none';
491
484
  }
492
485
  else {
@@ -542,7 +535,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
542
535
  flattenedComponents,
543
536
  displayValue: (component) => this.displayComponentValue(component),
544
537
  isVisibleInRow: (component) => this.isComponentVisibleInRow(component, flattenedComponents),
545
- getView: (component, data) => {
538
+ getView: (component, _data) => {
546
539
  var _a, _b;
547
540
  const instance = flattenedComponents[component.key];
548
541
  const view = instance ? instance.getView(instance.dataValue) : '';
@@ -1056,10 +1049,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1056
1049
  editRow.errors =
1057
1050
  this.component.modal || this.component.rowDrafts
1058
1051
  ? errors
1059
- : errors.filter((err) => lodash_1.default.find(this.visibleErrors, [
1060
- 'component.id',
1061
- err.component.id,
1062
- ]));
1052
+ : errors.filter((err) => lodash_1.default.find(this.visibleErrors, ['component.id', err.component.id]));
1063
1053
  }
1064
1054
  // TODO: this is essentially running its own custom validation and should be moved into a validation rule
1065
1055
  if (this.component.validate && this.component.validate.row) {
@@ -1077,7 +1067,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1077
1067
  if (valid === null) {
1078
1068
  editRow.errors.push({
1079
1069
  type: 'error',
1080
- message: `Invalid row validation for ${this.key}`,
1070
+ message: this.t('componentInvalidRowValidation', { componentKey: this.key })
1081
1071
  });
1082
1072
  }
1083
1073
  }
@@ -1107,7 +1097,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1107
1097
  return true;
1108
1098
  }
1109
1099
  checkComponentValidity(data, dirty, row, options = {}, errors = []) {
1110
- var _a, _b, _c;
1100
+ var _a;
1111
1101
  const { silentCheck, fromSubmission } = options;
1112
1102
  const superValid = super.checkComponentValidity(data, dirty, row, options, errors);
1113
1103
  // If super tells us that component invalid and there is no need to update alerts, just return false
@@ -1155,20 +1145,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1155
1145
  errors.push(...this._errors);
1156
1146
  return false;
1157
1147
  }
1158
- // TODO: this is the only place invalidMessage gets called, and it's not clear why it's needed - we already validate the editGrid
1159
- // component above with super.checkComponentValidity
1160
- const message = this.invalid || this.invalidMessage(data, dirty, false, row, options);
1161
- if (allRowErrors.length && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted) && !message) {
1162
- this._errors = this.setCustomValidity(message, dirty);
1163
- errors.push(...this._errors);
1164
- (_c = this.root) === null || _c === void 0 ? void 0 : _c.showErrors([
1165
- message,
1166
- ]);
1167
- }
1168
- else {
1169
- this._errors = this.setCustomValidity(message, dirty);
1170
- errors.push(...this._errors);
1171
- }
1172
1148
  return superValid;
1173
1149
  }
1174
1150
  setRowInvalid(ref, index) {
@@ -1196,9 +1172,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1196
1172
  }
1197
1173
  if (!Array.isArray(value)) {
1198
1174
  if (typeof value === 'object') {
1199
- value = [
1200
- value,
1201
- ];
1175
+ value = [value];
1202
1176
  }
1203
1177
  else {
1204
1178
  return false;
@@ -15,10 +15,7 @@ exports.default = [
15
15
  input: true,
16
16
  conditional: {
17
17
  json: {
18
- '!==': [
19
- { var: 'data.modal' },
20
- true,
21
- ],
18
+ '!==': [{ var: 'data.modal' }, true],
22
19
  },
23
20
  },
24
21
  },