@formio/js 5.0.0-rc.18 → 5.0.0-rc.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (325) hide show
  1. package/README.md +1 -1
  2. package/dist/formio.builder.css +14 -22
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.css +1 -2
  5. package/dist/formio.embed.js +2 -2
  6. package/dist/formio.embed.min.css +1 -1
  7. package/dist/formio.embed.min.js +1 -1
  8. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  9. package/dist/formio.form.css +10 -2
  10. package/dist/formio.form.js +333 -361
  11. package/dist/formio.form.min.css +1 -1
  12. package/dist/formio.form.min.js +1 -1
  13. package/dist/formio.form.min.js.LICENSE.txt +3 -8
  14. package/dist/formio.full.css +14 -22
  15. package/dist/formio.full.js +353 -370
  16. package/dist/formio.full.min.css +1 -1
  17. package/dist/formio.full.min.js +1 -1
  18. package/dist/formio.full.min.js.LICENSE.txt +3 -8
  19. package/dist/formio.js +208 -121
  20. package/dist/formio.min.js +1 -1
  21. package/dist/formio.min.js.LICENSE.txt +2 -7
  22. package/dist/formio.utils.js +220 -13
  23. package/dist/formio.utils.min.js +1 -1
  24. package/dist/formio.utils.min.js.LICENSE.txt +2 -7
  25. package/lib/cjs/CDN.js +1 -1
  26. package/lib/cjs/Element.js +7 -2
  27. package/lib/cjs/Embed.js +1 -1
  28. package/lib/cjs/Form.d.ts +8 -5
  29. package/lib/cjs/Form.js +52 -10
  30. package/lib/cjs/PDF.d.ts +11 -3
  31. package/lib/cjs/PDF.js +4 -5
  32. package/lib/cjs/PDFBuilder.js +2 -3
  33. package/lib/cjs/Webform.d.ts +4 -7
  34. package/lib/cjs/Webform.js +40 -119
  35. package/lib/cjs/WebformBuilder.d.ts +6 -1
  36. package/lib/cjs/WebformBuilder.js +104 -64
  37. package/lib/cjs/Wizard.d.ts +8 -5
  38. package/lib/cjs/Wizard.js +14 -14
  39. package/lib/cjs/WizardBuilder.d.ts +6 -4
  40. package/lib/cjs/WizardBuilder.js +20 -3
  41. package/lib/cjs/addons/FormioAddon.d.ts +1 -1
  42. package/lib/cjs/addons/FormioAddon.js +1 -2
  43. package/lib/cjs/components/_classes/component/Component.d.ts +17 -8
  44. package/lib/cjs/components/_classes/component/Component.js +52 -18
  45. package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
  46. package/lib/cjs/components/_classes/input/Input.js +1 -2
  47. package/lib/cjs/components/_classes/list/ListComponent.d.ts +4 -0
  48. package/lib/cjs/components/_classes/list/ListComponent.js +43 -6
  49. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -0
  50. package/lib/cjs/components/_classes/multivalue/Multivalue.js +10 -4
  51. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +5 -2
  52. package/lib/cjs/components/_classes/nested/NestedComponent.js +11 -12
  53. package/lib/cjs/components/address/Address.d.ts +8 -0
  54. package/lib/cjs/components/button/Button.js +2 -3
  55. package/lib/cjs/components/checkbox/Checkbox.d.ts +13 -0
  56. package/lib/cjs/components/checkbox/Checkbox.js +17 -5
  57. package/lib/cjs/components/columns/Columns.d.ts +1 -0
  58. package/lib/cjs/components/columns/Columns.js +1 -0
  59. package/lib/cjs/components/container/Container.d.ts +1 -0
  60. package/lib/cjs/components/container/Container.js +1 -0
  61. package/lib/cjs/components/content/Content.d.ts +1 -0
  62. package/lib/cjs/components/content/Content.js +1 -2
  63. package/lib/cjs/components/currency/editForm/Currency.edit.data.d.ts +14 -2
  64. package/lib/cjs/components/currency/editForm/Currency.edit.data.js +4 -0
  65. package/lib/cjs/components/currency/editForm/Currency.edit.display.js +4 -0
  66. package/lib/cjs/components/datagrid/DataGrid.d.ts +1 -0
  67. package/lib/cjs/components/datagrid/DataGrid.js +8 -1
  68. package/lib/cjs/components/datamap/DataMap.js +1 -0
  69. package/lib/cjs/components/datetime/DateTime.d.ts +4 -0
  70. package/lib/cjs/components/datetime/DateTime.js +21 -1
  71. package/lib/cjs/components/day/Day.d.ts +1 -1
  72. package/lib/cjs/components/day/Day.js +22 -6
  73. package/lib/cjs/components/day/fixtures/comp3.js +2 -2
  74. package/lib/cjs/components/editgrid/EditGrid.d.ts +4 -3
  75. package/lib/cjs/components/editgrid/EditGrid.js +11 -6
  76. package/lib/cjs/components/editgrid/fixtures/comp-with-custom-default-value.d.ts +190 -0
  77. package/lib/cjs/components/editgrid/fixtures/comp-with-custom-default-value.js +227 -0
  78. package/lib/cjs/components/editgrid/fixtures/comp15.d.ts +54 -0
  79. package/lib/cjs/components/editgrid/fixtures/comp15.js +51 -0
  80. package/lib/cjs/components/editgrid/fixtures/index.d.ts +3 -1
  81. package/lib/cjs/components/editgrid/fixtures/index.js +5 -1
  82. package/lib/cjs/components/fieldset/Fieldset.d.ts +1 -0
  83. package/lib/cjs/components/fieldset/Fieldset.js +1 -0
  84. package/lib/cjs/components/file/File.d.ts +7 -5
  85. package/lib/cjs/components/file/File.js +26 -9
  86. package/lib/cjs/components/file/editForm/File.edit.file.d.ts +62 -0
  87. package/lib/cjs/components/file/editForm/File.edit.file.js +29 -2
  88. package/lib/cjs/components/form/Form.d.ts +3 -0
  89. package/lib/cjs/components/form/Form.js +9 -10
  90. package/lib/cjs/components/hidden/Hidden.d.ts +1 -0
  91. package/lib/cjs/components/hidden/Hidden.js +1 -0
  92. package/lib/cjs/components/html/HTML.d.ts +1 -0
  93. package/lib/cjs/components/html/HTML.js +1 -0
  94. package/lib/cjs/components/number/Number.d.ts +5 -1
  95. package/lib/cjs/components/number/Number.js +24 -7
  96. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -0
  97. package/lib/cjs/components/radio/Radio.d.ts +5 -3
  98. package/lib/cjs/components/radio/Radio.js +59 -18
  99. package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
  100. package/lib/cjs/components/recaptcha/ReCaptcha.js +4 -5
  101. package/lib/cjs/components/resource/Resource.d.ts +7 -0
  102. package/lib/cjs/components/resource/Resource.js +0 -1
  103. package/lib/cjs/components/resource/editForm/Resource.edit.display.js +1 -1
  104. package/lib/cjs/components/select/Select.d.ts +7 -5
  105. package/lib/cjs/components/select/Select.js +15 -49
  106. package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +12 -0
  107. package/lib/cjs/components/selectboxes/SelectBoxes.js +53 -25
  108. package/lib/cjs/components/selectboxes/fixtures/comp4.d.ts +30 -27
  109. package/lib/cjs/components/selectboxes/fixtures/comp4.js +47 -32
  110. package/lib/cjs/components/selectboxes/fixtures/comp6.d.ts +14 -0
  111. package/lib/cjs/components/selectboxes/fixtures/comp6.js +15 -0
  112. package/lib/cjs/components/selectboxes/fixtures/index.d.ts +2 -1
  113. package/lib/cjs/components/selectboxes/fixtures/index.js +3 -1
  114. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  115. package/lib/cjs/components/signature/Signature.js +8 -3
  116. package/lib/cjs/components/survey/Survey.js +3 -0
  117. package/lib/cjs/components/table/Table.d.ts +1 -0
  118. package/lib/cjs/components/table/Table.js +1 -0
  119. package/lib/cjs/components/tabs/Tabs.d.ts +1 -0
  120. package/lib/cjs/components/tabs/Tabs.js +1 -0
  121. package/lib/cjs/components/tags/Tags.js +3 -0
  122. package/lib/cjs/components/textarea/TextArea.d.ts +3 -2
  123. package/lib/cjs/components/textarea/TextArea.js +4 -5
  124. package/lib/cjs/components/textarea/fixtures/comp4.d.ts +30 -0
  125. package/lib/cjs/components/textarea/fixtures/comp4.js +27 -0
  126. package/lib/cjs/components/textarea/fixtures/index.d.ts +2 -1
  127. package/lib/cjs/components/textarea/fixtures/index.js +3 -1
  128. package/lib/cjs/components/textfield/TextField.d.ts +1 -0
  129. package/lib/cjs/components/textfield/TextField.js +5 -3
  130. package/lib/cjs/components/time/Time.d.ts +4 -0
  131. package/lib/cjs/components/time/Time.js +6 -1
  132. package/lib/cjs/components/tree/Tree.d.ts +5 -4
  133. package/lib/cjs/components/tree/Tree.form.js +5 -0
  134. package/lib/cjs/components/tree/Tree.js +8 -9
  135. package/lib/cjs/components/tree/editForm/Tree.edit.display.d.ts +9 -0
  136. package/lib/cjs/components/tree/editForm/Tree.edit.display.js +12 -0
  137. package/lib/cjs/components/well/Well.d.ts +1 -0
  138. package/lib/cjs/components/well/Well.js +1 -0
  139. package/lib/cjs/providers/Providers.d.ts +31 -11
  140. package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +2 -2
  141. package/lib/cjs/providers/address/GoogleAddressProvider.js +2 -3
  142. package/lib/cjs/providers/processor/fileProcessor.d.ts +1 -1
  143. package/lib/cjs/providers/processor/fileProcessor.js +1 -5
  144. package/lib/cjs/providers/storage/azure.d.ts +10 -1
  145. package/lib/cjs/providers/storage/azure.js +7 -2
  146. package/lib/cjs/providers/storage/base64.d.ts +2 -2
  147. package/lib/cjs/providers/storage/base64.js +2 -6
  148. package/lib/cjs/providers/storage/dropbox.d.ts +2 -2
  149. package/lib/cjs/providers/storage/dropbox.js +2 -6
  150. package/lib/cjs/providers/storage/googleDrive.d.ts +3 -2
  151. package/lib/cjs/providers/storage/googleDrive.js +6 -6
  152. package/lib/cjs/providers/storage/indexeddb.d.ts +3 -3
  153. package/lib/cjs/providers/storage/indexeddb.js +9 -13
  154. package/lib/cjs/providers/storage/s3.d.ts +11 -1
  155. package/lib/cjs/providers/storage/s3.js +5 -2
  156. package/lib/cjs/providers/storage/uploadAdapter.js +1 -5
  157. package/lib/cjs/providers/storage/url.d.ts +2 -2
  158. package/lib/cjs/providers/storage/url.js +12 -8
  159. package/lib/cjs/providers/storage/xhr.d.ts +1 -1
  160. package/lib/cjs/providers/storage/xhr.js +1 -2
  161. package/lib/cjs/templates/index.d.ts +226 -1
  162. package/lib/cjs/utils/Evaluator.js +4 -33
  163. package/lib/cjs/utils/i18n.d.ts +16 -0
  164. package/lib/cjs/utils/i18n.js +88 -0
  165. package/lib/cjs/utils/utils.d.ts +1 -1
  166. package/lib/cjs/utils/utils.js +8 -9
  167. package/lib/cjs/validator/Validator.d.ts +30 -2
  168. package/lib/cjs/validator/Validator.js +32 -9
  169. package/lib/cjs/validator/rules/Select.js +1 -2
  170. package/lib/cjs/validator/rules/Unique.d.ts +1 -1
  171. package/lib/cjs/validator/rules/Unique.js +1 -2
  172. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -0
  173. package/lib/cjs/widgets/InputWidget.d.ts +1 -1
  174. package/lib/cjs/widgets/InputWidget.js +1 -2
  175. package/lib/mjs/CDN.js +1 -1
  176. package/lib/mjs/Element.js +6 -2
  177. package/lib/mjs/Embed.js +4 -1
  178. package/lib/mjs/Form.d.ts +8 -5
  179. package/lib/mjs/Form.js +52 -10
  180. package/lib/mjs/PDF.d.ts +11 -3
  181. package/lib/mjs/PDF.js +4 -5
  182. package/lib/mjs/PDFBuilder.js +2 -3
  183. package/lib/mjs/Webform.d.ts +4 -7
  184. package/lib/mjs/Webform.js +40 -122
  185. package/lib/mjs/WebformBuilder.d.ts +6 -1
  186. package/lib/mjs/WebformBuilder.js +102 -64
  187. package/lib/mjs/Wizard.d.ts +8 -5
  188. package/lib/mjs/Wizard.js +14 -14
  189. package/lib/mjs/WizardBuilder.d.ts +6 -4
  190. package/lib/mjs/WizardBuilder.js +20 -3
  191. package/lib/mjs/addons/FormioAddon.d.ts +1 -1
  192. package/lib/mjs/addons/FormioAddon.js +1 -2
  193. package/lib/mjs/components/_classes/component/Component.d.ts +17 -8
  194. package/lib/mjs/components/_classes/component/Component.js +52 -18
  195. package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
  196. package/lib/mjs/components/_classes/input/Input.js +1 -2
  197. package/lib/mjs/components/_classes/list/ListComponent.d.ts +4 -0
  198. package/lib/mjs/components/_classes/list/ListComponent.js +43 -5
  199. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -0
  200. package/lib/mjs/components/_classes/multivalue/Multivalue.js +10 -4
  201. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +5 -2
  202. package/lib/mjs/components/_classes/nested/NestedComponent.js +11 -12
  203. package/lib/mjs/components/address/Address.d.ts +8 -0
  204. package/lib/mjs/components/button/Button.js +2 -3
  205. package/lib/mjs/components/checkbox/Checkbox.d.ts +13 -0
  206. package/lib/mjs/components/checkbox/Checkbox.js +21 -5
  207. package/lib/mjs/components/columns/Columns.d.ts +1 -0
  208. package/lib/mjs/components/columns/Columns.js +1 -0
  209. package/lib/mjs/components/container/Container.d.ts +1 -0
  210. package/lib/mjs/components/container/Container.js +1 -0
  211. package/lib/mjs/components/content/Content.d.ts +1 -0
  212. package/lib/mjs/components/content/Content.js +1 -2
  213. package/lib/mjs/components/currency/editForm/Currency.edit.data.d.ts +14 -2
  214. package/lib/mjs/components/currency/editForm/Currency.edit.data.js +4 -0
  215. package/lib/mjs/components/currency/editForm/Currency.edit.display.js +4 -0
  216. package/lib/mjs/components/datagrid/DataGrid.d.ts +1 -0
  217. package/lib/mjs/components/datagrid/DataGrid.js +8 -1
  218. package/lib/mjs/components/datamap/DataMap.js +1 -0
  219. package/lib/mjs/components/datetime/DateTime.d.ts +4 -0
  220. package/lib/mjs/components/datetime/DateTime.js +28 -1
  221. package/lib/mjs/components/day/Day.d.ts +1 -1
  222. package/lib/mjs/components/day/Day.js +25 -6
  223. package/lib/mjs/components/day/fixtures/comp3.js +2 -2
  224. package/lib/mjs/components/editgrid/EditGrid.d.ts +4 -3
  225. package/lib/mjs/components/editgrid/EditGrid.js +11 -6
  226. package/lib/mjs/components/editgrid/fixtures/comp-with-custom-default-value.d.ts +190 -0
  227. package/lib/mjs/components/editgrid/fixtures/comp-with-custom-default-value.js +225 -0
  228. package/lib/mjs/components/editgrid/fixtures/comp15.d.ts +54 -0
  229. package/lib/mjs/components/editgrid/fixtures/comp15.js +49 -0
  230. package/lib/mjs/components/editgrid/fixtures/index.d.ts +3 -1
  231. package/lib/mjs/components/editgrid/fixtures/index.js +3 -1
  232. package/lib/mjs/components/fieldset/Fieldset.d.ts +1 -0
  233. package/lib/mjs/components/fieldset/Fieldset.js +1 -0
  234. package/lib/mjs/components/file/File.d.ts +7 -5
  235. package/lib/mjs/components/file/File.js +29 -9
  236. package/lib/mjs/components/file/editForm/File.edit.file.d.ts +62 -0
  237. package/lib/mjs/components/file/editForm/File.edit.file.js +29 -2
  238. package/lib/mjs/components/form/Form.d.ts +3 -0
  239. package/lib/mjs/components/form/Form.js +9 -10
  240. package/lib/mjs/components/hidden/Hidden.d.ts +1 -0
  241. package/lib/mjs/components/hidden/Hidden.js +1 -0
  242. package/lib/mjs/components/html/HTML.d.ts +1 -0
  243. package/lib/mjs/components/html/HTML.js +1 -0
  244. package/lib/mjs/components/number/Number.d.ts +5 -1
  245. package/lib/mjs/components/number/Number.js +24 -7
  246. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -0
  247. package/lib/mjs/components/radio/Radio.d.ts +5 -3
  248. package/lib/mjs/components/radio/Radio.js +59 -18
  249. package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
  250. package/lib/mjs/components/recaptcha/ReCaptcha.js +4 -5
  251. package/lib/mjs/components/resource/Resource.d.ts +7 -0
  252. package/lib/mjs/components/resource/Resource.js +0 -1
  253. package/lib/mjs/components/resource/editForm/Resource.edit.display.js +1 -1
  254. package/lib/mjs/components/select/Select.d.ts +7 -5
  255. package/lib/mjs/components/select/Select.js +18 -49
  256. package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +12 -0
  257. package/lib/mjs/components/selectboxes/SelectBoxes.js +56 -25
  258. package/lib/mjs/components/selectboxes/fixtures/comp4.d.ts +30 -27
  259. package/lib/mjs/components/selectboxes/fixtures/comp4.js +47 -32
  260. package/lib/mjs/components/selectboxes/fixtures/comp6.d.ts +14 -0
  261. package/lib/mjs/components/selectboxes/fixtures/comp6.js +13 -0
  262. package/lib/mjs/components/selectboxes/fixtures/index.d.ts +2 -1
  263. package/lib/mjs/components/selectboxes/fixtures/index.js +2 -1
  264. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  265. package/lib/mjs/components/signature/Signature.js +11 -3
  266. package/lib/mjs/components/survey/Survey.js +6 -0
  267. package/lib/mjs/components/table/Table.d.ts +1 -0
  268. package/lib/mjs/components/table/Table.js +1 -0
  269. package/lib/mjs/components/tabs/Tabs.d.ts +1 -0
  270. package/lib/mjs/components/tabs/Tabs.js +1 -0
  271. package/lib/mjs/components/tags/Tags.js +6 -0
  272. package/lib/mjs/components/textarea/TextArea.d.ts +3 -2
  273. package/lib/mjs/components/textarea/TextArea.js +4 -5
  274. package/lib/mjs/components/textarea/fixtures/comp4.d.ts +30 -0
  275. package/lib/mjs/components/textarea/fixtures/comp4.js +25 -0
  276. package/lib/mjs/components/textarea/fixtures/index.d.ts +2 -1
  277. package/lib/mjs/components/textarea/fixtures/index.js +2 -1
  278. package/lib/mjs/components/textfield/TextField.d.ts +1 -0
  279. package/lib/mjs/components/textfield/TextField.js +8 -3
  280. package/lib/mjs/components/time/Time.d.ts +4 -0
  281. package/lib/mjs/components/time/Time.js +12 -1
  282. package/lib/mjs/components/tree/Tree.d.ts +5 -4
  283. package/lib/mjs/components/tree/Tree.form.js +5 -0
  284. package/lib/mjs/components/tree/Tree.js +8 -9
  285. package/lib/mjs/components/tree/editForm/Tree.edit.display.d.ts +9 -0
  286. package/lib/mjs/components/tree/editForm/Tree.edit.display.js +10 -0
  287. package/lib/mjs/components/well/Well.d.ts +1 -0
  288. package/lib/mjs/components/well/Well.js +1 -0
  289. package/lib/mjs/providers/Providers.d.ts +31 -11
  290. package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +2 -2
  291. package/lib/mjs/providers/address/GoogleAddressProvider.js +2 -3
  292. package/lib/mjs/providers/processor/fileProcessor.d.ts +1 -1
  293. package/lib/mjs/providers/processor/fileProcessor.js +1 -2
  294. package/lib/mjs/providers/storage/azure.d.ts +10 -1
  295. package/lib/mjs/providers/storage/azure.js +7 -2
  296. package/lib/mjs/providers/storage/base64.d.ts +2 -2
  297. package/lib/mjs/providers/storage/base64.js +2 -3
  298. package/lib/mjs/providers/storage/dropbox.d.ts +2 -2
  299. package/lib/mjs/providers/storage/dropbox.js +2 -3
  300. package/lib/mjs/providers/storage/googleDrive.d.ts +3 -2
  301. package/lib/mjs/providers/storage/googleDrive.js +6 -3
  302. package/lib/mjs/providers/storage/indexeddb.d.ts +3 -3
  303. package/lib/mjs/providers/storage/indexeddb.js +9 -10
  304. package/lib/mjs/providers/storage/s3.d.ts +11 -1
  305. package/lib/mjs/providers/storage/s3.js +5 -2
  306. package/lib/mjs/providers/storage/uploadAdapter.js +1 -2
  307. package/lib/mjs/providers/storage/url.d.ts +2 -2
  308. package/lib/mjs/providers/storage/url.js +12 -5
  309. package/lib/mjs/providers/storage/xhr.d.ts +1 -1
  310. package/lib/mjs/providers/storage/xhr.js +1 -2
  311. package/lib/mjs/templates/index.d.ts +226 -1
  312. package/lib/mjs/utils/Evaluator.js +4 -33
  313. package/lib/mjs/utils/i18n.d.ts +16 -0
  314. package/lib/mjs/utils/i18n.js +81 -0
  315. package/lib/mjs/utils/utils.d.ts +1 -1
  316. package/lib/mjs/utils/utils.js +8 -9
  317. package/lib/mjs/validator/Validator.d.ts +30 -2
  318. package/lib/mjs/validator/Validator.js +31 -9
  319. package/lib/mjs/validator/rules/Select.js +1 -2
  320. package/lib/mjs/validator/rules/Unique.d.ts +1 -1
  321. package/lib/mjs/validator/rules/Unique.js +1 -2
  322. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -0
  323. package/lib/mjs/widgets/InputWidget.d.ts +1 -1
  324. package/lib/mjs/widgets/InputWidget.js +1 -2
  325. package/package.json +24 -25
