@formio/js 5.0.0-dev.5643.9c5173a → 5.0.0-dev.5646.35daa65
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 +65 -2
- package/dist/formio.builder.css +8 -8
- 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 -8
- package/dist/formio.form.js +792 -1237
- 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 -5
- package/dist/formio.full.css +8 -8
- package/dist/formio.full.js +692 -933
- 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 -5
- 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 -476
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +10 -4
- 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 +86 -96
- package/lib/cjs/Element.js +68 -78
- 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 -64
- package/lib/cjs/FormBuilder.d.ts +187 -2
- package/lib/cjs/FormBuilder.js +30 -8
- package/lib/cjs/Formio.js +1 -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 +6 -8
- package/lib/cjs/Webform.d.ts +187 -139
- package/lib/cjs/Webform.js +330 -300
- package/lib/cjs/WebformBuilder.d.ts +16 -14
- package/lib/cjs/WebformBuilder.js +19 -12
- package/lib/cjs/Wizard.d.ts +31 -21
- package/lib/cjs/Wizard.js +43 -20
- package/lib/cjs/WizardBuilder.d.ts +1 -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 +515 -269
- 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 +462 -204
- 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 +31 -7
- 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 +163 -67
- 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 +175 -54
- 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 +3 -12
- 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 +5 -0
- 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 +1 -1
- 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-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 +4 -1
- package/lib/cjs/components/datagrid/fixtures/index.js +7 -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 +7 -3
- 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 +5 -5
- 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 -22
- 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 +1 -2
- 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 +27 -15
- 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 +3 -26
- 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 +6 -7
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +5 -0
- 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 +14 -18
- 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 +7 -9
- 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 +2 -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/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/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 +360 -223
- package/lib/cjs/utils/utils.js +394 -239
- package/lib/cjs/widgets/CalendarWidget.d.ts +9 -10
- package/lib/cjs/widgets/CalendarWidget.js +9 -11
- package/lib/mjs/CDN.d.ts +1 -0
- package/lib/mjs/CDN.js +6 -3
- package/lib/mjs/Element.d.ts +86 -96
- package/lib/mjs/Element.js +68 -78
- 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 -57
- package/lib/mjs/FormBuilder.d.ts +187 -2
- package/lib/mjs/FormBuilder.js +32 -8
- package/lib/mjs/Formio.js +1 -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 +6 -8
- package/lib/mjs/Webform.d.ts +187 -139
- package/lib/mjs/Webform.js +342 -312
- package/lib/mjs/WebformBuilder.d.ts +16 -14
- package/lib/mjs/WebformBuilder.js +19 -12
- package/lib/mjs/Wizard.d.ts +31 -21
- package/lib/mjs/Wizard.js +42 -19
- package/lib/mjs/WizardBuilder.d.ts +1 -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 +515 -269
- 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 +470 -204
- 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 +30 -7
- 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 +163 -67
- 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 +175 -54
- 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 +3 -12
- 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 +5 -0
- 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 +1 -1
- 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-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 +4 -1
- package/lib/mjs/components/datagrid/fixtures/index.js +4 -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 +7 -3
- 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 +5 -5
- 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 -22
- 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 +1 -2
- 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 +25 -13
- 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 +3 -26
- 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 +6 -6
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +6 -3
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +5 -0
- 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 +15 -19
- 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 +7 -9
- 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 +2 -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/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/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 +360 -223
- package/lib/mjs/utils/utils.js +387 -233
- package/lib/mjs/widgets/CalendarWidget.d.ts +9 -10
- package/lib/mjs/widgets/CalendarWidget.js +9 -11
- package/package.json +22 -23
- package/sdk.d.ts +1 -0
- package/utils.d.ts +1 -0
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -34,7 +34,6 @@ exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.unique
|
|
|
34
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 = exports.observeOverload = exports.withSwitch = void 0;
|
|
35
35
|
const lodash_1 = __importDefault(require("lodash"));
|
|
36
36
|
exports._ = lodash_1.default;
|
|
37
|
-
const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
|
|
38
37
|
const json_logic_js_1 = __importDefault(require("json-logic-js"));
|
|
39
38
|
exports.jsonLogic = json_logic_js_1.default;
|
|
40
39
|
const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
|
|
@@ -42,15 +41,12 @@ const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
|
|
|
42
41
|
const operators_1 = require("./jsonlogic/operators");
|
|
43
42
|
const dompurify_1 = __importDefault(require("dompurify"));
|
|
44
43
|
const formUtils_1 = require("./formUtils");
|
|
45
|
-
const Evaluator_1 =
|
|
46
|
-
exports
|
|
44
|
+
const Evaluator_1 = require("./Evaluator");
|
|
45
|
+
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
|
47
46
|
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
|
48
47
|
exports.ConditionOperators = conditionOperators_1.default;
|
|
49
|
-
const interpolate = Evaluator_1.
|
|
48
|
+
const interpolate = Evaluator_1.Evaluator.interpolate;
|
|
50
49
|
exports.interpolate = interpolate;
|
|
51
|
-
const { fetch } = (0, fetch_ponyfill_1.default)({
|
|
52
|
-
Promise: Promise
|
|
53
|
-
});
|
|
54
50
|
__exportStar(require("./formUtils"), exports);
|
|
55
51
|
// Configure JsonLogic
|
|
56
52
|
operators_1.lodashOperators.forEach((name) => json_logic_js_1.default.add_operation(`_${name}`, lodash_1.default[name]));
|
|
@@ -67,6 +63,10 @@ json_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
|
|
67
63
|
return (0, moment_timezone_1.default)().add(relativeMaxDate, 'days').toISOString();
|
|
68
64
|
});
|
|
69
65
|
exports.moment = __importStar(require("moment-timezone/moment-timezone"));
|
|
66
|
+
/**
|
|
67
|
+
* Sets the path to the component and parent schema.
|
|
68
|
+
* @param {import('@formio/core').Component} component - The component to set the path for.
|
|
69
|
+
*/
|
|
70
70
|
function setPathToComponentAndPerentSchema(component) {
|
|
71
71
|
component.path = getComponentPath(component);
|
|
72
72
|
const dataParent = getDataParentComponent(component);
|
|
@@ -76,79 +76,30 @@ function setPathToComponentAndPerentSchema(component) {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* 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;
|
|
79
|
+
* @param {Function|string|object} func - The function to evaluate.
|
|
80
|
+
* @param {*} args - A map of arguments to pass to the function.
|
|
81
|
+
* @param {string} ret - The name of the "return" variable in the script.
|
|
82
|
+
* @param {boolean} interpolate - True if the script should be interpolated before being executed.
|
|
83
|
+
* @param {import('@formio/core').EvaluatorOptions} options - The evaluator options.
|
|
84
|
+
* @returns {*} - The result of the evaluation.
|
|
85
|
+
*/
|
|
86
|
+
function evaluate(func, args, ret, interpolate, options = {}) {
|
|
87
|
+
return Evaluator_1.Evaluator.evaluate(func, args, ret, interpolate, undefined, options);
|
|
140
88
|
}
|
|
141
89
|
exports.evaluate = evaluate;
|
|
90
|
+
/**
|
|
91
|
+
* Returns a random compoennt ID.
|
|
92
|
+
* @returns {string} - A random component ID.
|
|
93
|
+
*/
|
|
142
94
|
function getRandomComponentId() {
|
|
143
95
|
return `e${Math.random().toString(36).substring(7)}`;
|
|
144
96
|
}
|
|
145
97
|
exports.getRandomComponentId = getRandomComponentId;
|
|
146
98
|
/**
|
|
147
99
|
* Get a property value of an element.
|
|
148
|
-
*
|
|
149
|
-
* @param
|
|
150
|
-
* @
|
|
151
|
-
* @return {number}
|
|
100
|
+
* @param {CSSStyleDeclaration} style - The style element to get the property value from.
|
|
101
|
+
* @param {string} prop - The property to get the value for.
|
|
102
|
+
* @returns {number} - The value of the property.
|
|
152
103
|
*/
|
|
153
104
|
function getPropertyValue(style, prop) {
|
|
154
105
|
let value = style.getPropertyValue(prop);
|
|
@@ -158,9 +109,8 @@ function getPropertyValue(style, prop) {
|
|
|
158
109
|
exports.getPropertyValue = getPropertyValue;
|
|
159
110
|
/**
|
|
160
111
|
* Get an elements bounding rectagle.
|
|
161
|
-
*
|
|
162
|
-
* @
|
|
163
|
-
* @return {{x: string, y: string, width: string, height: string}}
|
|
112
|
+
* @param {HTMLElement} element - A DOM element to get the bounding rectangle for.
|
|
113
|
+
* @returns {{x: number, y: number, width: number, height: number}} - The bounding rectangle.
|
|
164
114
|
*/
|
|
165
115
|
function getElementRect(element) {
|
|
166
116
|
const style = window.getComputedStyle(element, null);
|
|
@@ -174,8 +124,8 @@ function getElementRect(element) {
|
|
|
174
124
|
exports.getElementRect = getElementRect;
|
|
175
125
|
/**
|
|
176
126
|
* Get non HTMLElement property in the window object
|
|
177
|
-
* @param {
|
|
178
|
-
* @
|
|
127
|
+
* @param {string} property - The window property to fetch the script plugin from.
|
|
128
|
+
* @returns {any | undefined} - The HTML Element property on the window object.
|
|
179
129
|
*/
|
|
180
130
|
function getScriptPlugin(property) {
|
|
181
131
|
const obj = window[property];
|
|
@@ -188,9 +138,8 @@ function getScriptPlugin(property) {
|
|
|
188
138
|
exports.getScriptPlugin = getScriptPlugin;
|
|
189
139
|
/**
|
|
190
140
|
* Determines the boolean value of a setting.
|
|
191
|
-
*
|
|
192
|
-
* @
|
|
193
|
-
* @return {boolean}
|
|
141
|
+
* @param {string|boolean} value - A string or boolean value to convert to boolean.
|
|
142
|
+
* @returns {boolean} - The boolean value of the setting.
|
|
194
143
|
*/
|
|
195
144
|
function boolValue(value) {
|
|
196
145
|
if (lodash_1.default.isBoolean(value)) {
|
|
@@ -206,22 +155,18 @@ function boolValue(value) {
|
|
|
206
155
|
exports.boolValue = boolValue;
|
|
207
156
|
/**
|
|
208
157
|
* Check to see if an ID is a mongoID.
|
|
209
|
-
* @param text
|
|
210
|
-
* @
|
|
158
|
+
* @param {string} text - The text to check if it is a mongoID.
|
|
159
|
+
* @returns {boolean} - TRUE if the text is a mongoID; FALSE otherwise.
|
|
211
160
|
*/
|
|
212
161
|
function isMongoId(text) {
|
|
213
|
-
return text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
162
|
+
return !!text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
214
163
|
}
|
|
215
164
|
exports.isMongoId = isMongoId;
|
|
216
165
|
/**
|
|
217
166
|
* Checks the calculated value for a provided component and data.
|
|
218
|
-
*
|
|
219
|
-
* @param {
|
|
220
|
-
*
|
|
221
|
-
* @param {Object} submission
|
|
222
|
-
* A submission object.
|
|
223
|
-
* @param data
|
|
224
|
-
* The full submission data.
|
|
167
|
+
* @param {import('@formio/core').Component} component - The component to check for the calculated value.
|
|
168
|
+
* @param {import('@formio/core').Submission} submission - A submission object.
|
|
169
|
+
* @param {*} rowData - The contextual row data for the component.
|
|
225
170
|
*/
|
|
226
171
|
function checkCalculated(component, submission, rowData) {
|
|
227
172
|
// Process calculated value stuff if present.
|
|
@@ -238,14 +183,51 @@ function checkCalculated(component, submission, rowData) {
|
|
|
238
183
|
exports.checkCalculated = checkCalculated;
|
|
239
184
|
/**
|
|
240
185
|
* Check if a simple conditional evaluates to true.
|
|
241
|
-
*
|
|
242
|
-
* @param condition
|
|
243
|
-
* @param
|
|
244
|
-
* @param
|
|
245
|
-
* @param
|
|
246
|
-
* @
|
|
247
|
-
* @returns {boolean}
|
|
186
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
187
|
+
* @param {import('@formio/core').SimpleConditional} condition - The condition to check.
|
|
188
|
+
* @param {*} row - The row data for the component.
|
|
189
|
+
* @param {*} data - The full submission data.
|
|
190
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
|
|
191
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
248
192
|
*/
|
|
193
|
+
function getConditionalPathsRecursive(conditionPaths, data) {
|
|
194
|
+
let currentGlobalIndex = 0;
|
|
195
|
+
const conditionalPathsArray = [];
|
|
196
|
+
const getConditionalPaths = (data, currentPath = '', localIndex = 0) => {
|
|
197
|
+
currentPath = currentPath.replace(/^\.+|\.+$/g, '');
|
|
198
|
+
const currentLocalIndex = localIndex;
|
|
199
|
+
const currentData = lodash_1.default.get(data, currentPath);
|
|
200
|
+
if (Array.isArray(currentData) && currentData.filter(Boolean).length > 0) {
|
|
201
|
+
if (currentData.some(element => typeof element !== 'object')) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const hasInnerDataArray = currentData.find(x => Array.isArray(x[conditionPaths[currentLocalIndex]]));
|
|
205
|
+
if (hasInnerDataArray) {
|
|
206
|
+
currentData.forEach((_, indexOutside) => {
|
|
207
|
+
const innerCompDataPath = `${currentPath}[${indexOutside}].${conditionPaths[currentLocalIndex]}`;
|
|
208
|
+
getConditionalPaths(data, innerCompDataPath, currentLocalIndex + 1);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
currentData.forEach((x, index) => {
|
|
213
|
+
if (!lodash_1.default.isNil(x[conditionPaths[currentLocalIndex]])) {
|
|
214
|
+
const compDataPath = `${currentPath}[${index}].${conditionPaths[currentLocalIndex]}`;
|
|
215
|
+
conditionalPathsArray.push(compDataPath);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
if (!conditionPaths[currentGlobalIndex]) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
currentGlobalIndex = currentGlobalIndex + 1;
|
|
225
|
+
getConditionalPaths(data, `${currentPath}.${conditionPaths[currentGlobalIndex - 1]}`, currentGlobalIndex);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
getConditionalPaths(data);
|
|
229
|
+
return conditionalPathsArray;
|
|
230
|
+
}
|
|
249
231
|
function checkSimpleConditional(component, condition, row, data, instance) {
|
|
250
232
|
if (condition.when) {
|
|
251
233
|
const value = getComponentActualValue(condition.when, data, row);
|
|
@@ -267,28 +249,49 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
|
267
249
|
return true;
|
|
268
250
|
}
|
|
269
251
|
const conditionsResult = lodash_1.default.map(conditions, (cond) => {
|
|
252
|
+
var _a, _b;
|
|
270
253
|
const { value: comparedValue, operator, component: conditionComponentPath } = cond;
|
|
271
254
|
if (!conditionComponentPath) {
|
|
272
255
|
return true;
|
|
273
256
|
}
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
257
|
+
const splittedConditionPath = conditionComponentPath.split('.');
|
|
258
|
+
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);
|
|
259
|
+
if (conditionalPaths.length > 0) {
|
|
260
|
+
return conditionalPaths.map((path) => {
|
|
261
|
+
const value = getComponentActualValue(path, data, row);
|
|
262
|
+
const ConditionOperator = conditionOperators_1.default[operator];
|
|
263
|
+
return ConditionOperator
|
|
264
|
+
? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
|
265
|
+
: true;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
const value = getComponentActualValue(conditionComponentPath, data, row);
|
|
270
|
+
const СonditionOperator = conditionOperators_1.default[operator];
|
|
271
|
+
return СonditionOperator
|
|
272
|
+
? new СonditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
|
273
|
+
: true;
|
|
274
|
+
}
|
|
279
275
|
});
|
|
280
276
|
let result = false;
|
|
281
277
|
switch (conjunction) {
|
|
282
278
|
case 'any':
|
|
283
|
-
result = lodash_1.default.some(conditionsResult, res => !!res);
|
|
279
|
+
result = lodash_1.default.some(conditionsResult.flat(), res => !!res);
|
|
284
280
|
break;
|
|
285
281
|
default:
|
|
286
|
-
result = lodash_1.default.every(conditionsResult, res => !!res);
|
|
282
|
+
result = lodash_1.default.every(conditionsResult.flat(), res => !!res);
|
|
287
283
|
}
|
|
288
284
|
return show ? result : !result;
|
|
289
285
|
}
|
|
290
286
|
}
|
|
291
287
|
exports.checkSimpleConditional = checkSimpleConditional;
|
|
288
|
+
/**
|
|
289
|
+
* Returns a components normalized value.
|
|
290
|
+
* @param {string} compPath - The full path to the component.
|
|
291
|
+
* @param {*} data - The data object to get the value from.
|
|
292
|
+
* @param {*} row - The contextual row data for the component.
|
|
293
|
+
* @returns {*} - The normalized value of the component.
|
|
294
|
+
*/
|
|
292
295
|
function getComponentActualValue(compPath, data, row) {
|
|
293
296
|
let value = null;
|
|
294
297
|
if (row) {
|
|
@@ -306,12 +309,15 @@ function getComponentActualValue(compPath, data, row) {
|
|
|
306
309
|
exports.getComponentActualValue = getComponentActualValue;
|
|
307
310
|
/**
|
|
308
311
|
* Check custom javascript conditional.
|
|
309
|
-
*
|
|
310
|
-
* @param
|
|
311
|
-
* @param
|
|
312
|
-
* @param
|
|
313
|
-
* @param
|
|
314
|
-
* @
|
|
312
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
313
|
+
* @param {string} custom - The custom conditional string to evaluate.
|
|
314
|
+
* @param {*} row - The row data for the component.
|
|
315
|
+
* @param {*} data - The full submission data.
|
|
316
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
317
|
+
* @param {string} variable - The variable name for the result of the custom conditional.
|
|
318
|
+
* @param {*} onError - A custom return if there is an error or the value is null from the evaluation.
|
|
319
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
320
|
+
* @returns {*} - The result of the evaulation.
|
|
315
321
|
*/
|
|
316
322
|
function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
|
|
317
323
|
if (typeof custom === 'string') {
|
|
@@ -326,6 +332,16 @@ function checkCustomConditional(component, custom, row, data, form, variable, on
|
|
|
326
332
|
return value;
|
|
327
333
|
}
|
|
328
334
|
exports.checkCustomConditional = checkCustomConditional;
|
|
335
|
+
/**
|
|
336
|
+
* Check a component for JSON conditionals.
|
|
337
|
+
* @param {import('@formio/core').Component} component - The component
|
|
338
|
+
* @param {import('@formio/core').JSONConditional} json - The json conditional to check.
|
|
339
|
+
* @param {*} row - The contextual row data for the component.
|
|
340
|
+
* @param {*} data - The full submission data.
|
|
341
|
+
* @param {import('@formio/core').Form} form - The Form JSON of the form.
|
|
342
|
+
* @param {*} onError - Custom return value if there is an error.
|
|
343
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
344
|
+
*/
|
|
329
345
|
function checkJsonConditional(component, json, row, data, form, onError) {
|
|
330
346
|
try {
|
|
331
347
|
return json_logic_js_1.default.apply(json, {
|
|
@@ -341,6 +357,14 @@ function checkJsonConditional(component, json, row, data, form, onError) {
|
|
|
341
357
|
}
|
|
342
358
|
}
|
|
343
359
|
exports.checkJsonConditional = checkJsonConditional;
|
|
360
|
+
/**
|
|
361
|
+
* Returns the contextual row data for a component.
|
|
362
|
+
* @param {import('@formio/core').Component} component - The component to get the row data for.
|
|
363
|
+
* @param {*} row - The row data for the component.
|
|
364
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
365
|
+
* @param {*} conditional - The component conditional.
|
|
366
|
+
* @returns {*} - The contextual row data for the component.
|
|
367
|
+
*/
|
|
344
368
|
function getRow(component, row, instance, conditional) {
|
|
345
369
|
var _a;
|
|
346
370
|
const condition = conditional || component.conditional;
|
|
@@ -363,15 +387,12 @@ function getRow(component, row, instance, conditional) {
|
|
|
363
387
|
}
|
|
364
388
|
/**
|
|
365
389
|
* Checks the conditions for a provided component and data.
|
|
366
|
-
*
|
|
367
|
-
* @param
|
|
368
|
-
*
|
|
369
|
-
* @param
|
|
370
|
-
*
|
|
371
|
-
* @
|
|
372
|
-
* The full submission data.
|
|
373
|
-
*
|
|
374
|
-
* @returns {boolean}
|
|
390
|
+
* @param {import('@formio/core').Component} component - The component to check for the condition.
|
|
391
|
+
* @param {*} row - The data within a row
|
|
392
|
+
* @param {*} data - The full submission data.
|
|
393
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
394
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
395
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
375
396
|
*/
|
|
376
397
|
function checkCondition(component, row, data, form, instance) {
|
|
377
398
|
const { customConditional, conditional } = component;
|
|
@@ -391,12 +412,13 @@ function checkCondition(component, row, data, form, instance) {
|
|
|
391
412
|
exports.checkCondition = checkCondition;
|
|
392
413
|
/**
|
|
393
414
|
* Test a trigger on a component.
|
|
394
|
-
*
|
|
395
|
-
* @param
|
|
396
|
-
* @param
|
|
397
|
-
* @param data
|
|
398
|
-
* @param
|
|
399
|
-
* @
|
|
415
|
+
* @param {import('@formio/core').Component} component - The component to test the trigger against.
|
|
416
|
+
* @param {import('@formio/core').LogicTrigger} trigger - The trigger configuration.
|
|
417
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
418
|
+
* @param {import('@formio/core').DataObject} data - The root data object.
|
|
419
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
420
|
+
* @param {any} instance - The component that is performing the trigger.
|
|
421
|
+
* @returns {boolean} - TRUE if the trigger should fire; FALSE otherwise.
|
|
400
422
|
*/
|
|
401
423
|
function checkTrigger(component, trigger, row, data, form, instance) {
|
|
402
424
|
// If trigger is empty, don't fire it
|
|
@@ -416,6 +438,16 @@ function checkTrigger(component, trigger, row, data, form, instance) {
|
|
|
416
438
|
return false;
|
|
417
439
|
}
|
|
418
440
|
exports.checkTrigger = checkTrigger;
|
|
441
|
+
/**
|
|
442
|
+
* Sets a property on a component via an executed Logic action.
|
|
443
|
+
* @param {import('@formio/core').Component} component - The component to set the property on.
|
|
444
|
+
* @param {import('@formio/core').LogicAction} action - The action to perform on the component.
|
|
445
|
+
* @param {string} result - The name of the variable in the evaulation to use as the result.
|
|
446
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
447
|
+
* @param {import('@formio/core').DataObject} data - The full submission data.
|
|
448
|
+
* @param {any} instance - The component instance.
|
|
449
|
+
* @returns {import('@formio/core').Component} - The modified component.
|
|
450
|
+
*/
|
|
419
451
|
function setActionProperty(component, action, result, row, data, instance) {
|
|
420
452
|
const property = action.property.value;
|
|
421
453
|
switch (action.property.type) {
|
|
@@ -438,7 +470,7 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
438
470
|
const currentValue = lodash_1.default.get(component, property, '');
|
|
439
471
|
const newValue = (instance && instance.interpolate)
|
|
440
472
|
? instance.interpolate(textValue, evalData)
|
|
441
|
-
: Evaluator_1.
|
|
473
|
+
: Evaluator_1.Evaluator.interpolate(textValue, evalData);
|
|
442
474
|
if (newValue !== currentValue) {
|
|
443
475
|
lodash_1.default.set(component, property, newValue);
|
|
444
476
|
}
|
|
@@ -450,8 +482,8 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
450
482
|
exports.setActionProperty = setActionProperty;
|
|
451
483
|
/**
|
|
452
484
|
* Removes HTML tags from string e.g. <div>Hello World</div> => Hello World
|
|
453
|
-
* @param {string} str
|
|
454
|
-
* @returns {string}
|
|
485
|
+
* @param {string} str - The string to remove HTML tags from.
|
|
486
|
+
* @returns {string} - The string without HTML tags.
|
|
455
487
|
*/
|
|
456
488
|
function removeHTML(str) {
|
|
457
489
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -460,8 +492,8 @@ function removeHTML(str) {
|
|
|
460
492
|
exports.removeHTML = removeHTML;
|
|
461
493
|
/**
|
|
462
494
|
* Unescape HTML characters like <, >, & and etc.
|
|
463
|
-
* @param str
|
|
464
|
-
* @returns {string}
|
|
495
|
+
* @param {string} str - The string to unescape.
|
|
496
|
+
* @returns {string} - The unescaped string.
|
|
465
497
|
*/
|
|
466
498
|
function unescapeHTML(str) {
|
|
467
499
|
if (typeof window === 'undefined' || !('DOMParser' in window)) {
|
|
@@ -474,9 +506,9 @@ function unescapeHTML(str) {
|
|
|
474
506
|
exports.unescapeHTML = unescapeHTML;
|
|
475
507
|
/**
|
|
476
508
|
* Make HTML element from string
|
|
477
|
-
* @param str
|
|
478
|
-
* @param selector
|
|
479
|
-
* @returns {HTMLElement}
|
|
509
|
+
* @param {string} str - The string to convert to an HTML element.
|
|
510
|
+
* @param {string} selector - The selector to use to get the element once it is created.
|
|
511
|
+
* @returns {HTMLElement} - The HTML element that was created.
|
|
480
512
|
*/
|
|
481
513
|
function convertStringToHTMLElement(str, selector) {
|
|
482
514
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -485,10 +517,10 @@ function convertStringToHTMLElement(str, selector) {
|
|
|
485
517
|
exports.convertStringToHTMLElement = convertStringToHTMLElement;
|
|
486
518
|
/**
|
|
487
519
|
* Make a filename guaranteed to be unique.
|
|
488
|
-
* @param name
|
|
489
|
-
* @param template
|
|
490
|
-
* @param evalContext
|
|
491
|
-
* @returns {string}
|
|
520
|
+
* @param {string} name - The original name of the file.
|
|
521
|
+
* @param {string} template - The template to use for the unique name.
|
|
522
|
+
* @param {object} evalContext - The context to use for the evaluation.
|
|
523
|
+
* @returns {string} - A unique filename.
|
|
492
524
|
*/
|
|
493
525
|
function uniqueName(name, template, evalContext) {
|
|
494
526
|
template = template || '{{fileName}}-{{guid}}';
|
|
@@ -508,10 +540,14 @@ function uniqueName(name, template, evalContext) {
|
|
|
508
540
|
guid: guid()
|
|
509
541
|
});
|
|
510
542
|
//only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash
|
|
511
|
-
const uniqueName = `${Evaluator_1.
|
|
543
|
+
const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
|
|
512
544
|
return uniqueName;
|
|
513
545
|
}
|
|
514
546
|
exports.uniqueName = uniqueName;
|
|
547
|
+
/**
|
|
548
|
+
* Returns a GUID
|
|
549
|
+
* @returns {string} - A GUID.
|
|
550
|
+
*/
|
|
515
551
|
function guid() {
|
|
516
552
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
517
553
|
const r = Math.random() * 16 | 0;
|
|
@@ -524,9 +560,8 @@ function guid() {
|
|
|
524
560
|
exports.guid = guid;
|
|
525
561
|
/**
|
|
526
562
|
* Return a translated date setting.
|
|
527
|
-
*
|
|
528
|
-
* @
|
|
529
|
-
* @return {(null|Date)}
|
|
563
|
+
* @param {string|Date} date - The date to translate.
|
|
564
|
+
* @returns {(null|Date)} - The translated date.
|
|
530
565
|
*/
|
|
531
566
|
function getDateSetting(date) {
|
|
532
567
|
if (lodash_1.default.isNil(date) || lodash_1.default.isNaN(date) || date === '') {
|
|
@@ -544,7 +579,7 @@ function getDateSetting(date) {
|
|
|
544
579
|
}
|
|
545
580
|
dateSetting = null;
|
|
546
581
|
try {
|
|
547
|
-
const value = Evaluator_1.
|
|
582
|
+
const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
|
|
548
583
|
if (typeof value === 'string') {
|
|
549
584
|
dateSetting = (0, moment_timezone_1.default)(value);
|
|
550
585
|
}
|
|
@@ -568,14 +603,18 @@ function getDateSetting(date) {
|
|
|
568
603
|
return dateSetting.toDate();
|
|
569
604
|
}
|
|
570
605
|
exports.getDateSetting = getDateSetting;
|
|
606
|
+
/**
|
|
607
|
+
* Returns true if the date is a valid date. False otherwise.
|
|
608
|
+
* @param {Date|string} date - The date to check for validity.
|
|
609
|
+
* @returns {boolean} - TRUE if the date is valid; FALSE otherwise.
|
|
610
|
+
*/
|
|
571
611
|
function isValidDate(date) {
|
|
572
612
|
return lodash_1.default.isDate(date) && !lodash_1.default.isNaN(date.getDate());
|
|
573
613
|
}
|
|
574
614
|
exports.isValidDate = isValidDate;
|
|
575
615
|
/**
|
|
576
616
|
* Get the current timezone string.
|
|
577
|
-
*
|
|
578
|
-
* @return {string}
|
|
617
|
+
* @returns {string} - The current timezone.
|
|
579
618
|
*/
|
|
580
619
|
function currentTimezone() {
|
|
581
620
|
if (moment_timezone_1.default.currentTimezone) {
|
|
@@ -587,10 +626,9 @@ function currentTimezone() {
|
|
|
587
626
|
exports.currentTimezone = currentTimezone;
|
|
588
627
|
/**
|
|
589
628
|
* Get an offset date provided a date object and timezone object.
|
|
590
|
-
*
|
|
591
|
-
* @param date
|
|
592
|
-
* @
|
|
593
|
-
* @return {Date}
|
|
629
|
+
* @param {Date} date - The date to offset.
|
|
630
|
+
* @param {string} timezone - The timezone to offset the date to.
|
|
631
|
+
* @returns {Date} - The offset date.
|
|
594
632
|
*/
|
|
595
633
|
function offsetDate(date, timezone) {
|
|
596
634
|
if (timezone === 'UTC') {
|
|
@@ -608,8 +646,7 @@ function offsetDate(date, timezone) {
|
|
|
608
646
|
exports.offsetDate = offsetDate;
|
|
609
647
|
/**
|
|
610
648
|
* Returns if the zones are loaded.
|
|
611
|
-
*
|
|
612
|
-
* @return {boolean}
|
|
649
|
+
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
|
613
650
|
*/
|
|
614
651
|
function zonesLoaded() {
|
|
615
652
|
return moment_timezone_1.default.zonesLoaded;
|
|
@@ -617,9 +654,8 @@ function zonesLoaded() {
|
|
|
617
654
|
exports.zonesLoaded = zonesLoaded;
|
|
618
655
|
/**
|
|
619
656
|
* Returns if we should load the zones.
|
|
620
|
-
*
|
|
621
|
-
* @
|
|
622
|
-
* @return {boolean}
|
|
657
|
+
* @param {string} timezone - The timezone to check if we should load the zones.
|
|
658
|
+
* @returns {boolean} - TRUE if we should load the zones; FALSE otherwise.
|
|
623
659
|
*/
|
|
624
660
|
function shouldLoadZones(timezone) {
|
|
625
661
|
if (timezone === currentTimezone() || timezone === 'UTC') {
|
|
@@ -630,8 +666,9 @@ function shouldLoadZones(timezone) {
|
|
|
630
666
|
exports.shouldLoadZones = shouldLoadZones;
|
|
631
667
|
/**
|
|
632
668
|
* Externally load the timezone data.
|
|
633
|
-
*
|
|
634
|
-
* @
|
|
669
|
+
* @param {string} url - The URL to load the timezone data from.
|
|
670
|
+
* @param {string} timezone - The timezone to load.
|
|
671
|
+
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
635
672
|
*/
|
|
636
673
|
function loadZones(url, timezone) {
|
|
637
674
|
if (timezone && !shouldLoadZones(timezone)) {
|
|
@@ -656,11 +693,10 @@ function loadZones(url, timezone) {
|
|
|
656
693
|
exports.loadZones = loadZones;
|
|
657
694
|
/**
|
|
658
695
|
* Get the moment date object for translating dates with timezones.
|
|
659
|
-
*
|
|
660
|
-
* @param
|
|
661
|
-
* @param
|
|
662
|
-
* @
|
|
663
|
-
* @return {*}
|
|
696
|
+
* @param {string|Date} value - The value to convert into a moment date.
|
|
697
|
+
* @param {string} format - The format to convert the date to.
|
|
698
|
+
* @param {string} timezone - The timezone to convert the date to.
|
|
699
|
+
* @returns {Date} - The moment date object.
|
|
664
700
|
*/
|
|
665
701
|
function momentDate(value, format, timezone) {
|
|
666
702
|
const momentDate = (0, moment_timezone_1.default)(value);
|
|
@@ -678,11 +714,12 @@ function momentDate(value, format, timezone) {
|
|
|
678
714
|
exports.momentDate = momentDate;
|
|
679
715
|
/**
|
|
680
716
|
* Format a date provided a value, format, and timezone object.
|
|
681
|
-
*
|
|
682
|
-
* @param value
|
|
683
|
-
* @param format
|
|
684
|
-
* @param timezone
|
|
685
|
-
* @
|
|
717
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
718
|
+
* @param {string|Date} value - The value to format.
|
|
719
|
+
* @param {string} format - The format to format the date to.
|
|
720
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
721
|
+
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
|
722
|
+
* @returns {string} - The formatted date.
|
|
686
723
|
*/
|
|
687
724
|
function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat) {
|
|
688
725
|
const momentDate = (0, moment_timezone_1.default)(value, flatPickrInputFormat || undefined);
|
|
@@ -716,12 +753,12 @@ function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat)
|
|
|
716
753
|
exports.formatDate = formatDate;
|
|
717
754
|
/**
|
|
718
755
|
* Pass a format function to format within a timezone.
|
|
719
|
-
*
|
|
720
|
-
* @param formatFn
|
|
721
|
-
* @param date
|
|
722
|
-
* @param format
|
|
723
|
-
* @param timezone
|
|
724
|
-
* @
|
|
756
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
757
|
+
* @param {Function} formatFn - The format function to use.
|
|
758
|
+
* @param {Date|string} date - The date to format.
|
|
759
|
+
* @param {string} format - The format to format the date to.
|
|
760
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
761
|
+
* @returns {string} - The formatted date.
|
|
725
762
|
*/
|
|
726
763
|
function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
727
764
|
if (timezone === currentTimezone()) {
|
|
@@ -741,6 +778,11 @@ function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
|
741
778
|
}
|
|
742
779
|
}
|
|
743
780
|
exports.formatOffset = formatOffset;
|
|
781
|
+
/**
|
|
782
|
+
* Returns the local date format information.
|
|
783
|
+
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
|
784
|
+
* @returns {object} - The local date format information.
|
|
785
|
+
*/
|
|
744
786
|
function getLocaleDateFormatInfo(locale) {
|
|
745
787
|
const formatInfo = {};
|
|
746
788
|
const day = 21;
|
|
@@ -752,8 +794,8 @@ function getLocaleDateFormatInfo(locale) {
|
|
|
752
794
|
exports.getLocaleDateFormatInfo = getLocaleDateFormatInfo;
|
|
753
795
|
/**
|
|
754
796
|
* Convert the format from the angular-datepicker module to flatpickr format.
|
|
755
|
-
* @param format
|
|
756
|
-
* @
|
|
797
|
+
* @param {string} format - The format to convert.
|
|
798
|
+
* @returns {string} - The converted format.
|
|
757
799
|
*/
|
|
758
800
|
function convertFormatToFlatpickr(format) {
|
|
759
801
|
return format
|
|
@@ -784,8 +826,8 @@ function convertFormatToFlatpickr(format) {
|
|
|
784
826
|
exports.convertFormatToFlatpickr = convertFormatToFlatpickr;
|
|
785
827
|
/**
|
|
786
828
|
* Convert the format from the angular-datepicker module to moment format.
|
|
787
|
-
* @param format
|
|
788
|
-
* @
|
|
829
|
+
* @param {string} format - The format to convert.
|
|
830
|
+
* @returns {string} - The converted format.
|
|
789
831
|
*/
|
|
790
832
|
function convertFormatToMoment(format) {
|
|
791
833
|
return format
|
|
@@ -801,6 +843,11 @@ function convertFormatToMoment(format) {
|
|
|
801
843
|
.replace(/U/g, 'X');
|
|
802
844
|
}
|
|
803
845
|
exports.convertFormatToMoment = convertFormatToMoment;
|
|
846
|
+
/**
|
|
847
|
+
* Convert the format from the angular-datepicker module to mask format.
|
|
848
|
+
* @param {string} format - The format to convert.
|
|
849
|
+
* @returns {string} - The converted format.
|
|
850
|
+
*/
|
|
804
851
|
function convertFormatToMask(format) {
|
|
805
852
|
return format
|
|
806
853
|
// Long month replacement.
|
|
@@ -860,6 +907,13 @@ function getInputMask(mask, placeholderChar) {
|
|
|
860
907
|
return maskArray;
|
|
861
908
|
}
|
|
862
909
|
exports.getInputMask = getInputMask;
|
|
910
|
+
/**
|
|
911
|
+
* Unmasks a value using the provided mask and placeholder characters.
|
|
912
|
+
* @param {string} value - The value to unmask.
|
|
913
|
+
* @param {string} mask - The mask to use for unmasking.
|
|
914
|
+
* @param {string} placeholderChar - The placeholder character to use for unmasking.
|
|
915
|
+
* @returns {string} - The unmasked value.
|
|
916
|
+
*/
|
|
863
917
|
function unmaskValue(value, mask, placeholderChar) {
|
|
864
918
|
if (!mask || !value || value.length > mask.length) {
|
|
865
919
|
return value;
|
|
@@ -876,6 +930,12 @@ function unmaskValue(value, mask, placeholderChar) {
|
|
|
876
930
|
return unmaskedValue;
|
|
877
931
|
}
|
|
878
932
|
exports.unmaskValue = unmaskValue;
|
|
933
|
+
/**
|
|
934
|
+
* Returns true if the value matches the input mask format.
|
|
935
|
+
* @param {string} value - The value to check.
|
|
936
|
+
* @param {string} inputMask - The input mask to check against.
|
|
937
|
+
* @returns {boolean} - TRUE if the value matches the input mask; FALSE otherwise.
|
|
938
|
+
*/
|
|
879
939
|
function matchInputMask(value, inputMask) {
|
|
880
940
|
if (!inputMask) {
|
|
881
941
|
return true;
|
|
@@ -894,6 +954,11 @@ function matchInputMask(value, inputMask) {
|
|
|
894
954
|
return true;
|
|
895
955
|
}
|
|
896
956
|
exports.matchInputMask = matchInputMask;
|
|
957
|
+
/**
|
|
958
|
+
* Returns the number separators (i.e. 1,000) for the provided language.
|
|
959
|
+
* @param {string} lang - The language code to get the number separators for.
|
|
960
|
+
* @returns {{delimiter: string, decimalSeparator: string}} - The number separators.
|
|
961
|
+
*/
|
|
897
962
|
function getNumberSeparators(lang = 'en') {
|
|
898
963
|
const formattedNumberString = (12345.6789).toLocaleString(lang);
|
|
899
964
|
const delimeters = formattedNumberString.match(/..(.)...(.)../);
|
|
@@ -909,6 +974,12 @@ function getNumberSeparators(lang = 'en') {
|
|
|
909
974
|
};
|
|
910
975
|
}
|
|
911
976
|
exports.getNumberSeparators = getNumberSeparators;
|
|
977
|
+
/**
|
|
978
|
+
* Returns the number for the maximum amount of decimal places for a number.
|
|
979
|
+
* @param {import('@formio/core').Component} component - The component to check for decimal limits.
|
|
980
|
+
* @param {number} defaultLimit - The default limit to use if none is provided in the component.
|
|
981
|
+
* @returns {number} - The number of decimal places allowed.
|
|
982
|
+
*/
|
|
912
983
|
function getNumberDecimalLimit(component, defaultLimit) {
|
|
913
984
|
if (lodash_1.default.has(component, 'decimalLimit')) {
|
|
914
985
|
return lodash_1.default.get(component, 'decimalLimit');
|
|
@@ -925,6 +996,15 @@ function getNumberDecimalLimit(component, defaultLimit) {
|
|
|
925
996
|
return decimalLimit;
|
|
926
997
|
}
|
|
927
998
|
exports.getNumberDecimalLimit = getNumberDecimalLimit;
|
|
999
|
+
/**
|
|
1000
|
+
* Returns the currency affixes for a specific language.
|
|
1001
|
+
* @param {object} arg0 - The arguments object.
|
|
1002
|
+
* @param {string} arg0.currency - The currency code to get the affixes for.
|
|
1003
|
+
* @param {number} arg0.decimalLimit - The number of decimal places to use.
|
|
1004
|
+
* @param {string} arg0.decimalSeparator - The decimal separator to use.
|
|
1005
|
+
* @param {string} arg0.lang - The language code to use.
|
|
1006
|
+
* @returns {{prefix: string, suffix: string}} - The currency affixes.
|
|
1007
|
+
*/
|
|
928
1008
|
function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }) {
|
|
929
1009
|
// Get the prefix and suffix from the localized string.
|
|
930
1010
|
let regex = `(.*)?${(100).toLocaleString(lang)}`;
|
|
@@ -947,10 +1027,9 @@ function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, })
|
|
|
947
1027
|
exports.getCurrencyAffixes = getCurrencyAffixes;
|
|
948
1028
|
/**
|
|
949
1029
|
* Fetch the field data provided a component.
|
|
950
|
-
*
|
|
951
|
-
* @param data
|
|
952
|
-
* @
|
|
953
|
-
* @return {*}
|
|
1030
|
+
* @param {import('@formio/core').DataObject} data - The data object to fetch the field data from.
|
|
1031
|
+
* @param {import('@formio/core').Component} component - The component to fetch the field data for.
|
|
1032
|
+
* @returns {*} - The field data.
|
|
954
1033
|
*/
|
|
955
1034
|
function fieldData(data, component) {
|
|
956
1035
|
if (!data) {
|
|
@@ -997,16 +1076,23 @@ function fieldData(data, component) {
|
|
|
997
1076
|
exports.fieldData = fieldData;
|
|
998
1077
|
/**
|
|
999
1078
|
* Delays function execution with possibility to execute function synchronously or cancel it.
|
|
1000
|
-
*
|
|
1001
|
-
* @param
|
|
1002
|
-
* @param
|
|
1003
|
-
* @
|
|
1079
|
+
* @param {Function} fn - Function to delay
|
|
1080
|
+
* @param {number} delay - Delay time
|
|
1081
|
+
* @param {...any} args - Arguments to pass to the function
|
|
1082
|
+
* @returns {*} - Function to cancel the delay
|
|
1004
1083
|
*/
|
|
1005
1084
|
function delay(fn, delay = 0, ...args) {
|
|
1006
1085
|
const timer = setTimeout(fn, delay, ...args);
|
|
1086
|
+
/**
|
|
1087
|
+
*
|
|
1088
|
+
*/
|
|
1007
1089
|
function cancel() {
|
|
1008
1090
|
clearTimeout(timer);
|
|
1009
1091
|
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Execute the function early.
|
|
1094
|
+
* @returns {*} - The result of the function.
|
|
1095
|
+
*/
|
|
1010
1096
|
function earlyCall() {
|
|
1011
1097
|
cancel();
|
|
1012
1098
|
return fn(...args);
|
|
@@ -1018,11 +1104,9 @@ function delay(fn, delay = 0, ...args) {
|
|
|
1018
1104
|
exports.delay = delay;
|
|
1019
1105
|
/**
|
|
1020
1106
|
* Iterate the given key to make it unique.
|
|
1021
|
-
*
|
|
1022
|
-
* @param {String} key
|
|
1107
|
+
* @param {string} key
|
|
1023
1108
|
* Modify the component key to be unique.
|
|
1024
|
-
*
|
|
1025
|
-
* @returns {String}
|
|
1109
|
+
* @returns {string}
|
|
1026
1110
|
* The new component key.
|
|
1027
1111
|
*/
|
|
1028
1112
|
function iterateKey(key) {
|
|
@@ -1036,10 +1120,9 @@ function iterateKey(key) {
|
|
|
1036
1120
|
exports.iterateKey = iterateKey;
|
|
1037
1121
|
/**
|
|
1038
1122
|
* Determines a unique key within a map provided the base key.
|
|
1039
|
-
*
|
|
1040
|
-
* @param
|
|
1041
|
-
* @
|
|
1042
|
-
* @return {*}
|
|
1123
|
+
* @param {Record<string, string>} map - The map to check for uniqueness.
|
|
1124
|
+
* @param {string} base - The base path of the key.
|
|
1125
|
+
* @returns {string} - The unique key.
|
|
1043
1126
|
*/
|
|
1044
1127
|
function uniqueKey(map, base) {
|
|
1045
1128
|
let newKey = base;
|
|
@@ -1051,8 +1134,9 @@ function uniqueKey(map, base) {
|
|
|
1051
1134
|
exports.uniqueKey = uniqueKey;
|
|
1052
1135
|
/**
|
|
1053
1136
|
* Determines the major version number of bootstrap.
|
|
1054
|
-
*
|
|
1055
|
-
* @
|
|
1137
|
+
* @param {object} options - The options to check for bootstrap version.
|
|
1138
|
+
* @param {string} options.bootstrap - The bootstrap version to use.
|
|
1139
|
+
* @returns {number} - The bootstrap version.
|
|
1056
1140
|
*/
|
|
1057
1141
|
function bootstrapVersion(options) {
|
|
1058
1142
|
if (options.bootstrap) {
|
|
@@ -1070,9 +1154,8 @@ exports.bootstrapVersion = bootstrapVersion;
|
|
|
1070
1154
|
/**
|
|
1071
1155
|
* Retrun provided argument.
|
|
1072
1156
|
* If argument is a function, returns the result of a function call.
|
|
1073
|
-
* @param {
|
|
1074
|
-
*
|
|
1075
|
-
* @return {*}
|
|
1157
|
+
* @param {Function|any} e - The argument to check if a function and call if so.
|
|
1158
|
+
* @returns {any} - Either the result of the function call (e) or e if it is not a function.
|
|
1076
1159
|
*/
|
|
1077
1160
|
function unfold(e) {
|
|
1078
1161
|
if (typeof e === 'function') {
|
|
@@ -1083,27 +1166,32 @@ function unfold(e) {
|
|
|
1083
1166
|
exports.unfold = unfold;
|
|
1084
1167
|
/**
|
|
1085
1168
|
* Map values through unfold and return first non-nil value.
|
|
1086
|
-
* @param {Array<T>} collection
|
|
1087
|
-
*
|
|
1088
|
-
* @return {T}
|
|
1169
|
+
* @param {Array<T>} collection - The collection to map through unfold.;
|
|
1170
|
+
* @returns {T} - The first non-nil value.
|
|
1089
1171
|
*/
|
|
1090
1172
|
exports.firstNonNil = lodash_1.default.flow([
|
|
1091
1173
|
lodash_1.default.partialRight(lodash_1.default.map, unfold),
|
|
1092
1174
|
lodash_1.default.partialRight(lodash_1.default.find, v => !lodash_1.default.isUndefined(v))
|
|
1093
1175
|
]);
|
|
1094
|
-
|
|
1095
|
-
* Create enclosed state.
|
|
1096
|
-
* Returns functions to getting and cycling between states.
|
|
1176
|
+
/**
|
|
1177
|
+
* Create enclosed state. Returns functions to getting and cycling between states.
|
|
1097
1178
|
* @param {*} a - initial state.
|
|
1098
1179
|
* @param {*} b - next state.
|
|
1099
|
-
* @
|
|
1180
|
+
* @returns {Functions[]} -- [get, toggle];
|
|
1100
1181
|
*/
|
|
1101
1182
|
function withSwitch(a, b) {
|
|
1102
1183
|
let state = a;
|
|
1103
1184
|
let next = b;
|
|
1185
|
+
/**
|
|
1186
|
+
* Returns the state of the switch.
|
|
1187
|
+
* @returns {*} - The current state.
|
|
1188
|
+
*/
|
|
1104
1189
|
function get() {
|
|
1105
1190
|
return state;
|
|
1106
1191
|
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Toggles the state of the switch.
|
|
1194
|
+
*/
|
|
1107
1195
|
function toggle() {
|
|
1108
1196
|
const prev = state;
|
|
1109
1197
|
state = next;
|
|
@@ -1112,6 +1200,14 @@ function withSwitch(a, b) {
|
|
|
1112
1200
|
return [get, toggle];
|
|
1113
1201
|
}
|
|
1114
1202
|
exports.withSwitch = withSwitch;
|
|
1203
|
+
/**
|
|
1204
|
+
* Create a function that will call the provided function only the provided limit.
|
|
1205
|
+
* @param {Function} callback - The callback to call.
|
|
1206
|
+
* @param {object} options - The options to use.
|
|
1207
|
+
* @param {number} options.limit - The limit to call the callback.
|
|
1208
|
+
* @param {number} options.delay - The delay to wait before resetting the call count.
|
|
1209
|
+
* @returns {Function} - The function that will call the callback only the provided limit.
|
|
1210
|
+
*/
|
|
1115
1211
|
function observeOverload(callback, options = {}) {
|
|
1116
1212
|
const { limit = 50, delay = 500 } = options;
|
|
1117
1213
|
let callCount = 0;
|
|
@@ -1132,6 +1228,13 @@ function observeOverload(callback, options = {}) {
|
|
|
1132
1228
|
};
|
|
1133
1229
|
}
|
|
1134
1230
|
exports.observeOverload = observeOverload;
|
|
1231
|
+
/**
|
|
1232
|
+
* Returns the components that are provided within an evaluation context.
|
|
1233
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1234
|
+
* @param {boolean} excludeNested - Exclude nested components.
|
|
1235
|
+
* @param {Array<string>} excludedTypes - The types of components to exclude.
|
|
1236
|
+
* @returns {Array} - The components within the evaluation context.
|
|
1237
|
+
*/
|
|
1135
1238
|
function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
1136
1239
|
const values = [];
|
|
1137
1240
|
context.utils.eachComponent(context.instance.options.editForm.components, (component, path) => {
|
|
@@ -1146,6 +1249,11 @@ function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
|
1146
1249
|
return values;
|
|
1147
1250
|
}
|
|
1148
1251
|
exports.getContextComponents = getContextComponents;
|
|
1252
|
+
/**
|
|
1253
|
+
* Returns the button components that are within an evaluation context.
|
|
1254
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1255
|
+
* @returns {Array} - The button components within the evaluation context.
|
|
1256
|
+
*/
|
|
1149
1257
|
function getContextButtons(context) {
|
|
1150
1258
|
const values = [];
|
|
1151
1259
|
context.utils.eachComponent(context.instance.options.editForm.components, (component) => {
|
|
@@ -1163,18 +1271,15 @@ exports.getContextButtons = getContextButtons;
|
|
|
1163
1271
|
const inTextTags = ['#text', 'A', 'B', 'EM', 'I', 'SMALL', 'STRONG', 'SUB', 'SUP', 'INS', 'DEL', 'MARK', 'CODE'];
|
|
1164
1272
|
/**
|
|
1165
1273
|
* Helper function for 'translateHTMLTemplate'. Translates text value of the passed html element.
|
|
1166
|
-
*
|
|
1167
|
-
* @param {
|
|
1168
|
-
* @
|
|
1169
|
-
*
|
|
1170
|
-
* @returns {String}
|
|
1171
|
-
* Translated element template.
|
|
1274
|
+
* @param {HTMLElement} elem - The element to translate.
|
|
1275
|
+
* @param {Function} translate - The translation function.
|
|
1276
|
+
* @returns {string} - Translated element template.
|
|
1172
1277
|
*/
|
|
1173
1278
|
function translateElemValue(elem, translate) {
|
|
1174
1279
|
if (!elem.innerText) {
|
|
1175
1280
|
return elem.innerHTML;
|
|
1176
1281
|
}
|
|
1177
|
-
const elemValue = elem.innerText.replace(Evaluator_1.
|
|
1282
|
+
const elemValue = elem.innerText.replace(Evaluator_1.Evaluator.templateSettings.interpolate, '').replace(/\s\s+/g, ' ').trim();
|
|
1178
1283
|
const translatedValue = translate(elemValue);
|
|
1179
1284
|
if (elemValue !== translatedValue) {
|
|
1180
1285
|
const links = elem.innerHTML.match(/<a[^>]*>(.*?)<\/a>/g);
|
|
@@ -1199,10 +1304,8 @@ function translateElemValue(elem, translate) {
|
|
|
1199
1304
|
}
|
|
1200
1305
|
/**
|
|
1201
1306
|
* Helper function for 'translateHTMLTemplate'. Goes deep through html tag children and calls function to translate their text values.
|
|
1202
|
-
*
|
|
1203
|
-
* @param {
|
|
1204
|
-
* @param {Function} translate
|
|
1205
|
-
*
|
|
1307
|
+
* @param {HTMLElement} tag - The tag to translate.
|
|
1308
|
+
* @param {Function} translate - The translation function.
|
|
1206
1309
|
* @returns {void}
|
|
1207
1310
|
*/
|
|
1208
1311
|
function translateDeepTag(tag, translate) {
|
|
@@ -1218,12 +1321,9 @@ function translateDeepTag(tag, translate) {
|
|
|
1218
1321
|
}
|
|
1219
1322
|
/**
|
|
1220
1323
|
* Translates text values in html template.
|
|
1221
|
-
*
|
|
1222
|
-
* @param {
|
|
1223
|
-
* @
|
|
1224
|
-
*
|
|
1225
|
-
* @returns {String}
|
|
1226
|
-
* Html template with translated values.
|
|
1324
|
+
* @param {string} template - The template to translate.
|
|
1325
|
+
* @param {Function} translate - The translation function.
|
|
1326
|
+
* @returns {string} - Html template with translated values.
|
|
1227
1327
|
*/
|
|
1228
1328
|
function translateHTMLTemplate(template, translate) {
|
|
1229
1329
|
const isHTML = /<[^>]*>/.test(template);
|
|
@@ -1241,9 +1341,9 @@ function translateHTMLTemplate(template, translate) {
|
|
|
1241
1341
|
exports.translateHTMLTemplate = translateHTMLTemplate;
|
|
1242
1342
|
/**
|
|
1243
1343
|
* Sanitize an html string.
|
|
1244
|
-
*
|
|
1245
|
-
* @param
|
|
1246
|
-
* @returns {
|
|
1344
|
+
* @param {string} string - The string to sanitize.
|
|
1345
|
+
* @param {any} options - The options to use for sanitization.
|
|
1346
|
+
* @returns {string} - The sanitized html string.
|
|
1247
1347
|
*/
|
|
1248
1348
|
function sanitize(string, options) {
|
|
1249
1349
|
if (typeof dompurify_1.default.sanitize !== 'function') {
|
|
@@ -1292,11 +1392,18 @@ function sanitize(string, options) {
|
|
|
1292
1392
|
exports.sanitize = sanitize;
|
|
1293
1393
|
/**
|
|
1294
1394
|
* Fast cloneDeep for JSON objects only.
|
|
1395
|
+
* @param {any} obj - The object to perform a fast clone deep against.
|
|
1396
|
+
* @returns {any} - The cloned object.
|
|
1295
1397
|
*/
|
|
1296
1398
|
function fastCloneDeep(obj) {
|
|
1297
1399
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
|
1298
1400
|
}
|
|
1299
1401
|
exports.fastCloneDeep = fastCloneDeep;
|
|
1402
|
+
/**
|
|
1403
|
+
* Returns if the component is an input component.
|
|
1404
|
+
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
1405
|
+
* @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
|
|
1406
|
+
*/
|
|
1300
1407
|
function isInputComponent(componentJson) {
|
|
1301
1408
|
if (componentJson.input === false || componentJson.input === true) {
|
|
1302
1409
|
return componentJson.input;
|
|
@@ -1317,6 +1424,11 @@ function isInputComponent(componentJson) {
|
|
|
1317
1424
|
}
|
|
1318
1425
|
}
|
|
1319
1426
|
exports.isInputComponent = isInputComponent;
|
|
1427
|
+
/**
|
|
1428
|
+
* Takes a component path, and returns a component path array.
|
|
1429
|
+
* @param {string} pathStr - The path string to convert to an array.
|
|
1430
|
+
* @returns {Arryay<number>} - The array of paths.
|
|
1431
|
+
*/
|
|
1320
1432
|
function getArrayFromComponentPath(pathStr) {
|
|
1321
1433
|
if (!pathStr || !lodash_1.default.isString(pathStr)) {
|
|
1322
1434
|
if (!lodash_1.default.isArray(pathStr)) {
|
|
@@ -1331,6 +1443,12 @@ function getArrayFromComponentPath(pathStr) {
|
|
|
1331
1443
|
.map(part => lodash_1.default.defaultTo(lodash_1.default.toNumber(part), part));
|
|
1332
1444
|
}
|
|
1333
1445
|
exports.getArrayFromComponentPath = getArrayFromComponentPath;
|
|
1446
|
+
/**
|
|
1447
|
+
* Returns true if the component is a child of the parent.
|
|
1448
|
+
* @param {any} child - The child component to check.
|
|
1449
|
+
* @param {any} parent - The parent component to check.
|
|
1450
|
+
* @returns {boolean} - TRUE if the child is a child of the parent; FALSE otherwise.
|
|
1451
|
+
*/
|
|
1334
1452
|
function isChildOf(child, parent) {
|
|
1335
1453
|
while (child && child.parent) {
|
|
1336
1454
|
if (child.parent === parent) {
|
|
@@ -1341,6 +1459,11 @@ function isChildOf(child, parent) {
|
|
|
1341
1459
|
return false;
|
|
1342
1460
|
}
|
|
1343
1461
|
exports.isChildOf = isChildOf;
|
|
1462
|
+
/**
|
|
1463
|
+
* Takes an array of component path indexes, and returns a string version of that array.
|
|
1464
|
+
* @param {Array<number>} path - The path array to convert to a string.
|
|
1465
|
+
* @returns {string} - The string version of the path.
|
|
1466
|
+
*/
|
|
1344
1467
|
function getStringFromComponentPath(path) {
|
|
1345
1468
|
if (!lodash_1.default.isArray(path)) {
|
|
1346
1469
|
return path;
|
|
@@ -1357,17 +1480,22 @@ function getStringFromComponentPath(path) {
|
|
|
1357
1480
|
return strPath;
|
|
1358
1481
|
}
|
|
1359
1482
|
exports.getStringFromComponentPath = getStringFromComponentPath;
|
|
1483
|
+
/**
|
|
1484
|
+
* Takes a number and rounds it to the provided precision amount.
|
|
1485
|
+
* @param {number} number - The number to round.
|
|
1486
|
+
* @param {number} precision - The precision to round the number to.
|
|
1487
|
+
* @returns {string} - The rounded number.
|
|
1488
|
+
*/
|
|
1360
1489
|
function round(number, precision) {
|
|
1361
1490
|
if (lodash_1.default.isNumber(number)) {
|
|
1362
1491
|
return number.toFixed(precision);
|
|
1363
1492
|
}
|
|
1364
|
-
return number;
|
|
1493
|
+
return number.toString();
|
|
1365
1494
|
}
|
|
1366
1495
|
exports.round = round;
|
|
1367
1496
|
/**
|
|
1368
1497
|
* Check for Internet Explorer browser version
|
|
1369
|
-
*
|
|
1370
|
-
* @return {(number|null)}
|
|
1498
|
+
* @returns {(number|null)} - The IE browser version or null if not IE
|
|
1371
1499
|
*/
|
|
1372
1500
|
function getIEBrowserVersion() {
|
|
1373
1501
|
const { ie, version } = getBrowserInfo();
|
|
@@ -1376,8 +1504,7 @@ function getIEBrowserVersion() {
|
|
|
1376
1504
|
exports.getIEBrowserVersion = getIEBrowserVersion;
|
|
1377
1505
|
/**
|
|
1378
1506
|
* Get browser name and version (modified from 'jquery-browser-plugin')
|
|
1379
|
-
*
|
|
1380
|
-
* @return {Object} -- {{browser name, version, isWebkit?}}
|
|
1507
|
+
* @returns {object} -- {{browser name, version, isWebkit?}}
|
|
1381
1508
|
* Possible browser names: chrome, safari, ie, edge, opera, mozilla, yabrowser
|
|
1382
1509
|
*/
|
|
1383
1510
|
function getBrowserInfo() {
|
|
@@ -1426,13 +1553,20 @@ function getBrowserInfo() {
|
|
|
1426
1553
|
return browser;
|
|
1427
1554
|
}
|
|
1428
1555
|
exports.getBrowserInfo = getBrowserInfo;
|
|
1556
|
+
/**
|
|
1557
|
+
* Takes a component path, which may include array indicies (i.e. [0][1]), and returns the compoennt path without the indicies.
|
|
1558
|
+
* @param {string} path - The path to remove the indicies from.
|
|
1559
|
+
* @returns {string} - The path without the indicies.
|
|
1560
|
+
*/
|
|
1429
1561
|
function getComponentPathWithoutIndicies(path = '') {
|
|
1430
1562
|
return path.replace(/\[\d+\]/, '');
|
|
1431
1563
|
}
|
|
1432
1564
|
exports.getComponentPathWithoutIndicies = getComponentPathWithoutIndicies;
|
|
1433
1565
|
/**
|
|
1434
1566
|
* Returns a path to the component which based on its schema
|
|
1435
|
-
* @param {
|
|
1567
|
+
* @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
|
|
1568
|
+
* @param {string} path - Path to the component
|
|
1569
|
+
* @returns {string} - Path to the component
|
|
1436
1570
|
*/
|
|
1437
1571
|
function getComponentPath(component, path = '') {
|
|
1438
1572
|
var _a;
|
|
@@ -1445,8 +1579,8 @@ function getComponentPath(component, path = '') {
|
|
|
1445
1579
|
exports.getComponentPath = getComponentPath;
|
|
1446
1580
|
/**
|
|
1447
1581
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
1448
|
-
* @param {
|
|
1449
|
-
* @
|
|
1582
|
+
* @param {Component} componentInstance - The component to check for the parent.
|
|
1583
|
+
* @returns {Component|undefined} - The parent data component.
|
|
1450
1584
|
*/
|
|
1451
1585
|
function getDataParentComponent(componentInstance) {
|
|
1452
1586
|
if (!componentInstance) {
|
|
@@ -1463,8 +1597,8 @@ function getDataParentComponent(componentInstance) {
|
|
|
1463
1597
|
exports.getDataParentComponent = getDataParentComponent;
|
|
1464
1598
|
/**
|
|
1465
1599
|
* Returns whether the value is a promise
|
|
1466
|
-
* @param value
|
|
1467
|
-
* @
|
|
1600
|
+
* @param {any} value - The value to check
|
|
1601
|
+
* @returns {boolean} - TRUE if the value is a promise; FALSE otherwise
|
|
1468
1602
|
*/
|
|
1469
1603
|
function isPromise(value) {
|
|
1470
1604
|
return value
|
|
@@ -1476,9 +1610,9 @@ exports.isPromise = isPromise;
|
|
|
1476
1610
|
/**
|
|
1477
1611
|
* Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
|
|
1478
1612
|
* changes by itself, e.g. EditGrid)
|
|
1479
|
-
* @param componentInstance
|
|
1480
|
-
* @param firstPass
|
|
1481
|
-
* @returns {boolean
|
|
1613
|
+
* @param {Component} componentInstance - The component to check for the scoping parent.
|
|
1614
|
+
* @param {boolean} firstPass - Whether it is the first pass of the function
|
|
1615
|
+
* @returns {boolean|*} - TRUE if the component has a scoping parent; FALSE otherwise
|
|
1482
1616
|
*/
|
|
1483
1617
|
function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
1484
1618
|
if (!firstPass && (componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.hasScopedChildren)) {
|
|
@@ -1494,6 +1628,11 @@ function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
|
1494
1628
|
return false;
|
|
1495
1629
|
}
|
|
1496
1630
|
exports.isInsideScopingComponent = isInsideScopingComponent;
|
|
1631
|
+
/**
|
|
1632
|
+
* Returns all the focusable elements within the provided dom element.
|
|
1633
|
+
* @param {HTMLElement} element - The element to get the focusable elements from.
|
|
1634
|
+
* @returns {NodeList<HTMLElement>} - The focusable elements within the provided element.
|
|
1635
|
+
*/
|
|
1497
1636
|
function getFocusableElements(element) {
|
|
1498
1637
|
const focusableSelector = `button:not([disabled]), input:not([disabled]), select:not([disabled]),
|
|
1499
1638
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
|
@@ -1509,6 +1648,11 @@ exports.componentValueTypes = {
|
|
|
1509
1648
|
date: 'date',
|
|
1510
1649
|
any: 'any',
|
|
1511
1650
|
};
|
|
1651
|
+
/**
|
|
1652
|
+
* Returns the saved types for the component
|
|
1653
|
+
* @param {import('@formio/core').Component} fullSchema - The component schema
|
|
1654
|
+
* @returns {Array<string>|null} - The saved types for the component
|
|
1655
|
+
*/
|
|
1512
1656
|
function getComponentSavedTypes(fullSchema) {
|
|
1513
1657
|
const schema = fullSchema || {};
|
|
1514
1658
|
if (schema.persistent !== true) {
|
|
@@ -1522,9 +1666,10 @@ function getComponentSavedTypes(fullSchema) {
|
|
|
1522
1666
|
exports.getComponentSavedTypes = getComponentSavedTypes;
|
|
1523
1667
|
/**
|
|
1524
1668
|
* Interpolates @formio/core errors so that they are compatible with the renderer
|
|
1525
|
-
* @param {
|
|
1526
|
-
* @param
|
|
1527
|
-
* @
|
|
1669
|
+
* @param {Component} component - The component to interpolate the errors for
|
|
1670
|
+
* @param {FieldError[]} errors - The errors to interpolate
|
|
1671
|
+
* @param {Function} interpolateFn - The interpolation function
|
|
1672
|
+
* @returns {[]} - The interpolated errors
|
|
1528
1673
|
*/
|
|
1529
1674
|
const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1530
1675
|
return errors.map((error) => {
|
|
@@ -1535,6 +1680,11 @@ const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1535
1680
|
});
|
|
1536
1681
|
};
|
|
1537
1682
|
exports.interpolateErrors = interpolateErrors;
|
|
1683
|
+
/**
|
|
1684
|
+
* Returns the template keys inside the template code.
|
|
1685
|
+
* @param {string} template - The template to get the keys from.
|
|
1686
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
1687
|
+
*/
|
|
1538
1688
|
function getItemTemplateKeys(template) {
|
|
1539
1689
|
const templateKeys = [];
|
|
1540
1690
|
if (!template) {
|
|
@@ -1552,6 +1702,11 @@ function getItemTemplateKeys(template) {
|
|
|
1552
1702
|
return templateKeys;
|
|
1553
1703
|
}
|
|
1554
1704
|
exports.getItemTemplateKeys = getItemTemplateKeys;
|
|
1705
|
+
/**
|
|
1706
|
+
* Returns if the component is a select resource with an object for its value.
|
|
1707
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1708
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1709
|
+
*/
|
|
1555
1710
|
function isSelectResourceWithObjectValue(comp = {}) {
|
|
1556
1711
|
const { reference, dataSrc, valueProperty } = comp;
|
|
1557
1712
|
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|