@formio/js 5.2.4-rc.0 → 5.2.5

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 (512) hide show
  1. package/dist/formio.builder.css +50 -161
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.embed.js +1 -1
  4. package/dist/formio.embed.min.js +1 -1
  5. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  6. package/dist/formio.form.css +49 -158
  7. package/dist/formio.form.js +108 -152
  8. package/dist/formio.form.min.css +1 -1
  9. package/dist/formio.form.min.js +1 -1
  10. package/dist/formio.form.min.js.LICENSE.txt +1 -1
  11. package/dist/formio.full.css +50 -161
  12. package/dist/formio.full.js +227 -401
  13. package/dist/formio.full.min.css +1 -1
  14. package/dist/formio.full.min.js +1 -1
  15. package/dist/formio.full.min.js.LICENSE.txt +1 -1
  16. package/dist/formio.js +18 -51
  17. package/dist/formio.min.js +1 -1
  18. package/dist/formio.min.js.LICENSE.txt +1 -1
  19. package/dist/formio.utils.js +14 -47
  20. package/dist/formio.utils.min.js +1 -1
  21. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  22. package/lib/cjs/CDN.js +12 -12
  23. package/lib/cjs/Element.d.ts +2 -3
  24. package/lib/cjs/Element.js +26 -29
  25. package/lib/cjs/Embed.js +42 -75
  26. package/lib/cjs/EventEmitter.js +1 -1
  27. package/lib/cjs/Form.d.ts +341 -371
  28. package/lib/cjs/Form.js +39 -153
  29. package/lib/cjs/FormBuilder.d.ts +3 -3
  30. package/lib/cjs/FormBuilder.js +3 -2
  31. package/lib/cjs/Formio.js +23 -26
  32. package/lib/cjs/InlineEmbed.js +17 -23
  33. package/lib/cjs/PDF.d.ts +0 -1
  34. package/lib/cjs/PDF.js +15 -18
  35. package/lib/cjs/PDFBuilder.js +36 -51
  36. package/lib/cjs/Webform.d.ts +366 -8
  37. package/lib/cjs/Webform.js +238 -177
  38. package/lib/cjs/WebformBuilder.js +152 -221
  39. package/lib/cjs/Wizard.js +65 -95
  40. package/lib/cjs/WizardBuilder.js +19 -27
  41. package/lib/cjs/addons/FormioAddon.js +1 -1
  42. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +57 -59
  43. package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +16 -24
  44. package/lib/cjs/addons/index.js +3 -3
  45. package/lib/cjs/components/Components.js +4 -0
  46. package/lib/cjs/components/_classes/component/Component.form.js +11 -11
  47. package/lib/cjs/components/_classes/component/Component.js +198 -309
  48. package/lib/cjs/components/_classes/component/editForm/Component.edit.addons.js +4 -2
  49. package/lib/cjs/components/_classes/component/editForm/Component.edit.api.js +5 -5
  50. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +11 -9
  51. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  52. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +25 -39
  53. package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +29 -47
  54. package/lib/cjs/components/_classes/component/editForm/Component.edit.layout.js +9 -9
  55. package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +7 -5
  56. package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +34 -37
  57. package/lib/cjs/components/_classes/component/editForm/utils.js +16 -12
  58. package/lib/cjs/components/_classes/componentModal/ComponentModal.js +6 -6
  59. package/lib/cjs/components/_classes/field/Field.js +1 -7
  60. package/lib/cjs/components/_classes/input/Input.js +26 -30
  61. package/lib/cjs/components/_classes/list/ListComponent.form.js +1 -1
  62. package/lib/cjs/components/_classes/list/ListComponent.js +18 -27
  63. package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +9 -36
  64. package/lib/cjs/components/_classes/multivalue/Multivalue.js +13 -32
  65. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  66. package/lib/cjs/components/_classes/nested/NestedComponent.form.js +3 -3
  67. package/lib/cjs/components/_classes/nested/NestedComponent.js +75 -67
  68. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +14 -19
  69. package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +17 -19
  70. package/lib/cjs/components/address/Address.d.ts +0 -1
  71. package/lib/cjs/components/address/Address.js +52 -57
  72. package/lib/cjs/components/address/editForm/Address.edit.data.js +2 -2
  73. package/lib/cjs/components/address/editForm/Address.edit.display.js +2 -2
  74. package/lib/cjs/components/address/editForm/Address.edit.provider.js +11 -53
  75. package/lib/cjs/components/alert/Alert.js +15 -21
  76. package/lib/cjs/components/button/Button.form.js +1 -1
  77. package/lib/cjs/components/button/Button.js +47 -64
  78. package/lib/cjs/components/button/editForm/Button.edit.display.js +9 -49
  79. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  80. package/lib/cjs/components/checkbox/Checkbox.form.js +3 -3
  81. package/lib/cjs/components/checkbox/Checkbox.js +20 -28
  82. package/lib/cjs/components/checkbox/editForm/Checkbox.edit.data.js +1 -1
  83. package/lib/cjs/components/checkbox/editForm/Checkbox.edit.display.js +3 -13
  84. package/lib/cjs/components/checkbox/editForm/Checkbox.edit.validation.js +2 -2
  85. package/lib/cjs/components/columns/Columns.form.js +1 -1
  86. package/lib/cjs/components/columns/Columns.js +12 -24
  87. package/lib/cjs/components/columns/editForm/Columns.edit.display.js +17 -17
  88. package/lib/cjs/components/container/Container.form.js +2 -2
  89. package/lib/cjs/components/container/Container.js +4 -6
  90. package/lib/cjs/components/container/editForm/Container.edit.data.js +3 -3
  91. package/lib/cjs/components/container/editForm/Container.edit.display.js +4 -4
  92. package/lib/cjs/components/content/Content.form.js +2 -4
  93. package/lib/cjs/components/content/Content.js +8 -10
  94. package/lib/cjs/components/content/editForm/Content.edit.display.js +10 -10
  95. package/lib/cjs/components/currency/Currency.form.js +3 -3
  96. package/lib/cjs/components/currency/Currency.js +10 -19
  97. package/lib/cjs/components/currency/editForm/Currency.edit.data.js +5 -5
  98. package/lib/cjs/components/currency/editForm/Currency.edit.display.js +8 -8
  99. package/lib/cjs/components/datagrid/DataGrid.form.js +3 -3
  100. package/lib/cjs/components/datagrid/DataGrid.js +42 -92
  101. package/lib/cjs/components/datagrid/editForm/DataGrid.edit.data.js +1 -1
  102. package/lib/cjs/components/datagrid/editForm/DataGrid.edit.display.js +14 -14
  103. package/lib/cjs/components/datagrid/editForm/DataGrid.edit.validation.js +3 -3
  104. package/lib/cjs/components/datamap/DataMap.form.js +2 -2
  105. package/lib/cjs/components/datamap/DataMap.js +35 -46
  106. package/lib/cjs/components/datamap/editForm/DataMap.edit.data.js +1 -1
  107. package/lib/cjs/components/datamap/editForm/DataMap.edit.display.js +8 -8
  108. package/lib/cjs/components/datetime/DateTime.form.js +5 -5
  109. package/lib/cjs/components/datetime/DateTime.js +15 -30
  110. package/lib/cjs/components/datetime/editForm/DateTime.edit.data.js +3 -4
  111. package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +10 -10
  112. package/lib/cjs/components/datetime/editForm/DateTime.edit.display.js +17 -22
  113. package/lib/cjs/components/datetime/editForm/DateTime.edit.time.js +5 -5
  114. package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +3 -3
  115. package/lib/cjs/components/day/Day.form.js +5 -5
  116. package/lib/cjs/components/day/Day.js +58 -147
  117. package/lib/cjs/components/day/editForm/Day.edit.day.js +9 -13
  118. package/lib/cjs/components/day/editForm/Day.edit.display.js +7 -7
  119. package/lib/cjs/components/day/editForm/Day.edit.month.js +8 -12
  120. package/lib/cjs/components/day/editForm/Day.edit.validation.js +7 -7
  121. package/lib/cjs/components/day/editForm/Day.edit.year.js +8 -8
  122. package/lib/cjs/components/editgrid/EditGrid.form.js +2 -2
  123. package/lib/cjs/components/editgrid/EditGrid.js +96 -142
  124. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.data.js +2 -2
  125. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +2 -7
  126. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.js +16 -16
  127. package/lib/cjs/components/editgrid/editForm/EditGrid.edit.validation.js +3 -3
  128. package/lib/cjs/components/email/Email.js +4 -4
  129. package/lib/cjs/components/email/editForm/Email.edit.display.js +3 -3
  130. package/lib/cjs/components/email/editForm/Email.edit.validation.js +6 -6
  131. package/lib/cjs/components/fieldset/Fieldset.form.js +1 -1
  132. package/lib/cjs/components/fieldset/Fieldset.js +2 -2
  133. package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -8
  134. package/lib/cjs/components/file/File.form.js +4 -4
  135. package/lib/cjs/components/file/File.js +90 -131
  136. package/lib/cjs/components/file/editForm/File.edit.display.js +5 -9
  137. package/lib/cjs/components/file/editForm/File.edit.file.js +53 -97
  138. package/lib/cjs/components/file/editForm/File.edit.validation.js +2 -2
  139. package/lib/cjs/components/form/Form.form.js +3 -3
  140. package/lib/cjs/components/form/Form.js +58 -68
  141. package/lib/cjs/components/form/editForm/Form.edit.data.js +3 -1
  142. package/lib/cjs/components/form/editForm/Form.edit.display.js +7 -6
  143. package/lib/cjs/components/form/editForm/Form.edit.form.js +9 -11
  144. package/lib/cjs/components/hidden/Hidden.form.js +4 -4
  145. package/lib/cjs/components/hidden/Hidden.js +2 -2
  146. package/lib/cjs/components/hidden/editForm/Hidden.edit.data.js +3 -3
  147. package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +10 -10
  148. package/lib/cjs/components/html/HTML.js +17 -23
  149. package/lib/cjs/components/html/editForm/HTML.edit.display.js +17 -17
  150. package/lib/cjs/components/html/editForm/HTML.edit.logic.js +2 -2
  151. package/lib/cjs/components/number/Number.form.js +3 -3
  152. package/lib/cjs/components/number/Number.js +11 -27
  153. package/lib/cjs/components/number/editForm/Number.edit.data.js +3 -3
  154. package/lib/cjs/components/number/editForm/Number.edit.display.js +4 -4
  155. package/lib/cjs/components/number/editForm/Number.edit.validation.js +9 -9
  156. package/lib/cjs/components/panel/Panel.form.js +1 -1
  157. package/lib/cjs/components/panel/Panel.js +2 -2
  158. package/lib/cjs/components/panel/editForm/Panel.edit.conditional.js +7 -5
  159. package/lib/cjs/components/panel/editForm/Panel.edit.display.js +29 -55
  160. package/lib/cjs/components/password/Password.form.js +3 -3
  161. package/lib/cjs/components/password/Password.js +2 -5
  162. package/lib/cjs/components/password/editForm/Password.edit.data.js +11 -11
  163. package/lib/cjs/components/password/editForm/Password.edit.display.js +3 -3
  164. package/lib/cjs/components/password/editForm/Password.edit.validation.js +3 -3
  165. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +8 -8
  166. package/lib/cjs/components/phonenumber/PhoneNumber.js +3 -3
  167. package/lib/cjs/components/phonenumber/editForm/PhoneNumber.edit.validation.js +6 -6
  168. package/lib/cjs/components/radio/Radio.form.js +3 -3
  169. package/lib/cjs/components/radio/Radio.js +32 -58
  170. package/lib/cjs/components/radio/editForm/Radio.edit.data.js +9 -23
  171. package/lib/cjs/components/radio/editForm/Radio.edit.display.js +6 -6
  172. package/lib/cjs/components/radio/editForm/Radio.edit.validation.js +2 -2
  173. package/lib/cjs/components/recaptcha/ReCaptcha.form.js +5 -5
  174. package/lib/cjs/components/recaptcha/ReCaptcha.js +10 -10
  175. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +24 -24
  176. package/lib/cjs/components/select/Select.form.js +3 -3
  177. package/lib/cjs/components/select/Select.js +140 -235
  178. package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  179. package/lib/cjs/components/select/editForm/Select.edit.data.js +57 -191
  180. package/lib/cjs/components/select/editForm/Select.edit.display.js +2 -2
  181. package/lib/cjs/components/select/editForm/Select.edit.validation.js +4 -4
  182. package/lib/cjs/components/selectboxes/SelectBoxes.form.js +3 -3
  183. package/lib/cjs/components/selectboxes/SelectBoxes.js +16 -29
  184. package/lib/cjs/components/selectboxes/editForm/SelectBoxes.edit.validation.js +5 -5
  185. package/lib/cjs/components/signature/Signature.form.js +3 -3
  186. package/lib/cjs/components/signature/Signature.js +17 -26
  187. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +10 -19
  188. package/lib/cjs/components/survey/Survey.form.js +3 -3
  189. package/lib/cjs/components/survey/Survey.js +17 -30
  190. package/lib/cjs/components/survey/editForm/Survey.edit.data.js +11 -23
  191. package/lib/cjs/components/survey/editForm/Survey.edit.display.js +1 -1
  192. package/lib/cjs/components/survey/editForm/Survey.edit.validation.js +1 -1
  193. package/lib/cjs/components/table/Table.form.js +1 -1
  194. package/lib/cjs/components/table/Table.js +7 -8
  195. package/lib/cjs/components/table/editForm/Table.edit.display.js +22 -22
  196. package/lib/cjs/components/tabs/Tabs.form.js +1 -1
  197. package/lib/cjs/components/tabs/Tabs.js +10 -27
  198. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +17 -21
  199. package/lib/cjs/components/tags/Tags.form.js +1 -1
  200. package/lib/cjs/components/tags/Tags.js +12 -28
  201. package/lib/cjs/components/tags/editForm/Tags.edit.data.js +7 -7
  202. package/lib/cjs/components/textarea/TextArea.form.js +2 -2
  203. package/lib/cjs/components/textarea/TextArea.js +45 -63
  204. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +72 -96
  205. package/lib/cjs/components/textarea/editForm/TextArea.edit.validation.js +3 -3
  206. package/lib/cjs/components/textfield/TextField.form.js +3 -3
  207. package/lib/cjs/components/textfield/TextField.js +21 -32
  208. package/lib/cjs/components/textfield/editForm/TextField.edit.data.js +13 -15
  209. package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +21 -31
  210. package/lib/cjs/components/textfield/editForm/TextField.edit.validation.js +6 -6
  211. package/lib/cjs/components/time/Time.js +10 -17
  212. package/lib/cjs/components/time/editForm/Time.edit.display.js +2 -2
  213. package/lib/cjs/components/unknown/Unknown.form.js +5 -5
  214. package/lib/cjs/components/unknown/Unknown.js +2 -2
  215. package/lib/cjs/components/unknown/editForm/Unknown.edit.display.js +3 -3
  216. package/lib/cjs/components/url/Url.form.js +3 -3
  217. package/lib/cjs/components/url/Url.js +2 -2
  218. package/lib/cjs/components/url/editForm/Url.edit.display.js +3 -3
  219. package/lib/cjs/components/url/editForm/Url.edit.validation.js +1 -1
  220. package/lib/cjs/components/well/Well.form.js +1 -1
  221. package/lib/cjs/components/well/Well.js +2 -2
  222. package/lib/cjs/components/well/editForm/Well.edit.display.js +10 -10
  223. package/lib/cjs/formio.form.d.ts +1 -2
  224. package/lib/cjs/formio.form.js +12 -38
  225. package/lib/cjs/i18n.d.ts +0 -4
  226. package/lib/cjs/i18n.js +3 -7
  227. package/lib/cjs/package.json +1 -1
  228. package/lib/cjs/pdf.image.d.ts +2 -0
  229. package/lib/cjs/pdf.image.js +94 -0
  230. package/lib/cjs/providers/address/AddressProvider.js +5 -8
  231. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +3 -3
  232. package/lib/cjs/providers/address/GoogleAddressProvider.js +13 -24
  233. package/lib/cjs/providers/processor/fileProcessor.js +1 -3
  234. package/lib/cjs/providers/storage/azure.js +2 -5
  235. package/lib/cjs/providers/storage/dropbox.js +5 -4
  236. package/lib/cjs/providers/storage/googleDrive.js +4 -3
  237. package/lib/cjs/providers/storage/index.js +1 -1
  238. package/lib/cjs/providers/storage/indexeddb.js +6 -16
  239. package/lib/cjs/providers/storage/s3.js +6 -17
  240. package/lib/cjs/providers/storage/uploadAdapter.js +11 -17
  241. package/lib/cjs/providers/storage/url.js +11 -13
  242. package/lib/cjs/providers/storage/xhr.js +9 -17
  243. package/lib/cjs/templates/index.js +1 -1
  244. package/lib/cjs/translations/en.d.ts +2 -0
  245. package/lib/cjs/translations/en.js +9 -7
  246. package/lib/cjs/utils/ChoicesWrapper.js +2 -2
  247. package/lib/cjs/utils/builder.js +7 -31
  248. package/lib/cjs/utils/calendarUtils.js +5 -7
  249. package/lib/cjs/utils/conditionOperators/ConditionOperator.js +1 -1
  250. package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +4 -12
  251. package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +1 -3
  252. package/lib/cjs/utils/conditionOperators/IsEqualTo.js +6 -10
  253. package/lib/cjs/utils/conditionOperators/index.js +1 -1
  254. package/lib/cjs/utils/formUtils.js +1 -1
  255. package/lib/cjs/utils/i18n.js +1 -7
  256. package/lib/cjs/utils/index.d.ts +1 -2
  257. package/lib/cjs/utils/index.js +2 -2
  258. package/lib/cjs/utils/jsonlogic/operators.d.ts +1 -0
  259. package/lib/cjs/utils/jsonlogic/operators.js +265 -0
  260. package/lib/cjs/utils/utils.d.ts +1 -10
  261. package/lib/cjs/utils/utils.js +92 -175
  262. package/lib/cjs/widgets/CalendarWidget.js +49 -66
  263. package/lib/cjs/widgets/InputWidget.js +4 -6
  264. package/lib/cjs/widgets/index.js +1 -1
  265. package/lib/mjs/CDN.js +12 -12
  266. package/lib/mjs/Element.d.ts +2 -3
  267. package/lib/mjs/Element.js +23 -29
  268. package/lib/mjs/Embed.js +43 -77
  269. package/lib/mjs/EventEmitter.js +1 -1
  270. package/lib/mjs/Form.d.ts +341 -371
  271. package/lib/mjs/Form.js +126 -142
  272. package/lib/mjs/FormBuilder.d.ts +3 -3
  273. package/lib/mjs/FormBuilder.js +3 -2
  274. package/lib/mjs/Formio.js +23 -26
  275. package/lib/mjs/InlineEmbed.js +17 -23
  276. package/lib/mjs/PDF.d.ts +0 -1
  277. package/lib/mjs/PDF.js +15 -18
  278. package/lib/mjs/PDFBuilder.js +36 -51
  279. package/lib/mjs/Webform.d.ts +366 -8
  280. package/lib/mjs/Webform.js +251 -184
  281. package/lib/mjs/WebformBuilder.js +151 -224
  282. package/lib/mjs/Wizard.js +64 -94
  283. package/lib/mjs/WizardBuilder.js +19 -27
  284. package/lib/mjs/addons/FormioAddon.js +1 -1
  285. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +57 -59
  286. package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +16 -24
  287. package/lib/mjs/addons/index.js +3 -3
  288. package/lib/mjs/components/Components.js +4 -0
  289. package/lib/mjs/components/_classes/component/Component.form.js +11 -11
  290. package/lib/mjs/components/_classes/component/Component.js +194 -313
  291. package/lib/mjs/components/_classes/component/editForm/Component.edit.addons.js +4 -2
  292. package/lib/mjs/components/_classes/component/editForm/Component.edit.api.js +5 -5
  293. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +11 -9
  294. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  295. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +25 -39
  296. package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +29 -47
  297. package/lib/mjs/components/_classes/component/editForm/Component.edit.layout.js +9 -9
  298. package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +7 -5
  299. package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +34 -37
  300. package/lib/mjs/components/_classes/component/editForm/utils.js +16 -12
  301. package/lib/mjs/components/_classes/componentModal/ComponentModal.js +2 -2
  302. package/lib/mjs/components/_classes/field/Field.js +2 -8
  303. package/lib/mjs/components/_classes/input/Input.js +23 -27
  304. package/lib/mjs/components/_classes/list/ListComponent.form.js +1 -1
  305. package/lib/mjs/components/_classes/list/ListComponent.js +18 -27
  306. package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +9 -36
  307. package/lib/mjs/components/_classes/multivalue/Multivalue.js +13 -32
  308. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
  309. package/lib/mjs/components/_classes/nested/NestedComponent.form.js +3 -3
  310. package/lib/mjs/components/_classes/nested/NestedComponent.js +33 -41
  311. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +15 -20
  312. package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +17 -19
  313. package/lib/mjs/components/address/Address.d.ts +0 -1
  314. package/lib/mjs/components/address/Address.js +49 -60
  315. package/lib/mjs/components/address/editForm/Address.edit.data.js +2 -2
  316. package/lib/mjs/components/address/editForm/Address.edit.display.js +2 -2
  317. package/lib/mjs/components/address/editForm/Address.edit.provider.js +11 -53
  318. package/lib/mjs/components/alert/Alert.js +16 -22
  319. package/lib/mjs/components/button/Button.form.js +1 -1
  320. package/lib/mjs/components/button/Button.js +42 -65
  321. package/lib/mjs/components/button/editForm/Button.edit.display.js +9 -49
  322. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  323. package/lib/mjs/components/checkbox/Checkbox.form.js +3 -3
  324. package/lib/mjs/components/checkbox/Checkbox.js +21 -29
  325. package/lib/mjs/components/checkbox/editForm/Checkbox.edit.data.js +1 -1
  326. package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +3 -13
  327. package/lib/mjs/components/checkbox/editForm/Checkbox.edit.validation.js +2 -2
  328. package/lib/mjs/components/columns/Columns.form.js +1 -1
  329. package/lib/mjs/components/columns/Columns.js +12 -24
  330. package/lib/mjs/components/columns/editForm/Columns.edit.display.js +17 -17
  331. package/lib/mjs/components/container/Container.form.js +2 -2
  332. package/lib/mjs/components/container/Container.js +4 -6
  333. package/lib/mjs/components/container/editForm/Container.edit.data.js +3 -3
  334. package/lib/mjs/components/container/editForm/Container.edit.display.js +4 -4
  335. package/lib/mjs/components/content/Content.form.js +2 -4
  336. package/lib/mjs/components/content/Content.js +8 -10
  337. package/lib/mjs/components/content/editForm/Content.edit.display.js +10 -10
  338. package/lib/mjs/components/currency/Currency.form.js +3 -3
  339. package/lib/mjs/components/currency/Currency.js +10 -19
  340. package/lib/mjs/components/currency/editForm/Currency.edit.data.js +5 -5
  341. package/lib/mjs/components/currency/editForm/Currency.edit.display.js +8 -8
  342. package/lib/mjs/components/datagrid/DataGrid.form.js +3 -3
  343. package/lib/mjs/components/datagrid/DataGrid.js +41 -92
  344. package/lib/mjs/components/datagrid/editForm/DataGrid.edit.data.js +1 -1
  345. package/lib/mjs/components/datagrid/editForm/DataGrid.edit.display.js +14 -14
  346. package/lib/mjs/components/datagrid/editForm/DataGrid.edit.validation.js +3 -3
  347. package/lib/mjs/components/datamap/DataMap.form.js +2 -2
  348. package/lib/mjs/components/datamap/DataMap.js +33 -46
  349. package/lib/mjs/components/datamap/editForm/DataMap.edit.data.js +1 -1
  350. package/lib/mjs/components/datamap/editForm/DataMap.edit.display.js +8 -8
  351. package/lib/mjs/components/datetime/DateTime.form.js +5 -5
  352. package/lib/mjs/components/datetime/DateTime.js +16 -31
  353. package/lib/mjs/components/datetime/editForm/DateTime.edit.data.js +3 -4
  354. package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +10 -10
  355. package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +17 -22
  356. package/lib/mjs/components/datetime/editForm/DateTime.edit.time.js +5 -5
  357. package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +3 -3
  358. package/lib/mjs/components/day/Day.form.js +5 -5
  359. package/lib/mjs/components/day/Day.js +58 -148
  360. package/lib/mjs/components/day/editForm/Day.edit.day.js +9 -13
  361. package/lib/mjs/components/day/editForm/Day.edit.display.js +7 -7
  362. package/lib/mjs/components/day/editForm/Day.edit.month.js +8 -12
  363. package/lib/mjs/components/day/editForm/Day.edit.validation.js +7 -7
  364. package/lib/mjs/components/day/editForm/Day.edit.year.js +8 -8
  365. package/lib/mjs/components/editgrid/EditGrid.form.js +2 -2
  366. package/lib/mjs/components/editgrid/EditGrid.js +92 -140
  367. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.data.js +2 -2
  368. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +2 -7
  369. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +16 -16
  370. package/lib/mjs/components/editgrid/editForm/EditGrid.edit.validation.js +3 -3
  371. package/lib/mjs/components/email/Email.js +4 -4
  372. package/lib/mjs/components/email/editForm/Email.edit.display.js +3 -3
  373. package/lib/mjs/components/email/editForm/Email.edit.validation.js +6 -6
  374. package/lib/mjs/components/fieldset/Fieldset.form.js +1 -1
  375. package/lib/mjs/components/fieldset/Fieldset.js +2 -2
  376. package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -8
  377. package/lib/mjs/components/file/File.form.js +4 -4
  378. package/lib/mjs/components/file/File.js +89 -136
  379. package/lib/mjs/components/file/editForm/File.edit.display.js +5 -9
  380. package/lib/mjs/components/file/editForm/File.edit.file.js +53 -97
  381. package/lib/mjs/components/file/editForm/File.edit.validation.js +2 -2
  382. package/lib/mjs/components/form/Form.form.js +3 -3
  383. package/lib/mjs/components/form/Form.js +55 -68
  384. package/lib/mjs/components/form/editForm/Form.edit.data.js +3 -1
  385. package/lib/mjs/components/form/editForm/Form.edit.display.js +7 -6
  386. package/lib/mjs/components/form/editForm/Form.edit.form.js +8 -10
  387. package/lib/mjs/components/hidden/Hidden.form.js +4 -4
  388. package/lib/mjs/components/hidden/Hidden.js +2 -2
  389. package/lib/mjs/components/hidden/editForm/Hidden.edit.data.js +3 -3
  390. package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +10 -10
  391. package/lib/mjs/components/html/HTML.js +17 -23
  392. package/lib/mjs/components/html/editForm/HTML.edit.display.js +17 -17
  393. package/lib/mjs/components/html/editForm/HTML.edit.logic.js +2 -2
  394. package/lib/mjs/components/number/Number.form.js +3 -3
  395. package/lib/mjs/components/number/Number.js +12 -28
  396. package/lib/mjs/components/number/editForm/Number.edit.data.js +3 -3
  397. package/lib/mjs/components/number/editForm/Number.edit.display.js +4 -4
  398. package/lib/mjs/components/number/editForm/Number.edit.validation.js +9 -9
  399. package/lib/mjs/components/panel/Panel.form.js +1 -1
  400. package/lib/mjs/components/panel/Panel.js +2 -2
  401. package/lib/mjs/components/panel/editForm/Panel.edit.conditional.js +8 -6
  402. package/lib/mjs/components/panel/editForm/Panel.edit.display.js +29 -55
  403. package/lib/mjs/components/password/Password.form.js +3 -3
  404. package/lib/mjs/components/password/Password.js +2 -5
  405. package/lib/mjs/components/password/editForm/Password.edit.data.js +11 -11
  406. package/lib/mjs/components/password/editForm/Password.edit.display.js +3 -3
  407. package/lib/mjs/components/password/editForm/Password.edit.validation.js +3 -3
  408. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +8 -8
  409. package/lib/mjs/components/phonenumber/PhoneNumber.js +3 -3
  410. package/lib/mjs/components/phonenumber/editForm/PhoneNumber.edit.validation.js +6 -6
  411. package/lib/mjs/components/radio/Radio.form.js +3 -3
  412. package/lib/mjs/components/radio/Radio.js +30 -59
  413. package/lib/mjs/components/radio/editForm/Radio.edit.data.js +9 -23
  414. package/lib/mjs/components/radio/editForm/Radio.edit.display.js +6 -6
  415. package/lib/mjs/components/radio/editForm/Radio.edit.validation.js +2 -2
  416. package/lib/mjs/components/recaptcha/ReCaptcha.form.js +5 -5
  417. package/lib/mjs/components/recaptcha/ReCaptcha.js +8 -10
  418. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +24 -24
  419. package/lib/mjs/components/select/Select.form.js +3 -3
  420. package/lib/mjs/components/select/Select.js +145 -240
  421. package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  422. package/lib/mjs/components/select/editForm/Select.edit.data.js +57 -191
  423. package/lib/mjs/components/select/editForm/Select.edit.display.js +2 -2
  424. package/lib/mjs/components/select/editForm/Select.edit.validation.js +4 -4
  425. package/lib/mjs/components/selectboxes/SelectBoxes.form.js +3 -3
  426. package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -30
  427. package/lib/mjs/components/selectboxes/editForm/SelectBoxes.edit.validation.js +5 -5
  428. package/lib/mjs/components/signature/Signature.form.js +3 -3
  429. package/lib/mjs/components/signature/Signature.js +16 -26
  430. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +10 -19
  431. package/lib/mjs/components/survey/Survey.form.js +3 -3
  432. package/lib/mjs/components/survey/Survey.js +17 -30
  433. package/lib/mjs/components/survey/editForm/Survey.edit.data.js +11 -23
  434. package/lib/mjs/components/survey/editForm/Survey.edit.display.js +1 -1
  435. package/lib/mjs/components/survey/editForm/Survey.edit.validation.js +1 -1
  436. package/lib/mjs/components/table/Table.form.js +1 -1
  437. package/lib/mjs/components/table/Table.js +6 -8
  438. package/lib/mjs/components/table/editForm/Table.edit.display.js +22 -22
  439. package/lib/mjs/components/tabs/Tabs.form.js +1 -1
  440. package/lib/mjs/components/tabs/Tabs.js +9 -27
  441. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +17 -21
  442. package/lib/mjs/components/tags/Tags.form.js +1 -1
  443. package/lib/mjs/components/tags/Tags.js +12 -28
  444. package/lib/mjs/components/tags/editForm/Tags.edit.data.js +7 -7
  445. package/lib/mjs/components/textarea/TextArea.form.js +2 -2
  446. package/lib/mjs/components/textarea/TextArea.js +51 -75
  447. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +72 -96
  448. package/lib/mjs/components/textarea/editForm/TextArea.edit.validation.js +3 -3
  449. package/lib/mjs/components/textfield/TextField.form.js +3 -3
  450. package/lib/mjs/components/textfield/TextField.js +23 -34
  451. package/lib/mjs/components/textfield/editForm/TextField.edit.data.js +13 -15
  452. package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +21 -31
  453. package/lib/mjs/components/textfield/editForm/TextField.edit.validation.js +6 -6
  454. package/lib/mjs/components/time/Time.js +10 -17
  455. package/lib/mjs/components/time/editForm/Time.edit.display.js +2 -2
  456. package/lib/mjs/components/unknown/Unknown.form.js +5 -5
  457. package/lib/mjs/components/unknown/Unknown.js +2 -2
  458. package/lib/mjs/components/unknown/editForm/Unknown.edit.display.js +3 -3
  459. package/lib/mjs/components/url/Url.form.js +3 -3
  460. package/lib/mjs/components/url/Url.js +2 -2
  461. package/lib/mjs/components/url/editForm/Url.edit.display.js +3 -3
  462. package/lib/mjs/components/url/editForm/Url.edit.validation.js +1 -1
  463. package/lib/mjs/components/well/Well.form.js +1 -1
  464. package/lib/mjs/components/well/Well.js +2 -2
  465. package/lib/mjs/components/well/editForm/Well.edit.display.js +10 -10
  466. package/lib/mjs/formio.form.d.ts +1 -2
  467. package/lib/mjs/formio.form.js +8 -10
  468. package/lib/mjs/i18n.d.ts +0 -4
  469. package/lib/mjs/i18n.js +3 -7
  470. package/lib/mjs/package.json +1 -1
  471. package/lib/mjs/pdf.image.d.ts +2 -0
  472. package/lib/mjs/pdf.image.js +94 -0
  473. package/lib/mjs/providers/address/AddressProvider.js +5 -8
  474. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +3 -3
  475. package/lib/mjs/providers/address/GoogleAddressProvider.js +13 -24
  476. package/lib/mjs/providers/processor/fileProcessor.js +1 -3
  477. package/lib/mjs/providers/storage/azure.js +2 -5
  478. package/lib/mjs/providers/storage/dropbox.js +5 -4
  479. package/lib/mjs/providers/storage/googleDrive.js +4 -3
  480. package/lib/mjs/providers/storage/index.js +1 -1
  481. package/lib/mjs/providers/storage/indexeddb.js +6 -16
  482. package/lib/mjs/providers/storage/s3.js +8 -19
  483. package/lib/mjs/providers/storage/uploadAdapter.js +11 -17
  484. package/lib/mjs/providers/storage/url.js +11 -13
  485. package/lib/mjs/providers/storage/xhr.js +9 -17
  486. package/lib/mjs/templates/index.js +1 -1
  487. package/lib/mjs/translations/en.d.ts +2 -0
  488. package/lib/mjs/translations/en.js +9 -7
  489. package/lib/mjs/utils/ChoicesWrapper.js +2 -2
  490. package/lib/mjs/utils/builder.js +7 -31
  491. package/lib/mjs/utils/calendarUtils.js +5 -7
  492. package/lib/mjs/utils/conditionOperators/ConditionOperator.js +1 -1
  493. package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +5 -16
  494. package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +1 -3
  495. package/lib/mjs/utils/conditionOperators/IsEqualTo.js +6 -10
  496. package/lib/mjs/utils/conditionOperators/index.js +1 -1
  497. package/lib/mjs/utils/formUtils.js +2 -2
  498. package/lib/mjs/utils/i18n.js +1 -7
  499. package/lib/mjs/utils/index.d.ts +1 -2
  500. package/lib/mjs/utils/index.js +3 -3
  501. package/lib/mjs/utils/jsonlogic/operators.d.ts +1 -0
  502. package/lib/mjs/utils/jsonlogic/operators.js +262 -0
  503. package/lib/mjs/utils/utils.d.ts +1 -10
  504. package/lib/mjs/utils/utils.js +91 -178
  505. package/lib/mjs/widgets/CalendarWidget.js +50 -67
  506. package/lib/mjs/widgets/InputWidget.js +4 -6
  507. package/lib/mjs/widgets/index.js +1 -1
  508. package/package.json +3 -3
  509. package/lib/cjs/translations/de.d.ts +0 -80
  510. package/lib/cjs/translations/de.js +0 -81
  511. package/lib/mjs/translations/de.d.ts +0 -80
  512. package/lib/mjs/translations/de.js +0 -79
