@formio/js 5.2.4-rc.0 → 5.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.builder.css +50 -161
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +49 -158
- package/dist/formio.form.js +108 -152
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.css +50 -161
- package/dist/formio.full.js +227 -401
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +18 -51
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +14 -47
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/CDN.js +12 -12
- package/lib/cjs/Element.d.ts +2 -3
- package/lib/cjs/Element.js +26 -29
- package/lib/cjs/Embed.js +42 -75
- package/lib/cjs/EventEmitter.js +1 -1
- package/lib/cjs/Form.d.ts +341 -371
- package/lib/cjs/Form.js +39 -153
- package/lib/cjs/FormBuilder.d.ts +3 -3
- package/lib/cjs/FormBuilder.js +3 -2
- package/lib/cjs/Formio.js +23 -26
- package/lib/cjs/InlineEmbed.js +17 -23
- package/lib/cjs/PDF.d.ts +0 -1
- package/lib/cjs/PDF.js +15 -18
- package/lib/cjs/PDFBuilder.js +36 -51
- package/lib/cjs/Webform.d.ts +366 -8
- package/lib/cjs/Webform.js +238 -177
- package/lib/cjs/WebformBuilder.js +152 -221
- package/lib/cjs/Wizard.js +65 -95
- package/lib/cjs/WizardBuilder.js +19 -27
- package/lib/cjs/addons/FormioAddon.js +1 -1
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +57 -59
- package/lib/cjs/addons/PasswordStrength/PasswordStrengthAddon.js +16 -24
- package/lib/cjs/addons/index.js +3 -3
- package/lib/cjs/components/Components.js +4 -0
- package/lib/cjs/components/_classes/component/Component.form.js +11 -11
- package/lib/cjs/components/_classes/component/Component.js +198 -309
- package/lib/cjs/components/_classes/component/editForm/Component.edit.addons.js +4 -2
- package/lib/cjs/components/_classes/component/editForm/Component.edit.api.js +5 -5
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +11 -9
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +25 -39
- package/lib/cjs/components/_classes/component/editForm/Component.edit.display.js +29 -47
- package/lib/cjs/components/_classes/component/editForm/Component.edit.layout.js +9 -9
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +7 -5
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +34 -37
- package/lib/cjs/components/_classes/component/editForm/utils.js +16 -12
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +6 -6
- package/lib/cjs/components/_classes/field/Field.js +1 -7
- package/lib/cjs/components/_classes/input/Input.js +26 -30
- package/lib/cjs/components/_classes/list/ListComponent.form.js +1 -1
- package/lib/cjs/components/_classes/list/ListComponent.js +18 -27
- package/lib/cjs/components/_classes/list/editForm/ListComponent.edit.data.js +9 -36
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +13 -32
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +3 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.js +75 -67
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +14 -19
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +17 -19
- package/lib/cjs/components/address/Address.d.ts +0 -1
- package/lib/cjs/components/address/Address.js +52 -57
- package/lib/cjs/components/address/editForm/Address.edit.data.js +2 -2
- package/lib/cjs/components/address/editForm/Address.edit.display.js +2 -2
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +11 -53
- package/lib/cjs/components/alert/Alert.js +15 -21
- package/lib/cjs/components/button/Button.form.js +1 -1
- package/lib/cjs/components/button/Button.js +47 -64
- package/lib/cjs/components/button/editForm/Button.edit.display.js +9 -49
- package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/cjs/components/checkbox/Checkbox.form.js +3 -3
- package/lib/cjs/components/checkbox/Checkbox.js +20 -28
- package/lib/cjs/components/checkbox/editForm/Checkbox.edit.data.js +1 -1
- package/lib/cjs/components/checkbox/editForm/Checkbox.edit.display.js +3 -13
- package/lib/cjs/components/checkbox/editForm/Checkbox.edit.validation.js +2 -2
- package/lib/cjs/components/columns/Columns.form.js +1 -1
- package/lib/cjs/components/columns/Columns.js +12 -24
- package/lib/cjs/components/columns/editForm/Columns.edit.display.js +17 -17
- package/lib/cjs/components/container/Container.form.js +2 -2
- package/lib/cjs/components/container/Container.js +4 -6
- package/lib/cjs/components/container/editForm/Container.edit.data.js +3 -3
- package/lib/cjs/components/container/editForm/Container.edit.display.js +4 -4
- package/lib/cjs/components/content/Content.form.js +2 -4
- package/lib/cjs/components/content/Content.js +8 -10
- package/lib/cjs/components/content/editForm/Content.edit.display.js +10 -10
- package/lib/cjs/components/currency/Currency.form.js +3 -3
- package/lib/cjs/components/currency/Currency.js +10 -19
- package/lib/cjs/components/currency/editForm/Currency.edit.data.js +5 -5
- package/lib/cjs/components/currency/editForm/Currency.edit.display.js +8 -8
- package/lib/cjs/components/datagrid/DataGrid.form.js +3 -3
- package/lib/cjs/components/datagrid/DataGrid.js +42 -92
- package/lib/cjs/components/datagrid/editForm/DataGrid.edit.data.js +1 -1
- package/lib/cjs/components/datagrid/editForm/DataGrid.edit.display.js +14 -14
- package/lib/cjs/components/datagrid/editForm/DataGrid.edit.validation.js +3 -3
- package/lib/cjs/components/datamap/DataMap.form.js +2 -2
- package/lib/cjs/components/datamap/DataMap.js +35 -46
- package/lib/cjs/components/datamap/editForm/DataMap.edit.data.js +1 -1
- package/lib/cjs/components/datamap/editForm/DataMap.edit.display.js +8 -8
- package/lib/cjs/components/datetime/DateTime.form.js +5 -5
- package/lib/cjs/components/datetime/DateTime.js +15 -30
- package/lib/cjs/components/datetime/editForm/DateTime.edit.data.js +3 -4
- package/lib/cjs/components/datetime/editForm/DateTime.edit.date.js +10 -10
- package/lib/cjs/components/datetime/editForm/DateTime.edit.display.js +17 -22
- package/lib/cjs/components/datetime/editForm/DateTime.edit.time.js +5 -5
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +3 -3
- package/lib/cjs/components/day/Day.form.js +5 -5
- package/lib/cjs/components/day/Day.js +58 -147
- package/lib/cjs/components/day/editForm/Day.edit.day.js +9 -13
- package/lib/cjs/components/day/editForm/Day.edit.display.js +7 -7
- package/lib/cjs/components/day/editForm/Day.edit.month.js +8 -12
- package/lib/cjs/components/day/editForm/Day.edit.validation.js +7 -7
- package/lib/cjs/components/day/editForm/Day.edit.year.js +8 -8
- package/lib/cjs/components/editgrid/EditGrid.form.js +2 -2
- package/lib/cjs/components/editgrid/EditGrid.js +96 -142
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.data.js +2 -2
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +2 -7
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.templates.js +16 -16
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.validation.js +3 -3
- package/lib/cjs/components/email/Email.js +4 -4
- package/lib/cjs/components/email/editForm/Email.edit.display.js +3 -3
- package/lib/cjs/components/email/editForm/Email.edit.validation.js +6 -6
- package/lib/cjs/components/fieldset/Fieldset.form.js +1 -1
- package/lib/cjs/components/fieldset/Fieldset.js +2 -2
- package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -8
- package/lib/cjs/components/file/File.form.js +4 -4
- package/lib/cjs/components/file/File.js +90 -131
- package/lib/cjs/components/file/editForm/File.edit.display.js +5 -9
- package/lib/cjs/components/file/editForm/File.edit.file.js +53 -97
- package/lib/cjs/components/file/editForm/File.edit.validation.js +2 -2
- package/lib/cjs/components/form/Form.form.js +3 -3
- package/lib/cjs/components/form/Form.js +58 -68
- package/lib/cjs/components/form/editForm/Form.edit.data.js +3 -1
- package/lib/cjs/components/form/editForm/Form.edit.display.js +7 -6
- package/lib/cjs/components/form/editForm/Form.edit.form.js +9 -11
- package/lib/cjs/components/hidden/Hidden.form.js +4 -4
- package/lib/cjs/components/hidden/Hidden.js +2 -2
- package/lib/cjs/components/hidden/editForm/Hidden.edit.data.js +3 -3
- package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +10 -10
- package/lib/cjs/components/html/HTML.js +17 -23
- package/lib/cjs/components/html/editForm/HTML.edit.display.js +17 -17
- package/lib/cjs/components/html/editForm/HTML.edit.logic.js +2 -2
- package/lib/cjs/components/number/Number.form.js +3 -3
- package/lib/cjs/components/number/Number.js +11 -27
- package/lib/cjs/components/number/editForm/Number.edit.data.js +3 -3
- package/lib/cjs/components/number/editForm/Number.edit.display.js +4 -4
- package/lib/cjs/components/number/editForm/Number.edit.validation.js +9 -9
- package/lib/cjs/components/panel/Panel.form.js +1 -1
- package/lib/cjs/components/panel/Panel.js +2 -2
- package/lib/cjs/components/panel/editForm/Panel.edit.conditional.js +7 -5
- package/lib/cjs/components/panel/editForm/Panel.edit.display.js +29 -55
- package/lib/cjs/components/password/Password.form.js +3 -3
- package/lib/cjs/components/password/Password.js +2 -5
- package/lib/cjs/components/password/editForm/Password.edit.data.js +11 -11
- package/lib/cjs/components/password/editForm/Password.edit.display.js +3 -3
- package/lib/cjs/components/password/editForm/Password.edit.validation.js +3 -3
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +8 -8
- package/lib/cjs/components/phonenumber/PhoneNumber.js +3 -3
- package/lib/cjs/components/phonenumber/editForm/PhoneNumber.edit.validation.js +6 -6
- package/lib/cjs/components/radio/Radio.form.js +3 -3
- package/lib/cjs/components/radio/Radio.js +32 -58
- package/lib/cjs/components/radio/editForm/Radio.edit.data.js +9 -23
- package/lib/cjs/components/radio/editForm/Radio.edit.display.js +6 -6
- package/lib/cjs/components/radio/editForm/Radio.edit.validation.js +2 -2
- package/lib/cjs/components/recaptcha/ReCaptcha.form.js +5 -5
- package/lib/cjs/components/recaptcha/ReCaptcha.js +10 -10
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +24 -24
- package/lib/cjs/components/select/Select.form.js +3 -3
- package/lib/cjs/components/select/Select.js +140 -235
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +57 -191
- package/lib/cjs/components/select/editForm/Select.edit.display.js +2 -2
- package/lib/cjs/components/select/editForm/Select.edit.validation.js +4 -4
- package/lib/cjs/components/selectboxes/SelectBoxes.form.js +3 -3
- package/lib/cjs/components/selectboxes/SelectBoxes.js +16 -29
- package/lib/cjs/components/selectboxes/editForm/SelectBoxes.edit.validation.js +5 -5
- package/lib/cjs/components/signature/Signature.form.js +3 -3
- package/lib/cjs/components/signature/Signature.js +17 -26
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +10 -19
- package/lib/cjs/components/survey/Survey.form.js +3 -3
- package/lib/cjs/components/survey/Survey.js +17 -30
- package/lib/cjs/components/survey/editForm/Survey.edit.data.js +11 -23
- package/lib/cjs/components/survey/editForm/Survey.edit.display.js +1 -1
- package/lib/cjs/components/survey/editForm/Survey.edit.validation.js +1 -1
- package/lib/cjs/components/table/Table.form.js +1 -1
- package/lib/cjs/components/table/Table.js +7 -8
- package/lib/cjs/components/table/editForm/Table.edit.display.js +22 -22
- package/lib/cjs/components/tabs/Tabs.form.js +1 -1
- package/lib/cjs/components/tabs/Tabs.js +10 -27
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +17 -21
- package/lib/cjs/components/tags/Tags.form.js +1 -1
- package/lib/cjs/components/tags/Tags.js +12 -28
- package/lib/cjs/components/tags/editForm/Tags.edit.data.js +7 -7
- package/lib/cjs/components/textarea/TextArea.form.js +2 -2
- package/lib/cjs/components/textarea/TextArea.js +45 -63
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +72 -96
- package/lib/cjs/components/textarea/editForm/TextArea.edit.validation.js +3 -3
- package/lib/cjs/components/textfield/TextField.form.js +3 -3
- package/lib/cjs/components/textfield/TextField.js +21 -32
- package/lib/cjs/components/textfield/editForm/TextField.edit.data.js +13 -15
- package/lib/cjs/components/textfield/editForm/TextField.edit.display.js +21 -31
- package/lib/cjs/components/textfield/editForm/TextField.edit.validation.js +6 -6
- package/lib/cjs/components/time/Time.js +10 -17
- package/lib/cjs/components/time/editForm/Time.edit.display.js +2 -2
- package/lib/cjs/components/unknown/Unknown.form.js +5 -5
- package/lib/cjs/components/unknown/Unknown.js +2 -2
- package/lib/cjs/components/unknown/editForm/Unknown.edit.display.js +3 -3
- package/lib/cjs/components/url/Url.form.js +3 -3
- package/lib/cjs/components/url/Url.js +2 -2
- package/lib/cjs/components/url/editForm/Url.edit.display.js +3 -3
- package/lib/cjs/components/url/editForm/Url.edit.validation.js +1 -1
- package/lib/cjs/components/well/Well.form.js +1 -1
- package/lib/cjs/components/well/Well.js +2 -2
- package/lib/cjs/components/well/editForm/Well.edit.display.js +10 -10
- package/lib/cjs/formio.form.d.ts +1 -2
- package/lib/cjs/formio.form.js +12 -38
- package/lib/cjs/i18n.d.ts +0 -4
- package/lib/cjs/i18n.js +3 -7
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/pdf.image.d.ts +2 -0
- package/lib/cjs/pdf.image.js +94 -0
- package/lib/cjs/providers/address/AddressProvider.js +5 -8
- package/lib/cjs/providers/address/GoogleAddressProvider.d.ts +3 -3
- package/lib/cjs/providers/address/GoogleAddressProvider.js +13 -24
- package/lib/cjs/providers/processor/fileProcessor.js +1 -3
- package/lib/cjs/providers/storage/azure.js +2 -5
- package/lib/cjs/providers/storage/dropbox.js +5 -4
- package/lib/cjs/providers/storage/googleDrive.js +4 -3
- package/lib/cjs/providers/storage/index.js +1 -1
- package/lib/cjs/providers/storage/indexeddb.js +6 -16
- package/lib/cjs/providers/storage/s3.js +6 -17
- package/lib/cjs/providers/storage/uploadAdapter.js +11 -17
- package/lib/cjs/providers/storage/url.js +11 -13
- package/lib/cjs/providers/storage/xhr.js +9 -17
- package/lib/cjs/templates/index.js +1 -1
- package/lib/cjs/translations/en.d.ts +2 -0
- package/lib/cjs/translations/en.js +9 -7
- package/lib/cjs/utils/ChoicesWrapper.js +2 -2
- package/lib/cjs/utils/builder.js +7 -31
- package/lib/cjs/utils/calendarUtils.js +5 -7
- package/lib/cjs/utils/conditionOperators/ConditionOperator.js +1 -1
- package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +4 -12
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +1 -3
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +6 -10
- package/lib/cjs/utils/conditionOperators/index.js +1 -1
- package/lib/cjs/utils/formUtils.js +1 -1
- package/lib/cjs/utils/i18n.js +1 -7
- package/lib/cjs/utils/index.d.ts +1 -2
- package/lib/cjs/utils/index.js +2 -2
- package/lib/cjs/utils/jsonlogic/operators.d.ts +1 -0
- package/lib/cjs/utils/jsonlogic/operators.js +265 -0
- package/lib/cjs/utils/utils.d.ts +1 -10
- package/lib/cjs/utils/utils.js +92 -175
- package/lib/cjs/widgets/CalendarWidget.js +49 -66
- package/lib/cjs/widgets/InputWidget.js +4 -6
- package/lib/cjs/widgets/index.js +1 -1
- package/lib/mjs/CDN.js +12 -12
- package/lib/mjs/Element.d.ts +2 -3
- package/lib/mjs/Element.js +23 -29
- package/lib/mjs/Embed.js +43 -77
- package/lib/mjs/EventEmitter.js +1 -1
- package/lib/mjs/Form.d.ts +341 -371
- package/lib/mjs/Form.js +126 -142
- package/lib/mjs/FormBuilder.d.ts +3 -3
- package/lib/mjs/FormBuilder.js +3 -2
- package/lib/mjs/Formio.js +23 -26
- package/lib/mjs/InlineEmbed.js +17 -23
- package/lib/mjs/PDF.d.ts +0 -1
- package/lib/mjs/PDF.js +15 -18
- package/lib/mjs/PDFBuilder.js +36 -51
- package/lib/mjs/Webform.d.ts +366 -8
- package/lib/mjs/Webform.js +251 -184
- package/lib/mjs/WebformBuilder.js +151 -224
- package/lib/mjs/Wizard.js +64 -94
- package/lib/mjs/WizardBuilder.js +19 -27
- package/lib/mjs/addons/FormioAddon.js +1 -1
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.form.js +57 -59
- package/lib/mjs/addons/PasswordStrength/PasswordStrengthAddon.js +16 -24
- package/lib/mjs/addons/index.js +3 -3
- package/lib/mjs/components/Components.js +4 -0
- package/lib/mjs/components/_classes/component/Component.form.js +11 -11
- package/lib/mjs/components/_classes/component/Component.js +194 -313
- package/lib/mjs/components/_classes/component/editForm/Component.edit.addons.js +4 -2
- package/lib/mjs/components/_classes/component/editForm/Component.edit.api.js +5 -5
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +11 -9
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +25 -39
- package/lib/mjs/components/_classes/component/editForm/Component.edit.display.js +29 -47
- package/lib/mjs/components/_classes/component/editForm/Component.edit.layout.js +9 -9
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +7 -5
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +34 -37
- package/lib/mjs/components/_classes/component/editForm/utils.js +16 -12
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +2 -2
- package/lib/mjs/components/_classes/field/Field.js +2 -8
- package/lib/mjs/components/_classes/input/Input.js +23 -27
- package/lib/mjs/components/_classes/list/ListComponent.form.js +1 -1
- package/lib/mjs/components/_classes/list/ListComponent.js +18 -27
- package/lib/mjs/components/_classes/list/editForm/ListComponent.edit.data.js +9 -36
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +13 -32
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +3 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.js +33 -41
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +15 -20
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +17 -19
- package/lib/mjs/components/address/Address.d.ts +0 -1
- package/lib/mjs/components/address/Address.js +49 -60
- package/lib/mjs/components/address/editForm/Address.edit.data.js +2 -2
- package/lib/mjs/components/address/editForm/Address.edit.display.js +2 -2
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +11 -53
- package/lib/mjs/components/alert/Alert.js +16 -22
- package/lib/mjs/components/button/Button.form.js +1 -1
- package/lib/mjs/components/button/Button.js +42 -65
- package/lib/mjs/components/button/editForm/Button.edit.display.js +9 -49
- package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/mjs/components/checkbox/Checkbox.form.js +3 -3
- package/lib/mjs/components/checkbox/Checkbox.js +21 -29
- package/lib/mjs/components/checkbox/editForm/Checkbox.edit.data.js +1 -1
- package/lib/mjs/components/checkbox/editForm/Checkbox.edit.display.js +3 -13
- package/lib/mjs/components/checkbox/editForm/Checkbox.edit.validation.js +2 -2
- package/lib/mjs/components/columns/Columns.form.js +1 -1
- package/lib/mjs/components/columns/Columns.js +12 -24
- package/lib/mjs/components/columns/editForm/Columns.edit.display.js +17 -17
- package/lib/mjs/components/container/Container.form.js +2 -2
- package/lib/mjs/components/container/Container.js +4 -6
- package/lib/mjs/components/container/editForm/Container.edit.data.js +3 -3
- package/lib/mjs/components/container/editForm/Container.edit.display.js +4 -4
- package/lib/mjs/components/content/Content.form.js +2 -4
- package/lib/mjs/components/content/Content.js +8 -10
- package/lib/mjs/components/content/editForm/Content.edit.display.js +10 -10
- package/lib/mjs/components/currency/Currency.form.js +3 -3
- package/lib/mjs/components/currency/Currency.js +10 -19
- package/lib/mjs/components/currency/editForm/Currency.edit.data.js +5 -5
- package/lib/mjs/components/currency/editForm/Currency.edit.display.js +8 -8
- package/lib/mjs/components/datagrid/DataGrid.form.js +3 -3
- package/lib/mjs/components/datagrid/DataGrid.js +41 -92
- package/lib/mjs/components/datagrid/editForm/DataGrid.edit.data.js +1 -1
- package/lib/mjs/components/datagrid/editForm/DataGrid.edit.display.js +14 -14
- package/lib/mjs/components/datagrid/editForm/DataGrid.edit.validation.js +3 -3
- package/lib/mjs/components/datamap/DataMap.form.js +2 -2
- package/lib/mjs/components/datamap/DataMap.js +33 -46
- package/lib/mjs/components/datamap/editForm/DataMap.edit.data.js +1 -1
- package/lib/mjs/components/datamap/editForm/DataMap.edit.display.js +8 -8
- package/lib/mjs/components/datetime/DateTime.form.js +5 -5
- package/lib/mjs/components/datetime/DateTime.js +16 -31
- package/lib/mjs/components/datetime/editForm/DateTime.edit.data.js +3 -4
- package/lib/mjs/components/datetime/editForm/DateTime.edit.date.js +10 -10
- package/lib/mjs/components/datetime/editForm/DateTime.edit.display.js +17 -22
- package/lib/mjs/components/datetime/editForm/DateTime.edit.time.js +5 -5
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +3 -3
- package/lib/mjs/components/day/Day.form.js +5 -5
- package/lib/mjs/components/day/Day.js +58 -148
- package/lib/mjs/components/day/editForm/Day.edit.day.js +9 -13
- package/lib/mjs/components/day/editForm/Day.edit.display.js +7 -7
- package/lib/mjs/components/day/editForm/Day.edit.month.js +8 -12
- package/lib/mjs/components/day/editForm/Day.edit.validation.js +7 -7
- package/lib/mjs/components/day/editForm/Day.edit.year.js +8 -8
- package/lib/mjs/components/editgrid/EditGrid.form.js +2 -2
- package/lib/mjs/components/editgrid/EditGrid.js +92 -140
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.data.js +2 -2
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +2 -7
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.templates.js +16 -16
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.validation.js +3 -3
- package/lib/mjs/components/email/Email.js +4 -4
- package/lib/mjs/components/email/editForm/Email.edit.display.js +3 -3
- package/lib/mjs/components/email/editForm/Email.edit.validation.js +6 -6
- package/lib/mjs/components/fieldset/Fieldset.form.js +1 -1
- package/lib/mjs/components/fieldset/Fieldset.js +2 -2
- package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -8
- package/lib/mjs/components/file/File.form.js +4 -4
- package/lib/mjs/components/file/File.js +89 -136
- package/lib/mjs/components/file/editForm/File.edit.display.js +5 -9
- package/lib/mjs/components/file/editForm/File.edit.file.js +53 -97
- package/lib/mjs/components/file/editForm/File.edit.validation.js +2 -2
- package/lib/mjs/components/form/Form.form.js +3 -3
- package/lib/mjs/components/form/Form.js +55 -68
- package/lib/mjs/components/form/editForm/Form.edit.data.js +3 -1
- package/lib/mjs/components/form/editForm/Form.edit.display.js +7 -6
- package/lib/mjs/components/form/editForm/Form.edit.form.js +8 -10
- package/lib/mjs/components/hidden/Hidden.form.js +4 -4
- package/lib/mjs/components/hidden/Hidden.js +2 -2
- package/lib/mjs/components/hidden/editForm/Hidden.edit.data.js +3 -3
- package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +10 -10
- package/lib/mjs/components/html/HTML.js +17 -23
- package/lib/mjs/components/html/editForm/HTML.edit.display.js +17 -17
- package/lib/mjs/components/html/editForm/HTML.edit.logic.js +2 -2
- package/lib/mjs/components/number/Number.form.js +3 -3
- package/lib/mjs/components/number/Number.js +12 -28
- package/lib/mjs/components/number/editForm/Number.edit.data.js +3 -3
- package/lib/mjs/components/number/editForm/Number.edit.display.js +4 -4
- package/lib/mjs/components/number/editForm/Number.edit.validation.js +9 -9
- package/lib/mjs/components/panel/Panel.form.js +1 -1
- package/lib/mjs/components/panel/Panel.js +2 -2
- package/lib/mjs/components/panel/editForm/Panel.edit.conditional.js +8 -6
- package/lib/mjs/components/panel/editForm/Panel.edit.display.js +29 -55
- package/lib/mjs/components/password/Password.form.js +3 -3
- package/lib/mjs/components/password/Password.js +2 -5
- package/lib/mjs/components/password/editForm/Password.edit.data.js +11 -11
- package/lib/mjs/components/password/editForm/Password.edit.display.js +3 -3
- package/lib/mjs/components/password/editForm/Password.edit.validation.js +3 -3
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +8 -8
- package/lib/mjs/components/phonenumber/PhoneNumber.js +3 -3
- package/lib/mjs/components/phonenumber/editForm/PhoneNumber.edit.validation.js +6 -6
- package/lib/mjs/components/radio/Radio.form.js +3 -3
- package/lib/mjs/components/radio/Radio.js +30 -59
- package/lib/mjs/components/radio/editForm/Radio.edit.data.js +9 -23
- package/lib/mjs/components/radio/editForm/Radio.edit.display.js +6 -6
- package/lib/mjs/components/radio/editForm/Radio.edit.validation.js +2 -2
- package/lib/mjs/components/recaptcha/ReCaptcha.form.js +5 -5
- package/lib/mjs/components/recaptcha/ReCaptcha.js +8 -10
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +24 -24
- package/lib/mjs/components/select/Select.form.js +3 -3
- package/lib/mjs/components/select/Select.js +145 -240
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +57 -191
- package/lib/mjs/components/select/editForm/Select.edit.display.js +2 -2
- package/lib/mjs/components/select/editForm/Select.edit.validation.js +4 -4
- package/lib/mjs/components/selectboxes/SelectBoxes.form.js +3 -3
- package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -30
- package/lib/mjs/components/selectboxes/editForm/SelectBoxes.edit.validation.js +5 -5
- package/lib/mjs/components/signature/Signature.form.js +3 -3
- package/lib/mjs/components/signature/Signature.js +16 -26
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +10 -19
- package/lib/mjs/components/survey/Survey.form.js +3 -3
- package/lib/mjs/components/survey/Survey.js +17 -30
- package/lib/mjs/components/survey/editForm/Survey.edit.data.js +11 -23
- package/lib/mjs/components/survey/editForm/Survey.edit.display.js +1 -1
- package/lib/mjs/components/survey/editForm/Survey.edit.validation.js +1 -1
- package/lib/mjs/components/table/Table.form.js +1 -1
- package/lib/mjs/components/table/Table.js +6 -8
- package/lib/mjs/components/table/editForm/Table.edit.display.js +22 -22
- package/lib/mjs/components/tabs/Tabs.form.js +1 -1
- package/lib/mjs/components/tabs/Tabs.js +9 -27
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +17 -21
- package/lib/mjs/components/tags/Tags.form.js +1 -1
- package/lib/mjs/components/tags/Tags.js +12 -28
- package/lib/mjs/components/tags/editForm/Tags.edit.data.js +7 -7
- package/lib/mjs/components/textarea/TextArea.form.js +2 -2
- package/lib/mjs/components/textarea/TextArea.js +51 -75
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +72 -96
- package/lib/mjs/components/textarea/editForm/TextArea.edit.validation.js +3 -3
- package/lib/mjs/components/textfield/TextField.form.js +3 -3
- package/lib/mjs/components/textfield/TextField.js +23 -34
- package/lib/mjs/components/textfield/editForm/TextField.edit.data.js +13 -15
- package/lib/mjs/components/textfield/editForm/TextField.edit.display.js +21 -31
- package/lib/mjs/components/textfield/editForm/TextField.edit.validation.js +6 -6
- package/lib/mjs/components/time/Time.js +10 -17
- package/lib/mjs/components/time/editForm/Time.edit.display.js +2 -2
- package/lib/mjs/components/unknown/Unknown.form.js +5 -5
- package/lib/mjs/components/unknown/Unknown.js +2 -2
- package/lib/mjs/components/unknown/editForm/Unknown.edit.display.js +3 -3
- package/lib/mjs/components/url/Url.form.js +3 -3
- package/lib/mjs/components/url/Url.js +2 -2
- package/lib/mjs/components/url/editForm/Url.edit.display.js +3 -3
- package/lib/mjs/components/url/editForm/Url.edit.validation.js +1 -1
- package/lib/mjs/components/well/Well.form.js +1 -1
- package/lib/mjs/components/well/Well.js +2 -2
- package/lib/mjs/components/well/editForm/Well.edit.display.js +10 -10
- package/lib/mjs/formio.form.d.ts +1 -2
- package/lib/mjs/formio.form.js +8 -10
- package/lib/mjs/i18n.d.ts +0 -4
- package/lib/mjs/i18n.js +3 -7
- package/lib/mjs/package.json +1 -1
- package/lib/mjs/pdf.image.d.ts +2 -0
- package/lib/mjs/pdf.image.js +94 -0
- package/lib/mjs/providers/address/AddressProvider.js +5 -8
- package/lib/mjs/providers/address/GoogleAddressProvider.d.ts +3 -3
- package/lib/mjs/providers/address/GoogleAddressProvider.js +13 -24
- package/lib/mjs/providers/processor/fileProcessor.js +1 -3
- package/lib/mjs/providers/storage/azure.js +2 -5
- package/lib/mjs/providers/storage/dropbox.js +5 -4
- package/lib/mjs/providers/storage/googleDrive.js +4 -3
- package/lib/mjs/providers/storage/index.js +1 -1
- package/lib/mjs/providers/storage/indexeddb.js +6 -16
- package/lib/mjs/providers/storage/s3.js +8 -19
- package/lib/mjs/providers/storage/uploadAdapter.js +11 -17
- package/lib/mjs/providers/storage/url.js +11 -13
- package/lib/mjs/providers/storage/xhr.js +9 -17
- package/lib/mjs/templates/index.js +1 -1
- package/lib/mjs/translations/en.d.ts +2 -0
- package/lib/mjs/translations/en.js +9 -7
- package/lib/mjs/utils/ChoicesWrapper.js +2 -2
- package/lib/mjs/utils/builder.js +7 -31
- package/lib/mjs/utils/calendarUtils.js +5 -7
- package/lib/mjs/utils/conditionOperators/ConditionOperator.js +1 -1
- package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +5 -16
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +1 -3
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +6 -10
- package/lib/mjs/utils/conditionOperators/index.js +1 -1
- package/lib/mjs/utils/formUtils.js +2 -2
- package/lib/mjs/utils/i18n.js +1 -7
- package/lib/mjs/utils/index.d.ts +1 -2
- package/lib/mjs/utils/index.js +3 -3
- package/lib/mjs/utils/jsonlogic/operators.d.ts +1 -0
- package/lib/mjs/utils/jsonlogic/operators.js +262 -0
- package/lib/mjs/utils/utils.d.ts +1 -10
- package/lib/mjs/utils/utils.js +91 -178
- package/lib/mjs/widgets/CalendarWidget.js +50 -67
- package/lib/mjs/widgets/InputWidget.js +4 -6
- package/lib/mjs/widgets/index.js +1 -1
- package/package.json +3 -3
- package/lib/cjs/translations/de.d.ts +0 -80
- package/lib/cjs/translations/de.js +0 -81
- package/lib/mjs/translations/de.d.ts +0 -80
- package/lib/mjs/translations/de.js +0 -79
|
@@ -17,13 +17,11 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
17
17
|
key: 'select',
|
|
18
18
|
idPath: 'id',
|
|
19
19
|
data: {
|
|
20
|
-
values: [
|
|
21
|
-
{ label: '', value: '' },
|
|
22
|
-
],
|
|
20
|
+
values: [{ label: '', value: '' }],
|
|
23
21
|
json: '',
|
|
24
22
|
url: '',
|
|
25
23
|
resource: '',
|
|
26
|
-
custom: ''
|
|
24
|
+
custom: ''
|
|
27
25
|
},
|
|
28
26
|
clearOnRefresh: false,
|
|
29
27
|
limit: 100,
|
|
@@ -44,7 +42,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
44
42
|
threshold: 0.3,
|
|
45
43
|
},
|
|
46
44
|
indexeddb: {
|
|
47
|
-
filter: {}
|
|
45
|
+
filter: {}
|
|
48
46
|
},
|
|
49
47
|
customOptions: {},
|
|
50
48
|
useExactSearch: false,
|
|
@@ -57,7 +55,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
57
55
|
icon: 'th-list',
|
|
58
56
|
weight: 70,
|
|
59
57
|
documentation: '/userguide/form-building/form-components#select',
|
|
60
|
-
schema: SelectComponent.schema()
|
|
58
|
+
schema: SelectComponent.schema()
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
61
|
static get serverConditionSettings() {
|
|
@@ -80,12 +78,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
80
78
|
}
|
|
81
79
|
return valueComp;
|
|
82
80
|
}, dataTypeOperators: {
|
|
83
|
-
number: [
|
|
84
|
-
'lessThan',
|
|
85
|
-
'greaterThan',
|
|
86
|
-
'lessThanOrEqual',
|
|
87
|
-
'greaterThanOrEqual',
|
|
88
|
-
],
|
|
81
|
+
number: ['lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],
|
|
89
82
|
}, dataTypeValueComponents: {
|
|
90
83
|
number: {
|
|
91
84
|
lessThan: numberType,
|
|
@@ -103,28 +96,15 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
103
96
|
return types;
|
|
104
97
|
}
|
|
105
98
|
if (reference) {
|
|
106
|
-
return [
|
|
107
|
-
object,
|
|
108
|
-
];
|
|
99
|
+
return [object];
|
|
109
100
|
}
|
|
110
101
|
if (dataType === 'object') {
|
|
111
|
-
return [
|
|
112
|
-
object,
|
|
113
|
-
array,
|
|
114
|
-
];
|
|
102
|
+
return [object, array];
|
|
115
103
|
}
|
|
116
104
|
if (utils_1.componentValueTypes[dataType]) {
|
|
117
|
-
return [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
return [
|
|
122
|
-
boolean,
|
|
123
|
-
string,
|
|
124
|
-
number,
|
|
125
|
-
object,
|
|
126
|
-
array,
|
|
127
|
-
];
|
|
105
|
+
return [utils_1.componentValueTypes[dataType]];
|
|
106
|
+
}
|
|
107
|
+
return [boolean, string, number, object, array];
|
|
128
108
|
}
|
|
129
109
|
init() {
|
|
130
110
|
super.init();
|
|
@@ -246,10 +226,17 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
246
226
|
return this.component.dataSrc === 'resource' && this.valueProperty === 'data';
|
|
247
227
|
}
|
|
248
228
|
selectValueAndLabel(data) {
|
|
249
|
-
|
|
229
|
+
let value;
|
|
230
|
+
// If the select is a resource reference, use the actual object value
|
|
231
|
+
if (this.component.reference && this.isSelectResource) {
|
|
232
|
+
value = this.getOptionValue(data);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
value = this.getOptionValue(this.isEntireObjectDisplay() && !this.itemValue(data) ? data : this.itemValue(data));
|
|
236
|
+
}
|
|
250
237
|
return {
|
|
251
238
|
value,
|
|
252
|
-
label: this.itemTemplate(this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data) ? { data: data } : data, value)
|
|
239
|
+
label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)
|
|
253
240
|
};
|
|
254
241
|
}
|
|
255
242
|
itemTemplate(data, value) {
|
|
@@ -263,13 +250,13 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
263
250
|
// Perform a fast interpretation if we should not use the template.
|
|
264
251
|
if (data && !this.component.template) {
|
|
265
252
|
const itemLabel = data.label || data;
|
|
266
|
-
const value = typeof itemLabel === 'string' ? this.t(itemLabel, { _userInput: true }) : itemLabel;
|
|
253
|
+
const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
|
|
267
254
|
return this.sanitize(value, this.shouldSanitizeValue);
|
|
268
255
|
}
|
|
269
256
|
// Inside DataTable component won't have dataValue set
|
|
270
257
|
const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)
|
|
271
258
|
? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
|
|
272
|
-
: this.dataValue === this.normalizeSingleValue(value)) || this.inDataTable;
|
|
259
|
+
: (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;
|
|
273
260
|
if (shouldUseSelectData) {
|
|
274
261
|
const selectData = this.selectData;
|
|
275
262
|
if (selectData) {
|
|
@@ -285,6 +272,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
285
272
|
else {
|
|
286
273
|
data = selectData;
|
|
287
274
|
}
|
|
275
|
+
// use template data for reference fields to make sure the data is updated
|
|
276
|
+
if (this.component.reference && this.templateData[templateValue]) {
|
|
277
|
+
data = this.templateData[templateValue];
|
|
278
|
+
}
|
|
288
279
|
}
|
|
289
280
|
}
|
|
290
281
|
if (typeof data === 'string' || typeof data === 'number') {
|
|
@@ -301,10 +292,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
301
292
|
if (data.data) {
|
|
302
293
|
// checking additional fields in the template for the selected Entire Object option
|
|
303
294
|
const hasNestedFields = /item\.data\.\w*/g.test(this.component.template);
|
|
304
|
-
data.data =
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
: data.data;
|
|
295
|
+
data.data = this.isEntireObjectDisplay() && lodash_1.default.isObject(data.data) && !hasNestedFields
|
|
296
|
+
? JSON.stringify(data.data)
|
|
297
|
+
: data.data;
|
|
308
298
|
}
|
|
309
299
|
return super.itemTemplate(data, value);
|
|
310
300
|
}
|
|
@@ -331,16 +321,15 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
331
321
|
if (value) {
|
|
332
322
|
this.selectOptions.push(option);
|
|
333
323
|
}
|
|
334
|
-
if (this.refs.selectContainer && this.component.widget === 'html5') {
|
|
324
|
+
if (this.refs.selectContainer && (this.component.widget === 'html5')) {
|
|
335
325
|
// Replace an empty Object value to an empty String.
|
|
336
326
|
if (option.value && lodash_1.default.isObject(option.value) && lodash_1.default.isEmpty(option.value)) {
|
|
337
327
|
option.value = '';
|
|
338
328
|
}
|
|
339
329
|
// Add element to option so we can reference it later.
|
|
340
330
|
const div = document.createElement('div');
|
|
341
|
-
const isInDataValue = this.component.multiple && Array.isArray(this.dataValue) && this.dataValue.includes(value);
|
|
342
331
|
div.innerHTML = this.sanitize(this.renderTemplate('selectOption', {
|
|
343
|
-
selected: lodash_1.default.isEqual(this.getOptionValue(this.dataValue), option.value)
|
|
332
|
+
selected: lodash_1.default.isEqual(this.getOptionValue(this.dataValue), option.value),
|
|
344
333
|
option,
|
|
345
334
|
attrs,
|
|
346
335
|
id,
|
|
@@ -355,21 +344,14 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
355
344
|
let added = false;
|
|
356
345
|
let data = this.dataValue;
|
|
357
346
|
// preset submission value with value property before request.
|
|
358
|
-
if (this.options.pdf &&
|
|
359
|
-
!items.length &&
|
|
360
|
-
this.component.dataSrc === 'url' &&
|
|
361
|
-
this.valueProperty) {
|
|
347
|
+
if (this.options.pdf && !items.length && this.component.dataSrc === 'url' && this.valueProperty) {
|
|
362
348
|
data = Array.isArray(data)
|
|
363
|
-
? data.map(
|
|
349
|
+
? data.map(item => lodash_1.default.set({}, this.valueProperty, item))
|
|
364
350
|
: lodash_1.default.set({}, this.valueProperty, data);
|
|
365
351
|
}
|
|
366
352
|
if (!this.selectOptions.length) {
|
|
367
353
|
// Add the currently selected choices if they don't already exist.
|
|
368
|
-
const currentChoices = Array.isArray(data) && this.component.multiple
|
|
369
|
-
? data
|
|
370
|
-
: [
|
|
371
|
-
data,
|
|
372
|
-
];
|
|
354
|
+
const currentChoices = Array.isArray(data) && this.component.multiple ? data : [data];
|
|
373
355
|
added = this.addCurrentChoices(currentChoices, items);
|
|
374
356
|
if (!added && !this.component.multiple) {
|
|
375
357
|
this.addPlaceholder();
|
|
@@ -396,13 +378,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
396
378
|
}
|
|
397
379
|
return false;
|
|
398
380
|
}
|
|
381
|
+
/* eslint-disable max-statements */
|
|
399
382
|
setItems(items, fromSearch) {
|
|
400
383
|
var _a, _b;
|
|
401
|
-
if (this.visible && this.isHtmlRenderMode() && !lodash_1.default.isEqual(items, this.selectItems)) {
|
|
402
|
-
this.itemsLoaded.then(() => {
|
|
403
|
-
this.redraw();
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
384
|
this.selectItems = items;
|
|
407
385
|
// If the items is a string, then parse as JSON.
|
|
408
386
|
if (typeof items == 'string') {
|
|
@@ -434,9 +412,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
434
412
|
if (this.itemsFromUrl) {
|
|
435
413
|
areItemsEqual = this.isSelectURL ? lodash_1.default.isEqual(items, this.downloadedResources) : false;
|
|
436
414
|
const areItemsEnded = this.component.limit > items.length;
|
|
437
|
-
const areItemsDownloaded = areItemsEqual
|
|
438
|
-
this.downloadedResources
|
|
439
|
-
this.downloadedResources.length === items.length;
|
|
415
|
+
const areItemsDownloaded = areItemsEqual
|
|
416
|
+
&& this.downloadedResources
|
|
417
|
+
&& this.downloadedResources.length === items.length;
|
|
440
418
|
if (areItemsEnded) {
|
|
441
419
|
this.disableInfiniteScroll();
|
|
442
420
|
}
|
|
@@ -453,8 +431,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
453
431
|
? this.downloadedResources.concat(items)
|
|
454
432
|
: items;
|
|
455
433
|
}
|
|
456
|
-
this.downloadedResources.serverCount =
|
|
457
|
-
items.serverCount || this.downloadedResources.serverCount;
|
|
434
|
+
this.downloadedResources.serverCount = items.serverCount || this.downloadedResources.serverCount;
|
|
458
435
|
}
|
|
459
436
|
else {
|
|
460
437
|
this.downloadedResources = items || [];
|
|
@@ -462,11 +439,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
462
439
|
// If there is new select option with same id as already selected, set the new one
|
|
463
440
|
if (!lodash_1.default.isEmpty(this.dataValue) && this.component.idPath) {
|
|
464
441
|
const selectedOptionId = lodash_1.default.get(this.dataValue, this.component.idPath, null);
|
|
465
|
-
const newOptionWithSameId = !lodash_1.default.isNil(selectedOptionId) &&
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
});
|
|
442
|
+
const newOptionWithSameId = !lodash_1.default.isNil(selectedOptionId) && items.find(item => {
|
|
443
|
+
const itemId = lodash_1.default.get(item, this.component.idPath);
|
|
444
|
+
return itemId === selectedOptionId;
|
|
445
|
+
});
|
|
470
446
|
if (newOptionWithSameId) {
|
|
471
447
|
this.setValue(newOptionWithSameId);
|
|
472
448
|
}
|
|
@@ -482,10 +458,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
482
458
|
// Iterate through each of the items.
|
|
483
459
|
lodash_1.default.each(items, (item, index) => {
|
|
484
460
|
// preventing references of the components inside the form to the parent form when building forms
|
|
485
|
-
if (this.root &&
|
|
486
|
-
this.root.options.editForm &&
|
|
487
|
-
this.root.options.editForm._id &&
|
|
488
|
-
this.root.options.editForm._id === item._id)
|
|
461
|
+
if (this.root && this.root.options.editForm && this.root.options.editForm._id && this.root.options.editForm._id === item._id)
|
|
489
462
|
return;
|
|
490
463
|
const itemValueAndLabel = this.selectValueAndLabel(item);
|
|
491
464
|
this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, lodash_1.default.get(item, this.component.idPath, String(index)));
|
|
@@ -505,7 +478,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
505
478
|
// If a value is provided, then select it.
|
|
506
479
|
if (!this.isEmpty() || this.isRemoveButtonPressed) {
|
|
507
480
|
this.setValue(this.dataValue, {
|
|
508
|
-
noUpdateEvent: true
|
|
481
|
+
noUpdateEvent: true
|
|
509
482
|
});
|
|
510
483
|
}
|
|
511
484
|
else if (this.shouldAddDefaultValue && !this.options.readOnly) {
|
|
@@ -532,17 +505,17 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
532
505
|
return super.itemValueForHTMLMode(value);
|
|
533
506
|
}
|
|
534
507
|
if (Array.isArray(value)) {
|
|
535
|
-
const values = value.map(
|
|
508
|
+
const values = value.map(item => Array.isArray(item)
|
|
536
509
|
? this.itemValueForHTMLMode(item)
|
|
537
510
|
: this.getSingleItemValueForHTMLMode(item));
|
|
538
511
|
return values.join(', ');
|
|
539
512
|
}
|
|
540
513
|
return this.getSingleItemValueForHTMLMode(value);
|
|
541
514
|
}
|
|
515
|
+
/* eslint-enable max-statements */
|
|
542
516
|
get defaultValue() {
|
|
543
517
|
let defaultValue = super.defaultValue;
|
|
544
|
-
if (!defaultValue &&
|
|
545
|
-
(this.component.defaultValue === false || this.component.defaultValue === 0)) {
|
|
518
|
+
if (!defaultValue && (this.component.defaultValue === false || this.component.defaultValue === 0)) {
|
|
546
519
|
defaultValue = this.component.defaultValue;
|
|
547
520
|
}
|
|
548
521
|
return defaultValue;
|
|
@@ -561,7 +534,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
561
534
|
}
|
|
562
535
|
// See if they have not met the minimum search requirements.
|
|
563
536
|
const minSearch = parseInt(this.component.minSearch, 10);
|
|
564
|
-
if (this.component.searchField &&
|
|
537
|
+
if (this.component.searchField &&
|
|
538
|
+
(minSearch > 0) &&
|
|
539
|
+
(!search || (search.length < minSearch))) {
|
|
565
540
|
// Set empty items.
|
|
566
541
|
return this.setItems([]);
|
|
567
542
|
}
|
|
@@ -572,19 +547,17 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
572
547
|
}
|
|
573
548
|
const limit = this.component.limit || 100;
|
|
574
549
|
const skip = this.isScrollLoading ? this.selectOptions.length : 0;
|
|
575
|
-
const query = this.component.disableLimit
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
skip,
|
|
580
|
-
};
|
|
550
|
+
const query = this.component.disableLimit ? {} : {
|
|
551
|
+
limit,
|
|
552
|
+
skip,
|
|
553
|
+
};
|
|
581
554
|
// Allow for url interpolation.
|
|
582
555
|
url = this.sanitize(this.interpolate(url, {
|
|
583
556
|
formioBase: Formio_1.Formio.getBaseUrl(),
|
|
584
557
|
search,
|
|
585
558
|
limit,
|
|
586
559
|
skip,
|
|
587
|
-
page: Math.abs(Math.floor(skip / limit))
|
|
560
|
+
page: Math.abs(Math.floor(skip / limit))
|
|
588
561
|
}), this.shouldSanitizeValue);
|
|
589
562
|
// Add search capability.
|
|
590
563
|
if (this.component.searchField && search) {
|
|
@@ -607,9 +580,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
607
580
|
}
|
|
608
581
|
if (!lodash_1.default.isEmpty(query)) {
|
|
609
582
|
// Add the query string.
|
|
610
|
-
url +=
|
|
611
|
-
(!url.includes('?') ? '?' : '&') +
|
|
612
|
-
Formio_1.Formio.serialize(query, (item) => this.interpolate(item));
|
|
583
|
+
url += (!url.includes('?') ? '?' : '&') + Formio_1.Formio.serialize(query, (item) => this.interpolate(item));
|
|
613
584
|
}
|
|
614
585
|
// Add filter capability
|
|
615
586
|
if (this.component.filter) {
|
|
@@ -670,7 +641,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
670
641
|
}
|
|
671
642
|
getCustomItems() {
|
|
672
643
|
const customItems = this.evaluate(this.component.data.custom, {
|
|
673
|
-
values: []
|
|
644
|
+
values: []
|
|
674
645
|
}, 'values');
|
|
675
646
|
this.asyncValues = (0, utils_1.isPromise)(customItems);
|
|
676
647
|
return customItems;
|
|
@@ -689,11 +660,11 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
689
660
|
}
|
|
690
661
|
this.loading = true;
|
|
691
662
|
this.getCustomItems()
|
|
692
|
-
.then(
|
|
663
|
+
.then(items => {
|
|
693
664
|
this.loading = false;
|
|
694
665
|
this.setItems(items || []);
|
|
695
666
|
})
|
|
696
|
-
.catch(
|
|
667
|
+
.catch(err => {
|
|
697
668
|
this.handleLoadingError(err);
|
|
698
669
|
});
|
|
699
670
|
}
|
|
@@ -705,13 +676,13 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
705
676
|
return super.isEmpty(value) || value === undefined;
|
|
706
677
|
}
|
|
707
678
|
refresh(value, { instance }) {
|
|
708
|
-
if (this.component.clearOnRefresh && instance && !instance.pristine) {
|
|
679
|
+
if (this.component.clearOnRefresh && (instance && !instance.pristine)) {
|
|
709
680
|
this.setValue(this.emptyValue);
|
|
710
681
|
}
|
|
711
682
|
this.updateItems(null, true);
|
|
712
683
|
}
|
|
713
684
|
get additionalResourcesAvailable() {
|
|
714
|
-
return lodash_1.default.isNil(this.serverCount) || this.serverCount > this.downloadedResources.length;
|
|
685
|
+
return lodash_1.default.isNil(this.serverCount) || (this.serverCount > this.downloadedResources.length);
|
|
715
686
|
}
|
|
716
687
|
get serverCount() {
|
|
717
688
|
if (this.isFromSearch) {
|
|
@@ -763,22 +734,18 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
763
734
|
setLoadingItem(addToCurrentList = false) {
|
|
764
735
|
if (this.choices) {
|
|
765
736
|
if (addToCurrentList) {
|
|
766
|
-
this.choices.setChoices([
|
|
767
|
-
{
|
|
737
|
+
this.choices.setChoices([{
|
|
768
738
|
value: `${this.id}-loading`,
|
|
769
739
|
label: 'Loading...',
|
|
770
740
|
disabled: true,
|
|
771
|
-
},
|
|
772
|
-
], 'value', 'label');
|
|
741
|
+
}], 'value', 'label');
|
|
773
742
|
}
|
|
774
743
|
else {
|
|
775
|
-
this.choices.setChoices([
|
|
776
|
-
{
|
|
744
|
+
this.choices.setChoices([{
|
|
777
745
|
value: '',
|
|
778
746
|
label: `<i class="${this.iconClass('refresh')}" style="font-size:1.3em;"></i>`,
|
|
779
747
|
disabled: true,
|
|
780
|
-
},
|
|
781
|
-
], 'value', 'label', true);
|
|
748
|
+
}], 'value', 'label', true);
|
|
782
749
|
}
|
|
783
750
|
}
|
|
784
751
|
else if (this.component.dataSrc === 'url' || this.component.dataSrc === 'resource') {
|
|
@@ -800,15 +767,13 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
800
767
|
}
|
|
801
768
|
wrapElement(element) {
|
|
802
769
|
return this.component.addResource && !this.options.readOnly
|
|
803
|
-
? this.renderTemplate('resourceAdd', {
|
|
804
|
-
element
|
|
805
|
-
})
|
|
770
|
+
? (this.renderTemplate('resourceAdd', {
|
|
771
|
+
element
|
|
772
|
+
}))
|
|
806
773
|
: element;
|
|
807
774
|
}
|
|
808
775
|
choicesOptions() {
|
|
809
|
-
const useSearch = this.component.hasOwnProperty('searchEnabled')
|
|
810
|
-
? this.component.searchEnabled
|
|
811
|
-
: true;
|
|
776
|
+
const useSearch = this.component.hasOwnProperty('searchEnabled') ? this.component.searchEnabled : true;
|
|
812
777
|
const placeholderValue = this.t(this.component.placeholder, { _userInput: true });
|
|
813
778
|
let customOptions = this.component.customOptions || {};
|
|
814
779
|
if (typeof customOptions == 'string') {
|
|
@@ -824,27 +789,20 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
824
789
|
maxPatternLength: 1000,
|
|
825
790
|
distance: 1000,
|
|
826
791
|
};
|
|
827
|
-
return Object.assign({ removeItemButton: this.component.disabled
|
|
828
|
-
|
|
829
|
-
: lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {
|
|
830
|
-
containerOuter: [
|
|
831
|
-
'choices',
|
|
832
|
-
'form-group',
|
|
833
|
-
'formio-choices',
|
|
834
|
-
],
|
|
792
|
+
return Object.assign({ removeItemButton: this.component.disabled ? false : lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {
|
|
793
|
+
containerOuter: ['choices', 'form-group', 'formio-choices'],
|
|
835
794
|
containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
|
|
836
|
-
}, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: this.component.dropdown || 'auto', searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', [
|
|
837
|
-
'label',
|
|
838
|
-
]), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch
|
|
795
|
+
}, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: (this.component.dropdown || 'auto'), searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', ['label']), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch
|
|
839
796
|
? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false, duplicateItemsAllowed: false }, customOptions);
|
|
840
797
|
}
|
|
798
|
+
/* eslint-disable max-statements */
|
|
841
799
|
attach(element) {
|
|
842
800
|
var _a, _b, _c;
|
|
843
801
|
const superAttach = super.attach(element);
|
|
844
802
|
this.loadRefs(element, {
|
|
845
803
|
selectContainer: 'single',
|
|
846
804
|
addResource: 'single',
|
|
847
|
-
autocompleteInput: 'single'
|
|
805
|
+
autocompleteInput: 'single'
|
|
848
806
|
});
|
|
849
807
|
//enable autocomplete for select
|
|
850
808
|
const autocompleteInput = this.refs.autocompleteInput;
|
|
@@ -857,18 +815,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
857
815
|
if (!input) {
|
|
858
816
|
return;
|
|
859
817
|
}
|
|
860
|
-
this.addEventListener(input, this.inputInfo.changeEvent, (
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
value = event.target.value;
|
|
864
|
-
if (this.component.multiple) {
|
|
865
|
-
value = Array.from(event.target.selectedOptions).map(opt => opt.value);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
this.updateValue(value, {
|
|
869
|
-
modified: true
|
|
870
|
-
});
|
|
871
|
-
});
|
|
818
|
+
this.addEventListener(input, this.inputInfo.changeEvent, () => this.updateValue(null, {
|
|
819
|
+
modified: true
|
|
820
|
+
}));
|
|
872
821
|
this.attachRefreshOnBlur();
|
|
873
822
|
if (this.component.widget === 'html5') {
|
|
874
823
|
this.addFocusBlurEvents(input);
|
|
@@ -882,10 +831,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
882
831
|
}
|
|
883
832
|
this.addEventListener(input, 'keydown', (event) => {
|
|
884
833
|
const { key } = event;
|
|
885
|
-
if ([
|
|
886
|
-
'Backspace',
|
|
887
|
-
'Delete',
|
|
888
|
-
].includes(key)) {
|
|
834
|
+
if (['Backspace', 'Delete'].includes(key)) {
|
|
889
835
|
this.setValue(this.emptyValue);
|
|
890
836
|
}
|
|
891
837
|
});
|
|
@@ -952,10 +898,8 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
952
898
|
this.isFromSearch = false;
|
|
953
899
|
});
|
|
954
900
|
// avoid spamming the resource/url endpoint when we have server side filtering enabled.
|
|
955
|
-
const debounceTimeout = this.component.searchField && (this.isSelectResource || this.isSelectURL)
|
|
956
|
-
|
|
957
|
-
? 0
|
|
958
|
-
: this.component.searchDebounce || this.defaultSchema.searchDebounce) * 1000
|
|
901
|
+
const debounceTimeout = this.component.searchField && (this.isSelectResource || this.isSelectURL) ?
|
|
902
|
+
(this.component.searchDebounce === 0 ? 0 : this.component.searchDebounce || this.defaultSchema.searchDebounce) * 1000
|
|
959
903
|
: 0;
|
|
960
904
|
const updateComponent = (evt) => {
|
|
961
905
|
this.triggerUpdate(evt.detail.value);
|
|
@@ -982,9 +926,8 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
982
926
|
});
|
|
983
927
|
}
|
|
984
928
|
// Add value options.
|
|
985
|
-
const value = this.undoValueTyping(this.dataValue);
|
|
986
929
|
this.addValueOptions();
|
|
987
|
-
this.setChoicesValue(
|
|
930
|
+
this.setChoicesValue(this.dataValue);
|
|
988
931
|
if (this.isSelectResource && this.refs.addResource) {
|
|
989
932
|
this.addEventListener(this.refs.addResource, 'click', (event) => {
|
|
990
933
|
event.preventDefault();
|
|
@@ -992,15 +935,13 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
992
935
|
const dialog = this.createModal(formioForm);
|
|
993
936
|
const projectUrl = lodash_1.default.get(this.root, 'formio.projectUrl', Formio_1.Formio.getProjectUrl());
|
|
994
937
|
const formUrl = `${projectUrl}/form/${this.component.data.resource}`;
|
|
995
|
-
new Form_1.default(formioForm, formUrl, {}).ready
|
|
938
|
+
new Form_1.default(formioForm, formUrl, {}).ready
|
|
939
|
+
.then((form) => {
|
|
996
940
|
form.on('submit', (submission) => {
|
|
997
941
|
// If valueProperty is set, replace the submission with the corresponding value
|
|
998
942
|
let value = this.valueProperty ? lodash_1.default.get(submission, this.valueProperty) : submission;
|
|
999
943
|
if (this.component.multiple) {
|
|
1000
|
-
value = [
|
|
1001
|
-
...this.dataValue,
|
|
1002
|
-
value,
|
|
1003
|
-
];
|
|
944
|
+
value = [...this.dataValue, value];
|
|
1004
945
|
}
|
|
1005
946
|
this.setValue(value);
|
|
1006
947
|
this.triggerUpdate();
|
|
@@ -1046,9 +987,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1046
987
|
}
|
|
1047
988
|
positionDropdown(scroll) {
|
|
1048
989
|
var _a;
|
|
1049
|
-
if (!this.shouldPositionDropdown ||
|
|
1050
|
-
!this.choices ||
|
|
1051
|
-
(!((_a = this.choices.dropdown) === null || _a === void 0 ? void 0 : _a.isActive) && scroll)) {
|
|
990
|
+
if (!this.shouldPositionDropdown || !this.choices || (!((_a = this.choices.dropdown) === null || _a === void 0 ? void 0 : _a.isActive) && scroll)) {
|
|
1052
991
|
return;
|
|
1053
992
|
}
|
|
1054
993
|
this.setDropdownPosition();
|
|
@@ -1069,12 +1008,11 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1069
1008
|
attachRefreshOnBlur() {
|
|
1070
1009
|
if (this.component.refreshOnBlur) {
|
|
1071
1010
|
this.on('blur', (instance) => {
|
|
1072
|
-
this.checkRefreshOn([
|
|
1073
|
-
{ instance, value: instance.dataValue },
|
|
1074
|
-
], { fromBlur: true });
|
|
1011
|
+
this.checkRefreshOn([{ instance, value: instance.dataValue }], { fromBlur: true });
|
|
1075
1012
|
});
|
|
1076
1013
|
}
|
|
1077
1014
|
}
|
|
1015
|
+
/* eslint-enable max-statements */
|
|
1078
1016
|
update() {
|
|
1079
1017
|
if (this.component.dataSrc === 'custom') {
|
|
1080
1018
|
this.updateCustomItems();
|
|
@@ -1103,7 +1041,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1103
1041
|
}
|
|
1104
1042
|
set visible(value) {
|
|
1105
1043
|
// If we go from hidden to visible, trigger a refresh.
|
|
1106
|
-
if (value && !this._visible !== !value) {
|
|
1044
|
+
if (value && (!this._visible !== !value)) {
|
|
1107
1045
|
this.triggerUpdate();
|
|
1108
1046
|
}
|
|
1109
1047
|
super.visible = value;
|
|
@@ -1130,7 +1068,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1130
1068
|
const isSelectOptions = items === this.selectOptions;
|
|
1131
1069
|
if (items && items.length) {
|
|
1132
1070
|
lodash_1.default.each(items, (choice) => {
|
|
1133
|
-
if (choice._id && value._id && choice._id === value._id) {
|
|
1071
|
+
if (choice._id && value._id && (choice._id === value._id)) {
|
|
1134
1072
|
found = true;
|
|
1135
1073
|
return false;
|
|
1136
1074
|
}
|
|
@@ -1150,23 +1088,22 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1150
1088
|
if (this.choices) {
|
|
1151
1089
|
this.choices.setChoices(notFoundValuesToAdd, 'value', 'label');
|
|
1152
1090
|
}
|
|
1153
|
-
notFoundValuesToAdd.map(
|
|
1091
|
+
notFoundValuesToAdd.map(notFoundValue => {
|
|
1154
1092
|
this.addOption(notFoundValue.value, notFoundValue.label);
|
|
1155
1093
|
});
|
|
1156
1094
|
}
|
|
1157
1095
|
return added;
|
|
1158
1096
|
}
|
|
1159
1097
|
getValueAsString(data, options) {
|
|
1160
|
-
return this.component.multiple && Array.isArray(data)
|
|
1098
|
+
return (this.component.multiple && Array.isArray(data))
|
|
1161
1099
|
? data.map((v) => this.asString(v, options)).join(', ')
|
|
1162
1100
|
: this.asString(data, options);
|
|
1163
1101
|
}
|
|
1164
1102
|
getValue() {
|
|
1165
1103
|
// If the widget isn't active.
|
|
1166
|
-
if (this.viewOnly ||
|
|
1167
|
-
this.
|
|
1168
|
-
|
|
1169
|
-
!this.element) {
|
|
1104
|
+
if (this.viewOnly || this.loading
|
|
1105
|
+
|| (!this.component.lazyLoad && !this.selectOptions.length)
|
|
1106
|
+
|| !this.element) {
|
|
1170
1107
|
return this.dataValue;
|
|
1171
1108
|
}
|
|
1172
1109
|
let value = this.emptyValue;
|
|
@@ -1175,7 +1112,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1175
1112
|
// Make sure we don't get the placeholder
|
|
1176
1113
|
if (!this.component.multiple &&
|
|
1177
1114
|
this.component.placeholder &&
|
|
1178
|
-
value === this.t(this.component.placeholder, { _userInput: true })) {
|
|
1115
|
+
(value === this.t(this.component.placeholder, { _userInput: true }))) {
|
|
1179
1116
|
value = this.emptyValue;
|
|
1180
1117
|
}
|
|
1181
1118
|
}
|
|
@@ -1185,7 +1122,8 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1185
1122
|
if (value === '') {
|
|
1186
1123
|
return {};
|
|
1187
1124
|
}
|
|
1188
|
-
const option = this.selectOptions[value] ||
|
|
1125
|
+
const option = this.selectOptions[value] ||
|
|
1126
|
+
this.selectOptions.find(option => option.id === value);
|
|
1189
1127
|
if (option && lodash_1.default.isObject(option.value)) {
|
|
1190
1128
|
value = option.value;
|
|
1191
1129
|
}
|
|
@@ -1220,18 +1158,16 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1220
1158
|
number() {
|
|
1221
1159
|
const numberValue = Number(this.value);
|
|
1222
1160
|
const isEquivalent = value.toString() === numberValue.toString();
|
|
1223
|
-
if (!Number.isNaN(numberValue) &&
|
|
1224
|
-
Number.isFinite(numberValue) &&
|
|
1225
|
-
value !== '' &&
|
|
1226
|
-
isEquivalent) {
|
|
1161
|
+
if (!Number.isNaN(numberValue) && Number.isFinite(numberValue) && value !== '' && isEquivalent) {
|
|
1227
1162
|
this.value = numberValue;
|
|
1228
1163
|
}
|
|
1229
1164
|
return this;
|
|
1230
1165
|
},
|
|
1231
1166
|
boolean() {
|
|
1232
|
-
if (lodash_1.default.isString(this.value)
|
|
1233
|
-
(this.value.toLowerCase() === 'true'
|
|
1234
|
-
|
|
1167
|
+
if (lodash_1.default.isString(this.value)
|
|
1168
|
+
&& (this.value.toLowerCase() === 'true'
|
|
1169
|
+
|| this.value.toLowerCase() === 'false')) {
|
|
1170
|
+
this.value = (this.value.toLowerCase() === 'true');
|
|
1235
1171
|
}
|
|
1236
1172
|
return this;
|
|
1237
1173
|
},
|
|
@@ -1250,7 +1186,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1250
1186
|
this.value = this.string().number().boolean().value;
|
|
1251
1187
|
}
|
|
1252
1188
|
return this;
|
|
1253
|
-
}
|
|
1189
|
+
}
|
|
1254
1190
|
};
|
|
1255
1191
|
try {
|
|
1256
1192
|
return normalize[dataType]().value;
|
|
@@ -1284,11 +1220,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1284
1220
|
// Check to see if we need to save off the template data into our metadata.
|
|
1285
1221
|
const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
|
|
1286
1222
|
const shouldSaveData = (!valueIsObject || this.component.reference) && !this.inDataTable;
|
|
1287
|
-
if (!lodash_1.default.isNil(templateValue) &&
|
|
1288
|
-
shouldSaveData &&
|
|
1289
|
-
this.templateData &&
|
|
1290
|
-
this.templateData[templateValue] &&
|
|
1291
|
-
((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
|
|
1223
|
+
if (!lodash_1.default.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
|
|
1292
1224
|
const submission = this.root.submission;
|
|
1293
1225
|
if (!submission.metadata) {
|
|
1294
1226
|
submission.metadata = {};
|
|
@@ -1302,9 +1234,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1302
1234
|
const dataValue = this.dataValue;
|
|
1303
1235
|
if (dataValue && lodash_1.default.isArray(dataValue) && dataValue.length) {
|
|
1304
1236
|
dataValue.forEach((dataValueItem) => {
|
|
1305
|
-
const dataValueItemValue = this.component.reference
|
|
1306
|
-
? dataValueItem._id.toString()
|
|
1307
|
-
: dataValueItem;
|
|
1237
|
+
const dataValueItemValue = this.component.reference ? dataValueItem._id.toString() : dataValueItem;
|
|
1308
1238
|
templateData[dataValueItemValue] = this.templateData[dataValueItemValue];
|
|
1309
1239
|
});
|
|
1310
1240
|
}
|
|
@@ -1324,7 +1254,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1324
1254
|
const changed = super.updateValue(value, flags);
|
|
1325
1255
|
if (changed || !this.selectMetadata || flags.resetValue) {
|
|
1326
1256
|
if (this.component.multiple && Array.isArray(this.dataValue)) {
|
|
1327
|
-
this.dataValue.forEach(
|
|
1257
|
+
this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
|
|
1328
1258
|
}
|
|
1329
1259
|
else {
|
|
1330
1260
|
this.setMetadata(this.dataValue, flags);
|
|
@@ -1335,7 +1265,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1335
1265
|
undoValueTyping(value) {
|
|
1336
1266
|
let untypedValue = value;
|
|
1337
1267
|
if (this.component.multiple && Array.isArray(value)) {
|
|
1338
|
-
untypedValue = value.map(
|
|
1268
|
+
untypedValue = value.map(v => {
|
|
1339
1269
|
if (typeof v === 'boolean' || typeof v === 'number') {
|
|
1340
1270
|
return v.toString();
|
|
1341
1271
|
}
|
|
@@ -1352,9 +1282,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1352
1282
|
setValue(value, flags = {}) {
|
|
1353
1283
|
const previousValue = this.dataValue;
|
|
1354
1284
|
const changed = this.updateValue(value, flags);
|
|
1355
|
-
if (this.component.widget === 'html5' &&
|
|
1356
|
-
(lodash_1.default.isEqual(value, previousValue) || (lodash_1.default.isEqual(previousValue, {}) && lodash_1.default.isEqual(flags, {}))) &&
|
|
1357
|
-
!flags.fromSubmission) {
|
|
1285
|
+
if (this.component.widget === 'html5' && (lodash_1.default.isEqual(value, previousValue) || lodash_1.default.isEqual(previousValue, {}) && lodash_1.default.isEqual(flags, {})) && !flags.fromSubmission) {
|
|
1358
1286
|
return false;
|
|
1359
1287
|
}
|
|
1360
1288
|
value = this.dataValue;
|
|
@@ -1378,9 +1306,6 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1378
1306
|
this.lazyLoadInit = true;
|
|
1379
1307
|
const searchProperty = this.component.searchField || this.component.valueProperty;
|
|
1380
1308
|
this.triggerUpdate(lodash_1.default.get(value.data || value, searchProperty, value), true);
|
|
1381
|
-
this.itemsLoaded.then(() => {
|
|
1382
|
-
this.setChoicesValue(value, hasPreviousValue, flags);
|
|
1383
|
-
});
|
|
1384
1309
|
return changed;
|
|
1385
1310
|
}
|
|
1386
1311
|
// Add the value options.
|
|
@@ -1391,28 +1316,23 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1391
1316
|
return changed;
|
|
1392
1317
|
}
|
|
1393
1318
|
isInitApiCallNeeded(hasValue) {
|
|
1394
|
-
return
|
|
1319
|
+
return this.component.lazyLoad &&
|
|
1395
1320
|
!this.lazyLoadInit &&
|
|
1396
1321
|
!this.active &&
|
|
1397
1322
|
!this.selectOptions.length &&
|
|
1398
1323
|
hasValue &&
|
|
1399
1324
|
this.shouldInitialLoad &&
|
|
1400
|
-
this.visible &&
|
|
1401
|
-
(this.component.searchField || this.component.valueProperty));
|
|
1325
|
+
this.visible && (this.component.searchField || this.component.valueProperty);
|
|
1402
1326
|
}
|
|
1403
1327
|
setChoicesValue(value, hasPreviousValue, flags = {}) {
|
|
1404
1328
|
const hasValue = !this.isEmpty(value) || flags.fromSubmission;
|
|
1405
|
-
hasPreviousValue = hasPreviousValue === undefined ? true : hasPreviousValue;
|
|
1329
|
+
hasPreviousValue = (hasPreviousValue === undefined) ? true : hasPreviousValue;
|
|
1406
1330
|
if (this.choices) {
|
|
1407
1331
|
// Now set the value.
|
|
1408
1332
|
if (hasValue) {
|
|
1409
1333
|
this.choices.removeActiveItems();
|
|
1410
1334
|
// Add the currently selected choices if they don't already exist.
|
|
1411
|
-
const currentChoices = Array.isArray(value) && this.component.multiple
|
|
1412
|
-
? value
|
|
1413
|
-
: [
|
|
1414
|
-
value,
|
|
1415
|
-
];
|
|
1335
|
+
const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];
|
|
1416
1336
|
if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {
|
|
1417
1337
|
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
|
1418
1338
|
}
|
|
@@ -1424,13 +1344,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1424
1344
|
}
|
|
1425
1345
|
else {
|
|
1426
1346
|
if (hasValue) {
|
|
1427
|
-
const values = Array.isArray(value)
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
value,
|
|
1431
|
-
];
|
|
1432
|
-
if ((!lodash_1.default.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2) ||
|
|
1433
|
-
(this.selectData && flags.fromSubmission)) {
|
|
1347
|
+
const values = Array.isArray(value) ? value : [value];
|
|
1348
|
+
if (!lodash_1.default.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2
|
|
1349
|
+
|| (this.selectData && flags.fromSubmission)) {
|
|
1434
1350
|
const { value, label } = this.selectValueAndLabel(this.dataValue);
|
|
1435
1351
|
this.addOption(value, label);
|
|
1436
1352
|
}
|
|
@@ -1470,7 +1386,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1470
1386
|
return false;
|
|
1471
1387
|
}
|
|
1472
1388
|
try {
|
|
1473
|
-
return JSON.stringify(normalizedOptionValue) === JSON.stringify(value);
|
|
1389
|
+
return (JSON.stringify(normalizedOptionValue) === JSON.stringify(value));
|
|
1474
1390
|
}
|
|
1475
1391
|
catch (err) {
|
|
1476
1392
|
console.warn.error('Error while comparing items', err);
|
|
@@ -1479,7 +1395,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1479
1395
|
};
|
|
1480
1396
|
return values.findIndex((optionValue) => compareComplexValues(optionValue)) !== -1;
|
|
1481
1397
|
}
|
|
1482
|
-
return
|
|
1398
|
+
return values.findIndex((optionValue) => this.normalizeSingleValue(optionValue) === value) !== -1;
|
|
1483
1399
|
}
|
|
1484
1400
|
return false;
|
|
1485
1401
|
}
|
|
@@ -1538,7 +1454,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1538
1454
|
*/
|
|
1539
1455
|
deleteValue() {
|
|
1540
1456
|
this.setValue('', {
|
|
1541
|
-
noUpdateEvent: true
|
|
1457
|
+
noUpdateEvent: true
|
|
1542
1458
|
});
|
|
1543
1459
|
this.unset();
|
|
1544
1460
|
}
|
|
@@ -1561,10 +1477,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1561
1477
|
if (!this.component || !this.component.data || !this.component.data.values) {
|
|
1562
1478
|
return;
|
|
1563
1479
|
}
|
|
1564
|
-
return this.component.data.values.map(
|
|
1565
|
-
label: value.label,
|
|
1566
|
-
value: String(this.normalizeSingleValue(value.value)),
|
|
1567
|
-
}));
|
|
1480
|
+
return this.component.data.values.map(value => ({ label: value.label, value: String(this.normalizeSingleValue(value.value)) }));
|
|
1568
1481
|
}
|
|
1569
1482
|
asString(value, options = {}) {
|
|
1570
1483
|
var _a;
|
|
@@ -1573,7 +1486,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1573
1486
|
if (this.inDataTable) {
|
|
1574
1487
|
value = this.undoValueTyping(value);
|
|
1575
1488
|
}
|
|
1576
|
-
const templateValue = this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data) ? { data: value } : value;
|
|
1489
|
+
const templateValue = (this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)) ? { data: value } : value;
|
|
1577
1490
|
const template = this.itemTemplate(templateValue, value, options);
|
|
1578
1491
|
return template;
|
|
1579
1492
|
}
|
|
@@ -1581,7 +1494,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1581
1494
|
const convertToString = (data, valueProperty) => {
|
|
1582
1495
|
if (valueProperty) {
|
|
1583
1496
|
if (Array.isArray(data)) {
|
|
1584
|
-
data.forEach((item) =>
|
|
1497
|
+
data.forEach((item) => item[valueProperty] = item[valueProperty].toString());
|
|
1585
1498
|
}
|
|
1586
1499
|
else if (lodash_1.default.isObject(data)) {
|
|
1587
1500
|
data[valueProperty] = data[valueProperty].toString();
|
|
@@ -1591,18 +1504,14 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1591
1504
|
if (this.isBooleanOrNumber(data)) {
|
|
1592
1505
|
data = data.toString();
|
|
1593
1506
|
}
|
|
1594
|
-
if (Array.isArray(data) && data.some(
|
|
1595
|
-
data = data.map(
|
|
1507
|
+
if (Array.isArray(data) && data.some(item => this.isBooleanOrNumber(item))) {
|
|
1508
|
+
data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);
|
|
1596
1509
|
}
|
|
1597
1510
|
return data;
|
|
1598
1511
|
};
|
|
1599
1512
|
value = convertToString(value);
|
|
1600
|
-
if ([
|
|
1601
|
-
'values'
|
|
1602
|
-
'custom',
|
|
1603
|
-
].includes(this.component.dataSrc) &&
|
|
1604
|
-
!this.asyncCustomValues()) {
|
|
1605
|
-
const { items, valueProperty } = this.component.dataSrc === 'values'
|
|
1513
|
+
if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {
|
|
1514
|
+
const { items, valueProperty, } = this.component.dataSrc === 'values'
|
|
1606
1515
|
? {
|
|
1607
1516
|
items: convertToString(this.getNormalizedValues(), 'value'),
|
|
1608
1517
|
valueProperty: 'value',
|
|
@@ -1612,30 +1521,28 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1612
1521
|
valueProperty: this.valueProperty,
|
|
1613
1522
|
};
|
|
1614
1523
|
const getFromValues = () => {
|
|
1615
|
-
const initialValue = lodash_1.default.find(items, [
|
|
1616
|
-
valueProperty,
|
|
1617
|
-
value,
|
|
1618
|
-
]);
|
|
1524
|
+
const initialValue = lodash_1.default.find(items, [valueProperty, value]);
|
|
1619
1525
|
const values = this.defaultSchema.data.values || [];
|
|
1620
1526
|
return lodash_1.default.isEqual(initialValue, values[0]) ? '-' : initialValue;
|
|
1621
1527
|
};
|
|
1622
|
-
value =
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
: value;
|
|
1528
|
+
value = (this.component.multiple && Array.isArray(value))
|
|
1529
|
+
? lodash_1.default.filter(items, (item) => value.includes(item.value))
|
|
1530
|
+
: (valueProperty && items)
|
|
1531
|
+
? (_a = getFromValues()) !== null && _a !== void 0 ? _a : { value, label: value }
|
|
1532
|
+
: value;
|
|
1628
1533
|
}
|
|
1629
1534
|
if (lodash_1.default.isString(value)) {
|
|
1630
1535
|
return value;
|
|
1631
1536
|
}
|
|
1632
1537
|
const getTemplateValue = (v) => {
|
|
1633
1538
|
const itemTemplate = this.itemTemplate(v);
|
|
1634
|
-
return options.csv && itemTemplate
|
|
1539
|
+
return options.csv && itemTemplate
|
|
1540
|
+
? (0, utils_1.removeHTML)(itemTemplate)
|
|
1541
|
+
: itemTemplate;
|
|
1635
1542
|
};
|
|
1636
1543
|
if (Array.isArray(value)) {
|
|
1637
1544
|
const items = [];
|
|
1638
|
-
value.forEach(
|
|
1545
|
+
value.forEach(item => items.push(getTemplateValue(item)));
|
|
1639
1546
|
if (this.component.dataSrc === 'resource' && items.length > 0) {
|
|
1640
1547
|
return items.join(', ');
|
|
1641
1548
|
}
|
|
@@ -1649,7 +1556,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1649
1556
|
if (this.isEntireObjectDisplay() && lodash_1.default.isObject(value)) {
|
|
1650
1557
|
return JSON.stringify(value);
|
|
1651
1558
|
}
|
|
1652
|
-
return !lodash_1.default.isNil(value)
|
|
1559
|
+
return !lodash_1.default.isNil(value)
|
|
1560
|
+
? getTemplateValue(value)
|
|
1561
|
+
: '-';
|
|
1653
1562
|
}
|
|
1654
1563
|
detach() {
|
|
1655
1564
|
var _a, _b;
|
|
@@ -1671,14 +1580,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
1671
1580
|
setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {
|
|
1672
1581
|
super.setErrorClasses(elements, dirty, hasError, hasMessages, element);
|
|
1673
1582
|
if (this.choices) {
|
|
1674
|
-
super.setErrorClasses([
|
|
1675
|
-
this.choices.containerInner.element,
|
|
1676
|
-
], dirty, hasError, hasMessages, element);
|
|
1583
|
+
super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);
|
|
1677
1584
|
}
|
|
1678
1585
|
else {
|
|
1679
|
-
super.setErrorClasses([
|
|
1680
|
-
this.refs.selectContainer,
|
|
1681
|
-
], dirty, hasError, hasMessages, element);
|
|
1586
|
+
super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);
|
|
1682
1587
|
}
|
|
1683
1588
|
}
|
|
1684
1589
|
}
|