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