@@ -1,17 +1,17 @@
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, eachComponent, } from './utils';
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, eachComponent } from './utils';
10
10
  // We need this here because dragula pulls in CustomEvent class that requires global to exist.
11
11
  if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
12
12
  window.global = window;
13
13
  }
14
- import dragula from 'dragula';
14
+ import dragula from "dragula";
15
15
  // Initialize the available forms.
16
16
  Formio.forms = {};
17
17
  // Allow people to register components.
@@ -22,10 +22,10 @@ Formio.registerComponent = Components.setComponent;
22
22
  * @returns {any} - The icon set.
23
23
  */
24
24
  function getIconSet(icons) {
25
- if (icons === 'fontawesome') {
26
- return 'fa';
25
+ if (icons === "fontawesome") {
26
+ return "fa";
27
27
  }
28
- return icons || '';
28
+ return icons || "";
29
29
  }
30
30
  /**
31
31
  *
@@ -40,7 +40,7 @@ function getOptions(options) {
40
40
  saveDraft: false,
41
41
  alwaysDirty: false,
42
42
  saveDraftThrottle: 5000,
43
- display: 'form',
43
+ display: "form",
44
44
  cdnUrl: Formio.cdn.baseUrl,
45
45
  });
46
46
  if (!options.events) {
@@ -49,10 +49,95 @@ function getOptions(options) {
49
49
  return options;
50
50
  }
51
51
  /**
52
- * Webform class for rendering forms with full component support.
53
- * @property {import('./Form.js').FormOptions} options - The options for this Webform instance.
52
+ * Represents a JSON value.
53
+ * @typedef {(string | number | boolean | null | JSONArray | JSONObject)} JSON
54
+ */
55
+ /**
56
+ * Represents a JSON array.
57
+ * @typedef {Array<JSON>} JSONArray
58
+ */
59
+ /**
60
+ * Represents a JSON object.
61
+ * @typedef {{[key: string]: JSON}} JSONObject
62
+ */
63
+ /**
64
+ * @typedef {object} FormioHooks
65
+ * @property {Function} [beforeSubmit] - A function that is called before the form is submitted.
66
+ * @property {Function} [beforeCancel] - A function that is called before the form is canceled.
67
+ * @property {Function} [beforeNext] - A function that is called before moving to the next page in a multi-page form.
68
+ * @property {Function} [beforePrev] - A function that is called before moving to the previous page in a multi-page form.
69
+ * @property {Function} [attachComponent] - A function that is called when a component is attached to the form.
70
+ * @property {Function} [setDataValue] - A function that is called when setting the value of a data component.
71
+ * @property {Function} [addComponents] - A function that is called when adding multiple components to the form.
72
+ * @property {Function} [addComponent] - A function that is called when adding a single component to the form.
73
+ * @property {Function} [customValidation] - A function that is called for custom validation of the form.
74
+ * @property {Function} [attachWebform] - A function that is called when attaching a webform to the form.
75
+ */
76
+ /**
77
+ * @typedef {object} SanitizeConfig
78
+ * @property {string[]} [addAttr] - The attributes to add.
79
+ * @property {string[]} [addTags] - The tags to add.
80
+ * @property {string[]} [allowedAttrs] - The allowed attributes.
81
+ * @property {string[]} [allowedTags] - The allowed tags.
82
+ * @property {string[]} [allowedUriRegex] - The allowed URI regex.
83
+ * @property {string[]} [addUriSafeAttr] - The URI safe attributes.
84
+ */
85
+ /**
86
+ * @typedef {object} ButtonSettings
87
+ * @property {boolean} [showPrevious] - Show the "Previous" button.
88
+ * @property {boolean} [showNext] - Show the "Next" button.
89
+ * @property {boolean} [showCancel] - Show the "Cancel" button.
90
+ * @property {boolean} [showSubmit] - Show the "Submit" button.
91
+ */
92
+ /**
93
+ * @typedef {object} FormOptions
94
+ * @property {boolean} [saveDraft] - Enable the save draft feature.
95
+ * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
96
+ * @property {boolean} [readOnly] - Set this form to readOnly.
97
+ * @property {boolean} [noAlerts] - Disable the alerts dialog.
98
+ * @property {{[key: string]: string}} [i18n] - The translation file for this rendering.
99
+ * @property {string} [template] - Custom logic for creation of elements.
100
+ * @property {boolean} [noDefaults] - Exclude default values from the settings.
101
+ * @property {any} [fileService] - The file service for this form.
102
+ * @property {EventEmitter} [events] - The EventEmitter for this form.
103
+ * @property {string} [language] - The language to render this form in.
104
+ * @property {{[key: string]: string}} [i18next] - The i18next configuration for this form.
105
+ * @property {boolean} [viewAsHtml] - View the form as raw HTML.
106
+ * @property {'form' | 'html' | 'flat' | 'builder' | 'pdf'} [renderMode] - The render mode for this form.
107
+ * @property {boolean} [highlightErrors] - Highlight any errors on the form.
108
+ * @property {string} [componentErrorClass] - The error class for components.
109
+ * @property {any} [templates] - The templates for this form.
110
+ * @property {string} [iconset] - The iconset for this form.
111
+ * @property {import('@formio/core').Component[]} [components] - The components for this form.
112
+ * @property {{[key: string]: boolean}} [disabled] - Disabled components for this form.
113
+ * @property {boolean} [showHiddenFields] - Show hidden fields.
114
+ * @property {{[key: string]: boolean}} [hide] - Hidden components for this form.
115
+ * @property {{[key: string]: boolean}} [show] - Components to show for this form.
116
+ * @property {Formio} [formio] - The Formio instance for this form.
117
+ * @property {string} [decimalSeparator] - The decimal separator for this form.
118
+ * @property {string} [thousandsSeparator] - The thousands separator for this form.
119
+ * @property {FormioHooks} [hooks] - The hooks for this form.
120
+ * @property {boolean} [alwaysDirty] - Always be dirty.
121
+ * @property {boolean} [skipDraftRestore] - Skip restoring a draft.
122
+ * @property {'form' | 'wizard' | 'pdf'} [display] - The display for this form.
123
+ * @property {string} [cdnUrl] - The CDN url for this form.
124
+ * @property {boolean} [flatten] - Flatten the form.
125
+ * @property {boolean} [sanitize] - Sanitize the form.
126
+ * @property {SanitizeConfig} [sanitizeConfig] - The sanitize configuration for this form.
127
+ * @property {ButtonSettings} [buttonSettings] - The button settings for this form.
128
+ * @property {object} [breadcrumbSettings] - The breadcrumb settings for this form.
129
+ * @property {boolean} [allowPrevious] - Allow the previous button (for Wizard forms).
130
+ * @property {string[]} [wizardButtonOrder] - The order of the buttons (for Wizard forms).
131
+ * @property {boolean} [showCheckboxBackground] - Show the checkbox background.
132
+ * @property {boolean} [inputsOnly] - Only show inputs in the form and no labels.
133
+ * @property {boolean} [building] - If we are in the process of building the form.
134
+ * @property {number} [zoom] - The zoom for PDF forms.
54
135
  */
55
136
  export default class Webform extends NestedDataComponent {
137
+ /**
138
+ * @type {import('Form').FormOptions} - the options for this Webform.
139
+ */
140
+ options;
56
141
  /**
57
142
  * Creates a new Form instance.
58
143
  * @param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
@@ -79,8 +164,8 @@ export default class Webform extends NestedDataComponent {
79
164
  * The type of this element.
80
165
  * @type {string}
81
166
  */
82
- this.type = 'form';
83
- this._src = '';
167
+ this.type = "form";
168
+ this._src = "";
84
169
  this._loading = false;
85
170
  this._form = {};
86
171
  this.draftEnabled = false;
@@ -202,6 +287,7 @@ export default class Webform extends NestedDataComponent {
202
287
  this.localRoot = this;
203
288
  this.root.dragulaLib = dragula;
204
289
  }
290
+ /* eslint-enable max-statements */
205
291
  get language() {
206
292
  return this.options.language;
207
293
  }
@@ -228,7 +314,7 @@ export default class Webform extends NestedDataComponent {
228
314
  return;
229
315
  }
230
316
  this.rebuild();
231
- this.emit('languageChanged');
317
+ this.emit("languageChanged");
232
318
  });
