@formio/js 5.0.0-dev.5703.20a26ed → 5.0.0-dev.5704.50db01f

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 (183) hide show
  1. package/Changelog.md +36 -0
  2. package/dist/formio.embed.js +1 -1
  3. package/dist/formio.embed.min.js +1 -1
  4. package/dist/formio.form.js +55 -35
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +2 -0
  7. package/dist/formio.full.js +61 -41
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +2 -0
  10. package/dist/formio.js +1 -1
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.utils.js +25 -5
  13. package/dist/formio.utils.min.js +1 -1
  14. package/dist/formio.utils.min.js.LICENSE.txt +2 -0
  15. package/lib/cjs/CDN.js +1 -2
  16. package/lib/cjs/Form.d.ts +2 -2
  17. package/lib/cjs/Form.js +11 -5
  18. package/lib/cjs/PDF.js +1 -1
  19. package/lib/cjs/PDFBuilder.js +2 -1
  20. package/lib/cjs/Webform.js +6 -4
  21. package/lib/cjs/WebformBuilder.js +13 -3
  22. package/lib/cjs/Wizard.js +1 -1
  23. package/lib/cjs/components/_classes/component/Component.d.ts +1 -1
  24. package/lib/cjs/components/_classes/component/Component.js +7 -6
  25. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  26. package/lib/cjs/components/_classes/multivalue/Multivalue.js +43 -25
  27. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  28. package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -1
  29. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
  30. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +56 -29
  31. package/lib/cjs/components/address/Address.d.ts +6 -0
  32. package/lib/cjs/components/address/Address.js +7 -1
  33. package/lib/cjs/components/currency/Currency.d.ts +2 -0
  34. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
  35. package/lib/cjs/components/datagrid/DataGrid.js +2 -9
  36. package/lib/cjs/components/datagrid/fixtures/comp11.d.ts +50 -0
  37. package/lib/cjs/components/datagrid/fixtures/comp11.js +55 -0
  38. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  39. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  40. package/lib/cjs/components/datamap/DataMap.js +1 -1
  41. package/lib/cjs/components/day/Day.d.ts +3 -4
  42. package/lib/cjs/components/day/Day.js +31 -10
  43. package/lib/cjs/components/editgrid/EditGrid.js +2 -5
  44. package/lib/cjs/components/editgrid/fixtures/comp17.d.ts +80 -0
  45. package/lib/cjs/components/editgrid/fixtures/comp17.js +99 -0
  46. package/lib/cjs/components/editgrid/fixtures/index.d.ts +8 -7
  47. package/lib/cjs/components/editgrid/fixtures/index.js +3 -1
  48. package/lib/cjs/components/file/File.d.ts +2 -2
  49. package/lib/cjs/components/file/File.js +13 -2
  50. package/lib/cjs/components/file/editForm/File.edit.display.js +1 -1
  51. package/lib/cjs/components/form/editForm/Form.edit.form.js +1 -1
  52. package/lib/cjs/components/form/fixtures/index.d.ts +2 -1
  53. package/lib/cjs/components/form/fixtures/index.js +3 -1
  54. package/lib/cjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
  55. package/lib/cjs/components/form/fixtures/nestedWizardForm.js +765 -0
  56. package/lib/cjs/components/number/Number.d.ts +17 -2
  57. package/lib/cjs/components/number/Number.js +26 -6
  58. package/lib/cjs/components/number/fixtures/comp10.d.ts +18 -0
  59. package/lib/cjs/components/number/fixtures/comp10.js +21 -0
  60. package/lib/cjs/components/number/fixtures/comp9.d.ts +18 -0
  61. package/lib/cjs/components/number/fixtures/comp9.js +21 -0
  62. package/lib/cjs/components/number/fixtures/index.d.ts +3 -1
  63. package/lib/cjs/components/number/fixtures/index.js +5 -1
  64. package/lib/cjs/components/panel/Panel.d.ts +1 -0
  65. package/lib/cjs/components/panel/Panel.js +1 -0
  66. package/lib/cjs/components/radio/Radio.d.ts +2 -18
  67. package/lib/cjs/components/radio/Radio.js +29 -27
  68. package/lib/cjs/components/radio/fixtures/comp12.d.ts +29 -0
  69. package/lib/cjs/components/radio/fixtures/comp12.js +36 -0
  70. package/lib/cjs/components/radio/fixtures/index.d.ts +2 -1
  71. package/lib/cjs/components/radio/fixtures/index.js +3 -1
  72. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +6 -0
  73. package/lib/cjs/components/recaptcha/ReCaptcha.js +6 -0
  74. package/lib/cjs/components/select/Select.d.ts +38 -0
  75. package/lib/cjs/components/select/Select.js +13 -3
  76. package/lib/cjs/components/select/fixtures/comp25.d.ts +59 -0
  77. package/lib/cjs/components/select/fixtures/comp25.js +66 -0
  78. package/lib/cjs/components/select/fixtures/comp26.d.ts +44 -0
  79. package/lib/cjs/components/select/fixtures/comp26.js +59 -0
  80. package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
  81. package/lib/cjs/components/select/fixtures/index.js +5 -1
  82. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +0 -22
  83. package/lib/cjs/components/selectboxes/SelectBoxes.js +12 -9
  84. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  85. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
  86. package/lib/cjs/components/tags/Tags.js +3 -3
  87. package/lib/cjs/components/time/Time.d.ts +2 -2
  88. package/lib/cjs/components/time/Time.form.js +2 -2
  89. package/lib/cjs/components/time/Time.js +3 -7
  90. package/lib/cjs/components/time/fixtures/comp4.d.ts +166 -0
  91. package/lib/cjs/components/time/fixtures/comp4.js +171 -0
  92. package/lib/cjs/components/time/fixtures/index.d.ts +2 -1
  93. package/lib/cjs/components/time/fixtures/index.js +3 -1
  94. package/lib/cjs/templates/Templates.js +1 -1
  95. package/lib/cjs/translations/en.d.ts +1 -0
  96. package/lib/cjs/translations/en.js +1 -0
  97. package/lib/cjs/utils/utils.d.ts +9 -1
  98. package/lib/cjs/utils/utils.js +14 -13
  99. package/lib/mjs/CDN.js +1 -2
  100. package/lib/mjs/Form.d.ts +2 -2
  101. package/lib/mjs/Form.js +11 -5
  102. package/lib/mjs/PDF.js +1 -1
  103. package/lib/mjs/PDFBuilder.js +1 -1
  104. package/lib/mjs/Webform.js +10 -4
  105. package/lib/mjs/WebformBuilder.js +12 -3
  106. package/lib/mjs/Wizard.js +1 -1
  107. package/lib/mjs/components/_classes/component/Component.d.ts +1 -1
  108. package/lib/mjs/components/_classes/component/Component.js +4 -3
  109. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  110. package/lib/mjs/components/_classes/multivalue/Multivalue.js +43 -25
  111. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  112. package/lib/mjs/components/_classes/nested/NestedComponent.js +5 -1
  113. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
  114. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +57 -29
  115. package/lib/mjs/components/address/Address.d.ts +6 -0
  116. package/lib/mjs/components/address/Address.js +10 -1
  117. package/lib/mjs/components/currency/Currency.d.ts +2 -0
  118. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
  119. package/lib/mjs/components/datagrid/DataGrid.js +2 -9
  120. package/lib/mjs/components/datagrid/fixtures/comp11.d.ts +50 -0
  121. package/lib/mjs/components/datagrid/fixtures/comp11.js +53 -0
  122. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  123. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  124. package/lib/mjs/components/datamap/DataMap.js +1 -1
  125. package/lib/mjs/components/day/Day.d.ts +3 -4
  126. package/lib/mjs/components/day/Day.js +30 -10
  127. package/lib/mjs/components/editgrid/EditGrid.js +2 -5
  128. package/lib/mjs/components/editgrid/fixtures/comp17.d.ts +80 -0
  129. package/lib/mjs/components/editgrid/fixtures/comp17.js +97 -0
  130. package/lib/mjs/components/editgrid/fixtures/index.d.ts +8 -7
  131. package/lib/mjs/components/editgrid/fixtures/index.js +2 -1
  132. package/lib/mjs/components/file/File.d.ts +2 -2
  133. package/lib/mjs/components/file/File.js +13 -2
  134. package/lib/mjs/components/file/editForm/File.edit.display.js +1 -1
  135. package/lib/mjs/components/form/editForm/Form.edit.form.js +1 -1
  136. package/lib/mjs/components/form/fixtures/index.d.ts +2 -1
  137. package/lib/mjs/components/form/fixtures/index.js +2 -1
  138. package/lib/mjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
  139. package/lib/mjs/components/form/fixtures/nestedWizardForm.js +763 -0
  140. package/lib/mjs/components/number/Number.d.ts +17 -2
  141. package/lib/mjs/components/number/Number.js +25 -5
  142. package/lib/mjs/components/number/fixtures/comp10.d.ts +18 -0
  143. package/lib/mjs/components/number/fixtures/comp10.js +19 -0
  144. package/lib/mjs/components/number/fixtures/comp9.d.ts +18 -0
  145. package/lib/mjs/components/number/fixtures/comp9.js +19 -0
  146. package/lib/mjs/components/number/fixtures/index.d.ts +3 -1
  147. package/lib/mjs/components/number/fixtures/index.js +3 -1
  148. package/lib/mjs/components/panel/Panel.d.ts +1 -0
  149. package/lib/mjs/components/panel/Panel.js +1 -0
  150. package/lib/mjs/components/radio/Radio.d.ts +2 -18
  151. package/lib/mjs/components/radio/Radio.js +32 -30
  152. package/lib/mjs/components/radio/fixtures/comp12.d.ts +29 -0
  153. package/lib/mjs/components/radio/fixtures/comp12.js +34 -0
  154. package/lib/mjs/components/radio/fixtures/index.d.ts +2 -1
  155. package/lib/mjs/components/radio/fixtures/index.js +2 -1
  156. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +6 -0
  157. package/lib/mjs/components/recaptcha/ReCaptcha.js +9 -0
  158. package/lib/mjs/components/select/Select.d.ts +38 -0
  159. package/lib/mjs/components/select/Select.js +16 -4
  160. package/lib/mjs/components/select/fixtures/comp25.d.ts +59 -0
  161. package/lib/mjs/components/select/fixtures/comp25.js +64 -0
  162. package/lib/mjs/components/select/fixtures/comp26.d.ts +44 -0
  163. package/lib/mjs/components/select/fixtures/comp26.js +57 -0
  164. package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
  165. package/lib/mjs/components/select/fixtures/index.js +3 -1
  166. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +0 -22
  167. package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -9
  168. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  169. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
  170. package/lib/mjs/components/tags/Tags.js +3 -3
  171. package/lib/mjs/components/time/Time.d.ts +2 -2
  172. package/lib/mjs/components/time/Time.form.js +2 -2
  173. package/lib/mjs/components/time/Time.js +3 -13
  174. package/lib/mjs/components/time/fixtures/comp4.d.ts +166 -0
  175. package/lib/mjs/components/time/fixtures/comp4.js +169 -0
  176. package/lib/mjs/components/time/fixtures/index.d.ts +2 -1
  177. package/lib/mjs/components/time/fixtures/index.js +2 -1
  178. package/lib/mjs/templates/Templates.js +1 -1
  179. package/lib/mjs/translations/en.d.ts +1 -0
  180. package/lib/mjs/translations/en.js +1 -0
  181. package/lib/mjs/utils/utils.d.ts +9 -1
  182. package/lib/mjs/utils/utils.js +14 -2
  183. package/package.json +4 -4
