@formio/js 5.0.0-dev.5603.8554c0d → 5.0.0-dev.5610.11a9aca
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 +641 -1189
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -11
- package/dist/formio.full.js +685 -913
- 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 +1855 -487
- 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 +85 -96
- package/lib/cjs/Element.js +65 -76
- 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 +15 -11
- 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 +7 -3
- package/lib/cjs/utils/Evaluator.js +12 -18
- 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 +361 -216
- package/lib/cjs/utils/utils.js +329 -169
- package/lib/cjs/widgets/CalendarWidget.d.ts +9 -10
- package/lib/cjs/widgets/CalendarWidget.js +9 -11
- package/lib/mjs/Element.d.ts +85 -96
- package/lib/mjs/Element.js +65 -76
- 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 +15 -11
- 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 +7 -3
- package/lib/mjs/utils/Evaluator.js +10 -18
- 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 +361 -216
- package/lib/mjs/utils/utils.js +321 -161
- 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,10 +80,11 @@ function setPathToComponentAndPerentSchema(component) {
|
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* Evaluate a method.
|
|
79
|
-
*
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
82
|
-
* @
|
|
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} tokenize - True if the script should be interpolated before being executed.
|
|
87
|
+
* @returns {*} - The result of the evaluation.
|
|
83
88
|
*/
|
|
84
89
|
function evaluate(func, args, ret, tokenize) {
|
|
85
90
|
let returnVal = null;
|
|
@@ -106,7 +111,7 @@ function evaluate(func, args, ret, tokenize) {
|
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
try {
|
|
109
|
-
func = Evaluator_1.
|
|
114
|
+
func = Evaluator_1.Evaluator.evaluator(func, args);
|
|
110
115
|
args = lodash_1.default.values(args);
|
|
111
116
|
}
|
|
112
117
|
catch (err) {
|
|
@@ -117,7 +122,7 @@ function evaluate(func, args, ret, tokenize) {
|
|
|
117
122
|
}
|
|
118
123
|
if (typeof func === 'function') {
|
|
119
124
|
try {
|
|
120
|
-
returnVal = Evaluator_1.
|
|
125
|
+
returnVal = Evaluator_1.Evaluator.evaluate(func, args);
|
|
121
126
|
}
|
|
122
127
|
catch (err) {
|
|
123
128
|
returnVal = null;
|
|
@@ -139,16 +144,19 @@ function evaluate(func, args, ret, tokenize) {
|
|
|
139
144
|
return returnVal;
|
|
140
145
|
}
|
|
141
146
|
exports.evaluate = evaluate;
|
|
147
|
+
/**
|
|
148
|
+
* Returns a random compoennt ID.
|
|
149
|
+
* @returns {string} - A random component ID.
|
|
150
|
+
*/
|
|
142
151
|
function getRandomComponentId() {
|
|
143
152
|
return `e${Math.random().toString(36).substring(7)}`;
|
|
144
153
|
}
|
|
145
154
|
exports.getRandomComponentId = getRandomComponentId;
|
|
146
155
|
/**
|
|
147
156
|
* Get a property value of an element.
|
|
148
|
-
*
|
|
149
|
-
* @param
|
|
150
|
-
* @
|
|
151
|
-
* @return {number}
|
|
157
|
+
* @param {CSSStyleDeclaration} style - The style element to get the property value from.
|
|
158
|
+
* @param {string} prop - The property to get the value for.
|
|
159
|
+
* @returns {number} - The value of the property.
|
|
152
160
|
*/
|
|
153
161
|
function getPropertyValue(style, prop) {
|
|
154
162
|
let value = style.getPropertyValue(prop);
|
|
@@ -158,9 +166,8 @@ function getPropertyValue(style, prop) {
|
|
|
158
166
|
exports.getPropertyValue = getPropertyValue;
|
|
159
167
|
/**
|
|
160
168
|
* Get an elements bounding rectagle.
|
|
161
|
-
*
|
|
162
|
-
* @
|
|
163
|
-
* @return {{x: string, y: string, width: string, height: string}}
|
|
169
|
+
* @param {HTMLElement} element - A DOM element to get the bounding rectangle for.
|
|
170
|
+
* @returns {{x: number, y: number, width: number, height: number}} - The bounding rectangle.
|
|
164
171
|
*/
|
|
165
172
|
function getElementRect(element) {
|
|
166
173
|
const style = window.getComputedStyle(element, null);
|
|
@@ -174,9 +181,8 @@ function getElementRect(element) {
|
|
|
174
181
|
exports.getElementRect = getElementRect;
|
|
175
182
|
/**
|
|
176
183
|
* Determines the boolean value of a setting.
|
|
177
|
-
*
|
|
178
|
-
* @
|
|
179
|
-
* @return {boolean}
|
|
184
|
+
* @param {string|boolean} value - A string or boolean value to convert to boolean.
|
|
185
|
+
* @returns {boolean} - The boolean value of the setting.
|
|
180
186
|
*/
|
|
181
187
|
function boolValue(value) {
|
|
182
188
|
if (lodash_1.default.isBoolean(value)) {
|
|
@@ -192,22 +198,18 @@ function boolValue(value) {
|
|
|
192
198
|
exports.boolValue = boolValue;
|
|
193
199
|
/**
|
|
194
200
|
* Check to see if an ID is a mongoID.
|
|
195
|
-
* @param text
|
|
196
|
-
* @
|
|
201
|
+
* @param {string} text - The text to check if it is a mongoID.
|
|
202
|
+
* @returns {boolean} - TRUE if the text is a mongoID; FALSE otherwise.
|
|
197
203
|
*/
|
|
198
204
|
function isMongoId(text) {
|
|
199
|
-
return text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
205
|
+
return !!text.toString().match(/^[0-9a-fA-F]{24}$/);
|
|
200
206
|
}
|
|
201
207
|
exports.isMongoId = isMongoId;
|
|
202
208
|
/**
|
|
203
209
|
* 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.
|
|
210
|
+
* @param {import('@formio/core').Component} component - The component to check for the calculated value.
|
|
211
|
+
* @param {import('@formio/core').Submission} submission - A submission object.
|
|
212
|
+
* @param {*} rowData - The contextual row data for the component.
|
|
211
213
|
*/
|
|
212
214
|
function checkCalculated(component, submission, rowData) {
|
|
213
215
|
// Process calculated value stuff if present.
|
|
@@ -224,13 +226,12 @@ function checkCalculated(component, submission, rowData) {
|
|
|
224
226
|
exports.checkCalculated = checkCalculated;
|
|
225
227
|
/**
|
|
226
228
|
* Check if a simple conditional evaluates to true.
|
|
227
|
-
*
|
|
228
|
-
* @param condition
|
|
229
|
-
* @param
|
|
230
|
-
* @param
|
|
231
|
-
* @param
|
|
232
|
-
* @
|
|
233
|
-
* @returns {boolean}
|
|
229
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
230
|
+
* @param {import('@formio/core').SimpleConditional} condition - The condition to check.
|
|
231
|
+
* @param {*} row - The row data for the component.
|
|
232
|
+
* @param {*} data - The full submission data.
|
|
233
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The instance of the component.
|
|
234
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
234
235
|
*/
|
|
235
236
|
function checkSimpleConditional(component, condition, row, data, instance) {
|
|
236
237
|
if (condition.when) {
|
|
@@ -275,6 +276,13 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
exports.checkSimpleConditional = checkSimpleConditional;
|
|
279
|
+
/**
|
|
280
|
+
* Returns a components normalized value.
|
|
281
|
+
* @param {string} compPath - The full path to the component.
|
|
282
|
+
* @param {*} data - The data object to get the value from.
|
|
283
|
+
* @param {*} row - The contextual row data for the component.
|
|
284
|
+
* @returns {*} - The normalized value of the component.
|
|
285
|
+
*/
|
|
278
286
|
function getComponentActualValue(compPath, data, row) {
|
|
279
287
|
let value = null;
|
|
280
288
|
if (row) {
|
|
@@ -292,12 +300,15 @@ function getComponentActualValue(compPath, data, row) {
|
|
|
292
300
|
exports.getComponentActualValue = getComponentActualValue;
|
|
293
301
|
/**
|
|
294
302
|
* Check custom javascript conditional.
|
|
295
|
-
*
|
|
296
|
-
* @param
|
|
297
|
-
* @param
|
|
298
|
-
* @param
|
|
299
|
-
* @param
|
|
300
|
-
* @
|
|
303
|
+
* @param {import('@formio/core').Component} component - The component to check for the conditional.
|
|
304
|
+
* @param {string} custom - The custom conditional string to evaluate.
|
|
305
|
+
* @param {*} row - The row data for the component.
|
|
306
|
+
* @param {*} data - The full submission data.
|
|
307
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
308
|
+
* @param {string} variable - The variable name for the result of the custom conditional.
|
|
309
|
+
* @param {*} onError - A custom return if there is an error or the value is null from the evaluation.
|
|
310
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
311
|
+
* @returns {*} - The result of the evaulation.
|
|
301
312
|
*/
|
|
302
313
|
function checkCustomConditional(component, custom, row, data, form, variable, onError, instance) {
|
|
303
314
|
if (typeof custom === 'string') {
|
|
@@ -312,6 +323,16 @@ function checkCustomConditional(component, custom, row, data, form, variable, on
|
|
|
312
323
|
return value;
|
|
313
324
|
}
|
|
314
325
|
exports.checkCustomConditional = checkCustomConditional;
|
|
326
|
+
/**
|
|
327
|
+
* Check a component for JSON conditionals.
|
|
328
|
+
* @param {import('@formio/core').Component} component - The component
|
|
329
|
+
* @param {import('@formio/core').JSONConditional} json - The json conditional to check.
|
|
330
|
+
* @param {*} row - The contextual row data for the component.
|
|
331
|
+
* @param {*} data - The full submission data.
|
|
332
|
+
* @param {import('@formio/core').Form} form - The Form JSON of the form.
|
|
333
|
+
* @param {*} onError - Custom return value if there is an error.
|
|
334
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
335
|
+
*/
|
|
315
336
|
function checkJsonConditional(component, json, row, data, form, onError) {
|
|
316
337
|
try {
|
|
317
338
|
return json_logic_js_1.default.apply(json, {
|
|
@@ -327,6 +348,14 @@ function checkJsonConditional(component, json, row, data, form, onError) {
|
|
|
327
348
|
}
|
|
328
349
|
}
|
|
329
350
|
exports.checkJsonConditional = checkJsonConditional;
|
|
351
|
+
/**
|
|
352
|
+
* Returns the contextual row data for a component.
|
|
353
|
+
* @param {import('@formio/core').Component} component - The component to get the row data for.
|
|
354
|
+
* @param {*} row - The row data for the component.
|
|
355
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
356
|
+
* @param {*} conditional - The component conditional.
|
|
357
|
+
* @returns {*} - The contextual row data for the component.
|
|
358
|
+
*/
|
|
330
359
|
function getRow(component, row, instance, conditional) {
|
|
331
360
|
var _a;
|
|
332
361
|
const condition = conditional || component.conditional;
|
|
@@ -349,15 +378,12 @@ function getRow(component, row, instance, conditional) {
|
|
|
349
378
|
}
|
|
350
379
|
/**
|
|
351
380
|
* 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}
|
|
381
|
+
* @param {import('@formio/core').Component} component - The component to check for the condition.
|
|
382
|
+
* @param {*} row - The data within a row
|
|
383
|
+
* @param {*} data - The full submission data.
|
|
384
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
385
|
+
* @param {import('../../src/components/_classes/component/Component').Component} instance - The component instance.
|
|
386
|
+
* @returns {boolean} - TRUE if the condition is true; FALSE otherwise.
|
|
361
387
|
*/
|
|
362
388
|
function checkCondition(component, row, data, form, instance) {
|
|
363
389
|
const { customConditional, conditional } = component;
|
|
@@ -377,12 +403,13 @@ function checkCondition(component, row, data, form, instance) {
|
|
|
377
403
|
exports.checkCondition = checkCondition;
|
|
378
404
|
/**
|
|
379
405
|
* Test a trigger on a component.
|
|
380
|
-
*
|
|
381
|
-
* @param
|
|
382
|
-
* @param
|
|
383
|
-
* @param data
|
|
384
|
-
* @param
|
|
385
|
-
* @
|
|
406
|
+
* @param {import('@formio/core').Component} component - The component to test the trigger against.
|
|
407
|
+
* @param {import('@formio/core').LogicTrigger} trigger - The trigger configuration.
|
|
408
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
409
|
+
* @param {import('@formio/core').DataObject} data - The root data object.
|
|
410
|
+
* @param {import('@formio/core').Form} form - The form object.
|
|
411
|
+
* @param {any} instance - The component that is performing the trigger.
|
|
412
|
+
* @returns {boolean} - TRUE if the trigger should fire; FALSE otherwise.
|
|
386
413
|
*/
|
|
387
414
|
function checkTrigger(component, trigger, row, data, form, instance) {
|
|
388
415
|
// If trigger is empty, don't fire it
|
|
@@ -402,6 +429,16 @@ function checkTrigger(component, trigger, row, data, form, instance) {
|
|
|
402
429
|
return false;
|
|
403
430
|
}
|
|
404
431
|
exports.checkTrigger = checkTrigger;
|
|
432
|
+
/**
|
|
433
|
+
* Sets a property on a component via an executed Logic action.
|
|
434
|
+
* @param {import('@formio/core').Component} component - The component to set the property on.
|
|
435
|
+
* @param {import('@formio/core').LogicAction} action - The action to perform on the component.
|
|
436
|
+
* @param {string} result - The name of the variable in the evaulation to use as the result.
|
|
437
|
+
* @param {import('@formio/core').DataObject} row - The contextual row data.
|
|
438
|
+
* @param {import('@formio/core').DataObject} data - The full submission data.
|
|
439
|
+
* @param {any} instance - The component instance.
|
|
440
|
+
* @returns {import('@formio/core').Component} - The modified component.
|
|
441
|
+
*/
|
|
405
442
|
function setActionProperty(component, action, result, row, data, instance) {
|
|
406
443
|
const property = action.property.value;
|
|
407
444
|
switch (action.property.type) {
|
|
@@ -424,7 +461,7 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
424
461
|
const currentValue = lodash_1.default.get(component, property, '');
|
|
425
462
|
const newValue = (instance && instance.interpolate)
|
|
426
463
|
? instance.interpolate(textValue, evalData)
|
|
427
|
-
: Evaluator_1.
|
|
464
|
+
: Evaluator_1.Evaluator.interpolate(textValue, evalData);
|
|
428
465
|
if (newValue !== currentValue) {
|
|
429
466
|
lodash_1.default.set(component, property, newValue);
|
|
430
467
|
}
|
|
@@ -436,8 +473,8 @@ function setActionProperty(component, action, result, row, data, instance) {
|
|
|
436
473
|
exports.setActionProperty = setActionProperty;
|
|
437
474
|
/**
|
|
438
475
|
* Unescape HTML characters like <, >, & and etc.
|
|
439
|
-
* @param str
|
|
440
|
-
* @returns {string}
|
|
476
|
+
* @param {string} str - The string to unescape.
|
|
477
|
+
* @returns {string} - The unescaped string.
|
|
441
478
|
*/
|
|
442
479
|
function unescapeHTML(str) {
|
|
443
480
|
if (typeof window === 'undefined' || !('DOMParser' in window)) {
|
|
@@ -449,9 +486,9 @@ function unescapeHTML(str) {
|
|
|
449
486
|
exports.unescapeHTML = unescapeHTML;
|
|
450
487
|
/**
|
|
451
488
|
* Make HTML element from string
|
|
452
|
-
* @param str
|
|
453
|
-
* @param selector
|
|
454
|
-
* @returns {HTMLElement}
|
|
489
|
+
* @param {string} str - The string to convert to an HTML element.
|
|
490
|
+
* @param {string} selector - The selector to use to get the element once it is created.
|
|
491
|
+
* @returns {HTMLElement} - The HTML element that was created.
|
|
455
492
|
*/
|
|
456
493
|
function convertStringToHTMLElement(str, selector) {
|
|
457
494
|
const doc = new window.DOMParser().parseFromString(str, 'text/html');
|
|
@@ -460,10 +497,10 @@ function convertStringToHTMLElement(str, selector) {
|
|
|
460
497
|
exports.convertStringToHTMLElement = convertStringToHTMLElement;
|
|
461
498
|
/**
|
|
462
499
|
* Make a filename guaranteed to be unique.
|
|
463
|
-
* @param name
|
|
464
|
-
* @param template
|
|
465
|
-
* @param evalContext
|
|
466
|
-
* @returns {string}
|
|
500
|
+
* @param {string} name - The original name of the file.
|
|
501
|
+
* @param {string} template - The template to use for the unique name.
|
|
502
|
+
* @param {object} evalContext - The context to use for the evaluation.
|
|
503
|
+
* @returns {string} - A unique filename.
|
|
467
504
|
*/
|
|
468
505
|
function uniqueName(name, template, evalContext) {
|
|
469
506
|
template = template || '{{fileName}}-{{guid}}';
|
|
@@ -483,10 +520,14 @@ function uniqueName(name, template, evalContext) {
|
|
|
483
520
|
guid: guid()
|
|
484
521
|
});
|
|
485
522
|
//only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash
|
|
486
|
-
const uniqueName = `${Evaluator_1.
|
|
523
|
+
const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\-_ ]/g, '-');
|
|
487
524
|
return uniqueName;
|
|
488
525
|
}
|
|
489
526
|
exports.uniqueName = uniqueName;
|
|
527
|
+
/**
|
|
528
|
+
* Returns a GUID
|
|
529
|
+
* @returns {string} - A GUID.
|
|
530
|
+
*/
|
|
490
531
|
function guid() {
|
|
491
532
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
492
533
|
const r = Math.random() * 16 | 0;
|
|
@@ -499,9 +540,8 @@ function guid() {
|
|
|
499
540
|
exports.guid = guid;
|
|
500
541
|
/**
|
|
501
542
|
* Return a translated date setting.
|
|
502
|
-
*
|
|
503
|
-
* @
|
|
504
|
-
* @return {(null|Date)}
|
|
543
|
+
* @param {string|Date} date - The date to translate.
|
|
544
|
+
* @returns {(null|Date)} - The translated date.
|
|
505
545
|
*/
|
|
506
546
|
function getDateSetting(date) {
|
|
507
547
|
if (lodash_1.default.isNil(date) || lodash_1.default.isNaN(date) || date === '') {
|
|
@@ -519,7 +559,7 @@ function getDateSetting(date) {
|
|
|
519
559
|
}
|
|
520
560
|
dateSetting = null;
|
|
521
561
|
try {
|
|
522
|
-
const value = Evaluator_1.
|
|
562
|
+
const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
|
|
523
563
|
if (typeof value === 'string') {
|
|
524
564
|
dateSetting = (0, moment_timezone_1.default)(value);
|
|
525
565
|
}
|
|
@@ -543,14 +583,18 @@ function getDateSetting(date) {
|
|
|
543
583
|
return dateSetting.toDate();
|
|
544
584
|
}
|
|
545
585
|
exports.getDateSetting = getDateSetting;
|
|
586
|
+
/**
|
|
587
|
+
* Returns true if the date is a valid date. False otherwise.
|
|
588
|
+
* @param {Date|string} date - The date to check for validity.
|
|
589
|
+
* @returns {boolean} - TRUE if the date is valid; FALSE otherwise.
|
|
590
|
+
*/
|
|
546
591
|
function isValidDate(date) {
|
|
547
592
|
return lodash_1.default.isDate(date) && !lodash_1.default.isNaN(date.getDate());
|
|
548
593
|
}
|
|
549
594
|
exports.isValidDate = isValidDate;
|
|
550
595
|
/**
|
|
551
596
|
* Get the current timezone string.
|
|
552
|
-
*
|
|
553
|
-
* @return {string}
|
|
597
|
+
* @returns {string} - The current timezone.
|
|
554
598
|
*/
|
|
555
599
|
function currentTimezone() {
|
|
556
600
|
if (moment_timezone_1.default.currentTimezone) {
|
|
@@ -562,10 +606,9 @@ function currentTimezone() {
|
|
|
562
606
|
exports.currentTimezone = currentTimezone;
|
|
563
607
|
/**
|
|
564
608
|
* Get an offset date provided a date object and timezone object.
|
|
565
|
-
*
|
|
566
|
-
* @param date
|
|
567
|
-
* @
|
|
568
|
-
* @return {Date}
|
|
609
|
+
* @param {Date} date - The date to offset.
|
|
610
|
+
* @param {string} timezone - The timezone to offset the date to.
|
|
611
|
+
* @returns {Date} - The offset date.
|
|
569
612
|
*/
|
|
570
613
|
function offsetDate(date, timezone) {
|
|
571
614
|
if (timezone === 'UTC') {
|
|
@@ -583,8 +626,7 @@ function offsetDate(date, timezone) {
|
|
|
583
626
|
exports.offsetDate = offsetDate;
|
|
584
627
|
/**
|
|
585
628
|
* Returns if the zones are loaded.
|
|
586
|
-
*
|
|
587
|
-
* @return {boolean}
|
|
629
|
+
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
|
588
630
|
*/
|
|
589
631
|
function zonesLoaded() {
|
|
590
632
|
return moment_timezone_1.default.zonesLoaded;
|
|
@@ -592,9 +634,8 @@ function zonesLoaded() {
|
|
|
592
634
|
exports.zonesLoaded = zonesLoaded;
|
|
593
635
|
/**
|
|
594
636
|
* Returns if we should load the zones.
|
|
595
|
-
*
|
|
596
|
-
* @
|
|
597
|
-
* @return {boolean}
|
|
637
|
+
* @param {string} timezone - The timezone to check if we should load the zones.
|
|
638
|
+
* @returns {boolean} - TRUE if we should load the zones; FALSE otherwise.
|
|
598
639
|
*/
|
|
599
640
|
function shouldLoadZones(timezone) {
|
|
600
641
|
if (timezone === currentTimezone() || timezone === 'UTC') {
|
|
@@ -605,8 +646,9 @@ function shouldLoadZones(timezone) {
|
|
|
605
646
|
exports.shouldLoadZones = shouldLoadZones;
|
|
606
647
|
/**
|
|
607
648
|
* Externally load the timezone data.
|
|
608
|
-
*
|
|
609
|
-
* @
|
|
649
|
+
* @param {string} url - The URL to load the timezone data from.
|
|
650
|
+
* @param {string} timezone - The timezone to load.
|
|
651
|
+
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
|
610
652
|
*/
|
|
611
653
|
function loadZones(url, timezone) {
|
|
612
654
|
if (timezone && !shouldLoadZones(timezone)) {
|
|
@@ -631,11 +673,10 @@ function loadZones(url, timezone) {
|
|
|
631
673
|
exports.loadZones = loadZones;
|
|
632
674
|
/**
|
|
633
675
|
* Get the moment date object for translating dates with timezones.
|
|
634
|
-
*
|
|
635
|
-
* @param
|
|
636
|
-
* @param
|
|
637
|
-
* @
|
|
638
|
-
* @return {*}
|
|
676
|
+
* @param {string|Date} value - The value to convert into a moment date.
|
|
677
|
+
* @param {string} format - The format to convert the date to.
|
|
678
|
+
* @param {string} timezone - The timezone to convert the date to.
|
|
679
|
+
* @returns {Date} - The moment date object.
|
|
639
680
|
*/
|
|
640
681
|
function momentDate(value, format, timezone) {
|
|
641
682
|
const momentDate = (0, moment_timezone_1.default)(value);
|
|
@@ -653,11 +694,12 @@ function momentDate(value, format, timezone) {
|
|
|
653
694
|
exports.momentDate = momentDate;
|
|
654
695
|
/**
|
|
655
696
|
* Format a date provided a value, format, and timezone object.
|
|
656
|
-
*
|
|
657
|
-
* @param value
|
|
658
|
-
* @param format
|
|
659
|
-
* @param timezone
|
|
660
|
-
* @
|
|
697
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
698
|
+
* @param {string|Date} value - The value to format.
|
|
699
|
+
* @param {string} format - The format to format the date to.
|
|
700
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
701
|
+
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
|
702
|
+
* @returns {string} - The formatted date.
|
|
661
703
|
*/
|
|
662
704
|
function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat) {
|
|
663
705
|
const momentDate = (0, moment_timezone_1.default)(value, flatPickrInputFormat || undefined);
|
|
@@ -691,12 +733,12 @@ function formatDate(timezonesUrl, value, format, timezone, flatPickrInputFormat)
|
|
|
691
733
|
exports.formatDate = formatDate;
|
|
692
734
|
/**
|
|
693
735
|
* Pass a format function to format within a timezone.
|
|
694
|
-
*
|
|
695
|
-
* @param formatFn
|
|
696
|
-
* @param date
|
|
697
|
-
* @param format
|
|
698
|
-
* @param timezone
|
|
699
|
-
* @
|
|
736
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
|
737
|
+
* @param {Function} formatFn - The format function to use.
|
|
738
|
+
* @param {Date|string} date - The date to format.
|
|
739
|
+
* @param {string} format - The format to format the date to.
|
|
740
|
+
* @param {string} timezone - The timezone to format the date to.
|
|
741
|
+
* @returns {string} - The formatted date.
|
|
700
742
|
*/
|
|
701
743
|
function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
702
744
|
if (timezone === currentTimezone()) {
|
|
@@ -716,6 +758,11 @@ function formatOffset(timezonesUrl, formatFn, date, format, timezone) {
|
|
|
716
758
|
}
|
|
717
759
|
}
|
|
718
760
|
exports.formatOffset = formatOffset;
|
|
761
|
+
/**
|
|
762
|
+
* Returns the local date format information.
|
|
763
|
+
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
|
764
|
+
* @returns {object} - The local date format information.
|
|
765
|
+
*/
|
|
719
766
|
function getLocaleDateFormatInfo(locale) {
|
|
720
767
|
const formatInfo = {};
|
|
721
768
|
const day = 21;
|
|
@@ -727,8 +774,8 @@ function getLocaleDateFormatInfo(locale) {
|
|
|
727
774
|
exports.getLocaleDateFormatInfo = getLocaleDateFormatInfo;
|
|
728
775
|
/**
|
|
729
776
|
* Convert the format from the angular-datepicker module to flatpickr format.
|
|
730
|
-
* @param format
|
|
731
|
-
* @
|
|
777
|
+
* @param {string} format - The format to convert.
|
|
778
|
+
* @returns {string} - The converted format.
|
|
732
779
|
*/
|
|
733
780
|
function convertFormatToFlatpickr(format) {
|
|
734
781
|
return format
|
|
@@ -759,8 +806,8 @@ function convertFormatToFlatpickr(format) {
|
|
|
759
806
|
exports.convertFormatToFlatpickr = convertFormatToFlatpickr;
|
|
760
807
|
/**
|
|
761
808
|
* Convert the format from the angular-datepicker module to moment format.
|
|
762
|
-
* @param format
|
|
763
|
-
* @
|
|
809
|
+
* @param {string} format - The format to convert.
|
|
810
|
+
* @returns {string} - The converted format.
|
|
764
811
|
*/
|
|
765
812
|
function convertFormatToMoment(format) {
|
|
766
813
|
return format
|
|
@@ -776,6 +823,11 @@ function convertFormatToMoment(format) {
|
|
|
776
823
|
.replace(/U/g, 'X');
|
|
777
824
|
}
|
|
778
825
|
exports.convertFormatToMoment = convertFormatToMoment;
|
|
826
|
+
/**
|
|
827
|
+
* Convert the format from the angular-datepicker module to mask format.
|
|
828
|
+
* @param {string} format - The format to convert.
|
|
829
|
+
* @returns {string} - The converted format.
|
|
830
|
+
*/
|
|
779
831
|
function convertFormatToMask(format) {
|
|
780
832
|
return format
|
|
781
833
|
// Long month replacement.
|
|
@@ -835,6 +887,13 @@ function getInputMask(mask, placeholderChar) {
|
|
|
835
887
|
return maskArray;
|
|
836
888
|
}
|
|
837
889
|
exports.getInputMask = getInputMask;
|
|
890
|
+
/**
|
|
891
|
+
* Unmasks a value using the provided mask and placeholder characters.
|
|
892
|
+
* @param {string} value - The value to unmask.
|
|
893
|
+
* @param {string} mask - The mask to use for unmasking.
|
|
894
|
+
* @param {string} placeholderChar - The placeholder character to use for unmasking.
|
|
895
|
+
* @returns {string} - The unmasked value.
|
|
896
|
+
*/
|
|
838
897
|
function unmaskValue(value, mask, placeholderChar) {
|
|
839
898
|
if (!mask || !value || value.length > mask.length) {
|
|
840
899
|
return value;
|
|
@@ -851,6 +910,12 @@ function unmaskValue(value, mask, placeholderChar) {
|
|
|
851
910
|
return unmaskedValue;
|
|
852
911
|
}
|
|
853
912
|
exports.unmaskValue = unmaskValue;
|
|
913
|
+
/**
|
|
914
|
+
* Returns true if the value matches the input mask format.
|
|
915
|
+
* @param {string} value - The value to check.
|
|
916
|
+
* @param {string} inputMask - The input mask to check against.
|
|
917
|
+
* @returns {boolean} - TRUE if the value matches the input mask; FALSE otherwise.
|
|
918
|
+
*/
|
|
854
919
|
function matchInputMask(value, inputMask) {
|
|
855
920
|
if (!inputMask) {
|
|
856
921
|
return true;
|
|
@@ -869,6 +934,11 @@ function matchInputMask(value, inputMask) {
|
|
|
869
934
|
return true;
|
|
870
935
|
}
|
|
871
936
|
exports.matchInputMask = matchInputMask;
|
|
937
|
+
/**
|
|
938
|
+
* Returns the number separators (i.e. 1,000) for the provided language.
|
|
939
|
+
* @param {string} lang - The language code to get the number separators for.
|
|
940
|
+
* @returns {{delimiter: string, decimalSeparator: string}} - The number separators.
|
|
941
|
+
*/
|
|
872
942
|
function getNumberSeparators(lang = 'en') {
|
|
873
943
|
const formattedNumberString = (12345.6789).toLocaleString(lang);
|
|
874
944
|
const delimeters = formattedNumberString.match(/..(.)...(.)../);
|
|
@@ -884,6 +954,12 @@ function getNumberSeparators(lang = 'en') {
|
|
|
884
954
|
};
|
|
885
955
|
}
|
|
886
956
|
exports.getNumberSeparators = getNumberSeparators;
|
|
957
|
+
/**
|
|
958
|
+
* Returns the number for the maximum amount of decimal places for a number.
|
|
959
|
+
* @param {import('@formio/core').Component} component - The component to check for decimal limits.
|
|
960
|
+
* @param {number} defaultLimit - The default limit to use if none is provided in the component.
|
|
961
|
+
* @returns {number} - The number of decimal places allowed.
|
|
962
|
+
*/
|
|
887
963
|
function getNumberDecimalLimit(component, defaultLimit) {
|
|
888
964
|
if (lodash_1.default.has(component, 'decimalLimit')) {
|
|
889
965
|
return lodash_1.default.get(component, 'decimalLimit');
|
|
@@ -900,6 +976,15 @@ function getNumberDecimalLimit(component, defaultLimit) {
|
|
|
900
976
|
return decimalLimit;
|
|
901
977
|
}
|
|
902
978
|
exports.getNumberDecimalLimit = getNumberDecimalLimit;
|
|
979
|
+
/**
|
|
980
|
+
* Returns the currency affixes for a specific language.
|
|
981
|
+
* @param {object} arg0 - The arguments object.
|
|
982
|
+
* @param {string} arg0.currency - The currency code to get the affixes for.
|
|
983
|
+
* @param {number} arg0.decimalLimit - The number of decimal places to use.
|
|
984
|
+
* @param {string} arg0.decimalSeparator - The decimal separator to use.
|
|
985
|
+
* @param {string} arg0.lang - The language code to use.
|
|
986
|
+
* @returns {{prefix: string, suffix: string}} - The currency affixes.
|
|
987
|
+
*/
|
|
903
988
|
function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, }) {
|
|
904
989
|
// Get the prefix and suffix from the localized string.
|
|
905
990
|
let regex = `(.*)?${(100).toLocaleString(lang)}`;
|
|
@@ -922,10 +1007,9 @@ function getCurrencyAffixes({ currency, decimalLimit, decimalSeparator, lang, })
|
|
|
922
1007
|
exports.getCurrencyAffixes = getCurrencyAffixes;
|
|
923
1008
|
/**
|
|
924
1009
|
* Fetch the field data provided a component.
|
|
925
|
-
*
|
|
926
|
-
* @param data
|
|
927
|
-
* @
|
|
928
|
-
* @return {*}
|
|
1010
|
+
* @param {import('@formio/core').DataObject} data - The data object to fetch the field data from.
|
|
1011
|
+
* @param {import('@formio/core').Component} component - The component to fetch the field data for.
|
|
1012
|
+
* @returns {*} - The field data.
|
|
929
1013
|
*/
|
|
930
1014
|
function fieldData(data, component) {
|
|
931
1015
|
if (!data) {
|
|
@@ -972,16 +1056,23 @@ function fieldData(data, component) {
|
|
|
972
1056
|
exports.fieldData = fieldData;
|
|
973
1057
|
/**
|
|
974
1058
|
* Delays function execution with possibility to execute function synchronously or cancel it.
|
|
975
|
-
*
|
|
976
|
-
* @param
|
|
977
|
-
* @param
|
|
978
|
-
* @
|
|
1059
|
+
* @param {Function} fn - Function to delay
|
|
1060
|
+
* @param {number} delay - Delay time
|
|
1061
|
+
* @param {...any} args - Arguments to pass to the function
|
|
1062
|
+
* @returns {*} - Function to cancel the delay
|
|
979
1063
|
*/
|
|
980
1064
|
function delay(fn, delay = 0, ...args) {
|
|
981
1065
|
const timer = setTimeout(fn, delay, ...args);
|
|
1066
|
+
/**
|
|
1067
|
+
*
|
|
1068
|
+
*/
|
|
982
1069
|
function cancel() {
|
|
983
1070
|
clearTimeout(timer);
|
|
984
1071
|
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Execute the function early.
|
|
1074
|
+
* @returns {*} - The result of the function.
|
|
1075
|
+
*/
|
|
985
1076
|
function earlyCall() {
|
|
986
1077
|
cancel();
|
|
987
1078
|
return fn(...args);
|
|
@@ -993,11 +1084,9 @@ function delay(fn, delay = 0, ...args) {
|
|
|
993
1084
|
exports.delay = delay;
|
|
994
1085
|
/**
|
|
995
1086
|
* Iterate the given key to make it unique.
|
|
996
|
-
*
|
|
997
|
-
* @param {String} key
|
|
1087
|
+
* @param {string} key
|
|
998
1088
|
* Modify the component key to be unique.
|
|
999
|
-
*
|
|
1000
|
-
* @returns {String}
|
|
1089
|
+
* @returns {string}
|
|
1001
1090
|
* The new component key.
|
|
1002
1091
|
*/
|
|
1003
1092
|
function iterateKey(key) {
|
|
@@ -1011,10 +1100,9 @@ function iterateKey(key) {
|
|
|
1011
1100
|
exports.iterateKey = iterateKey;
|
|
1012
1101
|
/**
|
|
1013
1102
|
* Determines a unique key within a map provided the base key.
|
|
1014
|
-
*
|
|
1015
|
-
* @param
|
|
1016
|
-
* @
|
|
1017
|
-
* @return {*}
|
|
1103
|
+
* @param {Record<string, string>} map - The map to check for uniqueness.
|
|
1104
|
+
* @param {string} base - The base path of the key.
|
|
1105
|
+
* @returns {string} - The unique key.
|
|
1018
1106
|
*/
|
|
1019
1107
|
function uniqueKey(map, base) {
|
|
1020
1108
|
let newKey = base;
|
|
@@ -1026,8 +1114,9 @@ function uniqueKey(map, base) {
|
|
|
1026
1114
|
exports.uniqueKey = uniqueKey;
|
|
1027
1115
|
/**
|
|
1028
1116
|
* Determines the major version number of bootstrap.
|
|
1029
|
-
*
|
|
1030
|
-
* @
|
|
1117
|
+
* @param {object} options - The options to check for bootstrap version.
|
|
1118
|
+
* @param {string} options.bootstrap - The bootstrap version to use.
|
|
1119
|
+
* @returns {number} - The bootstrap version.
|
|
1031
1120
|
*/
|
|
1032
1121
|
function bootstrapVersion(options) {
|
|
1033
1122
|
if (options.bootstrap) {
|
|
@@ -1045,9 +1134,8 @@ exports.bootstrapVersion = bootstrapVersion;
|
|
|
1045
1134
|
/**
|
|
1046
1135
|
* Retrun provided argument.
|
|
1047
1136
|
* If argument is a function, returns the result of a function call.
|
|
1048
|
-
* @param {
|
|
1049
|
-
*
|
|
1050
|
-
* @return {*}
|
|
1137
|
+
* @param {Function|any} e - The argument to check if a function and call if so.
|
|
1138
|
+
* @returns {any} - Either the result of the function call (e) or e if it is not a function.
|
|
1051
1139
|
*/
|
|
1052
1140
|
function unfold(e) {
|
|
1053
1141
|
if (typeof e === 'function') {
|
|
@@ -1058,27 +1146,32 @@ function unfold(e) {
|
|
|
1058
1146
|
exports.unfold = unfold;
|
|
1059
1147
|
/**
|
|
1060
1148
|
* Map values through unfold and return first non-nil value.
|
|
1061
|
-
* @param {Array<T>} collection
|
|
1062
|
-
*
|
|
1063
|
-
* @return {T}
|
|
1149
|
+
* @param {Array<T>} collection - The collection to map through unfold.;
|
|
1150
|
+
* @returns {T} - The first non-nil value.
|
|
1064
1151
|
*/
|
|
1065
1152
|
exports.firstNonNil = lodash_1.default.flow([
|
|
1066
1153
|
lodash_1.default.partialRight(lodash_1.default.map, unfold),
|
|
1067
1154
|
lodash_1.default.partialRight(lodash_1.default.find, v => !lodash_1.default.isUndefined(v))
|
|
1068
1155
|
]);
|
|
1069
|
-
|
|
1070
|
-
* Create enclosed state.
|
|
1071
|
-
* Returns functions to getting and cycling between states.
|
|
1156
|
+
/**
|
|
1157
|
+
* Create enclosed state. Returns functions to getting and cycling between states.
|
|
1072
1158
|
* @param {*} a - initial state.
|
|
1073
1159
|
* @param {*} b - next state.
|
|
1074
|
-
* @
|
|
1160
|
+
* @returns {Functions[]} -- [get, toggle];
|
|
1075
1161
|
*/
|
|
1076
1162
|
function withSwitch(a, b) {
|
|
1077
1163
|
let state = a;
|
|
1078
1164
|
let next = b;
|
|
1165
|
+
/**
|
|
1166
|
+
* Returns the state of the switch.
|
|
1167
|
+
* @returns {*} - The current state.
|
|
1168
|
+
*/
|
|
1079
1169
|
function get() {
|
|
1080
1170
|
return state;
|
|
1081
1171
|
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Toggles the state of the switch.
|
|
1174
|
+
*/
|
|
1082
1175
|
function toggle() {
|
|
1083
1176
|
const prev = state;
|
|
1084
1177
|
state = next;
|
|
@@ -1087,6 +1180,14 @@ function withSwitch(a, b) {
|
|
|
1087
1180
|
return [get, toggle];
|
|
1088
1181
|
}
|
|
1089
1182
|
exports.withSwitch = withSwitch;
|
|
1183
|
+
/**
|
|
1184
|
+
* Create a function that will call the provided function only the provided limit.
|
|
1185
|
+
* @param {Function} callback - The callback to call.
|
|
1186
|
+
* @param {object} options - The options to use.
|
|
1187
|
+
* @param {number} options.limit - The limit to call the callback.
|
|
1188
|
+
* @param {number} options.delay - The delay to wait before resetting the call count.
|
|
1189
|
+
* @returns {Function} - The function that will call the callback only the provided limit.
|
|
1190
|
+
*/
|
|
1090
1191
|
function observeOverload(callback, options = {}) {
|
|
1091
1192
|
const { limit = 50, delay = 500 } = options;
|
|
1092
1193
|
let callCount = 0;
|
|
@@ -1107,6 +1208,13 @@ function observeOverload(callback, options = {}) {
|
|
|
1107
1208
|
};
|
|
1108
1209
|
}
|
|
1109
1210
|
exports.observeOverload = observeOverload;
|
|
1211
|
+
/**
|
|
1212
|
+
* Returns the components that are provided within an evaluation context.
|
|
1213
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1214
|
+
* @param {boolean} excludeNested - Exclude nested components.
|
|
1215
|
+
* @param {Array<string>} excludedTypes - The types of components to exclude.
|
|
1216
|
+
* @returns {Array} - The components within the evaluation context.
|
|
1217
|
+
*/
|
|
1110
1218
|
function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
1111
1219
|
const values = [];
|
|
1112
1220
|
context.utils.eachComponent(context.instance.options.editForm.components, (component, path) => {
|
|
@@ -1121,6 +1229,11 @@ function getContextComponents(context, excludeNested, excludedTypes = []) {
|
|
|
1121
1229
|
return values;
|
|
1122
1230
|
}
|
|
1123
1231
|
exports.getContextComponents = getContextComponents;
|
|
1232
|
+
/**
|
|
1233
|
+
* Returns the button components that are within an evaluation context.
|
|
1234
|
+
* @param {any} context - The evaluation context to get the components from.
|
|
1235
|
+
* @returns {Array} - The button components within the evaluation context.
|
|
1236
|
+
*/
|
|
1124
1237
|
function getContextButtons(context) {
|
|
1125
1238
|
const values = [];
|
|
1126
1239
|
context.utils.eachComponent(context.instance.options.editForm.components, (component) => {
|
|
@@ -1138,18 +1251,15 @@ exports.getContextButtons = getContextButtons;
|
|
|
1138
1251
|
const inTextTags = ['#text', 'A', 'B', 'EM', 'I', 'SMALL', 'STRONG', 'SUB', 'SUP', 'INS', 'DEL', 'MARK', 'CODE'];
|
|
1139
1252
|
/**
|
|
1140
1253
|
* Helper function for 'translateHTMLTemplate'. Translates text value of the passed html element.
|
|
1141
|
-
*
|
|
1142
|
-
* @param {
|
|
1143
|
-
* @
|
|
1144
|
-
*
|
|
1145
|
-
* @returns {String}
|
|
1146
|
-
* Translated element template.
|
|
1254
|
+
* @param {HTMLElement} elem - The element to translate.
|
|
1255
|
+
* @param {Function} translate - The translation function.
|
|
1256
|
+
* @returns {string} - Translated element template.
|
|
1147
1257
|
*/
|
|
1148
1258
|
function translateElemValue(elem, translate) {
|
|
1149
1259
|
if (!elem.innerText) {
|
|
1150
1260
|
return elem.innerHTML;
|
|
1151
1261
|
}
|
|
1152
|
-
const elemValue = elem.innerText.replace(Evaluator_1.
|
|
1262
|
+
const elemValue = elem.innerText.replace(Evaluator_1.Evaluator.templateSettings.interpolate, '').replace(/\s\s+/g, ' ').trim();
|
|
1153
1263
|
const translatedValue = translate(elemValue);
|
|
1154
1264
|
if (elemValue !== translatedValue) {
|
|
1155
1265
|
const links = elem.innerHTML.match(/<a[^>]*>(.*?)<\/a>/g);
|
|
@@ -1174,10 +1284,8 @@ function translateElemValue(elem, translate) {
|
|
|
1174
1284
|
}
|
|
1175
1285
|
/**
|
|
1176
1286
|
* 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
|
-
*
|
|
1287
|
+
* @param {HTMLElement} tag - The tag to translate.
|
|
1288
|
+
* @param {Function} translate - The translation function.
|
|
1181
1289
|
* @returns {void}
|
|
1182
1290
|
*/
|
|
1183
1291
|
function translateDeepTag(tag, translate) {
|
|
@@ -1193,12 +1301,9 @@ function translateDeepTag(tag, translate) {
|
|
|
1193
1301
|
}
|
|
1194
1302
|
/**
|
|
1195
1303
|
* Translates text values in html template.
|
|
1196
|
-
*
|
|
1197
|
-
* @param {
|
|
1198
|
-
* @
|
|
1199
|
-
*
|
|
1200
|
-
* @returns {String}
|
|
1201
|
-
* Html template with translated values.
|
|
1304
|
+
* @param {string} template - The template to translate.
|
|
1305
|
+
* @param {Function} translate - The translation function.
|
|
1306
|
+
* @returns {string} - Html template with translated values.
|
|
1202
1307
|
*/
|
|
1203
1308
|
function translateHTMLTemplate(template, translate) {
|
|
1204
1309
|
const isHTML = /<[^>]*>/.test(template);
|
|
@@ -1216,9 +1321,9 @@ function translateHTMLTemplate(template, translate) {
|
|
|
1216
1321
|
exports.translateHTMLTemplate = translateHTMLTemplate;
|
|
1217
1322
|
/**
|
|
1218
1323
|
* Sanitize an html string.
|
|
1219
|
-
*
|
|
1220
|
-
* @param
|
|
1221
|
-
* @returns {
|
|
1324
|
+
* @param {string} string - The string to sanitize.
|
|
1325
|
+
* @param {any} options - The options to use for sanitization.
|
|
1326
|
+
* @returns {string} - The sanitized html string.
|
|
1222
1327
|
*/
|
|
1223
1328
|
function sanitize(string, options) {
|
|
1224
1329
|
if (typeof dompurify_1.default.sanitize !== 'function') {
|
|
@@ -1267,11 +1372,18 @@ function sanitize(string, options) {
|
|
|
1267
1372
|
exports.sanitize = sanitize;
|
|
1268
1373
|
/**
|
|
1269
1374
|
* Fast cloneDeep for JSON objects only.
|
|
1375
|
+
* @param {any} obj - The object to perform a fast clone deep against.
|
|
1376
|
+
* @returns {any} - The cloned object.
|
|
1270
1377
|
*/
|
|
1271
1378
|
function fastCloneDeep(obj) {
|
|
1272
1379
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
|
1273
1380
|
}
|
|
1274
1381
|
exports.fastCloneDeep = fastCloneDeep;
|
|
1382
|
+
/**
|
|
1383
|
+
* Returns if the component is an input component.
|
|
1384
|
+
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
|
1385
|
+
* @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
|
|
1386
|
+
*/
|
|
1275
1387
|
function isInputComponent(componentJson) {
|
|
1276
1388
|
if (componentJson.input === false || componentJson.input === true) {
|
|
1277
1389
|
return componentJson.input;
|
|
@@ -1292,6 +1404,11 @@ function isInputComponent(componentJson) {
|
|
|
1292
1404
|
}
|
|
1293
1405
|
}
|
|
1294
1406
|
exports.isInputComponent = isInputComponent;
|
|
1407
|
+
/**
|
|
1408
|
+
* Takes a component path, and returns a component path array.
|
|
1409
|
+
* @param {string} pathStr - The path string to convert to an array.
|
|
1410
|
+
* @returns {Arryay<number>} - The array of paths.
|
|
1411
|
+
*/
|
|
1295
1412
|
function getArrayFromComponentPath(pathStr) {
|
|
1296
1413
|
if (!pathStr || !lodash_1.default.isString(pathStr)) {
|
|
1297
1414
|
if (!lodash_1.default.isArray(pathStr)) {
|
|
@@ -1306,6 +1423,12 @@ function getArrayFromComponentPath(pathStr) {
|
|
|
1306
1423
|
.map(part => lodash_1.default.defaultTo(lodash_1.default.toNumber(part), part));
|
|
1307
1424
|
}
|
|
1308
1425
|
exports.getArrayFromComponentPath = getArrayFromComponentPath;
|
|
1426
|
+
/**
|
|
1427
|
+
* Returns true if the component is a child of the parent.
|
|
1428
|
+
* @param {any} child - The child component to check.
|
|
1429
|
+
* @param {any} parent - The parent component to check.
|
|
1430
|
+
* @returns {boolean} - TRUE if the child is a child of the parent; FALSE otherwise.
|
|
1431
|
+
*/
|
|
1309
1432
|
function isChildOf(child, parent) {
|
|
1310
1433
|
while (child && child.parent) {
|
|
1311
1434
|
if (child.parent === parent) {
|
|
@@ -1316,6 +1439,11 @@ function isChildOf(child, parent) {
|
|
|
1316
1439
|
return false;
|
|
1317
1440
|
}
|
|
1318
1441
|
exports.isChildOf = isChildOf;
|
|
1442
|
+
/**
|
|
1443
|
+
* Takes an array of component path indexes, and returns a string version of that array.
|
|
1444
|
+
* @param {Array<number>} path - The path array to convert to a string.
|
|
1445
|
+
* @returns {string} - The string version of the path.
|
|
1446
|
+
*/
|
|
1319
1447
|
function getStringFromComponentPath(path) {
|
|
1320
1448
|
if (!lodash_1.default.isArray(path)) {
|
|
1321
1449
|
return path;
|
|
@@ -1332,17 +1460,22 @@ function getStringFromComponentPath(path) {
|
|
|
1332
1460
|
return strPath;
|
|
1333
1461
|
}
|
|
1334
1462
|
exports.getStringFromComponentPath = getStringFromComponentPath;
|
|
1463
|
+
/**
|
|
1464
|
+
* Takes a number and rounds it to the provided precision amount.
|
|
1465
|
+
* @param {number} number - The number to round.
|
|
1466
|
+
* @param {number} precision - The precision to round the number to.
|
|
1467
|
+
* @returns {string} - The rounded number.
|
|
1468
|
+
*/
|
|
1335
1469
|
function round(number, precision) {
|
|
1336
1470
|
if (lodash_1.default.isNumber(number)) {
|
|
1337
1471
|
return number.toFixed(precision);
|
|
1338
1472
|
}
|
|
1339
|
-
return number;
|
|
1473
|
+
return number.toString();
|
|
1340
1474
|
}
|
|
1341
1475
|
exports.round = round;
|
|
1342
1476
|
/**
|
|
1343
1477
|
* Check for Internet Explorer browser version
|
|
1344
|
-
*
|
|
1345
|
-
* @return {(number|null)}
|
|
1478
|
+
* @returns {(number|null)} - The IE browser version or null if not IE
|
|
1346
1479
|
*/
|
|
1347
1480
|
function getIEBrowserVersion() {
|
|
1348
1481
|
const { ie, version } = getBrowserInfo();
|
|
@@ -1351,8 +1484,7 @@ function getIEBrowserVersion() {
|
|
|
1351
1484
|
exports.getIEBrowserVersion = getIEBrowserVersion;
|
|
1352
1485
|
/**
|
|
1353
1486
|
* Get browser name and version (modified from 'jquery-browser-plugin')
|
|
1354
|
-
*
|
|
1355
|
-
* @return {Object} -- {{browser name, version, isWebkit?}}
|
|
1487
|
+
* @returns {object} -- {{browser name, version, isWebkit?}}
|
|
1356
1488
|
* Possible browser names: chrome, safari, ie, edge, opera, mozilla, yabrowser
|
|
1357
1489
|
*/
|
|
1358
1490
|
function getBrowserInfo() {
|
|
@@ -1401,13 +1533,20 @@ function getBrowserInfo() {
|
|
|
1401
1533
|
return browser;
|
|
1402
1534
|
}
|
|
1403
1535
|
exports.getBrowserInfo = getBrowserInfo;
|
|
1536
|
+
/**
|
|
1537
|
+
* Takes a component path, which may include array indicies (i.e. [0][1]), and returns the compoennt path without the indicies.
|
|
1538
|
+
* @param {string} path - The path to remove the indicies from.
|
|
1539
|
+
* @returns {string} - The path without the indicies.
|
|
1540
|
+
*/
|
|
1404
1541
|
function getComponentPathWithoutIndicies(path = '') {
|
|
1405
1542
|
return path.replace(/\[\d+\]/, '');
|
|
1406
1543
|
}
|
|
1407
1544
|
exports.getComponentPathWithoutIndicies = getComponentPathWithoutIndicies;
|
|
1408
1545
|
/**
|
|
1409
1546
|
* Returns a path to the component which based on its schema
|
|
1410
|
-
* @param {
|
|
1547
|
+
* @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
|
|
1548
|
+
* @param {string} path - Path to the component
|
|
1549
|
+
* @returns {string} - Path to the component
|
|
1411
1550
|
*/
|
|
1412
1551
|
function getComponentPath(component, path = '') {
|
|
1413
1552
|
var _a;
|
|
@@ -1420,8 +1559,8 @@ function getComponentPath(component, path = '') {
|
|
|
1420
1559
|
exports.getComponentPath = getComponentPath;
|
|
1421
1560
|
/**
|
|
1422
1561
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
1423
|
-
* @param {
|
|
1424
|
-
* @
|
|
1562
|
+
* @param {Component} componentInstance - The component to check for the parent.
|
|
1563
|
+
* @returns {Component|undefined} - The parent data component.
|
|
1425
1564
|
*/
|
|
1426
1565
|
function getDataParentComponent(componentInstance) {
|
|
1427
1566
|
if (!componentInstance) {
|
|
@@ -1438,8 +1577,8 @@ function getDataParentComponent(componentInstance) {
|
|
|
1438
1577
|
exports.getDataParentComponent = getDataParentComponent;
|
|
1439
1578
|
/**
|
|
1440
1579
|
* Returns whether the value is a promise
|
|
1441
|
-
* @param value
|
|
1442
|
-
* @
|
|
1580
|
+
* @param {any} value - The value to check
|
|
1581
|
+
* @returns {boolean} - TRUE if the value is a promise; FALSE otherwise
|
|
1443
1582
|
*/
|
|
1444
1583
|
function isPromise(value) {
|
|
1445
1584
|
return value
|
|
@@ -1451,9 +1590,9 @@ exports.isPromise = isPromise;
|
|
|
1451
1590
|
/**
|
|
1452
1591
|
* Determines if the component has a scoping parent in tree (a component which scopes its children and manages its
|
|
1453
1592
|
* changes by itself, e.g. EditGrid)
|
|
1454
|
-
* @param componentInstance
|
|
1455
|
-
* @param firstPass
|
|
1456
|
-
* @returns {boolean
|
|
1593
|
+
* @param {Component} componentInstance - The component to check for the scoping parent.
|
|
1594
|
+
* @param {boolean} firstPass - Whether it is the first pass of the function
|
|
1595
|
+
* @returns {boolean|*} - TRUE if the component has a scoping parent; FALSE otherwise
|
|
1457
1596
|
*/
|
|
1458
1597
|
function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
1459
1598
|
if (!firstPass && (componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.hasScopedChildren)) {
|
|
@@ -1469,6 +1608,11 @@ function isInsideScopingComponent(componentInstance, firstPass = true) {
|
|
|
1469
1608
|
return false;
|
|
1470
1609
|
}
|
|
1471
1610
|
exports.isInsideScopingComponent = isInsideScopingComponent;
|
|
1611
|
+
/**
|
|
1612
|
+
* Returns all the focusable elements within the provided dom element.
|
|
1613
|
+
* @param {HTMLElement} element - The element to get the focusable elements from.
|
|
1614
|
+
* @returns {NodeList<HTMLElement>} - The focusable elements within the provided element.
|
|
1615
|
+
*/
|
|
1472
1616
|
function getFocusableElements(element) {
|
|
1473
1617
|
const focusableSelector = `button:not([disabled]), input:not([disabled]), select:not([disabled]),
|
|
1474
1618
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
|
@@ -1484,6 +1628,11 @@ exports.componentValueTypes = {
|
|
|
1484
1628
|
date: 'date',
|
|
1485
1629
|
any: 'any',
|
|
1486
1630
|
};
|
|
1631
|
+
/**
|
|
1632
|
+
* Returns the saved types for the component
|
|
1633
|
+
* @param {import('@formio/core').Component} fullSchema - The component schema
|
|
1634
|
+
* @returns {Array<string>|null} - The saved types for the component
|
|
1635
|
+
*/
|
|
1487
1636
|
function getComponentSavedTypes(fullSchema) {
|
|
1488
1637
|
const schema = fullSchema || {};
|
|
1489
1638
|
if (schema.persistent !== true) {
|
|
@@ -1497,9 +1646,10 @@ function getComponentSavedTypes(fullSchema) {
|
|
|
1497
1646
|
exports.getComponentSavedTypes = getComponentSavedTypes;
|
|
1498
1647
|
/**
|
|
1499
1648
|
* Interpolates @formio/core errors so that they are compatible with the renderer
|
|
1500
|
-
* @param {
|
|
1501
|
-
* @param
|
|
1502
|
-
* @
|
|
1649
|
+
* @param {Component} component - The component to interpolate the errors for
|
|
1650
|
+
* @param {FieldError[]} errors - The errors to interpolate
|
|
1651
|
+
* @param {Function} interpolateFn - The interpolation function
|
|
1652
|
+
* @returns {[]} - The interpolated errors
|
|
1503
1653
|
*/
|
|
1504
1654
|
const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1505
1655
|
return errors.map((error) => {
|
|
@@ -1510,6 +1660,11 @@ const interpolateErrors = (component, errors, interpolateFn) => {
|
|
|
1510
1660
|
});
|
|
1511
1661
|
};
|
|
1512
1662
|
exports.interpolateErrors = interpolateErrors;
|
|
1663
|
+
/**
|
|
1664
|
+
* Returns the template keys inside the template code.
|
|
1665
|
+
* @param {string} template - The template to get the keys from.
|
|
1666
|
+
* @returns {Array<string>} - The keys inside the template.
|
|
1667
|
+
*/
|
|
1513
1668
|
function getItemTemplateKeys(template) {
|
|
1514
1669
|
const templateKeys = [];
|
|
1515
1670
|
if (!template) {
|
|
@@ -1527,6 +1682,11 @@ function getItemTemplateKeys(template) {
|
|
|
1527
1682
|
return templateKeys;
|
|
1528
1683
|
}
|
|
1529
1684
|
exports.getItemTemplateKeys = getItemTemplateKeys;
|
|
1685
|
+
/**
|
|
1686
|
+
* Returns if the component is a select resource with an object for its value.
|
|
1687
|
+
* @param {import('@formio/core').Component} comp - The component to check.
|
|
1688
|
+
* @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.
|
|
1689
|
+
*/
|
|
1530
1690
|
function isSelectResourceWithObjectValue(comp = {}) {
|
|
1531
1691
|
const { reference, dataSrc, valueProperty } = comp;
|
|
1532
1692
|
return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));
|