@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
|
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
|
|
2
2
|
import { Formio } from '../../Formio';
|
|
3
3
|
import ListComponent from '../_classes/list/ListComponent';
|
|
4
4
|
import Form from '../../Form';
|
|
5
|
-
import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, isSelectResourceWithObjectValue, removeHTML
|
|
5
|
+
import { getRandomComponentId, boolValue, isPromise, componentValueTypes, getComponentSavedTypes, isSelectResourceWithObjectValue, removeHTML } from '../../utils';
|
|
6
6
|
import Choices from '../../utils/ChoicesWrapper';
|
|
7
7
|
export default class SelectComponent extends ListComponent {
|
|
8
8
|
static schema(...extend) {
|
|
@@ -12,13 +12,11 @@ export default class SelectComponent extends ListComponent {
|
|
|
12
12
|
key: 'select',
|
|
13
13
|
idPath: 'id',
|
|
14
14
|
data: {
|
|
15
|
-
values: [
|
|
16
|
-
{ label: '', value: '' },
|
|
17
|
-
],
|
|
15
|
+
values: [{ label: '', value: '' }],
|
|
18
16
|
json: '',
|
|
19
17
|
url: '',
|
|
20
18
|
resource: '',
|
|
21
|
-
custom: ''
|
|
19
|
+
custom: ''
|
|
22
20
|
},
|
|
23
21
|
clearOnRefresh: false,
|
|
24
22
|
limit: 100,
|
|
@@ -39,7 +37,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
39
37
|
threshold: 0.3,
|
|
40
38
|
},
|
|
41
39
|
indexeddb: {
|
|
42
|
-
filter: {}
|
|
40
|
+
filter: {}
|
|
43
41
|
},
|
|
44
42
|
customOptions: {},
|
|
45
43
|
useExactSearch: false,
|
|
@@ -52,7 +50,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
52
50
|
icon: 'th-list',
|
|
53
51
|
weight: 70,
|
|
54
52
|
documentation: '/userguide/form-building/form-components#select',
|
|
55
|
-
schema: SelectComponent.schema()
|
|
53
|
+
schema: SelectComponent.schema()
|
|
56
54
|
};
|
|
57
55
|
}
|
|
58
56
|
static get serverConditionSettings() {
|
|
@@ -78,12 +76,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
78
76
|
return valueComp;
|
|
79
77
|
},
|
|
80
78
|
dataTypeOperators: {
|
|
81
|
-
number: [
|
|
82
|
-
'lessThan',
|
|
83
|
-
'greaterThan',
|
|
84
|
-
'lessThanOrEqual',
|
|
85
|
-
'greaterThanOrEqual',
|
|
86
|
-
],
|
|
79
|
+
number: ['lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],
|
|
87
80
|
},
|
|
88
81
|
dataTypeValueComponents: {
|
|
89
82
|
number: {
|
|
@@ -103,28 +96,15 @@ export default class SelectComponent extends ListComponent {
|
|
|
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 (componentValueTypes[dataType]) {
|
|
117
|
-
return [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
return [
|
|
122
|
-
boolean,
|
|
123
|
-
string,
|
|
124
|
-
number,
|
|
125
|
-
object,
|
|
126
|
-
array,
|
|
127
|
-
];
|
|
105
|
+
return [componentValueTypes[dataType]];
|
|
106
|
+
}
|
|
107
|
+
return [boolean, string, number, object, array];
|
|
128
108
|
}
|
|
129
109
|
init() {
|
|
130
110
|
super.init();
|
|
@@ -246,10 +226,17 @@ export default class SelectComponent extends ListComponent {
|
|
|
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() && !_.isObject(data.data) ? { data: data } : data, value)
|
|
239
|
+
label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : data, value)
|
|
253
240
|
};
|
|
254
241
|
}
|
|
255
242
|
itemTemplate(data, value) {
|
|
@@ -263,13 +250,13 @@ export default class SelectComponent extends ListComponent {
|
|
|
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 && _.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 @@ export default class SelectComponent extends ListComponent {
|
|
|
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 @@ export default class SelectComponent extends ListComponent {
|
|
|
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() && _.isObject(data.data) && !hasNestedFields
|
|
296
|
+
? JSON.stringify(data.data)
|
|
297
|
+
: data.data;
|
|
308
298
|
}
|
|
309
299
|
return super.itemTemplate(data, value);
|
|
310
300
|
}
|
|
@@ -324,7 +314,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
324
314
|
const option = {
|
|
325
315
|
value: this.getOptionValue(value),
|
|
326
316
|
label,
|
|
327
|
-
...idPath
|
|
317
|
+
...idPath
|
|
328
318
|
};
|
|
329
319
|
const skipOption = this.component.uniqueOptions
|
|
330
320
|
? !!this.selectOptions.find((selectOption) => _.isEqual(selectOption.value, option.value))
|
|
@@ -335,16 +325,15 @@ export default class SelectComponent extends ListComponent {
|
|
|
335
325
|
if (value) {
|
|
336
326
|
this.selectOptions.push(option);
|
|
337
327
|
}
|
|
338
|
-
if (this.refs.selectContainer && this.component.widget === 'html5') {
|
|
328
|
+
if (this.refs.selectContainer && (this.component.widget === 'html5')) {
|
|
339
329
|
// Replace an empty Object value to an empty String.
|
|
340
330
|
if (option.value && _.isObject(option.value) && _.isEmpty(option.value)) {
|
|
341
331
|
option.value = '';
|
|
342
332
|
}
|
|
343
333
|
// Add element to option so we can reference it later.
|
|
344
334
|
const div = document.createElement('div');
|
|
345
|
-
const isInDataValue = this.component.multiple && Array.isArray(this.dataValue) && this.dataValue.includes(value);
|
|
346
335
|
div.innerHTML = this.sanitize(this.renderTemplate('selectOption', {
|
|
347
|
-
selected: _.isEqual(this.getOptionValue(this.dataValue), option.value)
|
|
336
|
+
selected: _.isEqual(this.getOptionValue(this.dataValue), option.value),
|
|
348
337
|
option,
|
|
349
338
|
attrs,
|
|
350
339
|
id,
|
|
@@ -359,21 +348,14 @@ export default class SelectComponent extends ListComponent {
|
|
|
359
348
|
let added = false;
|
|
360
349
|
let data = this.dataValue;
|
|
361
350
|
// preset submission value with value property before request.
|
|
362
|
-
if (this.options.pdf &&
|
|
363
|
-
!items.length &&
|
|
364
|
-
this.component.dataSrc === 'url' &&
|
|
365
|
-
this.valueProperty) {
|
|
351
|
+
if (this.options.pdf && !items.length && this.component.dataSrc === 'url' && this.valueProperty) {
|
|
366
352
|
data = Array.isArray(data)
|
|
367
|
-
? data.map(
|
|
353
|
+
? data.map(item => _.set({}, this.valueProperty, item))
|
|
368
354
|
: _.set({}, this.valueProperty, data);
|
|
369
355
|
}
|
|
370
356
|
if (!this.selectOptions.length) {
|
|
371
357
|
// Add the currently selected choices if they don't already exist.
|
|
372
|
-
const currentChoices = Array.isArray(data) && this.component.multiple
|
|
373
|
-
? data
|
|
374
|
-
: [
|
|
375
|
-
data,
|
|
376
|
-
];
|
|
358
|
+
const currentChoices = Array.isArray(data) && this.component.multiple ? data : [data];
|
|
377
359
|
added = this.addCurrentChoices(currentChoices, items);
|
|
378
360
|
if (!added && !this.component.multiple) {
|
|
379
361
|
this.addPlaceholder();
|
|
@@ -400,12 +382,8 @@ export default class SelectComponent extends ListComponent {
|
|
|
400
382
|
}
|
|
401
383
|
return false;
|
|
402
384
|
}
|
|
385
|
+
/* eslint-disable max-statements */
|
|
403
386
|
setItems(items, fromSearch) {
|
|
404
|
-
if (this.visible && this.isHtmlRenderMode() && !_.isEqual(items, this.selectItems)) {
|
|
405
|
-
this.itemsLoaded.then(() => {
|
|
406
|
-
this.redraw();
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
387
|
this.selectItems = items;
|
|
410
388
|
// If the items is a string, then parse as JSON.
|
|
411
389
|
if (typeof items == 'string') {
|
|
@@ -437,9 +415,9 @@ export default class SelectComponent extends ListComponent {
|
|
|
437
415
|
if (this.itemsFromUrl) {
|
|
438
416
|
areItemsEqual = this.isSelectURL ? _.isEqual(items, this.downloadedResources) : false;
|
|
439
417
|
const areItemsEnded = this.component.limit > items.length;
|
|
440
|
-
const areItemsDownloaded = areItemsEqual
|
|
441
|
-
this.downloadedResources
|
|
442
|
-
this.downloadedResources.length === items.length;
|
|
418
|
+
const areItemsDownloaded = areItemsEqual
|
|
419
|
+
&& this.downloadedResources
|
|
420
|
+
&& this.downloadedResources.length === items.length;
|
|
443
421
|
if (areItemsEnded) {
|
|
444
422
|
this.disableInfiniteScroll();
|
|
445
423
|
}
|
|
@@ -456,8 +434,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
456
434
|
? this.downloadedResources.concat(items)
|
|
457
435
|
: items;
|
|
458
436
|
}
|
|
459
|
-
this.downloadedResources.serverCount =
|
|
460
|
-
items.serverCount || this.downloadedResources.serverCount;
|
|
437
|
+
this.downloadedResources.serverCount = items.serverCount || this.downloadedResources.serverCount;
|
|
461
438
|
}
|
|
462
439
|
else {
|
|
463
440
|
this.downloadedResources = items || [];
|
|
@@ -465,11 +442,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
465
442
|
// If there is new select option with same id as already selected, set the new one
|
|
466
443
|
if (!_.isEmpty(this.dataValue) && this.component.idPath) {
|
|
467
444
|
const selectedOptionId = _.get(this.dataValue, this.component.idPath, null);
|
|
468
|
-
const newOptionWithSameId = !_.isNil(selectedOptionId) &&
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
});
|
|
445
|
+
const newOptionWithSameId = !_.isNil(selectedOptionId) && items.find(item => {
|
|
446
|
+
const itemId = _.get(item, this.component.idPath);
|
|
447
|
+
return itemId === selectedOptionId;
|
|
448
|
+
});
|
|
473
449
|
if (newOptionWithSameId) {
|
|
474
450
|
this.setValue(newOptionWithSameId);
|
|
475
451
|
}
|
|
@@ -485,10 +461,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
485
461
|
// Iterate through each of the items.
|
|
486
462
|
_.each(items, (item, index) => {
|
|
487
463
|
// preventing references of the components inside the form to the parent form when building forms
|
|
488
|
-
if (this.root &&
|
|
489
|
-
this.root.options.editForm &&
|
|
490
|
-
this.root.options.editForm._id &&
|
|
491
|
-
this.root.options.editForm._id === item._id)
|
|
464
|
+
if (this.root && this.root.options.editForm && this.root.options.editForm._id && this.root.options.editForm._id === item._id)
|
|
492
465
|
return;
|
|
493
466
|
const itemValueAndLabel = this.selectValueAndLabel(item);
|
|
494
467
|
this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, _.get(item, this.component.idPath, String(index)));
|
|
@@ -508,7 +481,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
508
481
|
// If a value is provided, then select it.
|
|
509
482
|
if (!this.isEmpty() || this.isRemoveButtonPressed) {
|
|
510
483
|
this.setValue(this.dataValue, {
|
|
511
|
-
noUpdateEvent: true
|
|
484
|
+
noUpdateEvent: true
|
|
512
485
|
});
|
|
513
486
|
}
|
|
514
487
|
else if (this.shouldAddDefaultValue && !this.options.readOnly) {
|
|
@@ -534,17 +507,17 @@ export default class SelectComponent extends ListComponent {
|
|
|
534
507
|
return super.itemValueForHTMLMode(value);
|
|
535
508
|
}
|
|
536
509
|
if (Array.isArray(value)) {
|
|
537
|
-
const values = value.map(
|
|
510
|
+
const values = value.map(item => Array.isArray(item)
|
|
538
511
|
? this.itemValueForHTMLMode(item)
|
|
539
512
|
: this.getSingleItemValueForHTMLMode(item));
|
|
540
513
|
return values.join(', ');
|
|
541
514
|
}
|
|
542
515
|
return this.getSingleItemValueForHTMLMode(value);
|
|
543
516
|
}
|
|
517
|
+
/* eslint-enable max-statements */
|
|
544
518
|
get defaultValue() {
|
|
545
519
|
let defaultValue = super.defaultValue;
|
|
546
|
-
if (!defaultValue &&
|
|
547
|
-
(this.component.defaultValue === false || this.component.defaultValue === 0)) {
|
|
520
|
+
if (!defaultValue && (this.component.defaultValue === false || this.component.defaultValue === 0)) {
|
|
548
521
|
defaultValue = this.component.defaultValue;
|
|
549
522
|
}
|
|
550
523
|
return defaultValue;
|
|
@@ -563,7 +536,9 @@ export default class SelectComponent extends ListComponent {
|
|
|
563
536
|
}
|
|
564
537
|
// See if they have not met the minimum search requirements.
|
|
565
538
|
const minSearch = parseInt(this.component.minSearch, 10);
|
|
566
|
-
if (this.component.searchField &&
|
|
539
|
+
if (this.component.searchField &&
|
|
540
|
+
(minSearch > 0) &&
|
|
541
|
+
(!search || (search.length < minSearch))) {
|
|
567
542
|
// Set empty items.
|
|
568
543
|
return this.setItems([]);
|
|
569
544
|
}
|
|
@@ -574,19 +549,17 @@ export default class SelectComponent extends ListComponent {
|
|
|
574
549
|
}
|
|
575
550
|
const limit = this.component.limit || 100;
|
|
576
551
|
const skip = this.isScrollLoading ? this.selectOptions.length : 0;
|
|
577
|
-
const query = this.component.disableLimit
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
skip,
|
|
582
|
-
};
|
|
552
|
+
const query = this.component.disableLimit ? {} : {
|
|
553
|
+
limit,
|
|
554
|
+
skip,
|
|
555
|
+
};
|
|
583
556
|
// Allow for url interpolation.
|
|
584
557
|
url = this.sanitize(this.interpolate(url, {
|
|
585
558
|
formioBase: Formio.getBaseUrl(),
|
|
586
559
|
search,
|
|
587
560
|
limit,
|
|
588
561
|
skip,
|
|
589
|
-
page: Math.abs(Math.floor(skip / limit))
|
|
562
|
+
page: Math.abs(Math.floor(skip / limit))
|
|
590
563
|
}), this.shouldSanitizeValue);
|
|
591
564
|
// Add search capability.
|
|
592
565
|
if (this.component.searchField && search) {
|
|
@@ -609,9 +582,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
609
582
|
}
|
|
610
583
|
if (!_.isEmpty(query)) {
|
|
611
584
|
// Add the query string.
|
|
612
|
-
url +=
|
|
613
|
-
(!url.includes('?') ? '?' : '&') +
|
|
614
|
-
Formio.serialize(query, (item) => this.interpolate(item));
|
|
585
|
+
url += (!url.includes('?') ? '?' : '&') + Formio.serialize(query, (item) => this.interpolate(item));
|
|
615
586
|
}
|
|
616
587
|
// Add filter capability
|
|
617
588
|
if (this.component.filter) {
|
|
@@ -672,7 +643,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
672
643
|
}
|
|
673
644
|
getCustomItems() {
|
|
674
645
|
const customItems = this.evaluate(this.component.data.custom, {
|
|
675
|
-
values: []
|
|
646
|
+
values: []
|
|
676
647
|
}, 'values');
|
|
677
648
|
this.asyncValues = isPromise(customItems);
|
|
678
649
|
return customItems;
|
|
@@ -691,11 +662,11 @@ export default class SelectComponent extends ListComponent {
|
|
|
691
662
|
}
|
|
692
663
|
this.loading = true;
|
|
693
664
|
this.getCustomItems()
|
|
694
|
-
.then(
|
|
665
|
+
.then(items => {
|
|
695
666
|
this.loading = false;
|
|
696
667
|
this.setItems(items || []);
|
|
697
668
|
})
|
|
698
|
-
.catch(
|
|
669
|
+
.catch(err => {
|
|
699
670
|
this.handleLoadingError(err);
|
|
700
671
|
});
|
|
701
672
|
}
|
|
@@ -707,13 +678,13 @@ export default class SelectComponent extends ListComponent {
|
|
|
707
678
|
return super.isEmpty(value) || value === undefined;
|
|
708
679
|
}
|
|
709
680
|
refresh(value, { instance }) {
|
|
710
|
-
if (this.component.clearOnRefresh && instance && !instance.pristine) {
|
|
681
|
+
if (this.component.clearOnRefresh && (instance && !instance.pristine)) {
|
|
711
682
|
this.setValue(this.emptyValue);
|
|
712
683
|
}
|
|
713
684
|
this.updateItems(null, true);
|
|
714
685
|
}
|
|
715
686
|
get additionalResourcesAvailable() {
|
|
716
|
-
return _.isNil(this.serverCount) || this.serverCount > this.downloadedResources.length;
|
|
687
|
+
return _.isNil(this.serverCount) || (this.serverCount > this.downloadedResources.length);
|
|
717
688
|
}
|
|
718
689
|
get serverCount() {
|
|
719
690
|
if (this.isFromSearch) {
|
|
@@ -765,22 +736,18 @@ export default class SelectComponent extends ListComponent {
|
|
|
765
736
|
setLoadingItem(addToCurrentList = false) {
|
|
766
737
|
if (this.choices) {
|
|
767
738
|
if (addToCurrentList) {
|
|
768
|
-
this.choices.setChoices([
|
|
769
|
-
{
|
|
739
|
+
this.choices.setChoices([{
|
|
770
740
|
value: `${this.id}-loading`,
|
|
771
741
|
label: 'Loading...',
|
|
772
742
|
disabled: true,
|
|
773
|
-
},
|
|
774
|
-
], 'value', 'label');
|
|
743
|
+
}], 'value', 'label');
|
|
775
744
|
}
|
|
776
745
|
else {
|
|
777
|
-
this.choices.setChoices([
|
|
778
|
-
{
|
|
746
|
+
this.choices.setChoices([{
|
|
779
747
|
value: '',
|
|
780
748
|
label: `<i class="${this.iconClass('refresh')}" style="font-size:1.3em;"></i>`,
|
|
781
749
|
disabled: true,
|
|
782
|
-
},
|
|
783
|
-
], 'value', 'label', true);
|
|
750
|
+
}], 'value', 'label', true);
|
|
784
751
|
}
|
|
785
752
|
}
|
|
786
753
|
else if (this.component.dataSrc === 'url' || this.component.dataSrc === 'resource') {
|
|
@@ -802,15 +769,13 @@ export default class SelectComponent extends ListComponent {
|
|
|
802
769
|
}
|
|
803
770
|
wrapElement(element) {
|
|
804
771
|
return this.component.addResource && !this.options.readOnly
|
|
805
|
-
? this.renderTemplate('resourceAdd', {
|
|
806
|
-
element
|
|
807
|
-
})
|
|
772
|
+
? (this.renderTemplate('resourceAdd', {
|
|
773
|
+
element
|
|
774
|
+
}))
|
|
808
775
|
: element;
|
|
809
776
|
}
|
|
810
777
|
choicesOptions() {
|
|
811
|
-
const useSearch = this.component.hasOwnProperty('searchEnabled')
|
|
812
|
-
? this.component.searchEnabled
|
|
813
|
-
: true;
|
|
778
|
+
const useSearch = this.component.hasOwnProperty('searchEnabled') ? this.component.searchEnabled : true;
|
|
814
779
|
const placeholderValue = this.t(this.component.placeholder, { _userInput: true });
|
|
815
780
|
let customOptions = this.component.customOptions || {};
|
|
816
781
|
if (typeof customOptions == 'string') {
|
|
@@ -827,16 +792,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
827
792
|
distance: 1000,
|
|
828
793
|
};
|
|
829
794
|
return {
|
|
830
|
-
removeItemButton: this.component.disabled
|
|
831
|
-
? false
|
|
832
|
-
: _.get(this.component, 'removeItemButton', true),
|
|
795
|
+
removeItemButton: this.component.disabled ? false : _.get(this.component, 'removeItemButton', true),
|
|
833
796
|
itemSelectText: '',
|
|
834
797
|
classNames: {
|
|
835
|
-
containerOuter: [
|
|
836
|
-
'choices',
|
|
837
|
-
'form-group',
|
|
838
|
-
'formio-choices',
|
|
839
|
-
],
|
|
798
|
+
containerOuter: ['choices', 'form-group', 'formio-choices'],
|
|
840
799
|
containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
|
|
841
800
|
},
|
|
842
801
|
addItemText: false,
|
|
@@ -847,23 +806,21 @@ export default class SelectComponent extends ListComponent {
|
|
|
847
806
|
noChoicesText: this.t('No choices to choose from'),
|
|
848
807
|
searchPlaceholderValue: this.t('Type to search'),
|
|
849
808
|
shouldSort: false,
|
|
850
|
-
position: this.component.dropdown || 'auto',
|
|
809
|
+
position: (this.component.dropdown || 'auto'),
|
|
851
810
|
searchEnabled: useSearch,
|
|
852
811
|
searchChoices: !this.component.searchField,
|
|
853
|
-
searchFields: _.get(this, 'component.searchFields', [
|
|
854
|
-
'label',
|
|
855
|
-
]),
|
|
812
|
+
searchFields: _.get(this, 'component.searchFields', ['label']),
|
|
856
813
|
shadowRoot: this.root ? this.root.shadowRoot : null,
|
|
857
814
|
fuseOptions: this.component.useExactSearch
|
|
858
815
|
? {
|
|
859
816
|
tokenize: true,
|
|
860
817
|
matchAllTokens: true,
|
|
861
|
-
...commonFuseOptions
|
|
818
|
+
...commonFuseOptions
|
|
862
819
|
}
|
|
863
820
|
: Object.assign({}, _.get(this, 'component.fuseOptions', {}), {
|
|
864
821
|
include: 'score',
|
|
865
822
|
threshold: _.get(this, 'component.selectThreshold', 0.3),
|
|
866
|
-
...commonFuseOptions
|
|
823
|
+
...commonFuseOptions
|
|
867
824
|
}),
|
|
868
825
|
valueComparer: _.isEqual,
|
|
869
826
|
resetScrollPosition: false,
|
|
@@ -871,12 +828,13 @@ export default class SelectComponent extends ListComponent {
|
|
|
871
828
|
...customOptions,
|
|
872
829
|
};
|
|
873
830
|
}
|
|
831
|
+
/* eslint-disable max-statements */
|
|
874
832
|
attach(element) {
|
|
875
833
|
const superAttach = super.attach(element);
|
|
876
834
|
this.loadRefs(element, {
|
|
877
835
|
selectContainer: 'single',
|
|
878
836
|
addResource: 'single',
|
|
879
|
-
autocompleteInput: 'single'
|
|
837
|
+
autocompleteInput: 'single'
|
|
880
838
|
});
|
|
881
839
|
//enable autocomplete for select
|
|
882
840
|
const autocompleteInput = this.refs.autocompleteInput;
|
|
@@ -889,18 +847,9 @@ export default class SelectComponent extends ListComponent {
|
|
|
889
847
|
if (!input) {
|
|
890
848
|
return;
|
|
891
849
|
}
|
|
892
|
-
this.addEventListener(input, this.inputInfo.changeEvent, (
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
value = event.target.value;
|
|
896
|
-
if (this.component.multiple) {
|
|
897
|
-
value = Array.from(event.target.selectedOptions).map(opt => opt.value);
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
this.updateValue(value, {
|
|
901
|
-
modified: true
|
|
902
|
-
});
|
|
903
|
-
});
|
|
850
|
+
this.addEventListener(input, this.inputInfo.changeEvent, () => this.updateValue(null, {
|
|
851
|
+
modified: true
|
|
852
|
+
}));
|
|
904
853
|
this.attachRefreshOnBlur();
|
|
905
854
|
if (this.component.widget === 'html5') {
|
|
906
855
|
this.addFocusBlurEvents(input);
|
|
@@ -914,10 +863,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
914
863
|
}
|
|
915
864
|
this.addEventListener(input, 'keydown', (event) => {
|
|
916
865
|
const { key } = event;
|
|
917
|
-
if ([
|
|
918
|
-
'Backspace',
|
|
919
|
-
'Delete',
|
|
920
|
-
].includes(key)) {
|
|
866
|
+
if (['Backspace', 'Delete'].includes(key)) {
|
|
921
867
|
this.setValue(this.emptyValue);
|
|
922
868
|
}
|
|
923
869
|
});
|
|
@@ -984,10 +930,8 @@ export default class SelectComponent extends ListComponent {
|
|
|
984
930
|
this.isFromSearch = false;
|
|
985
931
|
});
|
|
986
932
|
// avoid spamming the resource/url endpoint when we have server side filtering enabled.
|
|
987
|
-
const debounceTimeout = this.component.searchField && (this.isSelectResource || this.isSelectURL)
|
|
988
|
-
|
|
989
|
-
? 0
|
|
990
|
-
: this.component.searchDebounce || this.defaultSchema.searchDebounce) * 1000
|
|
933
|
+
const debounceTimeout = this.component.searchField && (this.isSelectResource || this.isSelectURL) ?
|
|
934
|
+
(this.component.searchDebounce === 0 ? 0 : this.component.searchDebounce || this.defaultSchema.searchDebounce) * 1000
|
|
991
935
|
: 0;
|
|
992
936
|
const updateComponent = (evt) => {
|
|
993
937
|
this.triggerUpdate(evt.detail.value);
|
|
@@ -1014,9 +958,8 @@ export default class SelectComponent extends ListComponent {
|
|
|
1014
958
|
});
|
|
1015
959
|
}
|
|
1016
960
|
// Add value options.
|
|
1017
|
-
const value = this.undoValueTyping(this.dataValue);
|
|
1018
961
|
this.addValueOptions();
|
|
1019
|
-
this.setChoicesValue(
|
|
962
|
+
this.setChoicesValue(this.dataValue);
|
|
1020
963
|
if (this.isSelectResource && this.refs.addResource) {
|
|
1021
964
|
this.addEventListener(this.refs.addResource, 'click', (event) => {
|
|
1022
965
|
event.preventDefault();
|
|
@@ -1024,15 +967,13 @@ export default class SelectComponent extends ListComponent {
|
|
|
1024
967
|
const dialog = this.createModal(formioForm);
|
|
1025
968
|
const projectUrl = _.get(this.root, 'formio.projectUrl', Formio.getProjectUrl());
|
|
1026
969
|
const formUrl = `${projectUrl}/form/${this.component.data.resource}`;
|
|
1027
|
-
new Form(formioForm, formUrl, {}).ready
|
|
970
|
+
new Form(formioForm, formUrl, {}).ready
|
|
971
|
+
.then((form) => {
|
|
1028
972
|
form.on('submit', (submission) => {
|
|
1029
973
|
// If valueProperty is set, replace the submission with the corresponding value
|
|
1030
974
|
let value = this.valueProperty ? _.get(submission, this.valueProperty) : submission;
|
|
1031
975
|
if (this.component.multiple) {
|
|
1032
|
-
value = [
|
|
1033
|
-
...this.dataValue,
|
|
1034
|
-
value,
|
|
1035
|
-
];
|
|
976
|
+
value = [...this.dataValue, value];
|
|
1036
977
|
}
|
|
1037
978
|
this.setValue(value);
|
|
1038
979
|
this.triggerUpdate();
|
|
@@ -1076,9 +1017,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1076
1017
|
}
|
|
1077
1018
|
}
|
|
1078
1019
|
positionDropdown(scroll) {
|
|
1079
|
-
if (!this.shouldPositionDropdown ||
|
|
1080
|
-
!this.choices ||
|
|
1081
|
-
(!this.choices.dropdown?.isActive && scroll)) {
|
|
1020
|
+
if (!this.shouldPositionDropdown || !this.choices || (!this.choices.dropdown?.isActive && scroll)) {
|
|
1082
1021
|
return;
|
|
1083
1022
|
}
|
|
1084
1023
|
this.setDropdownPosition();
|
|
@@ -1099,12 +1038,11 @@ export default class SelectComponent extends ListComponent {
|
|
|
1099
1038
|
attachRefreshOnBlur() {
|
|
1100
1039
|
if (this.component.refreshOnBlur) {
|
|
1101
1040
|
this.on('blur', (instance) => {
|
|
1102
|
-
this.checkRefreshOn([
|
|
1103
|
-
{ instance, value: instance.dataValue },
|
|
1104
|
-
], { fromBlur: true });
|
|
1041
|
+
this.checkRefreshOn([{ instance, value: instance.dataValue }], { fromBlur: true });
|
|
1105
1042
|
});
|
|
1106
1043
|
}
|
|
1107
1044
|
}
|
|
1045
|
+
/* eslint-enable max-statements */
|
|
1108
1046
|
update() {
|
|
1109
1047
|
if (this.component.dataSrc === 'custom') {
|
|
1110
1048
|
this.updateCustomItems();
|
|
@@ -1133,7 +1071,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1133
1071
|
}
|
|
1134
1072
|
set visible(value) {
|
|
1135
1073
|
// If we go from hidden to visible, trigger a refresh.
|
|
1136
|
-
if (value && !this._visible !== !value) {
|
|
1074
|
+
if (value && (!this._visible !== !value)) {
|
|
1137
1075
|
this.triggerUpdate();
|
|
1138
1076
|
}
|
|
1139
1077
|
super.visible = value;
|
|
@@ -1160,7 +1098,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1160
1098
|
const isSelectOptions = items === this.selectOptions;
|
|
1161
1099
|
if (items && items.length) {
|
|
1162
1100
|
_.each(items, (choice) => {
|
|
1163
|
-
if (choice._id && value._id && choice._id === value._id) {
|
|
1101
|
+
if (choice._id && value._id && (choice._id === value._id)) {
|
|
1164
1102
|
found = true;
|
|
1165
1103
|
return false;
|
|
1166
1104
|
}
|
|
@@ -1180,23 +1118,22 @@ export default class SelectComponent extends ListComponent {
|
|
|
1180
1118
|
if (this.choices) {
|
|
1181
1119
|
this.choices.setChoices(notFoundValuesToAdd, 'value', 'label');
|
|
1182
1120
|
}
|
|
1183
|
-
notFoundValuesToAdd.map(
|
|
1121
|
+
notFoundValuesToAdd.map(notFoundValue => {
|
|
1184
1122
|
this.addOption(notFoundValue.value, notFoundValue.label);
|
|
1185
1123
|
});
|
|
1186
1124
|
}
|
|
1187
1125
|
return added;
|
|
1188
1126
|
}
|
|
1189
1127
|
getValueAsString(data, options) {
|
|
1190
|
-
return this.component.multiple && Array.isArray(data)
|
|
1128
|
+
return (this.component.multiple && Array.isArray(data))
|
|
1191
1129
|
? data.map((v) => this.asString(v, options)).join(', ')
|
|
1192
1130
|
: this.asString(data, options);
|
|
1193
1131
|
}
|
|
1194
1132
|
getValue() {
|
|
1195
1133
|
// If the widget isn't active.
|
|
1196
|
-
if (this.viewOnly ||
|
|
1197
|
-
this.
|
|
1198
|
-
|
|
1199
|
-
!this.element) {
|
|
1134
|
+
if (this.viewOnly || this.loading
|
|
1135
|
+
|| (!this.component.lazyLoad && !this.selectOptions.length)
|
|
1136
|
+
|| !this.element) {
|
|
1200
1137
|
return this.dataValue;
|
|
1201
1138
|
}
|
|
1202
1139
|
let value = this.emptyValue;
|
|
@@ -1205,7 +1142,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1205
1142
|
// Make sure we don't get the placeholder
|
|
1206
1143
|
if (!this.component.multiple &&
|
|
1207
1144
|
this.component.placeholder &&
|
|
1208
|
-
value === this.t(this.component.placeholder, { _userInput: true })) {
|
|
1145
|
+
(value === this.t(this.component.placeholder, { _userInput: true }))) {
|
|
1209
1146
|
value = this.emptyValue;
|
|
1210
1147
|
}
|
|
1211
1148
|
}
|
|
@@ -1215,7 +1152,8 @@ export default class SelectComponent extends ListComponent {
|
|
|
1215
1152
|
if (value === '') {
|
|
1216
1153
|
return {};
|
|
1217
1154
|
}
|
|
1218
|
-
const option = this.selectOptions[value] ||
|
|
1155
|
+
const option = this.selectOptions[value] ||
|
|
1156
|
+
this.selectOptions.find(option => option.id === value);
|
|
1219
1157
|
if (option && _.isObject(option.value)) {
|
|
1220
1158
|
value = option.value;
|
|
1221
1159
|
}
|
|
@@ -1250,18 +1188,16 @@ export default class SelectComponent extends ListComponent {
|
|
|
1250
1188
|
number() {
|
|
1251
1189
|
const numberValue = Number(this.value);
|
|
1252
1190
|
const isEquivalent = value.toString() === numberValue.toString();
|
|
1253
|
-
if (!Number.isNaN(numberValue) &&
|
|
1254
|
-
Number.isFinite(numberValue) &&
|
|
1255
|
-
value !== '' &&
|
|
1256
|
-
isEquivalent) {
|
|
1191
|
+
if (!Number.isNaN(numberValue) && Number.isFinite(numberValue) && value !== '' && isEquivalent) {
|
|
1257
1192
|
this.value = numberValue;
|
|
1258
1193
|
}
|
|
1259
1194
|
return this;
|
|
1260
1195
|
},
|
|
1261
1196
|
boolean() {
|
|
1262
|
-
if (_.isString(this.value)
|
|
1263
|
-
(this.value.toLowerCase() === 'true'
|
|
1264
|
-
|
|
1197
|
+
if (_.isString(this.value)
|
|
1198
|
+
&& (this.value.toLowerCase() === 'true'
|
|
1199
|
+
|| this.value.toLowerCase() === 'false')) {
|
|
1200
|
+
this.value = (this.value.toLowerCase() === 'true');
|
|
1265
1201
|
}
|
|
1266
1202
|
return this;
|
|
1267
1203
|
},
|
|
@@ -1280,7 +1216,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1280
1216
|
this.value = this.string().number().boolean().value;
|
|
1281
1217
|
}
|
|
1282
1218
|
return this;
|
|
1283
|
-
}
|
|
1219
|
+
}
|
|
1284
1220
|
};
|
|
1285
1221
|
try {
|
|
1286
1222
|
return normalize[dataType]().value;
|
|
@@ -1313,11 +1249,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1313
1249
|
// Check to see if we need to save off the template data into our metadata.
|
|
1314
1250
|
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
|
|
1315
1251
|
const shouldSaveData = (!valueIsObject || this.component.reference) && !this.inDataTable;
|
|
1316
|
-
if (!_.isNil(templateValue) &&
|
|
1317
|
-
shouldSaveData &&
|
|
1318
|
-
this.templateData &&
|
|
1319
|
-
this.templateData[templateValue] &&
|
|
1320
|
-
this.root?.submission) {
|
|
1252
|
+
if (!_.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
|
|
1321
1253
|
const submission = this.root.submission;
|
|
1322
1254
|
if (!submission.metadata) {
|
|
1323
1255
|
submission.metadata = {};
|
|
@@ -1331,9 +1263,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1331
1263
|
const dataValue = this.dataValue;
|
|
1332
1264
|
if (dataValue && _.isArray(dataValue) && dataValue.length) {
|
|
1333
1265
|
dataValue.forEach((dataValueItem) => {
|
|
1334
|
-
const dataValueItemValue = this.component.reference
|
|
1335
|
-
? dataValueItem._id.toString()
|
|
1336
|
-
: dataValueItem;
|
|
1266
|
+
const dataValueItemValue = this.component.reference ? dataValueItem._id.toString() : dataValueItem;
|
|
1337
1267
|
templateData[dataValueItemValue] = this.templateData[dataValueItemValue];
|
|
1338
1268
|
});
|
|
1339
1269
|
}
|
|
@@ -1353,7 +1283,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1353
1283
|
const changed = super.updateValue(value, flags);
|
|
1354
1284
|
if (changed || !this.selectMetadata || flags.resetValue) {
|
|
1355
1285
|
if (this.component.multiple && Array.isArray(this.dataValue)) {
|
|
1356
|
-
this.dataValue.forEach(
|
|
1286
|
+
this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
|
|
1357
1287
|
}
|
|
1358
1288
|
else {
|
|
1359
1289
|
this.setMetadata(this.dataValue, flags);
|
|
@@ -1364,7 +1294,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1364
1294
|
undoValueTyping(value) {
|
|
1365
1295
|
let untypedValue = value;
|
|
1366
1296
|
if (this.component.multiple && Array.isArray(value)) {
|
|
1367
|
-
untypedValue = value.map(
|
|
1297
|
+
untypedValue = value.map(v => {
|
|
1368
1298
|
if (typeof v === 'boolean' || typeof v === 'number') {
|
|
1369
1299
|
return v.toString();
|
|
1370
1300
|
}
|
|
@@ -1381,9 +1311,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1381
1311
|
setValue(value, flags = {}) {
|
|
1382
1312
|
const previousValue = this.dataValue;
|
|
1383
1313
|
const changed = this.updateValue(value, flags);
|
|
1384
|
-
if (this.component.widget === 'html5' &&
|
|
1385
|
-
(_.isEqual(value, previousValue) || (_.isEqual(previousValue, {}) && _.isEqual(flags, {}))) &&
|
|
1386
|
-
!flags.fromSubmission) {
|
|
1314
|
+
if (this.component.widget === 'html5' && (_.isEqual(value, previousValue) || _.isEqual(previousValue, {}) && _.isEqual(flags, {})) && !flags.fromSubmission) {
|
|
1387
1315
|
return false;
|
|
1388
1316
|
}
|
|
1389
1317
|
value = this.dataValue;
|
|
@@ -1407,9 +1335,6 @@ export default class SelectComponent extends ListComponent {
|
|
|
1407
1335
|
this.lazyLoadInit = true;
|
|
1408
1336
|
const searchProperty = this.component.searchField || this.component.valueProperty;
|
|
1409
1337
|
this.triggerUpdate(_.get(value.data || value, searchProperty, value), true);
|
|
1410
|
-
this.itemsLoaded.then(() => {
|
|
1411
|
-
this.setChoicesValue(value, hasPreviousValue, flags);
|
|
1412
|
-
});
|
|
1413
1338
|
return changed;
|
|
1414
1339
|
}
|
|
1415
1340
|
// Add the value options.
|
|
@@ -1420,28 +1345,23 @@ export default class SelectComponent extends ListComponent {
|
|
|
1420
1345
|
return changed;
|
|
1421
1346
|
}
|
|
1422
1347
|
isInitApiCallNeeded(hasValue) {
|
|
1423
|
-
return
|
|
1348
|
+
return this.component.lazyLoad &&
|
|
1424
1349
|
!this.lazyLoadInit &&
|
|
1425
1350
|
!this.active &&
|
|
1426
1351
|
!this.selectOptions.length &&
|
|
1427
1352
|
hasValue &&
|
|
1428
1353
|
this.shouldInitialLoad &&
|
|
1429
|
-
this.visible &&
|
|
1430
|
-
(this.component.searchField || this.component.valueProperty));
|
|
1354
|
+
this.visible && (this.component.searchField || this.component.valueProperty);
|
|
1431
1355
|
}
|
|
1432
1356
|
setChoicesValue(value, hasPreviousValue, flags = {}) {
|
|
1433
1357
|
const hasValue = !this.isEmpty(value) || flags.fromSubmission;
|
|
1434
|
-
hasPreviousValue = hasPreviousValue === undefined ? true : hasPreviousValue;
|
|
1358
|
+
hasPreviousValue = (hasPreviousValue === undefined) ? true : hasPreviousValue;
|
|
1435
1359
|
if (this.choices) {
|
|
1436
1360
|
// Now set the value.
|
|
1437
1361
|
if (hasValue) {
|
|
1438
1362
|
this.choices.removeActiveItems();
|
|
1439
1363
|
// Add the currently selected choices if they don't already exist.
|
|
1440
|
-
const currentChoices = Array.isArray(value) && this.component.multiple
|
|
1441
|
-
? value
|
|
1442
|
-
: [
|
|
1443
|
-
value,
|
|
1444
|
-
];
|
|
1364
|
+
const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];
|
|
1445
1365
|
if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {
|
|
1446
1366
|
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
|
1447
1367
|
}
|
|
@@ -1453,13 +1373,9 @@ export default class SelectComponent extends ListComponent {
|
|
|
1453
1373
|
}
|
|
1454
1374
|
else {
|
|
1455
1375
|
if (hasValue) {
|
|
1456
|
-
const values = Array.isArray(value)
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
value,
|
|
1460
|
-
];
|
|
1461
|
-
if ((!_.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2) ||
|
|
1462
|
-
(this.selectData && flags.fromSubmission)) {
|
|
1376
|
+
const values = Array.isArray(value) ? value : [value];
|
|
1377
|
+
if (!_.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2
|
|
1378
|
+
|| (this.selectData && flags.fromSubmission)) {
|
|
1463
1379
|
const { value, label } = this.selectValueAndLabel(this.dataValue);
|
|
1464
1380
|
this.addOption(value, label);
|
|
1465
1381
|
}
|
|
@@ -1499,7 +1415,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1499
1415
|
return false;
|
|
1500
1416
|
}
|
|
1501
1417
|
try {
|
|
1502
|
-
return JSON.stringify(normalizedOptionValue) === JSON.stringify(value);
|
|
1418
|
+
return (JSON.stringify(normalizedOptionValue) === JSON.stringify(value));
|
|
1503
1419
|
}
|
|
1504
1420
|
catch (err) {
|
|
1505
1421
|
console.warn.error('Error while comparing items', err);
|
|
@@ -1508,7 +1424,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1508
1424
|
};
|
|
1509
1425
|
return values.findIndex((optionValue) => compareComplexValues(optionValue)) !== -1;
|
|
1510
1426
|
}
|
|
1511
|
-
return
|
|
1427
|
+
return values.findIndex((optionValue) => this.normalizeSingleValue(optionValue) === value) !== -1;
|
|
1512
1428
|
}
|
|
1513
1429
|
return false;
|
|
1514
1430
|
}
|
|
@@ -1567,7 +1483,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1567
1483
|
*/
|
|
1568
1484
|
deleteValue() {
|
|
1569
1485
|
this.setValue('', {
|
|
1570
|
-
noUpdateEvent: true
|
|
1486
|
+
noUpdateEvent: true
|
|
1571
1487
|
});
|
|
1572
1488
|
this.unset();
|
|
1573
1489
|
}
|
|
@@ -1590,10 +1506,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1590
1506
|
if (!this.component || !this.component.data || !this.component.data.values) {
|
|
1591
1507
|
return;
|
|
1592
1508
|
}
|
|
1593
|
-
return this.component.data.values.map(
|
|
1594
|
-
label: value.label,
|
|
1595
|
-
value: String(this.normalizeSingleValue(value.value)),
|
|
1596
|
-
}));
|
|
1509
|
+
return this.component.data.values.map(value => ({ label: value.label, value: String(this.normalizeSingleValue(value.value)) }));
|
|
1597
1510
|
}
|
|
1598
1511
|
asString(value, options = {}) {
|
|
1599
1512
|
value = value ?? this.getValue();
|
|
@@ -1601,7 +1514,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1601
1514
|
if (this.inDataTable) {
|
|
1602
1515
|
value = this.undoValueTyping(value);
|
|
1603
1516
|
}
|
|
1604
|
-
const templateValue = this.isEntireObjectDisplay() && !_.isObject(value.data) ? { data: value } : value;
|
|
1517
|
+
const templateValue = (this.isEntireObjectDisplay() && !_.isObject(value.data)) ? { data: value } : value;
|
|
1605
1518
|
const template = this.itemTemplate(templateValue, value, options);
|
|
1606
1519
|
return template;
|
|
1607
1520
|
}
|
|
@@ -1609,7 +1522,7 @@ export default class SelectComponent extends ListComponent {
|
|
|
1609
1522
|
const convertToString = (data, valueProperty) => {
|
|
1610
1523
|
if (valueProperty) {
|
|
1611
1524
|
if (Array.isArray(data)) {
|
|
1612
|
-
data.forEach((item) =>
|
|
1525
|
+
data.forEach((item) => item[valueProperty] = item[valueProperty].toString());
|
|
1613
1526
|
}
|
|
1614
1527
|
else if (_.isObject(data)) {
|
|
1615
1528
|
data[valueProperty] = data[valueProperty].toString();
|
|
@@ -1619,18 +1532,14 @@ export default class SelectComponent extends ListComponent {
|
|
|
1619
1532
|
if (this.isBooleanOrNumber(data)) {
|
|
1620
1533
|
data = data.toString();
|
|
1621
1534
|
}
|
|
1622
|
-
if (Array.isArray(data) && data.some(
|
|
1623
|
-
data = data.map(
|
|
1535
|
+
if (Array.isArray(data) && data.some(item => this.isBooleanOrNumber(item))) {
|
|
1536
|
+
data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);
|
|
1624
1537
|
}
|
|
1625
1538
|
return data;
|
|
1626
1539
|
};
|
|
1627
1540
|
value = convertToString(value);
|
|
1628
|
-
if ([
|
|
1629
|
-
'values'
|
|
1630
|
-
'custom',
|
|
1631
|
-
].includes(this.component.dataSrc) &&
|
|
1632
|
-
!this.asyncCustomValues()) {
|
|
1633
|
-
const { items, valueProperty } = this.component.dataSrc === 'values'
|
|
1541
|
+
if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {
|
|
1542
|
+
const { items, valueProperty, } = this.component.dataSrc === 'values'
|
|
1634
1543
|
? {
|
|
1635
1544
|
items: convertToString(this.getNormalizedValues(), 'value'),
|
|
1636
1545
|
valueProperty: 'value',
|
|
@@ -1640,30 +1549,28 @@ export default class SelectComponent extends ListComponent {
|
|
|
1640
1549
|
valueProperty: this.valueProperty,
|
|
1641
1550
|
};
|
|
1642
1551
|
const getFromValues = () => {
|
|
1643
|
-
const initialValue = _.find(items, [
|
|
1644
|
-
valueProperty,
|
|
1645
|
-
value,
|
|
1646
|
-
]);
|
|
1552
|
+
const initialValue = _.find(items, [valueProperty, value]);
|
|
1647
1553
|
const values = this.defaultSchema.data.values || [];
|
|
1648
1554
|
return _.isEqual(initialValue, values[0]) ? '-' : initialValue;
|
|
1649
1555
|
};
|
|
1650
|
-
value =
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
:
|
|
1654
|
-
|
|
1655
|
-
: value;
|
|
1556
|
+
value = (this.component.multiple && Array.isArray(value))
|
|
1557
|
+
? _.filter(items, (item) => value.includes(item.value))
|
|
1558
|
+
: (valueProperty && items)
|
|
1559
|
+
? getFromValues() ?? { value, label: value }
|
|
1560
|
+
: value;
|
|
1656
1561
|
}
|
|
1657
1562
|
if (_.isString(value)) {
|
|
1658
1563
|
return value;
|
|
1659
1564
|
}
|
|
1660
1565
|
const getTemplateValue = (v) => {
|
|
1661
1566
|
const itemTemplate = this.itemTemplate(v);
|
|
1662
|
-
return options.csv && itemTemplate
|
|
1567
|
+
return options.csv && itemTemplate
|
|
1568
|
+
? removeHTML(itemTemplate)
|
|
1569
|
+
: itemTemplate;
|
|
1663
1570
|
};
|
|
1664
1571
|
if (Array.isArray(value)) {
|
|
1665
1572
|
const items = [];
|
|
1666
|
-
value.forEach(
|
|
1573
|
+
value.forEach(item => items.push(getTemplateValue(item)));
|
|
1667
1574
|
if (this.component.dataSrc === 'resource' && items.length > 0) {
|
|
1668
1575
|
return items.join(', ');
|
|
1669
1576
|
}
|
|
@@ -1677,7 +1584,9 @@ export default class SelectComponent extends ListComponent {
|
|
|
1677
1584
|
if (this.isEntireObjectDisplay() && _.isObject(value)) {
|
|
1678
1585
|
return JSON.stringify(value);
|
|
1679
1586
|
}
|
|
1680
|
-
return !_.isNil(value)
|
|
1587
|
+
return !_.isNil(value)
|
|
1588
|
+
? getTemplateValue(value)
|
|
1589
|
+
: '-';
|
|
1681
1590
|
}
|
|
1682
1591
|
detach() {
|
|
1683
1592
|
this.off('blur');
|
|
@@ -1698,14 +1607,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
1698
1607
|
setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {
|
|
1699
1608
|
super.setErrorClasses(elements, dirty, hasError, hasMessages, element);
|
|
1700
1609
|
if (this.choices) {
|
|
1701
|
-
super.setErrorClasses([
|
|
1702
|
-
this.choices.containerInner.element,
|
|
1703
|
-
], dirty, hasError, hasMessages, element);
|
|
1610
|
+
super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);
|
|
1704
1611
|
}
|
|
1705
1612
|
else {
|
|
1706
|
-
super.setErrorClasses([
|
|
1707
|
-
this.refs.selectContainer,
|
|
1708
|
-
], dirty, hasError, hasMessages, element);
|
|
1613
|
+
super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);
|
|
1709
1614
|
}
|
|
1710
1615
|
}
|
|
1711
1616
|
}
|