@formio/js 5.0.0-dev.5633.8d2b30d → 5.0.0-dev.5633.fde3bc9

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 (493) hide show
  1. package/Changelog.md +47 -2
  2. package/dist/formio.builder.css +8 -8
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.form.css +8 -8
  8. package/dist/formio.form.js +615 -1196
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +3 -5
  12. package/dist/formio.full.css +8 -8
  13. package/dist/formio.full.js +659 -920
  14. package/dist/formio.full.min.css +1 -1
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +3 -5
  17. package/dist/formio.js +18 -18
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +1 -1
  20. package/dist/formio.utils.js +1829 -492
  21. package/dist/formio.utils.min.js +1 -1
  22. package/dist/formio.utils.min.js.LICENSE.txt +10 -4
  23. package/embed.d.ts +1 -0
  24. package/form.d.ts +1 -0
  25. package/lib/cjs/CDN.d.ts +1 -0
  26. package/lib/cjs/CDN.js +6 -3
  27. package/lib/cjs/Element.d.ts +86 -96
  28. package/lib/cjs/Element.js +68 -78
  29. package/lib/cjs/Embed.d.ts +1 -1
  30. package/lib/cjs/Embed.js +52 -12
  31. package/lib/cjs/Form.d.ts +365 -36
  32. package/lib/cjs/Form.js +50 -64
  33. package/lib/cjs/FormBuilder.d.ts +187 -2
  34. package/lib/cjs/FormBuilder.js +30 -8
  35. package/lib/cjs/InlineEmbed.d.ts +7 -0
  36. package/lib/cjs/InlineEmbed.js +116 -0
  37. package/lib/cjs/PDF.d.ts +11 -13
  38. package/lib/cjs/PDF.js +6 -8
  39. package/lib/cjs/Webform.d.ts +183 -143
  40. package/lib/cjs/Webform.js +310 -298
  41. package/lib/cjs/WebformBuilder.d.ts +16 -14
  42. package/lib/cjs/WebformBuilder.js +11 -10
  43. package/lib/cjs/Wizard.d.ts +31 -21
  44. package/lib/cjs/Wizard.js +43 -20
  45. package/lib/cjs/WizardBuilder.d.ts +1 -1
  46. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -5
  47. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -3
  48. package/lib/cjs/components/Components.d.ts +4 -4
  49. package/lib/cjs/components/Components.js +3 -3
  50. package/lib/cjs/components/_classes/component/Component.d.ts +507 -276
  51. package/lib/cjs/components/_classes/component/Component.form.d.ts +6 -3
  52. package/lib/cjs/components/_classes/component/Component.form.js +5 -0
  53. package/lib/cjs/components/_classes/component/Component.js +438 -196
  54. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +0 -8
  55. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +2 -2
  56. package/lib/cjs/components/_classes/component/editForm/utils.js +2 -2
  57. package/lib/cjs/components/_classes/component/fixtures/comp6.d.ts +77 -0
  58. package/lib/cjs/components/_classes/component/fixtures/comp6.js +59 -0
  59. package/lib/cjs/components/_classes/component/fixtures/index.d.ts +2 -1
  60. package/lib/cjs/components/_classes/component/fixtures/index.js +3 -1
  61. package/lib/cjs/components/_classes/field/Field.d.ts +11 -2
  62. package/lib/cjs/components/_classes/field/Field.js +13 -1
  63. package/lib/cjs/components/_classes/input/Input.d.ts +4 -3
  64. package/lib/cjs/components/_classes/input/Input.js +8 -6
  65. package/lib/cjs/components/_classes/list/ListComponent.d.ts +2 -2
  66. package/lib/cjs/components/_classes/list/ListComponent.form.d.ts +6 -3
  67. package/lib/cjs/components/_classes/list/ListComponent.form.js +5 -0
  68. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +43 -12
  69. package/lib/cjs/components/_classes/multivalue/Multivalue.js +37 -3
  70. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +163 -67
  71. package/lib/cjs/components/_classes/nested/NestedComponent.form.d.ts +6 -3
  72. package/lib/cjs/components/_classes/nested/NestedComponent.form.js +5 -0
  73. package/lib/cjs/components/_classes/nested/NestedComponent.js +175 -54
  74. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
  75. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  76. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +7 -1
  77. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +2 -3
  78. package/lib/cjs/components/address/Address.d.ts +4 -2
  79. package/lib/cjs/components/address/Address.form.d.ts +6 -3
  80. package/lib/cjs/components/address/Address.form.js +5 -0
  81. package/lib/cjs/components/button/Button.d.ts +3 -12
  82. package/lib/cjs/components/button/Button.form.d.ts +6 -3
  83. package/lib/cjs/components/button/Button.form.js +5 -0
  84. package/lib/cjs/components/button/Button.js +5 -0
  85. package/lib/cjs/components/checkbox/Checkbox.d.ts +4 -27
  86. package/lib/cjs/components/checkbox/Checkbox.form.d.ts +6 -3
  87. package/lib/cjs/components/checkbox/Checkbox.form.js +5 -0
  88. package/lib/cjs/components/columns/Columns.d.ts +3 -2
  89. package/lib/cjs/components/columns/Columns.form.d.ts +6 -3
  90. package/lib/cjs/components/columns/Columns.form.js +5 -0
  91. package/lib/cjs/components/columns/Columns.js +1 -1
  92. package/lib/cjs/components/container/Container.form.d.ts +6 -3
  93. package/lib/cjs/components/container/Container.form.js +5 -0
  94. package/lib/cjs/components/content/Content.d.ts +2 -1
  95. package/lib/cjs/components/content/Content.form.d.ts +6 -3
  96. package/lib/cjs/components/content/Content.form.js +5 -0
  97. package/lib/cjs/components/currency/Currency.form.d.ts +6 -3
  98. package/lib/cjs/components/currency/Currency.form.js +5 -0
  99. package/lib/cjs/components/currency/Currency.js +1 -2
  100. package/lib/cjs/components/datagrid/DataGrid.d.ts +8 -7
  101. package/lib/cjs/components/datagrid/DataGrid.form.d.ts +6 -3
  102. package/lib/cjs/components/datagrid/DataGrid.form.js +5 -0
  103. package/lib/cjs/components/datagrid/DataGrid.js +5 -5
  104. package/lib/cjs/components/datagrid/fixtures/comp-with-checkboxes.d.ts +29 -0
  105. package/lib/cjs/components/datagrid/fixtures/comp-with-checkboxes.js +36 -0
  106. package/lib/cjs/components/datagrid/fixtures/index.d.ts +2 -1
  107. package/lib/cjs/components/datagrid/fixtures/index.js +3 -1
  108. package/lib/cjs/components/datamap/DataMap.d.ts +1 -0
  109. package/lib/cjs/components/datamap/DataMap.form.d.ts +6 -3
  110. package/lib/cjs/components/datamap/DataMap.form.js +5 -0
  111. package/lib/cjs/components/datetime/DateTime.d.ts +0 -14
  112. package/lib/cjs/components/datetime/DateTime.form.d.ts +6 -3
  113. package/lib/cjs/components/datetime/DateTime.form.js +5 -0
  114. package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +2 -2
  115. package/lib/cjs/components/day/Day.d.ts +23 -49
  116. package/lib/cjs/components/day/Day.form.d.ts +6 -3
  117. package/lib/cjs/components/day/Day.form.js +5 -0
  118. package/lib/cjs/components/day/Day.js +16 -21
  119. package/lib/cjs/components/day/fixtures/comp7.d.ts +109 -0
  120. package/lib/cjs/components/day/fixtures/comp7.js +109 -0
  121. package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
  122. package/lib/cjs/components/day/fixtures/index.js +3 -1
  123. package/lib/cjs/components/editgrid/EditGrid.d.ts +7 -3
  124. package/lib/cjs/components/editgrid/EditGrid.form.d.ts +6 -3
  125. package/lib/cjs/components/editgrid/EditGrid.form.js +5 -0
  126. package/lib/cjs/components/editgrid/EditGrid.js +3 -3
  127. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +2 -5
  128. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.js +6 -9
  129. package/lib/cjs/components/email/Email.form.d.ts +6 -3
  130. package/lib/cjs/components/email/Email.form.js +5 -0
  131. package/lib/cjs/components/fieldset/Fieldset.form.d.ts +6 -3
  132. package/lib/cjs/components/fieldset/Fieldset.form.js +5 -0
  133. package/lib/cjs/components/file/File.d.ts +9 -22
  134. package/lib/cjs/components/file/File.form.d.ts +6 -3
  135. package/lib/cjs/components/file/File.form.js +5 -0
  136. package/lib/cjs/components/file/File.js +1 -2
  137. package/lib/cjs/components/form/Form.d.ts +34 -24
  138. package/lib/cjs/components/form/Form.form.d.ts +6 -3
  139. package/lib/cjs/components/form/Form.form.js +5 -0
  140. package/lib/cjs/components/form/Form.js +15 -13
  141. package/lib/cjs/components/hidden/Hidden.d.ts +1 -11
  142. package/lib/cjs/components/hidden/Hidden.form.d.ts +6 -3
  143. package/lib/cjs/components/hidden/Hidden.form.js +5 -0
  144. package/lib/cjs/components/hidden/Hidden.js +1 -2
  145. package/lib/cjs/components/html/HTML.d.ts +2 -1
  146. package/lib/cjs/components/html/HTML.form.d.ts +6 -3
  147. package/lib/cjs/components/html/HTML.form.js +5 -0
  148. package/lib/cjs/components/number/Number.d.ts +3 -17
  149. package/lib/cjs/components/number/Number.form.d.ts +6 -3
  150. package/lib/cjs/components/number/Number.form.js +5 -0
  151. package/lib/cjs/components/number/Number.js +1 -2
  152. package/lib/cjs/components/panel/Panel.form.d.ts +6 -3
  153. package/lib/cjs/components/panel/Panel.form.js +5 -0
  154. package/lib/cjs/components/panel/Panel.js +0 -1
  155. package/lib/cjs/components/password/Password.form.d.ts +6 -3
  156. package/lib/cjs/components/password/Password.form.js +5 -0
  157. package/lib/cjs/components/phonenumber/PhoneNumber.form.d.ts +6 -3
  158. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +5 -0
  159. package/lib/cjs/components/radio/Radio.d.ts +3 -26
  160. package/lib/cjs/components/radio/Radio.form.d.ts +6 -3
  161. package/lib/cjs/components/radio/Radio.form.js +5 -0
  162. package/lib/cjs/components/radio/Radio.js +6 -6
  163. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
  164. package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
  165. package/lib/cjs/components/recaptcha/ReCaptcha.form.js +5 -0
  166. package/lib/cjs/components/select/Select.d.ts +16 -39
  167. package/lib/cjs/components/select/Select.form.d.ts +6 -3
  168. package/lib/cjs/components/select/Select.form.js +5 -0
  169. package/lib/cjs/components/select/Select.js +13 -16
  170. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +2 -17
  171. package/lib/cjs/components/selectboxes/SelectBoxes.form.d.ts +6 -3
  172. package/lib/cjs/components/selectboxes/SelectBoxes.form.js +5 -0
  173. package/lib/cjs/components/selectboxes/SelectBoxes.js +7 -9
  174. package/lib/cjs/components/signature/Signature.d.ts +0 -14
  175. package/lib/cjs/components/signature/Signature.form.d.ts +6 -3
  176. package/lib/cjs/components/signature/Signature.form.js +5 -0
  177. package/lib/cjs/components/survey/Survey.d.ts +3 -15
  178. package/lib/cjs/components/survey/Survey.form.d.ts +6 -3
  179. package/lib/cjs/components/survey/Survey.form.js +5 -0
  180. package/lib/cjs/components/table/Table.d.ts +2 -1
  181. package/lib/cjs/components/table/Table.form.d.ts +6 -3
  182. package/lib/cjs/components/table/Table.form.js +5 -0
  183. package/lib/cjs/components/tabs/Tabs.d.ts +4 -4
  184. package/lib/cjs/components/tabs/Tabs.form.d.ts +6 -3
  185. package/lib/cjs/components/tabs/Tabs.form.js +5 -0
  186. package/lib/cjs/components/tabs/Tabs.js +1 -2
  187. package/lib/cjs/components/tags/Tags.d.ts +0 -14
  188. package/lib/cjs/components/tags/Tags.form.d.ts +6 -3
  189. package/lib/cjs/components/tags/Tags.form.js +5 -0
  190. package/lib/cjs/components/textarea/TextArea.d.ts +4 -9
  191. package/lib/cjs/components/textarea/TextArea.form.d.ts +6 -3
  192. package/lib/cjs/components/textarea/TextArea.form.js +5 -0
  193. package/lib/cjs/components/textarea/TextArea.js +2 -2
  194. package/lib/cjs/components/textfield/TextField.d.ts +14 -30
  195. package/lib/cjs/components/textfield/TextField.form.d.ts +6 -3
  196. package/lib/cjs/components/textfield/TextField.form.js +5 -0
  197. package/lib/cjs/components/textfield/TextField.js +16 -17
  198. package/lib/cjs/components/time/Time.form.d.ts +6 -3
  199. package/lib/cjs/components/time/Time.form.js +5 -0
  200. package/lib/cjs/components/unknown/Unknown.form.d.ts +5 -34
  201. package/lib/cjs/components/unknown/Unknown.form.js +4 -0
  202. package/lib/cjs/components/url/Url.form.d.ts +6 -3
  203. package/lib/cjs/components/url/Url.form.js +5 -0
  204. package/lib/cjs/components/well/Well.form.d.ts +6 -3
  205. package/lib/cjs/components/well/Well.form.js +5 -0
  206. package/lib/cjs/formio.embed.d.ts +1 -2
  207. package/lib/cjs/formio.embed.js +2 -100
  208. package/lib/cjs/formio.form.d.ts +11 -4
  209. package/lib/cjs/formio.form.js +13 -5
  210. package/lib/cjs/providers/Providers.d.ts +36 -5
  211. package/lib/cjs/providers/Providers.js +29 -0
  212. package/lib/cjs/providers/address/AddressProvider.d.ts +131 -12
  213. package/lib/cjs/providers/address/AddressProvider.js +88 -2
  214. package/lib/cjs/providers/address/AzureAddressProvider.d.ts +48 -1
  215. package/lib/cjs/providers/address/AzureAddressProvider.js +37 -0
  216. package/lib/cjs/providers/address/CustomAddressProvider.d.ts +27 -4
  217. package/lib/cjs/providers/address/CustomAddressProvider.js +34 -0
  218. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +130 -6
  219. package/lib/cjs/providers/address/GoogleAddressProvider.js +73 -1
  220. package/lib/cjs/providers/address/NominatimAddressProvider.d.ts +32 -7
  221. package/lib/cjs/providers/address/NominatimAddressProvider.js +33 -0
  222. package/lib/cjs/providers/address/index.d.ts +3 -1
  223. package/lib/cjs/providers/processor/fileProcessor.d.ts +7 -1
  224. package/lib/cjs/providers/processor/fileProcessor.js +6 -0
  225. package/lib/cjs/providers/storage/azure.d.ts +6 -13
  226. package/lib/cjs/providers/storage/azure.js +5 -0
  227. package/lib/cjs/providers/storage/base64.d.ts +5 -6
  228. package/lib/cjs/providers/storage/base64.js +4 -0
  229. package/lib/cjs/providers/storage/dropbox.d.ts +6 -4
  230. package/lib/cjs/providers/storage/dropbox.js +5 -0
  231. package/lib/cjs/providers/storage/googleDrive.d.ts +7 -5
  232. package/lib/cjs/providers/storage/googleDrive.js +6 -0
  233. package/lib/cjs/providers/storage/indexeddb.d.ts +5 -7
  234. package/lib/cjs/providers/storage/indexeddb.js +4 -0
  235. package/lib/cjs/providers/storage/s3.d.ts +6 -20
  236. package/lib/cjs/providers/storage/s3.js +5 -0
  237. package/lib/cjs/providers/storage/url.d.ts +6 -7
  238. package/lib/cjs/providers/storage/url.js +10 -0
  239. package/lib/cjs/providers/storage/util.d.ts +24 -1
  240. package/lib/cjs/providers/storage/util.js +18 -0
  241. package/lib/cjs/templates/Templates.d.ts +1 -0
  242. package/lib/cjs/translations/en.d.ts +2 -0
  243. package/lib/cjs/translations/en.js +3 -1
  244. package/lib/cjs/utils/ChoicesWrapper.d.ts +1 -1
  245. package/lib/cjs/utils/ChoicesWrapper.js +13 -2
  246. package/lib/cjs/utils/Evaluator.d.ts +6 -3
  247. package/lib/cjs/utils/Evaluator.js +11 -20
  248. package/lib/cjs/utils/builder.d.ts +9 -7
  249. package/lib/cjs/utils/builder.js +10 -5
  250. package/lib/cjs/utils/calendarUtils.d.ts +7 -13
  251. package/lib/cjs/utils/calendarUtils.js +10 -17
  252. package/lib/cjs/utils/formUtils.d.ts +43 -171
  253. package/lib/cjs/utils/formUtils.js +38 -569
  254. package/lib/cjs/utils/utils.d.ts +367 -221
  255. package/lib/cjs/utils/utils.js +335 -228
  256. package/lib/cjs/widgets/CalendarWidget.d.ts +9 -10
  257. package/lib/cjs/widgets/CalendarWidget.js +9 -11
  258. package/lib/mjs/CDN.d.ts +1 -0
  259. package/lib/mjs/CDN.js +6 -3
  260. package/lib/mjs/Element.d.ts +86 -96
  261. package/lib/mjs/Element.js +68 -78
  262. package/lib/mjs/Embed.d.ts +1 -1
  263. package/lib/mjs/Embed.js +52 -12
  264. package/lib/mjs/Form.d.ts +365 -36
  265. package/lib/mjs/Form.js +140 -57
  266. package/lib/mjs/FormBuilder.d.ts +187 -2
  267. package/lib/mjs/FormBuilder.js +32 -8
  268. package/lib/mjs/InlineEmbed.d.ts +7 -0
  269. package/lib/mjs/InlineEmbed.js +112 -0
  270. package/lib/mjs/PDF.d.ts +11 -13
  271. package/lib/mjs/PDF.js +6 -8
  272. package/lib/mjs/Webform.d.ts +183 -143
  273. package/lib/mjs/Webform.js +322 -310
  274. package/lib/mjs/WebformBuilder.d.ts +16 -14
  275. package/lib/mjs/WebformBuilder.js +11 -10
  276. package/lib/mjs/Wizard.d.ts +31 -21
  277. package/lib/mjs/Wizard.js +42 -19
  278. package/lib/mjs/WizardBuilder.d.ts +1 -1
  279. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -5
  280. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -3
  281. package/lib/mjs/components/Components.d.ts +4 -4
  282. package/lib/mjs/components/Components.js +3 -3
  283. package/lib/mjs/components/_classes/component/Component.d.ts +507 -276
  284. package/lib/mjs/components/_classes/component/Component.form.d.ts +6 -3
  285. package/lib/mjs/components/_classes/component/Component.form.js +5 -0
  286. package/lib/mjs/components/_classes/component/Component.js +438 -196
  287. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +0 -8
  288. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
  289. package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
  290. package/lib/mjs/components/_classes/component/fixtures/comp6.d.ts +77 -0
  291. package/lib/mjs/components/_classes/component/fixtures/comp6.js +57 -0
  292. package/lib/mjs/components/_classes/component/fixtures/index.d.ts +2 -1
  293. package/lib/mjs/components/_classes/component/fixtures/index.js +2 -1
  294. package/lib/mjs/components/_classes/field/Field.d.ts +11 -2
  295. package/lib/mjs/components/_classes/field/Field.js +13 -1
  296. package/lib/mjs/components/_classes/input/Input.d.ts +4 -3
  297. package/lib/mjs/components/_classes/input/Input.js +8 -6
  298. package/lib/mjs/components/_classes/list/ListComponent.d.ts +2 -2
  299. package/lib/mjs/components/_classes/list/ListComponent.form.d.ts +6 -3
  300. package/lib/mjs/components/_classes/list/ListComponent.form.js +5 -0
  301. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +43 -12
  302. package/lib/mjs/components/_classes/multivalue/Multivalue.js +37 -3
  303. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +163 -67
  304. package/lib/mjs/components/_classes/nested/NestedComponent.form.d.ts +6 -3
  305. package/lib/mjs/components/_classes/nested/NestedComponent.form.js +5 -0
  306. package/lib/mjs/components/_classes/nested/NestedComponent.js +175 -54
  307. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
  308. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  309. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +7 -1
  310. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +2 -3
  311. package/lib/mjs/components/address/Address.d.ts +4 -2
  312. package/lib/mjs/components/address/Address.form.d.ts +6 -3
  313. package/lib/mjs/components/address/Address.form.js +5 -0
  314. package/lib/mjs/components/button/Button.d.ts +3 -12
  315. package/lib/mjs/components/button/Button.form.d.ts +6 -3
  316. package/lib/mjs/components/button/Button.form.js +5 -0
  317. package/lib/mjs/components/button/Button.js +5 -0
  318. package/lib/mjs/components/checkbox/Checkbox.d.ts +4 -27
  319. package/lib/mjs/components/checkbox/Checkbox.form.d.ts +6 -3
  320. package/lib/mjs/components/checkbox/Checkbox.form.js +5 -0
  321. package/lib/mjs/components/columns/Columns.d.ts +3 -2
  322. package/lib/mjs/components/columns/Columns.form.d.ts +6 -3
  323. package/lib/mjs/components/columns/Columns.form.js +5 -0
  324. package/lib/mjs/components/columns/Columns.js +1 -1
  325. package/lib/mjs/components/container/Container.form.d.ts +6 -3
  326. package/lib/mjs/components/container/Container.form.js +5 -0
  327. package/lib/mjs/components/content/Content.d.ts +2 -1
  328. package/lib/mjs/components/content/Content.form.d.ts +6 -3
  329. package/lib/mjs/components/content/Content.form.js +5 -0
  330. package/lib/mjs/components/currency/Currency.form.d.ts +6 -3
  331. package/lib/mjs/components/currency/Currency.form.js +5 -0
  332. package/lib/mjs/components/currency/Currency.js +1 -2
  333. package/lib/mjs/components/datagrid/DataGrid.d.ts +8 -7
  334. package/lib/mjs/components/datagrid/DataGrid.form.d.ts +6 -3
  335. package/lib/mjs/components/datagrid/DataGrid.form.js +5 -0
  336. package/lib/mjs/components/datagrid/DataGrid.js +5 -5
  337. package/lib/mjs/components/datagrid/fixtures/comp-with-checkboxes.d.ts +29 -0
  338. package/lib/mjs/components/datagrid/fixtures/comp-with-checkboxes.js +34 -0
  339. package/lib/mjs/components/datagrid/fixtures/index.d.ts +2 -1
  340. package/lib/mjs/components/datagrid/fixtures/index.js +2 -1
  341. package/lib/mjs/components/datamap/DataMap.d.ts +1 -0
  342. package/lib/mjs/components/datamap/DataMap.form.d.ts +6 -3
  343. package/lib/mjs/components/datamap/DataMap.form.js +5 -0
  344. package/lib/mjs/components/datetime/DateTime.d.ts +0 -14
  345. package/lib/mjs/components/datetime/DateTime.form.d.ts +6 -3
  346. package/lib/mjs/components/datetime/DateTime.form.js +5 -0
  347. package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +1 -1
  348. package/lib/mjs/components/day/Day.d.ts +23 -49
  349. package/lib/mjs/components/day/Day.form.d.ts +6 -3
  350. package/lib/mjs/components/day/Day.form.js +5 -0
  351. package/lib/mjs/components/day/Day.js +16 -21
  352. package/lib/mjs/components/day/fixtures/comp7.d.ts +109 -0
  353. package/lib/mjs/components/day/fixtures/comp7.js +107 -0
  354. package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
  355. package/lib/mjs/components/day/fixtures/index.js +2 -1
  356. package/lib/mjs/components/editgrid/EditGrid.d.ts +7 -3
  357. package/lib/mjs/components/editgrid/EditGrid.form.d.ts +6 -3
  358. package/lib/mjs/components/editgrid/EditGrid.form.js +5 -0
  359. package/lib/mjs/components/editgrid/EditGrid.js +3 -3
  360. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  361. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +1 -1
  362. package/lib/mjs/components/email/Email.form.d.ts +6 -3
  363. package/lib/mjs/components/email/Email.form.js +5 -0
  364. package/lib/mjs/components/fieldset/Fieldset.form.d.ts +6 -3
  365. package/lib/mjs/components/fieldset/Fieldset.form.js +5 -0
  366. package/lib/mjs/components/file/File.d.ts +9 -22
  367. package/lib/mjs/components/file/File.form.d.ts +6 -3
  368. package/lib/mjs/components/file/File.form.js +5 -0
  369. package/lib/mjs/components/file/File.js +1 -2
  370. package/lib/mjs/components/form/Form.d.ts +34 -24
  371. package/lib/mjs/components/form/Form.form.d.ts +6 -3
  372. package/lib/mjs/components/form/Form.form.js +5 -0
  373. package/lib/mjs/components/form/Form.js +15 -13
  374. package/lib/mjs/components/hidden/Hidden.d.ts +1 -11
  375. package/lib/mjs/components/hidden/Hidden.form.d.ts +6 -3
  376. package/lib/mjs/components/hidden/Hidden.form.js +5 -0
  377. package/lib/mjs/components/hidden/Hidden.js +1 -2
  378. package/lib/mjs/components/html/HTML.d.ts +2 -1
  379. package/lib/mjs/components/html/HTML.form.d.ts +6 -3
  380. package/lib/mjs/components/html/HTML.form.js +5 -0
  381. package/lib/mjs/components/number/Number.d.ts +3 -17
  382. package/lib/mjs/components/number/Number.form.d.ts +6 -3
  383. package/lib/mjs/components/number/Number.form.js +5 -0
  384. package/lib/mjs/components/number/Number.js +1 -2
  385. package/lib/mjs/components/panel/Panel.form.d.ts +6 -3
  386. package/lib/mjs/components/panel/Panel.form.js +5 -0
  387. package/lib/mjs/components/panel/Panel.js +0 -1
  388. package/lib/mjs/components/password/Password.form.d.ts +6 -3
  389. package/lib/mjs/components/password/Password.form.js +5 -0
  390. package/lib/mjs/components/phonenumber/PhoneNumber.form.d.ts +6 -3
  391. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +5 -0
  392. package/lib/mjs/components/radio/Radio.d.ts +3 -26
  393. package/lib/mjs/components/radio/Radio.form.d.ts +6 -3
  394. package/lib/mjs/components/radio/Radio.form.js +5 -0
  395. package/lib/mjs/components/radio/Radio.js +6 -6
  396. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
  397. package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
  398. package/lib/mjs/components/recaptcha/ReCaptcha.form.js +5 -0
  399. package/lib/mjs/components/select/Select.d.ts +16 -39
  400. package/lib/mjs/components/select/Select.form.d.ts +6 -3
  401. package/lib/mjs/components/select/Select.form.js +5 -0
  402. package/lib/mjs/components/select/Select.js +14 -17
  403. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +2 -17
  404. package/lib/mjs/components/selectboxes/SelectBoxes.form.d.ts +6 -3
  405. package/lib/mjs/components/selectboxes/SelectBoxes.form.js +5 -0
  406. package/lib/mjs/components/selectboxes/SelectBoxes.js +7 -9
  407. package/lib/mjs/components/signature/Signature.d.ts +0 -14
  408. package/lib/mjs/components/signature/Signature.form.d.ts +6 -3
  409. package/lib/mjs/components/signature/Signature.form.js +5 -0
  410. package/lib/mjs/components/survey/Survey.d.ts +3 -15
  411. package/lib/mjs/components/survey/Survey.form.d.ts +6 -3
  412. package/lib/mjs/components/survey/Survey.form.js +5 -0
  413. package/lib/mjs/components/table/Table.d.ts +2 -1
  414. package/lib/mjs/components/table/Table.form.d.ts +6 -3
  415. package/lib/mjs/components/table/Table.form.js +5 -0
  416. package/lib/mjs/components/tabs/Tabs.d.ts +4 -4
  417. package/lib/mjs/components/tabs/Tabs.form.d.ts +6 -3
  418. package/lib/mjs/components/tabs/Tabs.form.js +5 -0
  419. package/lib/mjs/components/tabs/Tabs.js +1 -2
  420. package/lib/mjs/components/tags/Tags.d.ts +0 -14
  421. package/lib/mjs/components/tags/Tags.form.d.ts +6 -3
  422. package/lib/mjs/components/tags/Tags.form.js +5 -0
  423. package/lib/mjs/components/textarea/TextArea.d.ts +4 -9
  424. package/lib/mjs/components/textarea/TextArea.form.d.ts +6 -3
  425. package/lib/mjs/components/textarea/TextArea.form.js +5 -0
  426. package/lib/mjs/components/textarea/TextArea.js +2 -2
  427. package/lib/mjs/components/textfield/TextField.d.ts +14 -30
  428. package/lib/mjs/components/textfield/TextField.form.d.ts +6 -3
  429. package/lib/mjs/components/textfield/TextField.form.js +5 -0
  430. package/lib/mjs/components/textfield/TextField.js +16 -17
  431. package/lib/mjs/components/time/Time.form.d.ts +6 -3
  432. package/lib/mjs/components/time/Time.form.js +5 -0
  433. package/lib/mjs/components/unknown/Unknown.form.d.ts +5 -34
  434. package/lib/mjs/components/unknown/Unknown.form.js +4 -0
  435. package/lib/mjs/components/url/Url.form.d.ts +6 -3
  436. package/lib/mjs/components/url/Url.form.js +5 -0
  437. package/lib/mjs/components/well/Well.form.d.ts +6 -3
  438. package/lib/mjs/components/well/Well.form.js +5 -0
  439. package/lib/mjs/formio.embed.d.ts +1 -2
  440. package/lib/mjs/formio.embed.js +2 -99
  441. package/lib/mjs/formio.form.d.ts +11 -4
  442. package/lib/mjs/formio.form.js +10 -3
  443. package/lib/mjs/providers/Providers.d.ts +36 -5
  444. package/lib/mjs/providers/Providers.js +29 -0
  445. package/lib/mjs/providers/address/AddressProvider.d.ts +131 -12
  446. package/lib/mjs/providers/address/AddressProvider.js +88 -2
  447. package/lib/mjs/providers/address/AzureAddressProvider.d.ts +48 -1
  448. package/lib/mjs/providers/address/AzureAddressProvider.js +37 -0
  449. package/lib/mjs/providers/address/CustomAddressProvider.d.ts +27 -4
  450. package/lib/mjs/providers/address/CustomAddressProvider.js +34 -0
  451. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +130 -6
  452. package/lib/mjs/providers/address/GoogleAddressProvider.js +73 -1
  453. package/lib/mjs/providers/address/NominatimAddressProvider.d.ts +32 -7
  454. package/lib/mjs/providers/address/NominatimAddressProvider.js +33 -0
  455. package/lib/mjs/providers/address/index.d.ts +3 -1
  456. package/lib/mjs/providers/processor/fileProcessor.d.ts +7 -1
  457. package/lib/mjs/providers/processor/fileProcessor.js +6 -0
  458. package/lib/mjs/providers/storage/azure.d.ts +6 -13
  459. package/lib/mjs/providers/storage/azure.js +5 -0
  460. package/lib/mjs/providers/storage/base64.d.ts +5 -6
  461. package/lib/mjs/providers/storage/base64.js +4 -0
  462. package/lib/mjs/providers/storage/dropbox.d.ts +6 -4
  463. package/lib/mjs/providers/storage/dropbox.js +5 -0
  464. package/lib/mjs/providers/storage/googleDrive.d.ts +7 -5
  465. package/lib/mjs/providers/storage/googleDrive.js +6 -0
  466. package/lib/mjs/providers/storage/indexeddb.d.ts +5 -7
  467. package/lib/mjs/providers/storage/indexeddb.js +4 -0
  468. package/lib/mjs/providers/storage/s3.d.ts +6 -20
  469. package/lib/mjs/providers/storage/s3.js +5 -0
  470. package/lib/mjs/providers/storage/url.d.ts +6 -7
  471. package/lib/mjs/providers/storage/url.js +10 -0
  472. package/lib/mjs/providers/storage/util.d.ts +24 -1
  473. package/lib/mjs/providers/storage/util.js +18 -0
  474. package/lib/mjs/templates/Templates.d.ts +1 -0
  475. package/lib/mjs/translations/en.d.ts +2 -0
  476. package/lib/mjs/translations/en.js +3 -1
  477. package/lib/mjs/utils/ChoicesWrapper.d.ts +1 -1
  478. package/lib/mjs/utils/ChoicesWrapper.js +13 -2
  479. package/lib/mjs/utils/Evaluator.d.ts +6 -3
  480. package/lib/mjs/utils/Evaluator.js +9 -20
  481. package/lib/mjs/utils/builder.d.ts +9 -7
  482. package/lib/mjs/utils/builder.js +10 -5
  483. package/lib/mjs/utils/calendarUtils.d.ts +7 -13
  484. package/lib/mjs/utils/calendarUtils.js +10 -17
  485. package/lib/mjs/utils/formUtils.d.ts +43 -171
  486. package/lib/mjs/utils/formUtils.js +6 -554
  487. package/lib/mjs/utils/utils.d.ts +367 -221
  488. package/lib/mjs/utils/utils.js +329 -222
  489. package/lib/mjs/widgets/CalendarWidget.d.ts +9 -10
  490. package/lib/mjs/widgets/CalendarWidget.js +9 -11
  491. package/package.json +22 -22
  492. package/sdk.d.ts +1 -0
  493. package/utils.d.ts +1 -0
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const compare_versions_1 = require("compare-versions");
9
- const core_1 = require("@formio/core");
10
9
  const EventEmitter_1 = __importDefault(require("./EventEmitter"));
