@formio/js 5.0.0-dev.5639.43f7313 → 5.0.0-dev.5641.6eb7b96

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 (459) hide show
  1. package/Changelog.md +45 -0
  2. package/dist/formio.builder.css +0 -4
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.form.css +0 -4
  8. package/dist/formio.form.js +607 -1188
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +3 -5
  12. package/dist/formio.full.css +0 -4
  13. package/dist/formio.full.js +651 -912
  14. package/dist/formio.full.min.css +1 -1
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +3 -5
  17. package/dist/formio.js +18 -18
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +1 -1
  20. package/dist/formio.utils.js +1829 -492
  21. package/dist/formio.utils.min.js +1 -1
  22. package/dist/formio.utils.min.js.LICENSE.txt +10 -4
  23. package/embed.d.ts +1 -0
  24. package/form.d.ts +1 -0
  25. package/lib/cjs/CDN.d.ts +1 -0
  26. package/lib/cjs/CDN.js +6 -3
  27. package/lib/cjs/Element.d.ts +86 -96
  28. package/lib/cjs/Element.js +68 -78
  29. package/lib/cjs/Embed.d.ts +1 -1
  30. package/lib/cjs/Embed.js +52 -12
  31. package/lib/cjs/Form.d.ts +365 -36
  32. package/lib/cjs/Form.js +50 -64
  33. package/lib/cjs/FormBuilder.d.ts +187 -2
  34. package/lib/cjs/FormBuilder.js +30 -8
  35. package/lib/cjs/InlineEmbed.d.ts +7 -0
  36. package/lib/cjs/InlineEmbed.js +116 -0
  37. package/lib/cjs/PDF.d.ts +11 -13
  38. package/lib/cjs/PDF.js +6 -8
  39. package/lib/cjs/Webform.d.ts +180 -139
  40. package/lib/cjs/Webform.js +309 -296
  41. package/lib/cjs/WebformBuilder.d.ts +16 -14
  42. package/lib/cjs/WebformBuilder.js +19 -12
  43. package/lib/cjs/Wizard.d.ts +31 -21
  44. package/lib/cjs/Wizard.js +43 -20
  45. package/lib/cjs/WizardBuilder.d.ts +1 -1
  46. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -5
  47. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -3
  48. package/lib/cjs/components/Components.d.ts +4 -4
  49. package/lib/cjs/components/Components.js +3 -3
  50. package/lib/cjs/components/_classes/component/Component.d.ts +502 -269
  51. package/lib/cjs/components/_classes/component/Component.form.d.ts +6 -3
  52. package/lib/cjs/components/_classes/component/Component.form.js +5 -0
  53. package/lib/cjs/components/_classes/component/Component.js +434 -193
  54. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +0 -8
  55. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +2 -2
  56. package/lib/cjs/components/_classes/component/editForm/utils.js +2 -2
  57. package/lib/cjs/components/_classes/field/Field.d.ts +11 -2
  58. package/lib/cjs/components/_classes/field/Field.js +13 -1
  59. package/lib/cjs/components/_classes/input/Input.d.ts +4 -3
  60. package/lib/cjs/components/_classes/input/Input.js +2 -2
  61. package/lib/cjs/components/_classes/list/ListComponent.d.ts +2 -2
  62. package/lib/cjs/components/_classes/list/ListComponent.form.d.ts +6 -3
  63. package/lib/cjs/components/_classes/list/ListComponent.form.js +5 -0
  64. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +43 -12
  65. package/lib/cjs/components/_classes/multivalue/Multivalue.js +37 -3
  66. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +163 -67
  67. package/lib/cjs/components/_classes/nested/NestedComponent.form.d.ts +6 -3
  68. package/lib/cjs/components/_classes/nested/NestedComponent.form.js +5 -0
  69. package/lib/cjs/components/_classes/nested/NestedComponent.js +175 -54
  70. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
  71. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  72. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +7 -1
  73. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +2 -3
  74. package/lib/cjs/components/address/Address.d.ts +4 -2
  75. package/lib/cjs/components/address/Address.form.d.ts +6 -3
  76. package/lib/cjs/components/address/Address.form.js +5 -0
  77. package/lib/cjs/components/button/Button.d.ts +3 -12
  78. package/lib/cjs/components/button/Button.form.d.ts +6 -3
  79. package/lib/cjs/components/button/Button.form.js +5 -0
  80. package/lib/cjs/components/button/Button.js +5 -0
  81. package/lib/cjs/components/checkbox/Checkbox.d.ts +4 -27
  82. package/lib/cjs/components/checkbox/Checkbox.form.d.ts +6 -3
  83. package/lib/cjs/components/checkbox/Checkbox.form.js +5 -0
  84. package/lib/cjs/components/columns/Columns.d.ts +3 -2
  85. package/lib/cjs/components/columns/Columns.form.d.ts +6 -3
  86. package/lib/cjs/components/columns/Columns.form.js +5 -0
  87. package/lib/cjs/components/columns/Columns.js +1 -1
  88. package/lib/cjs/components/container/Container.form.d.ts +6 -3
  89. package/lib/cjs/components/container/Container.form.js +5 -0
  90. package/lib/cjs/components/content/Content.d.ts +2 -1
  91. package/lib/cjs/components/content/Content.form.d.ts +6 -3
  92. package/lib/cjs/components/content/Content.form.js +5 -0
  93. package/lib/cjs/components/currency/Currency.form.d.ts +6 -3
  94. package/lib/cjs/components/currency/Currency.form.js +5 -0
  95. package/lib/cjs/components/currency/Currency.js +1 -2
  96. package/lib/cjs/components/datagrid/DataGrid.d.ts +8 -7
  97. package/lib/cjs/components/datagrid/DataGrid.form.d.ts +6 -3
  98. package/lib/cjs/components/datagrid/DataGrid.form.js +5 -0
  99. package/lib/cjs/components/datagrid/DataGrid.js +5 -5
  100. package/lib/cjs/components/datamap/DataMap.d.ts +1 -0
  101. package/lib/cjs/components/datamap/DataMap.form.d.ts +6 -3
  102. package/lib/cjs/components/datamap/DataMap.form.js +5 -0
  103. package/lib/cjs/components/datetime/DateTime.d.ts +0 -14
  104. package/lib/cjs/components/datetime/DateTime.form.d.ts +6 -3
  105. package/lib/cjs/components/datetime/DateTime.form.js +5 -0
  106. package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +2 -2
  107. package/lib/cjs/components/day/Day.d.ts +22 -48
  108. package/lib/cjs/components/day/Day.form.d.ts +6 -3
  109. package/lib/cjs/components/day/Day.form.js +5 -0
  110. package/lib/cjs/components/day/Day.js +15 -20
  111. package/lib/cjs/components/editgrid/EditGrid.d.ts +7 -3
  112. package/lib/cjs/components/editgrid/EditGrid.form.d.ts +6 -3
  113. package/lib/cjs/components/editgrid/EditGrid.form.js +5 -0
  114. package/lib/cjs/components/editgrid/EditGrid.js +3 -3
  115. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +2 -5
  116. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.js +6 -9
  117. package/lib/cjs/components/email/Email.form.d.ts +6 -3
  118. package/lib/cjs/components/email/Email.form.js +5 -0
  119. package/lib/cjs/components/fieldset/Fieldset.form.d.ts +6 -3
  120. package/lib/cjs/components/fieldset/Fieldset.form.js +5 -0
  121. package/lib/cjs/components/file/File.d.ts +9 -22
  122. package/lib/cjs/components/file/File.form.d.ts +6 -3
  123. package/lib/cjs/components/file/File.form.js +5 -0
  124. package/lib/cjs/components/form/Form.d.ts +31 -20
  125. package/lib/cjs/components/form/Form.form.d.ts +6 -3
  126. package/lib/cjs/components/form/Form.form.js +5 -0
  127. package/lib/cjs/components/form/Form.js +13 -10
  128. package/lib/cjs/components/hidden/Hidden.d.ts +1 -11
  129. package/lib/cjs/components/hidden/Hidden.form.d.ts +6 -3
  130. package/lib/cjs/components/hidden/Hidden.form.js +5 -0
  131. package/lib/cjs/components/hidden/Hidden.js +1 -2
  132. package/lib/cjs/components/html/HTML.d.ts +2 -1
  133. package/lib/cjs/components/html/HTML.form.d.ts +6 -3
  134. package/lib/cjs/components/html/HTML.form.js +5 -0
  135. package/lib/cjs/components/number/Number.d.ts +3 -17
  136. package/lib/cjs/components/number/Number.form.d.ts +6 -3
  137. package/lib/cjs/components/number/Number.form.js +5 -0
  138. package/lib/cjs/components/number/Number.js +1 -2
  139. package/lib/cjs/components/panel/Panel.form.d.ts +6 -3
  140. package/lib/cjs/components/panel/Panel.form.js +5 -0
  141. package/lib/cjs/components/panel/Panel.js +0 -1
  142. package/lib/cjs/components/password/Password.form.d.ts +6 -3
  143. package/lib/cjs/components/password/Password.form.js +5 -0
  144. package/lib/cjs/components/phonenumber/PhoneNumber.form.d.ts +6 -3
  145. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +5 -0
  146. package/lib/cjs/components/radio/Radio.d.ts +3 -26
  147. package/lib/cjs/components/radio/Radio.form.d.ts +6 -3
  148. package/lib/cjs/components/radio/Radio.form.js +5 -0
  149. package/lib/cjs/components/radio/Radio.js +3 -4
  150. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
  151. package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
  152. package/lib/cjs/components/recaptcha/ReCaptcha.form.js +5 -0
  153. package/lib/cjs/components/select/Select.d.ts +16 -39
  154. package/lib/cjs/components/select/Select.form.d.ts +6 -3
  155. package/lib/cjs/components/select/Select.form.js +5 -0
  156. package/lib/cjs/components/select/Select.js +14 -17
  157. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +2 -17
  158. package/lib/cjs/components/selectboxes/SelectBoxes.form.d.ts +6 -3
  159. package/lib/cjs/components/selectboxes/SelectBoxes.form.js +5 -0
  160. package/lib/cjs/components/selectboxes/SelectBoxes.js +7 -9
  161. package/lib/cjs/components/signature/Signature.d.ts +1 -14
  162. package/lib/cjs/components/signature/Signature.form.d.ts +6 -3
  163. package/lib/cjs/components/signature/Signature.form.js +5 -0
  164. package/lib/cjs/components/survey/Survey.d.ts +3 -15
  165. package/lib/cjs/components/survey/Survey.form.d.ts +6 -3
  166. package/lib/cjs/components/survey/Survey.form.js +5 -0
  167. package/lib/cjs/components/table/Table.d.ts +2 -1
  168. package/lib/cjs/components/table/Table.form.d.ts +6 -3
  169. package/lib/cjs/components/table/Table.form.js +5 -0
  170. package/lib/cjs/components/tabs/Tabs.d.ts +4 -4
  171. package/lib/cjs/components/tabs/Tabs.form.d.ts +6 -3
  172. package/lib/cjs/components/tabs/Tabs.form.js +5 -0
  173. package/lib/cjs/components/tabs/Tabs.js +1 -2
  174. package/lib/cjs/components/tags/Tags.d.ts +0 -14
  175. package/lib/cjs/components/tags/Tags.form.d.ts +6 -3
  176. package/lib/cjs/components/tags/Tags.form.js +5 -0
  177. package/lib/cjs/components/textarea/TextArea.d.ts +4 -9
  178. package/lib/cjs/components/textarea/TextArea.form.d.ts +6 -3
  179. package/lib/cjs/components/textarea/TextArea.form.js +5 -0
  180. package/lib/cjs/components/textarea/TextArea.js +2 -2
  181. package/lib/cjs/components/textfield/TextField.d.ts +14 -30
  182. package/lib/cjs/components/textfield/TextField.form.d.ts +6 -3
  183. package/lib/cjs/components/textfield/TextField.form.js +5 -0
  184. package/lib/cjs/components/textfield/TextField.js +14 -17
  185. package/lib/cjs/components/time/Time.form.d.ts +6 -3
  186. package/lib/cjs/components/time/Time.form.js +5 -0
  187. package/lib/cjs/components/unknown/Unknown.form.d.ts +5 -34
  188. package/lib/cjs/components/unknown/Unknown.form.js +4 -0
  189. package/lib/cjs/components/url/Url.form.d.ts +6 -3
  190. package/lib/cjs/components/url/Url.form.js +5 -0
  191. package/lib/cjs/components/well/Well.form.d.ts +6 -3
  192. package/lib/cjs/components/well/Well.form.js +5 -0
  193. package/lib/cjs/formio.embed.d.ts +1 -2
  194. package/lib/cjs/formio.embed.js +2 -100
  195. package/lib/cjs/formio.form.d.ts +11 -4
  196. package/lib/cjs/formio.form.js +13 -5
  197. package/lib/cjs/providers/Providers.d.ts +36 -5
  198. package/lib/cjs/providers/Providers.js +29 -0
  199. package/lib/cjs/providers/address/AddressProvider.d.ts +131 -12
  200. package/lib/cjs/providers/address/AddressProvider.js +88 -2
  201. package/lib/cjs/providers/address/AzureAddressProvider.d.ts +48 -1
  202. package/lib/cjs/providers/address/AzureAddressProvider.js +37 -0
  203. package/lib/cjs/providers/address/CustomAddressProvider.d.ts +27 -4
  204. package/lib/cjs/providers/address/CustomAddressProvider.js +34 -0
  205. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +130 -6
  206. package/lib/cjs/providers/address/GoogleAddressProvider.js +72 -0
  207. package/lib/cjs/providers/address/NominatimAddressProvider.d.ts +32 -7
  208. package/lib/cjs/providers/address/NominatimAddressProvider.js +33 -0
  209. package/lib/cjs/providers/address/index.d.ts +3 -1
  210. package/lib/cjs/providers/processor/fileProcessor.d.ts +7 -1
  211. package/lib/cjs/providers/processor/fileProcessor.js +6 -0
  212. package/lib/cjs/providers/storage/azure.d.ts +6 -13
  213. package/lib/cjs/providers/storage/azure.js +5 -0
  214. package/lib/cjs/providers/storage/base64.d.ts +5 -6
  215. package/lib/cjs/providers/storage/base64.js +4 -0
  216. package/lib/cjs/providers/storage/dropbox.d.ts +6 -4
  217. package/lib/cjs/providers/storage/dropbox.js +5 -0
  218. package/lib/cjs/providers/storage/googleDrive.d.ts +7 -5
  219. package/lib/cjs/providers/storage/googleDrive.js +6 -0
  220. package/lib/cjs/providers/storage/indexeddb.d.ts +5 -7
  221. package/lib/cjs/providers/storage/indexeddb.js +4 -0
  222. package/lib/cjs/providers/storage/s3.d.ts +6 -20
  223. package/lib/cjs/providers/storage/s3.js +5 -0
  224. package/lib/cjs/providers/storage/url.d.ts +6 -7
  225. package/lib/cjs/providers/storage/url.js +10 -0
  226. package/lib/cjs/providers/storage/util.d.ts +24 -1
  227. package/lib/cjs/providers/storage/util.js +18 -0
  228. package/lib/cjs/templates/Templates.d.ts +1 -0
  229. package/lib/cjs/utils/Evaluator.d.ts +6 -3
  230. package/lib/cjs/utils/Evaluator.js +11 -20
  231. package/lib/cjs/utils/builder.d.ts +9 -7
  232. package/lib/cjs/utils/builder.js +10 -5
  233. package/lib/cjs/utils/calendarUtils.d.ts +7 -13
  234. package/lib/cjs/utils/calendarUtils.js +10 -17
  235. package/lib/cjs/utils/formUtils.d.ts +43 -171
  236. package/lib/cjs/utils/formUtils.js +38 -569
  237. package/lib/cjs/utils/utils.d.ts +370 -218
  238. package/lib/cjs/utils/utils.js +348 -230
  239. package/lib/cjs/widgets/CalendarWidget.d.ts +9 -10
  240. package/lib/cjs/widgets/CalendarWidget.js +9 -11
  241. package/lib/mjs/CDN.d.ts +1 -0
  242. package/lib/mjs/CDN.js +6 -3
  243. package/lib/mjs/Element.d.ts +86 -96
  244. package/lib/mjs/Element.js +68 -78
  245. package/lib/mjs/Embed.d.ts +1 -1
  246. package/lib/mjs/Embed.js +52 -12
  247. package/lib/mjs/Form.d.ts +365 -36
  248. package/lib/mjs/Form.js +140 -57
  249. package/lib/mjs/FormBuilder.d.ts +187 -2
  250. package/lib/mjs/FormBuilder.js +32 -8
  251. package/lib/mjs/InlineEmbed.d.ts +7 -0
  252. package/lib/mjs/InlineEmbed.js +112 -0
  253. package/lib/mjs/PDF.d.ts +11 -13
  254. package/lib/mjs/PDF.js +6 -8
  255. package/lib/mjs/Webform.d.ts +180 -139
  256. package/lib/mjs/Webform.js +321 -308
  257. package/lib/mjs/WebformBuilder.d.ts +16 -14
  258. package/lib/mjs/WebformBuilder.js +19 -12
  259. package/lib/mjs/Wizard.d.ts +31 -21
  260. package/lib/mjs/Wizard.js +42 -19
  261. package/lib/mjs/WizardBuilder.d.ts +1 -1
  262. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -5
  263. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -3
  264. package/lib/mjs/components/Components.d.ts +4 -4
  265. package/lib/mjs/components/Components.js +3 -3
  266. package/lib/mjs/components/_classes/component/Component.d.ts +502 -269
  267. package/lib/mjs/components/_classes/component/Component.form.d.ts +6 -3
  268. package/lib/mjs/components/_classes/component/Component.form.js +5 -0
  269. package/lib/mjs/components/_classes/component/Component.js +434 -193
  270. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +0 -8
  271. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
  272. package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
  273. package/lib/mjs/components/_classes/field/Field.d.ts +11 -2
  274. package/lib/mjs/components/_classes/field/Field.js +13 -1
  275. package/lib/mjs/components/_classes/input/Input.d.ts +4 -3
  276. package/lib/mjs/components/_classes/input/Input.js +2 -2
  277. package/lib/mjs/components/_classes/list/ListComponent.d.ts +2 -2
  278. package/lib/mjs/components/_classes/list/ListComponent.form.d.ts +6 -3
  279. package/lib/mjs/components/_classes/list/ListComponent.form.js +5 -0
  280. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +43 -12
  281. package/lib/mjs/components/_classes/multivalue/Multivalue.js +37 -3
  282. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +163 -67
  283. package/lib/mjs/components/_classes/nested/NestedComponent.form.d.ts +6 -3
  284. package/lib/mjs/components/_classes/nested/NestedComponent.form.js +5 -0
  285. package/lib/mjs/components/_classes/nested/NestedComponent.js +175 -54
  286. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
  287. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
  288. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +7 -1
  289. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +2 -3
  290. package/lib/mjs/components/address/Address.d.ts +4 -2
  291. package/lib/mjs/components/address/Address.form.d.ts +6 -3
  292. package/lib/mjs/components/address/Address.form.js +5 -0
  293. package/lib/mjs/components/button/Button.d.ts +3 -12
  294. package/lib/mjs/components/button/Button.form.d.ts +6 -3
  295. package/lib/mjs/components/button/Button.form.js +5 -0
  296. package/lib/mjs/components/button/Button.js +5 -0
  297. package/lib/mjs/components/checkbox/Checkbox.d.ts +4 -27
  298. package/lib/mjs/components/checkbox/Checkbox.form.d.ts +6 -3
  299. package/lib/mjs/components/checkbox/Checkbox.form.js +5 -0
  300. package/lib/mjs/components/columns/Columns.d.ts +3 -2
  301. package/lib/mjs/components/columns/Columns.form.d.ts +6 -3
  302. package/lib/mjs/components/columns/Columns.form.js +5 -0
  303. package/lib/mjs/components/columns/Columns.js +1 -1
  304. package/lib/mjs/components/container/Container.form.d.ts +6 -3
  305. package/lib/mjs/components/container/Container.form.js +5 -0
  306. package/lib/mjs/components/content/Content.d.ts +2 -1
  307. package/lib/mjs/components/content/Content.form.d.ts +6 -3
  308. package/lib/mjs/components/content/Content.form.js +5 -0
  309. package/lib/mjs/components/currency/Currency.form.d.ts +6 -3
  310. package/lib/mjs/components/currency/Currency.form.js +5 -0
  311. package/lib/mjs/components/currency/Currency.js +1 -2
  312. package/lib/mjs/components/datagrid/DataGrid.d.ts +8 -7
  313. package/lib/mjs/components/datagrid/DataGrid.form.d.ts +6 -3
  314. package/lib/mjs/components/datagrid/DataGrid.form.js +5 -0
  315. package/lib/mjs/components/datagrid/DataGrid.js +5 -5
  316. package/lib/mjs/components/datamap/DataMap.d.ts +1 -0
  317. package/lib/mjs/components/datamap/DataMap.form.d.ts +6 -3
  318. package/lib/mjs/components/datamap/DataMap.form.js +5 -0
  319. package/lib/mjs/components/datetime/DateTime.d.ts +0 -14
  320. package/lib/mjs/components/datetime/DateTime.form.d.ts +6 -3
  321. package/lib/mjs/components/datetime/DateTime.form.js +5 -0
  322. package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +1 -1
  323. package/lib/mjs/components/day/Day.d.ts +22 -48
  324. package/lib/mjs/components/day/Day.form.d.ts +6 -3
  325. package/lib/mjs/components/day/Day.form.js +5 -0
  326. package/lib/mjs/components/day/Day.js +15 -20
  327. package/lib/mjs/components/editgrid/EditGrid.d.ts +7 -3
  328. package/lib/mjs/components/editgrid/EditGrid.form.d.ts +6 -3
  329. package/lib/mjs/components/editgrid/EditGrid.form.js +5 -0
  330. package/lib/mjs/components/editgrid/EditGrid.js +3 -3
  331. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
  332. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +1 -1
  333. package/lib/mjs/components/email/Email.form.d.ts +6 -3
  334. package/lib/mjs/components/email/Email.form.js +5 -0
  335. package/lib/mjs/components/fieldset/Fieldset.form.d.ts +6 -3
  336. package/lib/mjs/components/fieldset/Fieldset.form.js +5 -0
  337. package/lib/mjs/components/file/File.d.ts +9 -22
  338. package/lib/mjs/components/file/File.form.d.ts +6 -3
  339. package/lib/mjs/components/file/File.form.js +5 -0
  340. package/lib/mjs/components/form/Form.d.ts +31 -20
  341. package/lib/mjs/components/form/Form.form.d.ts +6 -3
  342. package/lib/mjs/components/form/Form.form.js +5 -0
  343. package/lib/mjs/components/form/Form.js +13 -10
  344. package/lib/mjs/components/hidden/Hidden.d.ts +1 -11
  345. package/lib/mjs/components/hidden/Hidden.form.d.ts +6 -3
  346. package/lib/mjs/components/hidden/Hidden.form.js +5 -0
  347. package/lib/mjs/components/hidden/Hidden.js +1 -2
  348. package/lib/mjs/components/html/HTML.d.ts +2 -1
  349. package/lib/mjs/components/html/HTML.form.d.ts +6 -3
  350. package/lib/mjs/components/html/HTML.form.js +5 -0
  351. package/lib/mjs/components/number/Number.d.ts +3 -17
  352. package/lib/mjs/components/number/Number.form.d.ts +6 -3
  353. package/lib/mjs/components/number/Number.form.js +5 -0
  354. package/lib/mjs/components/number/Number.js +1 -2
  355. package/lib/mjs/components/panel/Panel.form.d.ts +6 -3
  356. package/lib/mjs/components/panel/Panel.form.js +5 -0
  357. package/lib/mjs/components/panel/Panel.js +0 -1
  358. package/lib/mjs/components/password/Password.form.d.ts +6 -3
  359. package/lib/mjs/components/password/Password.form.js +5 -0
  360. package/lib/mjs/components/phonenumber/PhoneNumber.form.d.ts +6 -3
  361. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +5 -0
  362. package/lib/mjs/components/radio/Radio.d.ts +3 -26
  363. package/lib/mjs/components/radio/Radio.form.d.ts +6 -3
  364. package/lib/mjs/components/radio/Radio.form.js +5 -0
  365. package/lib/mjs/components/radio/Radio.js +3 -4
  366. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
  367. package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
  368. package/lib/mjs/components/recaptcha/ReCaptcha.form.js +5 -0
  369. package/lib/mjs/components/select/Select.d.ts +16 -39
  370. package/lib/mjs/components/select/Select.form.d.ts +6 -3
  371. package/lib/mjs/components/select/Select.form.js +5 -0
  372. package/lib/mjs/components/select/Select.js +15 -18
  373. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +2 -17
  374. package/lib/mjs/components/selectboxes/SelectBoxes.form.d.ts +6 -3
  375. package/lib/mjs/components/selectboxes/SelectBoxes.form.js +5 -0
  376. package/lib/mjs/components/selectboxes/SelectBoxes.js +7 -9
  377. package/lib/mjs/components/signature/Signature.d.ts +1 -14
  378. package/lib/mjs/components/signature/Signature.form.d.ts +6 -3
  379. package/lib/mjs/components/signature/Signature.form.js +5 -0
  380. package/lib/mjs/components/survey/Survey.d.ts +3 -15
  381. package/lib/mjs/components/survey/Survey.form.d.ts +6 -3
  382. package/lib/mjs/components/survey/Survey.form.js +5 -0
  383. package/lib/mjs/components/table/Table.d.ts +2 -1
  384. package/lib/mjs/components/table/Table.form.d.ts +6 -3
  385. package/lib/mjs/components/table/Table.form.js +5 -0
  386. package/lib/mjs/components/tabs/Tabs.d.ts +4 -4
  387. package/lib/mjs/components/tabs/Tabs.form.d.ts +6 -3
  388. package/lib/mjs/components/tabs/Tabs.form.js +5 -0
  389. package/lib/mjs/components/tabs/Tabs.js +1 -2
  390. package/lib/mjs/components/tags/Tags.d.ts +0 -14
  391. package/lib/mjs/components/tags/Tags.form.d.ts +6 -3
  392. package/lib/mjs/components/tags/Tags.form.js +5 -0
  393. package/lib/mjs/components/textarea/TextArea.d.ts +4 -9
  394. package/lib/mjs/components/textarea/TextArea.form.d.ts +6 -3
  395. package/lib/mjs/components/textarea/TextArea.form.js +5 -0
  396. package/lib/mjs/components/textarea/TextArea.js +2 -2
  397. package/lib/mjs/components/textfield/TextField.d.ts +14 -30
  398. package/lib/mjs/components/textfield/TextField.form.d.ts +6 -3
  399. package/lib/mjs/components/textfield/TextField.form.js +5 -0
  400. package/lib/mjs/components/textfield/TextField.js +14 -17
  401. package/lib/mjs/components/time/Time.form.d.ts +6 -3
  402. package/lib/mjs/components/time/Time.form.js +5 -0
  403. package/lib/mjs/components/unknown/Unknown.form.d.ts +5 -34
  404. package/lib/mjs/components/unknown/Unknown.form.js +4 -0
  405. package/lib/mjs/components/url/Url.form.d.ts +6 -3
  406. package/lib/mjs/components/url/Url.form.js +5 -0
  407. package/lib/mjs/components/well/Well.form.d.ts +6 -3
  408. package/lib/mjs/components/well/Well.form.js +5 -0
  409. package/lib/mjs/formio.embed.d.ts +1 -2
  410. package/lib/mjs/formio.embed.js +2 -99
  411. package/lib/mjs/formio.form.d.ts +11 -4
  412. package/lib/mjs/formio.form.js +10 -3
  413. package/lib/mjs/providers/Providers.d.ts +36 -5
  414. package/lib/mjs/providers/Providers.js +29 -0
  415. package/lib/mjs/providers/address/AddressProvider.d.ts +131 -12
  416. package/lib/mjs/providers/address/AddressProvider.js +88 -2
  417. package/lib/mjs/providers/address/AzureAddressProvider.d.ts +48 -1
  418. package/lib/mjs/providers/address/AzureAddressProvider.js +37 -0
  419. package/lib/mjs/providers/address/CustomAddressProvider.d.ts +27 -4
  420. package/lib/mjs/providers/address/CustomAddressProvider.js +34 -0
  421. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +130 -6
  422. package/lib/mjs/providers/address/GoogleAddressProvider.js +72 -0
  423. package/lib/mjs/providers/address/NominatimAddressProvider.d.ts +32 -7
  424. package/lib/mjs/providers/address/NominatimAddressProvider.js +33 -0
  425. package/lib/mjs/providers/address/index.d.ts +3 -1
  426. package/lib/mjs/providers/processor/fileProcessor.d.ts +7 -1
  427. package/lib/mjs/providers/processor/fileProcessor.js +6 -0
  428. package/lib/mjs/providers/storage/azure.d.ts +6 -13
  429. package/lib/mjs/providers/storage/azure.js +5 -0
  430. package/lib/mjs/providers/storage/base64.d.ts +5 -6
  431. package/lib/mjs/providers/storage/base64.js +4 -0
  432. package/lib/mjs/providers/storage/dropbox.d.ts +6 -4
  433. package/lib/mjs/providers/storage/dropbox.js +5 -0
  434. package/lib/mjs/providers/storage/googleDrive.d.ts +7 -5
  435. package/lib/mjs/providers/storage/googleDrive.js +6 -0
  436. package/lib/mjs/providers/storage/indexeddb.d.ts +5 -7
  437. package/lib/mjs/providers/storage/indexeddb.js +4 -0
  438. package/lib/mjs/providers/storage/s3.d.ts +6 -20
  439. package/lib/mjs/providers/storage/s3.js +5 -0
  440. package/lib/mjs/providers/storage/url.d.ts +6 -7
  441. package/lib/mjs/providers/storage/url.js +10 -0
  442. package/lib/mjs/providers/storage/util.d.ts +24 -1
  443. package/lib/mjs/providers/storage/util.js +18 -0
  444. package/lib/mjs/templates/Templates.d.ts +1 -0
  445. package/lib/mjs/utils/Evaluator.d.ts +6 -3
  446. package/lib/mjs/utils/Evaluator.js +9 -20
  447. package/lib/mjs/utils/builder.d.ts +9 -7
  448. package/lib/mjs/utils/builder.js +10 -5
  449. package/lib/mjs/utils/calendarUtils.d.ts +7 -13
  450. package/lib/mjs/utils/calendarUtils.js +10 -17
  451. package/lib/mjs/utils/formUtils.d.ts +43 -171
  452. package/lib/mjs/utils/formUtils.js +6 -554
  453. package/lib/mjs/utils/utils.d.ts +370 -218
  454. package/lib/mjs/utils/utils.js +339 -222
  455. package/lib/mjs/widgets/CalendarWidget.d.ts +9 -10
  456. package/lib/mjs/widgets/CalendarWidget.js +9 -11
  457. package/package.json +22 -22
  458. package/sdk.d.ts +1 -0
  459. package/utils.d.ts +1 -0