@@ -20,6 +20,8 @@
20
20
 
21
21
  /*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */
22
22
 
23
+ /*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
24
+
23
25
  /*! formiojs v5.0.0-rc.59 | https://unpkg.com/formiojs@5.0.0-rc.59/LICENSE.txt */
24
26
 
25
27
  /**
package/lib/cjs/CDN.js CHANGED
@@ -64,8 +64,7 @@ class CDN {
64
64
  url += `/${lib}`;
65
65
  }
66
66
  // Only attach the version if this is the hosted cdn.
67
- if (cdnUrl.includes('form.io') &&
68
- version && version !== 'latest') {
67
+ if (cdnUrl.match(/cdn\.(test-)?form.io/) && version && version !== 'latest') {
69
68
  url += `/${version}`;
70
69
  }
71
70
  return url;
package/lib/cjs/Form.d.ts CHANGED
@@ -398,10 +398,10 @@ export default class Form extends Element {
398
398
  getFormInitOptions(url: string, form: import('@formio/core').Form): object;
399
399
  /**
400
400
  * Sets the form to the JSON schema of a form.
401
- * @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
401
+ * @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
402
402
  * @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
403
403
  */
404
- setForm(formParam: import('@formio/core').Form): Promise<Webform | Wizard | PDF>;
404
+ setForm(formParam: import('@formio/core').Form | string): Promise<Webform | Wizard | PDF>;
405
405
  _form: any;
