@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
@@ -17,6 +17,7 @@ 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"));
20
21
  // Initialize the available forms.
21
22
  Formio_1.Formio.forms = {};
22
23
  // Allow people to register components.
@@ -27,10 +28,10 @@ Formio_1.Formio.registerComponent = Components_1.default.setComponent;
27
28
  * @returns {any} - The icon set.
28
29
  */
29
30
  function getIconSet(icons) {
30
- if (icons === 'fontawesome') {
31
- return 'fa';
31
+ if (icons === "fontawesome") {
32
+ return "fa";
32
33
  }
33
- return icons || '';
34
+ return icons || "";
34
35
  }
35
36
  /**
36
37
  *
@@ -45,7 +46,7 @@ function getOptions(options) {
45
46
  saveDraft: false,
46
47
  alwaysDirty: false,
47
48
  saveDraftThrottle: 5000,
48
- display: 'form',
49
+ display: "form",
49
50
  cdnUrl: Formio_1.Formio.cdn.baseUrl,
50
51
  });
51
52
  if (!options.events) {
@@ -89,10 +90,10 @@ function getOptions(options) {
89
90
  */
90
91
  /**
91
92
  * @typedef {object} ButtonSettings
92
- * @property {boolean} [showPrevious] - Show the 'Previous' button.
93
- * @property {boolean} [showNext] - Show the 'Next' button.
94
- * @property {boolean} [showCancel] - Show the 'Cancel' button.
95
- * @property {boolean} [showSubmit] - Show the 'Submit' button.
93
+ * @property {boolean} [showPrevious] - Show the "Previous" button.
94
+ * @property {boolean} [showNext] - Show the "Next" button.
95
+ * @property {boolean} [showCancel] - Show the "Cancel" button.
96
+ * @property {boolean} [showSubmit] - Show the "Submit" button.
96
97
  */
97
98
  /**
98
99
  * @typedef {object} FormOptions
@@ -161,15 +162,15 @@ class Webform extends NestedDataComponent_1.default {
161
162
  }
162
163
  const ctrl = event.ctrlKey || event.metaKey;
163
164
  const keyCode = event.keyCode;
164
- let char = '';
165
+ let char = "";
165
166
  if (65 <= keyCode && keyCode <= 90) {
166
167
  char = String.fromCharCode(keyCode);
167
168
  }
168
169
  else if (keyCode === 13) {
169
- char = 'Enter';
170
+ char = "Enter";
170
171
  }
171
172
  else if (keyCode === 27) {
172
- char = 'Esc';
173
+ char = "Esc";
173
174
  }
174
175
  lodash_1.default.each(this.shortcuts, (shortcut) => {
175
176
  if (shortcut.ctrl && !ctrl) {
@@ -192,8 +193,8 @@ class Webform extends NestedDataComponent_1.default {
192
193
  * The type of this element.
193
194
  * @type {string}
194
195
  */
195
- this.type = 'form';
196
- this._src = '';
196
+ this.type = "form";
197
+ this._src = "";
197
198
  this._loading = false;
198
199
  this._form = {};
199
200
  this.draftEnabled = false;
@@ -313,26 +314,15 @@ class Webform extends NestedDataComponent_1.default {
313
314
  // Ensure the root is set to this component.
314
315
  this.root = this;
315
316
  this.localRoot = this;
317
+ this.root.dragulaLib = dragula_1.default;
316
318
  }
317
319
  /* eslint-enable max-statements */
318
- beforeInit() {
319
- this.executeFormController = lodash_1.default.once(this._executeFormController);
320
- }
321
320
  get language() {
322
321
  return this.options.language;
323
322
  }
324
323
  get emptyValue() {
325
324
  return null;
326
325
  }
327
- get shouldCallFormController() {
328
- // If no controller value or
329
- // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
330
- return (this.form &&
331
- this.form.controller &&
332
- !((!this.visible || this.component.hidden) &&
333
- this.component.clearOnHide &&
334
- !this.rootPristine));
335
- }
336
326
  componentContext() {
337
327
  return this._data;
338
328
  }
@@ -353,7 +343,7 @@ class Webform extends NestedDataComponent_1.default {
353
343
  return;
354
344
  }
355
345
  this.rebuild();
356
- this.emit('languageChanged');
346
+ this.emit("languageChanged");
357
347
  });
358
348
  }
