@formio/js 5.1.0-dev.6056.ba6432d → 5.1.0-dev.6059.845a6e3

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 (196) hide show
  1. package/Changelog.md +13 -131
  2. package/README.md +1 -28
  3. package/dist/formio.builder.css +17 -19
  4. package/dist/formio.builder.min.css +1 -1
  5. package/dist/formio.embed.js +1 -1
  6. package/dist/formio.embed.min.js +1 -1
  7. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  8. package/dist/formio.form.css +17 -19
  9. package/dist/formio.form.js +176 -102
  10. package/dist/formio.form.min.css +1 -1
  11. package/dist/formio.form.min.js +1 -1
  12. package/dist/formio.form.min.js.LICENSE.txt +3 -3
  13. package/dist/formio.full.css +17 -19
  14. package/dist/formio.full.js +101 -123
  15. package/dist/formio.full.min.css +2 -2
  16. package/dist/formio.full.min.js +1 -1
  17. package/dist/formio.full.min.js.LICENSE.txt +3 -3
  18. package/dist/formio.js +10 -10
  19. package/dist/formio.min.js +1 -1
  20. package/dist/formio.min.js.LICENSE.txt +1 -1
  21. package/dist/formio.utils.js +3 -3
  22. package/dist/formio.utils.min.js +1 -1
  23. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  24. package/lib/cjs/CDN.d.ts +1 -1
  25. package/lib/cjs/CDN.js +2 -2
  26. package/lib/cjs/Embed.js +1 -1
  27. package/lib/cjs/Form.d.ts +6 -4
  28. package/lib/cjs/Form.js +8 -16
  29. package/lib/cjs/Formio.js +1 -1
  30. package/lib/cjs/PDFBuilder.js +4 -4
  31. package/lib/cjs/Webform.d.ts +13 -16
  32. package/lib/cjs/Webform.js +148 -162
  33. package/lib/cjs/WebformBuilder.js +28 -17
  34. package/lib/cjs/Wizard.js +1 -1
  35. package/lib/cjs/WizardBuilder.js +2 -15
  36. package/lib/cjs/components/Components.d.ts +0 -3
  37. package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
  38. package/lib/cjs/components/_classes/component/Component.js +11 -38
  39. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  40. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  41. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -13
  42. package/lib/cjs/components/_classes/component/editForm/utils.d.ts +0 -1
  43. package/lib/cjs/components/_classes/component/editForm/utils.js +0 -3
  44. package/lib/cjs/components/_classes/input/Input.js +1 -23
  45. package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
  46. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  47. package/lib/cjs/components/_classes/multivalue/Multivalue.js +3 -10
  48. package/lib/cjs/components/_classes/nested/NestedComponent.form.js +0 -13
  49. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
  50. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -52
  51. package/lib/cjs/components/address/Address.js +1 -1
  52. package/lib/cjs/components/button/Button.js +6 -6
  53. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  54. package/lib/cjs/components/checkbox/Checkbox.js +2 -2
  55. package/lib/cjs/components/content/editForm/Content.edit.display.js +0 -8
  56. package/lib/cjs/components/currency/editForm/Currency.edit.display.js +0 -12
  57. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -2
  58. package/lib/cjs/components/datagrid/DataGrid.js +26 -41
  59. package/lib/cjs/components/day/Day.js +7 -9
  60. package/lib/cjs/components/day/editForm/Day.edit.display.js +0 -8
  61. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
  62. package/lib/cjs/components/editgrid/EditGrid.js +8 -26
  63. package/lib/cjs/components/email/editForm/Email.edit.display.js +0 -12
  64. package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +0 -8
  65. package/lib/cjs/components/file/File.d.ts +1 -1
  66. package/lib/cjs/components/file/File.js +17 -23
  67. package/lib/cjs/components/form/Form.d.ts +1 -1
  68. package/lib/cjs/components/form/Form.js +5 -9
  69. package/lib/cjs/components/form/editForm/Form.edit.form.js +3 -3
  70. package/lib/cjs/components/hidden/Hidden.d.ts +1 -0
  71. package/lib/cjs/components/hidden/Hidden.js +1 -1
  72. package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +0 -8
  73. package/lib/cjs/components/html/editForm/HTML.edit.display.js +0 -8
  74. package/lib/cjs/components/number/Number.js +5 -12
  75. package/lib/cjs/components/number/editForm/Number.edit.display.js +0 -12
  76. package/lib/cjs/components/password/editForm/Password.edit.display.js +1 -13
  77. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +1 -9
  78. package/lib/cjs/components/radio/Radio.js +0 -10
  79. package/lib/cjs/components/recaptcha/ReCaptcha.js +2 -2
  80. package/lib/cjs/components/select/Select.d.ts +1 -0
  81. package/lib/cjs/components/select/Select.js +33 -12
  82. package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  83. package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -3
  84. package/lib/cjs/components/selectboxes/SelectBoxes.js +2 -2
  85. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  86. package/lib/cjs/components/signature/Signature.js +3 -5
  87. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
  88. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +1 -0
  89. package/lib/cjs/components/survey/Survey.js +2 -2
  90. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +0 -8
  91. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  92. package/lib/cjs/components/tags/Tags.js +2 -2
  93. package/lib/cjs/components/textarea/TextArea.js +6 -6
  94. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +0 -12
  95. package/lib/cjs/components/url/editForm/Url.edit.display.js +0 -12
  96. package/lib/cjs/components/well/editForm/Well.edit.display.js +0 -8
  97. package/lib/cjs/formio.form.js +0 -5
  98. package/lib/cjs/providers/storage/googleDrive.js +2 -3
  99. package/lib/cjs/providers/storage/s3.js +3 -3
  100. package/lib/cjs/providers/storage/xhr.d.ts +0 -1
  101. package/lib/cjs/providers/storage/xhr.js +1 -6
  102. package/lib/cjs/translations/en.d.ts +81 -234
  103. package/lib/cjs/translations/en.js +81 -8
  104. package/lib/cjs/utils/ChoicesWrapper.d.ts +25 -4
  105. package/lib/cjs/utils/ChoicesWrapper.js +124 -47
  106. package/lib/cjs/utils/formUtils.d.ts +2 -2
  107. package/lib/cjs/utils/i18n.d.ts +2 -5
  108. package/lib/cjs/utils/i18n.js +5 -32
  109. package/lib/cjs/widgets/CalendarWidget.js +27 -27
  110. package/lib/mjs/CDN.d.ts +1 -1
  111. package/lib/mjs/CDN.js +2 -2
  112. package/lib/mjs/Embed.js +1 -1
  113. package/lib/mjs/Form.d.ts +6 -4
  114. package/lib/mjs/Form.js +9 -17
  115. package/lib/mjs/Formio.js +1 -1
  116. package/lib/mjs/PDFBuilder.js +4 -4
  117. package/lib/mjs/Webform.d.ts +13 -16
  118. package/lib/mjs/Webform.js +158 -171
  119. package/lib/mjs/WebformBuilder.js +28 -17
  120. package/lib/mjs/Wizard.js +1 -1
  121. package/lib/mjs/WizardBuilder.js +2 -15
  122. package/lib/mjs/components/Components.d.ts +0 -3
  123. package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
  124. package/lib/mjs/components/_classes/component/Component.js +11 -27
  125. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  126. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  127. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -13
  128. package/lib/mjs/components/_classes/component/editForm/utils.d.ts +0 -1
  129. package/lib/mjs/components/_classes/component/editForm/utils.js +0 -3
  130. package/lib/mjs/components/_classes/input/Input.js +1 -22
  131. package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
  132. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  133. package/lib/mjs/components/_classes/multivalue/Multivalue.js +3 -10
  134. package/lib/mjs/components/_classes/nested/NestedComponent.form.js +0 -13
  135. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
  136. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -53
  137. package/lib/mjs/components/address/Address.js +1 -1
  138. package/lib/mjs/components/button/Button.js +6 -6
  139. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  140. package/lib/mjs/components/checkbox/Checkbox.js +2 -2
  141. package/lib/mjs/components/content/editForm/Content.edit.display.js +0 -8
  142. package/lib/mjs/components/currency/editForm/Currency.edit.display.js +0 -12
  143. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -2
  144. package/lib/mjs/components/datagrid/DataGrid.js +26 -41
  145. package/lib/mjs/components/day/Day.js +7 -9
  146. package/lib/mjs/components/day/editForm/Day.edit.display.js +0 -8
  147. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
  148. package/lib/mjs/components/editgrid/EditGrid.js +7 -25
  149. package/lib/mjs/components/email/editForm/Email.edit.display.js +0 -12
  150. package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +0 -8
  151. package/lib/mjs/components/file/File.d.ts +1 -1
  152. package/lib/mjs/components/file/File.js +17 -23
  153. package/lib/mjs/components/form/Form.d.ts +1 -1
  154. package/lib/mjs/components/form/Form.js +5 -8
  155. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -3
  156. package/lib/mjs/components/hidden/Hidden.d.ts +1 -0
  157. package/lib/mjs/components/hidden/Hidden.js +1 -1
  158. package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +0 -8
  159. package/lib/mjs/components/html/editForm/HTML.edit.display.js +0 -8
  160. package/lib/mjs/components/number/Number.js +5 -12
  161. package/lib/mjs/components/number/editForm/Number.edit.display.js +0 -12
  162. package/lib/mjs/components/password/editForm/Password.edit.display.js +1 -13
  163. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +1 -9
  164. package/lib/mjs/components/radio/Radio.js +0 -10
  165. package/lib/mjs/components/recaptcha/ReCaptcha.js +2 -2
  166. package/lib/mjs/components/select/Select.d.ts +1 -0
  167. package/lib/mjs/components/select/Select.js +34 -14
  168. package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  169. package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -3
  170. package/lib/mjs/components/selectboxes/SelectBoxes.js +2 -2
  171. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  172. package/lib/mjs/components/signature/Signature.js +3 -5
  173. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
  174. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +1 -0
  175. package/lib/mjs/components/survey/Survey.js +2 -2
  176. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +0 -8
  177. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  178. package/lib/mjs/components/tags/Tags.js +2 -2
  179. package/lib/mjs/components/textarea/TextArea.js +6 -6
  180. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +0 -12
  181. package/lib/mjs/components/url/editForm/Url.edit.display.js +0 -12
  182. package/lib/mjs/components/well/editForm/Well.edit.display.js +0 -8
  183. package/lib/mjs/formio.form.js +0 -5
  184. package/lib/mjs/providers/storage/googleDrive.js +2 -3
  185. package/lib/mjs/providers/storage/s3.js +3 -3
  186. package/lib/mjs/providers/storage/xhr.d.ts +0 -1
  187. package/lib/mjs/providers/storage/xhr.js +1 -6
  188. package/lib/mjs/translations/en.d.ts +81 -234
  189. package/lib/mjs/translations/en.js +1 -87
  190. package/lib/mjs/utils/ChoicesWrapper.d.ts +25 -4
  191. package/lib/mjs/utils/ChoicesWrapper.js +119 -26
  192. package/lib/mjs/utils/formUtils.d.ts +2 -2
  193. package/lib/mjs/utils/i18n.d.ts +2 -5
  194. package/lib/mjs/utils/i18n.js +5 -32
  195. package/lib/mjs/widgets/CalendarWidget.js +27 -27
  196. package/package.json +11 -27
