@formio/js 5.0.0-dev.5704.492ccdf → 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 (193) hide show
  1. package/Changelog.md +47 -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 -131
  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.d.ts +1 -0
  16. package/lib/cjs/CDN.js +2 -2
  17. package/lib/cjs/Form.d.ts +2 -2
  18. package/lib/cjs/Form.js +11 -5
  19. package/lib/cjs/PDF.js +1 -1
  20. package/lib/cjs/PDFBuilder.js +2 -1
  21. package/lib/cjs/Webform.js +3 -6
  22. package/lib/cjs/WebformBuilder.js +13 -3
  23. package/lib/cjs/Wizard.js +1 -1
  24. package/lib/cjs/components/_classes/component/Component.d.ts +2 -1
  25. package/lib/cjs/components/_classes/component/Component.js +25 -6
  26. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  27. package/lib/cjs/components/_classes/multivalue/Multivalue.js +43 -25
  28. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  29. package/lib/cjs/components/_classes/nested/NestedComponent.js +5 -1
  30. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
  31. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +56 -29
  32. package/lib/cjs/components/address/Address.d.ts +6 -0
  33. package/lib/cjs/components/address/Address.js +7 -1
  34. package/lib/cjs/components/currency/Currency.d.ts +2 -0
  35. package/lib/cjs/components/datagrid/DataGrid.d.ts +2 -1
  36. package/lib/cjs/components/datagrid/DataGrid.js +40 -35
  37. package/lib/cjs/components/datagrid/fixtures/comp11.d.ts +50 -0
  38. package/lib/cjs/components/datagrid/fixtures/comp11.js +55 -0
  39. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  40. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  41. package/lib/cjs/components/datamap/DataMap.js +2 -2
  42. package/lib/cjs/components/day/Day.d.ts +3 -4
  43. package/lib/cjs/components/day/Day.js +31 -10
  44. package/lib/cjs/components/editgrid/EditGrid.js +14 -6
  45. package/lib/cjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
  46. package/lib/cjs/components/editgrid/fixtures/comp-test-events.js +54 -0
  47. package/lib/cjs/components/editgrid/fixtures/comp16.d.ts +52 -0
  48. package/lib/cjs/components/editgrid/fixtures/comp16.js +71 -0
  49. package/lib/cjs/components/editgrid/fixtures/comp17.d.ts +80 -0
  50. package/lib/cjs/components/editgrid/fixtures/comp17.js +99 -0
  51. package/lib/cjs/components/editgrid/fixtures/index.d.ts +10 -7
  52. package/lib/cjs/components/editgrid/fixtures/index.js +7 -1
  53. package/lib/cjs/components/file/File.d.ts +2 -2
  54. package/lib/cjs/components/file/File.js +13 -2
  55. package/lib/cjs/components/file/editForm/File.edit.display.js +1 -1
  56. package/lib/cjs/components/form/editForm/Form.edit.form.js +1 -1
  57. package/lib/cjs/components/form/fixtures/index.d.ts +2 -1
  58. package/lib/cjs/components/form/fixtures/index.js +3 -1
  59. package/lib/cjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
  60. package/lib/cjs/components/form/fixtures/nestedWizardForm.js +765 -0
  61. package/lib/cjs/components/number/Number.d.ts +17 -2
  62. package/lib/cjs/components/number/Number.js +26 -6
  63. package/lib/cjs/components/number/fixtures/comp10.d.ts +18 -0
  64. package/lib/cjs/components/number/fixtures/comp10.js +21 -0
  65. package/lib/cjs/components/number/fixtures/comp9.d.ts +18 -0
  66. package/lib/cjs/components/number/fixtures/comp9.js +21 -0
  67. package/lib/cjs/components/number/fixtures/index.d.ts +3 -1
  68. package/lib/cjs/components/number/fixtures/index.js +5 -1
  69. package/lib/cjs/components/panel/Panel.d.ts +1 -0
  70. package/lib/cjs/components/panel/Panel.js +1 -0
  71. package/lib/cjs/components/radio/Radio.d.ts +2 -18
  72. package/lib/cjs/components/radio/Radio.js +29 -27
  73. package/lib/cjs/components/radio/fixtures/comp12.d.ts +29 -0
  74. package/lib/cjs/components/radio/fixtures/comp12.js +36 -0
  75. package/lib/cjs/components/radio/fixtures/index.d.ts +2 -1
  76. package/lib/cjs/components/radio/fixtures/index.js +3 -1
  77. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +6 -0
  78. package/lib/cjs/components/recaptcha/ReCaptcha.js +6 -0
  79. package/lib/cjs/components/select/Select.d.ts +38 -0
  80. package/lib/cjs/components/select/Select.js +13 -3
  81. package/lib/cjs/components/select/fixtures/comp25.d.ts +59 -0
  82. package/lib/cjs/components/select/fixtures/comp25.js +66 -0
  83. package/lib/cjs/components/select/fixtures/comp26.d.ts +44 -0
  84. package/lib/cjs/components/select/fixtures/comp26.js +59 -0
  85. package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
  86. package/lib/cjs/components/select/fixtures/index.js +5 -1
  87. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +0 -22
  88. package/lib/cjs/components/selectboxes/SelectBoxes.js +12 -9
  89. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  90. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
  91. package/lib/cjs/components/tags/Tags.js +3 -3
  92. package/lib/cjs/components/time/Time.d.ts +2 -2
  93. package/lib/cjs/components/time/Time.form.js +2 -2
  94. package/lib/cjs/components/time/Time.js +3 -7
  95. package/lib/cjs/components/time/fixtures/comp4.d.ts +166 -0
  96. package/lib/cjs/components/time/fixtures/comp4.js +171 -0
  97. package/lib/cjs/components/time/fixtures/index.d.ts +2 -1
  98. package/lib/cjs/components/time/fixtures/index.js +3 -1
  99. package/lib/cjs/templates/Templates.js +1 -1
  100. package/lib/cjs/translations/en.d.ts +1 -0
  101. package/lib/cjs/translations/en.js +1 -0
  102. package/lib/cjs/utils/utils.d.ts +9 -1
  103. package/lib/cjs/utils/utils.js +14 -13
  104. package/lib/mjs/CDN.d.ts +1 -0
  105. package/lib/mjs/CDN.js +2 -2
  106. package/lib/mjs/Form.d.ts +2 -2
  107. package/lib/mjs/Form.js +11 -5
  108. package/lib/mjs/PDF.js +1 -1
  109. package/lib/mjs/PDFBuilder.js +1 -1
  110. package/lib/mjs/Webform.js +7 -6
  111. package/lib/mjs/WebformBuilder.js +12 -3
  112. package/lib/mjs/Wizard.js +1 -1
  113. package/lib/mjs/components/_classes/component/Component.d.ts +2 -1
  114. package/lib/mjs/components/_classes/component/Component.js +11 -3
  115. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
  116. package/lib/mjs/components/_classes/multivalue/Multivalue.js +43 -25
  117. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -1
  118. package/lib/mjs/components/_classes/nested/NestedComponent.js +5 -1
  119. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +3 -0
  120. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +57 -29
  121. package/lib/mjs/components/address/Address.d.ts +6 -0
  122. package/lib/mjs/components/address/Address.js +10 -1
  123. package/lib/mjs/components/currency/Currency.d.ts +2 -0
  124. package/lib/mjs/components/datagrid/DataGrid.d.ts +2 -1
  125. package/lib/mjs/components/datagrid/DataGrid.js +39 -34
  126. package/lib/mjs/components/datagrid/fixtures/comp11.d.ts +50 -0
  127. package/lib/mjs/components/datagrid/fixtures/comp11.js +53 -0
  128. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  129. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  130. package/lib/mjs/components/datamap/DataMap.js +2 -2
  131. package/lib/mjs/components/day/Day.d.ts +3 -4
  132. package/lib/mjs/components/day/Day.js +30 -10
  133. package/lib/mjs/components/editgrid/EditGrid.js +14 -6
  134. package/lib/mjs/components/editgrid/fixtures/comp-test-events.d.ts +54 -0
  135. package/lib/mjs/components/editgrid/fixtures/comp-test-events.js +52 -0
  136. package/lib/mjs/components/editgrid/fixtures/comp16.d.ts +52 -0
  137. package/lib/mjs/components/editgrid/fixtures/comp16.js +69 -0
  138. package/lib/mjs/components/editgrid/fixtures/comp17.d.ts +80 -0
  139. package/lib/mjs/components/editgrid/fixtures/comp17.js +97 -0
  140. package/lib/mjs/components/editgrid/fixtures/index.d.ts +10 -7
  141. package/lib/mjs/components/editgrid/fixtures/index.js +4 -1
  142. package/lib/mjs/components/file/File.d.ts +2 -2
  143. package/lib/mjs/components/file/File.js +13 -2
  144. package/lib/mjs/components/file/editForm/File.edit.display.js +1 -1
  145. package/lib/mjs/components/form/editForm/Form.edit.form.js +1 -1
  146. package/lib/mjs/components/form/fixtures/index.d.ts +2 -1
  147. package/lib/mjs/components/form/fixtures/index.js +2 -1
  148. package/lib/mjs/components/form/fixtures/nestedWizardForm.d.ts +771 -0
  149. package/lib/mjs/components/form/fixtures/nestedWizardForm.js +763 -0
  150. package/lib/mjs/components/number/Number.d.ts +17 -2
  151. package/lib/mjs/components/number/Number.js +25 -5
  152. package/lib/mjs/components/number/fixtures/comp10.d.ts +18 -0
  153. package/lib/mjs/components/number/fixtures/comp10.js +19 -0
  154. package/lib/mjs/components/number/fixtures/comp9.d.ts +18 -0
  155. package/lib/mjs/components/number/fixtures/comp9.js +19 -0
  156. package/lib/mjs/components/number/fixtures/index.d.ts +3 -1
  157. package/lib/mjs/components/number/fixtures/index.js +3 -1
  158. package/lib/mjs/components/panel/Panel.d.ts +1 -0
  159. package/lib/mjs/components/panel/Panel.js +1 -0
  160. package/lib/mjs/components/radio/Radio.d.ts +2 -18
  161. package/lib/mjs/components/radio/Radio.js +32 -30
  162. package/lib/mjs/components/radio/fixtures/comp12.d.ts +29 -0
  163. package/lib/mjs/components/radio/fixtures/comp12.js +34 -0
  164. package/lib/mjs/components/radio/fixtures/index.d.ts +2 -1
  165. package/lib/mjs/components/radio/fixtures/index.js +2 -1
  166. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +6 -0
  167. package/lib/mjs/components/recaptcha/ReCaptcha.js +9 -0
  168. package/lib/mjs/components/select/Select.d.ts +38 -0
  169. package/lib/mjs/components/select/Select.js +16 -4
  170. package/lib/mjs/components/select/fixtures/comp25.d.ts +59 -0
  171. package/lib/mjs/components/select/fixtures/comp25.js +64 -0
  172. package/lib/mjs/components/select/fixtures/comp26.d.ts +44 -0
  173. package/lib/mjs/components/select/fixtures/comp26.js +57 -0
  174. package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
  175. package/lib/mjs/components/select/fixtures/index.js +3 -1
  176. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +0 -22
  177. package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -9
  178. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  179. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
  180. package/lib/mjs/components/tags/Tags.js +3 -3
  181. package/lib/mjs/components/time/Time.d.ts +2 -2
  182. package/lib/mjs/components/time/Time.form.js +2 -2
  183. package/lib/mjs/components/time/Time.js +3 -13
  184. package/lib/mjs/components/time/fixtures/comp4.d.ts +166 -0
  185. package/lib/mjs/components/time/fixtures/comp4.js +169 -0
  186. package/lib/mjs/components/time/fixtures/index.d.ts +2 -1
  187. package/lib/mjs/components/time/fixtures/index.js +2 -1
  188. package/lib/mjs/templates/Templates.js +1 -1
  189. package/lib/mjs/translations/en.d.ts +1 -0
  190. package/lib/mjs/translations/en.js +1 -0
  191. package/lib/mjs/utils/utils.d.ts +9 -1
  192. package/lib/mjs/utils/utils.js +14 -2
  193. 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.d.ts CHANGED
