@formio/js 5.0.0-dev.5604.02ffada → 5.0.0-dev.5610.c46fab6
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 +1 -0
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +646 -1194
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -11
- package/dist/formio.full.js +690 -918
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -11
- package/dist/formio.js +16 -16
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +1856 -488
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +12 -2
- package/embed.d.ts +1 -0
- package/form.d.ts +1 -0
- package/lib/cjs/Element.d.ts +86 -96
- package/lib/cjs/Element.js +68 -78
- 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/InlineEmbed.d.ts +7 -0
- package/lib/cjs/InlineEmbed.js +109 -0
- package/lib/cjs/PDF.d.ts +11 -13
- package/lib/cjs/PDF.js +6 -8
- package/lib/cjs/Webform.d.ts +180 -139
- package/lib/cjs/Webform.js +313 -298
- package/lib/cjs/WebformBuilder.d.ts +16 -14
- package/lib/cjs/WebformBuilder.js +11 -10
- package/lib/cjs/Wizard.d.ts +31 -21
- package/lib/cjs/Wizard.js +42 -19
- 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 +501 -266
- 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 +433 -190
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +0 -8
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +2 -2
- package/lib/cjs/components/_classes/component/editForm/utils.js +2 -2
- package/lib/cjs/components/_classes/field/Field.d.ts +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 +2 -2
- 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 +37 -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/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 +4 -27
- 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/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 +8 -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 +5 -5
- 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 +22 -48
- 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 +15 -20
- 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 +3 -3
- 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/form/Form.d.ts +31 -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 +13 -10
- 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 +1 -2
- 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/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 +3 -4
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/cjs/components/recaptcha/ReCaptcha.form.d.ts +5 -3
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +4 -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 +13 -16
- 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 +1 -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/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 +13 -16
- 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 +130 -6
- package/lib/cjs/providers/address/GoogleAddressProvider.js +72 -0
- 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/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/formUtils.d.ts +43 -171
- package/lib/cjs/utils/formUtils.js +38 -569
- package/lib/cjs/utils/utils.d.ts +362 -216
- package/lib/cjs/utils/utils.js +331 -224
- package/lib/cjs/widgets/CalendarWidget.d.ts +9 -10
- package/lib/cjs/widgets/CalendarWidget.js +9 -11
- package/lib/mjs/Element.d.ts +86 -96
- package/lib/mjs/Element.js +68 -78
- 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/InlineEmbed.d.ts +7 -0
- package/lib/mjs/InlineEmbed.js +105 -0
- package/lib/mjs/PDF.d.ts +11 -13
- package/lib/mjs/PDF.js +6 -8
- package/lib/mjs/Webform.d.ts +180 -139
- package/lib/mjs/Webform.js +325 -310
- package/lib/mjs/WebformBuilder.d.ts +16 -14
- package/lib/mjs/WebformBuilder.js +11 -10
- package/lib/mjs/Wizard.d.ts +31 -21
- package/lib/mjs/Wizard.js +41 -18
- 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 +501 -266
- 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 +433 -190
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +0 -8
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/mjs/components/_classes/field/Field.d.ts +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 +2 -2
- 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 +37 -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/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 +4 -27
- 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/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 +8 -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 +5 -5
- 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 +22 -48
- 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 +15 -20
- 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 +3 -3
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +1 -1
- package/lib/mjs/components/email/Email.form.d.ts +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/form/Form.d.ts +31 -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 +13 -10
- 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 +1 -2
- 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/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 +3 -4
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.form.d.ts +5 -3
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +4 -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 +13 -16
- 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 +1 -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/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 +13 -16
- 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 +130 -6
- package/lib/mjs/providers/address/GoogleAddressProvider.js +72 -0
- 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/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/formUtils.d.ts +43 -171
- package/lib/mjs/utils/formUtils.js +6 -554
- package/lib/mjs/utils/utils.d.ts +362 -216
- package/lib/mjs/utils/utils.js +325 -218
- package/lib/mjs/widgets/CalendarWidget.d.ts +9 -10
- package/lib/mjs/widgets/CalendarWidget.js +9 -11
- package/package.json +22 -22
- package/sdk.d.ts +1 -0
- package/utils.d.ts +1 -0
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -42,11 +42,11 @@ const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
|
|
|
42
42
|
const operators_1 = require("./jsonlogic/operators");
|
|
43
43
|
const dompurify_1 = __importDefault(require("dompurify"));
|
|
44
44
|
const formUtils_1 = require("./formUtils");
|
|
45
|
-
const Evaluator_1 =
|
|
46
|
-
exports
|
|
45
|
+
const Evaluator_1 = require("./Evaluator");
|
|
46
|
+
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
|
47
47
|
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
|
48
48
|
exports.ConditionOperators = conditionOperators_1.default;
|
|
49
|
-
const interpolate = Evaluator_1.
|
|
49
|
+
const interpolate = Evaluator_1.Evaluator.interpolate;
|
|
50
50
|
exports.interpolate = interpolate;
|
|
51
51
|
const { fetch } = (0, fetch_ponyfill_1.default)({
|
|
52
52
|
Promise: Promise
|
|
@@ -67,6 +67,10 @@ json_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
|
|
67
67
|
return (0, moment_timezone_1.default)().add(relativeMaxDate, 'days').toISOString();
|
|
68
68
|
});
|
|
69
69
|
exports.moment = __importStar(require("moment-timezone/moment-timezone"));
|
|
70
|
+
/**
|
|
71
|
+
* Sets the path to the component and parent schema.
|
|
72
|
+
* @param {import('@formio/core').Component} component - The component to set the path for.
|
|
73
|
+
*/
|
|
70
74
|
function setPathToComponentAndPerentSchema(component) {
|
|
71
75
|
component.path = getComponentPath(component);
|
|
72
76
|
const dataParent = getDataParentComponent(component);
|
|
@@ -76,79 +80,30 @@ function setPathToComponentAndPerentSchema(component) {
|
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* 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;
|
|
83
|
+
* @param {Function|string|object} func - The function to evaluate.
|
|
84
|
+
* @param {*} args - A map of arguments to pass to the function.
|
|
85
|
+
* @param {string} ret - The name of the "return" variable in the script.
|
|
86
|
+
* @param {boolean} interpolate - True if the script should be interpolated before being executed.
|
|
87
|
+
* @param {import('@formio/core').EvaluatorOptions} options - The evaluator options.
|
|
88
|
+
* @returns {*} - The result of the evaluation.
|
|
89
|
+
*/
|
|
90
|
+
function evaluate(func, args, ret, interpolate, options = {}) {
|
|
91
|
+
return Evaluator_1.Evaluator.evaluate(func, args, ret, interpolate, undefined, options);
|
|
140
92
|
}
|
|
141
93
|
exports.evaluate = evaluate;
|
|
94
|
+
/**
|
|
95
|
+
* Returns a random compoennt ID.
|
|
96
|
+
* @returns {string} - A random component ID.
|
|
97
|
+
*/
|
|
142
98
|
function getRandomComponentId() {
|
|
143
99
|
return `e${Math.random().toString(36).substring(7)}`;
|
|
144
100
|
}
|
|
145
101
|
exports.getRandomComponentId = getRandomComponentId;
|
|
146
102
|
/**
|
|
147
103
|
* Get a property value of an element.
|
|
148
|
-
*
|
|
149
|
-
* @param
|
|
150
|
-
* @
|
|
151
|
-
* @return {number}
|
|
104
|
+
* @param {CSSStyleDeclaration} style - The style element to get the property value from.
|
|
105
|
+
* @param {string} prop - The property to get the value for.
|
|
106
|
+
* @returns {number} - The value of the property.
|
|
152
107
|
*/
|
|
153
108
|
function getPropertyValue(style, prop) {
|
|
154
109
|
let value = style.getPropertyValue(prop);
|
|
@@ -158,9 +113,8 @@ function getPropertyValue(style, prop) {
|
|
|
158
113
|
exports.getPropertyValue = getPropertyValue;
|
|
159
114
|
/**
|
|
160
115
|
* Get an elements bounding rectagle.
|
|
161
|
-
*
|
|
162
|
-
* @
|
|
163
|
-
* @return {{x: string, y: string, width: string, height: string}}
|
|
116
|
+
* @param {HTMLElement} element - A DOM element to get the bounding rectangle for.
|
|
117
|
+
* @returns {{x: number, y: number, width: number, height: number}} - The bounding rectangle.
|
|
164
118
|
*/
|
|
165
119
|
function getElementRect(element) {
|
|
166
120
|
const style = window.getComputedStyle(element, null);
|
|
@@ -174,9 +128,8 @@ function getElementRect(element) {
|
|
|
174
128
|
exports.getElementRect = getElementRect;
|
|
175
129
|
/**
|
|
176
130
|
* Determines the boolean value of a setting.
|
|
177
|
-
*
|
|
178
|
-
* @
|
|
179
|
-
* @return {boolean}
|
|
131
|
+
* @param {string|boolean} value - A string or boolean value to convert to boolean.
|
|
132
|
+
* @returns {boolean} - The boolean value of the setting.
|
|
180
133
|
*/
|
|
181
134
|
function boolValue(value) {
|
|
182
135
|
if (lodash_1.default.isBoolean(value)) {
|
|
@@ -192,22 +145,18 @@ function boolValue(value) {
|
|
|
192
145
|
exports.boolValue = boolValue;
|
|
193
146
|
/**
|
|
194
147
|
* Check to see if an ID is a mongoID.
|
|
195
|
-
* @param text
|
|
196
|
-
* @
|
|
148
|
+
* @param {string} text - The text to check if it is a mongoID.
|
|
149
|
+
* @returns {boolean} - TRUE if the text is a mongoID; FALSE otherwise.
|
|
197
150
|
*/
|
|
198
151
|
function isMongoId(text) {
|
|
199
|
-
return text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
152
|
+
return !!text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
200
153
|
}
|
|
201
154
|
exports.isMongoId = isMongoId;
|
|
202
155
|
/**
|
|
203
156
|
* Checks the calculated value for a provided component and data.
|
|
204
|
-
*
|
|
205
|
-
* @param {
|
|
206
|
-
*
|
|
207
|
-
* @param {Object} submission
|
|
208
|
-
* A submission object.
|
|
209
|
-
* @param data
|
|
210
|
-
* The full submission data.
|
|
157
|
+
* @param {import('@formio/core').Component} component - The component to check for the calculated value.
|
|
158
|
+
* @param {import('@formio/core').Submission} submission - A submission object.
|
|
159
|
+
* @param {*} rowData - The contextual row data for the component.
|
|
211
160
|
*/
|
|
212
161
|
function checkCalculated(component, submission, rowData) {
|
|
213
162
|
// Process calculated value stuff if present.
|
|
@@ -224,13 +173,12 @@ function checkCalculated(component, submission, rowData) {
|
|
|
224
173
|
exports.checkCalculated = checkCalculated;
|
|
225
174
|
/**
|
|
226
175
|
* Check if a simple conditional evaluates to true.
|
|
227
|
-
*
|
|
228
|
-
* @param condition
|
|
229
|
-
* @param
|
|
230
|
-
* @param
|
|
231
|
-
* @param
|
|
232
|
-
* @
|
|
233
|
-
* @returns {boolean}
|
|
176
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
177
|
+
* @param {import('@formio/core').SimpleConditional} condition - The condition to check.
|
|
178
|
+
* @param {*} row - The row data for the component.
|
|
179
|
+
* @param {*} data - The full submission data.
|
|
180
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
|
|
181
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
234
182
|
*/
|
|
235
183
|
function checkSimpleConditional(component, condition, row, data, instance) {
|
|
236
184
|
if (condition.when) {
|
|
@@ -275,6 +223,13 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
|
275
223
|
}
|
|
276
224
|
}
|
|
277
225
|
exports.checkSimpleConditional = checkSimpleConditional;
|
|
226
|
+
/**
|
|
227
|
+
* Returns a components normalized value.
|
|
228
|
+
* @param {string} compPath - The full path to the component.
|
|
229
|
+
* @param {*} data - The data object to get the value from.
|
|
230
|
+
* @param {*} row - The contextual row data for the component.
|
|
231
|
+
* @returns {*} - The normalized value of the component.
|
|
232
|
+
*/
|
|
278
233
|
function getComponentActualValue(compPath, data, row) {
|
|
279
234
|
let value = null;
|
|
280
235
|
if (row) {
|
|
@@ -292,12 +247,15 @@ function getComponentActualValue(compPath, data, row) {
|
|
|
292
247
|
exports.getComponentActualValue = getComponentActualValue;
|
|
293
248
|
/**
|
|
294
249
|
* Check custom javascript conditional.
|
|
295
|
-
*
|
|
296
|
-
* @param
|
|
297
|
-
* @param
|
|
298
|
-
* @param
|
|
299
|
-
* @param
|
|
300
|
-
* @
|
|
250
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
251
|
+
* @param {string} custom - The custom conditional string to evaluate.
|
|
252
|
+
* @param {*} row - The row data for the component.
|
|
253
|
+
* @param {*} data - The full submission data.
|
|
254
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
255
|
+
* @param {string} variable - The variable name for the result of the custom conditional.
|
|
256
|
+
* @param {*} onError - A custom return if there is an error or the value is null from the evaluation.
|
|
257
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
258
|
+
* @returns {*} - The result of the evaulation.
|
|
301
259
|
*/
|
|
302
260
|
function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
|
|
303
261
|
if (typeof custom === 'string') {
|
|
@@ -312,6 +270,16 @@ function checkCustomConditional(component, custom, row, data, form, variable, on
|
|
|
312
270
|
return value;
|
|
313
271
|
}
|
|
314
272
|
exports.checkCustomConditional = checkCustomConditional;
|
|
273
|
+
/**
|
|
274
|
+
* Check a component for JSON conditionals.
|
|
275
|
+
* @param {import('@formio/core').Component} component - The component
|
|
276
|
+
* @param {import('@formio/core').JSONConditional} json - The json conditional to check.
|
|
277
|
+
* @param {*} row - The contextual row data for the component.
|
|
278
|
+
* @param {*} data - The full submission data.
|
|
279
|
+
* @param {import('@formio/core').Form} form - The Form JSON of the form.
|
|
280
|
+
* @param {*} onError - Custom return value if there is an error.
|
|
281
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
282
|
+
*/
|
|
315
283
|
function checkJsonConditional(component, json, row, data, form, onError) {
|
|
316
284
|
try {
|
|
317
285
|
return json_logic_js_1.default.apply(json, {
|
|
@@ -327,6 +295,14 @@ function checkJsonConditional(component, json, row, data, form, onError) {
|
|
|
327
295
|
}
|
|
328
296
|
}
|
|
329
297
|
exports.checkJsonConditional = checkJsonConditional;
|
|
298
|
+
/**
|
|
299
|
+
* Returns the contextual row data for a component.
|
|
300
|
+
* @param {import('@formio/core').Component} component - The component to get the row data for.
|
|
301
|
+
* @param {*} row - The row data for the component.
|
|
302
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
303
|
+
* @param {*} conditional - The component conditional.
|
|
304
|
+
* @returns {*} - The contextual row data for the component.
|
|
305
|
+
*/
|
|
330
306
|
function getRow(component, row, instance, conditional) {
|
|
331
307
|
var _a;
|
|
332
308
|
const condition = conditional || component.conditional;
|
|
@@ -349,15 +325,12 @@ function getRow(component, row, instance, conditional) {
|
|
|
349
325
|
}
|
|
350
326
|
/**
|
|
351
327
|
* Checks the conditions for a provided component and data.
|
|
352
|
-
*
|
|
353
|
-
* @param
|
|
354
|
-
*
|
|
355
|
-
* @param
|
|
356
|
-
*
|
|
357
|
-
* @
|
|
358
|
-
* The full submission data.
|
|
359
|
-
*
|
|
360
|
-
* @returns {boolean}
|
|
328
|
+
* @param {import('@formio/core').Component} component - The component to check for the condition.
|
|
329
|
+
* @param {*} row - The data within a row
|
|
330
|
+
* @param {*} data - The full submission data.
|
|
331
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
332
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
333
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
361
334
|
*/
|
|
362
335
|
function checkCondition(component, row, data, form, instance) {
|
|
363
336
|
const { customConditional, conditional } = component;
|
|
@@ -377,12 +350,13 @@ function checkCondition(component, row, data, form, instance) {
|
|
|
377
350
|
exports.checkCondition = checkCondition;
|
|
378
351
|
/**
|
|
379
352
|
* Test a trigger on a component.
|
|
380
|
-
*
|
|
381
|
-
* @param
|
|
382
|
-
* @param
|
|
383
|
-
* @param data
|
|
384
|
-
* @param
|
|
385
|
-
* @
|
|
353
|
+
* @param {import('@formio/core').Component} component - The component to test the trigger against.
|
|
354
|
+
* @param {import('@formio/core').LogicTrigger} trigger - The trigger configuration.
|
|
355
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
356
|
+
* @param {import('@formio/core').DataObject} data - The root data object.
|
|
357
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
358
|
+
* @param {any} instance - The component that is performing the trigger.
|
|
359
|
+
* @returns {boolean} - TRUE if the trigger should fire; FALSE otherwise.
|
|
386
360
|
*/
|
|
387
361
|
function checkTrigger(component, trigger, row, data, form, instance) {
|
|
388
362
|
// If trigger is empty, don't fire it
|
|
@@ -402,6 +376,16 @@ function checkTrigger(component, trigger, row, data, form, instance) {
|
|
|
402
376
|
return false;
|
|
403
377
|
}
|
|
404
378
|
exports.checkTrigger = checkTrigger;
|
|
379
|
+
/**
|
|
380
|
+
* Sets a property on a component via an executed Logic action.
|
|
381
|
+
* @param {import('@formio/core').Component} component - The component to set the property on.
|
|
382
|
+
* @param {import('@formio/core').LogicAction} action - The action to perform on the component.
|
|
383
|
+
* @param {string} result - The name of the variable in the evaulation to use as the result.
|
|
384
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
385
|
+
* @param {import('@formio/core').DataObject} data - The full submission data.
|
|
386
|
+
* @param {any} instance - The component instance.
|
|
387
|
+
* @returns {import('@formio/core').Component} - The modified component.
|
|
388
|
+
*/
|
|
405
389
|
function setActionProperty(component, action, result, row, data, instance) {
|
|
406
390
|
const property = action.property.value;
|
|
407
391
|
switch (action.property.type) {
|
|
@@ -424,7 +408,7 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
424
408
|
const currentValue = lodash_1.default.get(component, property, '');
|
|
425
409
|
const newValue = (instance && instance.interpolate)
|
|
426
410
|
? instance.interpolate(textValue, evalData)
|
|
427
|
-
: Evaluator_1.
|
|
411
|
+
: Evaluator_1.Evaluator.interpolate(textValue, evalData);
|
|
428
412
|
if (newValue !== currentValue) {
|
|
429
413
|
lodash_1.default.set(component, property, newValue);
|
|
430
414
|
}
|
|
@@ -436,8 +420,8 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
436
420
|
exports.setActionProperty = setActionProperty;
|
|
437
421
|
/**
|
|
438
422
|
* Unescape HTML characters like <, >, & and etc.
|
|
439
|
-
* @param str
|
|
440
|
-
* @returns {string}
|
|
423
|
+
* @param {string} str - The string to unescape.
|
|
424
|
+
* @returns {string} - The unescaped string.
|
|
441
425
|
*/
|
|
442
426
|
function unescapeHTML(str) {
|
|
443
427
|
if (typeof window === 'undefined' || !('DOMParser' in window)) {
|
|
@@ -449,9 +433,9 @@ function unescapeHTML(str) {
|
|
|
449
433
|
exports.unescapeHTML = unescapeHTML;
|
|
450
434
|
/**
|
|
451
435
|
* Make HTML element from string
|
|
452
|
-
* @param str
|
|
453
|
-
* @param selector
|
|
454
|
-
* @returns {HTMLElement}
|
|
436
|
+
* @param {string} str - The string to convert to an HTML element.
|
|
437
|
+
* @param {string} selector - The selector to use to get the element once it is created.
|
|
438
|
+
* @returns {HTMLElement} - The HTML element that was created.
|
|
455
439
|
*/
|
|
456
440
|
function convertStringToHTMLElement(str, selector) {
|
|
457
441
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -460,10 +444,10 @@ function convertStringToHTMLElement(str, selector) {
|
|
|
460
444
|
exports.convertStringToHTMLElement = convertStringToHTMLElement;
|
|
461
445
|
/**
|
|
462
446
|
* Make a filename guaranteed to be unique.
|
|
463
|
-
* @param name
|
|
464
|
-
* @param template
|
|
465
|
-
* @param evalContext
|
|
466
|
-
* @returns {string}
|
|
447
|
+
* @param {string} name - The original name of the file.
|
|
448
|
+
* @param {string} template - The template to use for the unique name.
|
|
449
|
+
* @param {object} evalContext - The context to use for the evaluation.
|
|
450
|
+
* @returns {string} - A unique filename.
|
|
467
451
|
*/
|
|
468
452
|
function uniqueName(name, template, evalContext) {
|
|
469
453
|
template = template || '{{fileName}}-{{guid}}';
|
|
@@ -483,10 +467,14 @@ function uniqueName(name, template, evalContext) {
|
|
|
483
467
|
guid: guid()
|
|
484
468
|
});
|
|
485
469
|
//only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash
|
|
486
|
-
const uniqueName = `${Evaluator_1.
|
|
470
|
+
const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
|
|
487
471
|
return uniqueName;
|
|
488
472
|
}
|
|
489
473
|
exports.uniqueName = uniqueName;
|
|
474
|
+
/**
|
|
475
|
+
* Returns a GUID
|
|
476
|
+
* @returns {string} - A GUID.
|
|
477
|
+
*/
|
|
490
478
|
function guid() {
|
|
491
479
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
492
480
|
const r = Math.random() * 16 | 0;
|
|
@@ -499,9 +487,8 @@ function guid() {
|
|
|
499
487
|
exports.guid = guid;
|
|
500
488
|
/**
|
|
501
489
|
* Return a translated date setting.
|
|
502
|
-
*
|
|
503
|
-
* @
|
|
504
|
-
* @return {(null|Date)}
|
|
490
|
+
* @param {string|Date} date - The date to translate.
|
|
491
|
+
* @returns {(null|Date)} - The translated date.
|
|
505
492
|
*/
|
|
506
493
|
function getDateSetting(date) {
|
|
507
494
|
if (lodash_1.default.isNil(date) || lodash_1.default.isNaN(date) || date === '') {
|
|
@@ -519,7 +506,7 @@ function getDateSetting(date) {
|
|
|
519
506
|
}
|
|
520
507
|
dateSetting = null;
|
|
521
508
|
try {
|
|
522
|
-
const value = Evaluator_1.
|
|
509
|
+
const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
|
|
523
510
|
if (typeof value === 'string') {
|
|
524
511
|
dateSetting = (0, moment_timezone_1.default)(value);
|
|
525
512
|
}
|
|
@@ -543,14 +530,18 @@ function getDateSetting(date) {
|
|
|
543
530
|
return dateSetting.toDate();
|
|
544
531
|
}
|
|
545
532
|
exports.getDateSetting = getDateSetting;
|
|
533
|
+
/**
|
|
534
|
+
* Returns true if the date is a valid date. False otherwise.
|
|
535
|
+
* @param {Date|string} date - The date to check for validity.
|
|
536
|
+
* @returns {boolean} - TRUE if the date is valid; FALSE otherwise.
|
|
537
|
+
*/
|
|
546
538
|
function isValidDate(date) {
|
|
547
539
|
return lodash_1.default.isDate(date) && !lodash_1.default.isNaN(date.getDate());
|
|
548
540
|
}
|
|
549
541
|
exports.isValidDate = isValidDate;
|
|
550
542
|
/**
|
|
551
543
|
* Get the current timezone string.
|
|
552
|
-
*
|
|
553
|
-
* @return {string}
|
|
544
|
+
* @returns {string} - The current timezone.
|
|
554
545
|
*/
|
|
555
546
|
function currentTimezone() {
|
|
556
547
|
if (moment_timezone_1.default.currentTimezone) {
|
|
@@ -562,10 +553,9 @@ function currentTimezone() {
|
|
|
562
553
|
exports.currentTimezone = currentTimezone;
|
|
563
554
|
/**
|
|
564
555
|
* Get an offset date provided a date object and timezone object.
|
|
565
|
-
*
|
|
566
|
-
* @param date
|
|
567
|
-
* @
|
|
568
|
-
* @return {Date}
|
|
556
|
+
* @param {Date} date - The date to offset.
|
|
557
|
+
* @param {string} timezone - The timezone to offset the date to.
|
|
558
|
+
* @returns {Date} - The offset date.
|
|
569
559
|
*/
|
|
570
560
|
function offsetDate(date, timezone) {
|
|
571
561
|
if (timezone === 'UTC') {
|
|
@@ -583,8 +573,7 @@ function offsetDate(date, timezone) {
|
|
|
583
573
|
exports.offsetDate = offsetDate;
|
|
584
574
|
/**
|
|
585
575
|
* Returns if the zones are loaded.
|
|
586
|
-
*
|
|
587
|
-
* @return {boolean}
|
|
576
|
+
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
|
588
577
|
*/
|
|
589
578
|
function zonesLoaded() {
|
|
590
579
|
return moment_timezone_1.default.zonesLoaded;
|
|
@@ -592,9 +581,8 @@ function zonesLoaded() {
|
|
|
592
581
|
exports.zonesLoaded = zonesLoaded;
|
|
593
582
|
/**
|
|
594
583
|
* Returns if we should load the zones.
|
|
595
|
-
*
|
|
596
|
-
* @
|
|
597
|
-
* @return {boolean}
|
|
584
|
+
* @param {string} timezone - The timezone to check if we should load the zones.
|
|
585
|
+
* @returns {boolean} - TRUE if we should load the zones; FALSE otherwise.
|
|
598
586
|
*/
|
|
599
587
|
function shouldLoadZones(timezone) {
|
|
600
588
|
if (timezone === currentTimezone() || timezone === 'UTC') {
|
|
@@ -605,8 +593,9 @@ function shouldLoadZones(timezone) {
|
|
|
605
593
|
exports.shouldLoadZones = shouldLoadZones;
|
|
606
594
|
/**
|
|
607
595
|
* Externally load the timezone data.
|
|
608
|
-
*
|
|
609
|
-
* @
|
|
596
|
+
* @param {string} url - The URL to load the timezone data from.
|
|
597
|
+
* @param {string} timezone - The timezone to load.
|
|
598
|
+
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
610
599
|
*/
|
|
611
600
|
function loadZones(url, timezone) {
|
|
612
601
|
if (timezone && !shouldLoadZones(timezone)) {
|
|
@@ -631,11 +620,10 @@ function loadZones(url, timezone) {
|
|
|
631
620
|
exports.loadZones = loadZones;
|
|
632
621
|
/**
|
|
633
622
|
* Get the moment date object for translating dates with timezones.
|
|
634
|
-
*
|
|
635
|
-
* @param
|
|
636
|
-
* @param
|
|
637
|
-
* @
|
|
638
|
-
* @return {*}
|
|
623
|
+
* @param {string|Date} value - The value to convert into a moment date.
|
|
624
|
+
* @param {string} format - The format to convert the date to.
|
|
625
|
+
* @param {string} timezone - The timezone to convert the date to.
|
|
626
|
+
* @returns {Date} - The moment date object.
|
|
639
627
|
*/
|
|
640
628
|
function momentDate(value, format, timezone) {
|
|
641
629
|
const momentDate = (0, moment_timezone_1.default)(value);
|
|
@@ -653,11 +641,12 @@ function momentDate(value, format, timezone) {
|
|
|
653
641
|
exports.momentDate = momentDate;
|
|
654
642
|
/**
|
|
655
643
|
* Format a date provided a value, format, and timezone object.
|
|
656
|
-
*
|
|
657
|
-
* @param value
|
|
658
|
-
* @param format
|
|
659
|
-
* @param timezone
|
|
660
|
-
* @
|
|
644
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
645
|
+
* @param {string|Date} value - The value to format.
|
|
646
|
+
* @param {string} format - The format to format the date to.
|
|
647
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
648
|
+
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
|
649
|
+
* @returns {string} - The formatted date.
|
|
661
650
|
*/
|
|
662
651
|
function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat) {
|
|
663
652
|
const momentDate = (0, moment_timezone_1.default)(value, flatPickrInputFormat || undefined);
|
|
@@ -691,12 +680,12 @@ function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat)
|
|
|
691
680
|
exports.formatDate = formatDate;
|
|
692
681
|
/**
|
|
693
682
|
* Pass a format function to format within a timezone.
|
|
694
|
-
*
|
|
695
|
-
* @param formatFn
|
|
696
|
-
* @param date
|
|
697
|
-
* @param format
|
|
698
|
-
* @param timezone
|
|
699
|
-
* @
|
|
683
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
684
|
+
* @param {Function} formatFn - The format function to use.
|
|
685
|
+
* @param {Date|string} date - The date to format.
|
|
686
|
+
* @param {string} format - The format to format the date to.
|
|
687
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
688
|
+
* @returns {string} - The formatted date.
|
|
700
689
|
*/
|
|
701
690
|
function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
702
691
|
if (timezone === currentTimezone()) {
|
|
@@ -716,6 +705,11 @@ function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
|
716
705
|
}
|
|
717
706
|
}
|
|
718
707
|
exports.formatOffset = formatOffset;
|
|
708
|
+
/**
|
|
709
|
+
* Returns the local date format information.
|
|
710
|
+
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
|
711
|
+
* @returns {object} - The local date format information.
|
|
712
|
+
*/
|
|
719
713
|
function getLocaleDateFormatInfo(locale) {
|
|
720
714
|
const formatInfo = {};
|
|
721
715
|
const day = 21;
|
|
@@ -727,8 +721,8 @@ function getLocaleDateFormatInfo(locale) {
|
|
|
727
721
|
exports.getLocaleDateFormatInfo = getLocaleDateFormatInfo;
|
|
728
722
|
/**
|
|
729
723
|
* Convert the format from the angular-datepicker module to flatpickr format.
|
|
730
|
-
* @param format
|
|
731
|
-
* @
|
|
724
|
+
* @param {string} format - The format to convert.
|
|
725
|
+
* @returns {string} - The converted format.
|
|
732
726
|
*/
|
|
733
727
|
function convertFormatToFlatpickr(format) {
|
|
734
728
|
return format
|
|
@@ -759,8 +753,8 @@ function convertFormatToFlatpickr(format) {
|
|
|
759
753
|
exports.convertFormatToFlatpickr = convertFormatToFlatpickr;
|
|
760
754
|
/**
|
|
761
755
|
* Convert the format from the angular-datepicker module to moment format.
|
|
762
|
-
* @param format
|
|
763
|
-
* @
|
|
756
|
+
* @param {string} format - The format to convert.
|
|
757
|
+
* @returns {string} - The converted format.
|
|
764
758
|
*/
|
|
765
759
|
function convertFormatToMoment(format) {
|
|
766
760
|
return format
|
|
@@ -776,6 +770,11 @@ function convertFormatToMoment(format) {
|
|
|
776
770
|
.replace(/U/g, 'X');
|
|
777
771
|
}
|
|
778
772
|
exports.convertFormatToMoment = convertFormatToMoment;
|
|
773
|
+
/**
|
|
774
|
+
* Convert the format from the angular-datepicker module to mask format.
|
|
775
|
+
* @param {string} format - The format to convert.
|
|
776
|
+
* @returns {string} - The converted format.
|
|
777
|
+
*/
|
|
779
778
|
function convertFormatToMask(format) {
|
|
780
779
|
return format
|
|
781
780
|
// Long month replacement.
|
|
@@ -835,6 +834,13 @@ function getInputMask(mask, placeholderChar) {
|
|
|
835
834
|
return maskArray;
|
|
836
835
|
}
|
|
837
836
|
exports.getInputMask = getInputMask;
|
|
837
|
+
/**
|
|
838
|
+
* Unmasks a value using the provided mask and placeholder characters.
|
|
839
|
+
* @param {string} value - The value to unmask.
|
|
840
|
+
* @param {string} mask - The mask to use for unmasking.
|
|
841
|
+
* @param {string} placeholderChar - The placeholder character to use for unmasking.
|
|
842
|
+
* @returns {string} - The unmasked value.
|
|
843
|
+
*/
|
|
838
844
|
function unmaskValue(value, mask, placeholderChar) {
|
|
839
845
|
if (!mask || !value || value.length > mask.length) {
|
|
840
846
|
return value;
|
|
@@ -851,6 +857,12 @@ function unmaskValue(value, mask, placeholderChar) {
|
|
|
851
857
|
return unmaskedValue;
|
|
852
858
|
}
|
|
853
859
|
exports.unmaskValue = unmaskValue;
|
|
860
|
+
/**
|
|
861
|
+
* Returns true if the value matches the input mask format.
|
|
862
|
+
* @param {string} value - The value to check.
|
|
863
|
+
* @param {string} inputMask - The input mask to check against.
|
|
864
|
+
* @returns {boolean} - TRUE if the value matches the input mask; FALSE otherwise.
|
|
865
|
+
*/
|
|
854
866
|
function matchInputMask(value, inputMask) {
|
|
855
867
|
if (!inputMask) {
|
|
856
868
|
return true;
|
|
@@ -869,6 +881,11 @@ function matchInputMask(value, inputMask) {
|
|
|
869
881
|
return true;
|
|
870
882
|
}
|
|
871
883
|
exports.matchInputMask = matchInputMask;
|
|
884
|
+
/**
|
|
885
|
+
* Returns the number separators (i.e. 1,000) for the provided language.
|
|
886
|
+
* @param {string} lang - The language code to get the number separators for.
|
|
887
|
+
* @returns {{delimiter: string, decimalSeparator: string}} - The number separators.
|
|
888
|
+
*/
|
|
872
889
|
function getNumberSeparators(lang = 'en') {
|
|
873
890
|
const formattedNumberString = (12345.6789).toLocaleString(lang);
|
|
874
891
|
const delimeters = formattedNumberString.match(/..(.)...(.)../);
|
|
@@ -884,6 +901,12 @@ function getNumberSeparators(lang = 'en') {
|
|
|
884
901
|
};
|
|
885
902
|
}
|
|
886
903
|
exports.getNumberSeparators = getNumberSeparators;
|
|
904
|
+
/**
|
|
905
|
+
* Returns the number for the maximum amount of decimal places for a number.
|
|
906
|
+
* @param {import('@formio/core').Component} component - The component to check for decimal limits.
|
|
907
|
+
* @param {number} defaultLimit - The default limit to use if none is provided in the component.
|
|
908
|
+
* @returns {number} - The number of decimal places allowed.
|
|
909
|
+
*/
|
|
887
910
|
function getNumberDecimalLimit(component, defaultLimit) {
|
|
888
911
|
if (lodash_1.default.has(component, 'decimalLimit')) {
|
|
889
912
|
return lodash_1.default.get(component, 'decimalLimit');
|
|
@@ -900,6 +923,15 @@ function getNumberDecimalLimit(component, defaultLimit) {
|
|
|
900
923
|
return decimalLimit;
|
|
901
924
|
}
|
|
902
925
|
exports.getNumberDecimalLimit = getNumberDecimalLimit;
|
|
926
|
+
/**
|
|
927
|
+
* Returns the currency affixes for a specific language.
|
|
928
|
+
* @param {object} arg0 - The arguments object.
|
|
929
|
+
* @param {string} arg0.currency - The currency code to get the affixes for.
|
|
930
|
+
* @param {number} arg0.decimalLimit - The number of decimal places to use.
|
|
931
|
+
* @param {string} arg0.decimalSeparator - The decimal separator to use.
|
|
932
|
+
* @param {string} arg0.lang - The language code to use.
|
|
933
|
+
* @returns {{prefix: string, suffix: string}} - The currency affixes.
|
|
934
|
+
*/
|
|
903
935
|
function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }) {
|
|
904
936
|
// Get the prefix and suffix from the localized string.
|
|
905
937
|
let regex = `(.*)?${(100).toLocaleString(lang)}`;
|
|
@@ -922,10 +954,9 @@ function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, })
|
|
|
922
954
|
exports.getCurrencyAffixes = getCurrencyAffixes;
|
|
923
955
|
/**
|
|
924
956
|
* Fetch the field data provided a component.
|
|
925
|
-
*
|
|
926
|
-
* @param data
|
|
927
|
-
* @
|
|
928
|
-
* @return {*}
|
|
957
|
+
* @param {import('@formio/core').DataObject} data - The data object to fetch the field data from.
|
|
958
|
+
* @param {import('@formio/core').Component} component - The component to fetch the field data for.
|
|
959
|
+
* @returns {*} - The field data.
|
|
929
960
|
*/
|
|
930
961
|
function fieldData(data, component) {
|
|
931
962
|
if (!data) {
|
|
@@ -972,16 +1003,23 @@ function fieldData(data, component) {
|
|
|
972
1003
|
exports.fieldData = fieldData;
|
|
973
1004
|
/**
|
|
974
1005
|
* Delays function execution with possibility to execute function synchronously or cancel it.
|
|
975
|
-
*
|
|
976
|
-
* @param
|
|
977
|
-
* @param
|
|
978
|
-
* @
|
|
1006
|
+
* @param {Function} fn - Function to delay
|
|
1007
|
+
* @param {number} delay - Delay time
|
|
1008
|
+
* @param {...any} args - Arguments to pass to the function
|
|
1009
|
+
* @returns {*} - Function to cancel the delay
|
|
979
1010
|
*/
|
|
980
1011
|
function delay(fn, delay = 0, ...args) {
|
|
981
1012
|
const timer = setTimeout(fn, delay, ...args);
|
|
1013
|
+
/**
|
|
1014
|
+
*
|
|
1015
|
+
*/
|
|
982
1016
|
function cancel() {
|
|
983
1017
|
clearTimeout(timer);
|
|
984
1018
|
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Execute the function early.
|
|
1021
|
+
* @returns {*} - The result of the function.
|
|
1022
|
+
*/
|
|
985
1023
|
function earlyCall() {
|
|
986
1024
|
cancel();
|
|
987
1025
|
return fn(...args);
|
|
@@ -993,11 +1031,9 @@ function delay(fn, delay = 0, ...args) {
|
|
|
993
1031
|
exports.delay = delay;
|
|
994
1032
|
/**
|
|
995
1033
|
* Iterate the given key to make it unique.
|
|
996
|
-
*
|
|
997
|
-
* @param {String} key
|
|
1034
|
+
* @param {string} key
|
|
998
1035
|
* Modify the component key to be unique.
|
|
999
|
-
*
|
|
1000
|
-
* @returns {String}
|
|
1036
|
+
* @returns {string}
|
|
1001
1037
|
* The new component key.
|
|
1002
1038
|
*/
|
|
1003
1039
|
function iterateKey(key) {
|
|
@@ -1011,10 +1047,9 @@ function iterateKey(key) {
|
|
|
1011
1047
|
exports.iterateKey = iterateKey;
|
|
1012
1048
|
/**
|
|
1013
1049
|
* Determines a unique key within a map provided the base key.
|
|
1014
|
-
*
|
|
1015
|
-
* @param
|
|
1016
|
-
* @
|
|
1017
|
-
* @return {*}
|
|
1050
|
+
* @param {Record<string, string>} map - The map to check for uniqueness.
|
|
1051
|
+
* @param {string} base - The base path of the key.
|
|
1052
|
+
* @returns {string} - The unique key.
|
|
1018
1053
|
*/
|
|
1019
1054
|
function uniqueKey(map, base) {
|
|
1020
1055
|
let newKey = base;
|
|
@@ -1026,8 +1061,9 @@ function uniqueKey(map, base) {
|
|
|
1026
1061
|
exports.uniqueKey = uniqueKey;
|
|
1027
1062
|
/**
|
|
1028
1063
|
* Determines the major version number of bootstrap.
|
|
1029
|
-
*
|
|
1030
|
-
* @
|
|
1064
|
+
* @param {object} options - The options to check for bootstrap version.
|
|
1065
|
+
* @param {string} options.bootstrap - The bootstrap version to use.
|
|
1066
|
+
* @returns {number} - The bootstrap version.
|
|
1031
1067
|
*/
|
|
1032
1068
|
function bootstrapVersion(options) {
|
|
1033
1069
|
if (options.bootstrap) {
|
|
@@ -1045,9 +1081,8 @@ exports.bootstrapVersion = bootstrapVersion;
|
|
|
1045
1081
|
/**
|
|
1046
1082
|
* Retrun provided argument.
|
|
1047
1083
|
* If argument is a function, returns the result of a function call.
|
|
1048
|
-
* @param {
|
|
1049
|
-
*
|
|
1050
|
-
* @return {*}
|
|
1084
|
+
* @param {Function|any} e - The argument to check if a function and call if so.
|
|
1085
|
+
* @returns {any} - Either the result of the function call (e) or e if it is not a function.
|
|
1051
1086
|
*/
|
|
1052
1087
|
function unfold(e) {
|
|
1053
1088
|
if (typeof e === 'function') {
|
|
@@ -1058,27 +1093,32 @@ function unfold(e) {
|
|
|
1058
1093
|
exports.unfold = unfold;
|
|
1059
1094
|
/**
|
|
1060
1095
|
* Map values through unfold and return first non-nil value.
|
|
1061
|
-
* @param {Array<T>} collection
|
|
1062
|
-
*
|
|
1063
|
-
* @return {T}
|
|
1096
|
+
* @param {Array<T>} collection - The collection to map through unfold.;
|
|
1097
|
+
* @returns {T} - The first non-nil value.
|
|
1064
1098
|
*/
|
|
1065
1099
|
exports.firstNonNil = lodash_1.default.flow([
|
|
1066
1100
|
lodash_1.default.partialRight(lodash_1.default.map, unfold),
|
|
1067
1101
|
lodash_1.default.partialRight(lodash_1.default.find, v => !lodash_1.default.isUndefined(v))
|
|
1068
1102
|
]);
|
|
1069
|
-
|
|
1070
|
-
* Create enclosed state.
|
|
1071
|
-
* Returns functions to getting and cycling between states.
|
|
1103
|
+
/**
|
|
1104
|
+
* Create enclosed state. Returns functions to getting and cycling between states.
|
|
1072
1105
|
* @param {*} a - initial state.
|
|
1073
1106
|
* @param {*} b - next state.
|
|
1074
|
-
* @
|
|
1107
|
+
* @returns {Functions[]} -- [get, toggle];
|
|
1075
1108
|
*/
|
|
1076
1109
|
function withSwitch(a, b) {
|
|
1077
1110
|
let state = a;
|
|
1078
1111
|
let next = b;
|
|
1112
|
+
/**
|
|
1113
|
+
* Returns the state of the switch.
|
|
1114
|
+
* @returns {*} - The current state.
|
|
1115
|
+
*/
|
|
1079
1116
|
function get() {
|
|
1080
1117
|
return state;
|
|
1081
1118
|
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Toggles the state of the switch.
|
|
1121
|
+
*/
|
|
1082
1122
|
function toggle() {
|
|
1083
1123
|
const prev = state;
|
|
1084
1124
|
state = next;
|
|
@@ -1087,6 +1127,14 @@ function withSwitch(a, b) {
|
|
|
1087
1127
|
return [get, toggle];
|
|
1088
1128
|
}
|
|
1089
1129
|
exports.withSwitch = withSwitch;
|
|
1130
|
+
/**
|
|
1131
|
+
* Create a function that will call the provided function only the provided limit.
|
|
1132
|
+
* @param {Function} callback - The callback to call.
|
|
1133
|
+
* @param {object} options - The options to use.
|
|
1134
|
+
* @param {number} options.limit - The limit to call the callback.
|
|
1135
|
+
* @param {number} options.delay - The delay to wait before resetting the call count.
|
|
1136
|
+
* @returns {Function} - The function that will call the callback only the provided limit.
|
|
1137
|
+
*/
|
|
1090
1138
|
function observeOverload(callback, options = {}) {
|
|
1091
1139
|
const { limit = 50, delay = 500 } = options;
|
|
1092
1140
|
let callCount = 0;
|
|
@@ -1107,6 +1155,13 @@ function observeOverload(callback, options = {}) {
|
|
|
1107
1155
|
};
|
|
1108
1156
|
}
|
|
1109
1157
|
exports.observeOverload = observeOverload;
|
|
1158
|
+
/**
|
|
1159
|
+
* Returns the components that are provided within an evaluation context.
|
|
1160
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1161
|
+
* @param {boolean} excludeNested - Exclude nested components.
|
|
1162
|
+
* @param {Array<string>} excludedTypes - The types of components to exclude.
|
|
1163
|
+
* @returns {Array} - The components within the evaluation context.
|
|
1164
|
+
*/
|
|
1110
1165
|
function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
1111
1166
|
const values = [];
|
|
1112
1167
|
context.utils.eachComponent(context.instance.options.editForm.components, (component, path) => {
|
|
@@ -1121,6 +1176,11 @@ function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
|
1121
1176
|
return values;
|
|
1122
1177
|
}
|
|
1123
1178
|
exports.getContextComponents = getContextComponents;
|
|
1179
|
+
/**
|
|
1180
|
+
* Returns the button components that are within an evaluation context.
|
|
1181
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1182
|
+
* @returns {Array} - The button components within the evaluation context.
|
|
1183
|
+
*/
|
|
1124
1184
|
function getContextButtons(context) {
|
|
1125
1185
|
const values = [];
|
|
1126
1186
|
context.utils.eachComponent(context.instance.options.editForm.components, (component) => {
|
|
@@ -1138,18 +1198,15 @@ exports.getContextButtons = getContextButtons;
|
|
|
1138
1198
|
const inTextTags = ['#text', 'A', 'B', 'EM', 'I', 'SMALL', 'STRONG', 'SUB', 'SUP', 'INS', 'DEL', 'MARK', 'CODE'];
|
|
1139
1199
|
/**
|
|
1140
1200
|
* Helper function for 'translateHTMLTemplate'. Translates text value of the passed html element.
|
|
1141
|
-
*
|
|
1142
|
-
* @param {
|
|
1143
|
-
* @
|
|
1144
|
-
*
|
|
1145
|
-
* @returns {String}
|
|
1146
|
-
* Translated element template.
|
|
1201
|
+
* @param {HTMLElement} elem - The element to translate.
|
|
1202
|
+
* @param {Function} translate - The translation function.
|
|
1203
|
+
* @returns {string} - Translated element template.
|
|
1147
1204
|
*/
|
|
1148
1205
|
function translateElemValue(elem, translate) {
|
|
1149
1206
|
if (!elem.innerText) {
|
|
1150
1207
|
return elem.innerHTML;
|
|
1151
1208
|
}
|
|
1152
|
-
const elemValue = elem.innerText.replace(Evaluator_1.
|
|
1209
|
+
const elemValue = elem.innerText.replace(Evaluator_1.Evaluator.templateSettings.interpolate, '').replace(/\s\s+/g, ' ').trim();
|
|
1153
1210
|
const translatedValue = translate(elemValue);
|
|
1154
1211
|
if (elemValue !== translatedValue) {
|
|
1155
1212
|
const links = elem.innerHTML.match(/<a[^>]*>(.*?)<\/a>/g);
|
|
@@ -1174,10 +1231,8 @@ function translateElemValue(elem, translate) {
|
|
|
1174
1231
|
}
|
|
1175
1232
|
/**
|
|
1176
1233
|
* Helper function for 'translateHTMLTemplate'. Goes deep through html tag children and calls function to translate their text values.
|
|
1177
|
-
*
|
|
1178
|
-
* @param {
|
|
1179
|
-
* @param {Function} translate
|
|
1180
|
-
*
|
|
1234
|
+
* @param {HTMLElement} tag - The tag to translate.
|
|
1235
|
+
* @param {Function} translate - The translation function.
|
|
1181
1236
|
* @returns {void}
|
|
1182
1237
|
*/
|
|
1183
1238
|
function translateDeepTag(tag, translate) {
|
|
@@ -1193,12 +1248,9 @@ function translateDeepTag(tag, translate) {
|
|
|
1193
1248
|
}
|
|
1194
1249
|
/**
|
|
1195
1250
|
* Translates text values in html template.
|
|
1196
|
-
*
|
|
1197
|
-
* @param {
|
|
1198
|
-
* @
|
|
1199
|
-
*
|
|
1200
|
-
* @returns {String}
|
|
1201
|
-
* Html template with translated values.
|
|
1251
|
+
* @param {string} template - The template to translate.
|
|
1252
|
+
* @param {Function} translate - The translation function.
|
|
1253
|
+
* @returns {string} - Html template with translated values.
|
|
1202
1254
|
*/
|
|
1203
1255
|
function translateHTMLTemplate(template, translate) {
|
|
1204
1256
|
const isHTML = /<[^>]*>/.test(template);
|
|
@@ -1216,9 +1268,9 @@ function translateHTMLTemplate(template, translate) {
|
|
|
1216
1268
|
exports.translateHTMLTemplate = translateHTMLTemplate;
|
|
1217
1269
|
/**
|
|
1218
1270
|
* Sanitize an html string.
|
|
1219
|
-
*
|
|
1220
|
-
* @param
|
|
1221
|
-
* @returns {
|
|
1271
|
+
* @param {string} string - The string to sanitize.
|
|
1272
|
+
* @param {any} options - The options to use for sanitization.
|
|
1273
|
+
* @returns {string} - The sanitized html string.
|
|
1222
1274
|
*/
|
|
1223
1275
|
function sanitize(string, options) {
|
|
1224
1276
|
if (typeof dompurify_1.default.sanitize !== 'function') {
|
|
@@ -1267,11 +1319,18 @@ function sanitize(string, options) {
|
|
|
1267
1319
|
exports.sanitize = sanitize;
|
|
1268
1320
|
/**
|
|
1269
1321
|
* Fast cloneDeep for JSON objects only.
|
|
1322
|
+
* @param {any} obj - The object to perform a fast clone deep against.
|
|
1323
|
+
* @returns {any} - The cloned object.
|
|
1270
1324
|
*/
|
|
1271
1325
|
function fastCloneDeep(obj) {
|
|
1272
1326
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
|
1273
1327
|
}
|
|
1274
1328
|
exports.fastCloneDeep = fastCloneDeep;
|
|
1329
|
+
/**
|
|
1330
|
+
* Returns if the component is an input component.
|
|
1331
|
+
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
1332
|
+
* @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
|
|
1333
|
+
*/
|
|
1275
1334
|
function isInputComponent(componentJson) {
|
|
1276
1335
|
if (componentJson.input === false || componentJson.input === true) {
|
|
1277
1336
|
return componentJson.input;
|
|
@@ -1292,6 +1351,11 @@ function isInputComponent(componentJson) {
|
|
|
1292
1351
|
}
|
|
1293
1352
|
}
|
|
1294
1353
|
exports.isInputComponent = isInputComponent;
|
|
1354
|
+
/**
|
|
1355
|
+
* Takes a component path, and returns a component path array.
|
|
1356
|
+
* @param {string} pathStr - The path string to convert to an array.
|
|
1357
|
+
* @returns {Arryay<number>} - The array of paths.
|
|
1358
|
+
*/
|
|
1295
1359
|
function getArrayFromComponentPath(pathStr) {
|
|
1296
1360
|
if (!pathStr || !lodash_1.default.isString(pathStr)) {
|
|
1297
1361
|
if (!lodash_1.default.isArray(pathStr)) {
|
|
@@ -1306,6 +1370,12 @@ function getArrayFromComponentPath(pathStr) {
|
|
|
1306
1370
|
.map(part => lodash_1.default.defaultTo(lodash_1.default.toNumber(part), part));
|
|
1307
1371
|
}
|
|
1308
1372
|
exports.getArrayFromComponentPath = getArrayFromComponentPath;
|
|
1373
|
+
/**
|
|
1374
|
+
* Returns true if the component is a child of the parent.
|
|
1375
|
+
* @param {any} child - The child component to check.
|
|
1376
|
+
* @param {any} parent - The parent component to check.
|
|
1377
|
+
* @returns {boolean} - TRUE if the child is a child of the parent; FALSE otherwise.
|
|
1378
|
+
*/
|
|
1309
1379
|
function isChildOf(child, parent) {
|
|
1310
1380
|
while (child && child.parent) {
|
|
1311
1381
|
if (child.parent === parent) {
|
|
@@ -1316,6 +1386,11 @@ function isChildOf(child, parent) {
|
|
|
1316
1386
|
return false;
|
|
1317
1387
|
}
|
|
1318
1388
|
exports.isChildOf = isChildOf;
|
|
1389
|
+
/**
|
|
1390
|
+
* Takes an array of component path indexes, and returns a string version of that array.
|
|
1391
|
+
* @param {Array<number>} path - The path array to convert to a string.
|
|
1392
|
+
* @returns {string} - The string version of the path.
|
|
1393
|
+
*/
|
|
1319
1394
|
function getStringFromComponentPath(path) {
|
|
1320
1395
|
if (!lodash_1.default.isArray(path)) {
|
|
1321
1396
|
return path;
|
|
@@ -1332,17 +1407,22 @@ function getStringFromComponentPath(path) {
|
|
|
1332
1407
|
return strPath;
|
|
1333
1408
|
}
|
|
1334
1409
|
exports.getStringFromComponentPath = getStringFromComponentPath;
|
|
1410
|
+
/**
|
|
1411
|
+
* Takes a number and rounds it to the provided precision amount.
|
|
1412
|
+
* @param {number} number - The number to round.
|
|
1413
|
+
* @param {number} precision - The precision to round the number to.
|
|
1414
|
+
* @returns {string} - The rounded number.
|
|
1415
|
+
*/
|
|
1335
1416
|
function round(number, precision) {
|
|
1336
1417
|
if (lodash_1.default.isNumber(number)) {
|
|
1337
1418
|
return number.toFixed(precision);
|
|
1338
1419
|
}
|
|
1339
|
-
return number;
|
|
1420
|
+
return number.toString();
|
|
1340
1421
|
}
|
|
1341
1422
|
exports.round = round;
|
|
1342
1423
|
/**
|
|
1343
1424
|
* Check for Internet Explorer browser version
|
|
1344
|
-
*
|
|
1345
|
-
* @return {(number|null)}
|
|
1425
|
+
* @returns {(number|null)} - The IE browser version or null if not IE
|
|
1346
1426
|
*/
|
|
1347
1427
|
function getIEBrowserVersion() {
|
|
1348
1428
|
const { ie, version } = getBrowserInfo();
|
|
@@ -1351,8 +1431,7 @@ function getIEBrowserVersion() {
|
|
|
1351
1431
|
exports.getIEBrowserVersion = getIEBrowserVersion;
|
|
1352
1432
|
/**
|
|
1353
1433
|
* Get browser name and version (modified from 'jquery-browser-plugin')
|
|
1354
|
-
*
|
|
1355
|
-
* @return {Object} -- {{browser name, version, isWebkit?}}
|
|
1434
|
+
* @returns {object} -- {{browser name, version, isWebkit?}}
|
|
1356
1435
|
* Possible browser names: chrome, safari, ie, edge, opera, mozilla, yabrowser
|
|
1357
1436
|
*/
|
|
1358
1437
|
function getBrowserInfo() {
|
|
@@ -1401,13 +1480,20 @@ function getBrowserInfo() {
|
|
|
1401
1480
|
return browser;
|
|
1402
1481
|
}
|
|
1403
1482
|
exports.getBrowserInfo = getBrowserInfo;
|
|
1483
|
+
/**
|
|
1484
|
+
* Takes a component path, which may include array indicies (i.e. [0][1]), and returns the compoennt path without the indicies.
|
|
1485
|
+
* @param {string} path - The path to remove the indicies from.
|
|
1486
|
+
* @returns {string} - The path without the indicies.
|
|
1487
|
+
*/
|
|
1404
1488
|
function getComponentPathWithoutIndicies(path = '') {
|
|
1405
1489
|
return path.replace(/\[\d+\]/, '');
|
|
1406
1490
|
}
|
|
1407
1491
|
exports.getComponentPathWithoutIndicies = getComponentPathWithoutIndicies;
|
|
1408
1492
|
/**
|
|
1409
1493
|
* Returns a path to the component which based on its schema
|
|
1410
|
-
* @param {
|
|
1494
|
+
* @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
|
|
1495
|
+
* @param {string} path - Path to the component
|
|
1496
|
+
* @returns {string} - Path to the component
|
|
1411
1497
|
*/
|
|
1412
1498
|
function getComponentPath(component, path = '') {
|
|
1413
1499
|
var _a;
|
|
@@ -1420,8 +1506,8 @@ function getComponentPath(component, path = '') {
|
|
|
1420
1506
|
exports.getComponentPath = getComponentPath;
|
|
1421
1507
|
/**
|
|
1422
1508
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
1423
|
-
* @param {
|
|
1424
|
-
* @
|
|
1509
|
+
* @param {Component} componentInstance - The component to check for the parent.
|
|
1510
|
+
* @returns {Component|undefined} - The parent data component.
|
|
1425
1511
|
*/
|
|
1426
1512
|
function getDataParentComponent(componentInstance) {
|
|
1427
1513
|
if (!componentInstance) {
|
|
@@ -1438,8 +1524,8 @@ function getDataParentComponent(componentInstance) {
|
|
|
1438
1524
|
exports.getDataParentComponent = getDataParentComponent;
|
|
1439
1525
|
/**
|
|
1440
1526
|
* Returns whether the value is a promise
|
|
1441
|
-
* @param value
|
|
1442
|
-
* @
|
|
1527
|
+
* @param {any} value - The value to check
|
|
1528
|
+
* @returns {boolean} - TRUE if the value is a promise; FALSE otherwise
|
|
1443
1529
|
*/
|
|
1444
1530
|
function isPromise(value) {
|
|
1445
1531
|
return value
|
|
@@ -1451,9 +1537,9 @@ exports.isPromise = isPromise;
|
|
|
1451
1537
|
/**
|
|
1452
1538
|
* Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
|
|
1453
1539
|
* changes by itself, e.g. EditGrid)
|
|
1454
|
-
* @param componentInstance
|
|
1455
|
-
* @param firstPass
|
|
1456
|
-
* @returns {boolean
|
|
1540
|
+
* @param {Component} componentInstance - The component to check for the scoping parent.
|
|
1541
|
+
* @param {boolean} firstPass - Whether it is the first pass of the function
|
|
1542
|
+
* @returns {boolean|*} - TRUE if the component has a scoping parent; FALSE otherwise
|
|
1457
1543
|
*/
|
|
1458
1544
|
function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
1459
1545
|
if (!firstPass && (componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.hasScopedChildren)) {
|
|
@@ -1469,6 +1555,11 @@ function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
|
1469
1555
|
return false;
|
|
1470
1556
|
}
|
|
1471
1557
|
exports.isInsideScopingComponent = isInsideScopingComponent;
|
|
1558
|
+
/**
|
|
1559
|
+
* Returns all the focusable elements within the provided dom element.
|
|
1560
|
+
* @param {HTMLElement} element - The element to get the focusable elements from.
|
|
1561
|
+
* @returns {NodeList<HTMLElement>} - The focusable elements within the provided element.
|
|
1562
|
+
*/
|
|
1472
1563
|
function getFocusableElements(element) {
|
|
1473
1564
|
const focusableSelector = `button:not([disabled]), input:not([disabled]), select:not([disabled]),
|
|
1474
1565
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
|
@@ -1484,6 +1575,11 @@ exports.componentValueTypes = {
|
|
|
1484
1575
|
date: 'date',
|
|
1485
1576
|
any: 'any',
|
|
1486
1577
|
};
|
|
1578
|
+
/**
|
|
1579
|
+
* Returns the saved types for the component
|
|
1580
|
+
* @param {import('@formio/core').Component} fullSchema - The component schema
|
|
1581
|
+
* @returns {Array<string>|null} - The saved types for the component
|
|
1582
|
+
*/
|
|
1487
1583
|
function getComponentSavedTypes(fullSchema) {
|
|
1488
1584
|
const schema = fullSchema || {};
|
|
1489
1585
|
if (schema.persistent !== true) {
|
|
@@ -1497,9 +1593,10 @@ function getComponentSavedTypes(fullSchema) {
|
|
|
1497
1593
|
exports.getComponentSavedTypes = getComponentSavedTypes;
|
|
1498
1594
|
/**
|
|
1499
1595
|
* Interpolates @formio/core errors so that they are compatible with the renderer
|
|
1500
|
-
* @param {
|
|
1501
|
-
* @param
|
|
1502
|
-
* @
|
|
1596
|
+
* @param {Component} component - The component to interpolate the errors for
|
|
1597
|
+
* @param {FieldError[]} errors - The errors to interpolate
|
|
1598
|
+
* @param {Function} interpolateFn - The interpolation function
|
|
1599
|
+
* @returns {[]} - The interpolated errors
|
|
1503
1600
|
*/
|
|
1504
1601
|
const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1505
1602
|
return errors.map((error) => {
|
|
@@ -1510,6 +1607,11 @@ const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1510
1607
|
});
|
|
1511
1608
|
};
|
|
1512
1609
|
exports.interpolateErrors = interpolateErrors;
|
|
1610
|
+
/**
|
|
1611
|
+
* Returns the template keys inside the template code.
|
|
1612
|
+
* @param {string} template - The template to get the keys from.
|
|
1613
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
1614
|
+
*/
|
|
1513
1615
|
function getItemTemplateKeys(template) {
|
|
1514
1616
|
const templateKeys = [];
|
|
1515
1617
|
if (!template) {
|
|
@@ -1527,6 +1629,11 @@ function getItemTemplateKeys(template) {
|
|
|
1527
1629
|
return templateKeys;
|
|
1528
1630
|
}
|
|
1529
1631
|
exports.getItemTemplateKeys = getItemTemplateKeys;
|
|
1632
|
+
/**
|
|
1633
|
+
* Returns if the component is a select resource with an object for its value.
|
|
1634
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1635
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1636
|
+
*/
|
|
1530
1637
|
function isSelectResourceWithObjectValue(comp = {}) {
|
|
1531
1638
|
const { reference, dataSrc, valueProperty } = comp;
|
|
1532
1639
|
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|