359
349
  get componentComponents() {
@@ -371,18 +361,18 @@ class Webform extends NestedDataComponent_1.default {
371
361
  addLanguage(code, lang, active = false) {
372
362
  if (this.i18next) {
373
363
  var translations = lodash_1.default.assign((0, utils_1.fastCloneDeep)(i18n_1.default.resources.en.translation), lang);
374
- this.i18next.addResourceBundle(code, 'translation', translations, true, true);
364
+ this.i18next.addResourceBundle(code, "translation", translations, true, true);
375
365
  if (active) {
376
366
  this.language = code;
377
367
  }
378
368
  }
379
369
  }
380
370
  keyboardCatchableElement(element) {
381
- if (element.nodeName === 'TEXTAREA') {
371
+ if (element.nodeName === "TEXTAREA") {
382
372
  return false;
383
373
  }
384
- if (element.nodeName === 'INPUT') {
385
- return ['text', 'email', 'password'].indexOf(element.type) === -1;
374
+ if (element.nodeName === "INPUT") {
375
+ return ["text", "email", "password"].indexOf(element.type) === -1;
386
376
  }
387
377
  return true;
388
378
  }
@@ -391,9 +381,9 @@ class Webform extends NestedDataComponent_1.default {
391
381
  return;
392
382
  }
393
383
  shortcut = lodash_1.default.capitalize(shortcut);
394
- if (shortcut === 'Enter' || shortcut === 'Esc') {
384
+ if (shortcut === "Enter" || shortcut === "Esc") {
395
385
  // Restrict Enter and Esc only for buttons
396
- if (element.tagName !== 'BUTTON') {
386
+ if (element.tagName !== "BUTTON") {
397
387
  return;
398
388
  }
399
389
  this.shortcuts.push({
@@ -493,13 +483,13 @@ class Webform extends NestedDataComponent_1.default {
493
483
  * @returns {boolean} - TRUE means the url was set, FALSE otherwise.
494
484
  */
495
485
  setUrl(value, options) {
496
- if (!value || typeof value !== 'string' || value === this._src) {
486
+ if (!value || typeof value !== "string" || value === this._src) {
497
487
  return false;
498
488
  }
499
489
  this._src = value;
500
490
  this.nosubmit = true;
501
491
  this.formio = this.options.formio = new Formio_1.Formio(value, options);
502
- if (this.type === 'form') {
492
+ if (this.type === "form") {
503
493
  // Set the options source so this can be passed to other components.
504
494
  this.options.src = value;
505
495
  }
@@ -532,17 +522,17 @@ class Webform extends NestedDataComponent_1.default {
532
522
  }
533
523
  /**
534
524
  * Set the loading state for this form, and also show the loader spinner.
535
- * @param {boolean} loading - If this form should be 'loading' or not.
525
+ * @param {boolean} loading - If this form should be "loading" or not.
536
526
  */
537
527
  set loading(loading) {
538
528
  if (this._loading !== loading) {
539
529
  this._loading = loading;
540
530
  if (!this.loader && loading) {
541
- this.loader = this.ce('div', {
542
- class: 'loader-wrapper',
531
+ this.loader = this.ce("div", {
532
+ class: "loader-wrapper",
543
533
  });
544
- const spinner = this.ce('div', {
545
- class: 'loader text-center',
534
+ const spinner = this.ce("div", {
535
+ class: "loader text-center",
546
536
  });
547
537
  this.loader.appendChild(spinner);
548
538
  }
@@ -627,18 +617,18 @@ class Webform extends NestedDataComponent_1.default {
627
617
  // Use the sanitize config from the form settings or the global sanitize config if it is not provided in the options
628
618
  if (!this.options.sanitizeConfig && !this.builderMode) {
629
619
  this.options.sanitizeConfig =
630
- lodash_1.default.get(form, 'settings.sanitizeConfig') ||
631
- lodash_1.default.get(form, 'globalSettings.sanitizeConfig');
620
+ lodash_1.default.get(form, "settings.sanitizeConfig") ||
621
+ lodash_1.default.get(form, "globalSettings.sanitizeConfig");
632
622
  }
633
- if ('schema' in form && (0, compare_versions_1.compareVersions)(form.schema, '1.x') > 0) {
623
+ if ("schema" in form && (0, compare_versions_1.compareVersions)(form.schema, "1.x") > 0) {
634
624
  this.ready.then(() => {
635
- this.setAlert('alert alert-danger', this.t('newFormSchema'));
625
+ this.setAlert("alert alert-danger", "Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.");
636
626
  });
637
627
  }
638
628
  // See if they pass a module, and evaluate it if so.
639
629
  if (form && form.module) {
640
630
  let formModule = null;
641
- if (typeof form.module === 'string') {
631
+ if (typeof form.module === "string") {
642
632
  try {
643
633
  formModule = this.evaluate(`return ${form.module}`);
644
634
  }
@@ -660,7 +650,7 @@ class Webform extends NestedDataComponent_1.default {
660
650
  this.initialized = false;
661
651
  const rebuild = this.rebuild() || Promise.resolve();
662
652
  return rebuild.then(() => {
663
- this.emit('formLoad', form);
653
+ this.emit("formLoad", form);
664
654
  this.triggerCaptcha();
665
655
  // Make sure to trigger onChange after a render event occurs to speed up form rendering.
666
656
  setTimeout(() => {
@@ -732,7 +722,7 @@ class Webform extends NestedDataComponent_1.default {
732
722
  * @returns {Promise} - The promise that is triggered when the submission is set.
733
723
  */
734
724
  setSubmission(submission, flags = {}) {
735
- flags = Object.assign(Object.assign({}, flags), { fromSubmission: lodash_1.default.has(flags, 'fromSubmission') ? flags.fromSubmission : true });
725
+ flags = Object.assign(Object.assign({}, flags), { fromSubmission: lodash_1.default.has(flags, "fromSubmission") ? flags.fromSubmission : true });
736
726
  return (this.onSubmission = this.formReady
737
727
  .then((resolveFlags) => {
738
728
  if (resolveFlags) {
@@ -744,27 +734,26 @@ class Webform extends NestedDataComponent_1.default {
744
734
  .catch((err) => this.submissionReadyReject(err)));
745
735
  }
746
736
  handleDraftError(errName, errDetails, restoreDraft) {
747
- const errorMessage = lodash_1.default.trim(`${this.t(errName)} ${errDetails || ''}`);
737
+ const errorMessage = lodash_1.default.trim(`${this.t(errName)} ${errDetails || ""}`);
748
738
  console.warn(errorMessage);
749
- this.emit(restoreDraft ? 'restoreDraftError' : 'saveDraftError', errDetails || errorMessage);
739
+ this.emit(restoreDraft ? "restoreDraftError" : "saveDraftError", errDetails || errorMessage);
750
740
  }
751
741
  saveDraft() {
752
- var _a;
753
- if (!this.draftEnabled || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.component.reference) === false) {
742
+ if (!this.draftEnabled) {
754
743
  return;
755
744
  }
756
745
  if (!this.formio) {
757
- this.handleDraftError('saveDraftInstanceError');
746
+ this.handleDraftError("saveDraftInstanceError");
758
747
  return;
759
748
  }
760
749
  if (!Formio_1.Formio.getUser()) {
761
- this.handleDraftError('saveDraftAuthError');
750
+ this.handleDraftError("saveDraftAuthError");
762
751
  return;
763
752
  }
764
753
  const draft = (0, utils_1.fastCloneDeep)(this.submission);
765
- draft.state = 'draft';
754
+ draft.state = "draft";
766
755
  if (!this.savingDraft && !this.submitting) {
767
- this.emit('saveDraftBegin');
756
+ this.emit("saveDraftBegin");
768
757
  this.savingDraft = true;
769
758
  this.formio
770
759
  .saveSubmission(draft)
@@ -772,11 +761,11 @@ class Webform extends NestedDataComponent_1.default {
772
761
  // Set id to submission to avoid creating new draft submission
773
762
  this.submission._id = sub._id;
774
763
  this.savingDraft = false;
775
- this.emit('saveDraft', sub);
764
+ this.emit("saveDraft", sub);
776
765
  })
777
766
  .catch((err) => {
778
767
  this.savingDraft = false;
779
- this.handleDraftError('saveDraftError', err);
768
+ this.handleDraftError("saveDraftError", err);
780
769
  });
781
770
  }
782
771
  }
@@ -787,7 +776,7 @@ class Webform extends NestedDataComponent_1.default {
787
776
  restoreDraft(userId) {
788
777
  const formio = this.formio || this.options.formio;
789
778
  if (!formio) {
790
- this.handleDraftError('restoreDraftInstanceError', null, true);
779
+ this.handleDraftError("restoreDraftInstanceError", null, true);
791
780
  return;
792
781
  }
793
782
  this.savingDraft = true;
@@ -805,22 +794,22 @@ class Webform extends NestedDataComponent_1.default {
805
794
  return this.setSubmission(draft).then(() => {
806
795
  this.draftEnabled = true;
807
796
  this.savingDraft = false;
808
- this.emit('restoreDraft', draft);
797
+ this.emit("restoreDraft", draft);
809
798
  });
810
799
  }
811
800
  // Enable drafts so that we can keep track of changes.
812
801
  this.draftEnabled = true;
813
802
  this.savingDraft = false;
814
- this.emit('restoreDraft', null);
803
+ this.emit("restoreDraft", null);
815
804
  })
816
805
  .catch((err) => {
817
806
  this.draftEnabled = true;
818
807
  this.savingDraft = false;
819
- this.handleDraftError('restoreDraftError', err, true);
808
+ this.handleDraftError("restoreDraftError", err, true);
820
809
  });
821
810
  }
822
811
  get schema() {
823
- const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, ['components']));
812
+ const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, ["components"]));
824
813
  schema.components = [];
825
814
  this.eachComponent((component) => schema.components.push(component.schema));
826
815
  return schema;
@@ -895,28 +884,33 @@ class Webform extends NestedDataComponent_1.default {
895
884
  else {
896
885
  this.component = this.form;
897
886
  }
898
- this.component.type = 'form';
887
+ this.component.type = "form";
899
888
  this.component.input = false;
900
889
  this.addComponents();
901
- this.on('submitButton', (options) => {
890
+ this.on("submitButton", (options) => {
902
891
  this.submit(false, options).catch((e) => {
903
- if (options === null || options === void 0 ? void 0 : options.instance) {
904
- options.instance.loading = false;
905
- }
892
+ options.instance.loading = false;
906
893
  return e !== false && e !== undefined && console.log(e);
907
894
  });
908
895
  }, true);
909
- this.on('checkValidity', (data) => this.validate(data, { dirty: true, process: 'change' }), true);
910
- this.on('requestUrl', (args) => this.submitUrl(args.url, args.headers), true);
911
- this.on('resetForm', () => this.resetValue(), true);
912
- this.on('deleteSubmission', () => this.deleteSubmission(), true);
913
- this.on('refreshData', () => this.updateValue(), true);
914
- if (this.shouldCallFormController) {
915
- this.executeFormController();
916
- }
896
+ this.on("checkValidity", (data) => this.validate(data, { dirty: true, process: "change" }), true);
897
+ this.on("requestUrl", (args) => this.submitUrl(args.url, args.headers), true);
898
+ this.on("resetForm", () => this.resetValue(), true);
899
+ this.on("deleteSubmission", () => this.deleteSubmission(), true);
900
+ this.on("refreshData", () => this.updateValue(), true);
901
+ this.executeFormController();
917
902
  return this.formReady;
918
903
  }
919
- _executeFormController() {
904
+ executeFormController() {
905
+ // If no controller value or
906
+ // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
907
+ if (!this.form ||
908
+ !this.form.controller ||
909
+ ((!this.visible || this.component.hidden) &&
910
+ this.component.clearOnHide &&
911
+ !this.rootPristine)) {
912
+ return false;
913
+ }
920
914
  this.formReady.then(() => {
921
915
  this.evaluate(this.form.controller, {
922
916
  components: this.components,
@@ -928,19 +922,19 @@ class Webform extends NestedDataComponent_1.default {
928
922
  *
929
923
  */
930
924
  teardown() {
931
- this.emit('formDelete', this.id);
925
+ this.emit("formDelete", this.id);
932
926
  delete Formio_1.Formio.forms[this.id];
933
927
  delete this.executeShortcuts;
934
928
  delete this.triggerSaveDraft;
935
929
  super.teardown();
936
930
  }
937
931
  destroy(all = false) {
938
- this.off('submitButton');
939
- this.off('checkValidity');
940
- this.off('requestUrl');
941
- this.off('resetForm');
942
- this.off('deleteSubmission');
943
- this.off('refreshData');
932
+ this.off("submitButton");
933
+ this.off("checkValidity");
934
+ this.off("requestUrl");
935
+ this.off("resetForm");
936
+ this.off("deleteSubmission");
937
+ this.off("refreshData");
944
938
  return super.destroy(all);
945
939
  }
946
940
  build(element) {
@@ -953,17 +947,17 @@ class Webform extends NestedDataComponent_1.default {
953
947
  return this.ready;
954
948
  }
955
949
  getClassName() {
956
- let classes = 'formio-form';
950
+ let classes = "formio-form";
957
951
  if (this.options.readOnly) {
958
- classes += ' formio-read-only';
952
+ classes += " formio-read-only";
959
953
  }
960
954
  return classes;
961
955
  }
962
956
  render() {
963
- return super.render(this.renderTemplate('webform', {
957
+ return super.render(this.renderTemplate("webform", {
964
958
  classes: this.getClassName(),
965
959
  children: this.renderComponents(),
966
- }), this.builderMode ? 'builder' : 'form', true);
960
+ }), this.builderMode ? "builder" : "form", true);
967
961
  }
968
962
  redraw() {
969
963
  // Don't bother if we have not built yet.
@@ -976,13 +970,13 @@ class Webform extends NestedDataComponent_1.default {
976
970
  }
977
971
  attach(element) {
978
972
  this.setElement(element);
979
- this.loadRefs(element, { webform: 'single' });
973
+ this.loadRefs(element, { webform: "single" });
980
974
  const childPromise = this.attachComponents(this.refs.webform);
981
- this.addEventListener(document, 'keydown', this.executeShortcuts);
975
+ this.addEventListener(document, "keydown", this.executeShortcuts);
982
976
  this.currentForm = this;
983
- this.hook('attachWebform', element, this);
977
+ this.hook("attachWebform", element, this);
984
978
  return childPromise.then(() => {
985
- this.emit('render', this.element);
979
+ this.emit("render", this.element);
986
980
  return this.setValue(this._submission, {
987
981
  noUpdateEvent: true,
988
982
  });
@@ -1005,7 +999,7 @@ class Webform extends NestedDataComponent_1.default {
1005
999
  }
1006
1000
  /**
1007
1001
  * Sets a new alert to display in the error dialog of the form.
1008
- * @param {string} type - The type of alert to display. 'danger', 'success', 'warning', etc.
1002
+ * @param {string} type - The type of alert to display. "danger", "success", "warning", etc.
1009
1003
  * @param {string} message - The message to show in the alert.
1010
1004
  * @param {object} options - The options for the alert.
1011
1005
  */
@@ -1014,8 +1008,8 @@ class Webform extends NestedDataComponent_1.default {
1014
1008
  if (this.alert) {
1015
1009
  if (this.refs.errorRef && this.refs.errorRef.length) {
1016
1010
  this.refs.errorRef.forEach((el) => {
1017
- this.removeEventListener(el, 'click');
1018
- this.removeEventListener(el, 'keypress');
1011
+ this.removeEventListener(el, "click");
1012
+ this.removeEventListener(el, "keypress");
1019
1013
  });
1020
1014
  }
1021
1015
  this.removeChild(this.alert);
@@ -1025,7 +1019,7 @@ class Webform extends NestedDataComponent_1.default {
1025
1019
  }
1026
1020
  if (this.options.noAlerts) {
1027
1021
  if (!message) {
1028
- this.emit('error', false);
1022
+ this.emit("error", false);
1029
1023
  }
1030
1024
  return;
1031
1025
  }
@@ -1033,8 +1027,8 @@ class Webform extends NestedDataComponent_1.default {
1033
1027
  try {
1034
1028
  if (this.refs.errorRef && this.refs.errorRef.length) {
1035
1029
  this.refs.errorRef.forEach((el) => {
1036
- this.removeEventListener(el, 'click');
1037
- this.removeEventListener(el, 'keypress');
1030
+ this.removeEventListener(el, "click");
1031
+ this.removeEventListener(el, "keypress");
1038
1032
  });
1039
1033
  }
1040
1034
  this.removeChild(this.alert);
@@ -1054,19 +1048,19 @@ class Webform extends NestedDataComponent_1.default {
1054
1048
  attrs: attrs,
1055
1049
  type,
1056
1050
  };
1057
- this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate('alert', templateOptions), `#${attrs.id}`);
1051
+ this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate("alert", templateOptions), `#${attrs.id}`);
1058
1052
  }
1059
1053
  if (!this.alert) {
1060
1054
  return;
1061
1055
  }
1062
- this.loadRefs(this.alert, { errorRef: 'multiple' });
1056
+ this.loadRefs(this.alert, { errorRef: "multiple" });
1063
1057
  if (this.refs.errorRef && this.refs.errorRef.length) {
1064
1058
  this.refs.errorRef.forEach((el) => {
1065
- this.addEventListener(el, 'click', (e) => {
1059
+ this.addEventListener(el, "click", (e) => {
1066
1060
  const key = e.currentTarget.dataset.componentKey;
1067
1061
  this.focusOnComponent(key);
1068
1062
  });
1069
- this.addEventListener(el, 'keydown', (e) => {
1063
+ this.addEventListener(el, "keydown", (e) => {
1070
1064
  if (e.keyCode === 13) {
1071
1065
  e.preventDefault();
1072
1066
  const key = e.currentTarget.dataset.componentKey;
@@ -1146,8 +1140,8 @@ class Webform extends NestedDataComponent_1.default {
1146
1140
  (((_b = err.context) === null || _b === void 0 ? void 0 : _b.component) && ((_c = err.context) === null || _c === void 0 ? void 0 : _c.component.key)) ||
1147
1141
  (err.component && err.component.key) ||
1148
1142
  (err.fromServer && err.path);
1149
- const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : '';
1150
- if (typeof err !== 'string' && !err.formattedKeyOrPath) {
1143
+ const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : "";
1144
+ if (typeof err !== "string" && !err.formattedKeyOrPath) {
1151
1145
  err.formattedKeyOrPath = formattedKeyOrPath;
1152
1146
  }
1153
1147
  return {
@@ -1157,18 +1151,18 @@ class Webform extends NestedDataComponent_1.default {
1157
1151
  };
1158
1152
  errors.forEach(({ message, context, fromServer, component }, index) => {
1159
1153
  const text = !(component === null || component === void 0 ? void 0 : component.label) || (context === null || context === void 0 ? void 0 : context.hasLabel) || fromServer
1160
- ? this.t('alertMessage', { message: this.t(message) })
1161
- : this.t('alertMessageWithLabel', {
1154
+ ? this.t("alertMessage", { message: this.t(message) })
1155
+ : this.t("alertMessageWithLabel", {
1162
1156
  label: this.t(component === null || component === void 0 ? void 0 : component.label),
1163
1157
  message: this.t(message),
1164
1158
  });
1165
1159
  displayedErrors.push(createListItem(text, index));
1166
1160
  });
1167
1161
  }
1168
- const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
1169
- this.root.setAlert('danger', errorsList);
1162
+ const errorsList = this.renderTemplate("errorsList", { errors: displayedErrors });
1163
+ this.root.setAlert("danger", errorsList);
1170
1164
  if (triggerEvent) {
1171
- this.emit('error', errors);
1165
+ this.emit("error", errors);
1172
1166
  }
1173
1167
  return errors;
1174
1168
  }
@@ -1189,23 +1183,23 @@ class Webform extends NestedDataComponent_1.default {
1189
1183
  noValidate: true,
1190
1184
  noCheck: true,
1191
1185
  });
1192
- this.setAlert('success', `<p>${this.t('complete')}</p>`);
1186
+ this.setAlert("success", `<p>${this.t("complete")}</p>`);
1193
1187
  // Cancel triggered saveDraft to prevent overriding the submitted state
1194
1188
  if (this.draftEnabled && ((_a = this.triggerSaveDraft) === null || _a === void 0 ? void 0 : _a.cancel)) {
1195
1189
  this.triggerSaveDraft.cancel();
1196
1190
  }
1197
- this.emit('submit', submission, saved);
1191
+ this.emit("submit", submission, saved);
1198
1192
  if (saved) {
1199
- this.emit('submitDone', submission);
1193
+ this.emit("submitDone", submission);
1200
1194
  }
1201
1195
  return submission;
1202
1196
  }
1203
1197
  normalizeError(error) {
1204
1198
  if (error) {
1205
- if (typeof error === 'object' && 'details' in error) {
1199
+ if (typeof error === "object" && "details" in error) {
1206
1200
  error = error.details;
1207
1201
  }
1208
- if (typeof error === 'string') {
1202
+ if (typeof error === "string") {
1209
1203
  error = { message: error };
1210
1204
  }
1211
1205
  }
@@ -1220,10 +1214,10 @@ class Webform extends NestedDataComponent_1.default {
1220
1214
  error = this.normalizeError(error);
1221
1215
  this.submitting = false;
1222
1216
  this.setPristine(false);
1223
- this.emit('submitError', error || this.errors);
1217
+ this.emit("submitError", error || this.errors);
1224
1218
  // Allow for silent cancellations (no error message, no submit button error state)
1225
1219
  if (error && error.silent) {
1226
- this.emit('change', { isValid: true }, { silent: true });
1220
+ this.emit("change", { isValid: true }, { silent: true });
1227
1221
  return false;
1228
1222
  }
1229
1223
  const errors = this.showErrors(error, true);
@@ -1274,12 +1268,12 @@ class Webform extends NestedDataComponent_1.default {
1274
1268
  this.triggerSaveDraft();
1275
1269
  }
1276
1270
  if (!flags || !flags.noEmit) {
1277
- this.emit('change', value, flags, modified);
1271
+ this.emit("change", value, flags, modified);
1278
1272
  isChangeEventEmitted = true;
1279
1273
  }
1280
1274
  // The form is initialized after the first change event occurs.
1281
1275
  if (isChangeEventEmitted && !this.initialized) {
1282
- this.emit('initialized');
1276
+ this.emit("initialized");
1283
1277
  this.initialized = true;
1284
1278
  }
1285
1279
  }
@@ -1289,7 +1283,7 @@ class Webform extends NestedDataComponent_1.default {
1289
1283
  */
1290
1284
  deleteSubmission() {
1291
1285
  return this.formio.deleteSubmission().then(() => {
1292
- this.emit('submissionDeleted', this.submission);
1286
+ this.emit("submissionDeleted", this.submission);
1293
1287
  this.resetValue();
1294
1288
  });
1295
1289
  }
@@ -1300,13 +1294,13 @@ class Webform extends NestedDataComponent_1.default {
1300
1294
  * @returns {boolean} - TRUE means the submission was cancelled, FALSE otherwise.
1301
1295
  */
1302
1296
  cancel(noconfirm) {
1303
- const shouldReset = this.hook('beforeCancel', true);
1304
- if (shouldReset && (noconfirm || confirm(this.t('confirmCancel')))) {
1297
+ const shouldReset = this.hook("beforeCancel", true);
1298
+ if (shouldReset && (noconfirm || confirm(this.t("confirmCancel")))) {
1305
1299
  this.resetValue();
1306
1300
  return true;
1307
1301
  }
1308
1302
  else {
1309
- this.emit('cancelSubmit');
1303
+ this.emit("cancelSubmit");
1310
1304
  return false;
1311
1305
  }
1312
1306
  }
@@ -1314,8 +1308,8 @@ class Webform extends NestedDataComponent_1.default {
1314
1308
  // Add in metadata about client submitting the form
1315
1309
  submission.metadata = submission.metadata || {};
1316
1310
  lodash_1.default.defaults(submission.metadata, {
1317
- timezone: lodash_1.default.get(this, '_submission.metadata.timezone', (0, utils_1.currentTimezone)()),
1318
- offset: parseInt(lodash_1.default.get(this, '_submission.metadata.offset', (0, moment_1.default)().utcOffset()), 10),
1311
+ timezone: lodash_1.default.get(this, "_submission.metadata.timezone", (0, utils_1.currentTimezone)()),
1312
+ offset: parseInt(lodash_1.default.get(this, "_submission.metadata.offset", (0, moment_1.default)().utcOffset()), 10),
1319
1313
  origin: document.location.origin,
1320
1314
  referrer: document.referrer,
1321
1315
  browserName: navigator.appName,
@@ -1336,27 +1330,27 @@ class Webform extends NestedDataComponent_1.default {
1336
1330
  }
1337
1331
  const submission = (0, utils_1.fastCloneDeep)(this.submission || {});
1338
1332
  this.setMetadata(submission);
1339
- submission.state = options.state || submission.state || 'submitted';
1340
- const isDraft = submission.state === 'draft';
1341
- this.hook('beforeSubmit', Object.assign(Object.assign({}, submission), { component: options.component }), (err, data) => {
1333
+ submission.state = options.state || submission.state || "submitted";
1334
+ const isDraft = submission.state === "draft";
1335
+ this.hook("beforeSubmit", Object.assign(Object.assign({}, submission), { component: options.component }), (err, data) => {
1342
1336
  var _a;
1343
1337
  if (err) {
1344
1338
  return reject(err);
1345
1339
  }
1346
- submission._vnote = data && data._vnote ? data._vnote : '';
1340
+ submission._vnote = data && data._vnote ? data._vnote : "";
1347
1341
  try {
1348
1342
  if (!isDraft && !options.noValidate) {
1349
1343
  if (!submission.data) {
1350
- return reject('Invalid Submission');
1344
+ return reject("Invalid Submission");
1351
1345
  }
1352
1346
  const errors = this.validate(submission.data, {
1353
1347
  local,
1354
1348
  dirty: true,
1355
1349
  silentCheck: false,
1356
- process: 'submit',
1350
+ process: "submit",
1357
1351
  });
1358
1352
  if (errors.length ||
1359
- ((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === 'rejected'))) {
1353
+ ((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === "rejected"))) {
1360
1354
  return reject(errors);
1361
1355
  }
1362
1356
  }
@@ -1366,18 +1360,18 @@ class Webform extends NestedDataComponent_1.default {
1366
1360
  }
1367
1361
  this.everyComponent((comp) => {
1368
1362
  var _a, _b;
1369
- if (submission._vnote && comp.type === 'form' && comp.component.reference) {
1363
+ if (submission._vnote && comp.type === "form" && comp.component.reference) {
1370
1364
  lodash_1.default.get(submission.data, local ? (_a = comp.paths) === null || _a === void 0 ? void 0 : _a.localDataPath : comp.path, {})._vnote = submission._vnote;
1371
1365
  }
1372
1366
  const { persistent } = comp.component;
1373
- if (persistent === 'client-only') {
1367
+ if (persistent === "client-only") {
1374
1368
  lodash_1.default.unset(submission.data, local ? (_b = comp.paths) === null || _b === void 0 ? void 0 : _b.localDataPath : comp.path);
1375
1369
  }
1376
1370
  });
1377
- this.hook('customValidation', Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {
1371
+ this.hook("customValidation", Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {
1378
1372
  if (err) {
1379
1373
  // If string is returned, cast to object.
1380
- if (typeof err === 'string') {
1374
+ if (typeof err === "string") {
1381
1375
  err = {
1382
1376
  message: err,
1383
1377
  };
@@ -1391,8 +1385,8 @@ class Webform extends NestedDataComponent_1.default {
1391
1385
  if (this._form && this._form.action) {
1392
1386
  const method = submission.data._id &&
1393
1387
  this._form.action.includes(submission.data._id)
1394
- ? 'PUT'
1395
- : 'POST';
1388
+ ? "PUT"
1389
+ : "POST";
1396
1390
  return Formio_1.Formio.makeStaticRequest(this._form.action, method, submission, this.formio ? this.formio.options : {})
1397
1391
  .then((result) => resolve({
1398
1392
  submission: result,
@@ -1412,8 +1406,8 @@ class Webform extends NestedDataComponent_1.default {
1412
1406
  }
1413
1407
  // If this is an actionUrl, then make sure to save the action and not the submission.
1414
1408
  const submitMethod = submitFormio.actionUrl
1415
- ? 'saveAction'
1416
- : 'saveSubmission';
1409
+ ? "saveAction"
1410
+ : "saveSubmission";
1417
1411
  submitFormio[submitMethod](submission)
1418
1412
  .then((result) => resolve({
1419
1413
  submission: result,
@@ -1430,14 +1424,14 @@ class Webform extends NestedDataComponent_1.default {
1430
1424
  setServerErrors(error) {
1431
1425
  if (error.details) {
1432
1426
  this.serverErrors = error.details
1433
- .filter((err) => (err.level ? err.level === 'error' : err))
1427
+ .filter((err) => (err.level ? err.level === "error" : err))
1434
1428
  .map((err) => {
1435
1429
  err.fromServer = true;
1436
1430
  return err;
1437
1431
  });
1438
1432
  }
1439
- else if (typeof error === 'string') {
1440
- this.serverErrors = [{ fromServer: true, level: 'error', message: error }];
1433
+ else if (typeof error === "string") {
1434
+ this.serverErrors = [{ fromServer: true, level: "error", message: error }];
1441
1435
  }
1442
1436
  }
1443
1437
  executeSubmit(options) {
@@ -1496,17 +1490,17 @@ class Webform extends NestedDataComponent_1.default {
1496
1490
  }
1497
1491
  submitUrl(URL, headers) {
1498
1492
  if (!URL) {
1499
- return console.warn(this.t('missingUrl'));
1493
+ return console.warn("Missing URL argument");
1500
1494
  }
1501
1495
  const submission = this.submission || {};
1502
1496
  const API_URL = URL;
1503
1497
  const settings = {
1504
- method: 'POST',
1498
+ method: "POST",
1505
1499
  headers: {},
1506
1500
  };
1507
1501
  if (headers && headers.length > 0) {
1508
1502
  headers.map((e) => {
1509
- if (e.header !== '' && e.value !== '') {
1503
+ if (e.header !== "" && e.value !== "") {
1510
1504
  settings.headers[e.header] = this.interpolate(e.value, submission);
1511
1505
  }
1512
1506
  });
@@ -1516,26 +1510,25 @@ class Webform extends NestedDataComponent_1.default {
1516
1510
  headers: settings.headers,
1517
1511
  })
1518
1512
  .then(() => {
1519
- this.emit('requestDone');
1520
- this.setAlert('success', `<p> ${this.t('success')} </p>`);
1513
+ this.emit("requestDone");
1514
+ this.setAlert("success", "<p> Success </p>");
1521
1515
  })
1522
1516
  .catch((e) => {
1523
- const message = `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`;
1524
- this.emit('error', message);
1517
+ const message = `${e.statusText ? e.statusText : ""} ${e.status ? e.status : e}`;
1518
+ this.emit("error", message);
1525
1519
  console.error(message);
1526
- this.setAlert('danger', `<p> ${message} </p>`);
1520
+ this.setAlert("danger", `<p> ${message} </p>`);
1527
1521
  return Promise.reject(this.onSubmissionError(e));
1528
1522
  });
1529
1523
  }
1530
1524
  else {
1531
- const message = this.t('urlNotAttachedToBtn');
1532
- this.emit('error', message);
1533
- this.setAlert('warning', message);
1534
- return console.warn(message);
1525
+ this.emit("error", "You should add a URL to this button.");
1526
+ this.setAlert("warning", "You should add a URL to this button.");
1527
+ return console.warn("You should add a URL to this button.");
1535
1528
  }
1536
1529
  }
1537
1530
  triggerCaptcha(components = null) {
1538
- if (!this || !this.components || this.options.preview) {
1531
+ if (!this || !this.components) {
1539
1532
  return;
1540
1533
  }
1541
1534
  const captchaComponent = [];
@@ -1548,19 +1541,12 @@ class Webform extends NestedDataComponent_1.default {
1548
1541
  if (captchaComponent[0].component.provider === 'google' && components) {
1549
1542
  return;
1550
1543
  }
1551
- if (this.parent) {
1552
- this.parent.subFormReady.then(() => {
1553
- captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1554
- });
1555
- }
1556
- else {
1557
- captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1558
- }
1544
+ captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1559
1545
  }
1560
1546
  }
1561
1547
  set nosubmit(value) {
1562
1548
  this._nosubmit = !!value;
1563
- this.emit('nosubmit', this._nosubmit);
1549
+ this.emit("nosubmit", this._nosubmit);
1564
1550
  }
1565
1551
  get nosubmit() {
1566
1552
  return this._nosubmit || false;