@formio/js 5.0.0-dev.5610.da13e39 → 5.0.0-dev.5613.3476921
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/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 +1199 -651
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +11 -3
- package/dist/formio.full.js +919 -691
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +11 -3
- package/dist/formio.js +16 -16
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +493 -1861
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -12
- package/lib/cjs/Element.d.ts +96 -86
- package/lib/cjs/Element.js +78 -68
- 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 +298 -313
- package/lib/cjs/WebformBuilder.d.ts +14 -16
- package/lib/cjs/WebformBuilder.js +11 -17
- package/lib/cjs/Wizard.d.ts +21 -31
- package/lib/cjs/Wizard.js +19 -42
- 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/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 +10 -13
- 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 -5
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +0 -4
- 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 +16 -13
- 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/translations/en.d.ts +1 -0
- package/lib/cjs/translations/en.js +1 -0
- 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 +216 -362
- package/lib/cjs/utils/utils.js +224 -331
- package/lib/cjs/widgets/CalendarWidget.d.ts +10 -9
- package/lib/cjs/widgets/CalendarWidget.js +11 -9
- package/lib/mjs/Element.d.ts +96 -86
- package/lib/mjs/Element.js +78 -68
- 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 +310 -325
- package/lib/mjs/WebformBuilder.d.ts +14 -16
- package/lib/mjs/WebformBuilder.js +11 -16
- package/lib/mjs/Wizard.d.ts +21 -31
- package/lib/mjs/Wizard.js +18 -41
- 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/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 +10 -13
- 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 -5
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +0 -4
- 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 +16 -13
- 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 +16 -13
- 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/translations/en.d.ts +1 -0
- package/lib/mjs/translations/en.js +1 -0
- 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 +216 -362
- package/lib/mjs/utils/utils.js +218 -325
- 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 -109
- package/lib/mjs/InlineEmbed.d.ts +0 -7
- package/lib/mjs/InlineEmbed.js +0 -105
- 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,9 +590,10 @@ 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
598
|
setForm(form, flags) {
|
|
584
599
|
var _a, _b, _c;
|
|
@@ -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.triggerRecaptcha();
|
|
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,117 +710,114 @@ 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 =
|
|
741
|
-
if (!this.savingDraft) {
|
|
742
|
-
this.emit(
|
|
759
|
+
draft.state = 'draft';
|
|
760
|
+
if (!this.savingDraft && !this.submitting) {
|
|
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
|
-
state:
|
|
773
|
-
owner: userId
|
|
774
|
-
}
|
|
775
|
-
})
|
|
776
|
-
.then((submissions) => {
|
|
789
|
+
state: 'draft',
|
|
790
|
+
owner: userId
|
|
791
|
+
}
|
|
792
|
+
}).then(submissions => {
|
|
777
793
|
if (submissions.length > 0 && !this.options.skipDraftRestore) {
|
|
778
794
|
const draft = (0, utils_1.fastCloneDeep)(submissions[0]);
|
|
779
795
|
return this.setSubmission(draft).then(() => {
|
|
780
796
|
this.draftEnabled = true;
|
|
781
797
|
this.savingDraft = false;
|
|
782
|
-
this.emit(
|
|
798
|
+
this.emit('restoreDraft', draft);
|
|
783
799
|
});
|
|
784
800
|
}
|
|
785
801
|
// Enable drafts so that we can keep track of changes.
|
|
786
802
|
this.draftEnabled = true;
|
|
787
803
|
this.savingDraft = false;
|
|
788
|
-
this.emit(
|
|
804
|
+
this.emit('restoreDraft', null);
|
|
789
805
|
})
|
|
790
|
-
.catch(
|
|
806
|
+
.catch(err => {
|
|
791
807
|
this.draftEnabled = true;
|
|
792
808
|
this.savingDraft = false;
|
|
793
|
-
this.handleDraftError(
|
|
809
|
+
this.handleDraftError('restoreDraftError', err, true);
|
|
794
810
|
});
|
|
795
811
|
}
|
|
796
812
|
get schema() {
|
|
797
|
-
const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, [
|
|
813
|
+
const schema = (0, utils_1.fastCloneDeep)(lodash_1.default.omit(this._form, ['components']));
|
|
798
814
|
schema.components = [];
|
|
799
815
|
this.eachComponent((component) => schema.components.push(component.schema));
|
|
800
816
|
return schema;
|
|
801
817
|
}
|
|
802
818
|
mergeData(_this, _that) {
|
|
803
819
|
lodash_1.default.mergeWith(_this, _that, (thisValue, thatValue) => {
|
|
804
|
-
if (Array.isArray(thisValue) &&
|
|
805
|
-
Array.isArray(thatValue) &&
|
|
806
|
-
thisValue.length !== thatValue.length) {
|
|
820
|
+
if (Array.isArray(thisValue) && Array.isArray(thatValue) && thisValue.length !== thatValue.length) {
|
|
807
821
|
return thatValue;
|
|
808
822
|
}
|
|
809
823
|
});
|
|
@@ -845,7 +859,6 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
845
859
|
}
|
|
846
860
|
/**
|
|
847
861
|
* Build the form.
|
|
848
|
-
* @returns {Promise} - The promise that is triggered when the form is built.
|
|
849
862
|
*/
|
|
850
863
|
init() {
|
|
851
864
|
if (this.options.submission) {
|
|
@@ -867,31 +880,28 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
867
880
|
else {
|
|
868
881
|
this.component = this.form;
|
|
869
882
|
}
|
|
870
|
-
this.component.type =
|
|
883
|
+
this.component.type = 'form';
|
|
871
884
|
this.component.input = false;
|
|
872
885
|
this.addComponents();
|
|
873
|
-
this.on(
|
|
874
|
-
this.submit(false, options).catch(
|
|
886
|
+
this.on('submitButton', options => {
|
|
887
|
+
this.submit(false, options).catch(e => {
|
|
875
888
|
options.instance.loading = false;
|
|
876
889
|
return e !== false && e !== undefined && console.log(e);
|
|
877
890
|
});
|
|
878
891
|
}, true);
|
|
879
|
-
this.on(
|
|
880
|
-
this.on(
|
|
881
|
-
this.on(
|
|
882
|
-
this.on(
|
|
883
|
-
this.on(
|
|
892
|
+
this.on('checkValidity', (data) => this.validate(data, { dirty: true, process: 'change' }), true);
|
|
893
|
+
this.on('requestUrl', (args) => (this.submitUrl(args.url, args.headers)), true);
|
|
894
|
+
this.on('resetForm', () => this.resetValue(), true);
|
|
895
|
+
this.on('deleteSubmission', () => this.deleteSubmission(), true);
|
|
896
|
+
this.on('refreshData', () => this.updateValue(), true);
|
|
884
897
|
this.executeFormController();
|
|
885
898
|
return this.formReady;
|
|
886
899
|
}
|
|
887
900
|
executeFormController() {
|
|
888
901
|
// If no controller value or
|
|
889
902
|
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
|
890
|
-
if (!this.form ||
|
|
891
|
-
!this.
|
|
892
|
-
((!this.visible || this.component.hidden) &&
|
|
893
|
-
this.component.clearOnHide &&
|
|
894
|
-
!this.rootPristine)) {
|
|
903
|
+
if (!this.form || !this.form.controller
|
|
904
|
+
|| ((!this.visible || this.component.hidden) && this.component.clearOnHide && !this.rootPristine)) {
|
|
895
905
|
return false;
|
|
896
906
|
}
|
|
897
907
|
this.formReady.then(() => {
|
|
@@ -901,23 +911,20 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
901
911
|
});
|
|
902
912
|
});
|
|
903
913
|
}
|
|
904
|
-
/**
|
|
905
|
-
*
|
|
906
|
-
*/
|
|
907
914
|
teardown() {
|
|
908
|
-
this.emit(
|
|
915
|
+
this.emit('formDelete', this.id);
|
|
909
916
|
delete Formio_1.Formio.forms[this.id];
|
|
910
917
|
delete this.executeShortcuts;
|
|
911
918
|
delete this.triggerSaveDraft;
|
|
912
919
|
super.teardown();
|
|
913
920
|
}
|
|
914
921
|
destroy(all = false) {
|
|
915
|
-
this.off(
|
|
916
|
-
this.off(
|
|
917
|
-
this.off(
|
|
918
|
-
this.off(
|
|
919
|
-
this.off(
|
|
920
|
-
this.off(
|
|
922
|
+
this.off('submitButton');
|
|
923
|
+
this.off('checkValidity');
|
|
924
|
+
this.off('requestUrl');
|
|
925
|
+
this.off('resetForm');
|
|
926
|
+
this.off('deleteSubmission');
|
|
927
|
+
this.off('refreshData');
|
|
921
928
|
return super.destroy(all);
|
|
922
929
|
}
|
|
923
930
|
build(element) {
|
|
@@ -930,17 +937,17 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
930
937
|
return this.ready;
|
|
931
938
|
}
|
|
932
939
|
getClassName() {
|
|
933
|
-
let classes =
|
|
940
|
+
let classes = 'formio-form';
|
|
934
941
|
if (this.options.readOnly) {
|
|
935
|
-
classes +=
|
|
942
|
+
classes += ' formio-read-only';
|
|
936
943
|
}
|
|
937
944
|
return classes;
|
|
938
945
|
}
|
|
939
946
|
render() {
|
|
940
|
-
return super.render(this.renderTemplate(
|
|
947
|
+
return super.render(this.renderTemplate('webform', {
|
|
941
948
|
classes: this.getClassName(),
|
|
942
949
|
children: this.renderComponents(),
|
|
943
|
-
}), this.builderMode ?
|
|
950
|
+
}), this.builderMode ? 'builder' : 'form', true);
|
|
944
951
|
}
|
|
945
952
|
redraw() {
|
|
946
953
|
// Don't bother if we have not built yet.
|
|
@@ -953,13 +960,13 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
953
960
|
}
|
|
954
961
|
attach(element) {
|
|
955
962
|
this.setElement(element);
|
|
956
|
-
this.loadRefs(element, { webform:
|
|
963
|
+
this.loadRefs(element, { webform: 'single' });
|
|
957
964
|
const childPromise = this.attachComponents(this.refs.webform);
|
|
958
|
-
this.addEventListener(document,
|
|
965
|
+
this.addEventListener(document, 'keydown', this.executeShortcuts);
|
|
959
966
|
this.currentForm = this;
|
|
960
|
-
this.hook(
|
|
967
|
+
this.hook('attachWebform', element, this);
|
|
961
968
|
return childPromise.then(() => {
|
|
962
|
-
this.emit(
|
|
969
|
+
this.emit('render', this.element);
|
|
963
970
|
return this.setValue(this._submission, {
|
|
964
971
|
noUpdateEvent: true,
|
|
965
972
|
});
|
|
@@ -976,23 +983,24 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
976
983
|
return result;
|
|
977
984
|
}
|
|
978
985
|
resetValue() {
|
|
979
|
-
lodash_1.default.each(this.getComponents(), (comp) => comp.resetValue());
|
|
986
|
+
lodash_1.default.each(this.getComponents(), (comp) => (comp.resetValue()));
|
|
980
987
|
this.setPristine(true);
|
|
981
988
|
this.onChange({ resetValue: true });
|
|
982
989
|
}
|
|
983
990
|
/**
|
|
984
991
|
* Sets a new alert to display in the error dialog of the form.
|
|
992
|
+
*
|
|
985
993
|
* @param {string} type - The type of alert to display. "danger", "success", "warning", etc.
|
|
986
994
|
* @param {string} message - The message to show in the alert.
|
|
987
|
-
* @param {
|
|
995
|
+
* @param {Object} options
|
|
988
996
|
*/
|
|
989
997
|
setAlert(type, message, options) {
|
|
990
998
|
if (!type && this.submitted) {
|
|
991
999
|
if (this.alert) {
|
|
992
1000
|
if (this.refs.errorRef && this.refs.errorRef.length) {
|
|
993
|
-
this.refs.errorRef.forEach(
|
|
994
|
-
this.removeEventListener(el,
|
|
995
|
-
this.removeEventListener(el,
|
|
1001
|
+
this.refs.errorRef.forEach(el => {
|
|
1002
|
+
this.removeEventListener(el, 'click');
|
|
1003
|
+
this.removeEventListener(el, 'keypress');
|
|
996
1004
|
});
|
|
997
1005
|
}
|
|
998
1006
|
this.removeChild(this.alert);
|
|
@@ -1002,16 +1010,16 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1002
1010
|
}
|
|
1003
1011
|
if (this.options.noAlerts) {
|
|
1004
1012
|
if (!message) {
|
|
1005
|
-
this.emit(
|
|
1013
|
+
this.emit('error', false);
|
|
1006
1014
|
}
|
|
1007
1015
|
return;
|
|
1008
1016
|
}
|
|
1009
1017
|
if (this.alert) {
|
|
1010
1018
|
try {
|
|
1011
1019
|
if (this.refs.errorRef && this.refs.errorRef.length) {
|
|
1012
|
-
this.refs.errorRef.forEach(
|
|
1013
|
-
this.removeEventListener(el,
|
|
1014
|
-
this.removeEventListener(el,
|
|
1020
|
+
this.refs.errorRef.forEach(el => {
|
|
1021
|
+
this.removeEventListener(el, 'click');
|
|
1022
|
+
this.removeEventListener(el, 'keypress');
|
|
1015
1023
|
});
|
|
1016
1024
|
}
|
|
1017
1025
|
this.removeChild(this.alert);
|
|
@@ -1029,21 +1037,21 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1029
1037
|
const templateOptions = {
|
|
1030
1038
|
message: message instanceof HTMLElement ? message.outerHTML : message,
|
|
1031
1039
|
attrs: attrs,
|
|
1032
|
-
type
|
|
1040
|
+
type
|
|
1033
1041
|
};
|
|
1034
|
-
this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate(
|
|
1042
|
+
this.alert = (0, utils_1.convertStringToHTMLElement)(this.renderTemplate('alert', templateOptions), `#${attrs.id}`);
|
|
1035
1043
|
}
|
|
1036
1044
|
if (!this.alert) {
|
|
1037
1045
|
return;
|
|
1038
1046
|
}
|
|
1039
|
-
this.loadRefs(this.alert, { errorRef:
|
|
1047
|
+
this.loadRefs(this.alert, { errorRef: 'multiple' });
|
|
1040
1048
|
if (this.refs.errorRef && this.refs.errorRef.length) {
|
|
1041
|
-
this.refs.errorRef.forEach(
|
|
1042
|
-
this.addEventListener(el,
|
|
1049
|
+
this.refs.errorRef.forEach(el => {
|
|
1050
|
+
this.addEventListener(el, 'click', (e) => {
|
|
1043
1051
|
const key = e.currentTarget.dataset.componentKey;
|
|
1044
1052
|
this.focusOnComponent(key);
|
|
1045
1053
|
});
|
|
1046
|
-
this.addEventListener(el,
|
|
1054
|
+
this.addEventListener(el, 'keydown', (e) => {
|
|
1047
1055
|
if (e.keyCode === 13) {
|
|
1048
1056
|
e.preventDefault();
|
|
1049
1057
|
const key = e.currentTarget.dataset.componentKey;
|
|
@@ -1056,7 +1064,9 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1056
1064
|
}
|
|
1057
1065
|
/**
|
|
1058
1066
|
* Focus on selected component.
|
|
1067
|
+
*
|
|
1059
1068
|
* @param {string} key - The key of selected component.
|
|
1069
|
+
* @returns {*}
|
|
1060
1070
|
*/
|
|
1061
1071
|
focusOnComponent(key) {
|
|
1062
1072
|
if (key) {
|
|
@@ -1068,16 +1078,11 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1068
1078
|
}
|
|
1069
1079
|
/**
|
|
1070
1080
|
* Show the errors of this form within the alert dialog.
|
|
1071
|
-
*
|
|
1081
|
+
*
|
|
1082
|
+
* @param {Object} error - An optional additional error to display along with the component errors.
|
|
1072
1083
|
* @returns {*}
|
|
1073
1084
|
*/
|
|
1074
1085
|
/* eslint-disable no-unused-vars */
|
|
1075
|
-
/**
|
|
1076
|
-
*
|
|
1077
|
-
* @param {Array} errors - An array of errors to display.
|
|
1078
|
-
* @param {boolean} triggerEvent - Whether or not to trigger the error event.
|
|
1079
|
-
* @returns {void|Array} - The errors that were set.
|
|
1080
|
-
*/
|
|
1081
1086
|
showErrors(errors, triggerEvent) {
|
|
1082
1087
|
this.loading = false;
|
|
1083
1088
|
if (!Array.isArray(errors)) {
|
|
@@ -1114,47 +1119,43 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1114
1119
|
});
|
|
1115
1120
|
const displayedErrors = [];
|
|
1116
1121
|
if (errors.length) {
|
|
1117
|
-
errors = lodash_1.default.uniqBy(errors,
|
|
1122
|
+
errors = lodash_1.default.uniqBy(errors, error => error.message);
|
|
1118
1123
|
const createListItem = (message, index) => {
|
|
1119
1124
|
var _a, _b, _c;
|
|
1120
1125
|
const err = errors[index];
|
|
1121
1126
|
const messageFromIndex = !lodash_1.default.isUndefined(index) && errors && errors[index];
|
|
1122
|
-
const keyOrPath = (messageFromIndex === null || messageFromIndex === void 0 ? void 0 : messageFromIndex.formattedKeyOrPath) ||
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
(((_b = err.context) === null || _b === void 0 ? void 0 : _b.component) && ((_c = err.context) === null || _c === void 0 ? void 0 : _c.component.key)) ||
|
|
1126
|
-
(err.component && err.component.key) ||
|
|
1127
|
-
(err.fromServer && err.path);
|
|
1128
|
-
const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : "";
|
|
1129
|
-
if (typeof err !== "string" && !err.formattedKeyOrPath) {
|
|
1127
|
+
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;
|
|
1128
|
+
const formattedKeyOrPath = keyOrPath ? (0, utils_1.getStringFromComponentPath)(keyOrPath) : '';
|
|
1129
|
+
if (typeof err !== 'string' && !err.formattedKeyOrPath) {
|
|
1130
1130
|
err.formattedKeyOrPath = formattedKeyOrPath;
|
|
1131
1131
|
}
|
|
1132
1132
|
return {
|
|
1133
1133
|
message: (0, utils_1.unescapeHTML)(message),
|
|
1134
|
-
keyOrPath: formattedKeyOrPath
|
|
1134
|
+
keyOrPath: formattedKeyOrPath
|
|
1135
1135
|
};
|
|
1136
1136
|
};
|
|
1137
1137
|
errors.forEach(({ message, context, fromServer, component }, index) => {
|
|
1138
1138
|
const text = !(component === null || component === void 0 ? void 0 : component.label) || (context === null || context === void 0 ? void 0 : context.hasLabel) || fromServer
|
|
1139
|
-
? this.t(
|
|
1140
|
-
: this.t(
|
|
1139
|
+
? this.t('alertMessage', { message: this.t(message) })
|
|
1140
|
+
: this.t('alertMessageWithLabel', {
|
|
1141
1141
|
label: this.t(component === null || component === void 0 ? void 0 : component.label),
|
|
1142
1142
|
message: this.t(message),
|
|
1143
1143
|
});
|
|
1144
1144
|
displayedErrors.push(createListItem(text, index));
|
|
1145
1145
|
});
|
|
1146
1146
|
}
|
|
1147
|
-
const errorsList = this.renderTemplate(
|
|
1148
|
-
this.root.setAlert(
|
|
1147
|
+
const errorsList = this.renderTemplate('errorsList', { errors: displayedErrors });
|
|
1148
|
+
this.root.setAlert('danger', errorsList);
|
|
1149
1149
|
if (triggerEvent) {
|
|
1150
|
-
this.emit(
|
|
1150
|
+
this.emit('error', errors);
|
|
1151
1151
|
}
|
|
1152
1152
|
return errors;
|
|
1153
1153
|
}
|
|
1154
1154
|
/* eslint-enable no-unused-vars */
|
|
1155
1155
|
/**
|
|
1156
1156
|
* Called when the submission has completed, or if the submission needs to be sent to an external library.
|
|
1157
|
-
*
|
|
1157
|
+
*
|
|
1158
|
+
* @param {Object} submission - The submission object.
|
|
1158
1159
|
* @param {boolean} saved - Whether or not this submission was saved to the server.
|
|
1159
1160
|
* @returns {object} - The submission object.
|
|
1160
1161
|
*/
|
|
@@ -1166,25 +1167,25 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1166
1167
|
// We want to return the submitted submission and setValue will mutate the submission so cloneDeep it here.
|
|
1167
1168
|
this.setValue((0, utils_1.fastCloneDeep)(submission), {
|
|
1168
1169
|
noValidate: true,
|
|
1169
|
-
noCheck: true
|
|
1170
|
+
noCheck: true
|
|
1170
1171
|
});
|
|
1171
|
-
this.setAlert(
|
|
1172
|
+
this.setAlert('success', `<p>${this.t('complete')}</p>`);
|
|
1172
1173
|
// Cancel triggered saveDraft to prevent overriding the submitted state
|
|
1173
1174
|
if (this.draftEnabled && ((_a = this.triggerSaveDraft) === null || _a === void 0 ? void 0 : _a.cancel)) {
|
|
1174
1175
|
this.triggerSaveDraft.cancel();
|
|
1175
1176
|
}
|
|
1176
|
-
this.emit(
|
|
1177
|
+
this.emit('submit', submission, saved);
|
|
1177
1178
|
if (saved) {
|
|
1178
|
-
this.emit(
|
|
1179
|
+
this.emit('submitDone', submission);
|
|
1179
1180
|
}
|
|
1180
1181
|
return submission;
|
|
1181
1182
|
}
|
|
1182
1183
|
normalizeError(error) {
|
|
1183
1184
|
if (error) {
|
|
1184
|
-
if (typeof error ===
|
|
1185
|
+
if (typeof error === 'object' && 'details' in error) {
|
|
1185
1186
|
error = error.details;
|
|
1186
1187
|
}
|
|
1187
|
-
if (typeof error ===
|
|
1188
|
+
if (typeof error === 'string') {
|
|
1188
1189
|
error = { message: error };
|
|
1189
1190
|
}
|
|
1190
1191
|
}
|
|
@@ -1192,17 +1193,17 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1192
1193
|
}
|
|
1193
1194
|
/**
|
|
1194
1195
|
* Called when an error occurs during the submission.
|
|
1195
|
-
*
|
|
1196
|
-
* @
|
|
1196
|
+
*
|
|
1197
|
+
* @param {Object} error - The error that occured.
|
|
1197
1198
|
*/
|
|
1198
1199
|
onSubmissionError(error) {
|
|
1199
1200
|
error = this.normalizeError(error);
|
|
1200
1201
|
this.submitting = false;
|
|
1201
1202
|
this.setPristine(false);
|
|
1202
|
-
this.emit(
|
|
1203
|
+
this.emit('submitError', error || this.errors);
|
|
1203
1204
|
// Allow for silent cancellations (no error message, no submit button error state)
|
|
1204
1205
|
if (error && error.silent) {
|
|
1205
|
-
this.emit(
|
|
1206
|
+
this.emit('change', { isValid: true }, { silent: true });
|
|
1206
1207
|
return false;
|
|
1207
1208
|
}
|
|
1208
1209
|
const errors = this.showErrors(error, true);
|
|
@@ -1213,10 +1214,9 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1213
1214
|
}
|
|
1214
1215
|
/**
|
|
1215
1216
|
* Trigger the change event for this form.
|
|
1216
|
-
*
|
|
1217
|
-
* @param
|
|
1218
|
-
* @param
|
|
1219
|
-
* @param {any} changes - The changes that have occured in the form.
|
|
1217
|
+
*
|
|
1218
|
+
* @param changed
|
|
1219
|
+
* @param flags
|
|
1220
1220
|
*/
|
|
1221
1221
|
onChange(flags, changed, modified, changes) {
|
|
1222
1222
|
flags = flags || {};
|
|
@@ -1229,17 +1229,13 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1229
1229
|
this.pristine = false;
|
|
1230
1230
|
}
|
|
1231
1231
|
this.checkData(value.data, flags);
|
|
1232
|
-
const shouldValidate = !flags.noValidate ||
|
|
1233
|
-
|
|
1234
|
-
(flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
|
|
1235
|
-
const errors = shouldValidate
|
|
1236
|
-
? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: "change" }))
|
|
1237
|
-
: [];
|
|
1232
|
+
const shouldValidate = !flags.noValidate || flags.fromIFrame || (flags.fromSubmission && this.rootPristine && this.pristine && flags.changed);
|
|
1233
|
+
const errors = shouldValidate ? this.validate(value.data, Object.assign(Object.assign({}, flags), { process: 'change' })) : [];
|
|
1238
1234
|
value.isValid = errors.length === 0;
|
|
1239
1235
|
this.loading = false;
|
|
1240
1236
|
if (this.submitted) {
|
|
1241
1237
|
// show server errors while they are not cleaned/fixed
|
|
1242
|
-
const nonComponentServerErrors = lodash_1.default.filter(this.serverErrors || [],
|
|
1238
|
+
const nonComponentServerErrors = lodash_1.default.filter(this.serverErrors || [], err => !err.component && !err.path);
|
|
1243
1239
|
this.showErrors(nonComponentServerErrors.length ? nonComponentServerErrors : errors);
|
|
1244
1240
|
}
|
|
1245
1241
|
// See if we need to save the draft of the form.
|
|
@@ -1247,39 +1243,38 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1247
1243
|
this.triggerSaveDraft();
|
|
1248
1244
|
}
|
|
1249
1245
|
if (!flags || !flags.noEmit) {
|
|
1250
|
-
this.emit(
|
|
1246
|
+
this.emit('change', value, flags, modified);
|
|
1251
1247
|
isChangeEventEmitted = true;
|
|
1252
1248
|
}
|
|
1253
1249
|
// The form is initialized after the first change event occurs.
|
|
1254
1250
|
if (isChangeEventEmitted && !this.initialized) {
|
|
1255
|
-
this.emit(
|
|
1251
|
+
this.emit('initialized');
|
|
1256
1252
|
this.initialized = true;
|
|
1257
1253
|
}
|
|
1258
1254
|
}
|
|
1259
1255
|
/**
|
|
1260
1256
|
* Send a delete request to the server.
|
|
1261
|
-
* @returns {Promise} - The promise that is triggered when the delete is complete.
|
|
1262
1257
|
*/
|
|
1263
1258
|
deleteSubmission() {
|
|
1264
|
-
return this.formio.deleteSubmission()
|
|
1265
|
-
|
|
1259
|
+
return this.formio.deleteSubmission()
|
|
1260
|
+
.then(() => {
|
|
1261
|
+
this.emit('submissionDeleted', this.submission);
|
|
1266
1262
|
this.resetValue();
|
|
1267
1263
|
});
|
|
1268
1264
|
}
|
|
1269
1265
|
/**
|
|
1270
1266
|
* Cancels the submission.
|
|
1271
|
-
*
|
|
1267
|
+
*
|
|
1272
1268
|
* @alias reset
|
|
1273
|
-
* @returns {boolean} - TRUE means the submission was cancelled, FALSE otherwise.
|
|
1274
1269
|
*/
|
|
1275
1270
|
cancel(noconfirm) {
|
|
1276
|
-
const shouldReset = this.hook(
|
|
1277
|
-
if (shouldReset && (noconfirm || confirm(this.t(
|
|
1271
|
+
const shouldReset = this.hook('beforeCancel', true);
|
|
1272
|
+
if (shouldReset && (noconfirm || confirm(this.t('confirmCancel')))) {
|
|
1278
1273
|
this.resetValue();
|
|
1279
1274
|
return true;
|
|
1280
1275
|
}
|
|
1281
1276
|
else {
|
|
1282
|
-
this.emit(
|
|
1277
|
+
this.emit('cancelSubmit');
|
|
1283
1278
|
return false;
|
|
1284
1279
|
}
|
|
1285
1280
|
}
|
|
@@ -1287,14 +1282,14 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1287
1282
|
// Add in metadata about client submitting the form
|
|
1288
1283
|
submission.metadata = submission.metadata || {};
|
|
1289
1284
|
lodash_1.default.defaults(submission.metadata, {
|
|
1290
|
-
timezone: lodash_1.default.get(this,
|
|
1291
|
-
offset: parseInt(lodash_1.default.get(this,
|
|
1285
|
+
timezone: lodash_1.default.get(this, '_submission.metadata.timezone', (0, utils_1.currentTimezone)()),
|
|
1286
|
+
offset: parseInt(lodash_1.default.get(this, '_submission.metadata.offset', (0, moment_1.default)().utcOffset()), 10),
|
|
1292
1287
|
origin: document.location.origin,
|
|
1293
1288
|
referrer: document.referrer,
|
|
1294
1289
|
browserName: navigator.appName,
|
|
1295
1290
|
userAgent: navigator.userAgent,
|
|
1296
1291
|
pathName: window.location.pathname,
|
|
1297
|
-
onLine: navigator.onLine
|
|
1292
|
+
onLine: navigator.onLine
|
|
1298
1293
|
});
|
|
1299
1294
|
}
|
|
1300
1295
|
submitForm(options = {}) {
|
|
@@ -1304,31 +1299,30 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1304
1299
|
if (this.options.readOnly) {
|
|
1305
1300
|
return resolve({
|
|
1306
1301
|
submission: this.submission,
|
|
1307
|
-
saved: false
|
|
1302
|
+
saved: false
|
|
1308
1303
|
});
|
|
1309
1304
|
}
|
|
1310
1305
|
const submission = (0, utils_1.fastCloneDeep)(this.submission || {});
|
|
1311
1306
|
this.setMetadata(submission);
|
|
1312
|
-
submission.state = options.state || submission.state ||
|
|
1313
|
-
const isDraft = submission.state ===
|
|
1314
|
-
this.hook(
|
|
1307
|
+
submission.state = options.state || submission.state || 'submitted';
|
|
1308
|
+
const isDraft = (submission.state === 'draft');
|
|
1309
|
+
this.hook('beforeSubmit', Object.assign(Object.assign({}, submission), { component: options.component }), (err, data) => {
|
|
1315
1310
|
var _a;
|
|
1316
1311
|
if (err) {
|
|
1317
1312
|
return reject(err);
|
|
1318
1313
|
}
|
|
1319
|
-
submission._vnote = data && data._vnote ? data._vnote :
|
|
1314
|
+
submission._vnote = data && data._vnote ? data._vnote : '';
|
|
1320
1315
|
try {
|
|
1321
1316
|
if (!isDraft && !options.noValidate) {
|
|
1322
1317
|
if (!submission.data) {
|
|
1323
|
-
return reject(
|
|
1318
|
+
return reject('Invalid Submission');
|
|
1324
1319
|
}
|
|
1325
1320
|
const errors = this.validate(submission.data, {
|
|
1326
1321
|
dirty: true,
|
|
1327
1322
|
silentCheck: false,
|
|
1328
|
-
process:
|
|
1323
|
+
process: 'submit'
|
|
1329
1324
|
});
|
|
1330
|
-
if (errors.length ||
|
|
1331
|
-
((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === "rejected"))) {
|
|
1325
|
+
if (errors.length || ((_a = options.beforeSubmitResults) === null || _a === void 0 ? void 0 : _a.some((result) => result.status === 'rejected'))) {
|
|
1332
1326
|
return reject(errors);
|
|
1333
1327
|
}
|
|
1334
1328
|
}
|
|
@@ -1337,20 +1331,20 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1337
1331
|
console.error(err);
|
|
1338
1332
|
}
|
|
1339
1333
|
this.everyComponent((comp) => {
|
|
1340
|
-
if (submission._vnote && comp.type ===
|
|
1334
|
+
if (submission._vnote && comp.type === 'form' && comp.component.reference) {
|
|
1341
1335
|
lodash_1.default.get(submission.data, comp.path, {})._vnote = submission._vnote;
|
|
1342
1336
|
}
|
|
1343
1337
|
const { persistent } = comp.component;
|
|
1344
|
-
if (persistent ===
|
|
1338
|
+
if (persistent === 'client-only') {
|
|
1345
1339
|
lodash_1.default.unset(submission.data, comp.path);
|
|
1346
1340
|
}
|
|
1347
1341
|
});
|
|
1348
|
-
this.hook(
|
|
1342
|
+
this.hook('customValidation', Object.assign(Object.assign({}, submission), { component: options.component }), (err) => {
|
|
1349
1343
|
if (err) {
|
|
1350
1344
|
// If string is returned, cast to object.
|
|
1351
|
-
if (typeof err ===
|
|
1345
|
+
if (typeof err === 'string') {
|
|
1352
1346
|
err = {
|
|
1353
|
-
message: err
|
|
1347
|
+
message: err
|
|
1354
1348
|
};
|
|
1355
1349
|
}
|
|
1356
1350
|
// Ensure err is an array.
|
|
@@ -1360,10 +1354,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1360
1354
|
this.loading = true;
|
|
1361
1355
|
// Use the form action to submit the form if available.
|
|
1362
1356
|
if (this._form && this._form.action) {
|
|
1363
|
-
const method = submission.data._id &&
|
|
1364
|
-
this._form.action.includes(submission.data._id)
|
|
1365
|
-
? "PUT"
|
|
1366
|
-
: "POST";
|
|
1357
|
+
const method = (submission.data._id && this._form.action.includes(submission.data._id)) ? 'PUT' : 'POST';
|
|
1367
1358
|
return Formio_1.Formio.makeStaticRequest(this._form.action, method, submission, this.formio ? this.formio.options : {})
|
|
1368
1359
|
.then((result) => resolve({
|
|
1369
1360
|
submission: result,
|
|
@@ -1382,9 +1373,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1382
1373
|
});
|
|
1383
1374
|
}
|
|
1384
1375
|
// If this is an actionUrl, then make sure to save the action and not the submission.
|
|
1385
|
-
const submitMethod = submitFormio.actionUrl
|
|
1386
|
-
? "saveAction"
|
|
1387
|
-
: "saveSubmission";
|
|
1376
|
+
const submitMethod = submitFormio.actionUrl ? 'saveAction' : 'saveSubmission';
|
|
1388
1377
|
submitFormio[submitMethod](submission)
|
|
1389
1378
|
.then((result) => resolve({
|
|
1390
1379
|
submission: result,
|
|
@@ -1400,15 +1389,13 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1400
1389
|
}
|
|
1401
1390
|
setServerErrors(error) {
|
|
1402
1391
|
if (error.details) {
|
|
1403
|
-
this.serverErrors = error.details
|
|
1404
|
-
.filter((err) => (err.level ? err.level === "error" : err))
|
|
1405
|
-
.map((err) => {
|
|
1392
|
+
this.serverErrors = error.details.filter((err) => err.level ? err.level === 'error' : err).map((err) => {
|
|
1406
1393
|
err.fromServer = true;
|
|
1407
1394
|
return err;
|
|
1408
1395
|
});
|
|
1409
1396
|
}
|
|
1410
|
-
else if (typeof error ===
|
|
1411
|
-
this.serverErrors = [{ fromServer: true, level:
|
|
1397
|
+
else if (typeof error === 'string') {
|
|
1398
|
+
this.serverErrors = [{ fromServer: true, level: 'error', message: error }];
|
|
1412
1399
|
}
|
|
1413
1400
|
}
|
|
1414
1401
|
executeSubmit(options) {
|
|
@@ -1440,6 +1427,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1440
1427
|
}
|
|
1441
1428
|
/**
|
|
1442
1429
|
* Submits the form.
|
|
1430
|
+
*
|
|
1443
1431
|
* @example
|
|
1444
1432
|
* import Webform from '@formio/js/Webform';
|
|
1445
1433
|
* let form = new Webform(document.getElementById('formio'));
|
|
@@ -1452,11 +1440,12 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1452
1440
|
* form.submit().then((submission) => {
|
|
1453
1441
|
* console.log(submission);
|
|
1454
1442
|
* });
|
|
1443
|
+
*
|
|
1455
1444
|
* @param {boolean} before - If this submission occured from the before handlers.
|
|
1456
|
-
*
|
|
1445
|
+
*
|
|
1457
1446
|
* @returns {Promise} - A promise when the form is done submitting.
|
|
1458
1447
|
*/
|
|
1459
|
-
submit(before
|
|
1448
|
+
submit(before, options = {}) {
|
|
1460
1449
|
this.submissionInProcess = true;
|
|
1461
1450
|
if (!before) {
|
|
1462
1451
|
return this.beforeSubmit(options).then(() => this.executeSubmit(options));
|
|
@@ -1467,41 +1456,37 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1467
1456
|
}
|
|
1468
1457
|
submitUrl(URL, headers) {
|
|
1469
1458
|
if (!URL) {
|
|
1470
|
-
return console.warn(
|
|
1459
|
+
return console.warn('Missing URL argument');
|
|
1471
1460
|
}
|
|
1472
1461
|
const submission = this.submission || {};
|
|
1473
1462
|
const API_URL = URL;
|
|
1474
1463
|
const settings = {
|
|
1475
|
-
method:
|
|
1476
|
-
headers: {}
|
|
1464
|
+
method: 'POST',
|
|
1465
|
+
headers: {}
|
|
1477
1466
|
};
|
|
1478
1467
|
if (headers && headers.length > 0) {
|
|
1479
1468
|
headers.map((e) => {
|
|
1480
|
-
if (e.header !==
|
|
1469
|
+
if (e.header !== '' && e.value !== '') {
|
|
1481
1470
|
settings.headers[e.header] = this.interpolate(e.value, submission);
|
|
1482
1471
|
}
|
|
1483
1472
|
});
|
|
1484
1473
|
}
|
|
1485
1474
|
if (API_URL && settings) {
|
|
1486
|
-
Formio_1.Formio.makeStaticRequest(API_URL, settings.method, submission, {
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
this.
|
|
1492
|
-
})
|
|
1493
|
-
.catch((e) => {
|
|
1494
|
-
const message = `${e.statusText ? e.statusText : ""} ${e.status ? e.status : e}`;
|
|
1495
|
-
this.emit("error", message);
|
|
1475
|
+
Formio_1.Formio.makeStaticRequest(API_URL, settings.method, submission, { headers: settings.headers }).then(() => {
|
|
1476
|
+
this.emit('requestDone');
|
|
1477
|
+
this.setAlert('success', '<p> Success </p>');
|
|
1478
|
+
}).catch((e) => {
|
|
1479
|
+
const message = `${e.statusText ? e.statusText : ''} ${e.status ? e.status : e}`;
|
|
1480
|
+
this.emit('error', message);
|
|
1496
1481
|
console.error(message);
|
|
1497
|
-
this.setAlert(
|
|
1482
|
+
this.setAlert('danger', `<p> ${message} </p>`);
|
|
1498
1483
|
return Promise.reject(this.onSubmissionError(e));
|
|
1499
1484
|
});
|
|
1500
1485
|
}
|
|
1501
1486
|
else {
|
|
1502
|
-
this.emit(
|
|
1503
|
-
this.setAlert(
|
|
1504
|
-
return console.warn(
|
|
1487
|
+
this.emit('error', 'You should add a URL to this button.');
|
|
1488
|
+
this.setAlert('warning', 'You should add a URL to this button.');
|
|
1489
|
+
return console.warn('You should add a URL to this button.');
|
|
1505
1490
|
}
|
|
1506
1491
|
}
|
|
1507
1492
|
triggerRecaptcha() {
|
|
@@ -1509,16 +1494,16 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
1509
1494
|
return;
|
|
1510
1495
|
}
|
|
1511
1496
|
const recaptchaComponent = (0, utils_1.searchComponents)(this.components, {
|
|
1512
|
-
|
|
1513
|
-
|
|
1497
|
+
'component.type': 'recaptcha',
|
|
1498
|
+
'component.eventType': 'formLoad'
|
|
1514
1499
|
});
|
|
1515
1500
|
if (recaptchaComponent.length > 0) {
|
|
1516
|
-
recaptchaComponent[0].verify(`${this.form.name ? this.form.name :
|
|
1501
|
+
recaptchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
|
|
1517
1502
|
}
|
|
1518
1503
|
}
|
|
1519
1504
|
set nosubmit(value) {
|
|
1520
1505
|
this._nosubmit = !!value;
|
|
1521
|
-
this.emit(
|
|
1506
|
+
this.emit('nosubmit', this._nosubmit);
|
|
1522
1507
|
}
|
|
1523
1508
|
get nosubmit() {
|
|
1524
1509
|
return this._nosubmit || false;
|