@@ -22,7 +22,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
22
22
  return this.iteratableRows[component.rowIndex].data;
23
23
  }
24
24
  get iteratableRows() {
25
- throw new Error(this.t('iteratableRowsError'));
25
+ throw new Error('Getter #iteratableRows() is not implemented');
26
26
  }
27
27
  get rowIndex() {
28
28
  return this._rowIndex;
@@ -65,7 +65,7 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
65
65
  return this.validateComponents([this.component], data, flags);
66
66
  }
67
67
  checkRow(...args) {
68
- console.log(this.t('checkRowDeprecation'));
68
+ console.log('Deprecation Warning: checkRow method has been replaced with processRow');
69
69
  return this.processRow.call(this, ...args);
70
70
  }
71
71
  processRow(method, data, opts, row, components, silentCheck) {
@@ -112,60 +112,39 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
112
112
  }
113
113
  });
114
114
  }
115
- _getEmailTableHeader(options) {
116
- let row = '';
117
- const getHeaderCell = (component) => {
118
- if (!component.isInputComponent || !component.visible || component.skipInEmail) {
119
- return '';
120
- }
121
- const label = component.label || component.key;
122
- return `<th style="padding: 5px 10px;">${this.t(label, { _userInput: true })}</th>`;
123
- };
124
- const components = this.getComponents(0);
125
- for (const component of components) {
126
- if (component.isInputComponent) {
127
- row += getHeaderCell(component);
128
- }
129
- else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
130
- component.everyComponent((comp) => {
131
- row += getHeaderCell(comp);
132
- }, options);
133
- }
134
- }
135
- return `<thead><tr>${row}</tr></thead>`;
136
- }
137
- _getEmailTableBody(options) {
138
- const getBodyCell = (component) => {
139
- if (!component.isInputComponent || !component.visible || component.skipInEmail) {
140
- return '';
141
- }
142
- return `<td style="padding: 5px 10px;">${component.getView(component.dataValue, options)}</td>`;
143
- };
144
- const rows = [];
145
- for (const { components } of this.iteratableRows) {
146
- let row = '';
147
- for (const component of components) {
148
- if (component.isInputComponent) {
149
- row += getBodyCell(component);
150
- }
151
- else if ((0, utils_2.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
152
- component.everyComponent((comp) => {
153
- row += getBodyCell(comp);
154
- }, options);
155
- }
156
- }
157
- rows.push(`<tr>${row}</tr>`);
158
- }
159
- return `<tbody>${rows.join('')}</tbody>`;
160
- }
161
115
  getValueAsString(value, options) {
116
+ var _a;
162
117
  if (options === null || options === void 0 ? void 0 : options.email) {
163
- return `
118
+ let result = (`
164
119
  <table border="1" style="width:100%">
165
- ${this._getEmailTableHeader(options)}
166
- ${this._getEmailTableBody(options)}
120
+ <thead>
121
+ <tr>
122
+ `);
123
+ (_a = this.component.components) === null || _a === void 0 ? void 0 : _a.forEach((component) => {
124
+ const label = component.label || component.key;
125
+ result += `<th style="padding: 5px 10px;">${label}</th>`;
126
+ });
127
+ result += (`
128
+ </tr>
129
+ </thead>
130
+ <tbody>
131
+ `);
132
+ this.iteratableRows.forEach(({ components }) => {
133
+ result += '<tr>';
134
+ lodash_1.default.each(components, (component) => {
135
+ result += '<td style="padding:5px 10px;">';
136
+ if (component.isInputComponent && component.visible && !component.skipInEmail) {
137
+ result += component.getView(component.dataValue, options);
138
+ }
139
+ result += '</td>';
140
+ });
141
+ result += '</tr>';
142
+ });
143
+ result += (`
144
+ </tbody>
167
145
  </table>
168
- `;
146
+ `);
147
+ return result;
169
148
  }
170
149
  if (!value || !value.length) {
171
150
  return '';
@@ -321,7 +321,7 @@ class AddressComponent extends Container_1.default {
321
321
  return !this.isMultiple && (this.builderMode || this.manualModeEnabled);
322
322
  }
323
323
  get addAnother() {
324
- return this.t(this.component.addAnother || 'addAnother');
324
+ return this.t(this.component.addAnother || 'Add Another');
325
325
  }
326
326
  renderElement(value) {
327
327
  return this.renderTemplate(this.templateName, {
@@ -342,17 +342,17 @@ class ButtonComponent extends Field_1.default {
342
342
  break;
343
343
  case 'oauth':
344
344
  if (this.root === this) {
345
- console.warn(this.t('noOAuthBtn'));
345
+ console.warn('You must add the OAuth button to a form for it to function properly');
346
346
  return;
347
347
  }
348
348
  // Display Alert if OAuth config is missing
349
349
  if (!this.oauthConfig) {
350
- this.root.setAlert('danger', this.t('noOAuthConfiguration'));
350
+ this.root.setAlert('danger', 'OAuth not configured. You must configure oauth for your project before it will work.');
351
351
  break;
352
352
  }
353
353
  // Display Alert if oAuth has an error is missing
354
354
  if (this.oauthConfig.error) {
355
- this.root.setAlert('danger', `${this.t('oAuthErrorsTitle')} ${this.t(this.oauthConfig.error)}`);
355
+ this.root.setAlert('danger', `The Following Error Has Occured ${this.oauthConfig.error}`);
356
356
  break;
357
357
  }
358
358
  this.openOauth(this.oauthConfig);
@@ -361,7 +361,7 @@ class ButtonComponent extends Field_1.default {
361
361
  }
362
362
  openOauth(settings) {
363
363
  if (!this.root.formio) {
364
- console.warn(this.t('noOAuthFormUrl'));
364
+ console.warn('You must attach a Form API url to your form in order to use OAuth buttons.');
365
365
  return;
366
366
  }
367
367
  /*eslint-disable camelcase */
@@ -409,7 +409,7 @@ class ButtonComponent extends Field_1.default {
409
409
  }
410
410
  // TODO: check for error response here
411
411
  if (settings.state !== params.state) {
412
- this.root.setAlert('danger', this.t('oAuthStateError'));
412
+ this.root.setAlert('danger', 'OAuth state does not match. Please try logging in again.');
413
413
  return;
414
414
  }
415
415
  // Depending on where the settings came from, submit to either the submission endpoint (old) or oauth endpoint (new).
@@ -442,7 +442,7 @@ class ButtonComponent extends Field_1.default {
442
442
  }
443
443
  catch (error) {
444
444
  if (error.name !== 'SecurityError' && (error.name !== 'Error' || error.message !== 'Permission denied')) {
445
- this.root.setAlert('danger', this.t(`${error.message || error}`));
445
+ this.root.setAlert('danger', error.message || error);
446
446
  }
447
447
  }
448
448
  if (!popup || popup.closed || popup.closed === undefined) {
@@ -43,7 +43,7 @@ export default class CheckBoxComponent extends Field {
43
43
  attach(element: any): Promise<void>;
44
44
  input: any;
45
45
  detach(element: any): void;
46
- get emptyValue(): false | "";
46
+ get emptyValue(): false | null;
47
47
  getValueAt(index: any): any;
48
48
  get checked(): boolean;
49
49
  setCheckedState(value: any): any;
@@ -117,7 +117,7 @@ class CheckBoxComponent extends Field_1.default {
117
117
  super.detach();
118
118
  }
119
119
  get emptyValue() {
120
- return this.component.inputType === 'radio' ? '' : false;
120
+ return this.component.inputType === 'radio' ? null : false;
121
121
  }
122
122
  isEmpty(value = this.dataValue) {
123
123
  return super.isEmpty(value) || value === false;
@@ -188,7 +188,7 @@ class CheckBoxComponent extends Field_1.default {
188
188
  if (lodash_1.default.isUndefined(value) && this.inDataTable) {
189
189
  return '';
190
190
  }
191
- return this.t(hasValue ? 'yes' : 'no');
191
+ return this.t(hasValue ? 'Yes' : 'No');
192
192
  }
193
193
  updateValue(value, flags) {
194
194
  // If this is a radio and is alredy checked, uncheck it.
@@ -5,14 +5,6 @@ exports.default = [
5
5
  key: 'labelPosition',
6
6
  ignore: true
7
7
  },
8
- {
9
- key: 'labelWidth',
10
- ignore: true
11
- },
12
- {
13
- key: 'labelMargin',
14
- ignore: true
15
- },
16
8
  {
17
9
  key: 'placeholder',
18
10
  ignore: true
@@ -9,18 +9,6 @@ exports.default = [
9
9
  key: 'allowMultipleMasks',
10
10
  ignore: true
11
11
  },
12
- {
13
- key: 'inputMasks',
14
- ignore: true
15
- },
16
- {
17
- key: 'widget.type',
18
- ignore: true
19
- },
20
- {
21
- key: 'widget',
22
- ignore: true
23
- },
24
12
  {
25
13
  key: 'showWordCount',
26
14
  ignore: true
@@ -12,7 +12,6 @@ export default class DataGridComponent extends NestedArrayComponent {
12
12
  tabIndex: number;
13
13
  rows: any[] | undefined;
14
14
  columns: any[] | undefined;
15
- dragulaReady: Promise<any> | undefined;
16
15
  visibleColumns: {} | undefined;
17
16
  set dataValue(value: any[]);
18
17
  get dataValue(): any[];
@@ -71,7 +70,6 @@ export default class DataGridComponent extends NestedArrayComponent {
71
70
  */
72
71
  reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
73
72
  onReorder(element: any, _target: any, _source: any, sibling: any): void;
74
- onCloned(el: any, original: any): void;
75
73
  focusOnNewRowElement(row: any): void;
76
74
  addRow(): void;
77
75
  updateComponentsRowIndex(components: any, rowIndex: any): void;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
8
8
  const utils_1 = require("../../utils/utils");
9
+ const dragula_1 = __importDefault(require("dragula"));
9
10
  class DataGridComponent extends NestedArrayComponent_1.default {
10
11
  static schema(...extend) {
11
12
  return NestedArrayComponent_1.default.schema({
@@ -42,9 +43,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
42
43
  if (this.initRows || !lodash_1.default.isEqual(this.dataValue, this.emptyValue)) {
43
44
  this.createRows(true);
44
45
  }
45
- if (this.allowReorder) {
46
- this.dragulaReady = this.getDragula();
47
- }
48
46
  this.visibleColumns = {};
49
47
  this.prevHasAddButton = this.hasAddButton();
50
48
  this.checkColumns();
@@ -275,25 +273,31 @@ class DataGridComponent extends NestedArrayComponent_1.default {
275
273
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
276
274
  row.dragInfo = { index };
277
275
  });
278
- this.dragulaReady.then((dragula) => {
279
- // The drop event may call redraw twice which calls attach twice and because this block of code is asynchronous
280
- // BOTH redraws may be called before this block of code runs (which causes this block of code to run twice sequentially).
281
- // This causes two dragula() calls on the same container which breaks dragula. To fix this the return value must
282
- // be saved in this.dragula and have its container contents reset if it exists
283
- if (this.dragula && this.dragula.containers) {
284
- this.dragula.containers = [];
276
+ this.dragula = (0, dragula_1.default)([this.refs[`${this.datagridKey}-tbody`]], {
277
+ moves: (_draggedElement, _oldParent, clickedElement) => {
278
+ const clickedElementKey = clickedElement.getAttribute('data-key');
279
+ const oldParentKey = _oldParent.getAttribute('data-key');
280
+ //Check if the clicked button belongs to that container, if false, it belongs to the nested container
281
+ if (oldParentKey === clickedElementKey) {
282
+ return clickedElement.classList.contains('formio-drag-button');
283
+ }
285
284
  }
286
- this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
287
- moves: (_draggedElement, _oldParent, clickedElement) => {
288
- const clickedElementKey = clickedElement.getAttribute('data-key');
289
- const oldParentKey = _oldParent.getAttribute('data-key');
290
- //Check if the clicked button belongs to that container, if false, it belongs to the nested container
291
- if (oldParentKey === clickedElementKey) {
292
- return clickedElement.classList.contains('formio-drag-button');
285
+ }).on('drop', this.onReorder.bind(this));
286
+ this.dragula.on('cloned', (el, original) => {
287
+ if (el && el.children && original && original.children) {
288
+ lodash_1.default.each(original.children, (child, index) => {
289
+ const styles = getComputedStyle(child, null);
290
+ if (styles.cssText !== '') {
291
+ el.children[index].style.cssText = styles.cssText;
293
292
  }
294
- }
295
- }).on('drop', this.onReorder.bind(this))
296
- .on('cloned', this.onCloned.bind(this));
293
+ else {
294
+ const cssText = Object.values(styles).reduce((css, propertyName) => {
295
+ return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
296
+ }, '');
297
+ el.children[index].style.cssText = cssText;
298
+ }
299
+ });
300
+ }
297
301
  });
298
302
  }
299
303
  this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
@@ -342,7 +346,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
342
346
  }
343
347
  onReorder(element, _target, _source, sibling) {
344
348
  if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
345
- console.warn(this.t('noDragInfoError'));
349
+ console.warn('There is no Drag Info available for either dragged or sibling element');
346
350
  return;
347
351
  }
348
352
  const oldPosition = element.dragInfo.index;
@@ -353,29 +357,10 @@ class DataGridComponent extends NestedArrayComponent_1.default {
353
357
  this.reorderValues(dataValue, oldPosition, newPosition, movedBelow);
354
358
  //reorder select data
355
359
  this.reorderValues(lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, []), oldPosition, newPosition, movedBelow);
356
- // When components are reordered we need to set the dataGrid and form pristine properties to false
357
- this.root.pristine = false;
358
- this.pristine = false;
359
360
  //need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
360
361
  this.setValue(dataValue, { isReordered: true });
361
362
  this.rebuild();
362
363
  }
363
- onCloned(el, original) {
364
- if (el && el.children && original && original.children) {
365
- lodash_1.default.each(original.children, (child, index) => {
366
- const styles = getComputedStyle(child, null);
367
- if (styles.cssText !== '') {
368
- el.children[index].style.cssText = styles.cssText;
369
- }
370
- else {
371
- const cssText = Object.values(styles).reduce((css, propertyName) => {
372
- return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
373
- }, '');
374
- el.children[index].style.cssText = cssText;
375
- }
376
- });
377
- }
378
- }
379
364
  focusOnNewRowElement(row) {
380
365
  Object.keys(row).find((key) => {
381
366
  const element = row[key].element;
@@ -434,7 +419,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
434
419
  }
435
420
  removeRow(index) {
436
421
  const makeEmpty = index === 0 && this.rows.length === 1;
437
- const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
422
+ const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
438
423
  this.splice(index, flags);
439
424
  this.emit('dataGridDeleteRow', { index });
440
425
  const [row] = this.rows.splice(index, 1);
@@ -53,13 +53,11 @@ class DayComponent extends Field_1.default {
53
53
  return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
54
54
  }
55
55
  constructor(component, options, data) {
56
- if (!options.inFormBuilder && !options.building) {
57
- if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
- component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
59
- }
60
- if (component.minDate && component.minDate.indexOf('moment(') === -1) {
61
- component.minDate = (0, moment_1.default)(component.minDate, 'YYYY-MM-DD').toISOString();
62
- }
56
+ if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
57
+ component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
58
+ }
59
+ if (component.minDate && component.minDate.indexOf('moment(') === -1) {
60
+ component.minDate = (0, moment_1.default)(component.minDate, 'YYYY-MM-DD').toISOString();
63
61
  }
64
62
  super(component, options, data);
65
63
  }
@@ -176,7 +174,7 @@ class DayComponent extends Field_1.default {
176
174
  this._months = [
177
175
  {
178
176
  value: '',
179
- label: lodash_1.default.get(this.component, 'fields.month.placeholder') || (this.hideInputLabels ? this.t('month') : '')
177
+ label: lodash_1.default.get(this.component, 'fields.month.placeholder') || (this.hideInputLabels ? this.t('Month') : '')
180
178
  },
181
179
  { value: 1, label: 'January' },
182
180
  { value: 2, label: 'February' },
@@ -270,7 +268,7 @@ class DayComponent extends Field_1.default {
270
268
  this.saveCaretPosition(element, name);
271
269
  }
272
270
  catch (err) {
273
- console.warn(this.t('caretPositionSavingError'), err);
271
+ console.warn('An error occurred while trying to save caret position', err);
274
272
  }
275
273
  this.updateValue(null, {
276
274
  modified: true,
@@ -5,14 +5,6 @@ exports.default = [
5
5
  key: 'labelPosition',
6
6
  ignore: true
7
7
  },
8
- {
9
- key: 'labelWidth',
10
- ignore: true
11
- },
12
- {
13
- key: 'labelMargin',
14
- ignore: true
15
- },
16
8
  {
17
9
  weight: 15,
18
10
  type: 'checkbox',
@@ -43,7 +43,7 @@ export default class EditGridComponent extends NestedArrayComponent {
43
43
  get defaultValue(): any[];
44
44
  hasRemoveButtons(): boolean;
45
45
  editRows: any;
46
- checkRowVariableTypeComponents(editRow: any, rowIndex: any): boolean;
46
+ checkRowVariableTypeComponents(editRow: any, rowIndex: any): void;
47
47
  setVariableTypeComponents(): void;
48
48
  variableTypeComponentsIndexes: any[] | undefined;
49
49
  isOpen(editRow: any): boolean;
@@ -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('wantToClearData')}</h3>
123
+ <h3 ${this._referenceAttributeName}="dialogHeader">${this.t('Do you want to clear data?')}</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('yesDelete')}">${this.t('yesDelete')}</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('Yes, delete it')}">${this.t('Yes, delete it')}</button>
127
127
  </div>
128
128
  `;
129
129
  }
@@ -294,15 +294,12 @@ class EditGridComponent extends NestedArrayComponent_1.default {
294
294
  }
295
295
  checkRowVariableTypeComponents(editRow, rowIndex) {
296
296
  const rowComponents = editRow.components;
297
- let typeChanged = false;
298
297
  if (lodash_1.default.some(this.variableTypeComponentsIndexes, (compIndex) => {
299
298
  const variableTypeComp = rowComponents[compIndex];
300
299
  return variableTypeComp.type !== variableTypeComp.component.type;
301
300
  })) {
302
301
  editRow.components = this.createRowComponents(editRow.data, rowIndex, true);
303
- typeChanged = true;
304
302
  }
305
- return typeChanged;
306
303
  }
307
304
  setVariableTypeComponents() {
308
305
  //set components which type is changing within a row (e.g.,by mergeComponentSchema action)
@@ -672,11 +669,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
672
669
  }
673
670
  },
674
671
  }, this.component.saveRow || 'Save'));
675
- this.emit('editGridOpenModal', {
676
- component: this.component,
677
- row: editRow,
678
- instance: this,
679
- });
680
672
  return this.attachComponents(modalContent, components);
681
673
  }
682
674
  showDialog(rowIndex) {
@@ -734,11 +726,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
734
726
  editRow.data = dataSnapshot;
735
727
  this.restoreRowContext(editRow);
736
728
  }
737
- this.emit('editGridEditRow', {
738
- component: this.component,
739
- row: editRow,
740
- instance: this,
741
- });
742
729
  if (this.component.modal) {
743
730
  return this.addRowModal(rowIndex);
744
731
  }
@@ -947,10 +934,8 @@ class EditGridComponent extends NestedArrayComponent_1.default {
947
934
  this.validateRow(editRow, false, false);
948
935
  }
949
936
  if (this.variableTypeComponentsIndexes.length) {
950
- const typeChanged = this.checkRowVariableTypeComponents(editRow, rowIndex);
951
- if (typeChanged) {
952
- this.redraw();
953
- }
937
+ this.checkRowVariableTypeComponents(editRow, rowIndex);
938
+ this.redraw();
954
939
  }
955
940
  };
956
941
  const comp = this.createComponent(lodash_1.default.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);
@@ -985,7 +970,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
985
970
  dirty;
986
971
  }
987
972
  validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {
988
- var _a, _b;
973
+ var _a;
989
974
  editRow.errors = [];
990
975
  if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {
991
976
  const silentCheck = forceSilentCheck === false ? false : ((this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck);
@@ -1030,16 +1015,13 @@ class EditGridComponent extends NestedArrayComponent_1.default {
1030
1015
  if (valid === null) {
1031
1016
  editRow.errors.push({
1032
1017
  type: 'error',
1033
- message: this.t('componentInvalidRowValidation', { componentKey: this.key })
1018
+ message: `Invalid row validation for ${this.key}`
1034
1019
  });
1035
1020
  }
1036
1021
  }
1037
- if (editRow.alerts && (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted))) {
1022
+ if (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {
1038
1023
  this.showRowErrorAlerts(editRow, editRow.errors);
1039
1024
  }
1040
- else if ((_b = editRow.errors) === null || _b === void 0 ? void 0 : _b.length) {
1041
- this.setCustomValidity(editRow.errors, dirty);
1042
- }
1043
1025
  return editRow.errors;
1044
1026
  }
1045
1027
  showRowErrorAlerts(editRow, errors) {
@@ -9,18 +9,6 @@ exports.default = [
9
9
  key: 'allowMultipleMasks',
10
10
  ignore: true,
11
11
  },
12
- {
13
- key: 'inputMasks',
14
- ignore: true
15
- },
16
- {
17
- key: 'widget.type',
18
- ignore: true
19
- },
20
- {
21
- key: 'widget',
22
- ignore: true
23
- },
24
12
  {
25
13
  key: 'showWordCount',
26
14
  ignore: true
@@ -5,14 +5,6 @@ exports.default = [
5
5
  key: 'labelPosition',
6
6
  ignore: true
7
7
  },
8
- {
9
- key: 'labelWidth',
10
- ignore: true
11
- },
12
- {
13
- key: 'labelMargin',
14
- ignore: true
15
- },
16
8
  {
17
9
  key: 'placeholder',
18
10
  ignore: true
@@ -33,7 +33,7 @@ export default class FileComponent extends Field {
33
33
  get dataReady(): Promise<any>;
34
34
  loadImage(fileInfo: any): any;
35
35
  get emptyValue(): never[];
36
- getValueAsString(value: any, options: any): any;
36
+ getValueAsString(value: any): any;
37
37
  get defaultValue(): any[];
38
38
  get hasTypes(): any;
39
39
  _fileBrowseHidden: any;