11
10
  const i18n_1 = __importDefault(require("./i18n"));
12
11
  const Formio_1 = require("./Formio");
@@ -18,22 +17,32 @@ const formUtils_1 = require("./utils/formUtils");
18
17
  Formio_1.Formio.forms = {};
19
18
  // Allow people to register components.
20
19
  Formio_1.Formio.registerComponent = Components_1.default.setComponent;
20
+ /**
21
+ *
22
+ * @param {any} icons - The icons to use.
23
+ * @returns {any} - The icon set.
24
+ */
21
25
  function getIconSet(icons) {
22
- if (icons === 'fontawesome') {
23
- return 'fa';
26
+ if (icons === "fontawesome") {
27
+ return "fa";
24
28
  }
25
- return icons || '';
29
+ return icons || "";
26
30
  }
31
+ /**
32
+ *
33
+ * @param {any} options - The options to get.
34
+ * @returns {any} - The options.
35
+ */
27
36
  function getOptions(options) {
28
37
  options = lodash_1.default.defaults(options, {
29
38
  submitOnEnter: false,
30
- iconset: getIconSet((options && options.icons) ? options.icons : Formio_1.Formio.icons),
39
+ iconset: getIconSet(options && options.icons ? options.icons : Formio_1.Formio.icons),
31
40
  i18next: null,
32
41
  saveDraft: false,
33
42
  alwaysDirty: false,
34
43
  saveDraftThrottle: 5000,
35
- display: 'form',
36
- cdnUrl: Formio_1.Formio.cdn.baseUrl
44
+ display: "form",
45
+ cdnUrl: Formio_1.Formio.cdn.baseUrl,
37
46
  });
38
47
  if (!options.events) {
39
48
  options.events = new EventEmitter_1.default();
@@ -53,36 +62,36 @@ function getOptions(options) {
53
62
  * @typedef {{[key: string]: JSON}} JSONObject
54
63
  */
55
64
  /**
56
- * @typedef {Object} FormioHooks
57
- * @property {function} [beforeSubmit]
58
- * @property {function} [beforeCancel]
59
- * @property {function} [beforeNext]
60
- * @property {function} [beforePrev]
61
- * @property {function} [attachComponent]
62
- * @property {function} [setDataValue]
63
- * @property {function} [addComponents]
64
- * @property {function} [addComponent]
65
- * @property {function} [customValidation]
66
- * @property {function} [attachWebform]
65
+ * @typedef {object} FormioHooks
66
+ * @property {Function} [beforeSubmit] - A function that is called before the form is submitted.
67
+ * @property {Function} [beforeCancel] - A function that is called before the form is canceled.
68
+ * @property {Function} [beforeNext] - A function that is called before moving to the next page in a multi-page form.
69
+ * @property {Function} [beforePrev] - A function that is called before moving to the previous page in a multi-page form.
70
+ * @property {Function} [attachComponent] - A function that is called when a component is attached to the form.
71
+ * @property {Function} [setDataValue] - A function that is called when setting the value of a data component.
72
+ * @property {Function} [addComponents] - A function that is called when adding multiple components to the form.
73
+ * @property {Function} [addComponent] - A function that is called when adding a single component to the form.
74
+ * @property {Function} [customValidation] - A function that is called for custom validation of the form.
75
+ * @property {Function} [attachWebform] - A function that is called when attaching a webform to the form.
67
76
  */
68
77
  /**
69
- * @typedef {Object} SanitizeConfig
70
- * @property {string[]} [addAttr]
71
- * @property {string[]} [addTags]
72
- * @property {string[]} [allowedAttrs]
73
- * @property {string[]} [allowedTags]
74
- * @property {string[]} [allowedUriRegex]
75
- * @property {string[]} [addUriSafeAttr]
78
+ * @typedef {object} SanitizeConfig
79
+ * @property {string[]} [addAttr] - The attributes to add.
80
+ * @property {string[]} [addTags] - The tags to add.
81
+ * @property {string[]} [allowedAttrs] - The allowed attributes.
82
+ * @property {string[]} [allowedTags] - The allowed tags.
83
+ * @property {string[]} [allowedUriRegex] - The allowed URI regex.
84
+ * @property {string[]} [addUriSafeAttr] - The URI safe attributes.
76
85
  */
77
86
  /**
78
- * @typedef {Object} ButtonSettings
79
- * @property {boolean} [showPrevious]
80
- * @property {boolean} [showNext]
81
- * @property {boolean} [showCancel]
82
- * @property {boolean} [showSubmit]
87
+ * @typedef {object} ButtonSettings
88
+ * @property {boolean} [showPrevious] - Show the "Previous" button.
89
+ * @property {boolean} [showNext] - Show the "Next" button.
90
+ * @property {boolean} [showCancel] - Show the "Cancel" button.
91
+ * @property {boolean} [showSubmit] - Show the "Submit" button.
83
92
  */
84
93
  /**
85
- * @typedef {Object} FormOptions
94
+ * @typedef {object} FormOptions
86
95
  * @property {boolean} [saveDraft] - Enable the save draft feature.
87
96
  * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
88
97
  * @property {boolean} [readOnly] - Set this form to readOnly.
@@ -100,7 +109,7 @@ function getOptions(options) {
100
109
  * @property {string} [componentErrorClass] - The error class for components.
101
110
  * @property {any} [templates] - The templates for this form.
102
111
  * @property {string} [iconset] - The iconset for this form.
103
- * @property {Component[]} [components] - The components for this form.
112
+ * @property {import('@formio/core').Component[]} [components] - The components for this form.
104
113
  * @property {{[key: string]: boolean}} [disabled] - Disabled components for this form.
105
114
  * @property {boolean} [showHiddenFields] - Show hidden fields.
106
115
  * @property {{[key: string]: boolean}} [hide] - Hidden components for this form.
@@ -117,30 +126,28 @@ function getOptions(options) {
117
126
  * @property {boolean} [sanitize] - Sanitize the form.
118
127
  * @property {SanitizeConfig} [sanitizeConfig] - The sanitize configuration for this form.
119
128
  * @property {ButtonSettings} [buttonSettings] - The button settings for this form.
120
- * @property {Object} [breadCrumbSettings] - The breadcrumb settings for this form.
129
+ * @property {object} [breadcrumbSettings] - The breadcrumb settings for this form.
121
130
  * @property {boolean} [allowPrevious] - Allow the previous button (for Wizard forms).
122
131
  * @property {string[]} [wizardButtonOrder] - The order of the buttons (for Wizard forms).
123
132
  * @property {boolean} [showCheckboxBackground] - Show the checkbox background.
133
+ * @property {boolean} [inputsOnly] - Only show inputs in the form and no labels.
134
+ * @property {boolean} [building] - If we are in the process of building the form.
124
135
  * @property {number} [zoom] - The zoom for PDF forms.
125
136
  */
126
- /**
127
- * Renders a Form.io form within the webpage.
128
- */
129
137
  class Webform extends NestedDataComponent_1.default {
130
138
  /**
131
139
  * Creates a new Form instance.
132
- *
133
- * @param {HTMLElement | Object | FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
134
- * @param {FormOptions} [options] - The options to create a new form instance.
140
+ * @param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
141
+ * @param {import('Form').FormOptions} [options] - The options to create a new form instance.
135
142
  */
136
- constructor(elementOrOptions, options) {
143
+ constructor(elementOrOptions, options = undefined) {
137
144
  let element, formOptions;
138
145
  if (elementOrOptions instanceof HTMLElement || options) {
139
146
  element = elementOrOptions;
140
- formOptions = options;
147
+ formOptions = options || {};
141
148
  }
142
149
  else {
143
- formOptions = elementOrOptions;
150
+ formOptions = elementOrOptions || {};
144
151
  }
145
152
  super(null, getOptions(formOptions));
146
153
  this.executeShortcuts = (event) => {
@@ -150,15 +157,15 @@ class Webform extends NestedDataComponent_1.default {
150
157
  }
151
158
  const ctrl = event.ctrlKey || event.metaKey;
152
159
  const keyCode = event.keyCode;
153
- let char = '';
160
+ let char = "";
154
161
  if (65 <= keyCode && keyCode <= 90) {
155
162
  char = String.fromCharCode(keyCode);
156
163
  }
157
164
  else if (keyCode === 13) {
158
- char = 'Enter';
165
+ char = "Enter";
159
166
  }
160
167
  else if (keyCode === 27) {
161
- char = 'Esc';
168
+ char = "Esc";
162
169
  }
163
170
  lodash_1.default.each(this.shortcuts, (shortcut) => {
164
171
  if (shortcut.ctrl && !ctrl) {
@@ -181,12 +188,12 @@ class Webform extends NestedDataComponent_1.default {
181
188
  * The type of this element.
182
189
  * @type {string}
183
190
  */
184
- this.type = 'form';
185
- this._src = '';
191
+ this.type = "form";
192
+ this._src = "";
186
193
  this._loading = false;
187
194
  this._form = {};
188
195
  this.draftEnabled = false;
189
- this.savingDraft = true;
196
+ this.savingDraft = false;
190
197
  if (this.options.saveDraftThrottle) {
191
198
  this.triggerSaveDraft = lodash_1.default.throttle(this.saveDraft.bind(this), this.options.saveDraftThrottle);
192
199
  }
@@ -200,13 +207,11 @@ class Webform extends NestedDataComponent_1.default {
200
207
  this.nosubmit = false;
201
208
  /**
202
209
  * Determines if the form has tried to be submitted, error or not.
203
- *
204
210
  * @type {boolean}
205
211
  */
206
212
  this.submitted = false;
207
213
  /**
208
214
  * Determines if the form is being submitted at the moment.
209
- *
210
215
  * @type {boolean}
211
216
  */
212
217
  this.submitting = false;
@@ -238,7 +243,6 @@ class Webform extends NestedDataComponent_1.default {
238
243
  /**
239
244
  * Promise that executes when the form is ready and rendered.
240
245
  * @type {Promise}
241
- *
242
246
  * @example
243
247
  * import Webform from '@formio/js/Webform';
244
248
  * let form = new Webform(document.getElementById('formio'));
@@ -250,21 +254,18 @@ class Webform extends NestedDataComponent_1.default {
250
254
  this.formReady = new Promise((resolve, reject) => {
251
255
  /**
252
256
  * Called when the formReady state of this form has been resolved.
253
- *
254
- * @type {function}
257
+ * @type {Function}
255
258
  */
256
259
  this.formReadyResolve = resolve;
257
260
  /**
258
261
  * Called when this form could not load and is rejected.
259
- *
260
- * @type {function}
262
+ * @type {Function}
261
263
  */
262
264
  this.formReadyReject = reject;
263
265
  });
264
266
  /**
265
267
  * Promise that executes when the submission is ready and rendered.
266
268
  * @type {Promise}
267
- *
268
269
  * @example
269
270
  * import Webform from '@formio/js/Webform';
270
271
  * let form = new Webform(document.getElementById('formio'));
@@ -276,14 +277,12 @@ class Webform extends NestedDataComponent_1.default {
276
277
  this.submissionReady = new Promise((resolve, reject) => {
277
278
  /**
278
279
  * Called when the formReady state of this form has been resolved.
279
- *
280
- * @type {function}
280
+ * @type {Function}
281
281
  */
282
282
  this.submissionReadyResolve = resolve;
283
283
  /**
284
284
  * Called when this form could not load and is rejected.
285
- *
286
- * @type {function}
285
+ * @type {Function}
287
286
  */
288
287
  this.submissionReadyReject = reject;
289
288
  });
@@ -292,20 +291,19 @@ class Webform extends NestedDataComponent_1.default {
292
291
  this.language = this.i18next.language;
293
292
  // See if we need to restore the draft from a user.
294
293
  if (this.options.saveDraft) {
295
- this.formReady.then(() => {
296
- if (!this.options.skipDraftRestore) {
294
+ if (this.options.skipDraftRestore) {
295
+ this.draftEnabled = true;
296
+ this.savingDraft = false;
297
+ }
298
+ else {
299
+ this.formReady.then(() => {
297
300
  const user = Formio_1.Formio.getUser();
298
301
  // Only restore a draft if the submission isn't explicitly set.
299
302
  if (user && !this.submissionSet) {
300
303
  this.restoreDraft(user._id);
301
304
  }
302
- }
303
- else {
304
- // Enable drafts
305
- this.draftEnabled = true;
306
- this.savingDraft = false;
307
- }
308
- });
305
+ });
306
+ }
309
307
  }
310
308
  this.component.clearOnHide = false;
311
309
  // Ensure the root is set to this component.
@@ -324,9 +322,7 @@ class Webform extends NestedDataComponent_1.default {
324
322
  }
325
323
  /**
326
324
  * Sets the language for this form.
327
- *
328
- * @param lang
329
- * @return {Promise}
325
+ * @param {string} lang - The language to use (e.g. 'en', 'sp', etc.)
330
326
  */
331
327
  set language(lang) {
332
328
  if (!this.i18next) {
@@ -341,7 +337,7 @@ class Webform extends NestedDataComponent_1.default {
341
337
  return;
342
338
  }
343
339
  this.rebuild();
344
- this.emit('languageChanged');
340
+ this.emit("languageChanged");
345
341
  });
346
342
  }
347
343
  get componentComponents() {
@@ -352,31 +348,25 @@ class Webform extends NestedDataComponent_1.default {
352
348
  }
353
349
  /**
354
350
  * Add a language for translations
355
- *
356
- * @param code
357
- * @param lang
358
- * @param active
359
- * @return {*}
351
+ * @param {string} code - The language code for the language being added.
352
+ * @param {object} lang - The language translations.
353
+ * @param {boolean} [active] - If this language should be set as the active language.
360
354
  */
361
355
  addLanguage(code, lang, active = false) {
362
356
  if (this.i18next) {
363
357
  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);
358
+ this.i18next.addResourceBundle(code, "translation", translations, true, true);
365
359
  if (active) {
366
360
  this.language = code;
367
361
  }
368
362
  }
369
363
  }
370
364
  keyboardCatchableElement(element) {
371
- if (element.nodeName === 'TEXTAREA') {
365
+ if (element.nodeName === "TEXTAREA") {
372
366
  return false;
373
367
  }
374
- if (element.nodeName === 'INPUT') {
375
- return [
376
- 'text',
377
- 'email',
378
- 'password'
379
- ].indexOf(element.type) === -1;
368
+ if (element.nodeName === "INPUT") {
369
+ return ["text", "email", "password"].indexOf(element.type) === -1;
380
370
  }
381
371
  return true;
382
372
  }
@@ -385,21 +375,21 @@ class Webform extends NestedDataComponent_1.default {
385
375
  return;
386
376
  }
387
377
  shortcut = lodash_1.default.capitalize(shortcut);
388
- if (shortcut === 'Enter' || shortcut === 'Esc') {
378
+ if (shortcut === "Enter" || shortcut === "Esc") {
389
379
  // Restrict Enter and Esc only for buttons
390
- if (element.tagName !== 'BUTTON') {
380
+ if (element.tagName !== "BUTTON") {
391
381
  return;
392
382
  }
393
383
  this.shortcuts.push({
394
384
  shortcut,
395
- element
385
+ element,
396
386
  });
397
387
  }
398
388
  else {
399
389
  this.shortcuts.push({
400
390
  ctrl: true,
401
391
  shortcut,
402
- element
392
+ element,
403
393
  });
404
394
  }
405
395
  }
@@ -409,24 +399,27 @@ class Webform extends NestedDataComponent_1.default {
409
399
  }
410
400
  lodash_1.default.remove(this.shortcuts, {
411
401
  shortcut,
412
- element
402
+ element,
413
403
  });
414
404
  }
415
405
  /**
416
406
  * Get the embed source of the form.
417
- *
418
- * @returns {string}
407
+ * @returns {string} - The source of the form.
419
408
  */
420
409
  get src() {
421
410
  return this._src;
422
411
  }
423
412
  /**
424
413
  * Loads the submission if applicable.
414
+ * @returns {Promise} - The promise that is triggered when the submission is loaded.
425
415
  */
426
416
  loadSubmission() {
427
417
  this.loadingSubmission = true;
428
418
  if (this.formio.submissionId) {
429
- this.onSubmission = this.formio.loadSubmission().then((submission) => this.setSubmission(submission), (err) => this.submissionReadyReject(err)).catch((err) => this.submissionReadyReject(err));
419
+ this.onSubmission = this.formio
420
+ .loadSubmission()
421
+ .then((submission) => this.setSubmission(submission), (err) => this.submissionReadyReject(err))
422
+ .catch((err) => this.submissionReadyReject(err));
430
423
  }
431
424
  else {
432
425
  this.submissionReadyResolve();
@@ -435,18 +428,21 @@ class Webform extends NestedDataComponent_1.default {
435
428
  }
436
429
  /**
437
430
  * Set the src of the form renderer.
438
- *
439
- * @param value
440
- * @param options
431
+ * @param {string} value - The source value to set.
432
+ * @param {any} options - The options to set.
433
+ * @returns {Promise} - The promise that is triggered when the form is set.
441
434
  */
442
435
  setSrc(value, options) {
443
436
  if (this.setUrl(value, options)) {
444
437
  this.nosubmit = false;
445
- return this.formio.loadForm({ params: { live: 1 } }).then((form) => {
438
+ return this.formio
439
+ .loadForm({ params: { live: 1 } })
440
+ .then((form) => {
446
441
  const setForm = this.setForm(form);
447
442
  this.loadSubmission();
448
443
  return setForm;
449
- }).catch((err) => {
444
+ })
445
+ .catch((err) => {
450
446
  console.warn(err);
451
447
  this.formReadyReject(err);
452
448
  });
@@ -455,9 +451,7 @@ class Webform extends NestedDataComponent_1.default {
455
451
  }
456
452
  /**
457
453
  * Set the Form source, which is typically the Form.io embed URL.
458
- *
459
454
  * @param {string} value - The value of the form embed url.
460
- *
461
455
  * @example
462
456
  * import Webform from '@formio/js/Webform';
463
457
  * let form = new Webform(document.getElementById('formio'));
@@ -471,28 +465,25 @@ class Webform extends NestedDataComponent_1.default {
471
465
  }
472
466
  /**
473
467
  * Get the embed source of the form.
474
- *
475
- * @returns {string}
468
+ * @returns {string} - returns the source of the form.
476
469
  */
477
470
  get url() {
478
471
  return this._src;
479
472
  }
480
473
  /**
481
474
  * Sets the url of the form renderer.
482
- *
483
- * @param value
484
- * @param options
475
+ * @param {string} value - The value to set the url to.
476
+ * @param {any} options - The options to set.
477
+ * @returns {boolean} - TRUE means the url was set, FALSE otherwise.
485
478
  */
486
479
  setUrl(value, options) {
487
- if (!value ||
488
- (typeof value !== 'string') ||
489
- (value === this._src)) {
480
+ if (!value || typeof value !== "string" || value === this._src) {
490
481
  return false;
491
482
  }
492
483
  this._src = value;
493
484
  this.nosubmit = true;
494
485
  this.formio = this.options.formio = new Formio_1.Formio(value, options);
495
- if (this.type === 'form') {
486
+ if (this.type === "form") {
496
487
  // Set the options source so this can be passed to other components.
497
488
  this.options.src = value;
498
489
  }
@@ -500,7 +491,6 @@ class Webform extends NestedDataComponent_1.default {
500
491
  }
501
492
  /**
502
493
  * Set the form source but don't initialize the form and submission from the url.
503
- *
504
494
  * @param {string} value - The value of the form embed url.
505
495
  */
506
496
  set url(value) {
@@ -508,7 +498,6 @@ class Webform extends NestedDataComponent_1.default {
508
498
  }
509
499
  /**
510
500
  * Called when both the form and submission have been loaded.
511
- *
512
501
  * @returns {Promise} - The promise to trigger when both form and submission have loaded.
513
502
  */
514
503
  get ready() {
@@ -520,7 +509,6 @@ class Webform extends NestedDataComponent_1.default {
520
509
  }
521
510
  /**
522
511
  * Returns if this form is loading.
523
- *
524
512
  * @returns {boolean} - TRUE means the form is loading, FALSE otherwise.
525
513
  */
526
514
  get loading() {
@@ -528,18 +516,17 @@ class Webform extends NestedDataComponent_1.default {
528
516
  }
529
517
  /**
530
518
  * Set the loading state for this form, and also show the loader spinner.
531
- *
532
519
  * @param {boolean} loading - If this form should be "loading" or not.
533
520
  */
534
521
  set loading(loading) {
535
522
  if (this._loading !== loading) {
536
523
  this._loading = loading;
537
524
  if (!this.loader && loading) {
538
- this.loader = this.ce('div', {
539
- class: 'loader-wrapper'
525
+ this.loader = this.ce("div", {
526
+ class: "loader-wrapper",
540
527
  });
541
- const spinner = this.ce('div', {
542
- class: 'loader text-center'
528
+ const spinner = this.ce("div", {
529
+ class: "loader text-center",
543
530
  });
544
531
  this.loader.appendChild(spinner);
545
532
  }
@@ -562,7 +549,6 @@ class Webform extends NestedDataComponent_1.default {
562
549
  }
563
550
  /**
564
551
  * Sets the JSON schema for the form to be rendered.
565
- *
566
552
  * @example
567
553
  * import Webform from '@formio/js/Webform';
568
554
  * let form = new Webform(document.getElementById('formio'));
@@ -590,12 +576,11 @@ class Webform extends NestedDataComponent_1.default {
590
576
  * }
591
577
  * ]
592
578
  * });
593
- *
594
- * @param {Object} form - The JSON schema of the form @see https://examples.form.io/example for an example JSON schema.
595
- * @param flags
596
- * @returns {*}
579
+ * @param {object} form - The JSON schema of the form @see https://examples.form.io/example for an example JSON schema.
580
+ * @param {any} flags - Any flags to apply when setting the form.
581
+ * @returns {Promise} - The promise that is triggered when the form is set.
597
582
  */
598
- setForm(form, flags) {
583
+ setForm(form, flags = {}) {
599
584
  var _a, _b, _c;
600
585
  const isFormAlreadySet = this._form && ((_a = this._form.components) === null || _a === void 0 ? void 0 : _a.length);
601
586
  try {
@@ -626,17 +611,19 @@ class Webform extends NestedDataComponent_1.default {
626
611
  }
627
612
  // Use the sanitize config from the form settings or the global sanitize config if it is not provided in the options
628
613
  if (!this.options.sanitizeConfig && !this.builderMode) {
629
- this.options.sanitizeConfig = lodash_1.default.get(form, 'settings.sanitizeConfig') || lodash_1.default.get(form, 'globalSettings.sanitizeConfig');
614
+ this.options.sanitizeConfig =
615
+ lodash_1.default.get(form, "settings.sanitizeConfig") ||
616
+ lodash_1.default.get(form, "globalSettings.sanitizeConfig");
630
617
  }
631
- if ('schema' in form && (0, compare_versions_1.compareVersions)(form.schema, '1.x') > 0) {
618
+ if ("schema" in form && (0, compare_versions_1.compareVersions)(form.schema, "1.x") > 0) {
632
619
  this.ready.then(() => {
633
- this.setAlert('alert alert-danger', 'Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.');
620
+ this.setAlert("alert alert-danger", "Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.");
634
621
  });
635
622
  }
636
623
  // See if they pass a module, and evaluate it if so.
637
624
  if (form && form.module) {
638
625
  let formModule = null;
639
- if (typeof form.module === 'string') {
626
+ if (typeof form.module === "string") {
640
627
  try {
641
628
  formModule = this.evaluate(`return ${form.module}`);
642
629
  }
@@ -658,7 +645,7 @@ class Webform extends NestedDataComponent_1.default {
658
645
  this.initialized = false;
659
646
  const rebuild = this.rebuild() || Promise.resolve();
660
647
  return rebuild.then(() => {
661
- this.emit('formLoad', form);
648
+ this.emit("formLoad", form);
662
649
  this.triggerCaptcha();
663
650
  // Make sure to trigger onChange after a render event occurs to speed up form rendering.
664
651
  setTimeout(() => {
@@ -670,37 +657,33 @@ class Webform extends NestedDataComponent_1.default {
670
657
  }
671
658
  /**
672
659
  * Gets the form object.
673
- *
674
- * @returns {Object} - The form JSON schema.
660
+ * @returns {object} - The form JSON schema.
675
661
  */
676
662
  get form() {
677
663
  if (!this._form) {
678
664
  this._form = {
679
- components: []
665
+ components: [],
680
666
  };
681
667
  }
682
668
  return this._form;
683
669
  }
684
670
  /**
685
671
  * Sets the form value.
686
- *
687
672
  * @alias setForm
688
- * @param {Object} form - The form schema object.
673
+ * @param {object} form - The form schema object.
689
674
  */
690
675
  set form(form) {
691
676
  this.setForm(form);
692
677
  }
693
678
  /**
694
679
  * Returns the submission object that was set within this form.
695
- *
696
- * @returns {Object}
680
+ * @returns {object} - The submission object.
697
681
  */
698
682
  get submission() {
699
683
  return this.getValue();
700
684
  }
701
685
  /**
702
686
  * Sets the submission of a form.
703
- *
704
687
  * @example
705
688
  * import Webform from '@formio/js/Webform';
706
689
  * let form = new Webform(document.getElementById('formio'));
@@ -710,17 +693,15 @@ class Webform extends NestedDataComponent_1.default {
710
693
  * lastName: 'Smith',
711
694
  * email: 'joe@example.com'
712
695
  * }};
713
- *
714
- * @param {Object} submission - The Form.io submission object.
696
+ * @param {object} submission - The Form.io submission object.
715
697
  */
716
698
  set submission(submission) {
717
699
  this.setSubmission(submission);
718
700
  }
719
701
  /**
720
702
  * Sets the submission value
721
- *
722
- * @param {Object | null | undefined} submission
723
- * @param {Object | null | undefined} flags
703
+ * @param {object|null|undefined} submission - The submission to set.
704
+ * @param {object|null|undefined} flags - Any flags to apply when setting the submission.
724
705
  * @return {void}
725
706
  */
726
707
  onSetSubmission(submission, flags = {}) {
@@ -731,104 +712,108 @@ class Webform extends NestedDataComponent_1.default {
731
712
  }
732
713
  /**
733
714
  * Sets a submission and returns the promise when it is ready.
734
- * @param submission
735
- * @param flags
736
- * @return {Promise.<TResult>}
715
+ * @param {any} submission - The submission to set.
716
+ * @param {any} flags - Any flags to apply when setting the submission.
717
+ * @returns {Promise} - The promise that is triggered when the submission is set.
737
718
  */
738
719
  setSubmission(submission, flags = {}) {
739
- flags = Object.assign(Object.assign({}, flags), { fromSubmission: lodash_1.default.has(flags, 'fromSubmission') ? flags.fromSubmission : true });
740
- return this.onSubmission = this.formReady.then((resolveFlags) => {
720
+ flags = Object.assign(Object.assign({}, flags), { fromSubmission: lodash_1.default.has(flags, "fromSubmission") ? flags.fromSubmission : true });
721
+ return (this.onSubmission = this.formReady
722
+ .then((resolveFlags) => {
741
723
  if (resolveFlags) {
742
724
  flags = Object.assign(Object.assign({}, flags), resolveFlags);
743
725
  }
744
726
  this.onSetSubmission(submission, flags);
745
727
  return this.submissionReadyResolve(submission);
746
- }, (err) => this.submissionReadyReject(err)).catch((err) => this.submissionReadyReject(err));
728
+ }, (err) => this.submissionReadyReject(err))
729
+ .catch((err) => this.submissionReadyReject(err)));
747
730
  }
748
731
  handleDraftError(errName, errDetails, restoreDraft) {
749
- const errorMessage = lodash_1.default.trim(`${this.t(errName)} ${errDetails || ''}`);
732
+ const errorMessage = lodash_1.default.trim(`${this.t(errName)} ${errDetails || ""}`);
750
733
  console.warn(errorMessage);
751
- this.emit(restoreDraft ? 'restoreDraftError' : 'saveDraftError', errDetails || errorMessage);
734
+ this.emit(restoreDraft ? "restoreDraftError" : "saveDraftError", errDetails || errorMessage);
752
735
  }
753
- /**
754
- * Saves a submission draft.
755
- */
756
736
  saveDraft() {
757
737
  if (!this.draftEnabled) {
758
738
  return;
759
739
  }
760
740
  if (!this.formio) {
761
- this.handleDraftError('saveDraftInstanceError');
741
+ this.handleDraftError("saveDraftInstanceError");
762
742
  return;
763
743
  }
764
744
  if (!Formio_1.Formio.getUser()) {
765
- this.handleDraftError('saveDraftAuthError');
745
+ this.handleDraftError("saveDraftAuthError");
766
746
  return;
767
747
  }
768
748
  const draft = (0, utils_1.fastCloneDeep)(this.submission);
769
- draft.state = 'draft';
749
+ draft.state = "draft";
770
750
  if (!this.savingDraft && !this.submitting) {
771
- this.emit('saveDraftBegin');
751
+ this.emit("saveDraftBegin");
772
752
  this.savingDraft = true;
773
- this.formio.saveSubmission(draft).then((sub) => {
753
+ this.formio
754
+ .saveSubmission(draft)
755
+ .then((sub) => {
774
756
  // Set id to submission to avoid creating new draft submission
775
757
  this.submission._id = sub._id;
776
758
  this.savingDraft = false;
777
- this.emit('saveDraft', sub);
759
+ this.emit("saveDraft", sub);
778
760
  })
779
- .catch(err => {
761
+ .catch((err) => {
780
762
  this.savingDraft = false;
781
- this.handleDraftError('saveDraftError', err);
763
+ this.handleDraftError("saveDraftError", err);
782
764
  });
783
765
  }
784
766
  }
785
767
  /**
786
768
  * Restores a draft submission based on the user who is authenticated.
787
- *
788
- * @param {userId} - The user id where we need to restore the draft from.
769
+ * @param {string} userId - The user id where we need to restore the draft from.
789
770
  */
790
771
  restoreDraft(userId) {
791
772
  const formio = this.formio || this.options.formio;
792
773
  if (!formio) {
793
- this.handleDraftError('restoreDraftInstanceError', null, true);
774
+ this.handleDraftError("restoreDraftInstanceError", null, true);
794
775
  return;
795
776
  }
796
777
  this.savingDraft = true;
797
- formio.loadSubmissions({
778
+ formio
779
+ .loadSubmissions({
798
780
  params: {
799
781
  state: 'draft',
800
782
  owner: userId,
801
783
  sort: '-created'
802
- }
803
- }).then(submissions => {
784
+ },
785
+ })
786
+ .then((submissions) => {
804
787
  if (submissions.length > 0 && !this.options.skipDraftRestore) {
805
788
  const draft = (0, utils_1.fastCloneDeep)(submissions[0]);
806
789
  return this.setSubmission(draft).then(() => {
807
790
  this.draftEnabled = true;
808
791
  this.savingDraft = false;
809
- this.emit('restoreDraft', draft);
792
+ this.emit("restoreDraft", draft);
810
793
  });
811
794
  }
812
795
  // Enable drafts so that we can keep track of changes.
813
796
  this.draftEnabled = true;
814
797
  this.savingDraft = false;
815
- this.emit('restoreDraft', null);
798
+ this.emit("restoreDraft", null);
816
799
  })
817
- .catch(err => {
800
+ .catch((err) => {
818
801
  this.draftEnabled = true;
819
802
  this.savingDraft = false;
820
- this.handleDraftError('restoreDraftError', err, true);
803
+ this.handleDraftError("restoreDraftError", err, true);
821
804
  });
822
805
  }
823
806
  get schema() {
824
- const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, ['components']));
807
+ const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, ["components"]));
825
808
  schema.components = [];
826
809
  this.eachComponent((component) => schema.components.push(component.schema));
827
810
  return schema;
828
811
  }
829
812
  mergeData(_this, _that) {
830
813
  lodash_1.default.mergeWith(_this, _that, (thisValue, thatValue) => {
831
- if (Array.isArray(thisValue) && Array.isArray(thatValue) && thisValue.length !== thatValue.length) {
814
+ if (Array.isArray(thisValue) &&
815
+ Array.isArray(thatValue) &&
816
+ thisValue.length !== thatValue.length) {
832
817
  return thatValue;
833
818
  }
834
819
  });
@@ -841,9 +826,7 @@ class Webform extends NestedDataComponent_1.default {
841
826
  };
842
827
  }
843
828
  // Metadata needs to be available before setValue
844
- this._submission.metadata = submission.metadata
845
- ? lodash_1.default.cloneDeep(submission.metadata)
846
- : {};
829
+ this._submission.metadata = submission.metadata ? lodash_1.default.cloneDeep(submission.metadata) : {};
847
830
  this.editing = !!submission._id;
848
831
  // Set the timezone in the options if available.
849
832
  if (!this.options.submissionTimezone &&
@@ -872,6 +855,7 @@ class Webform extends NestedDataComponent_1.default {
872
855
  }
873
856
  /**
874
857
  * Build the form.
858
+ * @returns {Promise} - The promise that is triggered when the form is built.
875
859
  */
876
860
  init() {
877
861
  if (this.options.submission) {
@@ -893,28 +877,31 @@ class Webform extends NestedDataComponent_1.default {
893
877
  else {
894
878
  this.component = this.form;
895
879
  }
896
- this.component.type = 'form';
880
+ this.component.type = "form";
897
881
  this.component.input = false;
898
882
  this.addComponents();
899
- this.on('submitButton', options => {
900
- this.submit(false, options).catch(e => {
883
+ this.on("submitButton", (options) => {
884
+ this.submit(false, options).catch((e) => {
901
885
  options.instance.loading = false;
902
886
  return e !== false && e !== undefined && console.log(e);
903
887
  });
904
888
  }, true);
905
- this.on('checkValidity', (data) => this.validate(data, { dirty: true, process: 'change' }), true);
906
- this.on('requestUrl', (args) => (this.submitUrl(args.url, args.headers)), true);
907
- this.on('resetForm', () => this.resetValue(), true);
908
- this.on('deleteSubmission', () => this.deleteSubmission(), true);
909
- this.on('refreshData', () => this.updateValue(), true);
889
+ this.on("checkValidity", (data) => this.validate(data, { dirty: true, process: "change" }), true);
890
+ this.on("requestUrl", (args) => this.submitUrl(args.url, args.headers), true);
891
+ this.on("resetForm", () => this.resetValue(), true);
892
+ this.on("deleteSubmission", () => this.deleteSubmission(), true);
893
+ this.on("refreshData", () => this.updateValue(), true);
910
894
  this.executeFormController();
911
895
  return this.formReady;
912
896
  }
913
897
  executeFormController() {
914
898
  // If no controller value or
915
899
  // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
916
- if (!this.form || !this.form.controller
917
- || ((!this.visible || this.component.hidden) && this.component.clearOnHide && !this.rootPristine)) {
900
+ if (!this.form ||
901
+ !this.form.controller ||
902
+ ((!this.visible || this.component.hidden) &&
903
+ this.component.clearOnHide &&
904
+ !this.rootPristine)) {
918
905
  return false;
919
906
  }
920
907
  this.formReady.then(() => {
@@ -924,20 +911,23 @@ class Webform extends NestedDataComponent_1.default {
924
911
  });
925
912
  });
926
913
  }
914
+ /**
915
+ *
916
+ */
927
917
  teardown() {
928
- this.emit('formDelete', this.id);
918
+ this.emit("formDelete", this.id);
929
919
  delete Formio_1.Formio.forms[this.id];
930
920
  delete this.executeShortcuts;
931
921
  delete this.triggerSaveDraft;
932
922
  super.teardown();
933
923
  }
934
924
  destroy(all = false) {
935
- this.off('submitButton');
936
- this.off('checkValidity');
937
- this.off('requestUrl');
938
- this.off('resetForm');
939
- this.off('deleteSubmission');
940
- this.off('refreshData');
925
+ this.off("submitButton");
926
+ this.off("checkValidity");
927
+ this.off("requestUrl");
928
+ this.off("resetForm");
929
+ this.off("deleteSubmission");
930
+ this.off("refreshData");
941
931
  return super.destroy(all);
942
932
  }
943
933
  build(element) {
@@ -950,17 +940,17 @@ class Webform extends NestedDataComponent_1.default {
950
940
  return this.ready;
951
941
  }
952
942
  getClassName() {
953
- let classes = 'formio-form';
943
+ let classes = "formio-form";
954
944
  if (this.options.readOnly) {
955
- classes += ' formio-read-only';
945
+ classes += " formio-read-only";
956
946
  }
957
947
  return classes;
958
948
  }
959
949
  render() {
960
- return super.render(this.renderTemplate('webform', {
950
+ return super.render(this.renderTemplate("webform", {
961
951
  classes: this.getClassName(),
962
952
  children: this.renderComponents(),
963
- }), this.builderMode ? 'builder' : 'form', true);
953
+ }), this.builderMode ? "builder" : "form", true);
964
954
  }
965
955
  redraw() {
966
956
  // Don't bother if we have not built yet.
@@ -973,13 +963,13 @@ class Webform extends NestedDataComponent_1.default {
973
963
  }
974
964
  attach(element) {
975
965
  this.setElement(element);
976
- this.loadRefs(element, { webform: 'single' });
966
+ this.loadRefs(element, { webform: "single" });
977
967
  const childPromise = this.attachComponents(this.refs.webform);
978
- this.addEventListener(document, 'keydown', this.executeShortcuts);
968
+ this.addEventListener(document, "keydown", this.executeShortcuts);
979
969
  this.currentForm = this;
980
- this.hook('attachWebform', element, this);
970
+ this.hook("attachWebform", element, this);
981
971
  return childPromise.then(() => {
982
- this.emit('render', this.element);
972
+ this.emit("render", this.element);
983
973
  return this.setValue(this._submission, {
984
974
  noUpdateEvent: true,
985
975
  });
@@ -996,24 +986,23 @@ class Webform extends NestedDataComponent_1.default {
996
986
  return result;
997
987
  }
998
988
  resetValue() {
999
- lodash_1.default.each(this.getComponents(), (comp) => (comp.resetValue()));
989
+ lodash_1.default.each(this.getComponents(), (comp) => comp.resetValue());
1000
990
  this.setPristine(true);
1001
991
  this.onChange({ resetValue: true });
1002
992
  }
1003
993
  /**
1004
994
  * Sets a new alert to display in the error dialog of the form.
1005
- *
1006
995
  * @param {string} type - The type of alert to display. "danger", "success", "warning", etc.
1007
996
  * @param {string} message - The message to show in the alert.
1008
- * @param {Object} options
997
+ * @param {object} options - The options for the alert.
1009
998
  */
1010
999
  setAlert(type, message, options) {
1011
1000
  if (!type && this.submitted) {
1012
1001
  if (this.alert) {
1013
1002
  if (this.refs.errorRef && this.refs.errorRef.length) {
1014
- this.refs.errorRef.forEach(el => {
1015
- this.removeEventListener(el, 'click');
1016
- this.removeEventListener(el, 'keypress');
1003
+ this.refs.errorRef.forEach((el) => {
1004
+ this.removeEventListener(el, "click");
1005
+ this.removeEventListener(el, "keypress");
1017
1006
  });
1018
1007
  }
1019
1008
  this.removeChild(this.alert);
@@ -1023,16 +1012,16 @@ class Webform extends NestedDataComponent_1.default {
1023
1012
  }
1024
1013
  if (this.options.noAlerts) {
1025
1014
  if (!message) {
1026
- this.emit('error', false);
1015
+ this.emit("error", false);
1027
1016
  }
1028
1017
  return;
1029
1018
  }
1030
1019
  if (this.alert) {
1031
1020
  try {
1032
1021
  if (this.refs.errorRef && this.refs.errorRef.length) {
1033
- this.refs.errorRef.forEach(el => {
1034
- this.removeEventListener(el, 'click');
1035
- this.removeEventListener(el, 'keypress');
1022
+ this.refs.errorRef.forEach((el) => {
1023
+ this.removeEventListener(el, "click");
1024
+ this.removeEventListener(el, "keypress");
1036
1025
  });
1037
1026
  }
1038
1027
  this.removeChild(this.alert);
@@ -1050,21 +1039,21 @@ class Webform extends NestedDataComponent_1.default {
1050
1039
  const templateOptions = {
1051
1040
  message: message instanceof HTMLElement ? message.outerHTML : message,
1052
1041
  attrs: attrs,
1053
- type
1042
+ type,
1054
1043
  };
1055
- this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate('alert', templateOptions), `#${attrs.id}`);
1044
+ this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate("alert", templateOptions), `#${attrs.id}`);
1056
1045
  }
1057
1046
  if (!this.alert) {
1058
1047
  return;
1059
1048
  }
1060
- this.loadRefs(this.alert, { errorRef: 'multiple' });
1049
+ this.loadRefs(this.alert, { errorRef: "multiple" });
1061
1050
  if (this.refs.errorRef && this.refs.errorRef.length) {
1062
- this.refs.errorRef.forEach(el => {
1063
- this.addEventListener(el, 'click', (e) => {
1051
+ this.refs.errorRef.forEach((el) => {
1052
+ this.addEventListener(el, "click", (e) => {
1064
1053
  const key = e.currentTarget.dataset.componentKey;
1065
1054
  this.focusOnComponent(key);
1066
1055
  });
1067
- this.addEventListener(el, 'keydown', (e) => {
1056
+ this.addEventListener(el, "keydown", (e) => {
1068
1057
  if (e.keyCode === 13) {
1069
1058
  e.preventDefault();
1070
1059
  const key = e.currentTarget.dataset.componentKey;
@@ -1077,9 +1066,7 @@ class Webform extends NestedDataComponent_1.default {
1077
1066
  }
1078
1067
  /**
1079
1068
  * Focus on selected component.
1080
- *
1081
1069
  * @param {string} key - The key of selected component.
1082
- * @returns {*}
1083
1070
  */
1084
1071
  focusOnComponent(key) {
1085
1072
  if (key) {
@@ -1091,11 +1078,16 @@ class Webform extends NestedDataComponent_1.default {
1091
1078
  }
1092
1079
  /**
1093
1080
  * Show the errors of this form within the alert dialog.
1094
- *
1095
- * @param {Object} error - An optional additional error to display along with the component errors.
1081
+ * @param {object} error - An optional additional error to display along with the component errors.
1096
1082
  * @returns {*}
1097
1083
  */
1098
1084
  /* eslint-disable no-unused-vars */
1085
+ /**
1086
+ *
1087
+ * @param {Array} errors - An array of errors to display.
1088
+ * @param {boolean} triggerEvent - Whether or not to trigger the error event.
1089
+ * @returns {void|Array} - The errors that were set.
1090
+ */
1099
1091
  showErrors(errors, triggerEvent) {
1100
1092
  this.loading = false;
1101
1093
  if (!Array.isArray(errors)) {
@@ -1132,43 +1124,47 @@ class Webform extends NestedDataComponent_1.default {
1132
1124
  });
1133
1125
  const displayedErrors = [];
1134
1126
  if (errors.length) {
1135
- errors = lodash_1.default.uniqBy(errors, error => error.message);
1127
+ errors = lodash_1.default.uniqBy(errors, (error) => error.message);
1136
1128
  const createListItem = (message, index) => {
1137
1129
  var _a, _b, _c;
1138
1130
  const err = errors[index];
1139
1131
  const messageFromIndex = !lodash_1.default.isUndefined(index) && errors && errors[index];
1140
- const keyOrPath = ((messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.formattedKeyOrPath) || (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.path) || ((_a = messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.context) === null || _a === void 0 ? void 0 : _a.path)) || (((_b = err.context) === null || _b === void 0 ? void 0 : _b.component) && ((_c = err.context) === null || _c === void 0 ? void 0 : _c.component.key)) || (err.component && err.component.key) || err.fromServer && err.path;
1141
- const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : '';
1142
- if (typeof err !== 'string' && !err.formattedKeyOrPath) {
1132
+ const keyOrPath = (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.formattedKeyOrPath) ||
1133
+ (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.path) ||
1134
+ ((_a = messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.context) === null || _a === void 0 ? void 0 : _a.path) ||
1135
+ (((_b = err.context) === null || _b === void 0 ? void 0 : _b.component) && ((_c = err.context) === null || _c === void 0 ? void 0 : _c.component.key)) ||
1136
+ (err.component && err.component.key) ||
1137
+ (err.fromServer && err.path);
1138
+ const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : "";
1139
+ if (typeof err !== "string" && !err.formattedKeyOrPath) {
1143
1140
  err.formattedKeyOrPath = formattedKeyOrPath;
1144
1141
  }
1145
1142
  return {
1146
1143
  message: (0, utils_1.unescapeHTML)(message),
1147
- keyOrPath: formattedKeyOrPath
1144
+ keyOrPath: formattedKeyOrPath,
1148
1145
  };
1149
1146
  };
1150
1147
  errors.forEach(({ message, context, fromServer, component }, index) => {
1151
1148
  const text = !(component === null || component === void 0 ? void 0 : component.label) || (context === null || context === void 0 ? void 0 : context.hasLabel) || fromServer
1152
- ? this.t('alertMessage', { message: this.t(message) })
1153
- : this.t('alertMessageWithLabel', {
1149
+ ? this.t("alertMessage", { message: this.t(message) })
1150
+ : this.t("alertMessageWithLabel", {
1154
1151
  label: this.t(component === null || component === void 0 ? void 0 : component.label),
1155
1152
  message: this.t(message),
1156
1153
  });
1157
1154
  displayedErrors.push(createListItem(text, index));
1158
1155
  });
1159
1156
  }
1160
- const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
1161
- this.root.setAlert('danger', errorsList);
1157
+ const errorsList = this.renderTemplate("errorsList", { errors: displayedErrors });
1158
+ this.root.setAlert("danger", errorsList);
1162
1159
  if (triggerEvent) {
1163
- this.emit('error', errors);
1160
+ this.emit("error", errors);
1164
1161
  }
1165
1162
  return errors;
1166
1163
  }
1167
1164
  /* eslint-enable no-unused-vars */
1168
1165
  /**
1169
1166
  * Called when the submission has completed, or if the submission needs to be sent to an external library.
1170
- *
1171
- * @param {Object} submission - The submission object.
1167
+ * @param {object} submission - The submission object.
1172
1168
  * @param {boolean} saved - Whether or not this submission was saved to the server.
1173
1169
  * @returns {object} - The submission object.
1174
1170
  */
@@ -1180,25 +1176,25 @@ class Webform extends NestedDataComponent_1.default {
1180
1176
  // We want to return the submitted submission and setValue will mutate the submission so cloneDeep it here.
1181
1177
  this.setValue((0, utils_1.fastCloneDeep)(submission), {
1182
1178
  noValidate: true,
1183
- noCheck: true
1179
+ noCheck: true,
1184
1180
  });
1185
- this.setAlert('success', `<p>${this.t('complete')}</p>`);
1181
+ this.setAlert("success", `<p>${this.t("complete")}</p>`);
1186
1182
  // Cancel triggered saveDraft to prevent overriding the submitted state
1187
1183
  if (this.draftEnabled && ((_a = this.triggerSaveDraft) === null || _a === void 0 ? void 0 : _a.cancel)) {
1188
1184
  this.triggerSaveDraft.cancel();
1189
1185
  }
1190
- this.emit('submit', submission, saved);
1186
+ this.emit("submit", submission, saved);
1191
1187
  if (saved) {
1192
- this.emit('submitDone', submission);
1188
+ this.emit("submitDone", submission);
1193
1189
  }
1194
1190
  return submission;
1195
1191
  }
1196
1192
  normalizeError(error) {
1197
1193
  if (error) {
1198
- if (typeof error === 'object' && 'details' in error) {
1194
+ if (typeof error === "object" && "details" in error) {
1199
1195
  error = error.details;
1200
1196
  }
1201
- if (typeof error === 'string') {
1197
+ if (typeof error === "string") {
1202
1198
  error = { message: error };
1203
1199
  }
1204
1200
  }
@@ -1206,17 +1202,17 @@ class Webform extends NestedDataComponent_1.default {
1206
1202
  }
1207
1203
  /**
1208
1204
  * Called when an error occurs during the submission.
1209
- *
1210
- * @param {Object} error - The error that occured.
1205
+ * @param {object} error - The error that occured.
1206
+ * @returns {Array} errors - All errors.
1211
1207
  */
1212
1208
  onSubmissionError(error) {
1213
1209
  error = this.normalizeError(error);
1214
1210
  this.submitting = false;
1215
1211
  this.setPristine(false);
1216
- this.emit('submitError', error || this.errors);
1212
+ this.emit("submitError", error || this.errors);
1217
1213
  // Allow for silent cancellations (no error message, no submit button error state)
1218
1214
  if (error && error.silent) {
1219
- this.emit('change', { isValid: true }, { silent: true });
1215
+ this.emit("change", { isValid: true }, { silent: true });
1220
1216
  return false;
1221
1217
  }
1222
1218
  const errors = this.showErrors(error, true);
@@ -1227,9 +1223,10 @@ class Webform extends NestedDataComponent_1.default {
1227
1223
  }
1228
1224
  /**
1229
1225
  * Trigger the change event for this form.
1230
- *
1231
- * @param changed
1232
- * @param flags
1226
+ * @param {any} flags - The flags to set on this change event.
1227
+ * @param {any} changed - The changed object which reflects the changes in the form.
1228
+ * @param {boolean} modified - Whether or not the form has been modified.
1229
+ * @param {any} changes - The changes that have occured in the form.
1233
1230
  */
1234
1231
  onChange(flags, changed, modified, changes) {
1235
1232
  flags = flags || {};
@@ -1242,13 +1239,17 @@ class Webform extends NestedDataComponent_1.default {
1242
1239
  this.pristine = false;
1243
1240
  }
1244
1241
  this.checkData(value.data, flags);
1245
- const shouldValidate = !flags.noValidate || flags.fromIFrame || (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1246
- const errors = shouldValidate ? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: 'change' })) : [];
1242
+ const shouldValidate = !flags.noValidate ||
1243
+ flags.fromIFrame ||
1244
+ (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
1245
+ const errors = shouldValidate
1246
+ ? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: "change" }))
1247
+ : [];
1247
1248
  value.isValid = errors.length === 0;
1248
1249
  this.loading = false;
1249
1250
  if (this.submitted) {
1250
1251
  // show server errors while they are not cleaned/fixed
1251
- const nonComponentServerErrors = lodash_1.default.filter(this.serverErrors || [], err => !err.component && !err.path);
1252
+ const nonComponentServerErrors = lodash_1.default.filter(this.serverErrors || [], (err) => !err.component && !err.path);
1252
1253
  this.showErrors(nonComponentServerErrors.length ? nonComponentServerErrors : errors);
1253
1254
  }
1254
1255
  // See if we need to save the draft of the form.
@@ -1256,38 +1257,39 @@ class Webform extends NestedDataComponent_1.default {
1256
1257
  this.triggerSaveDraft();
1257
1258
  }
1258
1259
  if (!flags || !flags.noEmit) {
1259
- this.emit('change', value, flags, modified);
1260
+ this.emit("change", value, flags, modified);
1260
1261
  isChangeEventEmitted = true;
1261
1262
  }
1262
1263
  // The form is initialized after the first change event occurs.
1263
1264
  if (isChangeEventEmitted && !this.initialized) {
1264
- this.emit('initialized');
1265
+ this.emit("initialized");
1265
1266
  this.initialized = true;
1266
1267
  }
1267
1268
  }
1268
1269
  /**
1269
1270
  * Send a delete request to the server.
1271
+ * @returns {Promise} - The promise that is triggered when the delete is complete.
1270
1272
  */
1271
1273
  deleteSubmission() {
1272
- return this.formio.deleteSubmission()
1273
- .then(() => {
1274
- this.emit('submissionDeleted', this.submission);
1274
+ return this.formio.deleteSubmission().then(() => {
1275
+ this.emit("submissionDeleted", this.submission);
1275
1276
  this.resetValue();
1276
1277
  });
1277
1278
  }
1278
1279
  /**
1279
1280
  * Cancels the submission.
1280
- *
1281
+ * @param {boolean} noconfirm - Whether or not to confirm the cancellation.
1281
1282
  * @alias reset
1283
+ * @returns {boolean} - TRUE means the submission was cancelled, FALSE otherwise.
1282
1284
  */
1283
1285
  cancel(noconfirm) {
1284
- const shouldReset = this.hook('beforeCancel', true);
1285
- if (shouldReset && (noconfirm || confirm(this.t('confirmCancel')))) {
1286
+ const shouldReset = this.hook("beforeCancel", true);
1287
+ if (shouldReset && (noconfirm || confirm(this.t("confirmCancel")))) {
1286
1288
  this.resetValue();
1287
1289
  return true;
1288
1290
  }
1289
1291
  else {
1290
- this.emit('cancelSubmit');
1292
+ this.emit("cancelSubmit");
1291
1293
  return false;
1292
1294
  }
1293
1295
  }
@@ -1295,14 +1297,14 @@ class Webform extends NestedDataComponent_1.default {
1295
1297
  // Add in metadata about client submitting the form
1296
1298
  submission.metadata = submission.metadata || {};
1297
1299
  lodash_1.default.defaults(submission.metadata, {
1298
- timezone: lodash_1.default.get(this, '_submission.metadata.timezone', (0, utils_1.currentTimezone)()),
1299
- offset: parseInt(lodash_1.default.get(this, '_submission.metadata.offset', (0, moment_1.default)().utcOffset()), 10),
1300
+ timezone: lodash_1.default.get(this, "_submission.metadata.timezone", (0, utils_1.currentTimezone)()),
1301
+ offset: parseInt(lodash_1.default.get(this, "_submission.metadata.offset", (0, moment_1.default)().utcOffset()), 10),
1300
1302
  origin: document.location.origin,
1301
1303
  referrer: document.referrer,
1302
1304
  browserName: navigator.appName,
1303
1305
  userAgent: navigator.userAgent,
1304
1306
  pathName: window.location.pathname,
1305
- onLine: navigator.onLine
1307
+ onLine: navigator.onLine,
1306
1308
  });
1307
1309
  }
1308
1310
  submitForm(options = {}) {
@@ -1312,30 +1314,31 @@ class Webform extends NestedDataComponent_1.default {
1312
1314
  if (this.options.readOnly) {
1313
1315
  return resolve({
1314
1316
  submission: this.submission,
1315
- saved: false
1317
+ saved: false,
1316
1318
  });
1317
1319
  }
1318
1320
  const submission = (0, utils_1.fastCloneDeep)(this.submission || {});
1319
1321
  this.setMetadata(submission);
1320
- submission.state = options.state || submission.state || 'submitted';
1321
- const isDraft = (submission.state === 'draft');
1322
- this.hook('beforeSubmit', Object.assign(Object.assign({}, submission), { component: options.component }), (err, data) => {
1322
+ submission.state = options.state || submission.state || "submitted";
1323
+ const isDraft = submission.state === "draft";
1324
+ this.hook("beforeSubmit", Object.assign(Object.assign({}, submission), { component: options.component }), (err, data) => {
1323
1325
  var _a;
1324
1326
  if (err) {
1325
1327
  return reject(err);
1326
1328
  }
1327
- submission._vnote = data && data._vnote ? data._vnote : '';
1329
+ submission._vnote = data && data._vnote ? data._vnote : "";
1328
1330
  try {
1329
1331
  if (!isDraft && !options.noValidate) {
1330
1332
  if (!submission.data) {
1331
- return reject('Invalid Submission');
1333
+ return reject("Invalid Submission");
1332
1334
  }
1333
1335
  const errors = this.validate(submission.data, {
1334
1336
  dirty: true,
1335
1337
  silentCheck: false,
1336
- process: 'submit'
1338
+ process: "submit",
1337
1339
  });
1338
- if (errors.length || ((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === 'rejected'))) {
1340
+ if (errors.length ||
1341
+ ((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === "rejected"))) {
1339
1342
  return reject(errors);
1340
1343
  }
1341
1344
  }
@@ -1344,20 +1347,20 @@ class Webform extends NestedDataComponent_1.default {
1344
1347
  console.error(err);
1345
1348
  }
1346
1349
  this.everyComponent((comp) => {
1347
- if (submission._vnote && comp.type === 'form' && comp.component.reference) {
1350
+ if (submission._vnote && comp.type === "form" && comp.component.reference) {
1348
1351
  lodash_1.default.get(submission.data, comp.path, {})._vnote = submission._vnote;
1349
1352
  }
1350
1353
  const { persistent } = comp.component;
1351
- if (persistent === 'client-only') {
1354
+ if (persistent === "client-only") {
1352
1355
  lodash_1.default.unset(submission.data, comp.path);
1353
1356
  }
1354
1357
  });
1355
- this.hook('customValidation', Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {
1358
+ this.hook("customValidation", Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {
1356
1359
  if (err) {
1357
1360
  // If string is returned, cast to object.
1358
- if (typeof err === 'string') {
1361
+ if (typeof err === "string") {
1359
1362
  err = {
1360
- message: err
1363
+ message: err,
1361
1364
  };
1362
1365
  }
1363
1366
  // Ensure err is an array.
@@ -1367,7 +1370,10 @@ class Webform extends NestedDataComponent_1.default {
1367
1370
  this.loading = true;
1368
1371
  // Use the form action to submit the form if available.
1369
1372
  if (this._form && this._form.action) {
1370
- const method = (submission.data._id && this._form.action.includes(submission.data._id)) ? 'PUT' : 'POST';
1373
+ const method = submission.data._id &&
1374
+ this._form.action.includes(submission.data._id)
1375
+ ? "PUT"
1376
+ : "POST";
1371
1377
  return Formio_1.Formio.makeStaticRequest(this._form.action, method, submission, this.formio ? this.formio.options : {})
1372
1378
  .then((result) => resolve({
1373
1379
  submission: result,
@@ -1386,7 +1392,9 @@ class Webform extends NestedDataComponent_1.default {
1386
1392
  });
1387
1393
  }
1388
1394
  // If this is an actionUrl, then make sure to save the action and not the submission.
1389
- const submitMethod = submitFormio.actionUrl ? 'saveAction' : 'saveSubmission';
1395
+ const submitMethod = submitFormio.actionUrl
1396
+ ? "saveAction"
1397
+ : "saveSubmission";
1390
1398
  submitFormio[submitMethod](submission)
1391
1399
  .then((result) => resolve({
1392
1400
  submission: result,
@@ -1402,13 +1410,15 @@ class Webform extends NestedDataComponent_1.default {
1402
1410
  }
1403
1411
  setServerErrors(error) {
1404
1412
  if (error.details) {
1405
- this.serverErrors = error.details.filter((err) => err.level ? err.level === 'error' : err).map((err) => {
1413
+ this.serverErrors = error.details
1414
+ .filter((err) => (err.level ? err.level === "error" : err))
1415
+ .map((err) => {
1406
1416
  err.fromServer = true;
1407
1417
  return err;
1408
1418
  });
1409
1419
  }
1410
- else if (typeof error === 'string') {
1411
- this.serverErrors = [{ fromServer: true, level: 'error', message: error }];
1420
+ else if (typeof error === "string") {
1421
+ this.serverErrors = [{ fromServer: true, level: "error", message: error }];
1412
1422
  }
1413
1423
  }
1414
1424
  executeSubmit(options) {
@@ -1440,7 +1450,6 @@ class Webform extends NestedDataComponent_1.default {
1440
1450
  }
1441
1451
  /**
1442
1452
  * Submits the form.
1443
- *
1444
1453
  * @example
1445
1454
  * import Webform from '@formio/js/Webform';
1446
1455
  * let form = new Webform(document.getElementById('formio'));
@@ -1453,12 +1462,11 @@ class Webform extends NestedDataComponent_1.default {
1453
1462
  * form.submit().then((submission) => {
1454
1463
  * console.log(submission);
1455
1464
  * });
1456
- *
1457
1465
  * @param {boolean} before - If this submission occured from the before handlers.
1458
- *
1466
+ * @param {any} options - The options to use when submitting this form.
1459
1467
  * @returns {Promise} - A promise when the form is done submitting.
1460
1468
  */
1461
- submit(before, options = {}) {
1469
+ submit(before = false, options = {}) {
1462
1470
  this.submissionInProcess = true;
1463
1471
  if (!before) {
1464
1472
  return this.beforeSubmit(options).then(() => this.executeSubmit(options));
@@ -1469,37 +1477,41 @@ class Webform extends NestedDataComponent_1.default {
1469
1477
  }
1470
1478
  submitUrl(URL, headers) {
1471
1479
  if (!URL) {
1472
- return console.warn('Missing URL argument');
1480
+ return console.warn("Missing URL argument");
1473
1481
  }
1474
1482
  const submission = this.submission || {};
1475
1483
  const API_URL = URL;
1476
1484
  const settings = {
1477
- method: 'POST',
1478
- headers: {}
1485
+ method: "POST",
1486
+ headers: {},
1479
1487
  };
1480
1488
  if (headers && headers.length > 0) {
1481
1489
  headers.map((e) => {
1482
- if (e.header !== '' && e.value !== '') {
1490
+ if (e.header !== "" && e.value !== "") {
1483
1491
  settings.headers[e.header] = this.interpolate(e.value, submission);
1484
1492
  }
1485
1493
  });
1486
1494
  }
1487
1495
  if (API_URL && settings) {
1488
- Formio_1.Formio.makeStaticRequest(API_URL, settings.method, submission, { headers: settings.headers }).then(() => {
1489
- this.emit('requestDone');
1490
- this.setAlert('success', '<p> Success </p>');
1491
- }).catch((e) => {
1492
- const message = `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`;
1493
- this.emit('error', message);
1496
+ Formio_1.Formio.makeStaticRequest(API_URL, settings.method, submission, {
1497
+ headers: settings.headers,
1498
+ })
1499
+ .then(() => {
1500
+ this.emit("requestDone");
1501
+ this.setAlert("success", "<p> Success </p>");
1502
+ })
1503
+ .catch((e) => {
1504
+ const message = `${e.statusText ? e.statusText : ""} ${e.status ? e.status : e}`;
1505
+ this.emit("error", message);
1494
1506
  console.error(message);
1495
- this.setAlert('danger', `<p> ${message} </p>`);
1507
+ this.setAlert("danger", `<p> ${message} </p>`);
1496
1508
  return Promise.reject(this.onSubmissionError(e));
1497
1509
  });
1498
1510
  }
1499
1511
  else {
1500
- this.emit('error', 'You should add a URL to this button.');
1501
- this.setAlert('warning', 'You should add a URL to this button.');
1502
- return console.warn('You should add a URL to this button.');
1512
+ this.emit("error", "You should add a URL to this button.");
1513
+ this.setAlert("warning", "You should add a URL to this button.");
1514
+ return console.warn("You should add a URL to this button.");
1503
1515
  }
1504
1516
  }
1505
1517
  triggerCaptcha() {
@@ -1518,7 +1530,7 @@ class Webform extends NestedDataComponent_1.default {
1518
1530
  }
1519
1531
  set nosubmit(value) {
1520
1532
  this._nosubmit = !!value;
1521
- this.emit('nosubmit', this._nosubmit);
1533
+ this.emit("nosubmit", this._nosubmit);
1522
1534
  }
1523
1535
  get nosubmit() {
1524
1536
  return this._nosubmit || false;