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