@@ -13,6 +13,7 @@ declare class CDN {
13
13
  bootswatch: string;
14
14
  'bootstrap-icons': string;
15
15
  ckeditor: string;
16
+ dragula: string;
16
17
  flatpickr: string;
17
18
  'flatpickr-formio': string;
18
19
  'font-awesome': string;
package/lib/cjs/CDN.js CHANGED
@@ -17,6 +17,7 @@ class CDN {
17
17
  'bootswatch': '5.3.3',
18
18
  'bootstrap-icons': '1.11.1',
19
19
  'ckeditor': '19.0.0',
20
+ 'dragula': '3.7.3',
20
21
  'flatpickr': '4.6.8',
21
22
  'flatpickr-formio': '4.6.13-formio.3',
22
23
  'font-awesome': '4.7.0',
@@ -63,8 +64,7 @@ class CDN {
63
64
  url += `/${lib}`;
64
65
  }
65
66
  // Only attach the version if this is the hosted cdn.
66
- if (cdnUrl.includes('form.io') &&
67
- version && version !== 'latest') {
67
+ if (cdnUrl.match(/cdn\.(test-)?form.io/) && version && version !== 'latest') {
68
68
  url += `/${version}`;
69
69
  }
70
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),
@@ -17,7 +17,6 @@ const formUtils_1 = require("./utils/formUtils");
17
17
  if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
18
18
  window.global = window;
19
19
  }
20
- const dragula_1 = __importDefault(require("dragula"));
21
20
  // Initialize the available forms.
22
21
  Formio_1.Formio.forms = {};
23
22
  // Allow people to register components.
@@ -314,7 +313,6 @@ class Webform extends NestedDataComponent_1.default {
314
313
  // Ensure the root is set to this component.
315
314
  this.root = this;
316
315
  this.localRoot = this;
317
- this.root.dragulaLib = dragula_1.default;
318
316
  }
319
317
  /* eslint-enable max-statements */
320
318
  get language() {
@@ -828,7 +826,6 @@ class Webform extends NestedDataComponent_1.default {
828
826
  if (!submission || !submission.data) {
829
827
  submission = {
830
828
  data: {},
831
- metadata: submission.metadata,
832
829
  };
833
830
  }
834
831
  // Metadata needs to be available before setValue
@@ -1135,7 +1132,7 @@ class Webform extends NestedDataComponent_1.default {
1135
1132
  });
1136
1133
  const displayedErrors = [];
1137
1134
  if (errors.length) {
1138
- 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(); });
1139
1136
  const createListItem = (message, index) => {
1140
1137
  var _a, _b, _c;
1141
1138
  const err = errors[index];
@@ -1251,10 +1248,10 @@ class Webform extends NestedDataComponent_1.default {
1251
1248
  }
1252
1249
  this.checkData(value.data, flags);
1253
1250
  const shouldValidate = !flags.noValidate ||
1254
- flags.fromIFrame ||
1251
+ flags.fromIframe ||
1255
1252
  (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1256
1253
  const errors = shouldValidate
1257
- ? 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' }))
1258
1255
  : [];
1259
1256
  value.isValid = errors.length === 0;
1260
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
  }
@@ -830,6 +830,7 @@ declare class Component extends Element {
830
830
  quill: any;
831
831
  get shouldSanitizeValue(): boolean;
832
832
  addAce(element: any, settings: any, onChange: any): any;
833
+ getDragula(): Promise<any>;
833
834
  get tree(): any;
834
835
  /**
835
836
  * The empty value for this component.
@@ -1075,7 +1076,7 @@ declare class Component extends Element {
1075
1076
  elementInfo(): any;
1076
1077
  autofocus(): void;
1077
1078
  scrollIntoView(element?: any): void;
1078
- focus(index?: number): void;
1079
+ focus(index: any): void;
1079
1080
  /**
1080
1081
  * Get `Formio` instance for working with files
1081
1082
  * @returns {import('@formio/core').Formio} - The Formio instance file service.
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
@@ -2374,6 +2383,15 @@ class Component extends Element_1.default {
2374
2383
  return editor;
2375
2384
  });
2376
2385
  }
2386
+ getDragula() {
2387
+ return __awaiter(this, void 0, void 0, function* () {
2388
+ return new Promise((resolve) => {
2389
+ return Formio_1.Formio.requireLibrary('dragula', 'dragula', `${Formio_1.Formio.cdn.dragula}/dragula.js`, true, (ready) => {
2390
+ return ready.then(resolve);
2391
+ });
2392
+ });
2393
+ });
2394
+ }
2377
2395
  get tree() {
2378
2396
  return this.component.tree || false;
2379
2397
  }
@@ -3006,7 +3024,7 @@ class Component extends Element_1.default {
3006
3024
  this.parent.childErrors.push(...errors);
3007
3025
  }
3008
3026
  else {
3009
- 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; });
3010
3028
  }
3011
3029
  }
3012
3030
  this.showValidationErrors(errors, data, row, flags);
@@ -3022,7 +3040,7 @@ class Component extends Element_1.default {
3022
3040
  this.parent.childErrors.push(...errors);
3023
3041
  }
3024
3042
  else {
3025
- 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; });
3026
3044
  }
3027
3045
  }
3028
3046
  return errors.length === 0;
@@ -3445,14 +3463,15 @@ class Component extends Element_1.default {
3445
3463
  const { left, top } = element.getBoundingClientRect();
3446
3464
  window.scrollTo(left + window.scrollX, top + window.scrollY);
3447
3465
  }
3448
- focus(index = (this.refs.input.length - 1)) {
3449
- var _a, _b;
3466
+ focus(index) {
3467
+ var _a, _b, _c;
3450
3468
  if ('beforeFocus' in this.parent) {
3451
3469
  this.parent.beforeFocus(this);
3452
3470
  }
3453
- 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) {
3454
3473
  const focusingInput = this.refs.input[index];
3455
- 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') {
3456
3475
  const sibling = focusingInput.nextSibling;
3457
3476
  if (sibling) {
3458
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
  }
@@ -12,6 +12,7 @@ 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;
15
16
  visibleColumns: {} | undefined;
16
17
  set dataValue(value: any[]);
17
18
  get dataValue(): any[];
@@ -58,7 +59,6 @@ export default class DataGridComponent extends NestedArrayComponent {
58
59
  getRows(): {}[];
59
60
  getColumns(): any[];
60
61
  hasHeader(): any;
61
- loadRefs(element: any, refs: any): void;
62
62
  dragula: any;
63
63
  getComponentsContainer(): any;
64
64
  /**
@@ -71,6 +71,7 @@ export default class DataGridComponent extends NestedArrayComponent {
71
71
  */
72
72
  reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
73
73
  onReorder(element: any, _target: any, _source: any, sibling: any): void;
74
+ onCloned(el: any, original: any): void;
74
75
  focusOnNewRowElement(row: any): void;
75
76
  addRow(): void;
76
77
  updateComponentsRowIndex(components: any, rowIndex: any): void;