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