@formio/js 5.0.0-dev.5613.3476921 → 5.0.0-dev.5614.b5c93f3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +73 -4
- package/dist/formio.builder.css +8 -13
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +8 -13
- package/dist/formio.form.js +803 -1226
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -3
- package/dist/formio.full.css +8 -13
- package/dist/formio.full.js +722 -941
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -3
- package/dist/formio.js +18 -18
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +1853 -466
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +10 -2
- package/embed.d.ts +1 -0
- package/form.d.ts +1 -0
- package/lib/cjs/CDN.d.ts +1 -0
- package/lib/cjs/CDN.js +6 -3
- package/lib/cjs/Element.d.ts +87 -98
- package/lib/cjs/Element.js +76 -95
- package/lib/cjs/Embed.d.ts +1 -1
- package/lib/cjs/Embed.js +52 -12
- package/lib/cjs/Form.d.ts +365 -36
- package/lib/cjs/Form.js +50 -75
- package/lib/cjs/FormBuilder.d.ts +187 -2
- package/lib/cjs/FormBuilder.js +30 -8
- package/lib/cjs/Formio.js +12 -0
- package/lib/cjs/InlineEmbed.d.ts +7 -0
- package/lib/cjs/InlineEmbed.js +116 -0
- package/lib/cjs/PDF.d.ts +11 -13
- package/lib/cjs/PDF.js +7 -16
- package/lib/cjs/PDFBuilder.js +3 -3
- package/lib/cjs/Webform.d.ts +193 -140
- package/lib/cjs/Webform.js +341 -306
- package/lib/cjs/WebformBuilder.d.ts +18 -15
- package/lib/cjs/WebformBuilder.js +34 -27
- package/lib/cjs/Wizard.d.ts +31 -21
- package/lib/cjs/Wizard.js +44 -21
- package/lib/cjs/WizardBuilder.d.ts +1 -1
- package/lib/cjs/addons/FormioAddon.d.ts +0 -1
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -5
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -3
- package/lib/cjs/components/Components.d.ts +4 -4
- package/lib/cjs/components/Components.js +3 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +516 -270
- package/lib/cjs/components/_classes/component/Component.form.d.ts +6 -3
- package/lib/cjs/components/_classes/component/Component.form.js +5 -0
- package/lib/cjs/components/_classes/component/Component.js +470 -246
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +2 -2
- package/lib/cjs/components/_classes/component/editForm/utils.js +2 -2
- package/lib/cjs/components/_classes/component/fixtures/comp6.d.ts +77 -0
- package/lib/cjs/components/_classes/component/fixtures/comp6.js +59 -0
- package/lib/cjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
- package/lib/cjs/components/_classes/component/fixtures/comp7.js +86 -0
- package/lib/cjs/components/_classes/component/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/_classes/component/fixtures/index.js +5 -1
- package/lib/cjs/components/_classes/field/Field.d.ts +11 -2
- package/lib/cjs/components/_classes/field/Field.js +13 -1
- package/lib/cjs/components/_classes/input/Input.d.ts +4 -3
- package/lib/cjs/components/_classes/input/Input.js +32 -23
- package/lib/cjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/list/ListComponent.form.d.ts +6 -3
- package/lib/cjs/components/_classes/list/ListComponent.form.js +5 -0
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +43 -12
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +44 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +164 -68
- package/lib/cjs/components/_classes/nested/NestedComponent.form.d.ts +6 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +5 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +182 -62
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +7 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +2 -3
- package/lib/cjs/components/address/Address.d.ts +4 -2
- package/lib/cjs/components/address/Address.form.d.ts +6 -3
- package/lib/cjs/components/address/Address.form.js +5 -0
- package/lib/cjs/components/address/Address.js +4 -0
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +1 -1
- package/lib/cjs/components/button/Button.d.ts +4 -13
- package/lib/cjs/components/button/Button.form.d.ts +6 -3
- package/lib/cjs/components/button/Button.form.js +5 -0
- package/lib/cjs/components/button/Button.js +12 -7
- package/lib/cjs/components/checkbox/Checkbox.d.ts +5 -28
- package/lib/cjs/components/checkbox/Checkbox.form.d.ts +6 -3
- package/lib/cjs/components/checkbox/Checkbox.form.js +5 -0
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/checkbox/fixtures/comp6.d.ts +32 -0
- package/lib/cjs/components/checkbox/fixtures/comp6.js +30 -0
- package/lib/cjs/components/checkbox/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/checkbox/fixtures/index.js +3 -1
- package/lib/cjs/components/columns/Columns.d.ts +3 -2
- package/lib/cjs/components/columns/Columns.form.d.ts +6 -3
- package/lib/cjs/components/columns/Columns.form.js +5 -0
- package/lib/cjs/components/columns/Columns.js +3 -3
- package/lib/cjs/components/container/Container.form.d.ts +6 -3
- package/lib/cjs/components/container/Container.form.js +5 -0
- package/lib/cjs/components/content/Content.d.ts +2 -1
- package/lib/cjs/components/content/Content.form.d.ts +6 -3
- package/lib/cjs/components/content/Content.form.js +5 -0
- package/lib/cjs/components/currency/Currency.form.d.ts +6 -3
- package/lib/cjs/components/currency/Currency.form.js +5 -0
- package/lib/cjs/components/currency/Currency.js +1 -2
- package/lib/cjs/components/datagrid/DataGrid.d.ts +17 -7
- package/lib/cjs/components/datagrid/DataGrid.form.d.ts +6 -3
- package/lib/cjs/components/datagrid/DataGrid.form.js +5 -0
- package/lib/cjs/components/datagrid/DataGrid.js +55 -37
- package/lib/cjs/components/datagrid/fixtures/comp-with-checkboxes.d.ts +29 -0
- package/lib/cjs/components/datagrid/fixtures/comp-with-checkboxes.js +36 -0
- package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.d.ts +100 -0
- package/lib/cjs/components/datagrid/fixtures/comp-with-reorder.js +139 -0
- package/lib/cjs/components/datagrid/fixtures/comp10.d.ts +81 -0
- package/lib/cjs/components/datagrid/fixtures/comp10.js +87 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/cjs/components/datagrid/fixtures/comp9.js +44 -0
- package/lib/cjs/components/datagrid/fixtures/index.d.ts +5 -1
- package/lib/cjs/components/datagrid/fixtures/index.js +9 -1
- package/lib/cjs/components/datamap/DataMap.d.ts +1 -0
- package/lib/cjs/components/datamap/DataMap.form.d.ts +6 -3
- package/lib/cjs/components/datamap/DataMap.form.js +5 -0
- package/lib/cjs/components/datetime/DateTime.d.ts +0 -14
- package/lib/cjs/components/datetime/DateTime.form.d.ts +6 -3
- package/lib/cjs/components/datetime/DateTime.form.js +5 -0
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +2 -2
- package/lib/cjs/components/day/Day.d.ts +23 -49
- package/lib/cjs/components/day/Day.form.d.ts +6 -3
- package/lib/cjs/components/day/Day.form.js +5 -0
- package/lib/cjs/components/day/Day.js +16 -21
- package/lib/cjs/components/day/fixtures/comp7.d.ts +109 -0
- package/lib/cjs/components/day/fixtures/comp7.js +109 -0
- package/lib/cjs/components/day/fixtures/comp8.d.ts +41 -0
- package/lib/cjs/components/day/fixtures/comp8.js +40 -0
- package/lib/cjs/components/day/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/day/fixtures/index.js +5 -1
- package/lib/cjs/components/editgrid/EditGrid.d.ts +8 -4
- package/lib/cjs/components/editgrid/EditGrid.form.d.ts +6 -3
- package/lib/cjs/components/editgrid/EditGrid.form.js +5 -0
- package/lib/cjs/components/editgrid/EditGrid.js +12 -26
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +2 -5
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.js +6 -9
- package/lib/cjs/components/email/Email.form.d.ts +6 -3
- package/lib/cjs/components/email/Email.form.js +5 -0
- package/lib/cjs/components/fieldset/Fieldset.form.d.ts +6 -3
- package/lib/cjs/components/fieldset/Fieldset.form.js +5 -0
- package/lib/cjs/components/file/File.d.ts +9 -23
- package/lib/cjs/components/file/File.form.d.ts +6 -3
- package/lib/cjs/components/file/File.form.js +5 -0
- package/lib/cjs/components/file/File.js +3 -4
- package/lib/cjs/components/form/Form.d.ts +38 -20
- package/lib/cjs/components/form/Form.form.d.ts +6 -3
- package/lib/cjs/components/form/Form.form.js +5 -0
- package/lib/cjs/components/form/Form.js +33 -20
- package/lib/cjs/components/hidden/Hidden.d.ts +1 -11
- package/lib/cjs/components/hidden/Hidden.form.d.ts +6 -3
- package/lib/cjs/components/hidden/Hidden.form.js +5 -0
- package/lib/cjs/components/hidden/Hidden.js +1 -2
- package/lib/cjs/components/html/HTML.d.ts +2 -1
- package/lib/cjs/components/html/HTML.form.d.ts +6 -3
- package/lib/cjs/components/html/HTML.form.js +5 -0
- package/lib/cjs/components/number/Number.d.ts +3 -17
- package/lib/cjs/components/number/Number.form.d.ts +6 -3
- package/lib/cjs/components/number/Number.form.js +5 -0
- package/lib/cjs/components/number/Number.js +2 -3
- package/lib/cjs/components/number/fixtures/comp8.d.ts +32 -0
- package/lib/cjs/components/number/fixtures/comp8.js +28 -0
- package/lib/cjs/components/number/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/number/fixtures/index.js +3 -1
- package/lib/cjs/components/panel/Panel.form.d.ts +6 -3
- package/lib/cjs/components/panel/Panel.form.js +5 -0
- package/lib/cjs/components/panel/Panel.js +0 -1
- package/lib/cjs/components/password/Password.form.d.ts +6 -3
- package/lib/cjs/components/password/Password.form.js +5 -0
- package/lib/cjs/components/phonenumber/PhoneNumber.form.d.ts +6 -3
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +5 -0
- package/lib/cjs/components/phonenumber/fixtures/comp2.d.ts +16 -0
- package/lib/cjs/components/phonenumber/fixtures/comp2.js +25 -0
- package/lib/cjs/components/phonenumber/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/phonenumber/fixtures/index.js +3 -1
- package/lib/cjs/components/radio/Radio.d.ts +4 -27
- package/lib/cjs/components/radio/Radio.form.d.ts +6 -3
- package/lib/cjs/components/radio/Radio.form.js +5 -0
- package/lib/cjs/components/radio/Radio.js +11 -9
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +2 -9
- package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +7 -2
- package/lib/cjs/components/recaptcha/ReCaptcha.js +1 -8
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +33 -2
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +13 -2
- package/lib/cjs/components/select/Select.d.ts +16 -39
- package/lib/cjs/components/select/Select.form.d.ts +6 -3
- package/lib/cjs/components/select/Select.form.js +5 -0
- package/lib/cjs/components/select/Select.js +23 -24
- package/lib/cjs/components/select/editForm/Select.edit.data.js +16 -2
- package/lib/cjs/components/select/fixtures/comp22.js +1 -1
- package/lib/cjs/components/select/fixtures/comp23.d.ts +58 -0
- package/lib/cjs/components/select/fixtures/comp23.js +49 -0
- package/lib/cjs/components/select/fixtures/comp24.d.ts +47 -0
- package/lib/cjs/components/select/fixtures/comp24.js +40 -0
- package/lib/cjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/cjs/components/select/fixtures/index.js +5 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +2 -17
- package/lib/cjs/components/selectboxes/SelectBoxes.form.d.ts +6 -3
- package/lib/cjs/components/selectboxes/SelectBoxes.form.js +5 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +11 -10
- package/lib/cjs/components/signature/Signature.d.ts +0 -14
- package/lib/cjs/components/signature/Signature.form.d.ts +6 -3
- package/lib/cjs/components/signature/Signature.form.js +5 -0
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/components/survey/Survey.d.ts +3 -15
- package/lib/cjs/components/survey/Survey.form.d.ts +6 -3
- package/lib/cjs/components/survey/Survey.form.js +5 -0
- package/lib/cjs/components/table/Table.d.ts +3 -1
- package/lib/cjs/components/table/Table.form.d.ts +6 -3
- package/lib/cjs/components/table/Table.form.js +5 -0
- package/lib/cjs/components/table/Table.js +1 -1
- package/lib/cjs/components/tabs/Tabs.d.ts +4 -4
- package/lib/cjs/components/tabs/Tabs.form.d.ts +6 -3
- package/lib/cjs/components/tabs/Tabs.form.js +5 -0
- package/lib/cjs/components/tabs/Tabs.js +1 -2
- package/lib/cjs/components/tags/Tags.d.ts +0 -14
- package/lib/cjs/components/tags/Tags.form.d.ts +6 -3
- package/lib/cjs/components/tags/Tags.form.js +5 -0
- package/lib/cjs/components/tags/Tags.js +2 -4
- package/lib/cjs/components/textarea/TextArea.d.ts +4 -9
- package/lib/cjs/components/textarea/TextArea.form.d.ts +6 -3
- package/lib/cjs/components/textarea/TextArea.form.js +5 -0
- package/lib/cjs/components/textarea/TextArea.js +2 -2
- package/lib/cjs/components/textfield/TextField.d.ts +14 -30
- package/lib/cjs/components/textfield/TextField.form.d.ts +6 -3
- package/lib/cjs/components/textfield/TextField.form.js +5 -0
- package/lib/cjs/components/textfield/TextField.js +16 -17
- package/lib/cjs/components/time/Time.form.d.ts +6 -3
- package/lib/cjs/components/time/Time.form.js +5 -0
- package/lib/cjs/components/unknown/Unknown.form.d.ts +5 -34
- package/lib/cjs/components/unknown/Unknown.form.js +4 -0
- package/lib/cjs/components/url/Url.form.d.ts +6 -3
- package/lib/cjs/components/url/Url.form.js +5 -0
- package/lib/cjs/components/well/Well.form.d.ts +6 -3
- package/lib/cjs/components/well/Well.form.js +5 -0
- package/lib/cjs/formio.embed.d.ts +1 -2
- package/lib/cjs/formio.embed.js +2 -100
- package/lib/cjs/formio.form.d.ts +11 -4
- package/lib/cjs/formio.form.js +13 -5
- package/lib/cjs/providers/Providers.d.ts +36 -5
- package/lib/cjs/providers/Providers.js +29 -0
- package/lib/cjs/providers/address/AddressProvider.d.ts +131 -12
- package/lib/cjs/providers/address/AddressProvider.js +88 -2
- package/lib/cjs/providers/address/AzureAddressProvider.d.ts +48 -1
- package/lib/cjs/providers/address/AzureAddressProvider.js +37 -0
- package/lib/cjs/providers/address/CustomAddressProvider.d.ts +27 -4
- package/lib/cjs/providers/address/CustomAddressProvider.js +34 -0
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +135 -6
- package/lib/cjs/providers/address/GoogleAddressProvider.js +95 -1
- package/lib/cjs/providers/address/NominatimAddressProvider.d.ts +32 -7
- package/lib/cjs/providers/address/NominatimAddressProvider.js +33 -0
- package/lib/cjs/providers/address/index.d.ts +3 -1
- package/lib/cjs/providers/processor/fileProcessor.d.ts +7 -1
- package/lib/cjs/providers/processor/fileProcessor.js +6 -0
- package/lib/cjs/providers/storage/azure.d.ts +6 -13
- package/lib/cjs/providers/storage/azure.js +5 -0
- package/lib/cjs/providers/storage/base64.d.ts +5 -6
- package/lib/cjs/providers/storage/base64.js +4 -0
- package/lib/cjs/providers/storage/dropbox.d.ts +6 -4
- package/lib/cjs/providers/storage/dropbox.js +5 -0
- package/lib/cjs/providers/storage/googleDrive.d.ts +7 -5
- package/lib/cjs/providers/storage/googleDrive.js +6 -0
- package/lib/cjs/providers/storage/indexeddb.d.ts +5 -7
- package/lib/cjs/providers/storage/indexeddb.js +4 -0
- package/lib/cjs/providers/storage/s3.d.ts +6 -20
- package/lib/cjs/providers/storage/s3.js +5 -0
- package/lib/cjs/providers/storage/url.d.ts +6 -7
- package/lib/cjs/providers/storage/url.js +10 -0
- package/lib/cjs/providers/storage/util.d.ts +24 -1
- package/lib/cjs/providers/storage/util.js +18 -0
- package/lib/cjs/templates/Templates.d.ts +1 -0
- package/lib/cjs/translations/en.d.ts +5 -0
- package/lib/cjs/translations/en.js +6 -1
- package/lib/cjs/utils/ChoicesWrapper.d.ts +1 -1
- package/lib/cjs/utils/ChoicesWrapper.js +13 -2
- package/lib/cjs/utils/Evaluator.d.ts +6 -3
- package/lib/cjs/utils/Evaluator.js +11 -20
- package/lib/cjs/utils/builder.d.ts +9 -7
- package/lib/cjs/utils/builder.js +10 -5
- package/lib/cjs/utils/calendarUtils.d.ts +7 -13
- package/lib/cjs/utils/calendarUtils.js +10 -17
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +4 -3
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/formUtils.d.ts +43 -171
- package/lib/cjs/utils/formUtils.js +38 -569
- package/lib/cjs/utils/utils.d.ts +367 -218
- package/lib/cjs/utils/utils.js +420 -252
- package/lib/cjs/widgets/CalendarWidget.d.ts +9 -10
- package/lib/cjs/widgets/CalendarWidget.js +11 -13
- package/lib/mjs/CDN.d.ts +1 -0
- package/lib/mjs/CDN.js +6 -3
- package/lib/mjs/Element.d.ts +87 -98
- package/lib/mjs/Element.js +76 -95
- package/lib/mjs/Embed.d.ts +1 -1
- package/lib/mjs/Embed.js +52 -12
- package/lib/mjs/Form.d.ts +365 -36
- package/lib/mjs/Form.js +140 -68
- package/lib/mjs/FormBuilder.d.ts +187 -2
- package/lib/mjs/FormBuilder.js +32 -8
- package/lib/mjs/Formio.js +12 -0
- package/lib/mjs/InlineEmbed.d.ts +7 -0
- package/lib/mjs/InlineEmbed.js +112 -0
- package/lib/mjs/PDF.d.ts +11 -13
- package/lib/mjs/PDF.js +7 -16
- package/lib/mjs/PDFBuilder.js +3 -3
- package/lib/mjs/Webform.d.ts +193 -140
- package/lib/mjs/Webform.js +353 -318
- package/lib/mjs/WebformBuilder.d.ts +18 -15
- package/lib/mjs/WebformBuilder.js +34 -27
- package/lib/mjs/Wizard.d.ts +31 -21
- package/lib/mjs/Wizard.js +43 -20
- package/lib/mjs/WizardBuilder.d.ts +1 -1
- package/lib/mjs/addons/FormioAddon.d.ts +0 -1
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.d.ts +8 -5
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +6 -3
- package/lib/mjs/components/Components.d.ts +4 -4
- package/lib/mjs/components/Components.js +3 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +516 -270
- package/lib/mjs/components/_classes/component/Component.form.d.ts +6 -3
- package/lib/mjs/components/_classes/component/Component.form.js +5 -0
- package/lib/mjs/components/_classes/component/Component.js +479 -247
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/mjs/components/_classes/component/fixtures/comp6.d.ts +77 -0
- package/lib/mjs/components/_classes/component/fixtures/comp6.js +57 -0
- package/lib/mjs/components/_classes/component/fixtures/comp7.d.ts +84 -0
- package/lib/mjs/components/_classes/component/fixtures/comp7.js +84 -0
- package/lib/mjs/components/_classes/component/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/_classes/component/fixtures/index.js +3 -1
- package/lib/mjs/components/_classes/field/Field.d.ts +11 -2
- package/lib/mjs/components/_classes/field/Field.js +13 -1
- package/lib/mjs/components/_classes/input/Input.d.ts +4 -3
- package/lib/mjs/components/_classes/input/Input.js +31 -23
- package/lib/mjs/components/_classes/list/ListComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/list/ListComponent.form.d.ts +6 -3
- package/lib/mjs/components/_classes/list/ListComponent.form.js +5 -0
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +43 -12
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +44 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +164 -68
- package/lib/mjs/components/_classes/nested/NestedComponent.form.d.ts +6 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +5 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +182 -62
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +7 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +2 -3
- package/lib/mjs/components/address/Address.d.ts +4 -2
- package/lib/mjs/components/address/Address.form.d.ts +6 -3
- package/lib/mjs/components/address/Address.form.js +5 -0
- package/lib/mjs/components/address/Address.js +4 -0
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +1 -1
- package/lib/mjs/components/button/Button.d.ts +4 -13
- package/lib/mjs/components/button/Button.form.d.ts +6 -3
- package/lib/mjs/components/button/Button.form.js +5 -0
- package/lib/mjs/components/button/Button.js +12 -7
- package/lib/mjs/components/checkbox/Checkbox.d.ts +5 -28
- package/lib/mjs/components/checkbox/Checkbox.form.d.ts +6 -3
- package/lib/mjs/components/checkbox/Checkbox.form.js +5 -0
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/checkbox/fixtures/comp6.d.ts +32 -0
- package/lib/mjs/components/checkbox/fixtures/comp6.js +28 -0
- package/lib/mjs/components/checkbox/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/checkbox/fixtures/index.js +2 -1
- package/lib/mjs/components/columns/Columns.d.ts +3 -2
- package/lib/mjs/components/columns/Columns.form.d.ts +6 -3
- package/lib/mjs/components/columns/Columns.form.js +5 -0
- package/lib/mjs/components/columns/Columns.js +3 -3
- package/lib/mjs/components/container/Container.form.d.ts +6 -3
- package/lib/mjs/components/container/Container.form.js +5 -0
- package/lib/mjs/components/content/Content.d.ts +2 -1
- package/lib/mjs/components/content/Content.form.d.ts +6 -3
- package/lib/mjs/components/content/Content.form.js +5 -0
- package/lib/mjs/components/currency/Currency.form.d.ts +6 -3
- package/lib/mjs/components/currency/Currency.form.js +5 -0
- package/lib/mjs/components/currency/Currency.js +1 -2
- package/lib/mjs/components/datagrid/DataGrid.d.ts +17 -7
- package/lib/mjs/components/datagrid/DataGrid.form.d.ts +6 -3
- package/lib/mjs/components/datagrid/DataGrid.form.js +5 -0
- package/lib/mjs/components/datagrid/DataGrid.js +55 -37
- package/lib/mjs/components/datagrid/fixtures/comp-with-checkboxes.d.ts +29 -0
- package/lib/mjs/components/datagrid/fixtures/comp-with-checkboxes.js +34 -0
- package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.d.ts +100 -0
- package/lib/mjs/components/datagrid/fixtures/comp-with-reorder.js +137 -0
- package/lib/mjs/components/datagrid/fixtures/comp10.d.ts +81 -0
- package/lib/mjs/components/datagrid/fixtures/comp10.js +85 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.d.ts +41 -0
- package/lib/mjs/components/datagrid/fixtures/comp9.js +42 -0
- package/lib/mjs/components/datagrid/fixtures/index.d.ts +5 -1
- package/lib/mjs/components/datagrid/fixtures/index.js +5 -1
- package/lib/mjs/components/datamap/DataMap.d.ts +1 -0
- package/lib/mjs/components/datamap/DataMap.form.d.ts +6 -3
- package/lib/mjs/components/datamap/DataMap.form.js +5 -0
- package/lib/mjs/components/datetime/DateTime.d.ts +0 -14
- package/lib/mjs/components/datetime/DateTime.form.d.ts +6 -3
- package/lib/mjs/components/datetime/DateTime.form.js +5 -0
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +1 -1
- package/lib/mjs/components/day/Day.d.ts +23 -49
- package/lib/mjs/components/day/Day.form.d.ts +6 -3
- package/lib/mjs/components/day/Day.form.js +5 -0
- package/lib/mjs/components/day/Day.js +16 -21
- package/lib/mjs/components/day/fixtures/comp7.d.ts +109 -0
- package/lib/mjs/components/day/fixtures/comp7.js +107 -0
- package/lib/mjs/components/day/fixtures/comp8.d.ts +41 -0
- package/lib/mjs/components/day/fixtures/comp8.js +38 -0
- package/lib/mjs/components/day/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/day/fixtures/index.js +3 -1
- package/lib/mjs/components/editgrid/EditGrid.d.ts +8 -4
- package/lib/mjs/components/editgrid/EditGrid.form.d.ts +6 -3
- package/lib/mjs/components/editgrid/EditGrid.form.js +5 -0
- package/lib/mjs/components/editgrid/EditGrid.js +12 -25
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +1 -1
- package/lib/mjs/components/email/Email.form.d.ts +6 -3
- package/lib/mjs/components/email/Email.form.js +5 -0
- package/lib/mjs/components/fieldset/Fieldset.form.d.ts +6 -3
- package/lib/mjs/components/fieldset/Fieldset.form.js +5 -0
- package/lib/mjs/components/file/File.d.ts +9 -23
- package/lib/mjs/components/file/File.form.d.ts +6 -3
- package/lib/mjs/components/file/File.form.js +5 -0
- package/lib/mjs/components/file/File.js +3 -4
- package/lib/mjs/components/form/Form.d.ts +38 -20
- package/lib/mjs/components/form/Form.form.d.ts +6 -3
- package/lib/mjs/components/form/Form.form.js +5 -0
- package/lib/mjs/components/form/Form.js +31 -18
- package/lib/mjs/components/hidden/Hidden.d.ts +1 -11
- package/lib/mjs/components/hidden/Hidden.form.d.ts +6 -3
- package/lib/mjs/components/hidden/Hidden.form.js +5 -0
- package/lib/mjs/components/hidden/Hidden.js +1 -2
- package/lib/mjs/components/html/HTML.d.ts +2 -1
- package/lib/mjs/components/html/HTML.form.d.ts +6 -3
- package/lib/mjs/components/html/HTML.form.js +5 -0
- package/lib/mjs/components/number/Number.d.ts +3 -17
- package/lib/mjs/components/number/Number.form.d.ts +6 -3
- package/lib/mjs/components/number/Number.form.js +5 -0
- package/lib/mjs/components/number/Number.js +2 -3
- package/lib/mjs/components/number/fixtures/comp8.d.ts +32 -0
- package/lib/mjs/components/number/fixtures/comp8.js +26 -0
- package/lib/mjs/components/number/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/number/fixtures/index.js +2 -1
- package/lib/mjs/components/panel/Panel.form.d.ts +6 -3
- package/lib/mjs/components/panel/Panel.form.js +5 -0
- package/lib/mjs/components/panel/Panel.js +0 -1
- package/lib/mjs/components/password/Password.form.d.ts +6 -3
- package/lib/mjs/components/password/Password.form.js +5 -0
- package/lib/mjs/components/phonenumber/PhoneNumber.form.d.ts +6 -3
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +5 -0
- package/lib/mjs/components/phonenumber/fixtures/comp2.d.ts +16 -0
- package/lib/mjs/components/phonenumber/fixtures/comp2.js +23 -0
- package/lib/mjs/components/phonenumber/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/phonenumber/fixtures/index.js +2 -1
- package/lib/mjs/components/radio/Radio.d.ts +4 -27
- package/lib/mjs/components/radio/Radio.form.d.ts +6 -3
- package/lib/mjs/components/radio/Radio.form.js +5 -0
- package/lib/mjs/components/radio/Radio.js +11 -9
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +2 -9
- package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +7 -2
- package/lib/mjs/components/recaptcha/ReCaptcha.js +1 -8
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +33 -2
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +13 -2
- package/lib/mjs/components/select/Select.d.ts +16 -39
- package/lib/mjs/components/select/Select.form.d.ts +6 -3
- package/lib/mjs/components/select/Select.form.js +5 -0
- package/lib/mjs/components/select/Select.js +24 -25
- package/lib/mjs/components/select/editForm/Select.edit.data.js +16 -2
- package/lib/mjs/components/select/fixtures/comp22.js +1 -1
- package/lib/mjs/components/select/fixtures/comp23.d.ts +58 -0
- package/lib/mjs/components/select/fixtures/comp23.js +47 -0
- package/lib/mjs/components/select/fixtures/comp24.d.ts +47 -0
- package/lib/mjs/components/select/fixtures/comp24.js +38 -0
- package/lib/mjs/components/select/fixtures/index.d.ts +3 -1
- package/lib/mjs/components/select/fixtures/index.js +3 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +2 -17
- package/lib/mjs/components/selectboxes/SelectBoxes.form.d.ts +6 -3
- package/lib/mjs/components/selectboxes/SelectBoxes.form.js +5 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +11 -10
- package/lib/mjs/components/signature/Signature.d.ts +0 -14
- package/lib/mjs/components/signature/Signature.form.d.ts +6 -3
- package/lib/mjs/components/signature/Signature.form.js +5 -0
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/survey/Survey.d.ts +3 -15
- package/lib/mjs/components/survey/Survey.form.d.ts +6 -3
- package/lib/mjs/components/survey/Survey.form.js +5 -0
- package/lib/mjs/components/table/Table.d.ts +3 -1
- package/lib/mjs/components/table/Table.form.d.ts +6 -3
- package/lib/mjs/components/table/Table.form.js +5 -0
- package/lib/mjs/components/table/Table.js +1 -1
- package/lib/mjs/components/tabs/Tabs.d.ts +4 -4
- package/lib/mjs/components/tabs/Tabs.form.d.ts +6 -3
- package/lib/mjs/components/tabs/Tabs.form.js +5 -0
- package/lib/mjs/components/tabs/Tabs.js +1 -2
- package/lib/mjs/components/tags/Tags.d.ts +0 -14
- package/lib/mjs/components/tags/Tags.form.d.ts +6 -3
- package/lib/mjs/components/tags/Tags.form.js +5 -0
- package/lib/mjs/components/tags/Tags.js +2 -4
- package/lib/mjs/components/textarea/TextArea.d.ts +4 -9
- package/lib/mjs/components/textarea/TextArea.form.d.ts +6 -3
- package/lib/mjs/components/textarea/TextArea.form.js +5 -0
- package/lib/mjs/components/textarea/TextArea.js +2 -2
- package/lib/mjs/components/textfield/TextField.d.ts +14 -30
- package/lib/mjs/components/textfield/TextField.form.d.ts +6 -3
- package/lib/mjs/components/textfield/TextField.form.js +5 -0
- package/lib/mjs/components/textfield/TextField.js +16 -17
- package/lib/mjs/components/time/Time.form.d.ts +6 -3
- package/lib/mjs/components/time/Time.form.js +5 -0
- package/lib/mjs/components/unknown/Unknown.form.d.ts +5 -34
- package/lib/mjs/components/unknown/Unknown.form.js +4 -0
- package/lib/mjs/components/url/Url.form.d.ts +6 -3
- package/lib/mjs/components/url/Url.form.js +5 -0
- package/lib/mjs/components/well/Well.form.d.ts +6 -3
- package/lib/mjs/components/well/Well.form.js +5 -0
- package/lib/mjs/formio.embed.d.ts +1 -2
- package/lib/mjs/formio.embed.js +2 -99
- package/lib/mjs/formio.form.d.ts +11 -4
- package/lib/mjs/formio.form.js +10 -3
- package/lib/mjs/providers/Providers.d.ts +36 -5
- package/lib/mjs/providers/Providers.js +29 -0
- package/lib/mjs/providers/address/AddressProvider.d.ts +131 -12
- package/lib/mjs/providers/address/AddressProvider.js +88 -2
- package/lib/mjs/providers/address/AzureAddressProvider.d.ts +48 -1
- package/lib/mjs/providers/address/AzureAddressProvider.js +37 -0
- package/lib/mjs/providers/address/CustomAddressProvider.d.ts +27 -4
- package/lib/mjs/providers/address/CustomAddressProvider.js +34 -0
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +135 -6
- package/lib/mjs/providers/address/GoogleAddressProvider.js +94 -1
- package/lib/mjs/providers/address/NominatimAddressProvider.d.ts +32 -7
- package/lib/mjs/providers/address/NominatimAddressProvider.js +33 -0
- package/lib/mjs/providers/address/index.d.ts +3 -1
- package/lib/mjs/providers/processor/fileProcessor.d.ts +7 -1
- package/lib/mjs/providers/processor/fileProcessor.js +6 -0
- package/lib/mjs/providers/storage/azure.d.ts +6 -13
- package/lib/mjs/providers/storage/azure.js +5 -0
- package/lib/mjs/providers/storage/base64.d.ts +5 -6
- package/lib/mjs/providers/storage/base64.js +4 -0
- package/lib/mjs/providers/storage/dropbox.d.ts +6 -4
- package/lib/mjs/providers/storage/dropbox.js +5 -0
- package/lib/mjs/providers/storage/googleDrive.d.ts +7 -5
- package/lib/mjs/providers/storage/googleDrive.js +6 -0
- package/lib/mjs/providers/storage/indexeddb.d.ts +5 -7
- package/lib/mjs/providers/storage/indexeddb.js +4 -0
- package/lib/mjs/providers/storage/s3.d.ts +6 -20
- package/lib/mjs/providers/storage/s3.js +5 -0
- package/lib/mjs/providers/storage/url.d.ts +6 -7
- package/lib/mjs/providers/storage/url.js +10 -0
- package/lib/mjs/providers/storage/util.d.ts +24 -1
- package/lib/mjs/providers/storage/util.js +18 -0
- package/lib/mjs/templates/Templates.d.ts +1 -0
- package/lib/mjs/translations/en.d.ts +5 -0
- package/lib/mjs/translations/en.js +6 -1
- package/lib/mjs/utils/ChoicesWrapper.d.ts +1 -1
- package/lib/mjs/utils/ChoicesWrapper.js +13 -2
- package/lib/mjs/utils/Evaluator.d.ts +6 -3
- package/lib/mjs/utils/Evaluator.js +9 -20
- package/lib/mjs/utils/builder.d.ts +9 -7
- package/lib/mjs/utils/builder.js +10 -5
- package/lib/mjs/utils/calendarUtils.d.ts +7 -13
- package/lib/mjs/utils/calendarUtils.js +10 -17
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +3 -3
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/formUtils.d.ts +43 -171
- package/lib/mjs/utils/formUtils.js +6 -554
- package/lib/mjs/utils/utils.d.ts +367 -218
- package/lib/mjs/utils/utils.js +409 -233
- package/lib/mjs/widgets/CalendarWidget.d.ts +9 -10
- package/lib/mjs/widgets/CalendarWidget.js +11 -13
- package/package.json +22 -23
- package/sdk.d.ts +1 -0
- package/utils.d.ts +1 -0
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -11,46 +11,31 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
12
|
o[k2] = m[k];
|
|
13
13
|
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
14
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
16
|
};
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
19
|
};
|
|
32
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.
|
|
34
|
-
exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = void 0;
|
|
21
|
+
exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.ConditionOperators = exports.moment = exports.jsonLogic = void 0;
|
|
22
|
+
exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
|
|
35
23
|
const lodash_1 = __importDefault(require("lodash"));
|
|
36
24
|
exports._ = lodash_1.default;
|
|
37
|
-
const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
|
|
38
25
|
const json_logic_js_1 = __importDefault(require("json-logic-js"));
|
|
39
26
|
exports.jsonLogic = json_logic_js_1.default;
|
|
40
27
|
const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
|
|
28
|
+
exports.moment = moment_timezone_1.default;
|
|
41
29
|
const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
|
|
42
30
|
const operators_1 = require("./jsonlogic/operators");
|
|
43
31
|
const dompurify_1 = __importDefault(require("dompurify"));
|
|
44
32
|
const formUtils_1 = require("./formUtils");
|
|
45
|
-
const Evaluator_1 =
|
|
46
|
-
exports
|
|
33
|
+
const Evaluator_1 = require("./Evaluator");
|
|
34
|
+
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
|
47
35
|
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
|
48
36
|
exports.ConditionOperators = conditionOperators_1.default;
|
|
49
|
-
const interpolate = Evaluator_1.
|
|
37
|
+
const interpolate = Evaluator_1.Evaluator.interpolate;
|
|
50
38
|
exports.interpolate = interpolate;
|
|
51
|
-
const { fetch } = (0, fetch_ponyfill_1.default)({
|
|
52
|
-
Promise: Promise
|
|
53
|
-
});
|
|
54
39
|
__exportStar(require("./formUtils"), exports);
|
|
55
40
|
// Configure JsonLogic
|
|
56
41
|
operators_1.lodashOperators.forEach((name) => json_logic_js_1.default.add_operation(`_${name}`, lodash_1.default[name]));
|
|
@@ -66,7 +51,10 @@ json_logic_js_1.default.add_operation('relativeMinDate', (relativeMinDate) => {
|
|
|
66
51
|
json_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
|
67
52
|
return (0, moment_timezone_1.default)().add(relativeMaxDate, 'days').toISOString();
|
|
68
53
|
});
|
|
69
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Sets the path to the component and parent schema.
|
|
56
|
+
* @param {import('@formio/core').Component} component - The component to set the path for.
|
|
57
|
+
*/
|
|
70
58
|
function setPathToComponentAndPerentSchema(component) {
|
|
71
59
|
component.path = getComponentPath(component);
|
|
72
60
|
const dataParent = getDataParentComponent(component);
|
|
@@ -76,79 +64,30 @@ function setPathToComponentAndPerentSchema(component) {
|
|
|
76
64
|
}
|
|
77
65
|
/**
|
|
78
66
|
* Evaluate a method.
|
|
79
|
-
*
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
82
|
-
* @
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
args.form = lodash_1.default.get(args.instance, 'root._form', {});
|
|
89
|
-
}
|
|
90
|
-
const componentKey = component.key;
|
|
91
|
-
if (typeof func === 'string') {
|
|
92
|
-
if (ret) {
|
|
93
|
-
func += `;return ${ret}`;
|
|
94
|
-
}
|
|
95
|
-
if (tokenize) {
|
|
96
|
-
// Replace all {{ }} references with actual data.
|
|
97
|
-
func = func.replace(/({{\s+(.*)\s+}})/, (match, $1, $2) => {
|
|
98
|
-
if ($2.indexOf('data.') === 0) {
|
|
99
|
-
return lodash_1.default.get(args.data, $2.replace('data.', ''));
|
|
100
|
-
}
|
|
101
|
-
else if ($2.indexOf('row.') === 0) {
|
|
102
|
-
return lodash_1.default.get(args.row, $2.replace('row.', ''));
|
|
103
|
-
}
|
|
104
|
-
// Support legacy...
|
|
105
|
-
return lodash_1.default.get(args.data, $2);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
func = Evaluator_1.default.evaluator(func, args);
|
|
110
|
-
args = lodash_1.default.values(args);
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
console.warn(`An error occured within the custom function for ${componentKey}`, err);
|
|
114
|
-
returnVal = null;
|
|
115
|
-
func = false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (typeof func === 'function') {
|
|
119
|
-
try {
|
|
120
|
-
returnVal = Evaluator_1.default.evaluate(func, args);
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
returnVal = null;
|
|
124
|
-
console.warn(`An error occured within custom function for ${componentKey}`, err);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
else if (typeof func === 'object') {
|
|
128
|
-
try {
|
|
129
|
-
returnVal = json_logic_js_1.default.apply(func, args);
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
returnVal = null;
|
|
133
|
-
console.warn(`An error occured within custom function for ${componentKey}`, err);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (func) {
|
|
137
|
-
console.warn(`Unknown function type for ${componentKey}`);
|
|
138
|
-
}
|
|
139
|
-
return returnVal;
|
|
67
|
+
* @param {Function|string|object} func - The function to evaluate.
|
|
68
|
+
* @param {*} args - A map of arguments to pass to the function.
|
|
69
|
+
* @param {string} ret - The name of the "return" variable in the script.
|
|
70
|
+
* @param {boolean} interpolate - True if the script should be interpolated before being executed.
|
|
71
|
+
* @param {import('@formio/core').EvaluatorOptions} options - The evaluator options.
|
|
72
|
+
* @returns {*} - The result of the evaluation.
|
|
73
|
+
*/
|
|
74
|
+
function evaluate(func, args, ret, interpolate, options = {}) {
|
|
75
|
+
return Evaluator_1.Evaluator.evaluate(func, args, ret, interpolate, undefined, options);
|
|
140
76
|
}
|
|
141
77
|
exports.evaluate = evaluate;
|
|
78
|
+
/**
|
|
79
|
+
* Returns a random compoennt ID.
|
|
80
|
+
* @returns {string} - A random component ID.
|
|
81
|
+
*/
|
|
142
82
|
function getRandomComponentId() {
|
|
143
83
|
return `e${Math.random().toString(36).substring(7)}`;
|
|
144
84
|
}
|
|
145
85
|
exports.getRandomComponentId = getRandomComponentId;
|
|
146
86
|
/**
|
|
147
87
|
* Get a property value of an element.
|
|
148
|
-
*
|
|
149
|
-
* @param
|
|
150
|
-
* @
|
|
151
|
-
* @return {number}
|
|
88
|
+
* @param {CSSStyleDeclaration} style - The style element to get the property value from.
|
|
89
|
+
* @param {string} prop - The property to get the value for.
|
|
90
|
+
* @returns {number} - The value of the property.
|
|
152
91
|
*/
|
|
153
92
|
function getPropertyValue(style, prop) {
|
|
154
93
|
let value = style.getPropertyValue(prop);
|
|
@@ -158,9 +97,8 @@ function getPropertyValue(style, prop) {
|
|
|
158
97
|
exports.getPropertyValue = getPropertyValue;
|
|
159
98
|
/**
|
|
160
99
|
* Get an elements bounding rectagle.
|
|
161
|
-
*
|
|
162
|
-
* @
|
|
163
|
-
* @return {{x: string, y: string, width: string, height: string}}
|
|
100
|
+
* @param {HTMLElement} element - A DOM element to get the bounding rectangle for.
|
|
101
|
+
* @returns {{x: number, y: number, width: number, height: number}} - The bounding rectangle.
|
|
164
102
|
*/
|
|
165
103
|
function getElementRect(element) {
|
|
166
104
|
const style = window.getComputedStyle(element, null);
|
|
@@ -172,11 +110,24 @@ function getElementRect(element) {
|
|
|
172
110
|
};
|
|
173
111
|
}
|
|
174
112
|
exports.getElementRect = getElementRect;
|
|
113
|
+
/**
|
|
114
|
+
* Get non HTMLElement property in the window object
|
|
115
|
+
* @param {string} property - The window property to fetch the script plugin from.
|
|
116
|
+
* @returns {any | undefined} - The HTML Element property on the window object.
|
|
117
|
+
*/
|
|
118
|
+
function getScriptPlugin(property) {
|
|
119
|
+
const obj = window[property];
|
|
120
|
+
if (typeof HTMLElement === 'object' ? obj instanceof HTMLElement : //DOM2
|
|
121
|
+
obj && typeof obj === 'object' && true && obj.nodeType === 1 && typeof obj.nodeName === 'string') {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
return obj;
|
|
125
|
+
}
|
|
126
|
+
exports.getScriptPlugin = getScriptPlugin;
|
|
175
127
|
/**
|
|
176
128
|
* Determines the boolean value of a setting.
|
|
177
|
-
*
|
|
178
|
-
* @
|
|
179
|
-
* @return {boolean}
|
|
129
|
+
* @param {string|boolean} value - A string or boolean value to convert to boolean.
|
|
130
|
+
* @returns {boolean} - The boolean value of the setting.
|
|
180
131
|
*/
|
|
181
132
|
function boolValue(value) {
|
|
182
133
|
if (lodash_1.default.isBoolean(value)) {
|
|
@@ -192,22 +143,18 @@ function boolValue(value) {
|
|
|
192
143
|
exports.boolValue = boolValue;
|
|
193
144
|
/**
|
|
194
145
|
* Check to see if an ID is a mongoID.
|
|
195
|
-
* @param text
|
|
196
|
-
* @
|
|
146
|
+
* @param {string} text - The text to check if it is a mongoID.
|
|
147
|
+
* @returns {boolean} - TRUE if the text is a mongoID; FALSE otherwise.
|
|
197
148
|
*/
|
|
198
149
|
function isMongoId(text) {
|
|
199
|
-
return text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
150
|
+
return !!text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
200
151
|
}
|
|
201
152
|
exports.isMongoId = isMongoId;
|
|
202
153
|
/**
|
|
203
154
|
* Checks the calculated value for a provided component and data.
|
|
204
|
-
*
|
|
205
|
-
* @param {
|
|
206
|
-
*
|
|
207
|
-
* @param {Object} submission
|
|
208
|
-
* A submission object.
|
|
209
|
-
* @param data
|
|
210
|
-
* The full submission data.
|
|
155
|
+
* @param {import('@formio/core').Component} component - The component to check for the calculated value.
|
|
156
|
+
* @param {import('@formio/core').Submission} submission - A submission object.
|
|
157
|
+
* @param {*} rowData - The contextual row data for the component.
|
|
211
158
|
*/
|
|
212
159
|
function checkCalculated(component, submission, rowData) {
|
|
213
160
|
// Process calculated value stuff if present.
|
|
@@ -224,14 +171,51 @@ function checkCalculated(component, submission, rowData) {
|
|
|
224
171
|
exports.checkCalculated = checkCalculated;
|
|
225
172
|
/**
|
|
226
173
|
* Check if a simple conditional evaluates to true.
|
|
227
|
-
*
|
|
228
|
-
* @param condition
|
|
229
|
-
* @param
|
|
230
|
-
* @param
|
|
231
|
-
* @param
|
|
232
|
-
* @
|
|
233
|
-
* @returns {boolean}
|
|
174
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
175
|
+
* @param {import('@formio/core').SimpleConditional} condition - The condition to check.
|
|
176
|
+
* @param {*} row - The row data for the component.
|
|
177
|
+
* @param {*} data - The full submission data.
|
|
178
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
|
|
179
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
234
180
|
*/
|
|
181
|
+
function getConditionalPathsRecursive(conditionPaths, data) {
|
|
182
|
+
let currentGlobalIndex = 0;
|
|
183
|
+
const conditionalPathsArray = [];
|
|
184
|
+
const getConditionalPaths = (data, currentPath = '', localIndex = 0) => {
|
|
185
|
+
currentPath = currentPath.replace(/^\.+|\.+$/g, '');
|
|
186
|
+
const currentLocalIndex = localIndex;
|
|
187
|
+
const currentData = lodash_1.default.get(data, currentPath);
|
|
188
|
+
if (Array.isArray(currentData) && currentData.filter(Boolean).length > 0) {
|
|
189
|
+
if (currentData.some(element => typeof element !== 'object')) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const hasInnerDataArray = currentData.find(x => Array.isArray(x[conditionPaths[currentLocalIndex]]));
|
|
193
|
+
if (hasInnerDataArray) {
|
|
194
|
+
currentData.forEach((_, indexOutside) => {
|
|
195
|
+
const innerCompDataPath = `${currentPath}[${indexOutside}].${conditionPaths[currentLocalIndex]}`;
|
|
196
|
+
getConditionalPaths(data, innerCompDataPath, currentLocalIndex + 1);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
currentData.forEach((x, index) => {
|
|
201
|
+
if (!lodash_1.default.isNil(x[conditionPaths[currentLocalIndex]])) {
|
|
202
|
+
const compDataPath = `${currentPath}[${index}].${conditionPaths[currentLocalIndex]}`;
|
|
203
|
+
conditionalPathsArray.push(compDataPath);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
if (!conditionPaths[currentGlobalIndex]) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
currentGlobalIndex = currentGlobalIndex + 1;
|
|
213
|
+
getConditionalPaths(data, `${currentPath}.${conditionPaths[currentGlobalIndex - 1]}`, currentGlobalIndex);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
getConditionalPaths(data);
|
|
217
|
+
return conditionalPathsArray;
|
|
218
|
+
}
|
|
235
219
|
function checkSimpleConditional(component, condition, row, data, instance) {
|
|
236
220
|
if (condition.when) {
|
|
237
221
|
const value = getComponentActualValue(condition.when, data, row);
|
|
@@ -253,28 +237,49 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
|
253
237
|
return true;
|
|
254
238
|
}
|
|
255
239
|
const conditionsResult = lodash_1.default.map(conditions, (cond) => {
|
|
240
|
+
var _a, _b;
|
|
256
241
|
const { value: comparedValue, operator, component: conditionComponentPath } = cond;
|
|
257
242
|
if (!conditionComponentPath) {
|
|
258
243
|
return true;
|
|
259
244
|
}
|
|
260
|
-
const
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
245
|
+
const splittedConditionPath = conditionComponentPath.split('.');
|
|
246
|
+
const conditionalPaths = ((_a = instance === null || instance === void 0 ? void 0 : instance.parent) === null || _a === void 0 ? void 0 : _a.type) === 'datagrid' || ((_b = instance === null || instance === void 0 ? void 0 : instance.parent) === null || _b === void 0 ? void 0 : _b.type) === 'editgrid' ? [] : getConditionalPathsRecursive(splittedConditionPath, data);
|
|
247
|
+
if (conditionalPaths.length > 0) {
|
|
248
|
+
return conditionalPaths.map((path) => {
|
|
249
|
+
const value = getComponentActualValue(path, data, row);
|
|
250
|
+
const ConditionOperator = conditionOperators_1.default[operator];
|
|
251
|
+
return ConditionOperator
|
|
252
|
+
? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
|
253
|
+
: true;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const value = getComponentActualValue(conditionComponentPath, data, row);
|
|
258
|
+
const СonditionOperator = conditionOperators_1.default[operator];
|
|
259
|
+
return СonditionOperator
|
|
260
|
+
? new СonditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
|
261
|
+
: true;
|
|
262
|
+
}
|
|
265
263
|
});
|
|
266
264
|
let result = false;
|
|
267
265
|
switch (conjunction) {
|
|
268
266
|
case 'any':
|
|
269
|
-
result = lodash_1.default.some(conditionsResult, res => !!res);
|
|
267
|
+
result = lodash_1.default.some(conditionsResult.flat(), res => !!res);
|
|
270
268
|
break;
|
|
271
269
|
default:
|
|
272
|
-
result = lodash_1.default.every(conditionsResult, res => !!res);
|
|
270
|
+
result = lodash_1.default.every(conditionsResult.flat(), res => !!res);
|
|
273
271
|
}
|
|
274
272
|
return show ? result : !result;
|
|
275
273
|
}
|
|
276
274
|
}
|
|
277
275
|
exports.checkSimpleConditional = checkSimpleConditional;
|
|
276
|
+
/**
|
|
277
|
+
* Returns a components normalized value.
|
|
278
|
+
* @param {string} compPath - The full path to the component.
|
|
279
|
+
* @param {*} data - The data object to get the value from.
|
|
280
|
+
* @param {*} row - The contextual row data for the component.
|
|
281
|
+
* @returns {*} - The normalized value of the component.
|
|
282
|
+
*/
|
|
278
283
|
function getComponentActualValue(compPath, data, row) {
|
|
279
284
|
let value = null;
|
|
280
285
|
if (row) {
|
|
@@ -292,12 +297,15 @@ function getComponentActualValue(compPath, data, row) {
|
|
|
292
297
|
exports.getComponentActualValue = getComponentActualValue;
|
|
293
298
|
/**
|
|
294
299
|
* Check custom javascript conditional.
|
|
295
|
-
*
|
|
296
|
-
* @param
|
|
297
|
-
* @param
|
|
298
|
-
* @param
|
|
299
|
-
* @param
|
|
300
|
-
* @
|
|
300
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
301
|
+
* @param {string} custom - The custom conditional string to evaluate.
|
|
302
|
+
* @param {*} row - The row data for the component.
|
|
303
|
+
* @param {*} data - The full submission data.
|
|
304
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
305
|
+
* @param {string} variable - The variable name for the result of the custom conditional.
|
|
306
|
+
* @param {*} onError - A custom return if there is an error or the value is null from the evaluation.
|
|
307
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
308
|
+
* @returns {*} - The result of the evaulation.
|
|
301
309
|
*/
|
|
302
310
|
function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
|
|
303
311
|
if (typeof custom === 'string') {
|
|
@@ -312,6 +320,16 @@ function checkCustomConditional(component, custom, row, data, form, variable, on
|
|
|
312
320
|
return value;
|
|
313
321
|
}
|
|
314
322
|
exports.checkCustomConditional = checkCustomConditional;
|
|
323
|
+
/**
|
|
324
|
+
* Check a component for JSON conditionals.
|
|
325
|
+
* @param {import('@formio/core').Component} component - The component
|
|
326
|
+
* @param {import('@formio/core').JSONConditional} json - The json conditional to check.
|
|
327
|
+
* @param {*} row - The contextual row data for the component.
|
|
328
|
+
* @param {*} data - The full submission data.
|
|
329
|
+
* @param {import('@formio/core').Form} form - The Form JSON of the form.
|
|
330
|
+
* @param {*} onError - Custom return value if there is an error.
|
|
331
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
332
|
+
*/
|
|
315
333
|
function checkJsonConditional(component, json, row, data, form, onError) {
|
|
316
334
|
try {
|
|
317
335
|
return json_logic_js_1.default.apply(json, {
|
|
@@ -327,6 +345,14 @@ function checkJsonConditional(component, json, row, data, form, onError) {
|
|
|
327
345
|
}
|
|
328
346
|
}
|
|
329
347
|
exports.checkJsonConditional = checkJsonConditional;
|
|
348
|
+
/**
|
|
349
|
+
* Returns the contextual row data for a component.
|
|
350
|
+
* @param {import('@formio/core').Component} component - The component to get the row data for.
|
|
351
|
+
* @param {*} row - The row data for the component.
|
|
352
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
353
|
+
* @param {*} conditional - The component conditional.
|
|
354
|
+
* @returns {*} - The contextual row data for the component.
|
|
355
|
+
*/
|
|
330
356
|
function getRow(component, row, instance, conditional) {
|
|
331
357
|
var _a;
|
|
332
358
|
const condition = conditional || component.conditional;
|
|
@@ -349,15 +375,12 @@ function getRow(component, row, instance, conditional) {
|
|
|
349
375
|
}
|
|
350
376
|
/**
|
|
351
377
|
* Checks the conditions for a provided component and data.
|
|
352
|
-
*
|
|
353
|
-
* @param
|
|
354
|
-
*
|
|
355
|
-
* @param
|
|
356
|
-
*
|
|
357
|
-
* @
|
|
358
|
-
* The full submission data.
|
|
359
|
-
*
|
|
360
|
-
* @returns {boolean}
|
|
378
|
+
* @param {import('@formio/core').Component} component - The component to check for the condition.
|
|
379
|
+
* @param {*} row - The data within a row
|
|
380
|
+
* @param {*} data - The full submission data.
|
|
381
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
382
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
383
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
361
384
|
*/
|
|
362
385
|
function checkCondition(component, row, data, form, instance) {
|
|
363
386
|
const { customConditional, conditional } = component;
|
|
@@ -377,12 +400,13 @@ function checkCondition(component, row, data, form, instance) {
|
|
|
377
400
|
exports.checkCondition = checkCondition;
|
|
378
401
|
/**
|
|
379
402
|
* Test a trigger on a component.
|
|
380
|
-
*
|
|
381
|
-
* @param
|
|
382
|
-
* @param
|
|
383
|
-
* @param data
|
|
384
|
-
* @param
|
|
385
|
-
* @
|
|
403
|
+
* @param {import('@formio/core').Component} component - The component to test the trigger against.
|
|
404
|
+
* @param {import('@formio/core').LogicTrigger} trigger - The trigger configuration.
|
|
405
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
406
|
+
* @param {import('@formio/core').DataObject} data - The root data object.
|
|
407
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
408
|
+
* @param {any} instance - The component that is performing the trigger.
|
|
409
|
+
* @returns {boolean} - TRUE if the trigger should fire; FALSE otherwise.
|
|
386
410
|
*/
|
|
387
411
|
function checkTrigger(component, trigger, row, data, form, instance) {
|
|
388
412
|
// If trigger is empty, don't fire it
|
|
@@ -402,6 +426,16 @@ function checkTrigger(component, trigger, row, data, form, instance) {
|
|
|
402
426
|
return false;
|
|
403
427
|
}
|
|
404
428
|
exports.checkTrigger = checkTrigger;
|
|
429
|
+
/**
|
|
430
|
+
* Sets a property on a component via an executed Logic action.
|
|
431
|
+
* @param {import('@formio/core').Component} component - The component to set the property on.
|
|
432
|
+
* @param {import('@formio/core').LogicAction} action - The action to perform on the component.
|
|
433
|
+
* @param {string} result - The name of the variable in the evaulation to use as the result.
|
|
434
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
435
|
+
* @param {import('@formio/core').DataObject} data - The full submission data.
|
|
436
|
+
* @param {any} instance - The component instance.
|
|
437
|
+
* @returns {import('@formio/core').Component} - The modified component.
|
|
438
|
+
*/
|
|
405
439
|
function setActionProperty(component, action, result, row, data, instance) {
|
|
406
440
|
const property = action.property.value;
|
|
407
441
|
switch (action.property.type) {
|
|
@@ -424,7 +458,7 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
424
458
|
const currentValue = lodash_1.default.get(component, property, '');
|
|
425
459
|
const newValue = (instance && instance.interpolate)
|
|
426
460
|
? instance.interpolate(textValue, evalData)
|
|
427
|
-
: Evaluator_1.
|
|
461
|
+
: Evaluator_1.Evaluator.interpolate(textValue, evalData);
|
|
428
462
|
if (newValue !== currentValue) {
|
|
429
463
|
lodash_1.default.set(component, property, newValue);
|
|
430
464
|
}
|
|
@@ -434,24 +468,35 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
434
468
|
return component;
|
|
435
469
|
}
|
|
436
470
|
exports.setActionProperty = setActionProperty;
|
|
471
|
+
/**
|
|
472
|
+
* Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
|
|
473
|
+
* @param {string} str - The string to remove HTML tags from.
|
|
474
|
+
* @returns {string} - The string without HTML tags.
|
|
475
|
+
*/
|
|
476
|
+
function removeHTML(str) {
|
|
477
|
+
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
478
|
+
return (doc.body.textContent || '').trim();
|
|
479
|
+
}
|
|
480
|
+
exports.removeHTML = removeHTML;
|
|
437
481
|
/**
|
|
438
482
|
* Unescape HTML characters like <, >, & and etc.
|
|
439
|
-
* @param str
|
|
440
|
-
* @returns {string}
|
|
483
|
+
* @param {string} str - The string to unescape.
|
|
484
|
+
* @returns {string} - The unescaped string.
|
|
441
485
|
*/
|
|
442
486
|
function unescapeHTML(str) {
|
|
443
487
|
if (typeof window === 'undefined' || !('DOMParser' in window)) {
|
|
444
488
|
return str;
|
|
445
489
|
}
|
|
446
|
-
const
|
|
447
|
-
|
|
490
|
+
const elem = document.createElement('textarea');
|
|
491
|
+
elem.innerHTML = str;
|
|
492
|
+
return elem.value;
|
|
448
493
|
}
|
|
449
494
|
exports.unescapeHTML = unescapeHTML;
|
|
450
495
|
/**
|
|
451
496
|
* Make HTML element from string
|
|
452
|
-
* @param str
|
|
453
|
-
* @param selector
|
|
454
|
-
* @returns {HTMLElement}
|
|
497
|
+
* @param {string} str - The string to convert to an HTML element.
|
|
498
|
+
* @param {string} selector - The selector to use to get the element once it is created.
|
|
499
|
+
* @returns {HTMLElement} - The HTML element that was created.
|
|
455
500
|
*/
|
|
456
501
|
function convertStringToHTMLElement(str, selector) {
|
|
457
502
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -460,10 +505,10 @@ function convertStringToHTMLElement(str, selector) {
|
|
|
460
505
|
exports.convertStringToHTMLElement = convertStringToHTMLElement;
|
|
461
506
|
/**
|
|
462
507
|
* Make a filename guaranteed to be unique.
|
|
463
|
-
* @param name
|
|
464
|
-
* @param template
|
|
465
|
-
* @param evalContext
|
|
466
|
-
* @returns {string}
|
|
508
|
+
* @param {string} name - The original name of the file.
|
|
509
|
+
* @param {string} template - The template to use for the unique name.
|
|
510
|
+
* @param {object} evalContext - The context to use for the evaluation.
|
|
511
|
+
* @returns {string} - A unique filename.
|
|
467
512
|
*/
|
|
468
513
|
function uniqueName(name, template, evalContext) {
|
|
469
514
|
template = template || '{{fileName}}-{{guid}}';
|
|
@@ -483,10 +528,14 @@ function uniqueName(name, template, evalContext) {
|
|
|
483
528
|
guid: guid()
|
|
484
529
|
});
|
|
485
530
|
//only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash
|
|
486
|
-
const uniqueName = `${Evaluator_1.
|
|
531
|
+
const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
|
|
487
532
|
return uniqueName;
|
|
488
533
|
}
|
|
489
534
|
exports.uniqueName = uniqueName;
|
|
535
|
+
/**
|
|
536
|
+
* Returns a GUID
|
|
537
|
+
* @returns {string} - A GUID.
|
|
538
|
+
*/
|
|
490
539
|
function guid() {
|
|
491
540
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
492
541
|
const r = Math.random() * 16 | 0;
|
|
@@ -499,9 +548,8 @@ function guid() {
|
|
|
499
548
|
exports.guid = guid;
|
|
500
549
|
/**
|
|
501
550
|
* Return a translated date setting.
|
|
502
|
-
*
|
|
503
|
-
* @
|
|
504
|
-
* @return {(null|Date)}
|
|
551
|
+
* @param {string|Date} date - The date to translate.
|
|
552
|
+
* @returns {(null|Date)} - The translated date.
|
|
505
553
|
*/
|
|
506
554
|
function getDateSetting(date) {
|
|
507
555
|
if (lodash_1.default.isNil(date) || lodash_1.default.isNaN(date) || date === '') {
|
|
@@ -519,7 +567,7 @@ function getDateSetting(date) {
|
|
|
519
567
|
}
|
|
520
568
|
dateSetting = null;
|
|
521
569
|
try {
|
|
522
|
-
const value = Evaluator_1.
|
|
570
|
+
const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
|
|
523
571
|
if (typeof value === 'string') {
|
|
524
572
|
dateSetting = (0, moment_timezone_1.default)(value);
|
|
525
573
|
}
|
|
@@ -543,14 +591,18 @@ function getDateSetting(date) {
|
|
|
543
591
|
return dateSetting.toDate();
|
|
544
592
|
}
|
|
545
593
|
exports.getDateSetting = getDateSetting;
|
|
594
|
+
/**
|
|
595
|
+
* Returns true if the date is a valid date. False otherwise.
|
|
596
|
+
* @param {Date|string} date - The date to check for validity.
|
|
597
|
+
* @returns {boolean} - TRUE if the date is valid; FALSE otherwise.
|
|
598
|
+
*/
|
|
546
599
|
function isValidDate(date) {
|
|
547
600
|
return lodash_1.default.isDate(date) && !lodash_1.default.isNaN(date.getDate());
|
|
548
601
|
}
|
|
549
602
|
exports.isValidDate = isValidDate;
|
|
550
603
|
/**
|
|
551
604
|
* Get the current timezone string.
|
|
552
|
-
*
|
|
553
|
-
* @return {string}
|
|
605
|
+
* @returns {string} - The current timezone.
|
|
554
606
|
*/
|
|
555
607
|
function currentTimezone() {
|
|
556
608
|
if (moment_timezone_1.default.currentTimezone) {
|
|
@@ -562,10 +614,9 @@ function currentTimezone() {
|
|
|
562
614
|
exports.currentTimezone = currentTimezone;
|
|
563
615
|
/**
|
|
564
616
|
* Get an offset date provided a date object and timezone object.
|
|
565
|
-
*
|
|
566
|
-
* @param date
|
|
567
|
-
* @
|
|
568
|
-
* @return {Date}
|
|
617
|
+
* @param {Date} date - The date to offset.
|
|
618
|
+
* @param {string} timezone - The timezone to offset the date to.
|
|
619
|
+
* @returns {Date} - The offset date.
|
|
569
620
|
*/
|
|
570
621
|
function offsetDate(date, timezone) {
|
|
571
622
|
if (timezone === 'UTC') {
|
|
@@ -583,8 +634,7 @@ function offsetDate(date, timezone) {
|
|
|
583
634
|
exports.offsetDate = offsetDate;
|
|
584
635
|
/**
|
|
585
636
|
* Returns if the zones are loaded.
|
|
586
|
-
*
|
|
587
|
-
* @return {boolean}
|
|
637
|
+
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
|
588
638
|
*/
|
|
589
639
|
function zonesLoaded() {
|
|
590
640
|
return moment_timezone_1.default.zonesLoaded;
|
|
@@ -592,9 +642,8 @@ function zonesLoaded() {
|
|
|
592
642
|
exports.zonesLoaded = zonesLoaded;
|
|
593
643
|
/**
|
|
594
644
|
* Returns if we should load the zones.
|
|
595
|
-
*
|
|
596
|
-
* @
|
|
597
|
-
* @return {boolean}
|
|
645
|
+
* @param {string} timezone - The timezone to check if we should load the zones.
|
|
646
|
+
* @returns {boolean} - TRUE if we should load the zones; FALSE otherwise.
|
|
598
647
|
*/
|
|
599
648
|
function shouldLoadZones(timezone) {
|
|
600
649
|
if (timezone === currentTimezone() || timezone === 'UTC') {
|
|
@@ -605,8 +654,9 @@ function shouldLoadZones(timezone) {
|
|
|
605
654
|
exports.shouldLoadZones = shouldLoadZones;
|
|
606
655
|
/**
|
|
607
656
|
* Externally load the timezone data.
|
|
608
|
-
*
|
|
609
|
-
* @
|
|
657
|
+
* @param {string} url - The URL to load the timezone data from.
|
|
658
|
+
* @param {string} timezone - The timezone to load.
|
|
659
|
+
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
610
660
|
*/
|
|
611
661
|
function loadZones(url, timezone) {
|
|
612
662
|
if (timezone && !shouldLoadZones(timezone)) {
|
|
@@ -631,11 +681,10 @@ function loadZones(url, timezone) {
|
|
|
631
681
|
exports.loadZones = loadZones;
|
|
632
682
|
/**
|
|
633
683
|
* Get the moment date object for translating dates with timezones.
|
|
634
|
-
*
|
|
635
|
-
* @param
|
|
636
|
-
* @param
|
|
637
|
-
* @
|
|
638
|
-
* @return {*}
|
|
684
|
+
* @param {string|Date} value - The value to convert into a moment date.
|
|
685
|
+
* @param {string} format - The format to convert the date to.
|
|
686
|
+
* @param {string} timezone - The timezone to convert the date to.
|
|
687
|
+
* @returns {Date} - The moment date object.
|
|
639
688
|
*/
|
|
640
689
|
function momentDate(value, format, timezone) {
|
|
641
690
|
const momentDate = (0, moment_timezone_1.default)(value);
|
|
@@ -653,11 +702,12 @@ function momentDate(value, format, timezone) {
|
|
|
653
702
|
exports.momentDate = momentDate;
|
|
654
703
|
/**
|
|
655
704
|
* Format a date provided a value, format, and timezone object.
|
|
656
|
-
*
|
|
657
|
-
* @param value
|
|
658
|
-
* @param format
|
|
659
|
-
* @param timezone
|
|
660
|
-
* @
|
|
705
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
706
|
+
* @param {string|Date} value - The value to format.
|
|
707
|
+
* @param {string} format - The format to format the date to.
|
|
708
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
709
|
+
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
|
710
|
+
* @returns {string} - The formatted date.
|
|
661
711
|
*/
|
|
662
712
|
function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat) {
|
|
663
713
|
const momentDate = (0, moment_timezone_1.default)(value, flatPickrInputFormat || undefined);
|
|
@@ -691,12 +741,12 @@ function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat)
|
|
|
691
741
|
exports.formatDate = formatDate;
|
|
692
742
|
/**
|
|
693
743
|
* Pass a format function to format within a timezone.
|
|
694
|
-
*
|
|
695
|
-
* @param formatFn
|
|
696
|
-
* @param date
|
|
697
|
-
* @param format
|
|
698
|
-
* @param timezone
|
|
699
|
-
* @
|
|
744
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
745
|
+
* @param {Function} formatFn - The format function to use.
|
|
746
|
+
* @param {Date|string} date - The date to format.
|
|
747
|
+
* @param {string} format - The format to format the date to.
|
|
748
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
749
|
+
* @returns {string} - The formatted date.
|
|
700
750
|
*/
|
|
701
751
|
function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
702
752
|
if (timezone === currentTimezone()) {
|
|
@@ -716,6 +766,11 @@ function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
|
716
766
|
}
|
|
717
767
|
}
|
|
718
768
|
exports.formatOffset = formatOffset;
|
|
769
|
+
/**
|
|
770
|
+
* Returns the local date format information.
|
|
771
|
+
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
|
772
|
+
* @returns {object} - The local date format information.
|
|
773
|
+
*/
|
|
719
774
|
function getLocaleDateFormatInfo(locale) {
|
|
720
775
|
const formatInfo = {};
|
|
721
776
|
const day = 21;
|
|
@@ -727,8 +782,8 @@ function getLocaleDateFormatInfo(locale) {
|
|
|
727
782
|
exports.getLocaleDateFormatInfo = getLocaleDateFormatInfo;
|
|
728
783
|
/**
|
|
729
784
|
* Convert the format from the angular-datepicker module to flatpickr format.
|
|
730
|
-
* @param format
|
|
731
|
-
* @
|
|
785
|
+
* @param {string} format - The format to convert.
|
|
786
|
+
* @returns {string} - The converted format.
|
|
732
787
|
*/
|
|
733
788
|
function convertFormatToFlatpickr(format) {
|
|
734
789
|
return format
|
|
@@ -759,8 +814,8 @@ function convertFormatToFlatpickr(format) {
|
|
|
759
814
|
exports.convertFormatToFlatpickr = convertFormatToFlatpickr;
|
|
760
815
|
/**
|
|
761
816
|
* Convert the format from the angular-datepicker module to moment format.
|
|
762
|
-
* @param format
|
|
763
|
-
* @
|
|
817
|
+
* @param {string} format - The format to convert.
|
|
818
|
+
* @returns {string} - The converted format.
|
|
764
819
|
*/
|
|
765
820
|
function convertFormatToMoment(format) {
|
|
766
821
|
return format
|
|
@@ -776,6 +831,11 @@ function convertFormatToMoment(format) {
|
|
|
776
831
|
.replace(/U/g, 'X');
|
|
777
832
|
}
|
|
778
833
|
exports.convertFormatToMoment = convertFormatToMoment;
|
|
834
|
+
/**
|
|
835
|
+
* Convert the format from the angular-datepicker module to mask format.
|
|
836
|
+
* @param {string} format - The format to convert.
|
|
837
|
+
* @returns {string} - The converted format.
|
|
838
|
+
*/
|
|
779
839
|
function convertFormatToMask(format) {
|
|
780
840
|
return format
|
|
781
841
|
// Long month replacement.
|
|
@@ -835,6 +895,13 @@ function getInputMask(mask, placeholderChar) {
|
|
|
835
895
|
return maskArray;
|
|
836
896
|
}
|
|
837
897
|
exports.getInputMask = getInputMask;
|
|
898
|
+
/**
|
|
899
|
+
* Unmasks a value using the provided mask and placeholder characters.
|
|
900
|
+
* @param {string} value - The value to unmask.
|
|
901
|
+
* @param {string} mask - The mask to use for unmasking.
|
|
902
|
+
* @param {string} placeholderChar - The placeholder character to use for unmasking.
|
|
903
|
+
* @returns {string} - The unmasked value.
|
|
904
|
+
*/
|
|
838
905
|
function unmaskValue(value, mask, placeholderChar) {
|
|
839
906
|
if (!mask || !value || value.length > mask.length) {
|
|
840
907
|
return value;
|
|
@@ -851,6 +918,12 @@ function unmaskValue(value, mask, placeholderChar) {
|
|
|
851
918
|
return unmaskedValue;
|
|
852
919
|
}
|
|
853
920
|
exports.unmaskValue = unmaskValue;
|
|
921
|
+
/**
|
|
922
|
+
* Returns true if the value matches the input mask format.
|
|
923
|
+
* @param {string} value - The value to check.
|
|
924
|
+
* @param {string} inputMask - The input mask to check against.
|
|
925
|
+
* @returns {boolean} - TRUE if the value matches the input mask; FALSE otherwise.
|
|
926
|
+
*/
|
|
854
927
|
function matchInputMask(value, inputMask) {
|
|
855
928
|
if (!inputMask) {
|
|
856
929
|
return true;
|
|
@@ -869,6 +942,11 @@ function matchInputMask(value, inputMask) {
|
|
|
869
942
|
return true;
|
|
870
943
|
}
|
|
871
944
|
exports.matchInputMask = matchInputMask;
|
|
945
|
+
/**
|
|
946
|
+
* Returns the number separators (i.e. 1,000) for the provided language.
|
|
947
|
+
* @param {string} lang - The language code to get the number separators for.
|
|
948
|
+
* @returns {{delimiter: string, decimalSeparator: string}} - The number separators.
|
|
949
|
+
*/
|
|
872
950
|
function getNumberSeparators(lang = 'en') {
|
|
873
951
|
const formattedNumberString = (12345.6789).toLocaleString(lang);
|
|
874
952
|
const delimeters = formattedNumberString.match(/..(.)...(.)../);
|
|
@@ -884,6 +962,12 @@ function getNumberSeparators(lang = 'en') {
|
|
|
884
962
|
};
|
|
885
963
|
}
|
|
886
964
|
exports.getNumberSeparators = getNumberSeparators;
|
|
965
|
+
/**
|
|
966
|
+
* Returns the number for the maximum amount of decimal places for a number.
|
|
967
|
+
* @param {import('@formio/core').Component} component - The component to check for decimal limits.
|
|
968
|
+
* @param {number} defaultLimit - The default limit to use if none is provided in the component.
|
|
969
|
+
* @returns {number} - The number of decimal places allowed.
|
|
970
|
+
*/
|
|
887
971
|
function getNumberDecimalLimit(component, defaultLimit) {
|
|
888
972
|
if (lodash_1.default.has(component, 'decimalLimit')) {
|
|
889
973
|
return lodash_1.default.get(component, 'decimalLimit');
|
|
@@ -900,6 +984,15 @@ function getNumberDecimalLimit(component, defaultLimit) {
|
|
|
900
984
|
return decimalLimit;
|
|
901
985
|
}
|
|
902
986
|
exports.getNumberDecimalLimit = getNumberDecimalLimit;
|
|
987
|
+
/**
|
|
988
|
+
* Returns the currency affixes for a specific language.
|
|
989
|
+
* @param {object} arg0 - The arguments object.
|
|
990
|
+
* @param {string} arg0.currency - The currency code to get the affixes for.
|
|
991
|
+
* @param {number} arg0.decimalLimit - The number of decimal places to use.
|
|
992
|
+
* @param {string} arg0.decimalSeparator - The decimal separator to use.
|
|
993
|
+
* @param {string} arg0.lang - The language code to use.
|
|
994
|
+
* @returns {{prefix: string, suffix: string}} - The currency affixes.
|
|
995
|
+
*/
|
|
903
996
|
function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }) {
|
|
904
997
|
// Get the prefix and suffix from the localized string.
|
|
905
998
|
let regex = `(.*)?${(100).toLocaleString(lang)}`;
|
|
@@ -922,10 +1015,9 @@ function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, })
|
|
|
922
1015
|
exports.getCurrencyAffixes = getCurrencyAffixes;
|
|
923
1016
|
/**
|
|
924
1017
|
* Fetch the field data provided a component.
|
|
925
|
-
*
|
|
926
|
-
* @param data
|
|
927
|
-
* @
|
|
928
|
-
* @return {*}
|
|
1018
|
+
* @param {import('@formio/core').DataObject} data - The data object to fetch the field data from.
|
|
1019
|
+
* @param {import('@formio/core').Component} component - The component to fetch the field data for.
|
|
1020
|
+
* @returns {*} - The field data.
|
|
929
1021
|
*/
|
|
930
1022
|
function fieldData(data, component) {
|
|
931
1023
|
if (!data) {
|
|
@@ -972,16 +1064,23 @@ function fieldData(data, component) {
|
|
|
972
1064
|
exports.fieldData = fieldData;
|
|
973
1065
|
/**
|
|
974
1066
|
* Delays function execution with possibility to execute function synchronously or cancel it.
|
|
975
|
-
*
|
|
976
|
-
* @param
|
|
977
|
-
* @param
|
|
978
|
-
* @
|
|
1067
|
+
* @param {Function} fn - Function to delay
|
|
1068
|
+
* @param {number} delay - Delay time
|
|
1069
|
+
* @param {...any} args - Arguments to pass to the function
|
|
1070
|
+
* @returns {*} - Function to cancel the delay
|
|
979
1071
|
*/
|
|
980
1072
|
function delay(fn, delay = 0, ...args) {
|
|
981
1073
|
const timer = setTimeout(fn, delay, ...args);
|
|
1074
|
+
/**
|
|
1075
|
+
*
|
|
1076
|
+
*/
|
|
982
1077
|
function cancel() {
|
|
983
1078
|
clearTimeout(timer);
|
|
984
1079
|
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Execute the function early.
|
|
1082
|
+
* @returns {*} - The result of the function.
|
|
1083
|
+
*/
|
|
985
1084
|
function earlyCall() {
|
|
986
1085
|
cancel();
|
|
987
1086
|
return fn(...args);
|
|
@@ -993,11 +1092,9 @@ function delay(fn, delay = 0, ...args) {
|
|
|
993
1092
|
exports.delay = delay;
|
|
994
1093
|
/**
|
|
995
1094
|
* Iterate the given key to make it unique.
|
|
996
|
-
*
|
|
997
|
-
* @param {String} key
|
|
1095
|
+
* @param {string} key
|
|
998
1096
|
* Modify the component key to be unique.
|
|
999
|
-
*
|
|
1000
|
-
* @returns {String}
|
|
1097
|
+
* @returns {string}
|
|
1001
1098
|
* The new component key.
|
|
1002
1099
|
*/
|
|
1003
1100
|
function iterateKey(key) {
|
|
@@ -1011,10 +1108,9 @@ function iterateKey(key) {
|
|
|
1011
1108
|
exports.iterateKey = iterateKey;
|
|
1012
1109
|
/**
|
|
1013
1110
|
* Determines a unique key within a map provided the base key.
|
|
1014
|
-
*
|
|
1015
|
-
* @param
|
|
1016
|
-
* @
|
|
1017
|
-
* @return {*}
|
|
1111
|
+
* @param {Record<string, string>} map - The map to check for uniqueness.
|
|
1112
|
+
* @param {string} base - The base path of the key.
|
|
1113
|
+
* @returns {string} - The unique key.
|
|
1018
1114
|
*/
|
|
1019
1115
|
function uniqueKey(map, base) {
|
|
1020
1116
|
let newKey = base;
|
|
@@ -1026,8 +1122,9 @@ function uniqueKey(map, base) {
|
|
|
1026
1122
|
exports.uniqueKey = uniqueKey;
|
|
1027
1123
|
/**
|
|
1028
1124
|
* Determines the major version number of bootstrap.
|
|
1029
|
-
*
|
|
1030
|
-
* @
|
|
1125
|
+
* @param {object} options - The options to check for bootstrap version.
|
|
1126
|
+
* @param {string} options.bootstrap - The bootstrap version to use.
|
|
1127
|
+
* @returns {number} - The bootstrap version.
|
|
1031
1128
|
*/
|
|
1032
1129
|
function bootstrapVersion(options) {
|
|
1033
1130
|
if (options.bootstrap) {
|
|
@@ -1045,9 +1142,8 @@ exports.bootstrapVersion = bootstrapVersion;
|
|
|
1045
1142
|
/**
|
|
1046
1143
|
* Retrun provided argument.
|
|
1047
1144
|
* If argument is a function, returns the result of a function call.
|
|
1048
|
-
* @param {
|
|
1049
|
-
*
|
|
1050
|
-
* @return {*}
|
|
1145
|
+
* @param {Function|any} e - The argument to check if a function and call if so.
|
|
1146
|
+
* @returns {any} - Either the result of the function call (e) or e if it is not a function.
|
|
1051
1147
|
*/
|
|
1052
1148
|
function unfold(e) {
|
|
1053
1149
|
if (typeof e === 'function') {
|
|
@@ -1058,27 +1154,32 @@ function unfold(e) {
|
|
|
1058
1154
|
exports.unfold = unfold;
|
|
1059
1155
|
/**
|
|
1060
1156
|
* Map values through unfold and return first non-nil value.
|
|
1061
|
-
* @param {Array<T>} collection
|
|
1062
|
-
*
|
|
1063
|
-
* @return {T}
|
|
1157
|
+
* @param {Array<T>} collection - The collection to map through unfold.;
|
|
1158
|
+
* @returns {T} - The first non-nil value.
|
|
1064
1159
|
*/
|
|
1065
1160
|
exports.firstNonNil = lodash_1.default.flow([
|
|
1066
1161
|
lodash_1.default.partialRight(lodash_1.default.map, unfold),
|
|
1067
1162
|
lodash_1.default.partialRight(lodash_1.default.find, v => !lodash_1.default.isUndefined(v))
|
|
1068
1163
|
]);
|
|
1069
|
-
|
|
1070
|
-
* Create enclosed state.
|
|
1071
|
-
* Returns functions to getting and cycling between states.
|
|
1164
|
+
/**
|
|
1165
|
+
* Create enclosed state. Returns functions to getting and cycling between states.
|
|
1072
1166
|
* @param {*} a - initial state.
|
|
1073
1167
|
* @param {*} b - next state.
|
|
1074
|
-
* @
|
|
1168
|
+
* @returns {Functions[]} -- [get, toggle];
|
|
1075
1169
|
*/
|
|
1076
1170
|
function withSwitch(a, b) {
|
|
1077
1171
|
let state = a;
|
|
1078
1172
|
let next = b;
|
|
1173
|
+
/**
|
|
1174
|
+
* Returns the state of the switch.
|
|
1175
|
+
* @returns {*} - The current state.
|
|
1176
|
+
*/
|
|
1079
1177
|
function get() {
|
|
1080
1178
|
return state;
|
|
1081
1179
|
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Toggles the state of the switch.
|
|
1182
|
+
*/
|
|
1082
1183
|
function toggle() {
|
|
1083
1184
|
const prev = state;
|
|
1084
1185
|
state = next;
|
|
@@ -1087,6 +1188,14 @@ function withSwitch(a, b) {
|
|
|
1087
1188
|
return [get, toggle];
|
|
1088
1189
|
}
|
|
1089
1190
|
exports.withSwitch = withSwitch;
|
|
1191
|
+
/**
|
|
1192
|
+
* Create a function that will call the provided function only the provided limit.
|
|
1193
|
+
* @param {Function} callback - The callback to call.
|
|
1194
|
+
* @param {object} options - The options to use.
|
|
1195
|
+
* @param {number} options.limit - The limit to call the callback.
|
|
1196
|
+
* @param {number} options.delay - The delay to wait before resetting the call count.
|
|
1197
|
+
* @returns {Function} - The function that will call the callback only the provided limit.
|
|
1198
|
+
*/
|
|
1090
1199
|
function observeOverload(callback, options = {}) {
|
|
1091
1200
|
const { limit = 50, delay = 500 } = options;
|
|
1092
1201
|
let callCount = 0;
|
|
@@ -1107,6 +1216,13 @@ function observeOverload(callback, options = {}) {
|
|
|
1107
1216
|
};
|
|
1108
1217
|
}
|
|
1109
1218
|
exports.observeOverload = observeOverload;
|
|
1219
|
+
/**
|
|
1220
|
+
* Returns the components that are provided within an evaluation context.
|
|
1221
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1222
|
+
* @param {boolean} excludeNested - Exclude nested components.
|
|
1223
|
+
* @param {Array<string>} excludedTypes - The types of components to exclude.
|
|
1224
|
+
* @returns {Array} - The components within the evaluation context.
|
|
1225
|
+
*/
|
|
1110
1226
|
function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
1111
1227
|
const values = [];
|
|
1112
1228
|
context.utils.eachComponent(context.instance.options.editForm.components, (component, path) => {
|
|
@@ -1121,6 +1237,11 @@ function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
|
1121
1237
|
return values;
|
|
1122
1238
|
}
|
|
1123
1239
|
exports.getContextComponents = getContextComponents;
|
|
1240
|
+
/**
|
|
1241
|
+
* Returns the button components that are within an evaluation context.
|
|
1242
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1243
|
+
* @returns {Array} - The button components within the evaluation context.
|
|
1244
|
+
*/
|
|
1124
1245
|
function getContextButtons(context) {
|
|
1125
1246
|
const values = [];
|
|
1126
1247
|
context.utils.eachComponent(context.instance.options.editForm.components, (component) => {
|
|
@@ -1138,18 +1259,15 @@ exports.getContextButtons = getContextButtons;
|
|
|
1138
1259
|
const inTextTags = ['#text', 'A', 'B', 'EM', 'I', 'SMALL', 'STRONG', 'SUB', 'SUP', 'INS', 'DEL', 'MARK', 'CODE'];
|
|
1139
1260
|
/**
|
|
1140
1261
|
* Helper function for 'translateHTMLTemplate'. Translates text value of the passed html element.
|
|
1141
|
-
*
|
|
1142
|
-
* @param {
|
|
1143
|
-
* @
|
|
1144
|
-
*
|
|
1145
|
-
* @returns {String}
|
|
1146
|
-
* Translated element template.
|
|
1262
|
+
* @param {HTMLElement} elem - The element to translate.
|
|
1263
|
+
* @param {Function} translate - The translation function.
|
|
1264
|
+
* @returns {string} - Translated element template.
|
|
1147
1265
|
*/
|
|
1148
1266
|
function translateElemValue(elem, translate) {
|
|
1149
1267
|
if (!elem.innerText) {
|
|
1150
1268
|
return elem.innerHTML;
|
|
1151
1269
|
}
|
|
1152
|
-
const elemValue = elem.innerText.replace(Evaluator_1.
|
|
1270
|
+
const elemValue = elem.innerText.replace(Evaluator_1.Evaluator.templateSettings.interpolate, '').replace(/\s\s+/g, ' ').trim();
|
|
1153
1271
|
const translatedValue = translate(elemValue);
|
|
1154
1272
|
if (elemValue !== translatedValue) {
|
|
1155
1273
|
const links = elem.innerHTML.match(/<a[^>]*>(.*?)<\/a>/g);
|
|
@@ -1174,10 +1292,8 @@ function translateElemValue(elem, translate) {
|
|
|
1174
1292
|
}
|
|
1175
1293
|
/**
|
|
1176
1294
|
* Helper function for 'translateHTMLTemplate'. Goes deep through html tag children and calls function to translate their text values.
|
|
1177
|
-
*
|
|
1178
|
-
* @param {
|
|
1179
|
-
* @param {Function} translate
|
|
1180
|
-
*
|
|
1295
|
+
* @param {HTMLElement} tag - The tag to translate.
|
|
1296
|
+
* @param {Function} translate - The translation function.
|
|
1181
1297
|
* @returns {void}
|
|
1182
1298
|
*/
|
|
1183
1299
|
function translateDeepTag(tag, translate) {
|
|
@@ -1193,12 +1309,9 @@ function translateDeepTag(tag, translate) {
|
|
|
1193
1309
|
}
|
|
1194
1310
|
/**
|
|
1195
1311
|
* Translates text values in html template.
|
|
1196
|
-
*
|
|
1197
|
-
* @param {
|
|
1198
|
-
* @
|
|
1199
|
-
*
|
|
1200
|
-
* @returns {String}
|
|
1201
|
-
* Html template with translated values.
|
|
1312
|
+
* @param {string} template - The template to translate.
|
|
1313
|
+
* @param {Function} translate - The translation function.
|
|
1314
|
+
* @returns {string} - Html template with translated values.
|
|
1202
1315
|
*/
|
|
1203
1316
|
function translateHTMLTemplate(template, translate) {
|
|
1204
1317
|
const isHTML = /<[^>]*>/.test(template);
|
|
@@ -1216,9 +1329,9 @@ function translateHTMLTemplate(template, translate) {
|
|
|
1216
1329
|
exports.translateHTMLTemplate = translateHTMLTemplate;
|
|
1217
1330
|
/**
|
|
1218
1331
|
* Sanitize an html string.
|
|
1219
|
-
*
|
|
1220
|
-
* @param
|
|
1221
|
-
* @returns {
|
|
1332
|
+
* @param {string} string - The string to sanitize.
|
|
1333
|
+
* @param {any} options - The options to use for sanitization.
|
|
1334
|
+
* @returns {string} - The sanitized html string.
|
|
1222
1335
|
*/
|
|
1223
1336
|
function sanitize(string, options) {
|
|
1224
1337
|
if (typeof dompurify_1.default.sanitize !== 'function') {
|
|
@@ -1267,11 +1380,18 @@ function sanitize(string, options) {
|
|
|
1267
1380
|
exports.sanitize = sanitize;
|
|
1268
1381
|
/**
|
|
1269
1382
|
* Fast cloneDeep for JSON objects only.
|
|
1383
|
+
* @param {any} obj - The object to perform a fast clone deep against.
|
|
1384
|
+
* @returns {any} - The cloned object.
|
|
1270
1385
|
*/
|
|
1271
1386
|
function fastCloneDeep(obj) {
|
|
1272
1387
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
|
1273
1388
|
}
|
|
1274
1389
|
exports.fastCloneDeep = fastCloneDeep;
|
|
1390
|
+
/**
|
|
1391
|
+
* Returns if the component is an input component.
|
|
1392
|
+
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
1393
|
+
* @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
|
|
1394
|
+
*/
|
|
1275
1395
|
function isInputComponent(componentJson) {
|
|
1276
1396
|
if (componentJson.input === false || componentJson.input === true) {
|
|
1277
1397
|
return componentJson.input;
|
|
@@ -1292,6 +1412,11 @@ function isInputComponent(componentJson) {
|
|
|
1292
1412
|
}
|
|
1293
1413
|
}
|
|
1294
1414
|
exports.isInputComponent = isInputComponent;
|
|
1415
|
+
/**
|
|
1416
|
+
* Takes a component path, and returns a component path array.
|
|
1417
|
+
* @param {string} pathStr - The path string to convert to an array.
|
|
1418
|
+
* @returns {Arryay<number>} - The array of paths.
|
|
1419
|
+
*/
|
|
1295
1420
|
function getArrayFromComponentPath(pathStr) {
|
|
1296
1421
|
if (!pathStr || !lodash_1.default.isString(pathStr)) {
|
|
1297
1422
|
if (!lodash_1.default.isArray(pathStr)) {
|
|
@@ -1306,6 +1431,12 @@ function getArrayFromComponentPath(pathStr) {
|
|
|
1306
1431
|
.map(part => lodash_1.default.defaultTo(lodash_1.default.toNumber(part), part));
|
|
1307
1432
|
}
|
|
1308
1433
|
exports.getArrayFromComponentPath = getArrayFromComponentPath;
|
|
1434
|
+
/**
|
|
1435
|
+
* Returns true if the component is a child of the parent.
|
|
1436
|
+
* @param {any} child - The child component to check.
|
|
1437
|
+
* @param {any} parent - The parent component to check.
|
|
1438
|
+
* @returns {boolean} - TRUE if the child is a child of the parent; FALSE otherwise.
|
|
1439
|
+
*/
|
|
1309
1440
|
function isChildOf(child, parent) {
|
|
1310
1441
|
while (child && child.parent) {
|
|
1311
1442
|
if (child.parent === parent) {
|
|
@@ -1316,6 +1447,11 @@ function isChildOf(child, parent) {
|
|
|
1316
1447
|
return false;
|
|
1317
1448
|
}
|
|
1318
1449
|
exports.isChildOf = isChildOf;
|
|
1450
|
+
/**
|
|
1451
|
+
* Takes an array of component path indexes, and returns a string version of that array.
|
|
1452
|
+
* @param {Array<number>} path - The path array to convert to a string.
|
|
1453
|
+
* @returns {string} - The string version of the path.
|
|
1454
|
+
*/
|
|
1319
1455
|
function getStringFromComponentPath(path) {
|
|
1320
1456
|
if (!lodash_1.default.isArray(path)) {
|
|
1321
1457
|
return path;
|
|
@@ -1332,17 +1468,22 @@ function getStringFromComponentPath(path) {
|
|
|
1332
1468
|
return strPath;
|
|
1333
1469
|
}
|
|
1334
1470
|
exports.getStringFromComponentPath = getStringFromComponentPath;
|
|
1471
|
+
/**
|
|
1472
|
+
* Takes a number and rounds it to the provided precision amount.
|
|
1473
|
+
* @param {number} number - The number to round.
|
|
1474
|
+
* @param {number} precision - The precision to round the number to.
|
|
1475
|
+
* @returns {string} - The rounded number.
|
|
1476
|
+
*/
|
|
1335
1477
|
function round(number, precision) {
|
|
1336
1478
|
if (lodash_1.default.isNumber(number)) {
|
|
1337
1479
|
return number.toFixed(precision);
|
|
1338
1480
|
}
|
|
1339
|
-
return number;
|
|
1481
|
+
return number.toString();
|
|
1340
1482
|
}
|
|
1341
1483
|
exports.round = round;
|
|
1342
1484
|
/**
|
|
1343
1485
|
* Check for Internet Explorer browser version
|
|
1344
|
-
*
|
|
1345
|
-
* @return {(number|null)}
|
|
1486
|
+
* @returns {(number|null)} - The IE browser version or null if not IE
|
|
1346
1487
|
*/
|
|
1347
1488
|
function getIEBrowserVersion() {
|
|
1348
1489
|
const { ie, version } = getBrowserInfo();
|
|
@@ -1351,8 +1492,7 @@ function getIEBrowserVersion() {
|
|
|
1351
1492
|
exports.getIEBrowserVersion = getIEBrowserVersion;
|
|
1352
1493
|
/**
|
|
1353
1494
|
* Get browser name and version (modified from 'jquery-browser-plugin')
|
|
1354
|
-
*
|
|
1355
|
-
* @return {Object} -- {{browser name, version, isWebkit?}}
|
|
1495
|
+
* @returns {object} -- {{browser name, version, isWebkit?}}
|
|
1356
1496
|
* Possible browser names: chrome, safari, ie, edge, opera, mozilla, yabrowser
|
|
1357
1497
|
*/
|
|
1358
1498
|
function getBrowserInfo() {
|
|
@@ -1401,13 +1541,20 @@ function getBrowserInfo() {
|
|
|
1401
1541
|
return browser;
|
|
1402
1542
|
}
|
|
1403
1543
|
exports.getBrowserInfo = getBrowserInfo;
|
|
1544
|
+
/**
|
|
1545
|
+
* Takes a component path, which may include array indicies (i.e. [0][1]), and returns the compoennt path without the indicies.
|
|
1546
|
+
* @param {string} path - The path to remove the indicies from.
|
|
1547
|
+
* @returns {string} - The path without the indicies.
|
|
1548
|
+
*/
|
|
1404
1549
|
function getComponentPathWithoutIndicies(path = '') {
|
|
1405
1550
|
return path.replace(/\[\d+\]/, '');
|
|
1406
1551
|
}
|
|
1407
1552
|
exports.getComponentPathWithoutIndicies = getComponentPathWithoutIndicies;
|
|
1408
1553
|
/**
|
|
1409
1554
|
* Returns a path to the component which based on its schema
|
|
1410
|
-
* @param {
|
|
1555
|
+
* @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
|
|
1556
|
+
* @param {string} path - Path to the component
|
|
1557
|
+
* @returns {string} - Path to the component
|
|
1411
1558
|
*/
|
|
1412
1559
|
function getComponentPath(component, path = '') {
|
|
1413
1560
|
var _a;
|
|
@@ -1420,8 +1567,8 @@ function getComponentPath(component, path = '') {
|
|
|
1420
1567
|
exports.getComponentPath = getComponentPath;
|
|
1421
1568
|
/**
|
|
1422
1569
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
1423
|
-
* @param {
|
|
1424
|
-
* @
|
|
1570
|
+
* @param {Component} componentInstance - The component to check for the parent.
|
|
1571
|
+
* @returns {Component|undefined} - The parent data component.
|
|
1425
1572
|
*/
|
|
1426
1573
|
function getDataParentComponent(componentInstance) {
|
|
1427
1574
|
if (!componentInstance) {
|
|
@@ -1438,8 +1585,8 @@ function getDataParentComponent(componentInstance) {
|
|
|
1438
1585
|
exports.getDataParentComponent = getDataParentComponent;
|
|
1439
1586
|
/**
|
|
1440
1587
|
* Returns whether the value is a promise
|
|
1441
|
-
* @param value
|
|
1442
|
-
* @
|
|
1588
|
+
* @param {any} value - The value to check
|
|
1589
|
+
* @returns {boolean} - TRUE if the value is a promise; FALSE otherwise
|
|
1443
1590
|
*/
|
|
1444
1591
|
function isPromise(value) {
|
|
1445
1592
|
return value
|
|
@@ -1451,9 +1598,9 @@ exports.isPromise = isPromise;
|
|
|
1451
1598
|
/**
|
|
1452
1599
|
* Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
|
|
1453
1600
|
* changes by itself, e.g. EditGrid)
|
|
1454
|
-
* @param componentInstance
|
|
1455
|
-
* @param firstPass
|
|
1456
|
-
* @returns {boolean
|
|
1601
|
+
* @param {Component} componentInstance - The component to check for the scoping parent.
|
|
1602
|
+
* @param {boolean} firstPass - Whether it is the first pass of the function
|
|
1603
|
+
* @returns {boolean|*} - TRUE if the component has a scoping parent; FALSE otherwise
|
|
1457
1604
|
*/
|
|
1458
1605
|
function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
1459
1606
|
if (!firstPass && (componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.hasScopedChildren)) {
|
|
@@ -1469,6 +1616,11 @@ function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
|
1469
1616
|
return false;
|
|
1470
1617
|
}
|
|
1471
1618
|
exports.isInsideScopingComponent = isInsideScopingComponent;
|
|
1619
|
+
/**
|
|
1620
|
+
* Returns all the focusable elements within the provided dom element.
|
|
1621
|
+
* @param {HTMLElement} element - The element to get the focusable elements from.
|
|
1622
|
+
* @returns {NodeList<HTMLElement>} - The focusable elements within the provided element.
|
|
1623
|
+
*/
|
|
1472
1624
|
function getFocusableElements(element) {
|
|
1473
1625
|
const focusableSelector = `button:not([disabled]), input:not([disabled]), select:not([disabled]),
|
|
1474
1626
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
|
@@ -1484,6 +1636,11 @@ exports.componentValueTypes = {
|
|
|
1484
1636
|
date: 'date',
|
|
1485
1637
|
any: 'any',
|
|
1486
1638
|
};
|
|
1639
|
+
/**
|
|
1640
|
+
* Returns the saved types for the component
|
|
1641
|
+
* @param {import('@formio/core').Component} fullSchema - The component schema
|
|
1642
|
+
* @returns {Array<string>|null} - The saved types for the component
|
|
1643
|
+
*/
|
|
1487
1644
|
function getComponentSavedTypes(fullSchema) {
|
|
1488
1645
|
const schema = fullSchema || {};
|
|
1489
1646
|
if (schema.persistent !== true) {
|
|
@@ -1497,9 +1654,10 @@ function getComponentSavedTypes(fullSchema) {
|
|
|
1497
1654
|
exports.getComponentSavedTypes = getComponentSavedTypes;
|
|
1498
1655
|
/**
|
|
1499
1656
|
* Interpolates @formio/core errors so that they are compatible with the renderer
|
|
1500
|
-
* @param {
|
|
1501
|
-
* @param
|
|
1502
|
-
* @
|
|
1657
|
+
* @param {Component} component - The component to interpolate the errors for
|
|
1658
|
+
* @param {FieldError[]} errors - The errors to interpolate
|
|
1659
|
+
* @param {Function} interpolateFn - The interpolation function
|
|
1660
|
+
* @returns {[]} - The interpolated errors
|
|
1503
1661
|
*/
|
|
1504
1662
|
const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1505
1663
|
return errors.map((error) => {
|
|
@@ -1510,6 +1668,11 @@ const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1510
1668
|
});
|
|
1511
1669
|
};
|
|
1512
1670
|
exports.interpolateErrors = interpolateErrors;
|
|
1671
|
+
/**
|
|
1672
|
+
* Returns the template keys inside the template code.
|
|
1673
|
+
* @param {string} template - The template to get the keys from.
|
|
1674
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
1675
|
+
*/
|
|
1513
1676
|
function getItemTemplateKeys(template) {
|
|
1514
1677
|
const templateKeys = [];
|
|
1515
1678
|
if (!template) {
|
|
@@ -1527,6 +1690,11 @@ function getItemTemplateKeys(template) {
|
|
|
1527
1690
|
return templateKeys;
|
|
1528
1691
|
}
|
|
1529
1692
|
exports.getItemTemplateKeys = getItemTemplateKeys;
|
|
1693
|
+
/**
|
|
1694
|
+
* Returns if the component is a select resource with an object for its value.
|
|
1695
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1696
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1697
|
+
*/
|
|
1530
1698
|
function isSelectResourceWithObjectValue(comp = {}) {
|
|
1531
1699
|
const { reference, dataSrc, valueProperty } = comp;
|
|
1532
1700
|
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|