@formio/js 5.0.0-dev.5636.99a32e6 → 5.0.0-dev.5641.3b5157b

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