406
406
  getSubmission(formio: any, opts: any): any;
407
407
  /**
package/lib/cjs/Form.js CHANGED
@@ -65,13 +65,13 @@ class Form extends Element_1.default {
65
65
  else {
66
66
  this.element = null;
67
67
  }
68
+ this.options = formOptions;
69
+ this.options.events = this.events;
68
70
  if (form) {
69
71
  this.setForm(form)
70
72
  .then(() => this.readyResolve(this.instance))
71
73
  .catch(this.readyReject);
72
74
  }
73
- this.options = formOptions;
74
- this.options.events = this.events;
75
75
  this.display = '';
76
76
  }
77
77
  createElement(tag, attrs, children) {
@@ -195,7 +195,7 @@ class Form extends Element_1.default {
195
195
  }
196
196
  /**
197
197
  * Sets the form to the JSON schema of a form.
198
- * @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
198
+ * @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
199
199
  * @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
200
200
  */
201
201
  setForm(formParam) {
@@ -222,8 +222,14 @@ class Form extends Element_1.default {
222
222
  }
223
223
  this.loading = false;
224
224
  this.instance = this.instance || this.create(form.display);
225
- const options = this.getFormInitOptions(formParam, form);
226
- this.instance.setUrl(formParam, options);
225
+ // If we're in builder mode, instance.setUrl is not a function, so just manually set the URL.
226
+ if (this.instance.setUrl) {
227
+ const options = this.getFormInitOptions(formParam, form);
228
+ this.instance.setUrl(formParam, options);
229
+ }
230
+ else {
231
+ this.instance.url = formParam;
232
+ }
227
233
  this.instance.nosubmit = false;
228
234
  this._form = this.instance.form = form;
229
235
  if (submission) {
package/lib/cjs/PDF.js CHANGED
@@ -70,7 +70,7 @@ class PDF extends Webform_1.default {
70
70
  super.destroy(all);
71
71
  }
72
72
  rebuild() {
73
- if (this.attached && this.builderMode && this.component.components) {
73
+ if (this.builderMode && this.component.components) {
74
74
  this.destroyComponents();
75
75
  this.addComponents();
76
76
  return Promise.resolve();
@@ -403,6 +403,7 @@ class PDFBuilder extends WebformBuilder_1.default {
403
403
  return false;
404
404
  }
405
405
  onDragEnd(e) {
406
+ var _a;
406
407
  // IMPORTANT - must retrieve offsets BEFORE disabling the dropzone - offsets will
407
408
  // reflect absolute positioning if accessed after the target element is hidden
408
409
  const iframeRect = this.webform.refs.iframeContainer.getBoundingClientRect();
@@ -435,7 +436,7 @@ class PDFBuilder extends WebformBuilder_1.default {
435
436
  lodash_1.default.merge(schema, info);
436
437
  }
437
438
  // Set a unique key for this component.
438
- builder_1.default.uniquify([this.webform._form], schema);
439
+ builder_1.default.uniquify(((_a = this.webform._form) === null || _a === void 0 ? void 0 : _a.components) || [], schema);
439
440
  this.webform._form.components.push(schema);
440
441
  schema.overlay = {
441
442
  top: layerY ? (layerY - this.itemOffsetY + HEIGHT) : (e.clientY - iframeRect.top - (this.itemOffsetY - HEIGHT) * 2),
@@ -826,7 +826,6 @@ class Webform extends NestedDataComponent_1.default {
826
826
  if (!submission || !submission.data) {
827
827
  submission = {
828
828
  data: {},
829
- metadata: submission.metadata,
830
829
  };
831
830
  }
832
831
  // Metadata needs to be available before setValue
@@ -847,6 +846,9 @@ class Webform extends NestedDataComponent_1.default {
847
846
  return changed;
848
847
  }
849
848
  getValue() {
849
+ if (!this._submission) {
850
+ this._submission = {};
851
+ }
850
852
  if (!this._submission.data) {
851
853
  this._submission.data = {};
852
854
  }
@@ -1130,7 +1132,7 @@ class Webform extends NestedDataComponent_1.default {
1130
1132
  });
1131
1133
  const displayedErrors = [];
1132
1134
  if (errors.length) {
1133
- errors = lodash_1.default.uniqBy(errors, (error) => error.message);
1135
+ errors = lodash_1.default.uniqBy(errors, (error) => { var _a, _b; return [error.message, (_a = error.component) === null || _a === void 0 ? void 0 : _a.id, (_b = error.context) === null || _b === void 0 ? void 0 : _b.path].join(); });
1134
1136
  const createListItem = (message, index) => {
1135
1137
  var _a, _b, _c;
1136
1138
  const err = errors[index];
@@ -1246,10 +1248,10 @@ class Webform extends NestedDataComponent_1.default {
1246
1248
  }
1247
1249
  this.checkData(value.data, flags);
1248
1250
  const shouldValidate = !flags.noValidate ||
1249
- flags.fromIFrame ||
1251
+ flags.fromIframe ||
1250
1252
  (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1251
1253
  const errors = shouldValidate
1252
- ? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: "change" }))
1254
+ ? this.validate(value.data, Object.assign(Object.assign({}, flags), { noValidate: false, process: 'change' }))
1253
1255
  : [];
1254
1256
  value.isValid = errors.length === 0;
1255
1257
  this.loading = false;
@@ -208,7 +208,8 @@ class WebformBuilder extends Component_1.default {
208
208
  params: {
209
209
  type: 'resource',
210
210
  limit: 1000000,
211
- select: '_id,title,name,components'
211
+ select: '_id,title,name,components',
212
+ 'tags__ne': 'noBuilderResource'
212
213
  }
213
214
  };
214
215
  if (this.options && this.options.resourceTag) {
@@ -908,7 +909,11 @@ class WebformBuilder extends Component_1.default {
908
909
  if (form && form.properties) {
909
910
  this.options.properties = form.properties;
910
911
  }
911
- this.keyboardActionsEnabled = lodash_1.default.get(this.options, 'keyboardBuilder', false) || ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.keyboardBuilder);
912
+ let keyboardActionsEnabled = lodash_1.default.get(this.options, 'keyboardBuilder', false) || ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.keyboardBuilder);
913
+ if (typeof keyboardActionsEnabled === 'string') {
914
+ keyboardActionsEnabled = keyboardActionsEnabled === 'true';
915
+ }
916
+ this.keyboardActionsEnabled = keyboardActionsEnabled;
912
917
  const isShowSubmitButton = !this.options.noDefaultSubmitButton
913
918
  && (!form.components.length || !form.components.find(comp => comp.key === 'submit'));
914
919
  // Ensure there is at least a submit button.
@@ -1060,7 +1065,10 @@ class WebformBuilder extends Component_1.default {
1060
1065
  'calculateValue',
1061
1066
  'conditional',
1062
1067
  'customConditional',
1063
- 'id'
1068
+ 'id',
1069
+ 'fields.day.required',
1070
+ 'fields.month.required',
1071
+ 'fields.year.required',
1064
1072
  ]));
1065
1073
  const parentComponent = defaultValueComponent.parent;
1066
1074
  let tabIndex = -1;
@@ -1236,6 +1244,7 @@ class WebformBuilder extends Component_1.default {
1236
1244
  const previewButtons = this.componentEdit.querySelectorAll(`[${this._referenceAttributeName}="previewButton"]`);
1237
1245
  previewButtons.forEach((previewButton) => {
1238
1246
  this.editForm.addEventListener(previewButton, 'click', (event) => {
1247
+ var _a;
1239
1248
  event.preventDefault();
1240
1249
  this.showPreview = !this.showPreview;
1241
1250
  this.editForm.detach();
@@ -1247,6 +1256,7 @@ class WebformBuilder extends Component_1.default {
1247
1256
  helplinks: this.helplinks,
1248
1257
  }));
1249
1258
  this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
1259
+ this.updateComponent((_a = this.editForm.submission.data) !== null && _a !== void 0 ? _a : component);
1250
1260
  this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
1251
1261
  });
1252
1262
  });
package/lib/cjs/Wizard.js CHANGED
@@ -18,7 +18,7 @@ class Wizard extends Webform_1.default {
18
18
  */
19
19
  constructor(elementOrOptions = undefined, _options = undefined) {
20
20
  let element, options;
21
- if (elementOrOptions instanceof HTMLElement || options) {
21
+ if (elementOrOptions instanceof HTMLElement || _options) {
22
22
  element = elementOrOptions;
23
23
  options = _options || {};
24
24
  }
@@ -1076,7 +1076,7 @@ declare class Component extends Element {
1076
1076
  elementInfo(): any;
1077
1077
  autofocus(): void;
1078
1078
  scrollIntoView(element?: any): void;
1079
- focus(index?: number): void;
1079
+ focus(index: any): void;
1080
1080
  /**
1081
1081
  * Get `Formio` instance for working with files
1082
1082
  * @returns {import('@formio/core').Formio} - The Formio instance file service.
@@ -3024,7 +3024,7 @@ class Component extends Element_1.default {
3024
3024
  this.parent.childErrors.push(...errors);
3025
3025
  }
3026
3026
  else {
3027
- lodash_1.default.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
3027
+ lodash_1.default.remove(this.parent.childErrors, (err) => { var _a, _b; return (((_a = err === null || err === void 0 ? void 0 : err.component) === null || _a === void 0 ? void 0 : _a.key) || ((_b = err === null || err === void 0 ? void 0 : err.context) === null || _b === void 0 ? void 0 : _b.key)) === this.component.key; });
3028
3028
  }
3029
3029
  }
3030
3030
  this.showValidationErrors(errors, data, row, flags);
@@ -3040,7 +3040,7 @@ class Component extends Element_1.default {
3040
3040
  this.parent.childErrors.push(...errors);
3041
3041
  }
3042
3042
  else {
3043
- lodash_1.default.remove(this.parent.childErrors, (err) => err.component.key === this.component.key);
3043
+ lodash_1.default.remove(this.parent.childErrors, (err) => { var _a, _b; return (((_a = err === null || err === void 0 ? void 0 : err.component) === null || _a === void 0 ? void 0 : _a.key) || ((_b = err === null || err === void 0 ? void 0 : err.context) === null || _b === void 0 ? void 0 : _b.key)) === this.component.key; });
3044
3044
  }
3045
3045
  }
3046
3046
  return errors.length === 0;
@@ -3463,14 +3463,15 @@ class Component extends Element_1.default {
3463
3463
  const { left, top } = element.getBoundingClientRect();
3464
3464
  window.scrollTo(left + window.scrollX, top + window.scrollY);
3465
3465
  }
3466
- focus(index = (this.refs.input.length - 1)) {
3467
- var _a, _b;
3466
+ focus(index) {
3467
+ var _a, _b, _c;
3468
3468
  if ('beforeFocus' in this.parent) {
3469
3469
  this.parent.beforeFocus(this);
3470
3470
  }
3471
- if ((_a = this.refs.input) === null || _a === void 0 ? void 0 : _a.length) {
3471
+ index = index || ((_a = this.refs.input) === null || _a === void 0 ? void 0 : _a.length) - 1;
3472
+ if ((_b = this.refs.input) === null || _b === void 0 ? void 0 : _b.length) {
3472
3473
  const focusingInput = this.refs.input[index];
3473
- if (((_b = this.component.widget) === null || _b === void 0 ? void 0 : _b.type) === 'calendar') {
3474
+ if (((_c = this.component.widget) === null || _c === void 0 ? void 0 : _c.type) === 'calendar') {
3474
3475
  const sibling = focusingInput.nextSibling;
3475
3476
  if (sibling) {
3476
3477
  sibling.focus();
@@ -1,6 +1,5 @@
1
1
  export default class Multivalue extends Field {
2
2
  get addAnother(): string;
3
- useWrapper(): any;
4
3
  /**
5
4
  * @returns {Field} - The created field.
6
5
  */
@@ -6,12 +6,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Field_1 = __importDefault(require("../field/Field"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  class Multivalue extends Field_1.default {
9
- get dataValue() {
10
- const parent = super.dataValue;
11
- if (!parent && this.component.multiple) {
12
- return [];
9
+ /**
10
+ * Normalize values coming into updateValue.
11
+ * @param {*} value - The value to normalize before setting.
12
+ * @returns {*} - The normalized value.
13
+ */
14
+ normalizeValue(value) {
15
+ if (this.component.multiple) {
16
+ if (Array.isArray(value)) {
17
+ if (value.length === 0) {
18
+ return [this.emptyValue];
19
+ }
20
+ if (this.component.storeas === 'array') {
21
+ return super.normalizeValue([value]);
22
+ }
23
+ return super.normalizeValue(value);
24
+ }
25
+ else {
26
+ return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
27
+ }
28
+ }
29
+ else {
30
+ if (Array.isArray(value) && this.component.storeas !== 'array') {
31
+ if (this.component.storeas === 'string') {
32
+ return super.normalizeValue(value.join(this.delimiter || ''));
33
+ }
34
+ return super.normalizeValue(value[0] || this.emptyValue);
35
+ }
36
+ else {
37
+ return super.normalizeValue(value);
38
+ }
13
39
  }
14
- return parent;
40
+ }
41
+ get dataValue() {
42
+ return super.dataValue;
15
43
  }
16
44
  set dataValue(value) {
17
45
  super.dataValue = value;
@@ -31,30 +59,20 @@ class Multivalue extends Field_1.default {
31
59
  get addAnother() {
32
60
  return this.t(this.component.addAnother || 'Add Another');
33
61
  }
34
- useWrapper() {
35
- return this.component.hasOwnProperty('multiple') && this.component.multiple;
36
- }
37
62
  /**
38
63
  * @returns {Field} - The created field.
39
64
  */
40
65
  render() {
41
- // If single value field.
42
- if (!this.useWrapper()) {
43
- return super.render(`<div ${this._referenceAttributeName}="element">
44
- ${this.renderElement(this.component.type !== 'hidden' ? this.dataValue : '')}
45
- </div>`);
46
- }
47
- // Make sure dataValue is in the correct array format.
48
- let dataValue = this.dataValue;
49
- if (!Array.isArray(dataValue)) {
50
- dataValue = dataValue ? [dataValue] : [];
51
- }
52
- // If multiple value field.
53
- return super.render(this.renderTemplate('multiValueTable', {
54
- rows: dataValue.map(this.renderRow.bind(this)).join(''),
55
- disabled: this.disabled,
56
- addAnother: this.addAnother,
57
- }));
66
+ let dataValue = this.normalizeValue(this.dataValue);
67
+ return this.component.hasOwnProperty('multiple') && this.component.multiple
68
+ ? super.render(this.renderTemplate('multiValueTable', {
69
+ rows: dataValue.map(this.renderRow.bind(this)).join(''),
70
+ disabled: this.disabled,
71
+ addAnother: this.addAnother,
72
+ }))
73
+ : super.render(`<div ${this._referenceAttributeName}="element">
74
+ ${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
75
+ </div>`);
58
76
  }
59
77
  renderElement() {
60
78
  return '';
@@ -211,11 +211,12 @@ export default class NestedComponent extends Field {
211
211
  calculateValue(data: any, flags: any, row: any): any;
212
212
  isLastPage(): boolean;
213
213
  isValid(data: any, dirty: any): any;
214
- validationProcessor({ scope, data, row, instance }: {
214
+ validationProcessor({ scope, data, row, instance, component }: {
215
215
  scope: any;
216
216
  data: any;
217
217
  row: any;
218
218
  instance: any;
219
+ component: any;
219
220
  }, flags: any): void;
220
221
  /**
221
222
  * Perform a validation on all child components of this nested component.
@@ -497,6 +497,7 @@ class NestedComponent extends Field_1.default {
497
497
  header: 'single',
498
498
  collapsed: this.collapsed,
499
499
  [this.nestedKey]: 'single',
500
+ messageContainer: 'single-scope',
500
501
  });
501
502
  let childPromise = Promise.resolve();
502
503
  if (this.refs[this.nestedKey]) {
@@ -681,8 +682,11 @@ class NestedComponent extends Field_1.default {
681
682
  isValid(data, dirty) {
682
683
  return this.getComponents().reduce((valid, comp) => comp.isValid(data, dirty) && valid, super.isValid(data, dirty));
683
684
  }
684
- validationProcessor({ scope, data, row, instance }, flags) {
685
+ validationProcessor({ scope, data, row, instance, component }, flags) {
685
686
  const { dirty } = flags;
687
+ if (this.root.hasExtraPages && this.page !== this.root.page) {
688
+ instance = this.getComponent(component.path);
689
+ }
686
690
  if (!instance) {
687
691
  return;
688
692
  }
@@ -12,6 +12,9 @@ export default class NestedArrayComponent extends NestedDataComponent {
12
12
  hasAddButton(): any;
13
13
  getComponent(path: any, fn: any, originalPath: any): any;
14
14
  everyComponent(fn: any, rowIndex: any, options?: {}): void;
15
+ _getEmailTableHeader(options: any): string;
16
+ _getEmailTableBody(options: any): string;
15
17
  getComponents(rowIndex: any): any;
18
+ removeSubmissionMetadataRow(index: any): void;
16
19
  }
17
20
  import NestedDataComponent from '../nesteddata/NestedDataComponent';
@@ -149,39 +149,60 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
149
149
  }
150
150
  });
151
151
  }
152
+ _getEmailTableHeader(options) {
153
+ let row = '';
154
+ const getHeaderCell = (component) => {
155
+ if (!component.isInputComponent || !component.visible || component.skipInEmail) {
156
+ return '';
157
+ }
158
+ const label = component.label || component.key;
159
+ return `<th style="padding: 5px 10px;">${label}</th>`;
160
+ };
161
+ const components = this.getComponents(0);
162
+ for (const component of components) {
163
+ if (component.isInputComponent) {
164
+ row += getHeaderCell(component);
165
+ }
166
+ else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
167
+ component.everyComponent((comp) => {
168
+ row += getHeaderCell(comp);
169
+ }, options);
170
+ }
171
+ }
172
+ return `<thead><tr>${row}</tr></thead>`;
173
+ }
174
+ _getEmailTableBody(options) {
175
+ const getBodyCell = (component) => {
176
+ if (!component.isInputComponent || !component.visible || component.skipInEmail) {
177
+ return '';
178
+ }
179
+ return `<td style="padding: 5px 10px;">${component.getView(component.dataValue, options)}</td>`;
180
+ };
181
+ const rows = [];
182
+ for (const { components } of this.iteratableRows) {
183
+ let row = '';
184
+ for (const component of components) {
185
+ if (component.isInputComponent) {
186
+ row += getBodyCell(component);
187
+ }
188
+ else if ((0, utils_1.isLayoutComponent)(component) && typeof component.everyComponent === 'function') {
189
+ component.everyComponent((comp) => {
190
+ row += getBodyCell(comp);
191
+ }, options);
192
+ }
193
+ }
194
+ rows.push(`<tr>${row}</tr>`);
195
+ }
196
+ return `<tbody>${rows.join('')}</tbody>`;
197
+ }
152
198
  getValueAsString(value, options) {
153
- var _a;
154
199
  if (options === null || options === void 0 ? void 0 : options.email) {
155
- let result = (`
200
+ return `
156
201
  <table border="1" style="width:100%">
157
- <thead>
158
- <tr>
159
- `);
160
- (_a = this.component.components) === null || _a === void 0 ? void 0 : _a.forEach((component) => {
161
- const label = component.label || component.key;
162
- result += `<th style="padding: 5px 10px;">${label}</th>`;
163
- });
164
- result += (`
165
- </tr>
166
- </thead>
167
- <tbody>
168
- `);
169
- this.iteratableRows.forEach(({ components }) => {
170
- result += '<tr>';
171
- lodash_1.default.each(components, (component) => {
172
- result += '<td style="padding:5px 10px;">';
173
- if (component.isInputComponent && component.visible && !component.skipInEmail) {
174
- result += component.getView(component.dataValue, options);
175
- }
176
- result += '</td>';
177
- });
178
- result += '</tr>';
179
- });
180
- result += (`
181
- </tbody>
202
+ ${this._getEmailTableHeader(options)}
203
+ ${this._getEmailTableBody(options)}
182
204
  </table>
183
- `);
184
- return result;
205
+ `;
185
206
  }
186
207
  if (!value || !value.length) {
187
208
  return '';
@@ -197,5 +218,11 @@ class NestedArrayComponent extends NestedDataComponent_1.default {
197
218
  }
198
219
  return super.getComponents();
199
220
  }
221
+ removeSubmissionMetadataRow(index) {
222
+ const componentMetadata = lodash_1.default.get(this.root, `submission.metadata.selectData.${this.path}`, null);
223
+ if (lodash_1.default.isArray(componentMetadata)) {
224
+ componentMetadata.splice(index, 1);
225
+ }
226
+ }
200
227
  }
201
228
  exports.default = NestedArrayComponent;
@@ -11,6 +11,12 @@ export default class AddressComponent extends ContainerComponent {
11
11
  weight: number;
12
12
  schema: any;
13
13
  };
14
+ static get serverConditionSettings(): {
15
+ operators: string[];
16
+ };
17
+ static get conditionOperatorsSettings(): {
18
+ operators: string[];
19
+ };
14
20
  static get modeSwitcherRef(): string;
15
21
  static get removeValueIconRef(): string;
16
22
  static get searchInputRef(): string;
@@ -97,6 +97,12 @@ class AddressComponent extends Container_1.default {
97
97
  schema: AddressComponent.schema(),
98
98
  };
99
99
  }
100
+ static get serverConditionSettings() {
101
+ return AddressComponent.conditionOperatorsSettings;
102
+ }
103
+ static get conditionOperatorsSettings() {
104
+ return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: ['isEmpty', 'isNotEmpty'] });
105
+ }
100
106
  mergeSchema(component = {}) {
101
107
  let { defaultSchema } = this;
102
108
  if (component.components) {
@@ -188,7 +194,7 @@ class AddressComponent extends Container_1.default {
188
194
  return (this.manualModeEnabled && this.dataValue) ? this.dataValue.address : this.dataValue;
189
195
  }
190
196
  set address(value) {
191
- if (this.manualModeEnabled && !this.isMultiple) {
197
+ if (this.manualModeEnabled && !this.isMultiple && !lodash_1.default.isEqual(value, this.emptyValue)) {
192
198
  this.dataValue.address = value;
193
199
  }
194
200
  else {
@@ -2,6 +2,8 @@ export default class CurrencyComponent extends NumberComponent {
2
2
  constructor(component: any, options: any, data: any);
3
3
  currencyPrefix: any;
4
4
  currencySuffix: any;
5
+ parseNumber(value: any): number;
6
+ parseValue(value: any): string | null;
5
7
  addZerosAndFormatValue(value: any): any;
6
8
  stripPrefixSuffix(value: any): any;
7
9
  }
@@ -59,7 +59,6 @@ export default class DataGridComponent extends NestedArrayComponent {
59
59
  getRows(): {}[];
60
60
  getColumns(): any[];
61
61
  hasHeader(): any;
62
- loadRefs(element: any, refs: any): void;
63
62
  dragula: any;
64
63
  getComponentsContainer(): any;
65
64
  /**
@@ -263,13 +263,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
263
263
  return hasHeader || ((col.label || col.title) && !col.hideLabel);
264
264
  }, false);
265
265
  }
266
- loadRefs(element, refs) {
267
- super.loadRefs(element, refs);
268
- if (refs['messageContainer'] === 'single') {
269
- const container = lodash_1.default.last(element.querySelectorAll(`[${this._referenceAttributeName}=messageContainer]`));
270
- this.refs['messageContainer'] = container || this.refs['messageContainer'];
271
- }
272
- }
273
266
  attach(element) {
274
267
  this.loadRefs(element, {
275
268
  [`${this.datagridKey}-row`]: 'multiple',
@@ -278,7 +271,6 @@ class DataGridComponent extends NestedArrayComponent_1.default {
278
271
  [`${this.datagridKey}-removeRow`]: 'multiple',
279
272
  [`${this.datagridKey}-group-header`]: 'multiple',
280
273
  [this.datagridKey]: 'multiple',
281
- 'messageContainer': 'single'
282
274
  });
283
275
  if (this.allowReorder) {
284
276
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
@@ -444,10 +436,11 @@ class DataGridComponent extends NestedArrayComponent_1.default {
444
436
  }
445
437
  removeRow(index) {
446
438
  const makeEmpty = index === 0 && this.rows.length === 1;
447
- const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
439
+ const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
448
440
  this.splice(index, flags);
449
441
  this.emit('dataGridDeleteRow', { index });
450
442
  const [row] = this.rows.splice(index, 1);
443
+ this.removeSubmissionMetadataRow(index);
451
444
  this.removeRowComponents(row);
452
445
  this.updateRowsComponents(index);
453
446
  this.setValue(this.dataValue, flags);
@@ -0,0 +1,50 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ reorder: boolean;
10
+ addAnotherPosition: string;
11
+ layoutFixed: boolean;
12
+ enableRowGroups: boolean;
13
+ initEmpty: boolean;
14
+ tableView: boolean;
15
+ key: string;
16
+ type: string;
17
+ input: boolean;
18
+ components: {
19
+ label: string;
20
+ widget: string;
21
+ tableView: boolean;
22
+ data: {
23
+ values: {
24
+ label: string;
25
+ value: string;
26
+ }[];
27
+ };
28
+ validateWhenHidden: boolean;
29
+ key: string;
30
+ type: string;
31
+ input: boolean;
32
+ defaultValue: string;
33
+ }[];
34
+ disableOnInvalid?: undefined;
35
+ } | {
36
+ type: string;
37
+ label: string;
38
+ key: string;
39
+ disableOnInvalid: boolean;
40
+ input: boolean;
41
+ tableView: boolean;
42
+ reorder?: undefined;
43
+ addAnotherPosition?: undefined;
44
+ layoutFixed?: undefined;
45
+ enableRowGroups?: undefined;
46
+ initEmpty?: undefined;
47
+ components?: undefined;
48
+ })[];
49
+ }
50
+ export default _default;