@formio/js 5.1.0-dev.6059.845a6e3 → 5.1.0-dev.6060.19e3bfc

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