@formio/js 5.0.0-dev.5613.3476921 → 5.0.0-dev.5614.b5c93f3

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