@@ -7,7 +7,7 @@ import jtz from 'jstimezonedetect';
7
7
  import { lodashOperators } from './jsonlogic/operators';
8
8
  import dompurify from 'dompurify';
9
9
  import { getValue } from './formUtils';
10
- import Evaluator from './Evaluator';
10
+ import { Evaluator } from './Evaluator';
11
11
  import ConditionOperators from './conditionOperators';
12
12
  const interpolate = Evaluator.interpolate;
13
13
  const { fetch } = fetchPonyfill({
@@ -30,6 +30,10 @@ jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
30
30
  });
31
31
  export { jsonLogic, ConditionOperators };
32
32
  export * as moment from 'moment-timezone/moment-timezone';
33
+ /**
34
+ * Sets the path to the component and parent schema.
35
+ * @param {import('@formio/core').Component} component - The component to set the path for.
36
+ */
33
37
  function setPathToComponentAndPerentSchema(component) {
34
38
  component.path = getComponentPath(component);
35
39
  const dataParent = getDataParentComponent(component);
@@ -39,77 +43,28 @@ function setPathToComponentAndPerentSchema(component) {
39
43
  }
40
44
  /**
41
45
  * Evaluate a method.
42
- *
43
- * @param func
44
- * @param args
45
- * @return {*}
46
- */
47
- export function evaluate(func, args, ret, tokenize) {
48
- let returnVal = null;
49
- const component = args.component ? args.component : { key: 'unknown' };
50
- if (!args.form && args.instance) {
51
- args.form = _.get(args.instance, 'root._form', {});
52
- }
53
- const componentKey = component.key;
54
- if (typeof func === 'string') {
55
- if (ret) {
56
- func += `;return ${ret}`;
57
- }
58
- if (tokenize) {
59
- // Replace all {{ }} references with actual data.
60
- func = func.replace(/({{\s+(.*)\s+}})/, (match, $1, $2) => {
61
- if ($2.indexOf('data.') === 0) {
62
- return _.get(args.data, $2.replace('data.', ''));
63
- }
64
- else if ($2.indexOf('row.') === 0) {
65
- return _.get(args.row, $2.replace('row.', ''));
66
- }
67
- // Support legacy...
68
- return _.get(args.data, $2);
69
- });
70
- }
71
- try {
72
- func = Evaluator.evaluator(func, args);
73
- args = _.values(args);
74
- }
75
- catch (err) {
76
- console.warn(`An error occured within the custom function for ${componentKey}`, err);
77
- returnVal = null;
78
- func = false;
79
- }
80
- }
81
- if (typeof func === 'function') {
82
- try {
83
- returnVal = Evaluator.evaluate(func, args);
84
- }
85
- catch (err) {
86
- returnVal = null;
87
- console.warn(`An error occured within custom function for ${componentKey}`, err);
88
- }
89
- }
90
- else if (typeof func === 'object') {
91
- try {
92
- returnVal = jsonLogic.apply(func, args);
93
- }
94
- catch (err) {
95
- returnVal = null;
96
- console.warn(`An error occured within custom function for ${componentKey}`, err);
97
- }
98
- }
99
- else if (func) {
100
- console.warn(`Unknown function type for ${componentKey}`);
101
- }
102
- return returnVal;
46
+ * @param {Function|string|object} func - The function to evaluate.
47
+ * @param {*} args - A map of arguments to pass to the function.
48
+ * @param {string} ret - The name of the "return" variable in the script.
49
+ * @param {boolean} interpolate - True if the script should be interpolated before being executed.
50
+ * @param {import('@formio/core').EvaluatorOptions} options - The evaluator options.
51
+ * @returns {*} - The result of the evaluation.
52
+ */
53
+ export function evaluate(func, args, ret, interpolate, options = {}) {
54
+ return Evaluator.evaluate(func, args, ret, interpolate, undefined, options);
103
55
  }
56
+ /**
57
+ * Returns a random compoennt ID.
58
+ * @returns {string} - A random component ID.
59
+ */
104
60
  export function getRandomComponentId() {
105
61
  return `e${Math.random().toString(36).substring(7)}`;
106
62
  }
107
63
  /**
108
64
  * Get a property value of an element.
109
- *
110
- * @param style
111
- * @param prop
112
- * @return {number}
65
+ * @param {CSSStyleDeclaration} style - The style element to get the property value from.
66
+ * @param {string} prop - The property to get the value for.
67
+ * @returns {number} - The value of the property.
113
68
  */
114
69
  export function getPropertyValue(style, prop) {
115
70
  let value = style.getPropertyValue(prop);
@@ -118,9 +73,8 @@ export function getPropertyValue(style, prop) {
118
73
  }
119
74
  /**
120
75
  * Get an elements bounding rectagle.
121
- *
122
- * @param element
123
- * @return {{x: string, y: string, width: string, height: string}}
76
+ * @param {HTMLElement} element - A DOM element to get the bounding rectangle for.
77
+ * @returns {{x: number, y: number, width: number, height: number}} - The bounding rectangle.
124
78
  */
125
79
  export function getElementRect(element) {
126
80
  const style = window.getComputedStyle(element, null);
@@ -133,8 +87,8 @@ export function getElementRect(element) {
133
87
  }
134
88
  /**
135
89
  * Get non HTMLElement property in the window object
136
- * @param {String} property
137
- * @return {any || undefined}
90
+ * @param {string} property - The window property to fetch the script plugin from.
91
+ * @returns {any | undefined} - The HTML Element property on the window object.
138
92
  */
139
93
  export function getScriptPlugin(property) {
140
94
  const obj = window[property];
@@ -146,9 +100,8 @@ export function getScriptPlugin(property) {
146
100
  }
147
101
  /**
148
102
  * Determines the boolean value of a setting.
149
- *
150
- * @param value
151
- * @return {boolean}
103
+ * @param {string|boolean} value - A string or boolean value to convert to boolean.
104
+ * @returns {boolean} - The boolean value of the setting.
152
105
  */
153
106
  export function boolValue(value) {
154
107
  if (_.isBoolean(value)) {
@@ -163,21 +116,17 @@ export function boolValue(value) {
163
116
  }
164
117
  /**
165
118
  * Check to see if an ID is a mongoID.
166
- * @param text
167
- * @return {Array|{index: number, input: string}|Boolean|*}
119
+ * @param {string} text - The text to check if it is a mongoID.
120
+ * @returns {boolean} - TRUE if the text is a mongoID; FALSE otherwise.
168
121
  */
169
122
  export function isMongoId(text) {
170
- return text.toString().match(/^[0-9a-fA-F]{24}$/);
123
+ return !!text.toString().match(/^[0-9a-fA-F]{24}$/);
171
124
  }
172
125
  /**
173
126
  * Checks the calculated value for a provided component and data.
174
- *
175
- * @param {Object} component
176
- * The component to check for the calculated value.
177
- * @param {Object} submission
178
- * A submission object.
179
- * @param data
180
- * The full submission data.
127
+ * @param {import('@formio/core').Component} component - The component to check for the calculated value.
128
+ * @param {import('@formio/core').Submission} submission - A submission object.
129
+ * @param {*} rowData - The contextual row data for the component.
181
130
  */
182
131
  export function checkCalculated(component, submission, rowData) {
183
132
  // Process calculated value stuff if present.
@@ -193,13 +142,12 @@ export function checkCalculated(component, submission, rowData) {
193
142
  }
194
143
  /**
195
144
  * Check if a simple conditional evaluates to true.
196
- *
197
- * @param condition
198
- * @param condition
199
- * @param row
200
- * @param data
201
- * @param instance
202
- * @returns {boolean}
145
+ * @param {import('@formio/core').Component} component - The component to check for the conditional.
146
+ * @param {import('@formio/core').SimpleConditional} condition - The condition to check.
147
+ * @param {*} row - The row data for the component.
148
+ * @param {*} data - The full submission data.
149
+ * @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
150
+ * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
203
151
  */
204
152
  export function checkSimpleConditional(component, condition, row, data, instance) {
205
153
  if (condition.when) {
@@ -243,6 +191,13 @@ export function checkSimpleConditional(component, condition, row, data, instance
243
191
  return show ? result : !result;
244
192
  }
245
193
  }
194
+ /**
195
+ * Returns a components normalized value.
196
+ * @param {string} compPath - The full path to the component.
197
+ * @param {*} data - The data object to get the value from.
198
+ * @param {*} row - The contextual row data for the component.
199
+ * @returns {*} - The normalized value of the component.
200
+ */
246
201
  export function getComponentActualValue(compPath, data, row) {
247
202
  let value = null;
248
203
  if (row) {
@@ -259,12 +214,15 @@ export function getComponentActualValue(compPath, data, row) {
259
214
  }
260
215
  /**
261
216
  * Check custom javascript conditional.
262
- *
263
- * @param component
264
- * @param custom
265
- * @param row
266
- * @param data
267
- * @returns {*}
217
+ * @param {import('@formio/core').Component} component - The component to check for the conditional.
218
+ * @param {string} custom - The custom conditional string to evaluate.
219
+ * @param {*} row - The row data for the component.
220
+ * @param {*} data - The full submission data.
221
+ * @param {import('@formio/core').Form} form - The form object.
222
+ * @param {string} variable - The variable name for the result of the custom conditional.
223
+ * @param {*} onError - A custom return if there is an error or the value is null from the evaluation.
224
+ * @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
225
+ * @returns {*} - The result of the evaulation.
268
226
  */
269
227
  export function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
270
228
  if (typeof custom === 'string') {
@@ -278,6 +236,16 @@ export function checkCustomConditional(component, custom, row, data, form, varia
278
236
  }
279
237
  return value;
280
238
  }
239
+ /**
240
+ * Check a component for JSON conditionals.
241
+ * @param {import('@formio/core').Component} component - The component
242
+ * @param {import('@formio/core').JSONConditional} json - The json conditional to check.
243
+ * @param {*} row - The contextual row data for the component.
244
+ * @param {*} data - The full submission data.
245
+ * @param {import('@formio/core').Form} form - The Form JSON of the form.
246
+ * @param {*} onError - Custom return value if there is an error.
247
+ * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
248
+ */
281
249
  export function checkJsonConditional(component, json, row, data, form, onError) {
282
250
  try {
283
251
  return jsonLogic.apply(json, {
@@ -292,6 +260,14 @@ export function checkJsonConditional(component, json, row, data, form, onError)
292
260
  return onError;
293
261
  }
294
262
  }
263
+ /**
264
+ * Returns the contextual row data for a component.
265
+ * @param {import('@formio/core').Component} component - The component to get the row data for.
266
+ * @param {*} row - The row data for the component.
267
+ * @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
268
+ * @param {*} conditional - The component conditional.
269
+ * @returns {*} - The contextual row data for the component.
270
+ */
295
271
  function getRow(component, row, instance, conditional) {
296
272
  const condition = conditional || component.conditional;
297
273
  // If no component's instance passed (happens only in 6.x server), calculate its path based on the schema
@@ -313,15 +289,12 @@ function getRow(component, row, instance, conditional) {
313
289
  }
314
290
  /**
315
291
  * Checks the conditions for a provided component and data.
316
- *
317
- * @param component
318
- * The component to check for the condition.
319
- * @param row
320
- * The data within a row
321
- * @param data
322
- * The full submission data.
323
- *
324
- * @returns {boolean}
292
+ * @param {import('@formio/core').Component} component - The component to check for the condition.
293
+ * @param {*} row - The data within a row
294
+ * @param {*} data - The full submission data.
295
+ * @param {import('@formio/core').Form} form - The form object.
296
+ * @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
297
+ * @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
325
298
  */
326
299
  export function checkCondition(component, row, data, form, instance) {
327
300
  const { customConditional, conditional } = component;
@@ -340,12 +313,13 @@ export function checkCondition(component, row, data, form, instance) {
340
313
  }
341
314
  /**
342
315
  * Test a trigger on a component.
343
- *
344
- * @param component
345
- * @param action
346
- * @param data
347
- * @param row
348
- * @returns {mixed}
316
+ * @param {import('@formio/core').Component} component - The component to test the trigger against.
317
+ * @param {import('@formio/core').LogicTrigger} trigger - The trigger configuration.
318
+ * @param {import('@formio/core').DataObject} row - The contextual row data.
319
+ * @param {import('@formio/core').DataObject} data - The root data object.
320
+ * @param {import('@formio/core').Form} form - The form object.
321
+ * @param {any} instance - The component that is performing the trigger.
322
+ * @returns {boolean} - TRUE if the trigger should fire; FALSE otherwise.
349
323
  */
350
324
  export function checkTrigger(component, trigger, row, data, form, instance) {
351
325
  // If trigger is empty, don't fire it
@@ -364,6 +338,16 @@ export function checkTrigger(component, trigger, row, data, form, instance) {
364
338
  // If none of the types matched, don't fire the trigger.
365
339
  return false;
366
340
  }
341
+ /**
342
+ * Sets a property on a component via an executed Logic action.
343
+ * @param {import('@formio/core').Component} component - The component to set the property on.
344
+ * @param {import('@formio/core').LogicAction} action - The action to perform on the component.
345
+ * @param {string} result - The name of the variable in the evaulation to use as the result.
346
+ * @param {import('@formio/core').DataObject} row - The contextual row data.
347
+ * @param {import('@formio/core').DataObject} data - The full submission data.
348
+ * @param {any} instance - The component instance.
349
+ * @returns {import('@formio/core').Component} - The modified component.
350
+ */
367
351
  export function setActionProperty(component, action, result, row, data, instance) {
368
352
  const property = action.property.value;
369
353
  switch (action.property.type) {
@@ -395,23 +379,33 @@ export function setActionProperty(component, action, result, row, data, instance
395
379
  }
396
380
  return component;
397
381
  }
382
+ /**
383
+ * Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
384
+ * @param {string} str - The string to remove HTML tags from.
385
+ * @returns {string} - The string without HTML tags.
386
+ */
387
+ export function removeHTML(str) {
388
+ const doc = new window.DOMParser().parseFromString(str, 'text/html');
389
+ return (doc.body.textContent || '').trim();
390
+ }
398
391
  /**
399
392
  * Unescape HTML characters like &lt, &gt, &amp and etc.
400
- * @param str
401
- * @returns {string}
393
+ * @param {string} str - The string to unescape.
394
+ * @returns {string} - The unescaped string.
402
395
  */
403
396
  export function unescapeHTML(str) {
404
397
  if (typeof window === 'undefined' || !('DOMParser' in window)) {
405
398
  return str;
406
399
  }
407
- const doc = new window.DOMParser().parseFromString(str, 'text/html');
408
- return doc.documentElement.textContent;
400
+ const elem = document.createElement('textarea');
401
+ elem.innerHTML = str;
402
+ return elem.value;
409
403
  }
410
404
  /**
411
405
  * Make HTML element from string
412
- * @param str
413
- * @param selector
414
- * @returns {HTMLElement}
406
+ * @param {string} str - The string to convert to an HTML element.
407
+ * @param {string} selector - The selector to use to get the element once it is created.
408
+ * @returns {HTMLElement} - The HTML element that was created.
415
409
  */
416
410
  export function convertStringToHTMLElement(str, selector) {
417
411
  const doc = new window.DOMParser().parseFromString(str, 'text/html');
@@ -419,10 +413,10 @@ export function convertStringToHTMLElement(str, selector) {
419
413
  }
420
414
  /**
421
415
  * Make a filename guaranteed to be unique.
422
- * @param name
423
- * @param template
424
- * @param evalContext
425
- * @returns {string}
416
+ * @param {string} name - The original name of the file.
417
+ * @param {string} template - The template to use for the unique name.
418
+ * @param {object} evalContext - The context to use for the evaluation.
419
+ * @returns {string} - A unique filename.
426
420
  */
427
421
  export function uniqueName(name, template, evalContext) {
428
422
  template = template || '{{fileName}}-{{guid}}';
@@ -445,6 +439,10 @@ export function uniqueName(name, template, evalContext) {
445
439
  const uniqueName = `${Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
446
440
  return uniqueName;
447
441
  }
442
+ /**
443
+ * Returns a GUID
444
+ * @returns {string} - A GUID.
445
+ */
448
446
  export function guid() {
449
447
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
450
448
  const r = Math.random() * 16 | 0;
@@ -456,9 +454,8 @@ export function guid() {
456
454
  }
457
455
  /**
458
456
  * Return a translated date setting.
459
- *
460
- * @param date
461
- * @return {(null|Date)}
457
+ * @param {string|Date} date - The date to translate.
458
+ * @returns {(null|Date)} - The translated date.
462
459
  */
463
460
  export function getDateSetting(date) {
464
461
  if (_.isNil(date) || _.isNaN(date) || date === '') {
@@ -499,13 +496,17 @@ export function getDateSetting(date) {
499
496
  }
500
497
  return dateSetting.toDate();
501
498
  }
499
+ /**
500
+ * Returns true if the date is a valid date. False otherwise.
501
+ * @param {Date|string} date - The date to check for validity.
502
+ * @returns {boolean} - TRUE if the date is valid; FALSE otherwise.
503
+ */
502
504
  export function isValidDate(date) {
503
505
  return _.isDate(date) && !_.isNaN(date.getDate());
504
506
  }
505
507
  /**
506
508
  * Get the current timezone string.
507
- *
508
- * @return {string}
509
+ * @returns {string} - The current timezone.
509
510
  */
510
511
  export function currentTimezone() {
511
512
  if (moment.currentTimezone) {
@@ -516,10 +517,9 @@ export function currentTimezone() {
516
517
  }
517
518
  /**
518
519
  * Get an offset date provided a date object and timezone object.
519
- *
520
- * @param date
521
- * @param timezone
522
- * @return {Date}
520
+ * @param {Date} date - The date to offset.
521
+ * @param {string} timezone - The timezone to offset the date to.
522
+ * @returns {Date} - The offset date.
523
523
  */
524
524
  export function offsetDate(date, timezone) {
525
525
  if (timezone === 'UTC') {
@@ -536,17 +536,15 @@ export function offsetDate(date, timezone) {
536
536
  }
537
537
  /**
538
538
  * Returns if the zones are loaded.
539
- *
540
- * @return {boolean}
539
+ * @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
541
540
  */
542
541
  export function zonesLoaded() {
543
542
  return moment.zonesLoaded;
544
543
  }
545
544
  /**
546
545
  * Returns if we should load the zones.
547
- *
548
- * @param timezone
549
- * @return {boolean}
546
+ * @param {string} timezone - The timezone to check if we should load the zones.
547
+ * @returns {boolean} - TRUE if we should load the zones; FALSE otherwise.
550
548
  */
551
549
  export function shouldLoadZones(timezone) {
552
550
  if (timezone === currentTimezone() || timezone === 'UTC') {
@@ -556,8 +554,9 @@ export function shouldLoadZones(timezone) {
556
554
  }
557
555
  /**
558
556
  * Externally load the timezone data.
559
- *
560
- * @return {Promise<any> | *}
557
+ * @param {string} url - The URL to load the timezone data from.
558
+ * @param {string} timezone - The timezone to load.
559
+ * @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
561
560
  */
562
561
  export function loadZones(url, timezone) {
563
562
  if (timezone && !shouldLoadZones(timezone)) {
@@ -581,11 +580,10 @@ export function loadZones(url, timezone) {
581
580
  }
582
581
  /**
583
582
  * Get the moment date object for translating dates with timezones.
584
- *
585
- * @param value
586
- * @param format
587
- * @param timezone
588
- * @return {*}
583
+ * @param {string|Date} value - The value to convert into a moment date.
584
+ * @param {string} format - The format to convert the date to.
585
+ * @param {string} timezone - The timezone to convert the date to.
586
+ * @returns {Date} - The moment date object.
589
587
  */
590
588
  export function momentDate(value, format, timezone) {
591
589
  const momentDate = moment(value);
@@ -602,11 +600,12 @@ export function momentDate(value, format, timezone) {
602
600
  }
603
601
  /**
604
602
  * Format a date provided a value, format, and timezone object.
605
- *
606
- * @param value
607
- * @param format
608
- * @param timezone
609
- * @return {string}
603
+ * @param {string} timezonesUrl - The URL to load the timezone data from.
604
+ * @param {string|Date} value - The value to format.
605
+ * @param {string} format - The format to format the date to.
606
+ * @param {string} timezone - The timezone to format the date to.
607
+ * @param {string} flatPickrInputFormat - The format to use for flatpickr input.
608
+ * @returns {string} - The formatted date.
610
609
  */
611
610
  export function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat) {
612
611
  const momentDate = moment(value, flatPickrInputFormat || undefined);
@@ -639,12 +638,12 @@ export function formatDate(timezonesUrl, value, format, timezone, flatPickrInput
639
638
  }
640
639
  /**
641
640
  * Pass a format function to format within a timezone.
642
- *
643
- * @param formatFn
644
- * @param date
645
- * @param format
646
- * @param timezone
647
- * @return {string}
641
+ * @param {string} timezonesUrl - The URL to load the timezone data from.
642
+ * @param {Function} formatFn - The format function to use.
643
+ * @param {Date|string} date - The date to format.
644
+ * @param {string} format - The format to format the date to.
645
+ * @param {string} timezone - The timezone to format the date to.
646
+ * @returns {string} - The formatted date.
648
647
  */
649
648
  export function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
650
649
  if (timezone === currentTimezone()) {
@@ -663,6 +662,11 @@ export function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
663
662
  return formatFn(date, format);
664
663
  }
665
664
  }
665
+ /**
666
+ * Returns the local date format information.
667
+ * @param {Intl.LocalesArgument} locale - The locale to get the date format for.
668
+ * @returns {object} - The local date format information.
669
+ */
666
670
  export function getLocaleDateFormatInfo(locale) {
667
671
  const formatInfo = {};
668
672
  const day = 21;
@@ -673,8 +677,8 @@ export function getLocaleDateFormatInfo(locale) {
673
677
  }
674
678
  /**
675
679
  * Convert the format from the angular-datepicker module to flatpickr format.
676
- * @param format
677
- * @return {string}
680
+ * @param {string} format - The format to convert.
681
+ * @returns {string} - The converted format.
678
682
  */
679
683
  export function convertFormatToFlatpickr(format) {
680
684
  return format
@@ -704,8 +708,8 @@ export function convertFormatToFlatpickr(format) {
704
708
  }
705
709
  /**
706
710
  * Convert the format from the angular-datepicker module to moment format.
707
- * @param format
708
- * @return {string}
711
+ * @param {string} format - The format to convert.
712
+ * @returns {string} - The converted format.
709
713
  */
710
714
  export function convertFormatToMoment(format) {
711
715
  return format
@@ -720,6 +724,11 @@ export function convertFormatToMoment(format) {
720
724
  // Unix Timestamp
721
725
  .replace(/U/g, 'X');
722
726
  }
727
+ /**
728
+ * Convert the format from the angular-datepicker module to mask format.
729
+ * @param {string} format - The format to convert.
730
+ * @returns {string} - The converted format.
731
+ */
723
732
  export function convertFormatToMask(format) {
724
733
  return format
725
734
  // Long month replacement.
@@ -777,6 +786,13 @@ export function getInputMask(mask, placeholderChar) {
777
786
  }
778
787
  return maskArray;
779
788
  }
789
+ /**
790
+ * Unmasks a value using the provided mask and placeholder characters.
791
+ * @param {string} value - The value to unmask.
792
+ * @param {string} mask - The mask to use for unmasking.
793
+ * @param {string} placeholderChar - The placeholder character to use for unmasking.
794
+ * @returns {string} - The unmasked value.
795
+ */
780
796
  export function unmaskValue(value, mask, placeholderChar) {
781
797
  if (!mask || !value || value.length > mask.length) {
782
798
  return value;
@@ -792,6 +808,12 @@ export function unmaskValue(value, mask, placeholderChar) {
792
808
  unmaskedValue = unmaskedValue.join('').replace(placeholderChar, '');
793
809
  return unmaskedValue;
794
810
  }
811
+ /**
812
+ * Returns true if the value matches the input mask format.
813
+ * @param {string} value - The value to check.
814
+ * @param {string} inputMask - The input mask to check against.
815
+ * @returns {boolean} - TRUE if the value matches the input mask; FALSE otherwise.
816
+ */
795
817
  export function matchInputMask(value, inputMask) {
796
818
  if (!inputMask) {
797
819
  return true;
@@ -809,6 +831,11 @@ export function matchInputMask(value, inputMask) {
809
831
  }
810
832
  return true;
811
833
  }
834
+ /**
835
+ * Returns the number separators (i.e. 1,000) for the provided language.
836
+ * @param {string} lang - The language code to get the number separators for.
837
+ * @returns {{delimiter: string, decimalSeparator: string}} - The number separators.
838
+ */
812
839
  export function getNumberSeparators(lang = 'en') {
813
840
  const formattedNumberString = (12345.6789).toLocaleString(lang);
814
841
  const delimeters = formattedNumberString.match(/..(.)...(.)../);
@@ -823,6 +850,12 @@ export function getNumberSeparators(lang = 'en') {
823
850
  decimalSeparator: (delimeters.length > 2) ? delimeters[2] : '.',
824
851
  };
825
852
  }
853
+ /**
854
+ * Returns the number for the maximum amount of decimal places for a number.
855
+ * @param {import('@formio/core').Component} component - The component to check for decimal limits.
856
+ * @param {number} defaultLimit - The default limit to use if none is provided in the component.
857
+ * @returns {number} - The number of decimal places allowed.
858
+ */
826
859
  export function getNumberDecimalLimit(component, defaultLimit) {
827
860
  if (_.has(component, 'decimalLimit')) {
828
861
  return _.get(component, 'decimalLimit');
@@ -838,6 +871,15 @@ export function getNumberDecimalLimit(component, defaultLimit) {
838
871
  }
839
872
  return decimalLimit;
840
873
  }
874
+ /**
875
+ * Returns the currency affixes for a specific language.
876
+ * @param {object} arg0 - The arguments object.
877
+ * @param {string} arg0.currency - The currency code to get the affixes for.
878
+ * @param {number} arg0.decimalLimit - The number of decimal places to use.
879
+ * @param {string} arg0.decimalSeparator - The decimal separator to use.
880
+ * @param {string} arg0.lang - The language code to use.
881
+ * @returns {{prefix: string, suffix: string}} - The currency affixes.
882
+ */
841
883
  export function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }) {
842
884
  // Get the prefix and suffix from the localized string.
843
885
  let regex = `(.*)?${(100).toLocaleString(lang)}`;
@@ -859,10 +901,9 @@ export function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, l
859
901
  }
860
902
  /**
861
903
  * Fetch the field data provided a component.
862
- *
863
- * @param data
864
- * @param component
865
- * @return {*}
904
+ * @param {import('@formio/core').DataObject} data - The data object to fetch the field data from.
905
+ * @param {import('@formio/core').Component} component - The component to fetch the field data for.
906
+ * @returns {*} - The field data.
866
907
  */
867
908
  export function fieldData(data, component) {
868
909
  if (!data) {
@@ -908,16 +949,23 @@ export function fieldData(data, component) {
908
949
  }
909
950
  /**
910
951
  * Delays function execution with possibility to execute function synchronously or cancel it.
911
- *
912
- * @param fn Function to delay
913
- * @param delay Delay time
914
- * @return {*}
952
+ * @param {Function} fn - Function to delay
953
+ * @param {number} delay - Delay time
954
+ * @param {...any} args - Arguments to pass to the function
955
+ * @returns {*} - Function to cancel the delay
915
956
  */
916
957
  export function delay(fn, delay = 0, ...args) {
917
958
  const timer = setTimeout(fn, delay, ...args);
959
+ /**
960
+ *
961
+ */
918
962
  function cancel() {
919
963
  clearTimeout(timer);
920
964
  }
965
+ /**
966
+ * Execute the function early.
967
+ * @returns {*} - The result of the function.
968
+ */
921
969
  function earlyCall() {
922
970
  cancel();
923
971
  return fn(...args);
@@ -928,11 +976,9 @@ export function delay(fn, delay = 0, ...args) {
928
976
  }
929
977
  /**
930
978
  * Iterate the given key to make it unique.
931
- *
932
- * @param {String} key
979
+ * @param {string} key
933
980
  * Modify the component key to be unique.
934
- *
935
- * @returns {String}
981
+ * @returns {string}
936
982
  * The new component key.
937
983
  */
938
984
  export function iterateKey(key) {
@@ -945,10 +991,9 @@ export function iterateKey(key) {
945
991
  }
946
992
  /**
947
993
  * Determines a unique key within a map provided the base key.
948
- *
949
- * @param map
950
- * @param base
951
- * @return {*}
994
+ * @param {Record<string, string>} map - The map to check for uniqueness.
995
+ * @param {string} base - The base path of the key.
996
+ * @returns {string} - The unique key.
952
997
  */
953
998
  export function uniqueKey(map, base) {
954
999
  let newKey = base;
@@ -959,8 +1004,9 @@ export function uniqueKey(map, base) {
959
1004
  }
960
1005
  /**
961
1006
  * Determines the major version number of bootstrap.
962
- *
963
- * @return {number}
1007
+ * @param {object} options - The options to check for bootstrap version.
1008
+ * @param {string} options.bootstrap - The bootstrap version to use.
1009
+ * @returns {number} - The bootstrap version.
964
1010
  */
965
1011
  export function bootstrapVersion(options) {
966
1012
  if (options.bootstrap) {
@@ -977,9 +1023,8 @@ export function bootstrapVersion(options) {
977
1023
  /**
978
1024
  * Retrun provided argument.
979
1025
  * If argument is a function, returns the result of a function call.
980
- * @param {*} e;
981
- *
982
- * @return {*}
1026
+ * @param {Function|any} e - The argument to check if a function and call if so.
1027
+ * @returns {any} - Either the result of the function call (e) or e if it is not a function.
983
1028
  */
984
1029
  export function unfold(e) {
985
1030
  if (typeof e === 'function') {
@@ -989,27 +1034,32 @@ export function unfold(e) {
989
1034
  }
990
1035
  /**
991
1036
  * Map values through unfold and return first non-nil value.
992
- * @param {Array<T>} collection;
993
- *
994
- * @return {T}
1037
+ * @param {Array<T>} collection - The collection to map through unfold.;
1038
+ * @returns {T} - The first non-nil value.
995
1039
  */
996
1040
  export const firstNonNil = _.flow([
997
1041
  _.partialRight(_.map, unfold),
998
1042
  _.partialRight(_.find, v => !_.isUndefined(v))
999
1043
  ]);
1000
- /*
1001
- * Create enclosed state.
1002
- * Returns functions to getting and cycling between states.
1044
+ /**
1045
+ * Create enclosed state. Returns functions to getting and cycling between states.
1003
1046
  * @param {*} a - initial state.
1004
1047
  * @param {*} b - next state.
1005
- * @return {Functions[]} -- [get, toggle];
1048
+ * @returns {Functions[]} -- [get, toggle];
1006
1049
  */
1007
1050
  export function withSwitch(a, b) {
1008
1051
  let state = a;
1009
1052
  let next = b;
1053
+ /**
1054
+ * Returns the state of the switch.
1055
+ * @returns {*} - The current state.
1056
+ */
1010
1057
  function get() {
1011
1058
  return state;
1012
1059
  }
1060
+ /**
1061
+ * Toggles the state of the switch.
1062
+ */
1013
1063
  function toggle() {
1014
1064
  const prev = state;
1015
1065
  state = next;
@@ -1017,6 +1067,14 @@ export function withSwitch(a, b) {
1017
1067
  }
1018
1068
  return [get, toggle];
1019
1069
  }
1070
+ /**
1071
+ * Create a function that will call the provided function only the provided limit.
1072
+ * @param {Function} callback - The callback to call.
1073
+ * @param {object} options - The options to use.
1074
+ * @param {number} options.limit - The limit to call the callback.
1075
+ * @param {number} options.delay - The delay to wait before resetting the call count.
1076
+ * @returns {Function} - The function that will call the callback only the provided limit.
1077
+ */
1020
1078
  export function observeOverload(callback, options = {}) {
1021
1079
  const { limit = 50, delay = 500 } = options;
1022
1080
  let callCount = 0;
@@ -1036,6 +1094,13 @@ export function observeOverload(callback, options = {}) {
1036
1094
  }
1037
1095
  };
1038
1096
  }
1097
+ /**
1098
+ * Returns the components that are provided within an evaluation context.
1099
+ * @param {any} context - The evaluation context to get the components from.
1100
+ * @param {boolean} excludeNested - Exclude nested components.
1101
+ * @param {Array<string>} excludedTypes - The types of components to exclude.
1102
+ * @returns {Array} - The components within the evaluation context.
1103
+ */
1039
1104
  export function getContextComponents(context, excludeNested, excludedTypes = []) {
1040
1105
  const values = [];
1041
1106
  context.utils.eachComponent(context.instance.options.editForm.components, (component, path) => {
@@ -1049,6 +1114,11 @@ export function getContextComponents(context, excludeNested, excludedTypes = [])
1049
1114
  });
1050
1115
  return values;
1051
1116
  }
1117
+ /**
1118
+ * Returns the button components that are within an evaluation context.
1119
+ * @param {any} context - The evaluation context to get the components from.
1120
+ * @returns {Array} - The button components within the evaluation context.
1121
+ */
1052
1122
  export function getContextButtons(context) {
1053
1123
  const values = [];
1054
1124
  context.utils.eachComponent(context.instance.options.editForm.components, (component) => {
@@ -1065,12 +1135,9 @@ export function getContextButtons(context) {
1065
1135
  const inTextTags = ['#text', 'A', 'B', 'EM', 'I', 'SMALL', 'STRONG', 'SUB', 'SUP', 'INS', 'DEL', 'MARK', 'CODE'];
1066
1136
  /**
1067
1137
  * Helper function for 'translateHTMLTemplate'. Translates text value of the passed html element.
1068
- *
1069
- * @param {HTMLElement} elem
1070
- * @param {Function} translate
1071
- *
1072
- * @returns {String}
1073
- * Translated element template.
1138
+ * @param {HTMLElement} elem - The element to translate.
1139
+ * @param {Function} translate - The translation function.
1140
+ * @returns {string} - Translated element template.
1074
1141
  */
1075
1142
  function translateElemValue(elem, translate) {
1076
1143
  if (!elem.innerText) {
@@ -1101,10 +1168,8 @@ function translateElemValue(elem, translate) {
1101
1168
  }
1102
1169
  /**
1103
1170
  * Helper function for 'translateHTMLTemplate'. Goes deep through html tag children and calls function to translate their text values.
1104
- *
1105
- * @param {HTMLElement} tag
1106
- * @param {Function} translate
1107
- *
1171
+ * @param {HTMLElement} tag - The tag to translate.
1172
+ * @param {Function} translate - The translation function.
1108
1173
  * @returns {void}
1109
1174
  */
1110
1175
  function translateDeepTag(tag, translate) {
@@ -1120,12 +1185,9 @@ function translateDeepTag(tag, translate) {
1120
1185
  }
1121
1186
  /**
1122
1187
  * Translates text values in html template.
1123
- *
1124
- * @param {String} template
1125
- * @param {Function} translate
1126
- *
1127
- * @returns {String}
1128
- * Html template with translated values.
1188
+ * @param {string} template - The template to translate.
1189
+ * @param {Function} translate - The translation function.
1190
+ * @returns {string} - Html template with translated values.
1129
1191
  */
1130
1192
  export function translateHTMLTemplate(template, translate) {
1131
1193
  const isHTML = /<[^>]*>/.test(template);
@@ -1142,9 +1204,9 @@ export function translateHTMLTemplate(template, translate) {
1142
1204
  }
1143
1205
  /**
1144
1206
  * Sanitize an html string.
1145
- *
1146
- * @param string
1147
- * @returns {*}
1207
+ * @param {string} string - The string to sanitize.
1208
+ * @param {any} options - The options to use for sanitization.
1209
+ * @returns {string} - The sanitized html string.
1148
1210
  */
1149
1211
  export function sanitize(string, options) {
1150
1212
  if (typeof dompurify.sanitize !== 'function') {
@@ -1192,11 +1254,18 @@ export function sanitize(string, options) {
1192
1254
  }
1193
1255
  /**
1194
1256
  * Fast cloneDeep for JSON objects only.
1257
+ * @param {any} obj - The object to perform a fast clone deep against.
1258
+ * @returns {any} - The cloned object.
1195
1259
  */
1196
1260
  export function fastCloneDeep(obj) {
1197
1261
  return obj ? JSON.parse(JSON.stringify(obj)) : obj;
1198
1262
  }
1199
1263
  export { Evaluator, interpolate };
1264
+ /**
1265
+ * Returns if the component is an input component.
1266
+ * @param {import('@formio/core').Component} componentJson - The JSON of a component.
1267
+ * @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
1268
+ */
1200
1269
  export function isInputComponent(componentJson) {
1201
1270
  if (componentJson.input === false || componentJson.input === true) {
1202
1271
  return componentJson.input;
@@ -1216,6 +1285,11 @@ export function isInputComponent(componentJson) {
1216
1285
  return true;
1217
1286
  }
1218
1287
  }
1288
+ /**
1289
+ * Takes a component path, and returns a component path array.
1290
+ * @param {string} pathStr - The path string to convert to an array.
1291
+ * @returns {Arryay<number>} - The array of paths.
1292
+ */
1219
1293
  export function getArrayFromComponentPath(pathStr) {
1220
1294
  if (!pathStr || !_.isString(pathStr)) {
1221
1295
  if (!_.isArray(pathStr)) {
@@ -1229,6 +1303,12 @@ export function getArrayFromComponentPath(pathStr) {
1229
1303
  .split('.')
1230
1304
  .map(part => _.defaultTo(_.toNumber(part), part));
1231
1305
  }
1306
+ /**
1307
+ * Returns true if the component is a child of the parent.
1308
+ * @param {any} child - The child component to check.
1309
+ * @param {any} parent - The parent component to check.
1310
+ * @returns {boolean} - TRUE if the child is a child of the parent; FALSE otherwise.
1311
+ */
1232
1312
  export function isChildOf(child, parent) {
1233
1313
  while (child && child.parent) {
1234
1314
  if (child.parent === parent) {
@@ -1238,6 +1318,11 @@ export function isChildOf(child, parent) {
1238
1318
  }
1239
1319
  return false;
1240
1320
  }
1321
+ /**
1322
+ * Takes an array of component path indexes, and returns a string version of that array.
1323
+ * @param {Array<number>} path - The path array to convert to a string.
1324
+ * @returns {string} - The string version of the path.
1325
+ */
1241
1326
  export function getStringFromComponentPath(path) {
1242
1327
  if (!_.isArray(path)) {
1243
1328
  return path;
@@ -1253,16 +1338,21 @@ export function getStringFromComponentPath(path) {
1253
1338
  });
1254
1339
  return strPath;
1255
1340
  }
1341
+ /**
1342
+ * Takes a number and rounds it to the provided precision amount.
1343
+ * @param {number} number - The number to round.
1344
+ * @param {number} precision - The precision to round the number to.
1345
+ * @returns {string} - The rounded number.
1346
+ */
1256
1347
  export function round(number, precision) {
1257
1348
  if (_.isNumber(number)) {
1258
1349
  return number.toFixed(precision);
1259
1350
  }
1260
- return number;
1351
+ return number.toString();
1261
1352
  }
1262
1353
  /**
1263
1354
  * Check for Internet Explorer browser version
1264
- *
1265
- * @return {(number|null)}
1355
+ * @returns {(number|null)} - The IE browser version or null if not IE
1266
1356
  */
1267
1357
  export function getIEBrowserVersion() {
1268
1358
  const { ie, version } = getBrowserInfo();
@@ -1270,8 +1360,7 @@ export function getIEBrowserVersion() {
1270
1360
  }
1271
1361
  /**
1272
1362
  * Get browser name and version (modified from 'jquery-browser-plugin')
1273
- *
1274
- * @return {Object} -- {{browser name, version, isWebkit?}}
1363
+ * @returns {object} -- {{browser name, version, isWebkit?}}
1275
1364
  * Possible browser names: chrome, safari, ie, edge, opera, mozilla, yabrowser
1276
1365
  */
1277
1366
  export function getBrowserInfo() {
@@ -1319,12 +1408,19 @@ export function getBrowserInfo() {
1319
1408
  }
1320
1409
  return browser;
1321
1410
  }
1411
+ /**
1412
+ * Takes a component path, which may include array indicies (i.e. [0][1]), and returns the compoennt path without the indicies.
1413
+ * @param {string} path - The path to remove the indicies from.
1414
+ * @returns {string} - The path without the indicies.
1415
+ */
1322
1416
  export function getComponentPathWithoutIndicies(path = '') {
1323
1417
  return path.replace(/\[\d+\]/, '');
1324
1418
  }
1325
1419
  /**
1326
1420
  * Returns a path to the component which based on its schema
1327
- * @param {*} component is a component's schema containing link to its parent's schema in the 'parent' property
1421
+ * @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
1422
+ * @param {string} path - Path to the component
1423
+ * @returns {string} - Path to the component
1328
1424
  */
1329
1425
  export function getComponentPath(component, path = '') {
1330
1426
  if (!component || !component.key || component?._form?.display === 'wizard') { // unlike the Webform, the Wizard has the key and it is a duplicate of the panel key
@@ -1335,8 +1431,8 @@ export function getComponentPath(component, path = '') {
1335
1431
  }
1336
1432
  /**
1337
1433
  * Returns a parent component of the passed component instance skipping all the Layout components
1338
- * @param {*} componentInstance
1339
- * @return {(Component|undefined)}
1434
+ * @param {Component} componentInstance - The component to check for the parent.
1435
+ * @returns {Component|undefined} - The parent data component.
1340
1436
  */
1341
1437
  export function getDataParentComponent(componentInstance) {
1342
1438
  if (!componentInstance) {
@@ -1352,8 +1448,8 @@ export function getDataParentComponent(componentInstance) {
1352
1448
  }
1353
1449
  /**
1354
1450
  * Returns whether the value is a promise
1355
- * @param value
1356
- * @return {boolean}
1451
+ * @param {any} value - The value to check
1452
+ * @returns {boolean} - TRUE if the value is a promise; FALSE otherwise
1357
1453
  */
1358
1454
  export function isPromise(value) {
1359
1455
  return value
@@ -1364,9 +1460,9 @@ export function isPromise(value) {
1364
1460
  /**
1365
1461
  * Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
1366
1462
  * changes by itself, e.g. EditGrid)
1367
- * @param componentInstance
1368
- * @param firstPass
1369
- * @returns {boolean|boolean|*}
1463
+ * @param {Component} componentInstance - The component to check for the scoping parent.
1464
+ * @param {boolean} firstPass - Whether it is the first pass of the function
1465
+ * @returns {boolean|*} - TRUE if the component has a scoping parent; FALSE otherwise
1370
1466
  */
1371
1467
  export function isInsideScopingComponent(componentInstance, firstPass = true) {
1372
1468
  if (!firstPass && componentInstance?.hasScopedChildren) {
@@ -1381,6 +1477,11 @@ export function isInsideScopingComponent(componentInstance, firstPass = true) {
1381
1477
  }
1382
1478
  return false;
1383
1479
  }
1480
+ /**
1481
+ * Returns all the focusable elements within the provided dom element.
1482
+ * @param {HTMLElement} element - The element to get the focusable elements from.
1483
+ * @returns {NodeList<HTMLElement>} - The focusable elements within the provided element.
1484
+ */
1384
1485
  export function getFocusableElements(element) {
1385
1486
  const focusableSelector = `button:not([disabled]), input:not([disabled]), select:not([disabled]),
1386
1487
  textarea:not([disabled]), button:not([disabled]), [href]`;
@@ -1397,6 +1498,11 @@ export const componentValueTypes = {
1397
1498
  date: 'date',
1398
1499
  any: 'any',
1399
1500
  };
1501
+ /**
1502
+ * Returns the saved types for the component
1503
+ * @param {import('@formio/core').Component} fullSchema - The component schema
1504
+ * @returns {Array<string>|null} - The saved types for the component
1505
+ */
1400
1506
  export function getComponentSavedTypes(fullSchema) {
1401
1507
  const schema = fullSchema || {};
1402
1508
  if (schema.persistent !== true) {
@@ -1409,9 +1515,10 @@ export function getComponentSavedTypes(fullSchema) {
1409
1515
  }
1410
1516
  /**
1411
1517
  * Interpolates @formio/core errors so that they are compatible with the renderer
1412
- * @param {FieldError[]} errors
1413
- * @param firstPass
1414
- * @returns {[]}
1518
+ * @param {Component} component - The component to interpolate the errors for
1519
+ * @param {FieldError[]} errors - The errors to interpolate
1520
+ * @param {Function} interpolateFn - The interpolation function
1521
+ * @returns {[]} - The interpolated errors
1415
1522
  */
1416
1523
  export const interpolateErrors = (component, errors, interpolateFn) => {
1417
1524
  return errors.map((error) => {
@@ -1421,6 +1528,11 @@ export const interpolateErrors = (component, errors, interpolateFn) => {
1421
1528
  return { ...error, message: unescapeHTML(interpolateFn(toInterpolate, context)), context: { ...context } };
1422
1529
  });
1423
1530
  };
1531
+ /**
1532
+ * Returns the template keys inside the template code.
1533
+ * @param {string} template - The template to get the keys from.
1534
+ * @returns {Array<string>} - The keys inside the template.
1535
+ */
1424
1536
  export function getItemTemplateKeys(template) {
1425
1537
  const templateKeys = [];
1426
1538
  if (!template) {
@@ -1437,6 +1549,11 @@ export function getItemTemplateKeys(template) {
1437
1549
  }
1438
1550
  return templateKeys;
1439
1551
  }
1552
+ /**
1553
+ * Returns if the component is a select resource with an object for its value.
1554
+ * @param {import('@formio/core').Component} comp - The component to check.
1555
+ * @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
1556
+ */
1440
1557
  export function isSelectResourceWithObjectValue(comp = {}) {
1441
1558
  const { reference, dataSrc, valueProperty } = comp;
1442
1559
  return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));