@formio/js 5.0.0-dev.5641.d9ab3df → 5.0.0-dev.5642.afd813e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +0 -37
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +1189 -608
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +5 -3
- package/dist/formio.full.js +913 -652
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +5 -3
- package/dist/formio.js +18 -18
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +494 -1831
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +4 -10
- package/lib/cjs/CDN.d.ts +0 -1
- package/lib/cjs/CDN.js +3 -6
- package/lib/cjs/Element.d.ts +96 -86
- package/lib/cjs/Element.js +78 -68
- package/lib/cjs/Embed.d.ts +1 -1
- package/lib/cjs/Embed.js +12 -52
- package/lib/cjs/Form.d.ts +36 -365
- package/lib/cjs/Form.js +64 -50
- package/lib/cjs/FormBuilder.d.ts +2 -187
- package/lib/cjs/FormBuilder.js +8 -30
- package/lib/cjs/PDF.d.ts +13 -11
- package/lib/cjs/PDF.js +8 -6
- package/lib/cjs/Webform.d.ts +139 -180
- package/lib/cjs/Webform.js +296 -309
- package/lib/cjs/WebformBuilder.d.ts +14 -16
- package/lib/cjs/WebformBuilder.js +10 -11
- package/lib/cjs/Wizard.d.ts +21 -31
- package/lib/cjs/Wizard.js +20 -43
- package/lib/cjs/WizardBuilder.d.ts +1 -1
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +5 -8
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -6
- package/lib/cjs/components/Components.d.ts +4 -4
- package/lib/cjs/components/Components.js +3 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +269 -502
- package/lib/cjs/components/_classes/component/Component.form.d.ts +3 -6
- package/lib/cjs/components/_classes/component/Component.form.js +0 -5
- package/lib/cjs/components/_classes/component/Component.js +189 -433
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +2 -2
- package/lib/cjs/components/_classes/component/editForm/utils.js +2 -2
- package/lib/cjs/components/_classes/field/Field.d.ts +2 -11
- package/lib/cjs/components/_classes/field/Field.js +1 -13
- package/lib/cjs/components/_classes/input/Input.d.ts +3 -4
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.form.d.ts +3 -6
- package/lib/cjs/components/_classes/list/ListComponent.form.js +0 -5
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +12 -43
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +3 -37
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +67 -163
- package/lib/cjs/components/_classes/nested/NestedComponent.form.d.ts +3 -6
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +0 -5
- package/lib/cjs/components/_classes/nested/NestedComponent.js +54 -175
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -7
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +3 -2
- package/lib/cjs/components/address/Address.d.ts +2 -4
- package/lib/cjs/components/address/Address.form.d.ts +3 -6
- package/lib/cjs/components/address/Address.form.js +0 -5
- package/lib/cjs/components/button/Button.d.ts +12 -3
- package/lib/cjs/components/button/Button.form.d.ts +3 -6
- package/lib/cjs/components/button/Button.form.js +0 -5
- package/lib/cjs/components/button/Button.js +0 -5
- package/lib/cjs/components/checkbox/Checkbox.d.ts +27 -4
- package/lib/cjs/components/checkbox/Checkbox.form.d.ts +3 -6
- package/lib/cjs/components/checkbox/Checkbox.form.js +0 -5
- package/lib/cjs/components/columns/Columns.d.ts +2 -3
- package/lib/cjs/components/columns/Columns.form.d.ts +3 -6
- package/lib/cjs/components/columns/Columns.form.js +0 -5
- package/lib/cjs/components/columns/Columns.js +1 -1
- package/lib/cjs/components/container/Container.form.d.ts +3 -6
- package/lib/cjs/components/container/Container.form.js +0 -5
- package/lib/cjs/components/content/Content.d.ts +1 -2
- package/lib/cjs/components/content/Content.form.d.ts +3 -6
- package/lib/cjs/components/content/Content.form.js +0 -5
- package/lib/cjs/components/currency/Currency.form.d.ts +3 -6
- package/lib/cjs/components/currency/Currency.form.js +0 -5
- package/lib/cjs/components/currency/Currency.js +2 -1
- package/lib/cjs/components/datagrid/DataGrid.d.ts +7 -8
- package/lib/cjs/components/datagrid/DataGrid.form.d.ts +3 -6
- package/lib/cjs/components/datagrid/DataGrid.form.js +0 -5
- package/lib/cjs/components/datagrid/DataGrid.js +5 -5
- package/lib/cjs/components/datamap/DataMap.d.ts +0 -1
- package/lib/cjs/components/datamap/DataMap.form.d.ts +3 -6
- package/lib/cjs/components/datamap/DataMap.form.js +0 -5
- package/lib/cjs/components/datetime/DateTime.d.ts +14 -0
- package/lib/cjs/components/datetime/DateTime.form.d.ts +3 -6
- package/lib/cjs/components/datetime/DateTime.form.js +0 -5
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +2 -2
- package/lib/cjs/components/day/Day.d.ts +48 -22
- package/lib/cjs/components/day/Day.form.d.ts +3 -6
- package/lib/cjs/components/day/Day.form.js +0 -5
- package/lib/cjs/components/day/Day.js +20 -15
- package/lib/cjs/components/editgrid/EditGrid.d.ts +3 -7
- package/lib/cjs/components/editgrid/EditGrid.form.d.ts +3 -6
- package/lib/cjs/components/editgrid/EditGrid.form.js +0 -5
- package/lib/cjs/components/editgrid/EditGrid.js +3 -3
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +5 -2
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.js +9 -6
- package/lib/cjs/components/email/Email.form.d.ts +3 -6
- package/lib/cjs/components/email/Email.form.js +0 -5
- package/lib/cjs/components/fieldset/Fieldset.form.d.ts +3 -6
- package/lib/cjs/components/fieldset/Fieldset.form.js +0 -5
- package/lib/cjs/components/file/File.d.ts +22 -9
- package/lib/cjs/components/file/File.form.d.ts +3 -6
- package/lib/cjs/components/file/File.form.js +0 -5
- package/lib/cjs/components/file/File.js +1 -2
- package/lib/cjs/components/form/Form.d.ts +20 -31
- package/lib/cjs/components/form/Form.form.d.ts +3 -6
- package/lib/cjs/components/form/Form.form.js +0 -5
- package/lib/cjs/components/form/Form.js +14 -17
- package/lib/cjs/components/hidden/Hidden.d.ts +11 -1
- package/lib/cjs/components/hidden/Hidden.form.d.ts +3 -6
- package/lib/cjs/components/hidden/Hidden.form.js +0 -5
- package/lib/cjs/components/hidden/Hidden.js +2 -1
- package/lib/cjs/components/html/HTML.d.ts +1 -2
- package/lib/cjs/components/html/HTML.form.d.ts +3 -6
- package/lib/cjs/components/html/HTML.form.js +0 -5
- package/lib/cjs/components/number/Number.d.ts +17 -3
- package/lib/cjs/components/number/Number.form.d.ts +3 -6
- package/lib/cjs/components/number/Number.form.js +0 -5
- package/lib/cjs/components/number/Number.js +2 -1
- package/lib/cjs/components/panel/Panel.form.d.ts +3 -6
- package/lib/cjs/components/panel/Panel.form.js +0 -5
- package/lib/cjs/components/panel/Panel.js +1 -0
- package/lib/cjs/components/password/Password.form.d.ts +3 -6
- package/lib/cjs/components/password/Password.form.js +0 -5
- package/lib/cjs/components/phonenumber/PhoneNumber.form.d.ts +3 -6
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +0 -5
- package/lib/cjs/components/radio/Radio.d.ts +26 -3
- package/lib/cjs/components/radio/Radio.form.d.ts +3 -6
- package/lib/cjs/components/radio/Radio.form.js +0 -5
- package/lib/cjs/components/radio/Radio.js +4 -3
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +3 -6
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +0 -5
- package/lib/cjs/components/select/Select.d.ts +39 -16
- package/lib/cjs/components/select/Select.form.d.ts +3 -6
- package/lib/cjs/components/select/Select.form.js +0 -5
- package/lib/cjs/components/select/Select.js +16 -13
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +17 -2
- package/lib/cjs/components/selectboxes/SelectBoxes.form.d.ts +3 -6
- package/lib/cjs/components/selectboxes/SelectBoxes.form.js +0 -5
- package/lib/cjs/components/selectboxes/SelectBoxes.js +9 -7
- package/lib/cjs/components/signature/Signature.d.ts +14 -1
- package/lib/cjs/components/signature/Signature.form.d.ts +3 -6
- package/lib/cjs/components/signature/Signature.form.js +0 -5
- package/lib/cjs/components/survey/Survey.d.ts +15 -3
- package/lib/cjs/components/survey/Survey.form.d.ts +3 -6
- package/lib/cjs/components/survey/Survey.form.js +0 -5
- package/lib/cjs/components/table/Table.d.ts +1 -2
- package/lib/cjs/components/table/Table.form.d.ts +3 -6
- package/lib/cjs/components/table/Table.form.js +0 -5
- package/lib/cjs/components/tabs/Tabs.d.ts +4 -4
- package/lib/cjs/components/tabs/Tabs.form.d.ts +3 -6
- package/lib/cjs/components/tabs/Tabs.form.js +0 -5
- package/lib/cjs/components/tabs/Tabs.js +2 -1
- package/lib/cjs/components/tags/Tags.d.ts +14 -0
- package/lib/cjs/components/tags/Tags.form.d.ts +3 -6
- package/lib/cjs/components/tags/Tags.form.js +0 -5
- package/lib/cjs/components/textarea/TextArea.d.ts +9 -4
- package/lib/cjs/components/textarea/TextArea.form.d.ts +3 -6
- package/lib/cjs/components/textarea/TextArea.form.js +0 -5
- package/lib/cjs/components/textarea/TextArea.js +2 -2
- package/lib/cjs/components/textfield/TextField.d.ts +30 -14
- package/lib/cjs/components/textfield/TextField.form.d.ts +3 -6
- package/lib/cjs/components/textfield/TextField.form.js +0 -5
- package/lib/cjs/components/textfield/TextField.js +17 -16
- package/lib/cjs/components/time/Time.form.d.ts +3 -6
- package/lib/cjs/components/time/Time.form.js +0 -5
- package/lib/cjs/components/unknown/Unknown.form.d.ts +34 -5
- package/lib/cjs/components/unknown/Unknown.form.js +0 -4
- package/lib/cjs/components/url/Url.form.d.ts +3 -6
- package/lib/cjs/components/url/Url.form.js +0 -5
- package/lib/cjs/components/well/Well.form.d.ts +3 -6
- package/lib/cjs/components/well/Well.form.js +0 -5
- package/lib/cjs/formio.embed.d.ts +2 -1
- package/lib/cjs/formio.embed.js +100 -2
- package/lib/cjs/formio.form.d.ts +4 -11
- package/lib/cjs/formio.form.js +5 -13
- package/lib/cjs/providers/Providers.d.ts +5 -36
- package/lib/cjs/providers/Providers.js +0 -29
- package/lib/cjs/providers/address/AddressProvider.d.ts +12 -131
- package/lib/cjs/providers/address/AddressProvider.js +2 -88
- package/lib/cjs/providers/address/AzureAddressProvider.d.ts +1 -48
- package/lib/cjs/providers/address/AzureAddressProvider.js +0 -37
- package/lib/cjs/providers/address/CustomAddressProvider.d.ts +4 -27
- package/lib/cjs/providers/address/CustomAddressProvider.js +0 -34
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +6 -130
- package/lib/cjs/providers/address/GoogleAddressProvider.js +0 -72
- package/lib/cjs/providers/address/NominatimAddressProvider.d.ts +7 -32
- package/lib/cjs/providers/address/NominatimAddressProvider.js +0 -33
- package/lib/cjs/providers/address/index.d.ts +1 -3
- package/lib/cjs/providers/processor/fileProcessor.d.ts +1 -7
- package/lib/cjs/providers/processor/fileProcessor.js +0 -6
- package/lib/cjs/providers/storage/azure.d.ts +13 -6
- package/lib/cjs/providers/storage/azure.js +0 -5
- package/lib/cjs/providers/storage/base64.d.ts +6 -5
- package/lib/cjs/providers/storage/base64.js +0 -4
- package/lib/cjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/cjs/providers/storage/dropbox.js +0 -5
- package/lib/cjs/providers/storage/googleDrive.d.ts +5 -7
- package/lib/cjs/providers/storage/googleDrive.js +0 -6
- package/lib/cjs/providers/storage/indexeddb.d.ts +7 -5
- package/lib/cjs/providers/storage/indexeddb.js +0 -4
- package/lib/cjs/providers/storage/s3.d.ts +20 -6
- package/lib/cjs/providers/storage/s3.js +0 -5
- package/lib/cjs/providers/storage/url.d.ts +7 -6
- package/lib/cjs/providers/storage/url.js +0 -10
- package/lib/cjs/providers/storage/util.d.ts +1 -24
- package/lib/cjs/providers/storage/util.js +0 -18
- package/lib/cjs/templates/Templates.d.ts +0 -1
- package/lib/cjs/utils/Evaluator.d.ts +3 -6
- package/lib/cjs/utils/Evaluator.js +20 -11
- package/lib/cjs/utils/builder.d.ts +7 -9
- package/lib/cjs/utils/builder.js +5 -10
- package/lib/cjs/utils/calendarUtils.d.ts +13 -7
- package/lib/cjs/utils/calendarUtils.js +17 -10
- package/lib/cjs/utils/formUtils.d.ts +171 -43
- package/lib/cjs/utils/formUtils.js +569 -38
- package/lib/cjs/utils/utils.d.ts +221 -367
- package/lib/cjs/utils/utils.js +228 -335
- package/lib/cjs/widgets/CalendarWidget.d.ts +10 -9
- package/lib/cjs/widgets/CalendarWidget.js +11 -9
- package/lib/mjs/CDN.d.ts +0 -1
- package/lib/mjs/CDN.js +3 -6
- package/lib/mjs/Element.d.ts +96 -86
- package/lib/mjs/Element.js +78 -68
- package/lib/mjs/Embed.d.ts +1 -1
- package/lib/mjs/Embed.js +12 -52
- package/lib/mjs/Form.d.ts +36 -365
- package/lib/mjs/Form.js +57 -140
- package/lib/mjs/FormBuilder.d.ts +2 -187
- package/lib/mjs/FormBuilder.js +8 -32
- package/lib/mjs/PDF.d.ts +13 -11
- package/lib/mjs/PDF.js +8 -6
- package/lib/mjs/Webform.d.ts +139 -180
- package/lib/mjs/Webform.js +308 -321
- package/lib/mjs/WebformBuilder.d.ts +14 -16
- package/lib/mjs/WebformBuilder.js +10 -11
- package/lib/mjs/Wizard.d.ts +21 -31
- package/lib/mjs/Wizard.js +19 -42
- package/lib/mjs/WizardBuilder.d.ts +1 -1
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +5 -8
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -6
- package/lib/mjs/components/Components.d.ts +4 -4
- package/lib/mjs/components/Components.js +3 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +269 -502
- package/lib/mjs/components/_classes/component/Component.form.d.ts +3 -6
- package/lib/mjs/components/_classes/component/Component.form.js +0 -5
- package/lib/mjs/components/_classes/component/Component.js +189 -433
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/mjs/components/_classes/field/Field.d.ts +2 -11
- package/lib/mjs/components/_classes/field/Field.js +1 -13
- package/lib/mjs/components/_classes/input/Input.d.ts +3 -4
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.form.d.ts +3 -6
- package/lib/mjs/components/_classes/list/ListComponent.form.js +0 -5
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +12 -43
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +3 -37
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +67 -163
- package/lib/mjs/components/_classes/nested/NestedComponent.form.d.ts +3 -6
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +0 -5
- package/lib/mjs/components/_classes/nested/NestedComponent.js +54 -175
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -7
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +3 -2
- package/lib/mjs/components/address/Address.d.ts +2 -4
- package/lib/mjs/components/address/Address.form.d.ts +3 -6
- package/lib/mjs/components/address/Address.form.js +0 -5
- package/lib/mjs/components/button/Button.d.ts +12 -3
- package/lib/mjs/components/button/Button.form.d.ts +3 -6
- package/lib/mjs/components/button/Button.form.js +0 -5
- package/lib/mjs/components/button/Button.js +0 -5
- package/lib/mjs/components/checkbox/Checkbox.d.ts +27 -4
- package/lib/mjs/components/checkbox/Checkbox.form.d.ts +3 -6
- package/lib/mjs/components/checkbox/Checkbox.form.js +0 -5
- package/lib/mjs/components/columns/Columns.d.ts +2 -3
- package/lib/mjs/components/columns/Columns.form.d.ts +3 -6
- package/lib/mjs/components/columns/Columns.form.js +0 -5
- package/lib/mjs/components/columns/Columns.js +1 -1
- package/lib/mjs/components/container/Container.form.d.ts +3 -6
- package/lib/mjs/components/container/Container.form.js +0 -5
- package/lib/mjs/components/content/Content.d.ts +1 -2
- package/lib/mjs/components/content/Content.form.d.ts +3 -6
- package/lib/mjs/components/content/Content.form.js +0 -5
- package/lib/mjs/components/currency/Currency.form.d.ts +3 -6
- package/lib/mjs/components/currency/Currency.form.js +0 -5
- package/lib/mjs/components/currency/Currency.js +2 -1
- package/lib/mjs/components/datagrid/DataGrid.d.ts +7 -8
- package/lib/mjs/components/datagrid/DataGrid.form.d.ts +3 -6
- package/lib/mjs/components/datagrid/DataGrid.form.js +0 -5
- package/lib/mjs/components/datagrid/DataGrid.js +5 -5
- package/lib/mjs/components/datamap/DataMap.d.ts +0 -1
- package/lib/mjs/components/datamap/DataMap.form.d.ts +3 -6
- package/lib/mjs/components/datamap/DataMap.form.js +0 -5
- package/lib/mjs/components/datetime/DateTime.d.ts +14 -0
- package/lib/mjs/components/datetime/DateTime.form.d.ts +3 -6
- package/lib/mjs/components/datetime/DateTime.form.js +0 -5
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +1 -1
- package/lib/mjs/components/day/Day.d.ts +48 -22
- package/lib/mjs/components/day/Day.form.d.ts +3 -6
- package/lib/mjs/components/day/Day.form.js +0 -5
- package/lib/mjs/components/day/Day.js +20 -15
- package/lib/mjs/components/editgrid/EditGrid.d.ts +3 -7
- package/lib/mjs/components/editgrid/EditGrid.form.d.ts +3 -6
- package/lib/mjs/components/editgrid/EditGrid.form.js +0 -5
- package/lib/mjs/components/editgrid/EditGrid.js +3 -3
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +1 -1
- package/lib/mjs/components/email/Email.form.d.ts +3 -6
- package/lib/mjs/components/email/Email.form.js +0 -5
- package/lib/mjs/components/fieldset/Fieldset.form.d.ts +3 -6
- package/lib/mjs/components/fieldset/Fieldset.form.js +0 -5
- package/lib/mjs/components/file/File.d.ts +22 -9
- package/lib/mjs/components/file/File.form.d.ts +3 -6
- package/lib/mjs/components/file/File.form.js +0 -5
- package/lib/mjs/components/file/File.js +1 -2
- package/lib/mjs/components/form/Form.d.ts +20 -31
- package/lib/mjs/components/form/Form.form.d.ts +3 -6
- package/lib/mjs/components/form/Form.form.js +0 -5
- package/lib/mjs/components/form/Form.js +12 -15
- package/lib/mjs/components/hidden/Hidden.d.ts +11 -1
- package/lib/mjs/components/hidden/Hidden.form.d.ts +3 -6
- package/lib/mjs/components/hidden/Hidden.form.js +0 -5
- package/lib/mjs/components/hidden/Hidden.js +2 -1
- package/lib/mjs/components/html/HTML.d.ts +1 -2
- package/lib/mjs/components/html/HTML.form.d.ts +3 -6
- package/lib/mjs/components/html/HTML.form.js +0 -5
- package/lib/mjs/components/number/Number.d.ts +17 -3
- package/lib/mjs/components/number/Number.form.d.ts +3 -6
- package/lib/mjs/components/number/Number.form.js +0 -5
- package/lib/mjs/components/number/Number.js +2 -1
- package/lib/mjs/components/panel/Panel.form.d.ts +3 -6
- package/lib/mjs/components/panel/Panel.form.js +0 -5
- package/lib/mjs/components/panel/Panel.js +1 -0
- package/lib/mjs/components/password/Password.form.d.ts +3 -6
- package/lib/mjs/components/password/Password.form.js +0 -5
- package/lib/mjs/components/phonenumber/PhoneNumber.form.d.ts +3 -6
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +0 -5
- package/lib/mjs/components/radio/Radio.d.ts +26 -3
- package/lib/mjs/components/radio/Radio.form.d.ts +3 -6
- package/lib/mjs/components/radio/Radio.form.js +0 -5
- package/lib/mjs/components/radio/Radio.js +4 -3
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +3 -6
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +0 -5
- package/lib/mjs/components/select/Select.d.ts +39 -16
- package/lib/mjs/components/select/Select.form.d.ts +3 -6
- package/lib/mjs/components/select/Select.form.js +0 -5
- package/lib/mjs/components/select/Select.js +17 -14
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +17 -2
- package/lib/mjs/components/selectboxes/SelectBoxes.form.d.ts +3 -6
- package/lib/mjs/components/selectboxes/SelectBoxes.form.js +0 -5
- package/lib/mjs/components/selectboxes/SelectBoxes.js +9 -7
- package/lib/mjs/components/signature/Signature.d.ts +14 -1
- package/lib/mjs/components/signature/Signature.form.d.ts +3 -6
- package/lib/mjs/components/signature/Signature.form.js +0 -5
- package/lib/mjs/components/survey/Survey.d.ts +15 -3
- package/lib/mjs/components/survey/Survey.form.d.ts +3 -6
- package/lib/mjs/components/survey/Survey.form.js +0 -5
- package/lib/mjs/components/table/Table.d.ts +1 -2
- package/lib/mjs/components/table/Table.form.d.ts +3 -6
- package/lib/mjs/components/table/Table.form.js +0 -5
- package/lib/mjs/components/tabs/Tabs.d.ts +4 -4
- package/lib/mjs/components/tabs/Tabs.form.d.ts +3 -6
- package/lib/mjs/components/tabs/Tabs.form.js +0 -5
- package/lib/mjs/components/tabs/Tabs.js +2 -1
- package/lib/mjs/components/tags/Tags.d.ts +14 -0
- package/lib/mjs/components/tags/Tags.form.d.ts +3 -6
- package/lib/mjs/components/tags/Tags.form.js +0 -5
- package/lib/mjs/components/textarea/TextArea.d.ts +9 -4
- package/lib/mjs/components/textarea/TextArea.form.d.ts +3 -6
- package/lib/mjs/components/textarea/TextArea.form.js +0 -5
- package/lib/mjs/components/textarea/TextArea.js +2 -2
- package/lib/mjs/components/textfield/TextField.d.ts +30 -14
- package/lib/mjs/components/textfield/TextField.form.d.ts +3 -6
- package/lib/mjs/components/textfield/TextField.form.js +0 -5
- package/lib/mjs/components/textfield/TextField.js +17 -16
- package/lib/mjs/components/time/Time.form.d.ts +3 -6
- package/lib/mjs/components/time/Time.form.js +0 -5
- package/lib/mjs/components/unknown/Unknown.form.d.ts +34 -5
- package/lib/mjs/components/unknown/Unknown.form.js +0 -4
- package/lib/mjs/components/url/Url.form.d.ts +3 -6
- package/lib/mjs/components/url/Url.form.js +0 -5
- package/lib/mjs/components/well/Well.form.d.ts +3 -6
- package/lib/mjs/components/well/Well.form.js +0 -5
- package/lib/mjs/formio.embed.d.ts +2 -1
- package/lib/mjs/formio.embed.js +99 -2
- package/lib/mjs/formio.form.d.ts +4 -11
- package/lib/mjs/formio.form.js +3 -10
- package/lib/mjs/providers/Providers.d.ts +5 -36
- package/lib/mjs/providers/Providers.js +0 -29
- package/lib/mjs/providers/address/AddressProvider.d.ts +12 -131
- package/lib/mjs/providers/address/AddressProvider.js +2 -88
- package/lib/mjs/providers/address/AzureAddressProvider.d.ts +1 -48
- package/lib/mjs/providers/address/AzureAddressProvider.js +0 -37
- package/lib/mjs/providers/address/CustomAddressProvider.d.ts +4 -27
- package/lib/mjs/providers/address/CustomAddressProvider.js +0 -34
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +6 -130
- package/lib/mjs/providers/address/GoogleAddressProvider.js +0 -72
- package/lib/mjs/providers/address/NominatimAddressProvider.d.ts +7 -32
- package/lib/mjs/providers/address/NominatimAddressProvider.js +0 -33
- package/lib/mjs/providers/address/index.d.ts +1 -3
- package/lib/mjs/providers/processor/fileProcessor.d.ts +1 -7
- package/lib/mjs/providers/processor/fileProcessor.js +0 -6
- package/lib/mjs/providers/storage/azure.d.ts +13 -6
- package/lib/mjs/providers/storage/azure.js +0 -5
- package/lib/mjs/providers/storage/base64.d.ts +6 -5
- package/lib/mjs/providers/storage/base64.js +0 -4
- package/lib/mjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/mjs/providers/storage/dropbox.js +0 -5
- package/lib/mjs/providers/storage/googleDrive.d.ts +5 -7
- package/lib/mjs/providers/storage/googleDrive.js +0 -6
- package/lib/mjs/providers/storage/indexeddb.d.ts +7 -5
- package/lib/mjs/providers/storage/indexeddb.js +0 -4
- package/lib/mjs/providers/storage/s3.d.ts +20 -6
- package/lib/mjs/providers/storage/s3.js +0 -5
- package/lib/mjs/providers/storage/url.d.ts +7 -6
- package/lib/mjs/providers/storage/url.js +0 -10
- package/lib/mjs/providers/storage/util.d.ts +1 -24
- package/lib/mjs/providers/storage/util.js +0 -18
- package/lib/mjs/templates/Templates.d.ts +0 -1
- package/lib/mjs/utils/Evaluator.d.ts +3 -6
- package/lib/mjs/utils/Evaluator.js +20 -9
- package/lib/mjs/utils/builder.d.ts +7 -9
- package/lib/mjs/utils/builder.js +5 -10
- package/lib/mjs/utils/calendarUtils.d.ts +13 -7
- package/lib/mjs/utils/calendarUtils.js +17 -10
- package/lib/mjs/utils/formUtils.d.ts +171 -43
- package/lib/mjs/utils/formUtils.js +554 -6
- package/lib/mjs/utils/utils.d.ts +221 -367
- package/lib/mjs/utils/utils.js +222 -329
- package/lib/mjs/widgets/CalendarWidget.d.ts +10 -9
- package/lib/mjs/widgets/CalendarWidget.js +11 -9
- package/package.json +22 -22
- package/embed.d.ts +0 -1
- package/form.d.ts +0 -1
- package/lib/cjs/InlineEmbed.d.ts +0 -7
- package/lib/cjs/InlineEmbed.js +0 -116
- package/lib/mjs/InlineEmbed.d.ts +0 -7
- package/lib/mjs/InlineEmbed.js +0 -112
- package/sdk.d.ts +0 -1
- package/utils.d.ts +0 -1
package/lib/mjs/utils/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ import jtz from 'jstimezonedetect';
|
|
|
7
7
|
import { lodashOperators } from './jsonlogic/operators';
|
|
8
8
|
import dompurify from 'dompurify';
|
|
9
9
|
import { getValue } from './formUtils';
|
|
10
|
-
import
|
|
10
|
+
import Evaluator from './Evaluator';
|
|
11
11
|
import ConditionOperators from './conditionOperators';
|
|
12
12
|
const interpolate = Evaluator.interpolate;
|
|
13
13
|
const { fetch } = fetchPonyfill({
|
|
@@ -30,10 +30,6 @@ jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
|
|
30
30
|
});
|
|
31
31
|
export { jsonLogic, ConditionOperators };
|
|
32
32
|
export * as moment from 'moment-timezone/moment-timezone';
|
|
33
|
-
/**
|
|
34
|
-
* Sets the path to the component and parent schema.
|
|
35
|
-
* @param {import('@formio/core').Component} component - The component to set the path for.
|
|
36
|
-
*/
|
|
37
33
|
function setPathToComponentAndPerentSchema(component) {
|
|
38
34
|
component.path = getComponentPath(component);
|
|
39
35
|
const dataParent = getDataParentComponent(component);
|
|
@@ -43,28 +39,77 @@ function setPathToComponentAndPerentSchema(component) {
|
|
|
43
39
|
}
|
|
44
40
|
/**
|
|
45
41
|
* Evaluate a method.
|
|
46
|
-
*
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
*
|
|
43
|
+
* @param func
|
|
44
|
+
* @param args
|
|
45
|
+
* @return {*}
|
|
46
|
+
*/
|
|
47
|
+
export function evaluate(func, args, ret, tokenize) {
|
|
48
|
+
let returnVal = null;
|
|
49
|
+
const component = args.component ? args.component : { key: 'unknown' };
|
|
50
|
+
if (!args.form && args.instance) {
|
|
51
|
+
args.form = _.get(args.instance, 'root._form', {});
|
|
52
|
+
}
|
|
53
|
+
const componentKey = component.key;
|
|
54
|
+
if (typeof func === 'string') {
|
|
55
|
+
if (ret) {
|
|
56
|
+
func += `;return ${ret}`;
|
|
57
|
+
}
|
|
58
|
+
if (tokenize) {
|
|
59
|
+
// Replace all {{ }} references with actual data.
|
|
60
|
+
func = func.replace(/({{\s+(.*)\s+}})/, (match, $1, $2) => {
|
|
61
|
+
if ($2.indexOf('data.') === 0) {
|
|
62
|
+
return _.get(args.data, $2.replace('data.', ''));
|
|
63
|
+
}
|
|
64
|
+
else if ($2.indexOf('row.') === 0) {
|
|
65
|
+
return _.get(args.row, $2.replace('row.', ''));
|
|
66
|
+
}
|
|
67
|
+
// Support legacy...
|
|
68
|
+
return _.get(args.data, $2);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
func = Evaluator.evaluator(func, args);
|
|
73
|
+
args = _.values(args);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
console.warn(`An error occured within the custom function for ${componentKey}`, err);
|
|
77
|
+
returnVal = null;
|
|
78
|
+
func = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (typeof func === 'function') {
|
|
82
|
+
try {
|
|
83
|
+
returnVal = Evaluator.evaluate(func, args);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
returnVal = null;
|
|
87
|
+
console.warn(`An error occured within custom function for ${componentKey}`, err);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (typeof func === 'object') {
|
|
91
|
+
try {
|
|
92
|
+
returnVal = jsonLogic.apply(func, args);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
returnVal = null;
|
|
96
|
+
console.warn(`An error occured within custom function for ${componentKey}`, err);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (func) {
|
|
100
|
+
console.warn(`Unknown function type for ${componentKey}`);
|
|
101
|
+
}
|
|
102
|
+
return returnVal;
|
|
55
103
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Returns a random compoennt ID.
|
|
58
|
-
* @returns {string} - A random component ID.
|
|
59
|
-
*/
|
|
60
104
|
export function getRandomComponentId() {
|
|
61
105
|
return `e${Math.random().toString(36).substring(7)}`;
|
|
62
106
|
}
|
|
63
107
|
/**
|
|
64
108
|
* Get a property value of an element.
|
|
65
|
-
*
|
|
66
|
-
* @param
|
|
67
|
-
* @
|
|
109
|
+
*
|
|
110
|
+
* @param style
|
|
111
|
+
* @param prop
|
|
112
|
+
* @return {number}
|
|
68
113
|
*/
|
|
69
114
|
export function getPropertyValue(style, prop) {
|
|
70
115
|
let value = style.getPropertyValue(prop);
|
|
@@ -73,8 +118,9 @@ export function getPropertyValue(style, prop) {
|
|
|
73
118
|
}
|
|
74
119
|
/**
|
|
75
120
|
* Get an elements bounding rectagle.
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
121
|
+
*
|
|
122
|
+
* @param element
|
|
123
|
+
* @return {{x: string, y: string, width: string, height: string}}
|
|
78
124
|
*/
|
|
79
125
|
export function getElementRect(element) {
|
|
80
126
|
const style = window.getComputedStyle(element, null);
|
|
@@ -87,8 +133,8 @@ export function getElementRect(element) {
|
|
|
87
133
|
}
|
|
88
134
|
/**
|
|
89
135
|
* Get non HTMLElement property in the window object
|
|
90
|
-
* @param {
|
|
91
|
-
* @
|
|
136
|
+
* @param {String} property
|
|
137
|
+
* @return {any || undefined}
|
|
92
138
|
*/
|
|
93
139
|
export function getScriptPlugin(property) {
|
|
94
140
|
const obj = window[property];
|
|
@@ -100,8 +146,9 @@ export function getScriptPlugin(property) {
|
|
|
100
146
|
}
|
|
101
147
|
/**
|
|
102
148
|
* Determines the boolean value of a setting.
|
|
103
|
-
*
|
|
104
|
-
* @
|
|
149
|
+
*
|
|
150
|
+
* @param value
|
|
151
|
+
* @return {boolean}
|
|
105
152
|
*/
|
|
106
153
|
export function boolValue(value) {
|
|
107
154
|
if (_.isBoolean(value)) {
|
|
@@ -116,17 +163,21 @@ export function boolValue(value) {
|
|
|
116
163
|
}
|
|
117
164
|
/**
|
|
118
165
|
* Check to see if an ID is a mongoID.
|
|
119
|
-
* @param
|
|
120
|
-
* @
|
|
166
|
+
* @param text
|
|
167
|
+
* @return {Array|{index: number, input: string}|Boolean|*}
|
|
121
168
|
*/
|
|
122
169
|
export function isMongoId(text) {
|
|
123
|
-
return
|
|
170
|
+
return text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
124
171
|
}
|
|
125
172
|
/**
|
|
126
173
|
* Checks the calculated value for a provided component and data.
|
|
127
|
-
*
|
|
128
|
-
* @param {
|
|
129
|
-
*
|
|
174
|
+
*
|
|
175
|
+
* @param {Object} component
|
|
176
|
+
* The component to check for the calculated value.
|
|
177
|
+
* @param {Object} submission
|
|
178
|
+
* A submission object.
|
|
179
|
+
* @param data
|
|
180
|
+
* The full submission data.
|
|
130
181
|
*/
|
|
131
182
|
export function checkCalculated(component, submission, rowData) {
|
|
132
183
|
// Process calculated value stuff if present.
|
|
@@ -142,12 +193,13 @@ export function checkCalculated(component, submission, rowData) {
|
|
|
142
193
|
}
|
|
143
194
|
/**
|
|
144
195
|
* Check if a simple conditional evaluates to true.
|
|
145
|
-
*
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
150
|
-
* @
|
|
196
|
+
*
|
|
197
|
+
* @param condition
|
|
198
|
+
* @param condition
|
|
199
|
+
* @param row
|
|
200
|
+
* @param data
|
|
201
|
+
* @param instance
|
|
202
|
+
* @returns {boolean}
|
|
151
203
|
*/
|
|
152
204
|
export function checkSimpleConditional(component, condition, row, data, instance) {
|
|
153
205
|
if (condition.when) {
|
|
@@ -191,13 +243,6 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
|
191
243
|
return show ? result : !result;
|
|
192
244
|
}
|
|
193
245
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Returns a components normalized value.
|
|
196
|
-
* @param {string} compPath - The full path to the component.
|
|
197
|
-
* @param {*} data - The data object to get the value from.
|
|
198
|
-
* @param {*} row - The contextual row data for the component.
|
|
199
|
-
* @returns {*} - The normalized value of the component.
|
|
200
|
-
*/
|
|
201
246
|
export function getComponentActualValue(compPath, data, row) {
|
|
202
247
|
let value = null;
|
|
203
248
|
if (row) {
|
|
@@ -214,15 +259,12 @@ export function getComponentActualValue(compPath, data, row) {
|
|
|
214
259
|
}
|
|
215
260
|
/**
|
|
216
261
|
* Check custom javascript conditional.
|
|
217
|
-
*
|
|
218
|
-
* @param
|
|
219
|
-
* @param
|
|
220
|
-
* @param
|
|
221
|
-
* @param
|
|
222
|
-
* @
|
|
223
|
-
* @param {*} onError - A custom return if there is an error or the value is null from the evaluation.
|
|
224
|
-
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
225
|
-
* @returns {*} - The result of the evaulation.
|
|
262
|
+
*
|
|
263
|
+
* @param component
|
|
264
|
+
* @param custom
|
|
265
|
+
* @param row
|
|
266
|
+
* @param data
|
|
267
|
+
* @returns {*}
|
|
226
268
|
*/
|
|
227
269
|
export function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
|
|
228
270
|
if (typeof custom === 'string') {
|
|
@@ -236,16 +278,6 @@ export function checkCustomConditional(component, custom, row, data, form, varia
|
|
|
236
278
|
}
|
|
237
279
|
return value;
|
|
238
280
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Check a component for JSON conditionals.
|
|
241
|
-
* @param {import('@formio/core').Component} component - The component
|
|
242
|
-
* @param {import('@formio/core').JSONConditional} json - The json conditional to check.
|
|
243
|
-
* @param {*} row - The contextual row data for the component.
|
|
244
|
-
* @param {*} data - The full submission data.
|
|
245
|
-
* @param {import('@formio/core').Form} form - The Form JSON of the form.
|
|
246
|
-
* @param {*} onError - Custom return value if there is an error.
|
|
247
|
-
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
248
|
-
*/
|
|
249
281
|
export function checkJsonConditional(component, json, row, data, form, onError) {
|
|
250
282
|
try {
|
|
251
283
|
return jsonLogic.apply(json, {
|
|
@@ -260,14 +292,6 @@ export function checkJsonConditional(component, json, row, data, form, onError)
|
|
|
260
292
|
return onError;
|
|
261
293
|
}
|
|
262
294
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Returns the contextual row data for a component.
|
|
265
|
-
* @param {import('@formio/core').Component} component - The component to get the row data for.
|
|
266
|
-
* @param {*} row - The row data for the component.
|
|
267
|
-
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
268
|
-
* @param {*} conditional - The component conditional.
|
|
269
|
-
* @returns {*} - The contextual row data for the component.
|
|
270
|
-
*/
|
|
271
295
|
function getRow(component, row, instance, conditional) {
|
|
272
296
|
const condition = conditional || component.conditional;
|
|
273
297
|
// If no component's instance passed (happens only in 6.x server), calculate its path based on the schema
|
|
@@ -289,12 +313,15 @@ function getRow(component, row, instance, conditional) {
|
|
|
289
313
|
}
|
|
290
314
|
/**
|
|
291
315
|
* Checks the conditions for a provided component and data.
|
|
292
|
-
*
|
|
293
|
-
* @param
|
|
294
|
-
*
|
|
295
|
-
* @param
|
|
296
|
-
*
|
|
297
|
-
* @
|
|
316
|
+
*
|
|
317
|
+
* @param component
|
|
318
|
+
* The component to check for the condition.
|
|
319
|
+
* @param row
|
|
320
|
+
* The data within a row
|
|
321
|
+
* @param data
|
|
322
|
+
* The full submission data.
|
|
323
|
+
*
|
|
324
|
+
* @returns {boolean}
|
|
298
325
|
*/
|
|
299
326
|
export function checkCondition(component, row, data, form, instance) {
|
|
300
327
|
const { customConditional, conditional } = component;
|
|
@@ -313,13 +340,12 @@ export function checkCondition(component, row, data, form, instance) {
|
|
|
313
340
|
}
|
|
314
341
|
/**
|
|
315
342
|
* Test a trigger on a component.
|
|
316
|
-
*
|
|
317
|
-
* @param
|
|
318
|
-
* @param
|
|
319
|
-
* @param
|
|
320
|
-
* @param
|
|
321
|
-
* @
|
|
322
|
-
* @returns {boolean} - TRUE if the trigger should fire; FALSE otherwise.
|
|
343
|
+
*
|
|
344
|
+
* @param component
|
|
345
|
+
* @param action
|
|
346
|
+
* @param data
|
|
347
|
+
* @param row
|
|
348
|
+
* @returns {mixed}
|
|
323
349
|
*/
|
|
324
350
|
export function checkTrigger(component, trigger, row, data, form, instance) {
|
|
325
351
|
// If trigger is empty, don't fire it
|
|
@@ -338,16 +364,6 @@ export function checkTrigger(component, trigger, row, data, form, instance) {
|
|
|
338
364
|
// If none of the types matched, don't fire the trigger.
|
|
339
365
|
return false;
|
|
340
366
|
}
|
|
341
|
-
/**
|
|
342
|
-
* Sets a property on a component via an executed Logic action.
|
|
343
|
-
* @param {import('@formio/core').Component} component - The component to set the property on.
|
|
344
|
-
* @param {import('@formio/core').LogicAction} action - The action to perform on the component.
|
|
345
|
-
* @param {string} result - The name of the variable in the evaulation to use as the result.
|
|
346
|
-
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
347
|
-
* @param {import('@formio/core').DataObject} data - The full submission data.
|
|
348
|
-
* @param {any} instance - The component instance.
|
|
349
|
-
* @returns {import('@formio/core').Component} - The modified component.
|
|
350
|
-
*/
|
|
351
367
|
export function setActionProperty(component, action, result, row, data, instance) {
|
|
352
368
|
const property = action.property.value;
|
|
353
369
|
switch (action.property.type) {
|
|
@@ -381,8 +397,8 @@ export function setActionProperty(component, action, result, row, data, instance
|
|
|
381
397
|
}
|
|
382
398
|
/**
|
|
383
399
|
* Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
|
|
384
|
-
* @param {string} str
|
|
385
|
-
* @returns {string}
|
|
400
|
+
* @param {string} str
|
|
401
|
+
* @returns {string}
|
|
386
402
|
*/
|
|
387
403
|
export function removeHTML(str) {
|
|
388
404
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -390,8 +406,8 @@ export function removeHTML(str) {
|
|
|
390
406
|
}
|
|
391
407
|
/**
|
|
392
408
|
* Unescape HTML characters like <, >, & and etc.
|
|
393
|
-
* @param
|
|
394
|
-
* @returns {string}
|
|
409
|
+
* @param str
|
|
410
|
+
* @returns {string}
|
|
395
411
|
*/
|
|
396
412
|
export function unescapeHTML(str) {
|
|
397
413
|
if (typeof window === 'undefined' || !('DOMParser' in window)) {
|
|
@@ -403,9 +419,9 @@ export function unescapeHTML(str) {
|
|
|
403
419
|
}
|
|
404
420
|
/**
|
|
405
421
|
* Make HTML element from string
|
|
406
|
-
* @param
|
|
407
|
-
* @param
|
|
408
|
-
* @returns {HTMLElement}
|
|
422
|
+
* @param str
|
|
423
|
+
* @param selector
|
|
424
|
+
* @returns {HTMLElement}
|
|
409
425
|
*/
|
|
410
426
|
export function convertStringToHTMLElement(str, selector) {
|
|
411
427
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -413,10 +429,10 @@ export function convertStringToHTMLElement(str, selector) {
|
|
|
413
429
|
}
|
|
414
430
|
/**
|
|
415
431
|
* Make a filename guaranteed to be unique.
|
|
416
|
-
* @param
|
|
417
|
-
* @param
|
|
418
|
-
* @param
|
|
419
|
-
* @returns {string}
|
|
432
|
+
* @param name
|
|
433
|
+
* @param template
|
|
434
|
+
* @param evalContext
|
|
435
|
+
* @returns {string}
|
|
420
436
|
*/
|
|
421
437
|
export function uniqueName(name, template, evalContext) {
|
|
422
438
|
template = template || '{{fileName}}-{{guid}}';
|
|
@@ -439,10 +455,6 @@ export function uniqueName(name, template, evalContext) {
|
|
|
439
455
|
const uniqueName = `${Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
|
|
440
456
|
return uniqueName;
|
|
441
457
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Returns a GUID
|
|
444
|
-
* @returns {string} - A GUID.
|
|
445
|
-
*/
|
|
446
458
|
export function guid() {
|
|
447
459
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
448
460
|
const r = Math.random() * 16 | 0;
|
|
@@ -454,8 +466,9 @@ export function guid() {
|
|
|
454
466
|
}
|
|
455
467
|
/**
|
|
456
468
|
* Return a translated date setting.
|
|
457
|
-
*
|
|
458
|
-
* @
|
|
469
|
+
*
|
|
470
|
+
* @param date
|
|
471
|
+
* @return {(null|Date)}
|
|
459
472
|
*/
|
|
460
473
|
export function getDateSetting(date) {
|
|
461
474
|
if (_.isNil(date) || _.isNaN(date) || date === '') {
|
|
@@ -496,17 +509,13 @@ export function getDateSetting(date) {
|
|
|
496
509
|
}
|
|
497
510
|
return dateSetting.toDate();
|
|
498
511
|
}
|
|
499
|
-
/**
|
|
500
|
-
* Returns true if the date is a valid date. False otherwise.
|
|
501
|
-
* @param {Date|string} date - The date to check for validity.
|
|
502
|
-
* @returns {boolean} - TRUE if the date is valid; FALSE otherwise.
|
|
503
|
-
*/
|
|
504
512
|
export function isValidDate(date) {
|
|
505
513
|
return _.isDate(date) && !_.isNaN(date.getDate());
|
|
506
514
|
}
|
|
507
515
|
/**
|
|
508
516
|
* Get the current timezone string.
|
|
509
|
-
*
|
|
517
|
+
*
|
|
518
|
+
* @return {string}
|
|
510
519
|
*/
|
|
511
520
|
export function currentTimezone() {
|
|
512
521
|
if (moment.currentTimezone) {
|
|
@@ -517,9 +526,10 @@ export function currentTimezone() {
|
|
|
517
526
|
}
|
|
518
527
|
/**
|
|
519
528
|
* Get an offset date provided a date object and timezone object.
|
|
520
|
-
*
|
|
521
|
-
* @param
|
|
522
|
-
* @
|
|
529
|
+
*
|
|
530
|
+
* @param date
|
|
531
|
+
* @param timezone
|
|
532
|
+
* @return {Date}
|
|
523
533
|
*/
|
|
524
534
|
export function offsetDate(date, timezone) {
|
|
525
535
|
if (timezone === 'UTC') {
|
|
@@ -536,15 +546,17 @@ export function offsetDate(date, timezone) {
|
|
|
536
546
|
}
|
|
537
547
|
/**
|
|
538
548
|
* Returns if the zones are loaded.
|
|
539
|
-
*
|
|
549
|
+
*
|
|
550
|
+
* @return {boolean}
|
|
540
551
|
*/
|
|
541
552
|
export function zonesLoaded() {
|
|
542
553
|
return moment.zonesLoaded;
|
|
543
554
|
}
|
|
544
555
|
/**
|
|
545
556
|
* Returns if we should load the zones.
|
|
546
|
-
*
|
|
547
|
-
* @
|
|
557
|
+
*
|
|
558
|
+
* @param timezone
|
|
559
|
+
* @return {boolean}
|
|
548
560
|
*/
|
|
549
561
|
export function shouldLoadZones(timezone) {
|
|
550
562
|
if (timezone === currentTimezone() || timezone === 'UTC') {
|
|
@@ -554,9 +566,8 @@ export function shouldLoadZones(timezone) {
|
|
|
554
566
|
}
|
|
555
567
|
/**
|
|
556
568
|
* Externally load the timezone data.
|
|
557
|
-
*
|
|
558
|
-
* @
|
|
559
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
569
|
+
*
|
|
570
|
+
* @return {Promise<any> | *}
|
|
560
571
|
*/
|
|
561
572
|
export function loadZones(url, timezone) {
|
|
562
573
|
if (timezone && !shouldLoadZones(timezone)) {
|
|
@@ -580,10 +591,11 @@ export function loadZones(url, timezone) {
|
|
|
580
591
|
}
|
|
581
592
|
/**
|
|
582
593
|
* Get the moment date object for translating dates with timezones.
|
|
583
|
-
*
|
|
584
|
-
* @param
|
|
585
|
-
* @param
|
|
586
|
-
* @
|
|
594
|
+
*
|
|
595
|
+
* @param value
|
|
596
|
+
* @param format
|
|
597
|
+
* @param timezone
|
|
598
|
+
* @return {*}
|
|
587
599
|
*/
|
|
588
600
|
export function momentDate(value, format, timezone) {
|
|
589
601
|
const momentDate = moment(value);
|
|
@@ -600,12 +612,11 @@ export function momentDate(value, format, timezone) {
|
|
|
600
612
|
}
|
|
601
613
|
/**
|
|
602
614
|
* Format a date provided a value, format, and timezone object.
|
|
603
|
-
*
|
|
604
|
-
* @param
|
|
605
|
-
* @param
|
|
606
|
-
* @param
|
|
607
|
-
* @
|
|
608
|
-
* @returns {string} - The formatted date.
|
|
615
|
+
*
|
|
616
|
+
* @param value
|
|
617
|
+
* @param format
|
|
618
|
+
* @param timezone
|
|
619
|
+
* @return {string}
|
|
609
620
|
*/
|
|
610
621
|
export function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat) {
|
|
611
622
|
const momentDate = moment(value, flatPickrInputFormat || undefined);
|
|
@@ -638,12 +649,12 @@ export function formatDate(timezonesUrl, value, format, timezone, flatPickrInput
|
|
|
638
649
|
}
|
|
639
650
|
/**
|
|
640
651
|
* Pass a format function to format within a timezone.
|
|
641
|
-
*
|
|
642
|
-
* @param
|
|
643
|
-
* @param
|
|
644
|
-
* @param
|
|
645
|
-
* @param
|
|
646
|
-
* @
|
|
652
|
+
*
|
|
653
|
+
* @param formatFn
|
|
654
|
+
* @param date
|
|
655
|
+
* @param format
|
|
656
|
+
* @param timezone
|
|
657
|
+
* @return {string}
|
|
647
658
|
*/
|
|
648
659
|
export function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
649
660
|
if (timezone === currentTimezone()) {
|
|
@@ -662,11 +673,6 @@ export function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
|
662
673
|
return formatFn(date, format);
|
|
663
674
|
}
|
|
664
675
|
}
|
|
665
|
-
/**
|
|
666
|
-
* Returns the local date format information.
|
|
667
|
-
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
|
668
|
-
* @returns {object} - The local date format information.
|
|
669
|
-
*/
|
|
670
676
|
export function getLocaleDateFormatInfo(locale) {
|
|
671
677
|
const formatInfo = {};
|
|
672
678
|
const day = 21;
|
|
@@ -677,8 +683,8 @@ export function getLocaleDateFormatInfo(locale) {
|
|
|
677
683
|
}
|
|
678
684
|
/**
|
|
679
685
|
* Convert the format from the angular-datepicker module to flatpickr format.
|
|
680
|
-
* @param
|
|
681
|
-
* @
|
|
686
|
+
* @param format
|
|
687
|
+
* @return {string}
|
|
682
688
|
*/
|
|
683
689
|
export function convertFormatToFlatpickr(format) {
|
|
684
690
|
return format
|
|
@@ -708,8 +714,8 @@ export function convertFormatToFlatpickr(format) {
|
|
|
708
714
|
}
|
|
709
715
|
/**
|
|
710
716
|
* Convert the format from the angular-datepicker module to moment format.
|
|
711
|
-
* @param
|
|
712
|
-
* @
|
|
717
|
+
* @param format
|
|
718
|
+
* @return {string}
|
|
713
719
|
*/
|
|
714
720
|
export function convertFormatToMoment(format) {
|
|
715
721
|
return format
|
|
@@ -724,11 +730,6 @@ export function convertFormatToMoment(format) {
|
|
|
724
730
|
// Unix Timestamp
|
|
725
731
|
.replace(/U/g, 'X');
|
|
726
732
|
}
|
|
727
|
-
/**
|
|
728
|
-
* Convert the format from the angular-datepicker module to mask format.
|
|
729
|
-
* @param {string} format - The format to convert.
|
|
730
|
-
* @returns {string} - The converted format.
|
|
731
|
-
*/
|
|
732
733
|
export function convertFormatToMask(format) {
|
|
733
734
|
return format
|
|
734
735
|
// Long month replacement.
|
|
@@ -786,13 +787,6 @@ export function getInputMask(mask, placeholderChar) {
|
|
|
786
787
|
}
|
|
787
788
|
return maskArray;
|
|
788
789
|
}
|
|
789
|
-
/**
|
|
790
|
-
* Unmasks a value using the provided mask and placeholder characters.
|
|
791
|
-
* @param {string} value - The value to unmask.
|
|
792
|
-
* @param {string} mask - The mask to use for unmasking.
|
|
793
|
-
* @param {string} placeholderChar - The placeholder character to use for unmasking.
|
|
794
|
-
* @returns {string} - The unmasked value.
|
|
795
|
-
*/
|
|
796
790
|
export function unmaskValue(value, mask, placeholderChar) {
|
|
797
791
|
if (!mask || !value || value.length > mask.length) {
|
|
798
792
|
return value;
|
|
@@ -808,12 +802,6 @@ export function unmaskValue(value, mask, placeholderChar) {
|
|
|
808
802
|
unmaskedValue = unmaskedValue.join('').replace(placeholderChar, '');
|
|
809
803
|
return unmaskedValue;
|
|
810
804
|
}
|
|
811
|
-
/**
|
|
812
|
-
* Returns true if the value matches the input mask format.
|
|
813
|
-
* @param {string} value - The value to check.
|
|
814
|
-
* @param {string} inputMask - The input mask to check against.
|
|
815
|
-
* @returns {boolean} - TRUE if the value matches the input mask; FALSE otherwise.
|
|
816
|
-
*/
|
|
817
805
|
export function matchInputMask(value, inputMask) {
|
|
818
806
|
if (!inputMask) {
|
|
819
807
|
return true;
|
|
@@ -831,11 +819,6 @@ export function matchInputMask(value, inputMask) {
|
|
|
831
819
|
}
|
|
832
820
|
return true;
|
|
833
821
|
}
|
|
834
|
-
/**
|
|
835
|
-
* Returns the number separators (i.e. 1,000) for the provided language.
|
|
836
|
-
* @param {string} lang - The language code to get the number separators for.
|
|
837
|
-
* @returns {{delimiter: string, decimalSeparator: string}} - The number separators.
|
|
838
|
-
*/
|
|
839
822
|
export function getNumberSeparators(lang = 'en') {
|
|
840
823
|
const formattedNumberString = (12345.6789).toLocaleString(lang);
|
|
841
824
|
const delimeters = formattedNumberString.match(/..(.)...(.)../);
|
|
@@ -850,12 +833,6 @@ export function getNumberSeparators(lang = 'en') {
|
|
|
850
833
|
decimalSeparator: (delimeters.length > 2) ? delimeters[2] : '.',
|
|
851
834
|
};
|
|
852
835
|
}
|
|
853
|
-
/**
|
|
854
|
-
* Returns the number for the maximum amount of decimal places for a number.
|
|
855
|
-
* @param {import('@formio/core').Component} component - The component to check for decimal limits.
|
|
856
|
-
* @param {number} defaultLimit - The default limit to use if none is provided in the component.
|
|
857
|
-
* @returns {number} - The number of decimal places allowed.
|
|
858
|
-
*/
|
|
859
836
|
export function getNumberDecimalLimit(component, defaultLimit) {
|
|
860
837
|
if (_.has(component, 'decimalLimit')) {
|
|
861
838
|
return _.get(component, 'decimalLimit');
|
|
@@ -871,15 +848,6 @@ export function getNumberDecimalLimit(component, defaultLimit) {
|
|
|
871
848
|
}
|
|
872
849
|
return decimalLimit;
|
|
873
850
|
}
|
|
874
|
-
/**
|
|
875
|
-
* Returns the currency affixes for a specific language.
|
|
876
|
-
* @param {object} arg0 - The arguments object.
|
|
877
|
-
* @param {string} arg0.currency - The currency code to get the affixes for.
|
|
878
|
-
* @param {number} arg0.decimalLimit - The number of decimal places to use.
|
|
879
|
-
* @param {string} arg0.decimalSeparator - The decimal separator to use.
|
|
880
|
-
* @param {string} arg0.lang - The language code to use.
|
|
881
|
-
* @returns {{prefix: string, suffix: string}} - The currency affixes.
|
|
882
|
-
*/
|
|
883
851
|
export function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }) {
|
|
884
852
|
// Get the prefix and suffix from the localized string.
|
|
885
853
|
let regex = `(.*)?${(100).toLocaleString(lang)}`;
|
|
@@ -901,9 +869,10 @@ export function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, l
|
|
|
901
869
|
}
|
|
902
870
|
/**
|
|
903
871
|
* Fetch the field data provided a component.
|
|
904
|
-
*
|
|
905
|
-
* @param
|
|
906
|
-
* @
|
|
872
|
+
*
|
|
873
|
+
* @param data
|
|
874
|
+
* @param component
|
|
875
|
+
* @return {*}
|
|
907
876
|
*/
|
|
908
877
|
export function fieldData(data, component) {
|
|
909
878
|
if (!data) {
|
|
@@ -949,23 +918,16 @@ export function fieldData(data, component) {
|
|
|
949
918
|
}
|
|
950
919
|
/**
|
|
951
920
|
* Delays function execution with possibility to execute function synchronously or cancel it.
|
|
952
|
-
*
|
|
953
|
-
* @param
|
|
954
|
-
* @param
|
|
955
|
-
* @
|
|
921
|
+
*
|
|
922
|
+
* @param fn Function to delay
|
|
923
|
+
* @param delay Delay time
|
|
924
|
+
* @return {*}
|
|
956
925
|
*/
|
|
957
926
|
export function delay(fn, delay = 0, ...args) {
|
|
958
927
|
const timer = setTimeout(fn, delay, ...args);
|
|
959
|
-
/**
|
|
960
|
-
*
|
|
961
|
-
*/
|
|
962
928
|
function cancel() {
|
|
963
929
|
clearTimeout(timer);
|
|
964
930
|
}
|
|
965
|
-
/**
|
|
966
|
-
* Execute the function early.
|
|
967
|
-
* @returns {*} - The result of the function.
|
|
968
|
-
*/
|
|
969
931
|
function earlyCall() {
|
|
970
932
|
cancel();
|
|
971
933
|
return fn(...args);
|
|
@@ -976,9 +938,11 @@ export function delay(fn, delay = 0, ...args) {
|
|
|
976
938
|
}
|
|
977
939
|
/**
|
|
978
940
|
* Iterate the given key to make it unique.
|
|
979
|
-
*
|
|
941
|
+
*
|
|
942
|
+
* @param {String} key
|
|
980
943
|
* Modify the component key to be unique.
|
|
981
|
-
*
|
|
944
|
+
*
|
|
945
|
+
* @returns {String}
|
|
982
946
|
* The new component key.
|
|
983
947
|
*/
|
|
984
948
|
export function iterateKey(key) {
|
|
@@ -991,9 +955,10 @@ export function iterateKey(key) {
|
|
|
991
955
|
}
|
|
992
956
|
/**
|
|
993
957
|
* Determines a unique key within a map provided the base key.
|
|
994
|
-
*
|
|
995
|
-
* @param
|
|
996
|
-
* @
|
|
958
|
+
*
|
|
959
|
+
* @param map
|
|
960
|
+
* @param base
|
|
961
|
+
* @return {*}
|
|
997
962
|
*/
|
|
998
963
|
export function uniqueKey(map, base) {
|
|
999
964
|
let newKey = base;
|
|
@@ -1004,9 +969,8 @@ export function uniqueKey(map, base) {
|
|
|
1004
969
|
}
|
|
1005
970
|
/**
|
|
1006
971
|
* Determines the major version number of bootstrap.
|
|
1007
|
-
*
|
|
1008
|
-
* @
|
|
1009
|
-
* @returns {number} - The bootstrap version.
|
|
972
|
+
*
|
|
973
|
+
* @return {number}
|
|
1010
974
|
*/
|
|
1011
975
|
export function bootstrapVersion(options) {
|
|
1012
976
|
if (options.bootstrap) {
|
|
@@ -1023,8 +987,9 @@ export function bootstrapVersion(options) {
|
|
|
1023
987
|
/**
|
|
1024
988
|
* Retrun provided argument.
|
|
1025
989
|
* If argument is a function, returns the result of a function call.
|
|
1026
|
-
* @param {
|
|
1027
|
-
*
|
|
990
|
+
* @param {*} e;
|
|
991
|
+
*
|
|
992
|
+
* @return {*}
|
|
1028
993
|
*/
|
|
1029
994
|
export function unfold(e) {
|
|
1030
995
|
if (typeof e === 'function') {
|
|
@@ -1034,32 +999,27 @@ export function unfold(e) {
|
|
|
1034
999
|
}
|
|
1035
1000
|
/**
|
|
1036
1001
|
* Map values through unfold and return first non-nil value.
|
|
1037
|
-
* @param {Array<T>} collection
|
|
1038
|
-
*
|
|
1002
|
+
* @param {Array<T>} collection;
|
|
1003
|
+
*
|
|
1004
|
+
* @return {T}
|
|
1039
1005
|
*/
|
|
1040
1006
|
export const firstNonNil = _.flow([
|
|
1041
1007
|
_.partialRight(_.map, unfold),
|
|
1042
1008
|
_.partialRight(_.find, v => !_.isUndefined(v))
|
|
1043
1009
|
]);
|
|
1044
|
-
|
|
1045
|
-
* Create enclosed state.
|
|
1010
|
+
/*
|
|
1011
|
+
* Create enclosed state.
|
|
1012
|
+
* Returns functions to getting and cycling between states.
|
|
1046
1013
|
* @param {*} a - initial state.
|
|
1047
1014
|
* @param {*} b - next state.
|
|
1048
|
-
* @
|
|
1015
|
+
* @return {Functions[]} -- [get, toggle];
|
|
1049
1016
|
*/
|
|
1050
1017
|
export function withSwitch(a, b) {
|
|
1051
1018
|
let state = a;
|
|
1052
1019
|
let next = b;
|
|
1053
|
-
/**
|
|
1054
|
-
* Returns the state of the switch.
|
|
1055
|
-
* @returns {*} - The current state.
|
|
1056
|
-
*/
|
|
1057
1020
|
function get() {
|
|
1058
1021
|
return state;
|
|
1059
1022
|
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Toggles the state of the switch.
|
|
1062
|
-
*/
|
|
1063
1023
|
function toggle() {
|
|
1064
1024
|
const prev = state;
|
|
1065
1025
|
state = next;
|
|
@@ -1067,14 +1027,6 @@ export function withSwitch(a, b) {
|
|
|
1067
1027
|
}
|
|
1068
1028
|
return [get, toggle];
|
|
1069
1029
|
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Create a function that will call the provided function only the provided limit.
|
|
1072
|
-
* @param {Function} callback - The callback to call.
|
|
1073
|
-
* @param {object} options - The options to use.
|
|
1074
|
-
* @param {number} options.limit - The limit to call the callback.
|
|
1075
|
-
* @param {number} options.delay - The delay to wait before resetting the call count.
|
|
1076
|
-
* @returns {Function} - The function that will call the callback only the provided limit.
|
|
1077
|
-
*/
|
|
1078
1030
|
export function observeOverload(callback, options = {}) {
|
|
1079
1031
|
const { limit = 50, delay = 500 } = options;
|
|
1080
1032
|
let callCount = 0;
|
|
@@ -1094,13 +1046,6 @@ export function observeOverload(callback, options = {}) {
|
|
|
1094
1046
|
}
|
|
1095
1047
|
};
|
|
1096
1048
|
}
|
|
1097
|
-
/**
|
|
1098
|
-
* Returns the components that are provided within an evaluation context.
|
|
1099
|
-
* @param {any} context - The evaluation context to get the components from.
|
|
1100
|
-
* @param {boolean} excludeNested - Exclude nested components.
|
|
1101
|
-
* @param {Array<string>} excludedTypes - The types of components to exclude.
|
|
1102
|
-
* @returns {Array} - The components within the evaluation context.
|
|
1103
|
-
*/
|
|
1104
1049
|
export function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
1105
1050
|
const values = [];
|
|
1106
1051
|
context.utils.eachComponent(context.instance.options.editForm.components, (component, path) => {
|
|
@@ -1114,11 +1059,6 @@ export function getContextComponents(context, excludeNested, excludedTypes = [])
|
|
|
1114
1059
|
});
|
|
1115
1060
|
return values;
|
|
1116
1061
|
}
|
|
1117
|
-
/**
|
|
1118
|
-
* Returns the button components that are within an evaluation context.
|
|
1119
|
-
* @param {any} context - The evaluation context to get the components from.
|
|
1120
|
-
* @returns {Array} - The button components within the evaluation context.
|
|
1121
|
-
*/
|
|
1122
1062
|
export function getContextButtons(context) {
|
|
1123
1063
|
const values = [];
|
|
1124
1064
|
context.utils.eachComponent(context.instance.options.editForm.components, (component) => {
|
|
@@ -1135,9 +1075,12 @@ export function getContextButtons(context) {
|
|
|
1135
1075
|
const inTextTags = ['#text', 'A', 'B', 'EM', 'I', 'SMALL', 'STRONG', 'SUB', 'SUP', 'INS', 'DEL', 'MARK', 'CODE'];
|
|
1136
1076
|
/**
|
|
1137
1077
|
* Helper function for 'translateHTMLTemplate'. Translates text value of the passed html element.
|
|
1138
|
-
*
|
|
1139
|
-
* @param {
|
|
1140
|
-
* @
|
|
1078
|
+
*
|
|
1079
|
+
* @param {HTMLElement} elem
|
|
1080
|
+
* @param {Function} translate
|
|
1081
|
+
*
|
|
1082
|
+
* @returns {String}
|
|
1083
|
+
* Translated element template.
|
|
1141
1084
|
*/
|
|
1142
1085
|
function translateElemValue(elem, translate) {
|
|
1143
1086
|
if (!elem.innerText) {
|
|
@@ -1168,8 +1111,10 @@ function translateElemValue(elem, translate) {
|
|
|
1168
1111
|
}
|
|
1169
1112
|
/**
|
|
1170
1113
|
* Helper function for 'translateHTMLTemplate'. Goes deep through html tag children and calls function to translate their text values.
|
|
1171
|
-
*
|
|
1172
|
-
* @param {
|
|
1114
|
+
*
|
|
1115
|
+
* @param {HTMLElement} tag
|
|
1116
|
+
* @param {Function} translate
|
|
1117
|
+
*
|
|
1173
1118
|
* @returns {void}
|
|
1174
1119
|
*/
|
|
1175
1120
|
function translateDeepTag(tag, translate) {
|
|
@@ -1185,9 +1130,12 @@ function translateDeepTag(tag, translate) {
|
|
|
1185
1130
|
}
|
|
1186
1131
|
/**
|
|
1187
1132
|
* Translates text values in html template.
|
|
1188
|
-
*
|
|
1189
|
-
* @param {
|
|
1190
|
-
* @
|
|
1133
|
+
*
|
|
1134
|
+
* @param {String} template
|
|
1135
|
+
* @param {Function} translate
|
|
1136
|
+
*
|
|
1137
|
+
* @returns {String}
|
|
1138
|
+
* Html template with translated values.
|
|
1191
1139
|
*/
|
|
1192
1140
|
export function translateHTMLTemplate(template, translate) {
|
|
1193
1141
|
const isHTML = /<[^>]*>/.test(template);
|
|
@@ -1204,9 +1152,9 @@ export function translateHTMLTemplate(template, translate) {
|
|
|
1204
1152
|
}
|
|
1205
1153
|
/**
|
|
1206
1154
|
* Sanitize an html string.
|
|
1207
|
-
*
|
|
1208
|
-
* @param
|
|
1209
|
-
* @returns {
|
|
1155
|
+
*
|
|
1156
|
+
* @param string
|
|
1157
|
+
* @returns {*}
|
|
1210
1158
|
*/
|
|
1211
1159
|
export function sanitize(string, options) {
|
|
1212
1160
|
if (typeof dompurify.sanitize !== 'function') {
|
|
@@ -1254,18 +1202,11 @@ export function sanitize(string, options) {
|
|
|
1254
1202
|
}
|
|
1255
1203
|
/**
|
|
1256
1204
|
* Fast cloneDeep for JSON objects only.
|
|
1257
|
-
* @param {any} obj - The object to perform a fast clone deep against.
|
|
1258
|
-
* @returns {any} - The cloned object.
|
|
1259
1205
|
*/
|
|
1260
1206
|
export function fastCloneDeep(obj) {
|
|
1261
1207
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
|
1262
1208
|
}
|
|
1263
1209
|
export { Evaluator, interpolate };
|
|
1264
|
-
/**
|
|
1265
|
-
* Returns if the component is an input component.
|
|
1266
|
-
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
1267
|
-
* @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
|
|
1268
|
-
*/
|
|
1269
1210
|
export function isInputComponent(componentJson) {
|
|
1270
1211
|
if (componentJson.input === false || componentJson.input === true) {
|
|
1271
1212
|
return componentJson.input;
|
|
@@ -1285,11 +1226,6 @@ export function isInputComponent(componentJson) {
|
|
|
1285
1226
|
return true;
|
|
1286
1227
|
}
|
|
1287
1228
|
}
|
|
1288
|
-
/**
|
|
1289
|
-
* Takes a component path, and returns a component path array.
|
|
1290
|
-
* @param {string} pathStr - The path string to convert to an array.
|
|
1291
|
-
* @returns {Arryay<number>} - The array of paths.
|
|
1292
|
-
*/
|
|
1293
1229
|
export function getArrayFromComponentPath(pathStr) {
|
|
1294
1230
|
if (!pathStr || !_.isString(pathStr)) {
|
|
1295
1231
|
if (!_.isArray(pathStr)) {
|
|
@@ -1303,12 +1239,6 @@ export function getArrayFromComponentPath(pathStr) {
|
|
|
1303
1239
|
.split('.')
|
|
1304
1240
|
.map(part => _.defaultTo(_.toNumber(part), part));
|
|
1305
1241
|
}
|
|
1306
|
-
/**
|
|
1307
|
-
* Returns true if the component is a child of the parent.
|
|
1308
|
-
* @param {any} child - The child component to check.
|
|
1309
|
-
* @param {any} parent - The parent component to check.
|
|
1310
|
-
* @returns {boolean} - TRUE if the child is a child of the parent; FALSE otherwise.
|
|
1311
|
-
*/
|
|
1312
1242
|
export function isChildOf(child, parent) {
|
|
1313
1243
|
while (child && child.parent) {
|
|
1314
1244
|
if (child.parent === parent) {
|
|
@@ -1318,11 +1248,6 @@ export function isChildOf(child, parent) {
|
|
|
1318
1248
|
}
|
|
1319
1249
|
return false;
|
|
1320
1250
|
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Takes an array of component path indexes, and returns a string version of that array.
|
|
1323
|
-
* @param {Array<number>} path - The path array to convert to a string.
|
|
1324
|
-
* @returns {string} - The string version of the path.
|
|
1325
|
-
*/
|
|
1326
1251
|
export function getStringFromComponentPath(path) {
|
|
1327
1252
|
if (!_.isArray(path)) {
|
|
1328
1253
|
return path;
|
|
@@ -1338,21 +1263,16 @@ export function getStringFromComponentPath(path) {
|
|
|
1338
1263
|
});
|
|
1339
1264
|
return strPath;
|
|
1340
1265
|
}
|
|
1341
|
-
/**
|
|
1342
|
-
* Takes a number and rounds it to the provided precision amount.
|
|
1343
|
-
* @param {number} number - The number to round.
|
|
1344
|
-
* @param {number} precision - The precision to round the number to.
|
|
1345
|
-
* @returns {string} - The rounded number.
|
|
1346
|
-
*/
|
|
1347
1266
|
export function round(number, precision) {
|
|
1348
1267
|
if (_.isNumber(number)) {
|
|
1349
1268
|
return number.toFixed(precision);
|
|
1350
1269
|
}
|
|
1351
|
-
return number
|
|
1270
|
+
return number;
|
|
1352
1271
|
}
|
|
1353
1272
|
/**
|
|
1354
1273
|
* Check for Internet Explorer browser version
|
|
1355
|
-
*
|
|
1274
|
+
*
|
|
1275
|
+
* @return {(number|null)}
|
|
1356
1276
|
*/
|
|
1357
1277
|
export function getIEBrowserVersion() {
|
|
1358
1278
|
const { ie, version } = getBrowserInfo();
|
|
@@ -1360,7 +1280,8 @@ export function getIEBrowserVersion() {
|
|
|
1360
1280
|
}
|
|
1361
1281
|
/**
|
|
1362
1282
|
* Get browser name and version (modified from 'jquery-browser-plugin')
|
|
1363
|
-
*
|
|
1283
|
+
*
|
|
1284
|
+
* @return {Object} -- {{browser name, version, isWebkit?}}
|
|
1364
1285
|
* Possible browser names: chrome, safari, ie, edge, opera, mozilla, yabrowser
|
|
1365
1286
|
*/
|
|
1366
1287
|
export function getBrowserInfo() {
|
|
@@ -1408,19 +1329,12 @@ export function getBrowserInfo() {
|
|
|
1408
1329
|
}
|
|
1409
1330
|
return browser;
|
|
1410
1331
|
}
|
|
1411
|
-
/**
|
|
1412
|
-
* Takes a component path, which may include array indicies (i.e. [0][1]), and returns the compoennt path without the indicies.
|
|
1413
|
-
* @param {string} path - The path to remove the indicies from.
|
|
1414
|
-
* @returns {string} - The path without the indicies.
|
|
1415
|
-
*/
|
|
1416
1332
|
export function getComponentPathWithoutIndicies(path = '') {
|
|
1417
1333
|
return path.replace(/\[\d+\]/, '');
|
|
1418
1334
|
}
|
|
1419
1335
|
/**
|
|
1420
1336
|
* Returns a path to the component which based on its schema
|
|
1421
|
-
* @param {
|
|
1422
|
-
* @param {string} path - Path to the component
|
|
1423
|
-
* @returns {string} - Path to the component
|
|
1337
|
+
* @param {*} component is a component's schema containing link to its parent's schema in the 'parent' property
|
|
1424
1338
|
*/
|
|
1425
1339
|
export function getComponentPath(component, path = '') {
|
|
1426
1340
|
if (!component || !component.key || component?._form?.display === 'wizard') { // unlike the Webform, the Wizard has the key and it is a duplicate of the panel key
|
|
@@ -1431,8 +1345,8 @@ export function getComponentPath(component, path = '') {
|
|
|
1431
1345
|
}
|
|
1432
1346
|
/**
|
|
1433
1347
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
1434
|
-
* @param {
|
|
1435
|
-
* @
|
|
1348
|
+
* @param {*} componentInstance
|
|
1349
|
+
* @return {(Component|undefined)}
|
|
1436
1350
|
*/
|
|
1437
1351
|
export function getDataParentComponent(componentInstance) {
|
|
1438
1352
|
if (!componentInstance) {
|
|
@@ -1448,8 +1362,8 @@ export function getDataParentComponent(componentInstance) {
|
|
|
1448
1362
|
}
|
|
1449
1363
|
/**
|
|
1450
1364
|
* Returns whether the value is a promise
|
|
1451
|
-
* @param
|
|
1452
|
-
* @
|
|
1365
|
+
* @param value
|
|
1366
|
+
* @return {boolean}
|
|
1453
1367
|
*/
|
|
1454
1368
|
export function isPromise(value) {
|
|
1455
1369
|
return value
|
|
@@ -1460,9 +1374,9 @@ export function isPromise(value) {
|
|
|
1460
1374
|
/**
|
|
1461
1375
|
* Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
|
|
1462
1376
|
* changes by itself, e.g. EditGrid)
|
|
1463
|
-
* @param
|
|
1464
|
-
* @param
|
|
1465
|
-
* @returns {boolean|*}
|
|
1377
|
+
* @param componentInstance
|
|
1378
|
+
* @param firstPass
|
|
1379
|
+
* @returns {boolean|boolean|*}
|
|
1466
1380
|
*/
|
|
1467
1381
|
export function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
1468
1382
|
if (!firstPass && componentInstance?.hasScopedChildren) {
|
|
@@ -1477,11 +1391,6 @@ export function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
|
1477
1391
|
}
|
|
1478
1392
|
return false;
|
|
1479
1393
|
}
|
|
1480
|
-
/**
|
|
1481
|
-
* Returns all the focusable elements within the provided dom element.
|
|
1482
|
-
* @param {HTMLElement} element - The element to get the focusable elements from.
|
|
1483
|
-
* @returns {NodeList<HTMLElement>} - The focusable elements within the provided element.
|
|
1484
|
-
*/
|
|
1485
1394
|
export function getFocusableElements(element) {
|
|
1486
1395
|
const focusableSelector = `button:not([disabled]), input:not([disabled]), select:not([disabled]),
|
|
1487
1396
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
|
@@ -1498,11 +1407,6 @@ export const componentValueTypes = {
|
|
|
1498
1407
|
date: 'date',
|
|
1499
1408
|
any: 'any',
|
|
1500
1409
|
};
|
|
1501
|
-
/**
|
|
1502
|
-
* Returns the saved types for the component
|
|
1503
|
-
* @param {import('@formio/core').Component} fullSchema - The component schema
|
|
1504
|
-
* @returns {Array<string>|null} - The saved types for the component
|
|
1505
|
-
*/
|
|
1506
1410
|
export function getComponentSavedTypes(fullSchema) {
|
|
1507
1411
|
const schema = fullSchema || {};
|
|
1508
1412
|
if (schema.persistent !== true) {
|
|
@@ -1515,10 +1419,9 @@ export function getComponentSavedTypes(fullSchema) {
|
|
|
1515
1419
|
}
|
|
1516
1420
|
/**
|
|
1517
1421
|
* Interpolates @formio/core errors so that they are compatible with the renderer
|
|
1518
|
-
* @param {
|
|
1519
|
-
* @param
|
|
1520
|
-
* @
|
|
1521
|
-
* @returns {[]} - The interpolated errors
|
|
1422
|
+
* @param {FieldError[]} errors
|
|
1423
|
+
* @param firstPass
|
|
1424
|
+
* @returns {[]}
|
|
1522
1425
|
*/
|
|
1523
1426
|
export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1524
1427
|
return errors.map((error) => {
|
|
@@ -1528,11 +1431,6 @@ export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1528
1431
|
return { ...error, message: unescapeHTML(interpolateFn(toInterpolate, context)), context: { ...context } };
|
|
1529
1432
|
});
|
|
1530
1433
|
};
|
|
1531
|
-
/**
|
|
1532
|
-
* Returns the template keys inside the template code.
|
|
1533
|
-
* @param {string} template - The template to get the keys from.
|
|
1534
|
-
* @returns {Array<string>} - The keys inside the template.
|
|
1535
|
-
*/
|
|
1536
1434
|
export function getItemTemplateKeys(template) {
|
|
1537
1435
|
const templateKeys = [];
|
|
1538
1436
|
if (!template) {
|
|
@@ -1549,11 +1447,6 @@ export function getItemTemplateKeys(template) {
|
|
|
1549
1447
|
}
|
|
1550
1448
|
return templateKeys;
|
|
1551
1449
|
}
|
|
1552
|
-
/**
|
|
1553
|
-
* Returns if the component is a select resource with an object for its value.
|
|
1554
|
-
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1555
|
-
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1556
|
-
*/
|
|
1557
1450
|
export function isSelectResourceWithObjectValue(comp = {}) {
|
|
1558
1451
|
const { reference, dataSrc, valueProperty } = comp;
|
|
1559
1452
|
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|