@formio/js 5.0.0-dev.5610.c46fab6 → 5.0.0-dev.5613.3476921
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +1199 -651
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +11 -3
- package/dist/formio.full.js +919 -691
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +11 -3
- package/dist/formio.js +16 -16
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +493 -1861
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -12
- package/lib/cjs/Element.d.ts +96 -86
- package/lib/cjs/Element.js +78 -68
- package/lib/cjs/Form.d.ts +36 -365
- package/lib/cjs/Form.js +64 -50
- package/lib/cjs/FormBuilder.d.ts +2 -187
- package/lib/cjs/FormBuilder.js +8 -30
- package/lib/cjs/PDF.d.ts +13 -11
- package/lib/cjs/PDF.js +8 -6
- package/lib/cjs/Webform.d.ts +139 -180
- package/lib/cjs/Webform.js +298 -313
- package/lib/cjs/WebformBuilder.d.ts +14 -16
- package/lib/cjs/WebformBuilder.js +11 -17
- package/lib/cjs/Wizard.d.ts +21 -31
- package/lib/cjs/Wizard.js +19 -42
- package/lib/cjs/WizardBuilder.d.ts +1 -1
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +5 -8
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -6
- package/lib/cjs/components/Components.d.ts +4 -4
- package/lib/cjs/components/Components.js +3 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +269 -502
- package/lib/cjs/components/_classes/component/Component.form.d.ts +3 -6
- package/lib/cjs/components/_classes/component/Component.form.js +0 -5
- package/lib/cjs/components/_classes/component/Component.js +189 -433
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +2 -2
- package/lib/cjs/components/_classes/component/editForm/utils.js +2 -2
- package/lib/cjs/components/_classes/field/Field.d.ts +2 -11
- package/lib/cjs/components/_classes/field/Field.js +1 -13
- package/lib/cjs/components/_classes/input/Input.d.ts +3 -4
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.form.d.ts +3 -6
- package/lib/cjs/components/_classes/list/ListComponent.form.js +0 -5
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +12 -43
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +3 -37
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +67 -163
- package/lib/cjs/components/_classes/nested/NestedComponent.form.d.ts +3 -6
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +0 -5
- package/lib/cjs/components/_classes/nested/NestedComponent.js +54 -175
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -7
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +3 -2
- package/lib/cjs/components/address/Address.d.ts +2 -4
- package/lib/cjs/components/address/Address.form.d.ts +3 -6
- package/lib/cjs/components/address/Address.form.js +0 -5
- package/lib/cjs/components/button/Button.d.ts +12 -3
- package/lib/cjs/components/button/Button.form.d.ts +3 -6
- package/lib/cjs/components/button/Button.form.js +0 -5
- package/lib/cjs/components/button/Button.js +0 -5
- package/lib/cjs/components/checkbox/Checkbox.d.ts +27 -4
- package/lib/cjs/components/checkbox/Checkbox.form.d.ts +3 -6
- package/lib/cjs/components/checkbox/Checkbox.form.js +0 -5
- package/lib/cjs/components/columns/Columns.d.ts +2 -3
- package/lib/cjs/components/columns/Columns.form.d.ts +3 -6
- package/lib/cjs/components/columns/Columns.form.js +0 -5
- package/lib/cjs/components/columns/Columns.js +1 -1
- package/lib/cjs/components/container/Container.form.d.ts +3 -6
- package/lib/cjs/components/container/Container.form.js +0 -5
- package/lib/cjs/components/content/Content.d.ts +1 -2
- package/lib/cjs/components/content/Content.form.d.ts +3 -6
- package/lib/cjs/components/content/Content.form.js +0 -5
- package/lib/cjs/components/currency/Currency.form.d.ts +3 -6
- package/lib/cjs/components/currency/Currency.form.js +0 -5
- package/lib/cjs/components/currency/Currency.js +2 -1
- package/lib/cjs/components/datagrid/DataGrid.d.ts +7 -8
- package/lib/cjs/components/datagrid/DataGrid.form.d.ts +3 -6
- package/lib/cjs/components/datagrid/DataGrid.form.js +0 -5
- package/lib/cjs/components/datagrid/DataGrid.js +5 -5
- package/lib/cjs/components/datamap/DataMap.d.ts +0 -1
- package/lib/cjs/components/datamap/DataMap.form.d.ts +3 -6
- package/lib/cjs/components/datamap/DataMap.form.js +0 -5
- package/lib/cjs/components/datetime/DateTime.d.ts +14 -0
- package/lib/cjs/components/datetime/DateTime.form.d.ts +3 -6
- package/lib/cjs/components/datetime/DateTime.form.js +0 -5
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +2 -2
- package/lib/cjs/components/day/Day.d.ts +48 -22
- package/lib/cjs/components/day/Day.form.d.ts +3 -6
- package/lib/cjs/components/day/Day.form.js +0 -5
- package/lib/cjs/components/day/Day.js +20 -15
- package/lib/cjs/components/editgrid/EditGrid.d.ts +3 -7
- package/lib/cjs/components/editgrid/EditGrid.form.d.ts +3 -6
- package/lib/cjs/components/editgrid/EditGrid.form.js +0 -5
- package/lib/cjs/components/editgrid/EditGrid.js +3 -3
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +5 -2
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.js +9 -6
- package/lib/cjs/components/email/Email.form.d.ts +3 -6
- package/lib/cjs/components/email/Email.form.js +0 -5
- package/lib/cjs/components/fieldset/Fieldset.form.d.ts +3 -6
- package/lib/cjs/components/fieldset/Fieldset.form.js +0 -5
- package/lib/cjs/components/file/File.d.ts +22 -9
- package/lib/cjs/components/file/File.form.d.ts +3 -6
- package/lib/cjs/components/file/File.form.js +0 -5
- package/lib/cjs/components/form/Form.d.ts +20 -31
- package/lib/cjs/components/form/Form.form.d.ts +3 -6
- package/lib/cjs/components/form/Form.form.js +0 -5
- package/lib/cjs/components/form/Form.js +10 -13
- package/lib/cjs/components/hidden/Hidden.d.ts +11 -1
- package/lib/cjs/components/hidden/Hidden.form.d.ts +3 -6
- package/lib/cjs/components/hidden/Hidden.form.js +0 -5
- package/lib/cjs/components/hidden/Hidden.js +2 -1
- package/lib/cjs/components/html/HTML.d.ts +1 -2
- package/lib/cjs/components/html/HTML.form.d.ts +3 -6
- package/lib/cjs/components/html/HTML.form.js +0 -5
- package/lib/cjs/components/number/Number.d.ts +17 -3
- package/lib/cjs/components/number/Number.form.d.ts +3 -6
- package/lib/cjs/components/number/Number.form.js +0 -5
- package/lib/cjs/components/number/Number.js +2 -1
- package/lib/cjs/components/panel/Panel.form.d.ts +3 -6
- package/lib/cjs/components/panel/Panel.form.js +0 -5
- package/lib/cjs/components/panel/Panel.js +1 -0
- package/lib/cjs/components/password/Password.form.d.ts +3 -6
- package/lib/cjs/components/password/Password.form.js +0 -5
- package/lib/cjs/components/phonenumber/PhoneNumber.form.d.ts +3 -6
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +0 -5
- package/lib/cjs/components/radio/Radio.d.ts +26 -3
- package/lib/cjs/components/radio/Radio.form.d.ts +3 -6
- package/lib/cjs/components/radio/Radio.form.js +0 -5
- package/lib/cjs/components/radio/Radio.js +4 -3
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +3 -5
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +0 -4
- package/lib/cjs/components/select/Select.d.ts +39 -16
- package/lib/cjs/components/select/Select.form.d.ts +3 -6
- package/lib/cjs/components/select/Select.form.js +0 -5
- package/lib/cjs/components/select/Select.js +16 -13
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +17 -2
- package/lib/cjs/components/selectboxes/SelectBoxes.form.d.ts +3 -6
- package/lib/cjs/components/selectboxes/SelectBoxes.form.js +0 -5
- package/lib/cjs/components/selectboxes/SelectBoxes.js +9 -7
- package/lib/cjs/components/signature/Signature.d.ts +14 -1
- package/lib/cjs/components/signature/Signature.form.d.ts +3 -6
- package/lib/cjs/components/signature/Signature.form.js +0 -5
- package/lib/cjs/components/survey/Survey.d.ts +15 -3
- package/lib/cjs/components/survey/Survey.form.d.ts +3 -6
- package/lib/cjs/components/survey/Survey.form.js +0 -5
- package/lib/cjs/components/table/Table.d.ts +1 -2
- package/lib/cjs/components/table/Table.form.d.ts +3 -6
- package/lib/cjs/components/table/Table.form.js +0 -5
- package/lib/cjs/components/tabs/Tabs.d.ts +4 -4
- package/lib/cjs/components/tabs/Tabs.form.d.ts +3 -6
- package/lib/cjs/components/tabs/Tabs.form.js +0 -5
- package/lib/cjs/components/tabs/Tabs.js +2 -1
- package/lib/cjs/components/tags/Tags.d.ts +14 -0
- package/lib/cjs/components/tags/Tags.form.d.ts +3 -6
- package/lib/cjs/components/tags/Tags.form.js +0 -5
- package/lib/cjs/components/textarea/TextArea.d.ts +9 -4
- package/lib/cjs/components/textarea/TextArea.form.d.ts +3 -6
- package/lib/cjs/components/textarea/TextArea.form.js +0 -5
- package/lib/cjs/components/textarea/TextArea.js +2 -2
- package/lib/cjs/components/textfield/TextField.d.ts +30 -14
- package/lib/cjs/components/textfield/TextField.form.d.ts +3 -6
- package/lib/cjs/components/textfield/TextField.form.js +0 -5
- package/lib/cjs/components/textfield/TextField.js +16 -13
- package/lib/cjs/components/time/Time.form.d.ts +3 -6
- package/lib/cjs/components/time/Time.form.js +0 -5
- package/lib/cjs/components/unknown/Unknown.form.d.ts +34 -5
- package/lib/cjs/components/unknown/Unknown.form.js +0 -4
- package/lib/cjs/components/url/Url.form.d.ts +3 -6
- package/lib/cjs/components/url/Url.form.js +0 -5
- package/lib/cjs/components/well/Well.form.d.ts +3 -6
- package/lib/cjs/components/well/Well.form.js +0 -5
- package/lib/cjs/formio.embed.d.ts +2 -1
- package/lib/cjs/formio.embed.js +100 -2
- package/lib/cjs/formio.form.d.ts +4 -11
- package/lib/cjs/formio.form.js +5 -13
- package/lib/cjs/providers/Providers.d.ts +5 -36
- package/lib/cjs/providers/Providers.js +0 -29
- package/lib/cjs/providers/address/AddressProvider.d.ts +12 -131
- package/lib/cjs/providers/address/AddressProvider.js +2 -88
- package/lib/cjs/providers/address/AzureAddressProvider.d.ts +1 -48
- package/lib/cjs/providers/address/AzureAddressProvider.js +0 -37
- package/lib/cjs/providers/address/CustomAddressProvider.d.ts +4 -27
- package/lib/cjs/providers/address/CustomAddressProvider.js +0 -34
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +6 -130
- package/lib/cjs/providers/address/GoogleAddressProvider.js +0 -72
- package/lib/cjs/providers/address/NominatimAddressProvider.d.ts +7 -32
- package/lib/cjs/providers/address/NominatimAddressProvider.js +0 -33
- package/lib/cjs/providers/address/index.d.ts +1 -3
- package/lib/cjs/providers/processor/fileProcessor.d.ts +1 -7
- package/lib/cjs/providers/processor/fileProcessor.js +0 -6
- package/lib/cjs/providers/storage/azure.d.ts +13 -6
- package/lib/cjs/providers/storage/azure.js +0 -5
- package/lib/cjs/providers/storage/base64.d.ts +6 -5
- package/lib/cjs/providers/storage/base64.js +0 -4
- package/lib/cjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/cjs/providers/storage/dropbox.js +0 -5
- package/lib/cjs/providers/storage/googleDrive.d.ts +5 -7
- package/lib/cjs/providers/storage/googleDrive.js +0 -6
- package/lib/cjs/providers/storage/indexeddb.d.ts +7 -5
- package/lib/cjs/providers/storage/indexeddb.js +0 -4
- package/lib/cjs/providers/storage/s3.d.ts +20 -6
- package/lib/cjs/providers/storage/s3.js +0 -5
- package/lib/cjs/providers/storage/url.d.ts +7 -6
- package/lib/cjs/providers/storage/url.js +0 -10
- package/lib/cjs/providers/storage/util.d.ts +1 -24
- package/lib/cjs/providers/storage/util.js +0 -18
- package/lib/cjs/templates/Templates.d.ts +0 -1
- package/lib/cjs/translations/en.d.ts +1 -0
- package/lib/cjs/translations/en.js +1 -0
- package/lib/cjs/utils/Evaluator.d.ts +3 -6
- package/lib/cjs/utils/Evaluator.js +20 -11
- package/lib/cjs/utils/builder.d.ts +7 -9
- package/lib/cjs/utils/builder.js +5 -10
- package/lib/cjs/utils/calendarUtils.d.ts +13 -7
- package/lib/cjs/utils/calendarUtils.js +17 -10
- package/lib/cjs/utils/formUtils.d.ts +171 -43
- package/lib/cjs/utils/formUtils.js +569 -38
- package/lib/cjs/utils/utils.d.ts +216 -362
- package/lib/cjs/utils/utils.js +224 -331
- package/lib/cjs/widgets/CalendarWidget.d.ts +10 -9
- package/lib/cjs/widgets/CalendarWidget.js +11 -9
- package/lib/mjs/Element.d.ts +96 -86
- package/lib/mjs/Element.js +78 -68
- package/lib/mjs/Form.d.ts +36 -365
- package/lib/mjs/Form.js +57 -140
- package/lib/mjs/FormBuilder.d.ts +2 -187
- package/lib/mjs/FormBuilder.js +8 -32
- package/lib/mjs/PDF.d.ts +13 -11
- package/lib/mjs/PDF.js +8 -6
- package/lib/mjs/Webform.d.ts +139 -180
- package/lib/mjs/Webform.js +310 -325
- package/lib/mjs/WebformBuilder.d.ts +14 -16
- package/lib/mjs/WebformBuilder.js +11 -16
- package/lib/mjs/Wizard.d.ts +21 -31
- package/lib/mjs/Wizard.js +18 -41
- package/lib/mjs/WizardBuilder.d.ts +1 -1
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +5 -8
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +3 -6
- package/lib/mjs/components/Components.d.ts +4 -4
- package/lib/mjs/components/Components.js +3 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +269 -502
- package/lib/mjs/components/_classes/component/Component.form.d.ts +3 -6
- package/lib/mjs/components/_classes/component/Component.form.js +0 -5
- package/lib/mjs/components/_classes/component/Component.js +189 -433
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +8 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/mjs/components/_classes/field/Field.d.ts +2 -11
- package/lib/mjs/components/_classes/field/Field.js +1 -13
- package/lib/mjs/components/_classes/input/Input.d.ts +3 -4
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.form.d.ts +3 -6
- package/lib/mjs/components/_classes/list/ListComponent.form.js +0 -5
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +12 -43
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +3 -37
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +67 -163
- package/lib/mjs/components/_classes/nested/NestedComponent.form.d.ts +3 -6
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +0 -5
- package/lib/mjs/components/_classes/nested/NestedComponent.js +54 -175
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -7
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +3 -2
- package/lib/mjs/components/address/Address.d.ts +2 -4
- package/lib/mjs/components/address/Address.form.d.ts +3 -6
- package/lib/mjs/components/address/Address.form.js +0 -5
- package/lib/mjs/components/button/Button.d.ts +12 -3
- package/lib/mjs/components/button/Button.form.d.ts +3 -6
- package/lib/mjs/components/button/Button.form.js +0 -5
- package/lib/mjs/components/button/Button.js +0 -5
- package/lib/mjs/components/checkbox/Checkbox.d.ts +27 -4
- package/lib/mjs/components/checkbox/Checkbox.form.d.ts +3 -6
- package/lib/mjs/components/checkbox/Checkbox.form.js +0 -5
- package/lib/mjs/components/columns/Columns.d.ts +2 -3
- package/lib/mjs/components/columns/Columns.form.d.ts +3 -6
- package/lib/mjs/components/columns/Columns.form.js +0 -5
- package/lib/mjs/components/columns/Columns.js +1 -1
- package/lib/mjs/components/container/Container.form.d.ts +3 -6
- package/lib/mjs/components/container/Container.form.js +0 -5
- package/lib/mjs/components/content/Content.d.ts +1 -2
- package/lib/mjs/components/content/Content.form.d.ts +3 -6
- package/lib/mjs/components/content/Content.form.js +0 -5
- package/lib/mjs/components/currency/Currency.form.d.ts +3 -6
- package/lib/mjs/components/currency/Currency.form.js +0 -5
- package/lib/mjs/components/currency/Currency.js +2 -1
- package/lib/mjs/components/datagrid/DataGrid.d.ts +7 -8
- package/lib/mjs/components/datagrid/DataGrid.form.d.ts +3 -6
- package/lib/mjs/components/datagrid/DataGrid.form.js +0 -5
- package/lib/mjs/components/datagrid/DataGrid.js +5 -5
- package/lib/mjs/components/datamap/DataMap.d.ts +0 -1
- package/lib/mjs/components/datamap/DataMap.form.d.ts +3 -6
- package/lib/mjs/components/datamap/DataMap.form.js +0 -5
- package/lib/mjs/components/datetime/DateTime.d.ts +14 -0
- package/lib/mjs/components/datetime/DateTime.form.d.ts +3 -6
- package/lib/mjs/components/datetime/DateTime.form.js +0 -5
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +1 -1
- package/lib/mjs/components/day/Day.d.ts +48 -22
- package/lib/mjs/components/day/Day.form.d.ts +3 -6
- package/lib/mjs/components/day/Day.form.js +0 -5
- package/lib/mjs/components/day/Day.js +20 -15
- package/lib/mjs/components/editgrid/EditGrid.d.ts +3 -7
- package/lib/mjs/components/editgrid/EditGrid.form.d.ts +3 -6
- package/lib/mjs/components/editgrid/EditGrid.form.js +0 -5
- package/lib/mjs/components/editgrid/EditGrid.js +3 -3
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +1 -1
- package/lib/mjs/components/email/Email.form.d.ts +3 -6
- package/lib/mjs/components/email/Email.form.js +0 -5
- package/lib/mjs/components/fieldset/Fieldset.form.d.ts +3 -6
- package/lib/mjs/components/fieldset/Fieldset.form.js +0 -5
- package/lib/mjs/components/file/File.d.ts +22 -9
- package/lib/mjs/components/file/File.form.d.ts +3 -6
- package/lib/mjs/components/file/File.form.js +0 -5
- package/lib/mjs/components/form/Form.d.ts +20 -31
- package/lib/mjs/components/form/Form.form.d.ts +3 -6
- package/lib/mjs/components/form/Form.form.js +0 -5
- package/lib/mjs/components/form/Form.js +10 -13
- package/lib/mjs/components/hidden/Hidden.d.ts +11 -1
- package/lib/mjs/components/hidden/Hidden.form.d.ts +3 -6
- package/lib/mjs/components/hidden/Hidden.form.js +0 -5
- package/lib/mjs/components/hidden/Hidden.js +2 -1
- package/lib/mjs/components/html/HTML.d.ts +1 -2
- package/lib/mjs/components/html/HTML.form.d.ts +3 -6
- package/lib/mjs/components/html/HTML.form.js +0 -5
- package/lib/mjs/components/number/Number.d.ts +17 -3
- package/lib/mjs/components/number/Number.form.d.ts +3 -6
- package/lib/mjs/components/number/Number.form.js +0 -5
- package/lib/mjs/components/number/Number.js +2 -1
- package/lib/mjs/components/panel/Panel.form.d.ts +3 -6
- package/lib/mjs/components/panel/Panel.form.js +0 -5
- package/lib/mjs/components/panel/Panel.js +1 -0
- package/lib/mjs/components/password/Password.form.d.ts +3 -6
- package/lib/mjs/components/password/Password.form.js +0 -5
- package/lib/mjs/components/phonenumber/PhoneNumber.form.d.ts +3 -6
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +0 -5
- package/lib/mjs/components/radio/Radio.d.ts +26 -3
- package/lib/mjs/components/radio/Radio.form.d.ts +3 -6
- package/lib/mjs/components/radio/Radio.form.js +0 -5
- package/lib/mjs/components/radio/Radio.js +4 -3
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +3 -5
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +0 -4
- package/lib/mjs/components/select/Select.d.ts +39 -16
- package/lib/mjs/components/select/Select.form.d.ts +3 -6
- package/lib/mjs/components/select/Select.form.js +0 -5
- package/lib/mjs/components/select/Select.js +16 -13
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +17 -2
- package/lib/mjs/components/selectboxes/SelectBoxes.form.d.ts +3 -6
- package/lib/mjs/components/selectboxes/SelectBoxes.form.js +0 -5
- package/lib/mjs/components/selectboxes/SelectBoxes.js +9 -7
- package/lib/mjs/components/signature/Signature.d.ts +14 -1
- package/lib/mjs/components/signature/Signature.form.d.ts +3 -6
- package/lib/mjs/components/signature/Signature.form.js +0 -5
- package/lib/mjs/components/survey/Survey.d.ts +15 -3
- package/lib/mjs/components/survey/Survey.form.d.ts +3 -6
- package/lib/mjs/components/survey/Survey.form.js +0 -5
- package/lib/mjs/components/table/Table.d.ts +1 -2
- package/lib/mjs/components/table/Table.form.d.ts +3 -6
- package/lib/mjs/components/table/Table.form.js +0 -5
- package/lib/mjs/components/tabs/Tabs.d.ts +4 -4
- package/lib/mjs/components/tabs/Tabs.form.d.ts +3 -6
- package/lib/mjs/components/tabs/Tabs.form.js +0 -5
- package/lib/mjs/components/tabs/Tabs.js +2 -1
- package/lib/mjs/components/tags/Tags.d.ts +14 -0
- package/lib/mjs/components/tags/Tags.form.d.ts +3 -6
- package/lib/mjs/components/tags/Tags.form.js +0 -5
- package/lib/mjs/components/textarea/TextArea.d.ts +9 -4
- package/lib/mjs/components/textarea/TextArea.form.d.ts +3 -6
- package/lib/mjs/components/textarea/TextArea.form.js +0 -5
- package/lib/mjs/components/textarea/TextArea.js +2 -2
- package/lib/mjs/components/textfield/TextField.d.ts +30 -14
- package/lib/mjs/components/textfield/TextField.form.d.ts +3 -6
- package/lib/mjs/components/textfield/TextField.form.js +0 -5
- package/lib/mjs/components/textfield/TextField.js +16 -13
- package/lib/mjs/components/time/Time.form.d.ts +3 -6
- package/lib/mjs/components/time/Time.form.js +0 -5
- package/lib/mjs/components/unknown/Unknown.form.d.ts +34 -5
- package/lib/mjs/components/unknown/Unknown.form.js +0 -4
- package/lib/mjs/components/url/Url.form.d.ts +3 -6
- package/lib/mjs/components/url/Url.form.js +0 -5
- package/lib/mjs/components/well/Well.form.d.ts +3 -6
- package/lib/mjs/components/well/Well.form.js +0 -5
- package/lib/mjs/formio.embed.d.ts +2 -1
- package/lib/mjs/formio.embed.js +99 -2
- package/lib/mjs/formio.form.d.ts +4 -11
- package/lib/mjs/formio.form.js +3 -10
- package/lib/mjs/providers/Providers.d.ts +5 -36
- package/lib/mjs/providers/Providers.js +0 -29
- package/lib/mjs/providers/address/AddressProvider.d.ts +12 -131
- package/lib/mjs/providers/address/AddressProvider.js +2 -88
- package/lib/mjs/providers/address/AzureAddressProvider.d.ts +1 -48
- package/lib/mjs/providers/address/AzureAddressProvider.js +0 -37
- package/lib/mjs/providers/address/CustomAddressProvider.d.ts +4 -27
- package/lib/mjs/providers/address/CustomAddressProvider.js +0 -34
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +6 -130
- package/lib/mjs/providers/address/GoogleAddressProvider.js +0 -72
- package/lib/mjs/providers/address/NominatimAddressProvider.d.ts +7 -32
- package/lib/mjs/providers/address/NominatimAddressProvider.js +0 -33
- package/lib/mjs/providers/address/index.d.ts +1 -3
- package/lib/mjs/providers/processor/fileProcessor.d.ts +1 -7
- package/lib/mjs/providers/processor/fileProcessor.js +0 -6
- package/lib/mjs/providers/storage/azure.d.ts +13 -6
- package/lib/mjs/providers/storage/azure.js +0 -5
- package/lib/mjs/providers/storage/base64.d.ts +6 -5
- package/lib/mjs/providers/storage/base64.js +0 -4
- package/lib/mjs/providers/storage/dropbox.d.ts +4 -6
- package/lib/mjs/providers/storage/dropbox.js +0 -5
- package/lib/mjs/providers/storage/googleDrive.d.ts +5 -7
- package/lib/mjs/providers/storage/googleDrive.js +0 -6
- package/lib/mjs/providers/storage/indexeddb.d.ts +7 -5
- package/lib/mjs/providers/storage/indexeddb.js +0 -4
- package/lib/mjs/providers/storage/s3.d.ts +20 -6
- package/lib/mjs/providers/storage/s3.js +0 -5
- package/lib/mjs/providers/storage/url.d.ts +7 -6
- package/lib/mjs/providers/storage/url.js +0 -10
- package/lib/mjs/providers/storage/util.d.ts +1 -24
- package/lib/mjs/providers/storage/util.js +0 -18
- package/lib/mjs/templates/Templates.d.ts +0 -1
- package/lib/mjs/translations/en.d.ts +1 -0
- package/lib/mjs/translations/en.js +1 -0
- package/lib/mjs/utils/Evaluator.d.ts +3 -6
- package/lib/mjs/utils/Evaluator.js +20 -9
- package/lib/mjs/utils/builder.d.ts +7 -9
- package/lib/mjs/utils/builder.js +5 -10
- package/lib/mjs/utils/calendarUtils.d.ts +13 -7
- package/lib/mjs/utils/calendarUtils.js +17 -10
- package/lib/mjs/utils/formUtils.d.ts +171 -43
- package/lib/mjs/utils/formUtils.js +554 -6
- package/lib/mjs/utils/utils.d.ts +216 -362
- package/lib/mjs/utils/utils.js +218 -325
- package/lib/mjs/widgets/CalendarWidget.d.ts +10 -9
- package/lib/mjs/widgets/CalendarWidget.js +11 -9
- package/package.json +22 -22
- package/embed.d.ts +0 -1
- package/form.d.ts +0 -1
- package/lib/cjs/InlineEmbed.d.ts +0 -7
- package/lib/cjs/InlineEmbed.js +0 -109
- package/lib/mjs/InlineEmbed.d.ts +0 -7
- package/lib/mjs/InlineEmbed.js +0 -105
- package/sdk.d.ts +0 -1
- package/utils.d.ts +0 -1
package/lib/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,9 @@ export function getElementRect(element) {
|
|
|
87
133
|
}
|
|
88
134
|
/**
|
|
89
135
|
* Determines the boolean value of a setting.
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
136
|
+
*
|
|
137
|
+
* @param value
|
|
138
|
+
* @return {boolean}
|
|
92
139
|
*/
|
|
93
140
|
export function boolValue(value) {
|
|
94
141
|
if (_.isBoolean(value)) {
|
|
@@ -103,17 +150,21 @@ export function boolValue(value) {
|
|
|
103
150
|
}
|
|
104
151
|
/**
|
|
105
152
|
* Check to see if an ID is a mongoID.
|
|
106
|
-
* @param
|
|
107
|
-
* @
|
|
153
|
+
* @param text
|
|
154
|
+
* @return {Array|{index: number, input: string}|Boolean|*}
|
|
108
155
|
*/
|
|
109
156
|
export function isMongoId(text) {
|
|
110
|
-
return
|
|
157
|
+
return text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
111
158
|
}
|
|
112
159
|
/**
|
|
113
160
|
* Checks the calculated value for a provided component and data.
|
|
114
|
-
*
|
|
115
|
-
* @param {
|
|
116
|
-
*
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} component
|
|
163
|
+
* The component to check for the calculated value.
|
|
164
|
+
* @param {Object} submission
|
|
165
|
+
* A submission object.
|
|
166
|
+
* @param data
|
|
167
|
+
* The full submission data.
|
|
117
168
|
*/
|
|
118
169
|
export function checkCalculated(component, submission, rowData) {
|
|
119
170
|
// Process calculated value stuff if present.
|
|
@@ -129,12 +180,13 @@ export function checkCalculated(component, submission, rowData) {
|
|
|
129
180
|
}
|
|
130
181
|
/**
|
|
131
182
|
* Check if a simple conditional evaluates to true.
|
|
132
|
-
*
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
136
|
-
* @param
|
|
137
|
-
* @
|
|
183
|
+
*
|
|
184
|
+
* @param condition
|
|
185
|
+
* @param condition
|
|
186
|
+
* @param row
|
|
187
|
+
* @param data
|
|
188
|
+
* @param instance
|
|
189
|
+
* @returns {boolean}
|
|
138
190
|
*/
|
|
139
191
|
export function checkSimpleConditional(component, condition, row, data, instance) {
|
|
140
192
|
if (condition.when) {
|
|
@@ -178,13 +230,6 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
|
178
230
|
return show ? result : !result;
|
|
179
231
|
}
|
|
180
232
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Returns a components normalized value.
|
|
183
|
-
* @param {string} compPath - The full path to the component.
|
|
184
|
-
* @param {*} data - The data object to get the value from.
|
|
185
|
-
* @param {*} row - The contextual row data for the component.
|
|
186
|
-
* @returns {*} - The normalized value of the component.
|
|
187
|
-
*/
|
|
188
233
|
export function getComponentActualValue(compPath, data, row) {
|
|
189
234
|
let value = null;
|
|
190
235
|
if (row) {
|
|
@@ -201,15 +246,12 @@ export function getComponentActualValue(compPath, data, row) {
|
|
|
201
246
|
}
|
|
202
247
|
/**
|
|
203
248
|
* Check custom javascript conditional.
|
|
204
|
-
*
|
|
205
|
-
* @param
|
|
206
|
-
* @param
|
|
207
|
-
* @param
|
|
208
|
-
* @param
|
|
209
|
-
* @
|
|
210
|
-
* @param {*} onError - A custom return if there is an error or the value is null from the evaluation.
|
|
211
|
-
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
212
|
-
* @returns {*} - The result of the evaulation.
|
|
249
|
+
*
|
|
250
|
+
* @param component
|
|
251
|
+
* @param custom
|
|
252
|
+
* @param row
|
|
253
|
+
* @param data
|
|
254
|
+
* @returns {*}
|
|
213
255
|
*/
|
|
214
256
|
export function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
|
|
215
257
|
if (typeof custom === 'string') {
|
|
@@ -223,16 +265,6 @@ export function checkCustomConditional(component, custom, row, data, form, varia
|
|
|
223
265
|
}
|
|
224
266
|
return value;
|
|
225
267
|
}
|
|
226
|
-
/**
|
|
227
|
-
* Check a component for JSON conditionals.
|
|
228
|
-
* @param {import('@formio/core').Component} component - The component
|
|
229
|
-
* @param {import('@formio/core').JSONConditional} json - The json conditional to check.
|
|
230
|
-
* @param {*} row - The contextual row data for the component.
|
|
231
|
-
* @param {*} data - The full submission data.
|
|
232
|
-
* @param {import('@formio/core').Form} form - The Form JSON of the form.
|
|
233
|
-
* @param {*} onError - Custom return value if there is an error.
|
|
234
|
-
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
235
|
-
*/
|
|
236
268
|
export function checkJsonConditional(component, json, row, data, form, onError) {
|
|
237
269
|
try {
|
|
238
270
|
return jsonLogic.apply(json, {
|
|
@@ -247,14 +279,6 @@ export function checkJsonConditional(component, json, row, data, form, onError)
|
|
|
247
279
|
return onError;
|
|
248
280
|
}
|
|
249
281
|
}
|
|
250
|
-
/**
|
|
251
|
-
* Returns the contextual row data for a component.
|
|
252
|
-
* @param {import('@formio/core').Component} component - The component to get the row data for.
|
|
253
|
-
* @param {*} row - The row data for the component.
|
|
254
|
-
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
255
|
-
* @param {*} conditional - The component conditional.
|
|
256
|
-
* @returns {*} - The contextual row data for the component.
|
|
257
|
-
*/
|
|
258
282
|
function getRow(component, row, instance, conditional) {
|
|
259
283
|
const condition = conditional || component.conditional;
|
|
260
284
|
// If no component's instance passed (happens only in 6.x server), calculate its path based on the schema
|
|
@@ -276,12 +300,15 @@ function getRow(component, row, instance, conditional) {
|
|
|
276
300
|
}
|
|
277
301
|
/**
|
|
278
302
|
* Checks the conditions for a provided component and data.
|
|
279
|
-
*
|
|
280
|
-
* @param
|
|
281
|
-
*
|
|
282
|
-
* @param
|
|
283
|
-
*
|
|
284
|
-
* @
|
|
303
|
+
*
|
|
304
|
+
* @param component
|
|
305
|
+
* The component to check for the condition.
|
|
306
|
+
* @param row
|
|
307
|
+
* The data within a row
|
|
308
|
+
* @param data
|
|
309
|
+
* The full submission data.
|
|
310
|
+
*
|
|
311
|
+
* @returns {boolean}
|
|
285
312
|
*/
|
|
286
313
|
export function checkCondition(component, row, data, form, instance) {
|
|
287
314
|
const { customConditional, conditional } = component;
|
|
@@ -300,13 +327,12 @@ export function checkCondition(component, row, data, form, instance) {
|
|
|
300
327
|
}
|
|
301
328
|
/**
|
|
302
329
|
* Test a trigger on a component.
|
|
303
|
-
*
|
|
304
|
-
* @param
|
|
305
|
-
* @param
|
|
306
|
-
* @param
|
|
307
|
-
* @param
|
|
308
|
-
* @
|
|
309
|
-
* @returns {boolean} - TRUE if the trigger should fire; FALSE otherwise.
|
|
330
|
+
*
|
|
331
|
+
* @param component
|
|
332
|
+
* @param action
|
|
333
|
+
* @param data
|
|
334
|
+
* @param row
|
|
335
|
+
* @returns {mixed}
|
|
310
336
|
*/
|
|
311
337
|
export function checkTrigger(component, trigger, row, data, form, instance) {
|
|
312
338
|
// If trigger is empty, don't fire it
|
|
@@ -325,16 +351,6 @@ export function checkTrigger(component, trigger, row, data, form, instance) {
|
|
|
325
351
|
// If none of the types matched, don't fire the trigger.
|
|
326
352
|
return false;
|
|
327
353
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Sets a property on a component via an executed Logic action.
|
|
330
|
-
* @param {import('@formio/core').Component} component - The component to set the property on.
|
|
331
|
-
* @param {import('@formio/core').LogicAction} action - The action to perform on the component.
|
|
332
|
-
* @param {string} result - The name of the variable in the evaulation to use as the result.
|
|
333
|
-
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
334
|
-
* @param {import('@formio/core').DataObject} data - The full submission data.
|
|
335
|
-
* @param {any} instance - The component instance.
|
|
336
|
-
* @returns {import('@formio/core').Component} - The modified component.
|
|
337
|
-
*/
|
|
338
354
|
export function setActionProperty(component, action, result, row, data, instance) {
|
|
339
355
|
const property = action.property.value;
|
|
340
356
|
switch (action.property.type) {
|
|
@@ -368,8 +384,8 @@ export function setActionProperty(component, action, result, row, data, instance
|
|
|
368
384
|
}
|
|
369
385
|
/**
|
|
370
386
|
* Unescape HTML characters like <, >, & and etc.
|
|
371
|
-
* @param
|
|
372
|
-
* @returns {string}
|
|
387
|
+
* @param str
|
|
388
|
+
* @returns {string}
|
|
373
389
|
*/
|
|
374
390
|
export function unescapeHTML(str) {
|
|
375
391
|
if (typeof window === 'undefined' || !('DOMParser' in window)) {
|
|
@@ -380,9 +396,9 @@ export function unescapeHTML(str) {
|
|
|
380
396
|
}
|
|
381
397
|
/**
|
|
382
398
|
* Make HTML element from string
|
|
383
|
-
* @param
|
|
384
|
-
* @param
|
|
385
|
-
* @returns {HTMLElement}
|
|
399
|
+
* @param str
|
|
400
|
+
* @param selector
|
|
401
|
+
* @returns {HTMLElement}
|
|
386
402
|
*/
|
|
387
403
|
export function convertStringToHTMLElement(str, selector) {
|
|
388
404
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -390,10 +406,10 @@ export function convertStringToHTMLElement(str, selector) {
|
|
|
390
406
|
}
|
|
391
407
|
/**
|
|
392
408
|
* Make a filename guaranteed to be unique.
|
|
393
|
-
* @param
|
|
394
|
-
* @param
|
|
395
|
-
* @param
|
|
396
|
-
* @returns {string}
|
|
409
|
+
* @param name
|
|
410
|
+
* @param template
|
|
411
|
+
* @param evalContext
|
|
412
|
+
* @returns {string}
|
|
397
413
|
*/
|
|
398
414
|
export function uniqueName(name, template, evalContext) {
|
|
399
415
|
template = template || '{{fileName}}-{{guid}}';
|
|
@@ -416,10 +432,6 @@ export function uniqueName(name, template, evalContext) {
|
|
|
416
432
|
const uniqueName = `${Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
|
|
417
433
|
return uniqueName;
|
|
418
434
|
}
|
|
419
|
-
/**
|
|
420
|
-
* Returns a GUID
|
|
421
|
-
* @returns {string} - A GUID.
|
|
422
|
-
*/
|
|
423
435
|
export function guid() {
|
|
424
436
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
425
437
|
const r = Math.random() * 16 | 0;
|
|
@@ -431,8 +443,9 @@ export function guid() {
|
|
|
431
443
|
}
|
|
432
444
|
/**
|
|
433
445
|
* Return a translated date setting.
|
|
434
|
-
*
|
|
435
|
-
* @
|
|
446
|
+
*
|
|
447
|
+
* @param date
|
|
448
|
+
* @return {(null|Date)}
|
|
436
449
|
*/
|
|
437
450
|
export function getDateSetting(date) {
|
|
438
451
|
if (_.isNil(date) || _.isNaN(date) || date === '') {
|
|
@@ -473,17 +486,13 @@ export function getDateSetting(date) {
|
|
|
473
486
|
}
|
|
474
487
|
return dateSetting.toDate();
|
|
475
488
|
}
|
|
476
|
-
/**
|
|
477
|
-
* Returns true if the date is a valid date. False otherwise.
|
|
478
|
-
* @param {Date|string} date - The date to check for validity.
|
|
479
|
-
* @returns {boolean} - TRUE if the date is valid; FALSE otherwise.
|
|
480
|
-
*/
|
|
481
489
|
export function isValidDate(date) {
|
|
482
490
|
return _.isDate(date) && !_.isNaN(date.getDate());
|
|
483
491
|
}
|
|
484
492
|
/**
|
|
485
493
|
* Get the current timezone string.
|
|
486
|
-
*
|
|
494
|
+
*
|
|
495
|
+
* @return {string}
|
|
487
496
|
*/
|
|
488
497
|
export function currentTimezone() {
|
|
489
498
|
if (moment.currentTimezone) {
|
|
@@ -494,9 +503,10 @@ export function currentTimezone() {
|
|
|
494
503
|
}
|
|
495
504
|
/**
|
|
496
505
|
* Get an offset date provided a date object and timezone object.
|
|
497
|
-
*
|
|
498
|
-
* @param
|
|
499
|
-
* @
|
|
506
|
+
*
|
|
507
|
+
* @param date
|
|
508
|
+
* @param timezone
|
|
509
|
+
* @return {Date}
|
|
500
510
|
*/
|
|
501
511
|
export function offsetDate(date, timezone) {
|
|
502
512
|
if (timezone === 'UTC') {
|
|
@@ -513,15 +523,17 @@ export function offsetDate(date, timezone) {
|
|
|
513
523
|
}
|
|
514
524
|
/**
|
|
515
525
|
* Returns if the zones are loaded.
|
|
516
|
-
*
|
|
526
|
+
*
|
|
527
|
+
* @return {boolean}
|
|
517
528
|
*/
|
|
518
529
|
export function zonesLoaded() {
|
|
519
530
|
return moment.zonesLoaded;
|
|
520
531
|
}
|
|
521
532
|
/**
|
|
522
533
|
* Returns if we should load the zones.
|
|
523
|
-
*
|
|
524
|
-
* @
|
|
534
|
+
*
|
|
535
|
+
* @param timezone
|
|
536
|
+
* @return {boolean}
|
|
525
537
|
*/
|
|
526
538
|
export function shouldLoadZones(timezone) {
|
|
527
539
|
if (timezone === currentTimezone() || timezone === 'UTC') {
|
|
@@ -531,9 +543,8 @@ export function shouldLoadZones(timezone) {
|
|
|
531
543
|
}
|
|
532
544
|
/**
|
|
533
545
|
* Externally load the timezone data.
|
|
534
|
-
*
|
|
535
|
-
* @
|
|
536
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
546
|
+
*
|
|
547
|
+
* @return {Promise<any> | *}
|
|
537
548
|
*/
|
|
538
549
|
export function loadZones(url, timezone) {
|
|
539
550
|
if (timezone && !shouldLoadZones(timezone)) {
|
|
@@ -557,10 +568,11 @@ export function loadZones(url, timezone) {
|
|
|
557
568
|
}
|
|
558
569
|
/**
|
|
559
570
|
* Get the moment date object for translating dates with timezones.
|
|
560
|
-
*
|
|
561
|
-
* @param
|
|
562
|
-
* @param
|
|
563
|
-
* @
|
|
571
|
+
*
|
|
572
|
+
* @param value
|
|
573
|
+
* @param format
|
|
574
|
+
* @param timezone
|
|
575
|
+
* @return {*}
|
|
564
576
|
*/
|
|
565
577
|
export function momentDate(value, format, timezone) {
|
|
566
578
|
const momentDate = moment(value);
|
|
@@ -577,12 +589,11 @@ export function momentDate(value, format, timezone) {
|
|
|
577
589
|
}
|
|
578
590
|
/**
|
|
579
591
|
* Format a date provided a value, format, and timezone object.
|
|
580
|
-
*
|
|
581
|
-
* @param
|
|
582
|
-
* @param
|
|
583
|
-
* @param
|
|
584
|
-
* @
|
|
585
|
-
* @returns {string} - The formatted date.
|
|
592
|
+
*
|
|
593
|
+
* @param value
|
|
594
|
+
* @param format
|
|
595
|
+
* @param timezone
|
|
596
|
+
* @return {string}
|
|
586
597
|
*/
|
|
587
598
|
export function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat) {
|
|
588
599
|
const momentDate = moment(value, flatPickrInputFormat || undefined);
|
|
@@ -615,12 +626,12 @@ export function formatDate(timezonesUrl, value, format, timezone, flatPickrInput
|
|
|
615
626
|
}
|
|
616
627
|
/**
|
|
617
628
|
* Pass a format function to format within a timezone.
|
|
618
|
-
*
|
|
619
|
-
* @param
|
|
620
|
-
* @param
|
|
621
|
-
* @param
|
|
622
|
-
* @param
|
|
623
|
-
* @
|
|
629
|
+
*
|
|
630
|
+
* @param formatFn
|
|
631
|
+
* @param date
|
|
632
|
+
* @param format
|
|
633
|
+
* @param timezone
|
|
634
|
+
* @return {string}
|
|
624
635
|
*/
|
|
625
636
|
export function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
626
637
|
if (timezone === currentTimezone()) {
|
|
@@ -639,11 +650,6 @@ export function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
|
639
650
|
return formatFn(date, format);
|
|
640
651
|
}
|
|
641
652
|
}
|
|
642
|
-
/**
|
|
643
|
-
* Returns the local date format information.
|
|
644
|
-
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
|
645
|
-
* @returns {object} - The local date format information.
|
|
646
|
-
*/
|
|
647
653
|
export function getLocaleDateFormatInfo(locale) {
|
|
648
654
|
const formatInfo = {};
|
|
649
655
|
const day = 21;
|
|
@@ -654,8 +660,8 @@ export function getLocaleDateFormatInfo(locale) {
|
|
|
654
660
|
}
|
|
655
661
|
/**
|
|
656
662
|
* Convert the format from the angular-datepicker module to flatpickr format.
|
|
657
|
-
* @param
|
|
658
|
-
* @
|
|
663
|
+
* @param format
|
|
664
|
+
* @return {string}
|
|
659
665
|
*/
|
|
660
666
|
export function convertFormatToFlatpickr(format) {
|
|
661
667
|
return format
|
|
@@ -685,8 +691,8 @@ export function convertFormatToFlatpickr(format) {
|
|
|
685
691
|
}
|
|
686
692
|
/**
|
|
687
693
|
* Convert the format from the angular-datepicker module to moment format.
|
|
688
|
-
* @param
|
|
689
|
-
* @
|
|
694
|
+
* @param format
|
|
695
|
+
* @return {string}
|
|
690
696
|
*/
|
|
691
697
|
export function convertFormatToMoment(format) {
|
|
692
698
|
return format
|
|
@@ -701,11 +707,6 @@ export function convertFormatToMoment(format) {
|
|
|
701
707
|
// Unix Timestamp
|
|
702
708
|
.replace(/U/g, 'X');
|
|
703
709
|
}
|
|
704
|
-
/**
|
|
705
|
-
* Convert the format from the angular-datepicker module to mask format.
|
|
706
|
-
* @param {string} format - The format to convert.
|
|
707
|
-
* @returns {string} - The converted format.
|
|
708
|
-
*/
|
|
709
710
|
export function convertFormatToMask(format) {
|
|
710
711
|
return format
|
|
711
712
|
// Long month replacement.
|
|
@@ -763,13 +764,6 @@ export function getInputMask(mask, placeholderChar) {
|
|
|
763
764
|
}
|
|
764
765
|
return maskArray;
|
|
765
766
|
}
|
|
766
|
-
/**
|
|
767
|
-
* Unmasks a value using the provided mask and placeholder characters.
|
|
768
|
-
* @param {string} value - The value to unmask.
|
|
769
|
-
* @param {string} mask - The mask to use for unmasking.
|
|
770
|
-
* @param {string} placeholderChar - The placeholder character to use for unmasking.
|
|
771
|
-
* @returns {string} - The unmasked value.
|
|
772
|
-
*/
|
|
773
767
|
export function unmaskValue(value, mask, placeholderChar) {
|
|
774
768
|
if (!mask || !value || value.length > mask.length) {
|
|
775
769
|
return value;
|
|
@@ -785,12 +779,6 @@ export function unmaskValue(value, mask, placeholderChar) {
|
|
|
785
779
|
unmaskedValue = unmaskedValue.join('').replace(placeholderChar, '');
|
|
786
780
|
return unmaskedValue;
|
|
787
781
|
}
|
|
788
|
-
/**
|
|
789
|
-
* Returns true if the value matches the input mask format.
|
|
790
|
-
* @param {string} value - The value to check.
|
|
791
|
-
* @param {string} inputMask - The input mask to check against.
|
|
792
|
-
* @returns {boolean} - TRUE if the value matches the input mask; FALSE otherwise.
|
|
793
|
-
*/
|
|
794
782
|
export function matchInputMask(value, inputMask) {
|
|
795
783
|
if (!inputMask) {
|
|
796
784
|
return true;
|
|
@@ -808,11 +796,6 @@ export function matchInputMask(value, inputMask) {
|
|
|
808
796
|
}
|
|
809
797
|
return true;
|
|
810
798
|
}
|
|
811
|
-
/**
|
|
812
|
-
* Returns the number separators (i.e. 1,000) for the provided language.
|
|
813
|
-
* @param {string} lang - The language code to get the number separators for.
|
|
814
|
-
* @returns {{delimiter: string, decimalSeparator: string}} - The number separators.
|
|
815
|
-
*/
|
|
816
799
|
export function getNumberSeparators(lang = 'en') {
|
|
817
800
|
const formattedNumberString = (12345.6789).toLocaleString(lang);
|
|
818
801
|
const delimeters = formattedNumberString.match(/..(.)...(.)../);
|
|
@@ -827,12 +810,6 @@ export function getNumberSeparators(lang = 'en') {
|
|
|
827
810
|
decimalSeparator: (delimeters.length > 2) ? delimeters[2] : '.',
|
|
828
811
|
};
|
|
829
812
|
}
|
|
830
|
-
/**
|
|
831
|
-
* Returns the number for the maximum amount of decimal places for a number.
|
|
832
|
-
* @param {import('@formio/core').Component} component - The component to check for decimal limits.
|
|
833
|
-
* @param {number} defaultLimit - The default limit to use if none is provided in the component.
|
|
834
|
-
* @returns {number} - The number of decimal places allowed.
|
|
835
|
-
*/
|
|
836
813
|
export function getNumberDecimalLimit(component, defaultLimit) {
|
|
837
814
|
if (_.has(component, 'decimalLimit')) {
|
|
838
815
|
return _.get(component, 'decimalLimit');
|
|
@@ -848,15 +825,6 @@ export function getNumberDecimalLimit(component, defaultLimit) {
|
|
|
848
825
|
}
|
|
849
826
|
return decimalLimit;
|
|
850
827
|
}
|
|
851
|
-
/**
|
|
852
|
-
* Returns the currency affixes for a specific language.
|
|
853
|
-
* @param {object} arg0 - The arguments object.
|
|
854
|
-
* @param {string} arg0.currency - The currency code to get the affixes for.
|
|
855
|
-
* @param {number} arg0.decimalLimit - The number of decimal places to use.
|
|
856
|
-
* @param {string} arg0.decimalSeparator - The decimal separator to use.
|
|
857
|
-
* @param {string} arg0.lang - The language code to use.
|
|
858
|
-
* @returns {{prefix: string, suffix: string}} - The currency affixes.
|
|
859
|
-
*/
|
|
860
828
|
export function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }) {
|
|
861
829
|
// Get the prefix and suffix from the localized string.
|
|
862
830
|
let regex = `(.*)?${(100).toLocaleString(lang)}`;
|
|
@@ -878,9 +846,10 @@ export function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, l
|
|
|
878
846
|
}
|
|
879
847
|
/**
|
|
880
848
|
* Fetch the field data provided a component.
|
|
881
|
-
*
|
|
882
|
-
* @param
|
|
883
|
-
* @
|
|
849
|
+
*
|
|
850
|
+
* @param data
|
|
851
|
+
* @param component
|
|
852
|
+
* @return {*}
|
|
884
853
|
*/
|
|
885
854
|
export function fieldData(data, component) {
|
|
886
855
|
if (!data) {
|
|
@@ -926,23 +895,16 @@ export function fieldData(data, component) {
|
|
|
926
895
|
}
|
|
927
896
|
/**
|
|
928
897
|
* Delays function execution with possibility to execute function synchronously or cancel it.
|
|
929
|
-
*
|
|
930
|
-
* @param
|
|
931
|
-
* @param
|
|
932
|
-
* @
|
|
898
|
+
*
|
|
899
|
+
* @param fn Function to delay
|
|
900
|
+
* @param delay Delay time
|
|
901
|
+
* @return {*}
|
|
933
902
|
*/
|
|
934
903
|
export function delay(fn, delay = 0, ...args) {
|
|
935
904
|
const timer = setTimeout(fn, delay, ...args);
|
|
936
|
-
/**
|
|
937
|
-
*
|
|
938
|
-
*/
|
|
939
905
|
function cancel() {
|
|
940
906
|
clearTimeout(timer);
|
|
941
907
|
}
|
|
942
|
-
/**
|
|
943
|
-
* Execute the function early.
|
|
944
|
-
* @returns {*} - The result of the function.
|
|
945
|
-
*/
|
|
946
908
|
function earlyCall() {
|
|
947
909
|
cancel();
|
|
948
910
|
return fn(...args);
|
|
@@ -953,9 +915,11 @@ export function delay(fn, delay = 0, ...args) {
|
|
|
953
915
|
}
|
|
954
916
|
/**
|
|
955
917
|
* Iterate the given key to make it unique.
|
|
956
|
-
*
|
|
918
|
+
*
|
|
919
|
+
* @param {String} key
|
|
957
920
|
* Modify the component key to be unique.
|
|
958
|
-
*
|
|
921
|
+
*
|
|
922
|
+
* @returns {String}
|
|
959
923
|
* The new component key.
|
|
960
924
|
*/
|
|
961
925
|
export function iterateKey(key) {
|
|
@@ -968,9 +932,10 @@ export function iterateKey(key) {
|
|
|
968
932
|
}
|
|
969
933
|
/**
|
|
970
934
|
* Determines a unique key within a map provided the base key.
|
|
971
|
-
*
|
|
972
|
-
* @param
|
|
973
|
-
* @
|
|
935
|
+
*
|
|
936
|
+
* @param map
|
|
937
|
+
* @param base
|
|
938
|
+
* @return {*}
|
|
974
939
|
*/
|
|
975
940
|
export function uniqueKey(map, base) {
|
|
976
941
|
let newKey = base;
|
|
@@ -981,9 +946,8 @@ export function uniqueKey(map, base) {
|
|
|
981
946
|
}
|
|
982
947
|
/**
|
|
983
948
|
* Determines the major version number of bootstrap.
|
|
984
|
-
*
|
|
985
|
-
* @
|
|
986
|
-
* @returns {number} - The bootstrap version.
|
|
949
|
+
*
|
|
950
|
+
* @return {number}
|
|
987
951
|
*/
|
|
988
952
|
export function bootstrapVersion(options) {
|
|
989
953
|
if (options.bootstrap) {
|
|
@@ -1000,8 +964,9 @@ export function bootstrapVersion(options) {
|
|
|
1000
964
|
/**
|
|
1001
965
|
* Retrun provided argument.
|
|
1002
966
|
* If argument is a function, returns the result of a function call.
|
|
1003
|
-
* @param {
|
|
1004
|
-
*
|
|
967
|
+
* @param {*} e;
|
|
968
|
+
*
|
|
969
|
+
* @return {*}
|
|
1005
970
|
*/
|
|
1006
971
|
export function unfold(e) {
|
|
1007
972
|
if (typeof e === 'function') {
|
|
@@ -1011,32 +976,27 @@ export function unfold(e) {
|
|
|
1011
976
|
}
|
|
1012
977
|
/**
|
|
1013
978
|
* Map values through unfold and return first non-nil value.
|
|
1014
|
-
* @param {Array<T>} collection
|
|
1015
|
-
*
|
|
979
|
+
* @param {Array<T>} collection;
|
|
980
|
+
*
|
|
981
|
+
* @return {T}
|
|
1016
982
|
*/
|
|
1017
983
|
export const firstNonNil = _.flow([
|
|
1018
984
|
_.partialRight(_.map, unfold),
|
|
1019
985
|
_.partialRight(_.find, v => !_.isUndefined(v))
|
|
1020
986
|
]);
|
|
1021
|
-
|
|
1022
|
-
* Create enclosed state.
|
|
987
|
+
/*
|
|
988
|
+
* Create enclosed state.
|
|
989
|
+
* Returns functions to getting and cycling between states.
|
|
1023
990
|
* @param {*} a - initial state.
|
|
1024
991
|
* @param {*} b - next state.
|
|
1025
|
-
* @
|
|
992
|
+
* @return {Functions[]} -- [get, toggle];
|
|
1026
993
|
*/
|
|
1027
994
|
export function withSwitch(a, b) {
|
|
1028
995
|
let state = a;
|
|
1029
996
|
let next = b;
|
|
1030
|
-
/**
|
|
1031
|
-
* Returns the state of the switch.
|
|
1032
|
-
* @returns {*} - The current state.
|
|
1033
|
-
*/
|
|
1034
997
|
function get() {
|
|
1035
998
|
return state;
|
|
1036
999
|
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Toggles the state of the switch.
|
|
1039
|
-
*/
|
|
1040
1000
|
function toggle() {
|
|
1041
1001
|
const prev = state;
|
|
1042
1002
|
state = next;
|
|
@@ -1044,14 +1004,6 @@ export function withSwitch(a, b) {
|
|
|
1044
1004
|
}
|
|
1045
1005
|
return [get, toggle];
|
|
1046
1006
|
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Create a function that will call the provided function only the provided limit.
|
|
1049
|
-
* @param {Function} callback - The callback to call.
|
|
1050
|
-
* @param {object} options - The options to use.
|
|
1051
|
-
* @param {number} options.limit - The limit to call the callback.
|
|
1052
|
-
* @param {number} options.delay - The delay to wait before resetting the call count.
|
|
1053
|
-
* @returns {Function} - The function that will call the callback only the provided limit.
|
|
1054
|
-
*/
|
|
1055
1007
|
export function observeOverload(callback, options = {}) {
|
|
1056
1008
|
const { limit = 50, delay = 500 } = options;
|
|
1057
1009
|
let callCount = 0;
|
|
@@ -1071,13 +1023,6 @@ export function observeOverload(callback, options = {}) {
|
|
|
1071
1023
|
}
|
|
1072
1024
|
};
|
|
1073
1025
|
}
|
|
1074
|
-
/**
|
|
1075
|
-
* Returns the components that are provided within an evaluation context.
|
|
1076
|
-
* @param {any} context - The evaluation context to get the components from.
|
|
1077
|
-
* @param {boolean} excludeNested - Exclude nested components.
|
|
1078
|
-
* @param {Array<string>} excludedTypes - The types of components to exclude.
|
|
1079
|
-
* @returns {Array} - The components within the evaluation context.
|
|
1080
|
-
*/
|
|
1081
1026
|
export function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
1082
1027
|
const values = [];
|
|
1083
1028
|
context.utils.eachComponent(context.instance.options.editForm.components, (component, path) => {
|
|
@@ -1091,11 +1036,6 @@ export function getContextComponents(context, excludeNested, excludedTypes = [])
|
|
|
1091
1036
|
});
|
|
1092
1037
|
return values;
|
|
1093
1038
|
}
|
|
1094
|
-
/**
|
|
1095
|
-
* Returns the button components that are within an evaluation context.
|
|
1096
|
-
* @param {any} context - The evaluation context to get the components from.
|
|
1097
|
-
* @returns {Array} - The button components within the evaluation context.
|
|
1098
|
-
*/
|
|
1099
1039
|
export function getContextButtons(context) {
|
|
1100
1040
|
const values = [];
|
|
1101
1041
|
context.utils.eachComponent(context.instance.options.editForm.components, (component) => {
|
|
@@ -1112,9 +1052,12 @@ export function getContextButtons(context) {
|
|
|
1112
1052
|
const inTextTags = ['#text', 'A', 'B', 'EM', 'I', 'SMALL', 'STRONG', 'SUB', 'SUP', 'INS', 'DEL', 'MARK', 'CODE'];
|
|
1113
1053
|
/**
|
|
1114
1054
|
* Helper function for 'translateHTMLTemplate'. Translates text value of the passed html element.
|
|
1115
|
-
*
|
|
1116
|
-
* @param {
|
|
1117
|
-
* @
|
|
1055
|
+
*
|
|
1056
|
+
* @param {HTMLElement} elem
|
|
1057
|
+
* @param {Function} translate
|
|
1058
|
+
*
|
|
1059
|
+
* @returns {String}
|
|
1060
|
+
* Translated element template.
|
|
1118
1061
|
*/
|
|
1119
1062
|
function translateElemValue(elem, translate) {
|
|
1120
1063
|
if (!elem.innerText) {
|
|
@@ -1145,8 +1088,10 @@ function translateElemValue(elem, translate) {
|
|
|
1145
1088
|
}
|
|
1146
1089
|
/**
|
|
1147
1090
|
* Helper function for 'translateHTMLTemplate'. Goes deep through html tag children and calls function to translate their text values.
|
|
1148
|
-
*
|
|
1149
|
-
* @param {
|
|
1091
|
+
*
|
|
1092
|
+
* @param {HTMLElement} tag
|
|
1093
|
+
* @param {Function} translate
|
|
1094
|
+
*
|
|
1150
1095
|
* @returns {void}
|
|
1151
1096
|
*/
|
|
1152
1097
|
function translateDeepTag(tag, translate) {
|
|
@@ -1162,9 +1107,12 @@ function translateDeepTag(tag, translate) {
|
|
|
1162
1107
|
}
|
|
1163
1108
|
/**
|
|
1164
1109
|
* Translates text values in html template.
|
|
1165
|
-
*
|
|
1166
|
-
* @param {
|
|
1167
|
-
* @
|
|
1110
|
+
*
|
|
1111
|
+
* @param {String} template
|
|
1112
|
+
* @param {Function} translate
|
|
1113
|
+
*
|
|
1114
|
+
* @returns {String}
|
|
1115
|
+
* Html template with translated values.
|
|
1168
1116
|
*/
|
|
1169
1117
|
export function translateHTMLTemplate(template, translate) {
|
|
1170
1118
|
const isHTML = /<[^>]*>/.test(template);
|
|
@@ -1181,9 +1129,9 @@ export function translateHTMLTemplate(template, translate) {
|
|
|
1181
1129
|
}
|
|
1182
1130
|
/**
|
|
1183
1131
|
* Sanitize an html string.
|
|
1184
|
-
*
|
|
1185
|
-
* @param
|
|
1186
|
-
* @returns {
|
|
1132
|
+
*
|
|
1133
|
+
* @param string
|
|
1134
|
+
* @returns {*}
|
|
1187
1135
|
*/
|
|
1188
1136
|
export function sanitize(string, options) {
|
|
1189
1137
|
if (typeof dompurify.sanitize !== 'function') {
|
|
@@ -1231,18 +1179,11 @@ export function sanitize(string, options) {
|
|
|
1231
1179
|
}
|
|
1232
1180
|
/**
|
|
1233
1181
|
* Fast cloneDeep for JSON objects only.
|
|
1234
|
-
* @param {any} obj - The object to perform a fast clone deep against.
|
|
1235
|
-
* @returns {any} - The cloned object.
|
|
1236
1182
|
*/
|
|
1237
1183
|
export function fastCloneDeep(obj) {
|
|
1238
1184
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
|
1239
1185
|
}
|
|
1240
1186
|
export { Evaluator, interpolate };
|
|
1241
|
-
/**
|
|
1242
|
-
* Returns if the component is an input component.
|
|
1243
|
-
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
1244
|
-
* @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
|
|
1245
|
-
*/
|
|
1246
1187
|
export function isInputComponent(componentJson) {
|
|
1247
1188
|
if (componentJson.input === false || componentJson.input === true) {
|
|
1248
1189
|
return componentJson.input;
|
|
@@ -1262,11 +1203,6 @@ export function isInputComponent(componentJson) {
|
|
|
1262
1203
|
return true;
|
|
1263
1204
|
}
|
|
1264
1205
|
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Takes a component path, and returns a component path array.
|
|
1267
|
-
* @param {string} pathStr - The path string to convert to an array.
|
|
1268
|
-
* @returns {Arryay<number>} - The array of paths.
|
|
1269
|
-
*/
|
|
1270
1206
|
export function getArrayFromComponentPath(pathStr) {
|
|
1271
1207
|
if (!pathStr || !_.isString(pathStr)) {
|
|
1272
1208
|
if (!_.isArray(pathStr)) {
|
|
@@ -1280,12 +1216,6 @@ export function getArrayFromComponentPath(pathStr) {
|
|
|
1280
1216
|
.split('.')
|
|
1281
1217
|
.map(part => _.defaultTo(_.toNumber(part), part));
|
|
1282
1218
|
}
|
|
1283
|
-
/**
|
|
1284
|
-
* Returns true if the component is a child of the parent.
|
|
1285
|
-
* @param {any} child - The child component to check.
|
|
1286
|
-
* @param {any} parent - The parent component to check.
|
|
1287
|
-
* @returns {boolean} - TRUE if the child is a child of the parent; FALSE otherwise.
|
|
1288
|
-
*/
|
|
1289
1219
|
export function isChildOf(child, parent) {
|
|
1290
1220
|
while (child && child.parent) {
|
|
1291
1221
|
if (child.parent === parent) {
|
|
@@ -1295,11 +1225,6 @@ export function isChildOf(child, parent) {
|
|
|
1295
1225
|
}
|
|
1296
1226
|
return false;
|
|
1297
1227
|
}
|
|
1298
|
-
/**
|
|
1299
|
-
* Takes an array of component path indexes, and returns a string version of that array.
|
|
1300
|
-
* @param {Array<number>} path - The path array to convert to a string.
|
|
1301
|
-
* @returns {string} - The string version of the path.
|
|
1302
|
-
*/
|
|
1303
1228
|
export function getStringFromComponentPath(path) {
|
|
1304
1229
|
if (!_.isArray(path)) {
|
|
1305
1230
|
return path;
|
|
@@ -1315,21 +1240,16 @@ export function getStringFromComponentPath(path) {
|
|
|
1315
1240
|
});
|
|
1316
1241
|
return strPath;
|
|
1317
1242
|
}
|
|
1318
|
-
/**
|
|
1319
|
-
* Takes a number and rounds it to the provided precision amount.
|
|
1320
|
-
* @param {number} number - The number to round.
|
|
1321
|
-
* @param {number} precision - The precision to round the number to.
|
|
1322
|
-
* @returns {string} - The rounded number.
|
|
1323
|
-
*/
|
|
1324
1243
|
export function round(number, precision) {
|
|
1325
1244
|
if (_.isNumber(number)) {
|
|
1326
1245
|
return number.toFixed(precision);
|
|
1327
1246
|
}
|
|
1328
|
-
return number
|
|
1247
|
+
return number;
|
|
1329
1248
|
}
|
|
1330
1249
|
/**
|
|
1331
1250
|
* Check for Internet Explorer browser version
|
|
1332
|
-
*
|
|
1251
|
+
*
|
|
1252
|
+
* @return {(number|null)}
|
|
1333
1253
|
*/
|
|
1334
1254
|
export function getIEBrowserVersion() {
|
|
1335
1255
|
const { ie, version } = getBrowserInfo();
|
|
@@ -1337,7 +1257,8 @@ export function getIEBrowserVersion() {
|
|
|
1337
1257
|
}
|
|
1338
1258
|
/**
|
|
1339
1259
|
* Get browser name and version (modified from 'jquery-browser-plugin')
|
|
1340
|
-
*
|
|
1260
|
+
*
|
|
1261
|
+
* @return {Object} -- {{browser name, version, isWebkit?}}
|
|
1341
1262
|
* Possible browser names: chrome, safari, ie, edge, opera, mozilla, yabrowser
|
|
1342
1263
|
*/
|
|
1343
1264
|
export function getBrowserInfo() {
|
|
@@ -1385,19 +1306,12 @@ export function getBrowserInfo() {
|
|
|
1385
1306
|
}
|
|
1386
1307
|
return browser;
|
|
1387
1308
|
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Takes a component path, which may include array indicies (i.e. [0][1]), and returns the compoennt path without the indicies.
|
|
1390
|
-
* @param {string} path - The path to remove the indicies from.
|
|
1391
|
-
* @returns {string} - The path without the indicies.
|
|
1392
|
-
*/
|
|
1393
1309
|
export function getComponentPathWithoutIndicies(path = '') {
|
|
1394
1310
|
return path.replace(/\[\d+\]/, '');
|
|
1395
1311
|
}
|
|
1396
1312
|
/**
|
|
1397
1313
|
* Returns a path to the component which based on its schema
|
|
1398
|
-
* @param {
|
|
1399
|
-
* @param {string} path - Path to the component
|
|
1400
|
-
* @returns {string} - Path to the component
|
|
1314
|
+
* @param {*} component is a component's schema containing link to its parent's schema in the 'parent' property
|
|
1401
1315
|
*/
|
|
1402
1316
|
export function getComponentPath(component, path = '') {
|
|
1403
1317
|
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
|
|
@@ -1408,8 +1322,8 @@ export function getComponentPath(component, path = '') {
|
|
|
1408
1322
|
}
|
|
1409
1323
|
/**
|
|
1410
1324
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
1411
|
-
* @param {
|
|
1412
|
-
* @
|
|
1325
|
+
* @param {*} componentInstance
|
|
1326
|
+
* @return {(Component|undefined)}
|
|
1413
1327
|
*/
|
|
1414
1328
|
export function getDataParentComponent(componentInstance) {
|
|
1415
1329
|
if (!componentInstance) {
|
|
@@ -1425,8 +1339,8 @@ export function getDataParentComponent(componentInstance) {
|
|
|
1425
1339
|
}
|
|
1426
1340
|
/**
|
|
1427
1341
|
* Returns whether the value is a promise
|
|
1428
|
-
* @param
|
|
1429
|
-
* @
|
|
1342
|
+
* @param value
|
|
1343
|
+
* @return {boolean}
|
|
1430
1344
|
*/
|
|
1431
1345
|
export function isPromise(value) {
|
|
1432
1346
|
return value
|
|
@@ -1437,9 +1351,9 @@ export function isPromise(value) {
|
|
|
1437
1351
|
/**
|
|
1438
1352
|
* Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
|
|
1439
1353
|
* changes by itself, e.g. EditGrid)
|
|
1440
|
-
* @param
|
|
1441
|
-
* @param
|
|
1442
|
-
* @returns {boolean|*}
|
|
1354
|
+
* @param componentInstance
|
|
1355
|
+
* @param firstPass
|
|
1356
|
+
* @returns {boolean|boolean|*}
|
|
1443
1357
|
*/
|
|
1444
1358
|
export function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
1445
1359
|
if (!firstPass && componentInstance?.hasScopedChildren) {
|
|
@@ -1454,11 +1368,6 @@ export function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
|
1454
1368
|
}
|
|
1455
1369
|
return false;
|
|
1456
1370
|
}
|
|
1457
|
-
/**
|
|
1458
|
-
* Returns all the focusable elements within the provided dom element.
|
|
1459
|
-
* @param {HTMLElement} element - The element to get the focusable elements from.
|
|
1460
|
-
* @returns {NodeList<HTMLElement>} - The focusable elements within the provided element.
|
|
1461
|
-
*/
|
|
1462
1371
|
export function getFocusableElements(element) {
|
|
1463
1372
|
const focusableSelector = `button:not([disabled]), input:not([disabled]), select:not([disabled]),
|
|
1464
1373
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
|
@@ -1475,11 +1384,6 @@ export const componentValueTypes = {
|
|
|
1475
1384
|
date: 'date',
|
|
1476
1385
|
any: 'any',
|
|
1477
1386
|
};
|
|
1478
|
-
/**
|
|
1479
|
-
* Returns the saved types for the component
|
|
1480
|
-
* @param {import('@formio/core').Component} fullSchema - The component schema
|
|
1481
|
-
* @returns {Array<string>|null} - The saved types for the component
|
|
1482
|
-
*/
|
|
1483
1387
|
export function getComponentSavedTypes(fullSchema) {
|
|
1484
1388
|
const schema = fullSchema || {};
|
|
1485
1389
|
if (schema.persistent !== true) {
|
|
@@ -1492,10 +1396,9 @@ export function getComponentSavedTypes(fullSchema) {
|
|
|
1492
1396
|
}
|
|
1493
1397
|
/**
|
|
1494
1398
|
* Interpolates @formio/core errors so that they are compatible with the renderer
|
|
1495
|
-
* @param {
|
|
1496
|
-
* @param
|
|
1497
|
-
* @
|
|
1498
|
-
* @returns {[]} - The interpolated errors
|
|
1399
|
+
* @param {FieldError[]} errors
|
|
1400
|
+
* @param firstPass
|
|
1401
|
+
* @returns {[]}
|
|
1499
1402
|
*/
|
|
1500
1403
|
export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1501
1404
|
return errors.map((error) => {
|
|
@@ -1505,11 +1408,6 @@ export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1505
1408
|
return { ...error, message: unescapeHTML(interpolateFn(toInterpolate, context)), context: { ...context } };
|
|
1506
1409
|
});
|
|
1507
1410
|
};
|
|
1508
|
-
/**
|
|
1509
|
-
* Returns the template keys inside the template code.
|
|
1510
|
-
* @param {string} template - The template to get the keys from.
|
|
1511
|
-
* @returns {Array<string>} - The keys inside the template.
|
|
1512
|
-
*/
|
|
1513
1411
|
export function getItemTemplateKeys(template) {
|
|
1514
1412
|
const templateKeys = [];
|
|
1515
1413
|
if (!template) {
|
|
@@ -1526,11 +1424,6 @@ export function getItemTemplateKeys(template) {
|
|
|
1526
1424
|
}
|
|
1527
1425
|
return templateKeys;
|
|
1528
1426
|
}
|
|
1529
|
-
/**
|
|
1530
|
-
* Returns if the component is a select resource with an object for its value.
|
|
1531
|
-
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1532
|
-
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1533
|
-
*/
|
|
1534
1427
|
export function isSelectResourceWithObjectValue(comp = {}) {
|
|
1535
1428
|
const { reference, dataSrc, valueProperty } = comp;
|
|
1536
1429
|
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|