@formio/js 5.0.0-dev.5643.9c5173a → 5.0.0-dev.5646.35daa65

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