@@ -4,7 +4,6 @@ import { compareVersions } from 'compare-versions';
4
4
  import EventEmitter from './EventEmitter';
5
5
  import i18nDefaults from './i18n';
6
6
  import { Formio } from './Formio';
7
- import NativePromise from 'native-promise-only';
8
7
  import Components from './components/Components';
9
8
  import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
10
9
  import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, searchComponents, convertStringToHTMLElement, getArrayFromComponentPath } from './utils/utils';
@@ -68,42 +67,6 @@ export default class Webform extends NestedDataComponent {
68
67
  if (this.options.baseUrl) {
69
68
  Formio.setBaseUrl(this.options.baseUrl);
70
69
  }
71
- /**
72
- * The i18n configuration for this component.
73
- */
74
- let i18n = i18nDefaults;
75
- if (options && options.i18n && !options.i18nReady) {
76
- // Support legacy way of doing translations.
77
- if (options.i18n.resources) {
78
- i18n = options.i18n;
79
- }
80
- else {
81
- _.each(options.i18n, (lang, code) => {
82
- if (code === 'options') {
83
- _.merge(i18n, lang);
84
- }
85
- else if (!i18n.resources[code]) {
86
- // extend the default translations (validations, buttons etc.) in case they are not in the options.
87
- i18n.resources[code] = { translation: _.assign(fastCloneDeep(i18nDefaults.resources.en.translation), lang) };
88
- }
89
- else {
90
- _.assign(i18n.resources[code].translation, lang);
91
- }
92
- });
93
- }
94
- options.i18n = i18n;
95
- options.i18nReady = true;
96
- }
97
- if (options && options.i18n) {
98
- this.options.i18n = options.i18n;
99
- }
100
- else {
101
- this.options.i18n = i18n;
102
- }
103
- // Set the language.
104
- if (this.options.language) {
105
- this.options.i18n.lng = this.options.language;
106
- }
107
70
  /**
108
71
  * The type of this element.
109
72
  * @type {string}
@@ -175,7 +138,7 @@ export default class Webform extends NestedDataComponent {
175
138
  * });
176
139
  * form.src = 'https://examples.form.io/example';
177
140
  */
178
- this.formReady = new NativePromise((resolve, reject) => {
141
+ this.formReady = new Promise((resolve, reject) => {
179
142
  /**
180
143
  * Called when the formReady state of this form has been resolved.
181
144
  *
@@ -201,7 +164,7 @@ export default class Webform extends NestedDataComponent {
201
164
  * });
202
165
  * form.src = 'https://examples.form.io/example/submission/234234234234234243';
203
166
  */
204
- this.submissionReady = new NativePromise((resolve, reject) => {
167
+ this.submissionReady = new Promise((resolve, reject) => {
205
168
  /**
206
169
  * Called when the formReady state of this form has been resolved.
207
170
  *
@@ -217,9 +180,7 @@ export default class Webform extends NestedDataComponent {
217
180
  });
218
181
  this.shortcuts = [];
219
182
  // Set language after everything is established.
220
- this.localize().then(() => {
221
- this.language = this.options.language;
222
- });
183
+ this.language = this.i18next.language;
223
184
  // See if we need to restore the draft from a user.
224
185
  if (this.options.saveDraft && !this.options.skipDraftRestore) {
225
186
  const user = Formio.getUser();
@@ -253,32 +214,17 @@ export default class Webform extends NestedDataComponent {
253
214
  if (!this.i18next) {
254
215
  return;
255
216
  }
256
- let cleanupThis = this;
257
- if (!cleanupThis) {
258
- return;
259
- }
260
- cleanupThis.options.language = lang;
261
- if (cleanupThis.i18next.language === lang) {
262
- cleanupThis = null;
263
- return;
264
- }
265
- try {
266
- cleanupThis.i18next.changeLanguage(lang, (err) => {
267
- if (err) {
268
- cleanupThis = null;
269
- return;
270
- }
271
- if (cleanupThis) {
272
- cleanupThis.rebuild();
273
- cleanupThis.emit('languageChanged');
274
- cleanupThis = null;
275
- }
276
- });
277
- }
278
- catch (err) {
279
- cleanupThis = null;
217
+ this.options.language = lang;
218
+ if (this.i18next.language === lang) {
280
219
  return;
281
220
  }
221
+ this.i18next.changeLanguage(lang, (err) => {
222
+ if (err) {
223
+ return;
224
+ }
225
+ this.rebuild();
226
+ this.emit('languageChanged');
227
+ });
282
228
  }
283
229
  get componentComponents() {
284
230
  return this.form.components;
@@ -303,48 +249,6 @@ export default class Webform extends NestedDataComponent {
303
249
  }
304
250
  }
305
251
  }
306
- /**
307
- * Perform the localization initialization.
308
- * @returns {*}
309
- */
310
- localize() {
311
- if (!this.i18next) {
312
- return NativePromise.resolve(null);
313
- }
314
- if (this.i18next.initialized) {
315
- return NativePromise.resolve(this.i18next);
316
- }
317
- this.i18next.initialized = true;
318
- let cleanupThis = this;
319
- return new NativePromise((resolve, reject) => {
320
- try {
321
- if (!cleanupThis) {
322
- return;
323
- }
324
- cleanupThis.i18next.init({
325
- ...cleanupThis.options.i18n,
326
- ...{ compatibilityJSON: 'v3' }
327
- }, (err) => {
328
- if (!cleanupThis) {
329
- reject(new Error('Lost reference to `this` while initializing i18next.'));
330
- }
331
- // Get language but remove any ;q=1 that might exist on it.
332
- cleanupThis.options.language = cleanupThis.i18next.language.split(';')[0];
333
- if (err) {
334
- cleanupThis = null;
335
- return reject(err);
336
- }
337
- const i18next = cleanupThis.i18next;
338
- cleanupThis = null;
339
- resolve(i18next);
340
- });
341
- }
342
- catch (err) {
343
- cleanupThis = null;
344
- return reject(err);
345
- }
346
- });
347
- }
348
252
  keyboardCatchableElement(element) {
349
253
  if (element.nodeName === 'TEXTAREA') {
350
254
  return false;
@@ -456,7 +360,7 @@ export default class Webform extends NestedDataComponent {
456
360
  this.formReadyReject(err);
457
361
  });
458
362
  }
459
- return NativePromise.resolve();
363
+ return Promise.resolve();
460
364
  }
461
365
  /**
462
366
  * Set the Form source, which is typically the Form.io embed URL.
@@ -605,7 +509,7 @@ export default class Webform extends NestedDataComponent {
605
509
  try {
606
510
  // Do not set the form again if it has been already set
607
511
  if (isFormAlreadySet && JSON.stringify(this._form) === JSON.stringify(form)) {
608
- return NativePromise.resolve();
512
+ return Promise.resolve();
609
513
  }
610
514
  // Create the form.
611
515
  this._form = flags?.keepAsReference ? form : _.cloneDeep(form);
@@ -613,13 +517,13 @@ export default class Webform extends NestedDataComponent {
613
517
  this.onSetForm(_.cloneDeep(this._form), form);
614
518
  }
615
519
  if (this.parent?.component?.modalEdit) {
616
- return NativePromise.resolve();
520
+ return Promise.resolve();
617
521
  }
618
522
  }
619
523
  catch (err) {
620
524
  console.warn(err);
621
525
  // If provided form is not a valid JSON object, do not set it too
622
- return NativePromise.resolve();
526
+ return Promise.resolve();
623
527
  }
624
528
  // Allow the form to provide component overrides.
625
529
  if (form && form.settings && form.settings.components) {
@@ -656,7 +560,7 @@ export default class Webform extends NestedDataComponent {
656
560
  }
657
561
  }
658
562
  this.initialized = false;
659
- const rebuild = this.rebuild() || NativePromise.resolve();
563
+ const rebuild = this.rebuild() || Promise.resolve();
660
564
  return rebuild.then(() => {
661
565
  this.emit('formLoad', form);
662
566
  this.triggerRecaptcha();
@@ -815,7 +719,10 @@ export default class Webform extends NestedDataComponent {
815
719
  }
816
720
  setValue(submission, flags = {}) {
817
721
  if (!submission || !submission.data) {
818
- submission = { data: {} };
722
+ submission = {
723
+ data: {},
724
+ metadata: submission.metadata,
725
+ };
819
726
  }
820
727
  // Metadata needs to be available before setValue
821
728
  this._submission.metadata = submission.metadata || {};
@@ -849,7 +756,14 @@ export default class Webform extends NestedDataComponent {
849
756
  * Build the form.
850
757
  */
851
758
  init() {
852
- this._submission = this._submission || { data: {} };
759
+ if (this.options.submission) {
760
+ const submission = _.extend({}, this.options.submission);
761
+ this._submission = submission;
762
+ this._data = submission.data;
763
+ }
764
+ else {
765
+ this._submission = this._submission || { data: {} };
766
+ }
853
767
  // Remove any existing components.
854
768
  if (this.components && this.components.length) {
855
769
  this.destroyComponents();
@@ -930,7 +844,7 @@ export default class Webform extends NestedDataComponent {
930
844
  redraw() {
931
845
  // Don't bother if we have not built yet.
932
846
  if (!this.element) {
933
- return NativePromise.resolve();
847
+ return Promise.resolve();
934
848
  }
935
849
  this.clear();
936
850
  this.setContent(this.element, this.render());
@@ -1303,7 +1217,7 @@ export default class Webform extends NestedDataComponent {
1303
1217
  }
1304
1218
  submitForm(options = {}) {
1305
1219
  this.clearServerErrors();
1306
- return new NativePromise((resolve, reject) => {
1220
+ return new Promise((resolve, reject) => {
1307
1221
  // Read-only forms should never submit.
1308
1222
  if (this.options.readOnly) {
1309
1223
  return resolve({
@@ -1327,6 +1241,9 @@ export default class Webform extends NestedDataComponent {
1327
1241
  return reject();
1328
1242
  }
1329
1243
  this.everyComponent((comp) => {
1244
+ if (submission._vnote && comp.type === 'form' && comp.component.reference) {
1245
+ _.get(submission.data, comp.path, {})._vnote = submission._vnote;
1246
+ }
1330
1247
  const { persistent } = comp.component;
1331
1248
  if (persistent === 'client-only') {
1332
1249
  _.unset(submission.data, comp.path);
@@ -1404,7 +1321,7 @@ export default class Webform extends NestedDataComponent {
1404
1321
  })
1405
1322
  .catch((err) => {
1406
1323
  this.submissionInProcess = false;
1407
- return NativePromise.reject(this.onSubmissionError(err));
1324
+ return Promise.reject(this.onSubmissionError(err));
1408
1325
  });
1409
1326
  }
1410
1327
  clearServerErrors() {
@@ -1470,10 +1387,11 @@ export default class Webform extends NestedDataComponent {
1470
1387
  this.emit('requestDone');
1471
1388
  this.setAlert('success', '<p> Success </p>');
1472
1389
  }).catch((e) => {
1473
- this.showErrors(`${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`);
1474
- this.emit('error', `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`);
1475
- console.error(`${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`);
1476
- this.setAlert('danger', `<p> ${e.statusText ? e.statusText : ''} ${e.status ? e.status : e} </p>`);
1390
+ const message = `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`;
1391
+ this.emit('error', message);
1392
+ console.error(message);
1393
+ this.setAlert('danger', `<p> ${message} </p>`);
1394
+ return Promise.reject(this.onSubmissionError(e));
1477
1395
  });
1478
1396
  }
1479
1397
  else {
@@ -49,6 +49,7 @@ export default class WebformBuilder extends Component {
49
49
  weight: number;
50
50
  };
51
51
  };
52
+ redraw(): Promise<void> | Promise<boolean>;
52
53
  set form(arg: any);
53
54
  get form(): any;
54
55
  get container(): any;
@@ -60,6 +61,7 @@ export default class WebformBuilder extends Component {
60
61
  findNamespaceRoot(component: any): any;
61
62
  recurseNamespace(component: any): any;
62
63
  render(): any;
64
+ attach(element: any): Promise<any>;
63
65
  searchFields(searchString?: string): void;
64
66
  orderComponents(groupInfo: any, foundComponents: any): void;
65
67
  updateDragAndDrop(): any;
@@ -86,6 +88,9 @@ export default class WebformBuilder extends Component {
86
88
  saveComponent(component: any, parent: any, isNew: any, original: any): boolean;
87
89
  isComponentCreated: boolean | undefined;
88
90
  emitSaveComponentEvent(schema: any, originalComp: any, parentComponentSchema: any, path: any, index: any, isNew: any, originalComponentSchema: any): void;
91
+ attachEditComponentControls(component: any, parent: any, isNew: any, original: any, ComponentClass: any): void;
92
+ saved: boolean | undefined;
93
+ showPreview: any;
89
94
  editComponent(component: any, parent: any, isNew: any, isJsonEdit: any, original: any, flags?: {}): void;
90
95
  editForm: Webform | undefined;
91
96
  preview: Webform | null | undefined;
@@ -93,7 +98,7 @@ export default class WebformBuilder extends Component {
93
98
  dialog: any;
94
99
  updateComponentKey(data: any): any;
95
100
  moveComponent(component: any): void;
96
- selectedElement: any;
101
+ selectedComponent: any;
97
102
  moveHandler: (e: any) => void;
98
103
  updateComponentPlacement(direction: any): void;
99
104
  stopMoving(comp: any): void;
@@ -1,7 +1,6 @@
1
1
  import Webform from './Webform';
2
2
  import Component from './components/_classes/component/Component';
3
3
  import tippy from 'tippy.js';
4
- import NativePromise from 'native-promise-only';
5
4
  import Components from './components/Components';
6
5
  import { Formio } from './Formio';
7
6
  import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath } from './utils/utils';
@@ -305,6 +304,9 @@ export default class WebformBuilder extends Component {
305
304
  });
306
305
  }
307
306
  attachComponent(element, component) {
307
+ if (component instanceof WebformBuilder) {
308
+ return;
309
+ }
308
310
  // Add component to element for later reference.
309
311
  element.formioComponent = component;
310
312
  component.loadRefs(element, {
@@ -571,7 +573,7 @@ export default class WebformBuilder extends Component {
571
573
  const { subgroups = [], components } = result;
572
574
  const filteredComponents = [];
573
575
  for (const key in components) {
574
- const isMatchedToTitle = components[key].title.toLowerCase().match(searchValue);
576
+ const isMatchedToTitle = this.t(components[key].title).toLowerCase().match(searchValue);
575
577
  const isMatchedToKey = components[key].key.toLowerCase().match(searchValue);
576
578
  if (isMatchedToTitle || isMatchedToKey) {
577
579
  filteredComponents.push(components[key]);
@@ -689,8 +691,17 @@ export default class WebformBuilder extends Component {
689
691
  }
690
692
  getComponentInfo(key, group) {
691
693
  let info;
694
+ // Need to check in first order as resource component key can be the same as from webform default components
695
+ if (group && group.slice(0, group.indexOf('-')) === 'resource') {
696
+ // This is an existing resource field.
697
+ const resourceGroups = this.groups.resource.subgroups;
698
+ const resourceGroup = _.find(resourceGroups, { key: group });
699
+ if (resourceGroup && resourceGroup.components.hasOwnProperty(`component-${key}`)) {
700
+ info = fastCloneDeep(resourceGroup.components[`component-${key}`].schema);
701
+ }
702
+ }
692
703
  // This is a new component
693
- if (this.schemas.hasOwnProperty(key)) {
704
+ else if (this.schemas.hasOwnProperty(key)) {
694
705
  info = fastCloneDeep(this.schemas[key]);
695
706
  }
696
707
  else if (this.groups.hasOwnProperty(group)) {
@@ -699,14 +710,6 @@ export default class WebformBuilder extends Component {
699
710
  info = fastCloneDeep(groupComponents[key].schema);
700
711
  }
701
712
  }
702
- else if (group.slice(0, group.indexOf('-')) === 'resource') {
703
- // This is an existing resource field.
704
- const resourceGroups = this.groups.resource.subgroups;
705
- const resourceGroup = _.find(resourceGroups, { key: group });
706
- if (resourceGroup && resourceGroup.components.hasOwnProperty(`component-${key}`)) {
707
- info = fastCloneDeep(resourceGroup.components[`component-${key}`].schema);
708
- }
709
- }
710
713
  else if (group === 'searchFields') { //Search components go into this group
711
714
  const resourceGroups = this.groups.resource.subgroups;
712
715
  for (let ix = 0; ix < resourceGroups.length; ix++) {
@@ -853,7 +856,7 @@ export default class WebformBuilder extends Component {
853
856
  rebuild = target.formioComponent.rebuild();
854
857
  }
855
858
  if (!rebuild) {
856
- rebuild = NativePromise.resolve();
859
+ rebuild = Promise.resolve();
857
860
  }
858
861
  return rebuild.then(() => {
859
862
  this.emit('addComponent', info, parent, path, index, isNew && !this.options.noNewEdit && !info.noNewEdit);
@@ -871,7 +874,7 @@ export default class WebformBuilder extends Component {
871
874
  }
872
875
  this.keyboardActionsEnabled = _.get(this.options, 'keyboardBuilder', false) || this.options.properties?.keyboardBuilder;
873
876
  const isShowSubmitButton = !this.options.noDefaultSubmitButton
874
- && !form.components.length;
877
+ && (!form.components.length || !form.components.find(comp => comp.key === 'submit'));
875
878
  // Ensure there is at least a submit button.
876
879
  if (isShowSubmitButton) {
877
880
  form.components.push({
@@ -898,7 +901,7 @@ export default class WebformBuilder extends Component {
898
901
  return this.rebuild().then(() => this.form);
899
902
  });
900
903
  }
901
- return NativePromise.resolve(form);
904
+ return Promise.resolve(form);
902
905
  }
903
906
  populateRecaptchaSettings(form) {
904
907
  //populate isEnabled for recaptcha form settings
@@ -947,7 +950,7 @@ export default class WebformBuilder extends Component {
947
950
  else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
948
951
  parent.formioComponent.removeChildComponent(component);
949
952
  }
950
- const rebuild = parent.formioComponent.rebuild() || NativePromise.resolve();
953
+ const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
951
954
  rebuild.then(() => {
952
955
  this.emit('removeComponent', component, parent.formioComponent.schema, path, index);
953
956
  this.emit('change', this.form);
@@ -996,6 +999,9 @@ export default class WebformBuilder extends Component {
996
999
  _.assign(defaultValueComponent.component, _.omit({ ...component }, [
997
1000
  'key',
998
1001
  'label',
1002
+ 'labelPosition',
1003
+ 'labelMargin',
1004
+ 'labelWidth',
999
1005
  'placeholder',
1000
1006
  'tooltip',
1001
1007
  'hidden',
@@ -1124,7 +1130,7 @@ export default class WebformBuilder extends Component {
1124
1130
  else if (isParentSaveChildMethod) {
1125
1131
  parent.formioComponent.saveChildComponent(submissionData);
1126
1132
  }
1127
- const rebuild = parentComponent.rebuild() || NativePromise.resolve();
1133
+ const rebuild = parentComponent.rebuild() || Promise.resolve();
1128
1134
  return rebuild.then(() => {
1129
1135
  const schema = parentContainer ? parentContainer[index] : (comp ? comp.schema : []);
1130
1136
  this.emitSaveComponentEvent(schema, originalComp, parentComponent.schema, path, index, isNew, originalComponentSchema);
@@ -1138,16 +1144,70 @@ export default class WebformBuilder extends Component {
1138
1144
  });
1139
1145
  }
1140
1146
  this.highlightInvalidComponents();
1141
- return NativePromise.resolve();
1147
+ return Promise.resolve();
1142
1148
  }
1143
1149
  emitSaveComponentEvent(schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema) {
1144
1150
  this.emit('saveComponent', schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema);
1145
1151
  }
1152
+ attachEditComponentControls(component, parent, isNew, original, ComponentClass) {
1153
+ const cancelButtons = this.componentEdit.querySelectorAll('[ref="cancelButton"]');
1154
+ cancelButtons.forEach((cancelButton) => {
1155
+ this.editForm.addEventListener(cancelButton, 'click', (event) => {
1156
+ event.preventDefault();
1157
+ this.editForm.detach();
1158
+ this.emit('cancelComponent', component);
1159
+ this.dialog.close();
1160
+ this.highlightInvalidComponents();
1161
+ });
1162
+ });
1163
+ const removeButtons = this.componentEdit.querySelectorAll('[ref="removeButton"]');
1164
+ removeButtons.forEach((removeButton) => {
1165
+ this.editForm.addEventListener(removeButton, 'click', (event) => {
1166
+ event.preventDefault();
1167
+ // Since we are already removing the component, don't trigger another remove.
1168
+ this.saved = true;
1169
+ this.editForm.detach();
1170
+ this.removeComponent(component, parent, original);
1171
+ this.dialog.close();
1172
+ this.highlightInvalidComponents();
1173
+ });
1174
+ });
1175
+ const saveButtons = this.componentEdit.querySelectorAll('[ref="saveButton"]');
1176
+ saveButtons.forEach((saveButton) => {
1177
+ this.editForm.addEventListener(saveButton, 'click', (event) => {
1178
+ event.preventDefault();
1179
+ if (!this.editForm.checkValidity(this.editForm.data, true, this.editForm.data)) {
1180
+ this.editForm.setPristine(false);
1181
+ this.editForm.showErrors();
1182
+ return false;
1183
+ }
1184
+ this.saved = true;
1185
+ this.saveComponent(component, parent, isNew, original);
1186
+ });
1187
+ });
1188
+ const previewButtons = this.componentEdit.querySelectorAll('[ref="previewButton"]');
1189
+ previewButtons.forEach((previewButton) => {
1190
+ this.editForm.addEventListener(previewButton, 'click', (event) => {
1191
+ event.preventDefault();
1192
+ this.showPreview = !this.showPreview;
1193
+ this.editForm.detach();
1194
+ this.setContent(this.componentEdit, this.renderTemplate('builderEditForm', {
1195
+ componentInfo: ComponentClass.builderInfo,
1196
+ editForm: this.editForm.render(),
1197
+ preview: this.preview ? this.preview.render() : false,
1198
+ showPreview: this.showPreview,
1199
+ helplinks: this.helplinks,
1200
+ }));
1201
+ this.editForm.attach(this.componentEdit.querySelector('[ref="editForm"]'));
1202
+ this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
1203
+ });
1204
+ });
1205
+ }
1146
1206
  editComponent(component, parent, isNew, isJsonEdit, original, flags = {}) {
1147
1207
  if (!component.key) {
1148
1208
  return;
1149
1209
  }
1150
- let saved = false;
1210
+ this.saved = false;
1151
1211
  const componentCopy = fastCloneDeep(component);
1152
1212
  let ComponentClass = Components.components[componentCopy.type];
1153
1213
  const isCustom = ComponentClass === undefined;
@@ -1195,7 +1255,9 @@ export default class WebformBuilder extends Component {
1195
1255
  }
1196
1256
  ]
1197
1257
  } : ComponentClass.editForm(_.cloneDeep(overrides));
1198
- const instanceOptions = {};
1258
+ const instanceOptions = {
1259
+ inFormBuilder: true,
1260
+ };
1199
1261
  this.hook('instanceOptionsPreview', instanceOptions);
1200
1262
  const instance = new ComponentClass(componentCopy, instanceOptions);
1201
1263
  const schema = this.hook('builderComponentSchema', component, instance);
@@ -1220,12 +1282,14 @@ export default class WebformBuilder extends Component {
1220
1282
  ]));
1221
1283
  this.hook('previewFormSettitngs', schema, isJsonEdit);
1222
1284
  }
1285
+ this.showPreview = ComponentClass.builderInfo.showPreview ?? true;
1223
1286
  this.componentEdit = this.ce('div', { 'class': 'component-edit-container' });
1224
1287
  this.setContent(this.componentEdit, this.renderTemplate('builderEditForm', {
1225
1288
  componentInfo: ComponentClass.builderInfo,
1226
1289
  editForm: this.editForm.render(),
1227
1290
  preview: this.preview ? this.preview.render() : false,
1228
- helplinks: this.helplinks,
1291
+ showPreview: this.showPreview,
1292
+ helplinks: this.helplinks
1229
1293
  }));
1230
1294
  this.dialog = this.createModal(this.componentEdit, _.get(this.options, 'dialogAttr', {}));
1231
1295
  // This is the attach step.
@@ -1279,48 +1343,14 @@ export default class WebformBuilder extends Component {
1279
1343
  this.updateComponent(event.data.componentJson || event.data, event.changed);
1280
1344
  }
1281
1345
  });
1282
- const cancelButtons = this.componentEdit.querySelectorAll('[ref="cancelButton"]');
1283
- cancelButtons.forEach((cancelButton) => {
1284
- this.addEventListener(cancelButton, 'click', (event) => {
1285
- event.preventDefault();
1286
- this.editForm.detach();
1287
- this.emit('cancelComponent', component);
1288
- this.dialog.close();
1289
- this.highlightInvalidComponents();
1290
- });
1291
- });
1292
- const removeButtons = this.componentEdit.querySelectorAll('[ref="removeButton"]');
1293
- removeButtons.forEach((removeButton) => {
1294
- this.addEventListener(removeButton, 'click', (event) => {
1295
- event.preventDefault();
1296
- // Since we are already removing the component, don't trigger another remove.
1297
- saved = true;
1298
- this.editForm.detach();
1299
- this.removeComponent(component, parent, original);
1300
- this.dialog.close();
1301
- this.highlightInvalidComponents();
1302
- });
1303
- });
1304
- const saveButtons = this.componentEdit.querySelectorAll('[ref="saveButton"]');
1305
- saveButtons.forEach((saveButton) => {
1306
- this.addEventListener(saveButton, 'click', (event) => {
1307
- event.preventDefault();
1308
- if (!this.editForm.checkValidity(this.editForm.data, true, this.editForm.data)) {
1309
- this.editForm.setPristine(false);
1310
- this.editForm.showErrors();
1311
- return false;
1312
- }
1313
- saved = true;
1314
- this.saveComponent(component, parent, isNew, original);
1315
- });
1316
- });
1346
+ this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
1317
1347
  const dialogClose = () => {
1318
1348
  this.editForm.destroy(true);
1319
1349
  if (this.preview) {
1320
1350
  this.preview.destroy(true);
1321
1351
  this.preview = null;
1322
1352
  }
1323
- if (isNew && !saved) {
1353
+ if (isNew && !this.saved) {
1324
1354
  this.removeComponent(component, parent, original);
1325
1355
  this.highlightInvalidComponents();
1326
1356
  }
@@ -1339,15 +1369,21 @@ export default class WebformBuilder extends Component {
1339
1369
  data.type).replace(/^[0-9]*/, '');
1340
1370
  }
1341
1371
  moveComponent(component) {
1372
+ if (this.selectedComponent) {
1373
+ const prevSelected = this.selectedComponent;
1374
+ prevSelected.element?.classList.remove('builder-component-selected');
1375
+ this.removeEventListener(document, 'keydown');
1376
+ }
1342
1377
  component.element.focus();
1343
- component.element.classList.add('builder-selected');
1344
- this.selectedElement = component;
1345
- this.removeEventListener(component.element, 'keydown');
1346
- this.addEventListener(component.element, 'keydown', this.moveHandler.bind(this));
1378
+ component.element.classList.add('builder-component-selected');
1379
+ this.selectedComponent = component;
1380
+ this.addEventListener(document, 'keydown', this.moveHandler.bind(this));
1347
1381
  }
1348
1382
  moveHandler = (e) => {
1349
- e.stopPropagation();
1350
- e.preventDefault();
1383
+ if (e.keyCode === 38 || e.keyCode === 40 || e.keyCode === 13) {
1384
+ e.stopPropagation();
1385
+ e.preventDefault();
1386
+ }
1351
1387
  if (e.keyCode === 38) {
1352
1388
  this.updateComponentPlacement(true);
1353
1389
  }
@@ -1355,11 +1391,11 @@ export default class WebformBuilder extends Component {
1355
1391
  this.updateComponentPlacement(false);
1356
1392
  }
1357
1393
  if (e.keyCode === 13) {
1358
- this.stopMoving(this.selectedElement);
1394
+ this.stopMoving(this.selectedComponent);
1359
1395
  }
1360
1396
  };
1361
1397
  updateComponentPlacement(direction) {
1362
- const component = this.selectedElement;
1398
+ const component = this.selectedComponent;
1363
1399
  let index, info;
1364
1400
  const step = direction ? -1 : 1;
1365
1401
  if (component) {
@@ -1402,7 +1438,9 @@ export default class WebformBuilder extends Component {
1402
1438
  }
1403
1439
  stopMoving(comp) {
1404
1440
  const parent = comp.element.parentNode;
1441
+ this.removeEventListener(document, 'keydown');
1405
1442
  parent.formioComponent.rebuild();
1443
+ this.selectedComponent = null;
1406
1444
  }
1407
1445
  addNewComponent(element) {
1408
1446
  const source = document.querySelector('.formio-builder-form');
@@ -11,7 +11,7 @@ declare class Wizard extends Webform {
11
11
  _seenPages: number[];
12
12
  subWizards: any[];
13
13
  allPages: any[];
14
- lastPromise: any;
14
+ lastPromise: Promise<void>;
15
15
  enabledIndex: number;
16
16
  editMode: boolean;
17
17
  originalOptions: any;
@@ -40,6 +40,7 @@ declare class Wizard extends Webform {
40
40
  prepareHeaderSettings(ctx: any, headerType: any): any;
41
41
  redrawNavigation(): void;
42
42
  redrawHeader(): void;
43
+ attach(element: any): Promise<void>;
43
44
  scrollPageToTop(): void;
44
45
  isBreadcrumbClickable(): any;
45
46
  isAllowPrevious(): any;
@@ -60,16 +61,18 @@ declare class Wizard extends Webform {
60
61
  establishPages(data?: any): any[];
61
62
  updatePages(): void;
62
63
  addComponents(): void;
63
- setPage(num: any): any;
64
+ setPage(num: any): Promise<void>;
64
65
  pageFieldLogic(page: any): void;
65
66
  get currentPage(): any;
66
67
  getNextPage(): number | null;
67
68
  getPreviousPage(): number;
69
+ beforeSubmit(): Promise<any[]>;
70
+ beforePage(next: any): Promise<any>;
68
71
  emitNextPage(): void;
69
- nextPage(): any;
72
+ nextPage(): Promise<void>;
70
73
  emitPrevPage(): void;
71
- prevPage(): any;
72
- cancel(noconfirm: any): any;
74
+ prevPage(): Promise<void>;
75
+ cancel(noconfirm: any): Promise<void> | Promise<number>;
73
76
  getPageIndexByKey(key: any): number;
74
77
  get schema(): Object;
75
78
  setComponentSchema(): void;