@formio/js 5.0.0-dev.5641.d9ab3df → 5.0.0-dev.5643.9c5173a

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