233
319
  }
234
320
  get componentComponents() {
@@ -254,22 +340,18 @@ export default class Webform extends NestedDataComponent {
254
340
  addLanguage(code, lang, active = false) {
255
341
  if (this.i18next) {
256
342
  var translations = _.assign(fastCloneDeep(i18nDefaults.resources.en.translation), lang);
257
- this.i18next.addResourceBundle(code, 'translation', translations, true, true);
343
+ this.i18next.addResourceBundle(code, "translation", translations, true, true);
258
344
  if (active) {
259
345
  this.language = code;
260
346
  }
261
347
  }
262
348
  }
263
349
  keyboardCatchableElement(element) {
264
- if (element.nodeName === 'TEXTAREA') {
350
+ if (element.nodeName === "TEXTAREA") {
265
351
  return false;
266
352
  }
267
- if (element.nodeName === 'INPUT') {
268
- return ([
269
- 'text',
270
- 'email',
271
- 'password',
272
- ].indexOf(element.type) === -1);
353
+ if (element.nodeName === "INPUT") {
354
+ return ["text", "email", "password"].indexOf(element.type) === -1;
273
355
  }
274
356
  return true;
275
357
  }
@@ -280,15 +362,15 @@ export default class Webform extends NestedDataComponent {
280
362
  }
281
363
  const ctrl = event.ctrlKey || event.metaKey;
282
364
  const keyCode = event.keyCode;
283
- let char = '';
365
+ let char = "";
284
366
  if (65 <= keyCode && keyCode <= 90) {
285
367
  char = String.fromCharCode(keyCode);
286
368
  }
287
369
  else if (keyCode === 13) {
288
- char = 'Enter';
370
+ char = "Enter";
289
371
  }
290
372
  else if (keyCode === 27) {
291
- char = 'Esc';
373
+ char = "Esc";
292
374
  }
293
375
  _.each(this.shortcuts, (shortcut) => {
294
376
  if (shortcut.ctrl && !ctrl) {
@@ -305,9 +387,9 @@ export default class Webform extends NestedDataComponent {
305
387
  return;
306
388
  }
307
389
  shortcut = _.capitalize(shortcut);
308
- if (shortcut === 'Enter' || shortcut === 'Esc') {
390
+ if (shortcut === "Enter" || shortcut === "Esc") {
309
391
  // Restrict Enter and Esc only for buttons
310
- if (element.tagName !== 'BUTTON') {
392
+ if (element.tagName !== "BUTTON") {
311
393
  return;
312
394
  }
313
395
  this.shortcuts.push({
@@ -407,13 +489,13 @@ export default class Webform extends NestedDataComponent {
407
489
  * @returns {boolean} - TRUE means the url was set, FALSE otherwise.
408
490
  */
409
491
  setUrl(value, options) {
410
- if (!value || typeof value !== 'string' || value === this._src) {
492
+ if (!value || typeof value !== "string" || value === this._src) {
411
493
  return false;
412
494
  }
413
495
  this._src = value;
414
496
  this.nosubmit = true;
415
497
  this.formio = this.options.formio = new Formio(value, options);
416
- if (this.type === 'form') {
498
+ if (this.type === "form") {
417
499
  // Set the options source so this can be passed to other components.
418
500
  this.options.src = value;
419
501
  }
@@ -452,14 +534,15 @@ export default class Webform extends NestedDataComponent {
452
534
  if (this._loading !== loading) {
453
535
  this._loading = loading;
454
536
  if (!this.loader && loading) {
455
- this.loader = this.ce('div', {
456
- class: 'loader-wrapper',
537
+ this.loader = this.ce("div", {
538
+ class: "loader-wrapper",
457
539
  });
458
- const spinner = this.ce('div', {
459
- class: 'loader text-center',
540
+ const spinner = this.ce("div", {
541
+ class: "loader text-center",
460
542
  });
461
543
  this.loader.appendChild(spinner);
462
544
  }
545
+ /* eslint-disable max-depth */
463
546
  if (this.loader) {
464
547
  try {
465
548
  if (loading) {
@@ -469,10 +552,11 @@ export default class Webform extends NestedDataComponent {
469
552
  this.removeChildFrom(this.loader, this.wrapper);
470
553
  }
471
554
  }
472
- catch (ignoreErr) {
473
- // ignore
555
+ catch (err) {
556
+ // ingore
474
557
  }
475
558
  }
559
+ /* eslint-enable max-depth */
476
560
  }
477
561
  }
478
562
  /**
@@ -538,17 +622,18 @@ export default class Webform extends NestedDataComponent {
538
622
  // Use the sanitize config from the form settings or the global sanitize config if it is not provided in the options
539
623
  if (!this.options.sanitizeConfig && !this.builderMode) {
540
624
  this.options.sanitizeConfig =
541
- _.get(form, 'settings.sanitizeConfig') || _.get(form, 'globalSettings.sanitizeConfig');
625
+ _.get(form, "settings.sanitizeConfig") ||
626
+ _.get(form, "globalSettings.sanitizeConfig");
542
627
  }
543
- if ('schema' in form && compareVersions(form.schema, '1.x') > 0) {
628
+ if ("schema" in form && compareVersions(form.schema, "1.x") > 0) {
544
629
  this.ready.then(() => {
545
- this.setAlert('alert alert-danger', 'Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.');
630
+ this.setAlert("alert alert-danger", "Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.");
546
631
  });
547
632
  }
548
633
  // See if they pass a module, and evaluate it if so.
549
634
  if (form && form.module) {
550
635
  let formModule = null;
551
- if (typeof form.module === 'string') {
636
+ if (typeof form.module === "string") {
552
637
  try {
553
638
  formModule = this.evaluate(`return ${form.module}`);
554
639
  }
@@ -633,7 +718,7 @@ export default class Webform extends NestedDataComponent {
633
718
  */
634
719
  onSetSubmission(submission, flags = {}) {
635
720
  this.submissionSet = true;
636
- this.triggerChange(flags);
721
+ this.triggerChange?.(flags);
637
722
  this.emit('beforeSetSubmission', submission);
638
723
  this.setValue(submission, flags);
639
724
  }
@@ -646,7 +731,7 @@ export default class Webform extends NestedDataComponent {
646
731
  setSubmission(submission, flags = {}) {
647
732
  flags = {
648
733
  ...flags,
649
- fromSubmission: _.has(flags, 'fromSubmission') ? flags.fromSubmission : true,
734
+ fromSubmission: _.has(flags, "fromSubmission") ? flags.fromSubmission : true,
650
735
  };
651
736
  return (this.onSubmission = this.formReady
652
737
  .then((resolveFlags) => {
@@ -662,26 +747,26 @@ export default class Webform extends NestedDataComponent {
662
747
  .catch((err) => this.submissionReadyReject(err)));
663
748
  }
664
749
  handleDraftError(errName, errDetails, restoreDraft) {
665
- const errorMessage = _.trim(`${this.t(errName)} ${errDetails || ''}`);
750
+ const errorMessage = _.trim(`${this.t(errName)} ${errDetails || ""}`);
666
751
  console.warn(errorMessage);
667
- this.emit(restoreDraft ? 'restoreDraftError' : 'saveDraftError', errDetails || errorMessage);
752
+ this.emit(restoreDraft ? "restoreDraftError" : "saveDraftError", errDetails || errorMessage);
668
753
  }
669
754
  saveDraft() {
670
755
  if (!this.draftEnabled || this.parent?.component.reference === false) {
671
756
  return;
672
757
  }
673
758
  if (!this.formio) {
674
- this.handleDraftError('saveDraftInstanceError');
759
+ this.handleDraftError("saveDraftInstanceError");
675
760
  return;
676
761
  }
677
762
  if (!Formio.getUser()) {
678
- this.handleDraftError('saveDraftAuthError');
763
+ this.handleDraftError("saveDraftAuthError");
679
764
  return;
680
765
  }
681
766
  const draft = fastCloneDeep(this.submission);
682
- draft.state = 'draft';
767
+ draft.state = "draft";
683
768
  if (!this.savingDraft && !this.submitting) {
684
- this.emit('saveDraftBegin');
769
+ this.emit("saveDraftBegin");
685
770
  this.savingDraft = true;
686
771
  this.formio
687
772
  .saveSubmission(draft)
@@ -689,11 +774,11 @@ export default class Webform extends NestedDataComponent {
689
774
  // Set id to submission to avoid creating new draft submission
690
775
  this.submission._id = sub._id;
691
776
  this.savingDraft = false;
692
- this.emit('saveDraft', sub);
777
+ this.emit("saveDraft", sub);
693
778
  })
694
779
  .catch((err) => {
695
780
  this.savingDraft = false;
696
- this.handleDraftError('saveDraftError', err);
781
+ this.handleDraftError("saveDraftError", err);
697
782
  });
698
783
  }
699
784
  }
@@ -704,7 +789,7 @@ export default class Webform extends NestedDataComponent {
704
789
  restoreDraft(userId) {
705
790
  const formio = this.formio || this.options.formio;
706
791
  if (!formio) {
707
- this.handleDraftError('restoreDraftInstanceError', null, true);
792
+ this.handleDraftError("restoreDraftInstanceError", null, true);
708
793
  return;
709
794
  }
710
795
  this.savingDraft = true;
@@ -713,7 +798,7 @@ export default class Webform extends NestedDataComponent {
713
798
  params: {
714
799
  state: 'draft',
715
800
  owner: userId,
716
- sort: '-created',
801
+ sort: '-created'
717
802
  },
718
803
  })
719
804
  .then((submissions) => {
@@ -722,24 +807,22 @@ export default class Webform extends NestedDataComponent {
722
807
  return this.setSubmission(draft).then(() => {
723
808
  this.draftEnabled = true;
724
809
  this.savingDraft = false;
725
- this.emit('restoreDraft', draft);
810
+ this.emit("restoreDraft", draft);
726
811
  });
727
812
  }
728
813
  // Enable drafts so that we can keep track of changes.
729
814
  this.draftEnabled = true;
730
815
  this.savingDraft = false;
731
- this.emit('restoreDraft', null);
816
+ this.emit("restoreDraft", null);
732
817
  })
733
818
  .catch((err) => {
734
819
  this.draftEnabled = true;
735
820
  this.savingDraft = false;
736
- this.handleDraftError('restoreDraftError', err, true);
821
+ this.handleDraftError("restoreDraftError", err, true);
737
822
  });
738
823
  }
739
824
  get schema() {
740
- const schema = fastCloneDeep(_.omit(this._form, [
741
- 'components',
742
- ]));
825
+ const schema = fastCloneDeep(_.omit(this._form, ["components"]));
743
826
  schema.components = [];
744
827
  this.eachComponent((component) => schema.components.push(component.schema));
745
828
  return schema;
@@ -763,7 +846,9 @@ export default class Webform extends NestedDataComponent {
763
846
  this._submission.metadata = submission.metadata ? _.cloneDeep(submission.metadata) : {};
764
847
  this.editing = !!submission._id;
765
848
  // Set the timezone in the options if available.
766
- if (!this.options.submissionTimezone && submission.metadata && submission.metadata.timezone) {
849
+ if (!this.options.submissionTimezone &&
850
+ submission.metadata &&
851
+ submission.metadata.timezone) {
767
852
  this.options.submissionTimezone = submission.metadata.timezone;
768
853
  }
769
854
  const changed = super.setValue(submission.data, flags);
@@ -812,20 +897,20 @@ export default class Webform extends NestedDataComponent {
812
897
  else {
813
898
  this.component = this.form;
814
899
  }
815
- this.component.type = 'form';
900
+ this.component.type = "form";
816
901
  this.component.input = false;
817
902
  this.addComponents();
818
- this.on('submitButton', (options) => {
903
+ this.on("submitButton", (options) => {
819
904
  this.submit(false, options).catch((e) => {
820
905
  options.instance.loading = false;
821
906
  return e !== false && e !== undefined && console.log(e);
822
907
  });
823
908
  }, true);
824
- this.on('checkValidity', (data) => this.validate(data, { dirty: true, process: 'change' }), true);
825
- this.on('requestUrl', (args) => this.submitUrl(args.url, args.headers), true);
826
- this.on('resetForm', () => this.resetValue(), true);
827
- this.on('deleteSubmission', () => this.deleteSubmission(), true);
828
- this.on('refreshData', () => this.updateValue(), true);
909
+ this.on("checkValidity", (data) => this.validate(data, { dirty: true, process: "change" }), true);
910
+ this.on("requestUrl", (args) => this.submitUrl(args.url, args.headers), true);
911
+ this.on("resetForm", () => this.resetValue(), true);
912
+ this.on("deleteSubmission", () => this.deleteSubmission(), true);
913
+ this.on("refreshData", () => this.updateValue(), true);
829
914
  this.executeFormController();
830
915
  return this.formReady;
831
916
  }
@@ -834,7 +919,9 @@ export default class Webform extends NestedDataComponent {
834
919
  // hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
835
920
  if (!this.form ||
836
921
  !this.form.controller ||
837
- ((!this.visible || this.component.hidden) && this.component.clearOnHide && !this.rootPristine)) {
922
+ ((!this.visible || this.component.hidden) &&
923
+ this.component.clearOnHide &&
924
+ !this.rootPristine)) {
838
925
  return false;
839
926
  }
840
927
  this.formReady.then(() => {
@@ -848,19 +935,19 @@ export default class Webform extends NestedDataComponent {
848
935
  *
849
936
  */
850
937
  teardown() {
851
- this.emit('formDelete', this.id);
938
+ this.emit("formDelete", this.id);
852
939
  delete Formio.forms[this.id];
853
940
  delete this.executeShortcuts;
854
941
  delete this.triggerSaveDraft;
855
942
  super.teardown();
856
943
  }
857
944
  destroy(all = false) {
858
- this.off('submitButton');
859
- this.off('checkValidity');
860
- this.off('requestUrl');
861
- this.off('resetForm');
862
- this.off('deleteSubmission');
863
- this.off('refreshData');
945
+ this.off("submitButton");
946
+ this.off("checkValidity");
947
+ this.off("requestUrl");
948
+ this.off("resetForm");
949
+ this.off("deleteSubmission");
950
+ this.off("refreshData");
864
951
  return super.destroy(all);
865
952
  }
866
953
  build(element) {
@@ -873,17 +960,17 @@ export default class Webform extends NestedDataComponent {
873
960
  return this.ready;
874
961
  }
875
962
  getClassName() {
876
- let classes = 'formio-form';
963
+ let classes = "formio-form";
877
964
  if (this.options.readOnly) {
878
- classes += ' formio-read-only';
965
+ classes += " formio-read-only";
879
966
  }
880
967
  return classes;
881
968
  }
882
969
  render() {
883
- return super.render(this.renderTemplate('webform', {
970
+ return super.render(this.renderTemplate("webform", {
884
971
  classes: this.getClassName(),
885
972
  children: this.renderComponents(),
886
- }), this.builderMode ? 'builder' : 'form', true);
973
+ }), this.builderMode ? "builder" : "form", true);
887
974
  }
888
975
  redraw() {
889
976
  // Don't bother if we have not built yet.
@@ -896,13 +983,13 @@ export default class Webform extends NestedDataComponent {
896
983
  }
897
984
  attach(element) {
898
985
  this.setElement(element);
899
- this.loadRefs(element, { webform: 'single' });
986
+ this.loadRefs(element, { webform: "single" });
900
987
  const childPromise = this.attachComponents(this.refs.webform);
901
- this.addEventListener(document, 'keydown', this.executeShortcuts);
988
+ this.addEventListener(document, "keydown", this.executeShortcuts);
902
989
  this.currentForm = this;
903
- this.hook('attachWebform', element, this);
990
+ this.hook("attachWebform", element, this);
904
991
  return childPromise.then(() => {
905
- this.emit('render', this.element);
992
+ this.emit("render", this.element);
906
993
  return this.setValue(this._submission, {
907
994
  noUpdateEvent: true,
908
995
  });
@@ -934,8 +1021,8 @@ export default class Webform extends NestedDataComponent {
934
1021
  if (this.alert) {
935
1022
  if (this.refs.errorRef && this.refs.errorRef.length) {
936
1023
  this.refs.errorRef.forEach((el) => {
937
- this.removeEventListener(el, 'click');
938
- this.removeEventListener(el, 'keypress');
1024
+ this.removeEventListener(el, "click");
1025
+ this.removeEventListener(el, "keypress");
939
1026
  });
940
1027
  }
941
1028
  this.removeChild(this.alert);
@@ -945,7 +1032,7 @@ export default class Webform extends NestedDataComponent {
945
1032
  }
946
1033
  if (this.options.noAlerts) {
947
1034
  if (!message) {
948
- this.emit('error', false);
1035
+ this.emit("error", false);
949
1036
  }
950
1037
  return;
951
1038
  }
@@ -953,14 +1040,14 @@ export default class Webform extends NestedDataComponent {
953
1040
  try {
954
1041
  if (this.refs.errorRef && this.refs.errorRef.length) {
955
1042
  this.refs.errorRef.forEach((el) => {
956
- this.removeEventListener(el, 'click');
957
- this.removeEventListener(el, 'keypress');
1043
+ this.removeEventListener(el, "click");
1044
+ this.removeEventListener(el, "keypress");
958
1045
  });
959
1046
  }
960
1047
  this.removeChild(this.alert);
961
1048
  this.alert = null;
962
1049
  }
963
- catch (ignoreErr) {
1050
+ catch (err) {
964
1051
  // ignore
965
1052
  }
966
1053
  }
@@ -974,19 +1061,19 @@ export default class Webform extends NestedDataComponent {
974
1061
  attrs: attrs,
975
1062
  type,
976
1063
  };
977
- this.alert = convertStringToHTMLElement(this.renderTemplate('alert', templateOptions), `#${attrs.id}`);
1064
+ this.alert = convertStringToHTMLElement(this.renderTemplate("alert", templateOptions), `#${attrs.id}`);
978
1065
  }
979
1066
  if (!this.alert) {
980
1067
  return;
981
1068
  }
982
- this.loadRefs(this.alert, { errorRef: 'multiple' });
1069
+ this.loadRefs(this.alert, { errorRef: "multiple" });
983
1070
  if (this.refs.errorRef && this.refs.errorRef.length) {
984
1071
  this.refs.errorRef.forEach((el) => {
985
- this.addEventListener(el, 'click', (e) => {
1072
+ this.addEventListener(el, "click", (e) => {
986
1073
  const key = e.currentTarget.dataset.componentKey;
987
1074
  this.focusOnComponent(key);
988
1075
  });
989
- this.addEventListener(el, 'keydown', (e) => {
1076
+ this.addEventListener(el, "keydown", (e) => {
990
1077
  if (e.keyCode === 13) {
991
1078
  e.preventDefault();
992
1079
  const key = e.currentTarget.dataset.componentKey;
@@ -1009,17 +1096,12 @@ export default class Webform extends NestedDataComponent {
1009
1096
  }
1010
1097
  }
1011
1098
  }
1012
- /**
1013
- * @returns {boolean} - Whether or not the draft submission is being edited
1014
- */
1015
- isDraftEdit() {
1016
- return this.submitted && this.submission?.state === 'draft';
1017
- }
1018
1099
  /**
1019
1100
  * Show the errors of this form within the alert dialog.
1020
1101
  * @param {object} error - An optional additional error to display along with the component errors.
1021
1102
  * @returns {*}
1022
1103
  */
1104
+ /* eslint-disable no-unused-vars */
1023
1105
  /**
1024
1106
  *
1025
1107
  * @param {Array} errors - An array of errors to display.
@@ -1029,13 +1111,9 @@ export default class Webform extends NestedDataComponent {
1029
1111
  showErrors(errors, triggerEvent) {
1030
1112
  this.loading = false;
1031
1113
  if (!Array.isArray(errors)) {
1032
- errors = [
1033
- errors,
1034
- ];
1114
+ errors = [errors];
1035
1115
  }
1036
- if (Array.isArray(this.errors) &&
1037
- // do not show components validation errors in alert for draft submission
1038
- !this.isDraftEdit()) {
1116
+ if (Array.isArray(this.errors)) {
1039
1117
  errors = _.union(errors, this.errors);
1040
1118
  }
1041
1119
  errors = errors.concat(this.customErrors).filter((err) => !!err);
@@ -1063,11 +1141,7 @@ export default class Webform extends NestedDataComponent {
1063
1141
  }
1064
1142
  const displayedErrors = [];
1065
1143
  if (errors.length) {
1066
- errors = _.uniqBy(errors, (error) => [
1067
- error.message,
1068
- error.component?.id,
1069
- error.context?.path,
1070
- ].join());
1144
+ errors = _.uniqBy(errors, (error) => [error.message, error.component?.id, error.context?.path].join());
1071
1145
  const createListItem = (message, index) => {
1072
1146
  const err = errors[index];
1073
1147
  const messageFromIndex = !_.isUndefined(index) && errors && errors[index];
@@ -1077,8 +1151,8 @@ export default class Webform extends NestedDataComponent {
1077
1151
  (err.context?.component && err.context?.component.key) ||
1078
1152
  (err.component && err.component.key) ||
1079
1153
  (err.fromServer && err.path);
1080
- const formattedKeyOrPath = keyOrPath ? getStringFromComponentPath(keyOrPath) : '';
1081
- if (typeof err !== 'string' && !err.formattedKeyOrPath) {
1154
+ const formattedKeyOrPath = keyOrPath ? getStringFromComponentPath(keyOrPath) : "";
1155
+ if (typeof err !== "string" && !err.formattedKeyOrPath) {
1082
1156
  err.formattedKeyOrPath = formattedKeyOrPath;
1083
1157
  }
1084
1158
  return {
@@ -1088,18 +1162,22 @@ export default class Webform extends NestedDataComponent {
1088
1162
  };
1089
1163
  errors.forEach(({ message, context, fromServer, component }, index) => {
1090
1164
  const text = !component?.label || context?.hasLabel || fromServer
1091
- ? this.t(message)
1092
- : `${this.t(component?.label)}: ${this.t(message)}`;
1165
+ ? this.t("alertMessage", { message: this.t(message) })
1166
+ : this.t("alertMessageWithLabel", {
1167
+ label: this.t(component?.label),
1168
+ message: this.t(message),
1169
+ });
1093
1170
  displayedErrors.push(createListItem(text, index));
1094
1171
  });
1095
1172
  }
1096
- const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
1097
- this.root.setAlert('danger', errorsList);
1173
+ const errorsList = this.renderTemplate("errorsList", { errors: displayedErrors });
1174
+ this.root?.setAlert("danger", errorsList);
1098
1175
  if (triggerEvent) {
1099
- this.emit('error', errors);
1176
+ this.emit("error", errors);
1100
1177
  }
1101
1178
  return errors;
1102
1179
  }
1180
+ /* eslint-enable no-unused-vars */
1103
1181
  /**
1104
1182
  * Called when the submission has completed, or if the submission needs to be sent to an external library.
1105
1183
  * @param {object} submission - The submission object.
@@ -1115,23 +1193,23 @@ export default class Webform extends NestedDataComponent {
1115
1193
  noValidate: true,
1116
1194
  noCheck: true,
1117
1195
  });
1118
- this.setAlert('success', `<p>${this.t('complete')}</p>`);
1196
+ this.setAlert("success", `<p>${this.t("complete")}</p>`);
1119
1197
  // Cancel triggered saveDraft to prevent overriding the submitted state
1120
1198
  if (this.draftEnabled && this.triggerSaveDraft?.cancel) {
1121
1199
  this.triggerSaveDraft.cancel();
1122
1200
  }
1123
- this.emit('submit', submission, saved);
1201
+ this.emit("submit", submission, saved);
1124
1202
  if (saved) {
1125
- this.emit('submitDone', submission);
1203
+ this.emit("submitDone", submission);
1126
1204
  }
1127
1205
  return submission;
1128
1206
  }
1129
1207
  normalizeError(error) {
1130
1208
  if (error) {
1131
- if (typeof error === 'object' && 'details' in error) {
1209
+ if (typeof error === "object" && "details" in error) {
1132
1210
  error = error.details;
1133
1211
  }
1134
- if (typeof error === 'string') {
1212
+ if (typeof error === "string") {
1135
1213
  error = { message: error };
1136
1214
  }
1137
1215
  }
@@ -1146,10 +1224,10 @@ export default class Webform extends NestedDataComponent {
1146
1224
  error = this.normalizeError(error);
1147
1225
  this.submitting = false;
1148
1226
  this.setPristine(false);
1149
- this.emit('submitError', error || this.errors);
1227
+ this.emit("submitError", error || this.errors);
1150
1228
  // Allow for silent cancellations (no error message, no submit button error state)
1151
1229
  if (error && error.silent) {
1152
- this.emit('change', { isValid: true }, { silent: true });
1230
+ this.emit("change", { isValid: true }, { silent: true });
1153
1231
  return false;
1154
1232
  }
1155
1233
  const errors = this.showErrors(error, true);
@@ -1188,34 +1266,27 @@ export default class Webform extends NestedDataComponent {
1188
1266
  ? this.validate(value.data, {
1189
1267
  ...flags,
1190
1268
  noValidate: false,
1191
- process: 'change',
1269
+ process: 'change'
1192
1270
  })
1193
1271
  : [];
1194
- value.isValid = (errors || []).filter((err) => !err.fromServer).length === 0;
1272
+ value.isValid = (errors || []).filter(err => !err.fromServer).length === 0;
1195
1273
  this.loading = false;
1196
1274
  if (this.submitted) {
1197
1275
  // show server errors while they are not cleaned/fixed
1198
1276
  const nonComponentServerErrors = _.filter(this.serverErrors || [], (err) => !err.component && !err.path);
1199
- if (this.isDraftEdit()) {
1200
- if (nonComponentServerErrors.length) {
1201
- this.showErrors(nonComponentServerErrors);
1202
- }
1203
- }
1204
- else {
1205
- this.showErrors(nonComponentServerErrors.length ? nonComponentServerErrors : errors);
1206
- }
1277
+ this.showErrors(nonComponentServerErrors.length ? nonComponentServerErrors : errors);
1207
1278
  }
1208
1279
  // See if we need to save the draft of the form.
1209
1280
  if (modified && this.options.saveDraft) {
1210
1281
  this.triggerSaveDraft();
1211
1282
  }
1212
1283
  if (!flags || !flags.noEmit) {
1213
- this.emit('change', value, flags, modified);
1284
+ this.emit("change", value, flags, modified);
1214
1285
  isChangeEventEmitted = true;
1215
1286
  }
1216
1287
  // The form is initialized after the first change event occurs.
1217
1288
  if (isChangeEventEmitted && !this.initialized) {
1218
- this.emit('initialized');
1289
+ this.emit("initialized");
1219
1290
  this.initialized = true;
1220
1291
  }
1221
1292
  }
@@ -1225,7 +1296,7 @@ export default class Webform extends NestedDataComponent {
1225
1296
  */
1226
1297
  deleteSubmission() {
1227
1298
  return this.formio.deleteSubmission().then(() => {
1228
- this.emit('submissionDeleted', this.submission);
1299
+ this.emit("submissionDeleted", this.submission);
1229
1300
  this.resetValue();
1230
1301
  });
1231
1302
  }
@@ -1236,13 +1307,13 @@ export default class Webform extends NestedDataComponent {
1236
1307
  * @returns {boolean} - TRUE means the submission was cancelled, FALSE otherwise.
1237
1308
  */
1238
1309
  cancel(noconfirm) {
1239
- const shouldReset = this.hook('beforeCancel', true);
1240
- if (shouldReset && (noconfirm || confirm(this.t('confirmCancel')))) {
1310
+ const shouldReset = this.hook("beforeCancel", true);
1311
+ if (shouldReset && (noconfirm || confirm(this.t("confirmCancel")))) {
1241
1312
  this.resetValue();
1242
1313
  return true;
1243
1314
  }
1244
1315
  else {
1245
- this.emit('cancelSubmit');
1316
+ this.emit("cancelSubmit");
1246
1317
  return false;
1247
1318
  }
1248
1319
  }
@@ -1250,8 +1321,8 @@ export default class Webform extends NestedDataComponent {
1250
1321
  // Add in metadata about client submitting the form
1251
1322
  submission.metadata = submission.metadata || {};
1252
1323
  _.defaults(submission.metadata, {
1253
- timezone: _.get(this, '_submission.metadata.timezone', currentTimezone()),
1254
- offset: parseInt(_.get(this, '_submission.metadata.offset', moment().utcOffset()), 10),
1324
+ timezone: _.get(this, "_submission.metadata.timezone", currentTimezone()),
1325
+ offset: parseInt(_.get(this, "_submission.metadata.offset", moment().utcOffset()), 10),
1255
1326
  origin: document.location.origin,
1256
1327
  referrer: document.referrer,
1257
1328
  browserName: navigator.appName,
@@ -1272,26 +1343,26 @@ export default class Webform extends NestedDataComponent {
1272
1343
  }
1273
1344
  const submission = fastCloneDeep(this.submission || {});
1274
1345
  this.setMetadata(submission);
1275
- submission.state = options.state || submission.state || 'submitted';
1276
- const isDraft = submission.state === 'draft';
1277
- this.hook('beforeSubmit', { ...submission, component: options.component }, (err, data) => {
1346
+ submission.state = options.state || submission.state || "submitted";
1347
+ const isDraft = submission.state === "draft";
1348
+ this.hook("beforeSubmit", { ...submission, component: options.component }, (err, data) => {
1278
1349
  if (err) {
1279
1350
  return reject(err);
1280
1351
  }
1281
- submission._vnote = data && data._vnote ? data._vnote : '';
1352
+ submission._vnote = data && data._vnote ? data._vnote : "";
1282
1353
  try {
1283
1354
  if (!isDraft && !options.noValidate) {
1284
1355
  if (!submission.data) {
1285
- return reject('Invalid Submission');
1356
+ return reject("Invalid Submission");
1286
1357
  }
1287
1358
  const errors = this.validate(submission.data, {
1288
1359
  local,
1289
1360
  dirty: true,
1290
1361
  silentCheck: false,
1291
- process: 'submit',
1362
+ process: "submit",
1292
1363
  });
1293
1364
  if (errors.length ||
1294
- options.beforeSubmitResults?.some((result) => result.status === 'rejected')) {
1365
+ options.beforeSubmitResults?.some((result) => result.status === "rejected")) {
1295
1366
  return reject(errors);
1296
1367
  }
1297
1368
  }
@@ -1300,37 +1371,33 @@ export default class Webform extends NestedDataComponent {
1300
1371
  console.error(err);
1301
1372
  }
1302
1373
  this.everyComponent((comp) => {
1303
- if (submission._vnote && comp.type === 'form' && comp.component.reference) {
1304
- _.get(submission.data, local ? comp.paths?.localDataPath : comp.path, {})._vnote =
1305
- submission._vnote;
1374
+ if (submission._vnote && comp.type === "form" && comp.component.reference) {
1375
+ _.get(submission.data, local ? comp.paths?.localDataPath : comp.path, {})._vnote = submission._vnote;
1306
1376
  }
1307
1377
  const { persistent } = comp.component;
1308
- if (persistent === 'client-only') {
1378
+ if (persistent === "client-only") {
1309
1379
  _.unset(submission.data, local ? comp.paths?.localDataPath : comp.path);
1310
1380
  }
1311
1381
  });
1312
- this.hook('customValidation', { ...submission, component: options.component }, (err) => {
1382
+ this.hook("customValidation", { ...submission, component: options.component }, (err) => {
1313
1383
  if (err) {
1314
1384
  // If string is returned, cast to object.
1315
- if (typeof err === 'string') {
1385
+ if (typeof err === "string") {
1316
1386
  err = {
1317
1387
  message: err,
1318
1388
  };
1319
1389
  }
1320
1390
  // Ensure err is an array.
1321
- err = Array.isArray(err)
1322
- ? err
1323
- : [
1324
- err,
1325
- ];
1391
+ err = Array.isArray(err) ? err : [err];
1326
1392
  return reject(err);
1327
1393
  }
1328
1394
  this.loading = true;
1329
1395
  // Use the form action to submit the form if available.
1330
1396
  if (this._form && this._form.action) {
1331
- const method = submission.data._id && this._form.action.includes(submission.data._id)
1332
- ? 'PUT'
1333
- : 'POST';
1397
+ const method = submission.data._id &&
1398
+ this._form.action.includes(submission.data._id)
1399
+ ? "PUT"
1400
+ : "POST";
1334
1401
  return Formio.makeStaticRequest(this._form.action, method, submission, this.formio ? this.formio.options : {})
1335
1402
  .then((result) => resolve({
1336
1403
  submission: result,
@@ -1349,7 +1416,9 @@ export default class Webform extends NestedDataComponent {
1349
1416
  });
1350
1417
  }
1351
1418
  // If this is an actionUrl, then make sure to save the action and not the submission.
1352
- const submitMethod = submitFormio.actionUrl ? 'saveAction' : 'saveSubmission';
1419
+ const submitMethod = submitFormio.actionUrl
1420
+ ? "saveAction"
1421
+ : "saveSubmission";
1353
1422
  submitFormio[submitMethod](submission)
1354
1423
  .then((result) => resolve({
1355
1424
  submission: result,
@@ -1366,16 +1435,14 @@ export default class Webform extends NestedDataComponent {
1366
1435
  setServerErrors(error) {
1367
1436
  if (error.details) {
1368
1437
  this.serverErrors = error.details
1369
- .filter((err) => (err.level ? err.level === 'error' : err))
1438
+ .filter((err) => (err.level ? err.level === "error" : err))
1370
1439
  .map((err) => {
1371
1440
  err.fromServer = true;
1372
1441
  return err;
1373
1442
  });
1374
1443
  }
1375
- else if (typeof error === 'string') {
1376
- this.serverErrors = [
1377
- { fromServer: true, level: 'error', message: error },
1378
- ];
1444
+ else if (typeof error === "string") {
1445
+ this.serverErrors = [{ fromServer: true, level: "error", message: error }];
1379
1446
  }
1380
1447
  }
1381
1448
  executeSubmit(options) {
@@ -1433,17 +1500,17 @@ export default class Webform extends NestedDataComponent {
1433
1500
  }
1434
1501
  submitUrl(URL, headers) {
1435
1502
  if (!URL) {
1436
- return console.warn('Missing URL argument');
1503
+ return console.warn("Missing URL argument");
1437
1504
  }
1438
1505
  const submission = this.submission || {};
1439
1506
  const API_URL = URL;
1440
1507
  const settings = {
1441
- method: 'POST',
1508
+ method: "POST",
1442
1509
  headers: {},
1443
1510
  };
1444
1511
  if (headers && headers.length > 0) {
1445
1512
  headers.map((e) => {
1446
- if (e.header !== '' && e.value !== '') {
1513
+ if (e.header !== "" && e.value !== "") {
1447
1514
  settings.headers[e.header] = this.interpolate(e.value, submission);
1448
1515
  }
1449
1516
  });
@@ -1453,21 +1520,21 @@ export default class Webform extends NestedDataComponent {
1453
1520
  headers: settings.headers,
1454
1521
  })
1455
1522
  .then(() => {
1456
- this.emit('requestDone');
1457
- this.setAlert('success', '<p> Success </p>');
1523
+ this.emit("requestDone");
1524
+ this.setAlert("success", "<p> Success </p>");
1458
1525
  })
1459
1526
  .catch((e) => {
1460
- const message = `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`;
1461
- this.emit('error', message);
1527
+ const message = `${e.statusText ? e.statusText : ""} ${e.status ? e.status : e}`;
1528
+ this.emit("error", message);
1462
1529
  console.error(message);
1463
- this.setAlert('danger', `<p> ${message} </p>`);
1530
+ this.setAlert("danger", `<p> ${message} </p>`);
1464
1531
  return Promise.reject(this.onSubmissionError(e));
1465
1532
  });
1466
1533
  }
1467
1534
  else {
1468
- this.emit('error', 'You should add a URL to this button.');
1469
- this.setAlert('warning', 'You should add a URL to this button.');
1470
- return console.warn('You should add a URL to this button.');
1535
+ this.emit("error", "You should add a URL to this button.");
1536
+ this.setAlert("warning", "You should add a URL to this button.");
1537
+ return console.warn("You should add a URL to this button.");
1471
1538
  }
1472
1539
  }
1473
1540
  triggerCaptcha(components = null) {
@@ -1489,7 +1556,7 @@ export default class Webform extends NestedDataComponent {
1489
1556
  }
1490
1557
  set nosubmit(value) {
1491
1558
  this._nosubmit = !!value;
1492
- this.emit('nosubmit', this._nosubmit);
1559
+ this.emit("nosubmit", this._nosubmit);
1493
1560
  }
1494
1561
  get nosubmit() {
1495
1562
  return this._nosubmit || false;