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