@lion/ui 0.23.0 → 0.25.0
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/README.md +50 -20
- package/components/accordion/src/LionAccordion.js +31 -42
- package/components/accordion/test/lion-accordion.test.js +108 -134
- package/components/button/src/LionButton.js +9 -12
- package/components/button/src/LionButtonReset.js +0 -5
- package/components/button/src/LionButtonSubmit.js +7 -12
- package/components/button/test/demos.screenshots-test.js +50 -11
- package/components/button/test/lion-button.test.js +0 -1
- package/components/button/test-suites/LionButton.suite.js +135 -145
- package/components/button/test-suites/LionButtonReset.suite.js +54 -72
- package/components/button/test-suites/LionButtonSubmit.suite.js +49 -68
- package/components/calendar/src/LionCalendar.js +151 -104
- package/components/calendar/src/calendarStyle.js +0 -1
- package/components/calendar/src/utils/createMonth.js +3 -4
- package/components/calendar/src/utils/createMultipleMonth.js +15 -7
- package/components/calendar/src/utils/createWeek.js +0 -2
- package/components/calendar/src/utils/dataTemplate.js +8 -4
- package/components/calendar/src/utils/dayTemplate.js +0 -6
- package/components/calendar/src/utils/getDayMonthYear.js +6 -2
- package/components/calendar/test/demos.screenshots-test.js +40 -9
- package/components/calendar/test/lion-calendar.test.js +171 -282
- package/components/calendar/test/utils/createMonth.test.js +61 -22
- package/components/calendar/test/utils/createMultipleMonth.test.js +14 -7
- package/components/calendar/test/utils/createWeek.test.js +51 -17
- package/components/calendar/test/utils/dataTemplate.test.js +3 -4
- package/components/calendar/test/utils/dayTemplate.test.js +106 -34
- package/components/calendar/test/utils/getFirstDayNextMonth.test.js +0 -1
- package/components/calendar/test/utils/getLastDayPreviousMonth.test.js +0 -1
- package/components/calendar/test/utils/isSameDate.test.js +0 -1
- package/components/calendar/test/utils/snapshots/monthTemplate_en-GB_Sunday_2018-12.js +1 -2
- package/components/calendar/test-helpers/CalendarObject.js +31 -62
- package/components/calendar/test-helpers/DayObject.js +7 -15
- package/components/calendar/test-suites/LionCalendar.suite.js +7 -9
- package/components/checkbox-group/src/LionCheckboxIndeterminate.js +17 -30
- package/components/checkbox-group/test/lion-checkbox-group-integrations.test.js +0 -1
- package/components/checkbox-group/test/lion-checkbox-group.test.js +21 -16
- package/components/checkbox-group/test/lion-checkbox-indeterminate-integrations.test.js +3 -3
- package/components/checkbox-group/test/lion-checkbox-integrations.test.js +3 -2
- package/components/checkbox-group/test/lion-checkbox.test.js +30 -16
- package/components/checkbox-group/test-suites/CheckboxIndeterminate.suite.js +147 -191
- package/components/collapsible/src/LionCollapsible.js +10 -15
- package/components/collapsible/test/lion-collapsible.test.js +4 -18
- package/components/combobox/src/LionCombobox.js +35 -53
- package/components/combobox/src/utils/makeMatchingTextBold.js +2 -5
- package/components/combobox/src/validators.js +0 -1
- package/components/combobox/test/lion-combobox-integrations.test.js +6 -6
- package/components/combobox/test/lion-combobox.test.js +576 -869
- package/components/combobox/test/validators.test.js +6 -13
- package/components/combobox/test-helpers/combobox-helpers.js +24 -11
- package/components/core/src/DisabledMixin.js +61 -66
- package/components/core/src/DisabledWithTabIndexMixin.js +76 -83
- package/components/core/src/EventTargetShim.js +1 -4
- package/components/core/src/ScopedElementsMixin.js +4 -15
- package/components/core/src/ScopedStylesController.js +1 -5
- package/components/core/src/SlotMixin.js +236 -239
- package/components/core/src/browserDetection.js +5 -12
- package/components/core/test/DisabledMixin.test.js +24 -39
- package/components/core/test/DisabledWithTabIndexMixin.test.js +21 -34
- package/components/core/test/EventTargetShim.test.js +0 -8
- package/components/core/test/ScopedElementsMixin.test.js +22 -38
- package/components/core/test/ScopedStylesController.test.js +11 -20
- package/components/core/test/SlotMixin.test.js +102 -154
- package/components/core/test-helpers/getCachedFixture.js +5 -11
- package/components/core/types/SlotMixinTypes.ts +8 -3
- package/components/dialog/src/LionDialog.js +4 -3
- package/components/dialog/test/lion-dialog.integration.test.js +10 -20
- package/components/dialog/test/lion-dialog.test.js +48 -62
- package/components/dialog/test-helpers/test-router.js +4 -6
- package/components/drawer/src/LionDrawer.js +18 -34
- package/components/drawer/src/drawerStyle.js +0 -1
- package/components/drawer/test/lion-drawer.test.js +1 -17
- package/components/fieldset/test/lion-fieldset.test.js +6 -4
- package/components/form/src/LionForm.js +18 -13
- package/components/form/test/lion-form.test.js +22 -52
- package/components/form-core/src/FocusMixin.js +172 -174
- package/components/form-core/src/FormControlMixin.js +811 -813
- package/components/form-core/src/FormatMixin.js +537 -537
- package/components/form-core/src/InteractionStateMixin.js +196 -183
- package/components/form-core/src/LionField.js +9 -5
- package/components/form-core/src/NativeTextFieldMixin.js +114 -116
- package/components/form-core/src/choice-group/ChoiceGroupMixin.js +322 -364
- package/components/form-core/src/choice-group/ChoiceInputMixin.js +306 -296
- package/components/form-core/src/choice-group/CustomChoiceGroupMixin.js +114 -139
- package/components/form-core/src/form-group/FormElementsHaveNoError.js +0 -2
- package/components/form-core/src/form-group/FormGroupMixin.js +551 -557
- package/components/form-core/src/registration/FormRegisteringMixin.js +72 -71
- package/components/form-core/src/registration/FormRegistrarMixin.js +201 -217
- package/components/form-core/src/registration/FormRegistrarPortalMixin.js +31 -37
- package/components/form-core/src/utils/SyncUpdatableMixin.js +106 -117
- package/components/form-core/src/utils/getAriaElementsInRightDomOrder.js +1 -2
- package/components/form-core/src/validate/LionValidationFeedback.js +12 -8
- package/components/form-core/src/validate/Unparseable.js +4 -2
- package/components/form-core/src/validate/ValidateMixin.js +829 -883
- package/components/form-core/src/validate/Validator.js +3 -6
- package/components/form-core/src/validate/resultValidators/DefaultSuccess.js +1 -2
- package/components/form-core/src/validate/validators/DateValidators.js +0 -5
- package/components/form-core/src/validate/validators/NumberValidators.js +1 -5
- package/components/form-core/src/validate/validators/Required.js +1 -1
- package/components/form-core/src/validate/validators/StringValidators.js +1 -8
- package/components/form-core/test/FocusMixin.test.js +96 -82
- package/components/form-core/test/FormControlMixin.test.js +120 -176
- package/components/form-core/test/FormRegistrationMixins.test.js +0 -2
- package/components/form-core/test/FormatMixin.test.js +0 -1
- package/components/form-core/test/InteractionStateMixin.test.js +0 -1
- package/components/form-core/test/NativeTextFieldMixin.test.js +0 -1
- package/components/form-core/test/choice-group/ChoiceGroupMixin.test.js +0 -1
- package/components/form-core/test/choice-group/ChoiceInputMixin.test.js +0 -1
- package/components/form-core/test/choice-group/CustomChoiceGroupMixin.integrations.test.js +6 -8
- package/components/form-core/test/choice-group/CustomChoiceGroupMixin.test.js +0 -3
- package/components/form-core/test/form-group/FormGroupMixin.test.js +0 -1
- package/components/form-core/test/lion-field.test.js +88 -98
- package/components/form-core/test/utils/SyncUpdatableMixin.test.js +51 -65
- package/components/form-core/test/utils/getAriaElementsInRightDomOrder.test.js +3 -3
- package/components/form-core/test/validate/DateValidators.test.js +5 -27
- package/components/form-core/test/validate/NumberValidators.test.js +4 -16
- package/components/form-core/test/validate/Required.test.js +8 -21
- package/components/form-core/test/validate/ResultValidator.test.js +1 -2
- package/components/form-core/test/validate/StringValidators.test.js +4 -35
- package/components/form-core/test/validate/ValidateMixin.test.js +0 -1
- package/components/form-core/test/validate/ValidateMixinFeedbackPart.test.js +0 -1
- package/components/form-core/test/validate/Validator.test.js +39 -34
- package/components/form-core/test/validate/lion-validation-feedback.test.js +81 -43
- package/components/form-core/test-helpers/ExampleValidators.js +0 -5
- package/components/form-core/test-helpers/getFormControlMembers.js +2 -2
- package/components/form-core/test-helpers/mimicUserInput.js +5 -1
- package/components/form-core/test-suites/FormRegistrationMixins.suite.js +65 -122
- package/components/form-core/test-suites/FormatMixin.suite.js +202 -227
- package/components/form-core/test-suites/InteractionStateMixin.suite.js +47 -60
- package/components/form-core/test-suites/NativeTextFieldMixin.suite.js +8 -11
- package/components/form-core/test-suites/ValidateMixin.suite.js +280 -359
- package/components/form-core/test-suites/ValidateMixinFeedbackPart.suite.js +112 -163
- package/components/form-core/test-suites/choice-group/ChoiceGroupMixin.suite.js +185 -218
- package/components/form-core/test-suites/choice-group/ChoiceInputMixin.suite.js +116 -109
- package/components/form-core/test-suites/choice-group/CustomChoiceGroupMixin.suite.js +36 -70
- package/components/form-core/test-suites/form-group/FormGroupMixin-input.suite.js +57 -65
- package/components/form-core/test-suites/form-group/FormGroupMixin.suite.js +664 -523
- package/components/form-core/translations/bg-BG.js +0 -1
- package/components/form-core/translations/cs-CZ.js +0 -1
- package/components/form-core/translations/de-DE.js +0 -1
- package/components/form-core/translations/en-AU.js +0 -1
- package/components/form-core/translations/en-GB.js +0 -1
- package/components/form-core/translations/en-US.js +0 -1
- package/components/form-core/translations/es-ES.js +0 -1
- package/components/form-core/translations/fr-BE.js +0 -1
- package/components/form-core/translations/fr-FR.js +0 -1
- package/components/form-core/translations/hu-HU.js +0 -1
- package/components/form-core/translations/it-IT.js +0 -1
- package/components/form-core/translations/nl-BE.js +0 -1
- package/components/form-core/translations/nl-NL.js +0 -1
- package/components/form-core/translations/pl-PL.js +0 -1
- package/components/form-core/translations/ro-RO.js +0 -1
- package/components/form-core/translations/ru-RU.js +0 -1
- package/components/form-core/translations/sk-SK.js +0 -1
- package/components/form-core/translations/tr-TR.js +0 -1
- package/components/form-core/translations/uk-UA.js +0 -1
- package/components/form-integrations/test/dialog-integrations.test.js +1 -4
- package/components/form-integrations/test/form-group-methods.test.js +28 -31
- package/components/form-integrations/test/form-integrations.test.js +27 -28
- package/components/form-integrations/test/form-validation-integrations.test.js +21 -29
- package/components/form-integrations/test/helpers/umbrella-form.js +3 -5
- package/components/form-integrations/test/model-value-consistency.test.js +75 -77
- package/components/form-integrations/test/model-value-event.test.js +10 -20
- package/components/helpers/src/SbActionLogger.js +13 -17
- package/components/helpers/src/SbLocaleSwitcher.js +5 -5
- package/components/helpers/src/sortEachDepth.js +0 -2
- package/components/helpers/test/renderLitAsNode.test.js +0 -4
- package/components/helpers/test/sb-action-logger.test.js +24 -55
- package/components/icon/src/IconManager.js +0 -2
- package/components/icon/src/LionIcon.js +2 -7
- package/components/icon/src/icons.js +0 -2
- package/components/icon/test/IconManager.test.js +0 -15
- package/components/icon/test/hammer.svg.js +3 -4
- package/components/icon/test/heart.svg.js +3 -4
- package/components/icon/test/lion-icon.test.js +14 -43
- package/components/input/src/LionInput.js +2 -8
- package/components/input/test/input-integrations.test.js +0 -5
- package/components/input/test/lion-input-integrations.test.js +0 -4
- package/components/input/test/lion-input.test.js +28 -58
- package/components/input/test-helpers/getInputMembers.js +2 -2
- package/components/input-amount/src/LionInputAmount.js +20 -20
- package/components/input-amount/src/formatters.js +0 -3
- package/components/input-amount/src/parsers.js +0 -3
- package/components/input-amount/test/formatters.test.js +24 -16
- package/components/input-amount/test/lion-input-amount-integrations.test.js +0 -4
- package/components/input-amount/test/lion-input-amount.test.js +123 -147
- package/components/input-amount/test/parsers.test.js +33 -17
- package/components/input-amount/test/preprocessors.test.js +0 -3
- package/components/input-amount-dropdown/src/LionInputAmountDropdown.js +49 -59
- package/components/input-amount-dropdown/src/currencyUtil.js +8 -7
- package/components/input-amount-dropdown/src/parsers.js +0 -1
- package/components/input-amount-dropdown/src/validators.js +0 -1
- package/components/input-amount-dropdown/test/LionInputAmountDropdown.test.js +34 -36
- package/components/input-amount-dropdown/test/lion-input-amount-dropdown-integrations.test.js +18 -13
- package/components/input-amount-dropdown/test-helpers/mimicUserChangingDropdown.js +5 -1
- package/components/input-amount-dropdown/test-suites/LionInputAmountDropdown.suite.js +132 -107
- package/components/input-date/src/LionInputDate.js +4 -3
- package/components/input-date/test/lion-input-date-integrations.test.js +0 -3
- package/components/input-date/test/lion-input-date.test.js +19 -32
- package/components/input-datepicker/src/LionInputDatepicker.js +17 -29
- package/components/input-datepicker/src/localizeNamespaceLoader.js +1 -2
- package/components/input-datepicker/test/lion-input-datepicker-integrations.test.js +0 -3
- package/components/input-datepicker/test/lion-input-datepicker.test.js +88 -153
- package/components/input-datepicker/test-helpers/DatepickerInputObject.js +9 -12
- package/components/input-datepicker/test-suites/LionInputDatepicker.suite.js +6 -4
- package/components/input-datepicker/translations/bg-BG.js +0 -1
- package/components/input-datepicker/translations/cs-CZ.js +0 -1
- package/components/input-datepicker/translations/de-DE.js +0 -1
- package/components/input-datepicker/translations/en-AU.js +0 -1
- package/components/input-datepicker/translations/en-GB.js +0 -1
- package/components/input-datepicker/translations/en-US.js +0 -1
- package/components/input-datepicker/translations/es-ES.js +0 -1
- package/components/input-datepicker/translations/fr-BE.js +0 -1
- package/components/input-datepicker/translations/fr-FR.js +0 -1
- package/components/input-datepicker/translations/hu-HU.js +0 -1
- package/components/input-datepicker/translations/it-IT.js +0 -1
- package/components/input-datepicker/translations/nl-BE.js +0 -1
- package/components/input-datepicker/translations/nl-NL.js +0 -1
- package/components/input-datepicker/translations/pl-PL.js +0 -1
- package/components/input-datepicker/translations/ro-RO.js +0 -1
- package/components/input-datepicker/translations/ru-RU.js +0 -1
- package/components/input-datepicker/translations/sk-SK.js +0 -1
- package/components/input-datepicker/translations/tr-TR.js +0 -1
- package/components/input-datepicker/translations/uk-UA.js +0 -1
- package/components/input-email/test/lion-input-email-integrations.test.js +0 -2
- package/components/input-email/test/lion-input-email.test.js +1 -7
- package/components/input-file/src/FileHandle.js +0 -3
- package/components/input-file/src/LionInputFile.js +85 -83
- package/components/input-file/src/LionSelectedFileList.js +12 -12
- package/components/input-file/src/validators.js +10 -9
- package/components/input-file/test/FileValidators.test.js +170 -80
- package/components/input-file/test/lion-input-file.test.js +160 -244
- package/components/input-file/test/lion-selected-file-list.test.js +13 -22
- package/components/input-file/translations/bg-BG.js +0 -1
- package/components/input-file/translations/cs-CZ.js +0 -1
- package/components/input-file/translations/de-DE.js +0 -1
- package/components/input-file/translations/en-AU.js +0 -1
- package/components/input-file/translations/en-GB.js +0 -1
- package/components/input-file/translations/en-PH.js +0 -1
- package/components/input-file/translations/en-US.js +0 -1
- package/components/input-file/translations/en.js +2 -1
- package/components/input-file/translations/es-ES.js +0 -1
- package/components/input-file/translations/fr-BE.js +0 -1
- package/components/input-file/translations/fr-FR.js +0 -1
- package/components/input-file/translations/hu-HU.js +0 -1
- package/components/input-file/translations/id-ID.js +0 -1
- package/components/input-file/translations/id.js +2 -1
- package/components/input-file/translations/it-IT.js +0 -1
- package/components/input-file/translations/nl-BE.js +0 -1
- package/components/input-file/translations/nl-NL.js +0 -1
- package/components/input-file/translations/pl-PL.js +0 -1
- package/components/input-file/translations/ro-RO.js +0 -1
- package/components/input-file/translations/ru-RU.js +0 -1
- package/components/input-file/translations/sk-SK.js +0 -1
- package/components/input-file/translations/uk-UA.js +0 -1
- package/components/input-file/translations/zh-CN.js +0 -1
- package/components/input-iban/src/validators.js +6 -11
- package/components/input-iban/test/formatters.test.js +0 -3
- package/components/input-iban/test/lion-input-iban-integrations.test.js +0 -2
- package/components/input-iban/test/lion-input-iban.test.js +1 -9
- package/components/input-iban/test/parsers.test.js +0 -2
- package/components/input-iban/test/validators.test.js +0 -12
- package/components/input-iban/translations/bg-BG.js +0 -1
- package/components/input-iban/translations/cs-CZ.js +0 -1
- package/components/input-iban/translations/de-DE.js +0 -1
- package/components/input-iban/translations/en-AU.js +0 -1
- package/components/input-iban/translations/en-GB.js +0 -1
- package/components/input-iban/translations/en-US.js +0 -1
- package/components/input-iban/translations/es-ES.js +0 -1
- package/components/input-iban/translations/fr-BE.js +0 -1
- package/components/input-iban/translations/fr-FR.js +0 -1
- package/components/input-iban/translations/hu-HU.js +0 -1
- package/components/input-iban/translations/it-IT.js +0 -1
- package/components/input-iban/translations/nl-BE.js +0 -1
- package/components/input-iban/translations/nl-NL.js +0 -1
- package/components/input-iban/translations/pl-PL.js +0 -1
- package/components/input-iban/translations/ro-RO.js +0 -1
- package/components/input-iban/translations/ru-RU.js +0 -1
- package/components/input-iban/translations/sk-SK.js +0 -1
- package/components/input-iban/translations/uk-UA.js +0 -1
- package/components/input-range/src/LionInputRange.js +18 -19
- package/components/input-range/test/lion-input-range.test.js +23 -48
- package/components/input-range/translations/bg-BG.js +0 -1
- package/components/input-range/translations/cs-CZ.js +0 -1
- package/components/input-range/translations/de-DE.js +0 -1
- package/components/input-range/translations/en-AU.js +0 -1
- package/components/input-range/translations/en-GB.js +0 -1
- package/components/input-range/translations/en-PH.js +0 -1
- package/components/input-range/translations/en-US.js +0 -1
- package/components/input-range/translations/es-ES.js +0 -1
- package/components/input-range/translations/fr-BE.js +0 -1
- package/components/input-range/translations/fr-FR.js +0 -1
- package/components/input-range/translations/hu-HU.js +0 -1
- package/components/input-range/translations/it-IT.js +0 -1
- package/components/input-range/translations/nl-BE.js +0 -1
- package/components/input-range/translations/nl-NL.js +0 -1
- package/components/input-range/translations/pl-PL.js +0 -1
- package/components/input-range/translations/ro-RO.js +0 -1
- package/components/input-range/translations/ru-RU.js +0 -1
- package/components/input-range/translations/sk-SK.js +0 -1
- package/components/input-range/translations/uk-UA.js +0 -1
- package/components/input-range/translations/zh-CN.js +0 -1
- package/components/input-stepper/src/LionInputStepper.js +19 -38
- package/components/input-stepper/test/lion-input-stepper-integrations.test.js +0 -1
- package/components/input-stepper/test/lion-input-stepper.test.js +0 -1
- package/components/input-stepper/test-suites/lion-input-stepper.integration.suite.js +0 -2
- package/components/input-stepper/test-suites/lion-input-stepper.suite.js +56 -105
- package/components/input-stepper/translations/bg-BG.js +0 -1
- package/components/input-stepper/translations/cs-CZ.js +0 -1
- package/components/input-stepper/translations/de-DE.js +0 -1
- package/components/input-stepper/translations/en-AU.js +0 -1
- package/components/input-stepper/translations/en-GB.js +0 -1
- package/components/input-stepper/translations/en-US.js +0 -1
- package/components/input-stepper/translations/es-ES.js +0 -1
- package/components/input-stepper/translations/fr-BE.js +0 -1
- package/components/input-stepper/translations/fr-FR.js +0 -1
- package/components/input-stepper/translations/hu-HU.js +0 -1
- package/components/input-stepper/translations/it-IT.js +0 -1
- package/components/input-stepper/translations/nl-BE.js +0 -1
- package/components/input-stepper/translations/nl-NL.js +0 -1
- package/components/input-stepper/translations/pl-PL.js +0 -1
- package/components/input-stepper/translations/ro-RO.js +0 -1
- package/components/input-stepper/translations/ru-RU.js +0 -1
- package/components/input-stepper/translations/sk-SK.js +0 -1
- package/components/input-stepper/translations/uk-UA.js +0 -1
- package/components/input-tel/src/LionInputTel.js +53 -37
- package/components/input-tel/src/PhoneUtilManager.js +6 -4
- package/components/input-tel/src/formatters.js +12 -10
- package/components/input-tel/src/parsers.js +3 -3
- package/components/input-tel/src/preprocessors.js +15 -7
- package/components/input-tel/src/validators.js +4 -6
- package/components/input-tel/test/LionInputTel.test.js +4 -2
- package/components/input-tel/test/formatters.test.js +22 -10
- package/components/input-tel/test/parsers.test.js +127 -11
- package/components/input-tel/test/preprocessors.test.js +24 -13
- package/components/input-tel/test/validators.test.js +7 -14
- package/components/input-tel/test-helpers/mockPhoneUtilManager.js +20 -8
- package/components/input-tel/test-suites/LionInputTel.suite.js +33 -73
- package/components/input-tel/translations/bg-BG.js +0 -1
- package/components/input-tel/translations/cs-CZ.js +0 -1
- package/components/input-tel/translations/de-DE.js +0 -1
- package/components/input-tel/translations/en-AU.js +0 -1
- package/components/input-tel/translations/en-GB.js +0 -1
- package/components/input-tel/translations/en-US.js +0 -1
- package/components/input-tel/translations/es-ES.js +0 -1
- package/components/input-tel/translations/fr-BE.js +0 -1
- package/components/input-tel/translations/fr-FR.js +0 -1
- package/components/input-tel/translations/hu-HU.js +0 -1
- package/components/input-tel/translations/it-IT.js +0 -1
- package/components/input-tel/translations/nl-BE.js +0 -1
- package/components/input-tel/translations/nl-NL.js +0 -1
- package/components/input-tel/translations/pl-PL.js +0 -1
- package/components/input-tel/translations/ro-RO.js +0 -1
- package/components/input-tel/translations/ru-RU.js +0 -1
- package/components/input-tel/translations/sk-SK.js +0 -1
- package/components/input-tel/translations/uk-UA.js +0 -1
- package/components/input-tel-dropdown/src/LionInputTelDropdown.js +10 -28
- package/components/input-tel-dropdown/src/regionCodeToLocale.js +3 -1
- package/components/input-tel-dropdown/test/LionInputTelDropdown.test.js +31 -38
- package/components/input-tel-dropdown/test/regionCodeToLocale.test.js +0 -1
- package/components/input-tel-dropdown/test-helpers/mimicUserChangingDropdown.js +5 -1
- package/components/input-tel-dropdown/test-suites/LionInputTelDropdown--parentheses.suite.js +16 -11
- package/components/input-tel-dropdown/test-suites/LionInputTelDropdown.suite.js +54 -79
- package/components/listbox/src/LionListbox.js +5 -2
- package/components/listbox/src/LionOption.js +8 -7
- package/components/listbox/src/LionOptions.js +0 -3
- package/components/listbox/src/ListboxMixin.js +786 -820
- package/components/listbox/test/lion-listbox.test.js +0 -1
- package/components/listbox/test/lion-option.test.js +53 -64
- package/components/listbox/test/lion-options.test.js +3 -4
- package/components/listbox/test-helpers/getListboxMembers.js +6 -3
- package/components/listbox/test-suites/ListboxMixin.suite.js +101 -261
- package/components/localize/src/LocalizeManager.js +40 -40
- package/components/localize/src/LocalizeMixin.js +130 -157
- package/components/localize/src/date/formatDate.js +1 -5
- package/components/localize/src/date/getDateFormatBasedOnLocale.js +5 -3
- package/components/localize/src/date/getMonthNames.js +3 -5
- package/components/localize/src/date/getWeekdayNames.js +1 -5
- package/components/localize/src/date/parseDate.js +5 -20
- package/components/localize/src/date/utils/normalizeIntlDate.js +0 -7
- package/components/localize/src/getLocalizeManager.js +0 -3
- package/components/localize/src/number/formatNumber.js +3 -7
- package/components/localize/src/number/formatNumberToParts.js +52 -18
- package/components/localize/src/number/getCurrencyName.js +5 -5
- package/components/localize/src/number/getFractionDigits.js +4 -4
- package/components/localize/src/number/getSeparatorsFromNumber.js +1 -3
- package/components/localize/src/number/parseNumber.js +0 -3
- package/components/localize/src/number/utils/normalize-format-number-to-parts/forceAddGroupSeparators.js +0 -1
- package/components/localize/src/number/utils/normalize-format-number-to-parts/forceSpaceBetweenCurrencyCodeAndNumber.js +4 -1
- package/components/localize/test/LocalizeManager.test.js +385 -278
- package/components/localize/test/LocalizeMixin.test.js +28 -112
- package/components/localize/test/date/formatDate.test.js +18 -48
- package/components/localize/test/date/getDateFormatBasedOnLocale.test.js +0 -3
- package/components/localize/test/date/getMonthNames.test.js +27 -12
- package/components/localize/test/date/getWeekdayNames.test.js +93 -49
- package/components/localize/test/date/normalizeDateTime.test.js +0 -2
- package/components/localize/test/date/parseDate.test.js +12 -16
- package/components/localize/test/getLocalizeManager.test.js +0 -3
- package/components/localize/test/isLocalizeESModule.test.js +32 -13
- package/components/localize/test/localize.test.js +0 -4
- package/components/localize/test/number/formatNumber.test.js +215 -106
- package/components/localize/test/number/formatNumberToParts.test.js +31 -38
- package/components/localize/test/number/getCurrencyName.test.js +20 -6
- package/components/localize/test/number/getDecimalSeparator.test.js +5 -4
- package/components/localize/test/number/getFractionDigits.test.js +0 -2
- package/components/localize/test/number/getGroupSeparator.test.js +0 -2
- package/components/localize/test/number/getSeparatorsFromNumber.test.js +5 -3
- package/components/localize/test/number/parseNumber.test.js +123 -56
- package/components/localize/test/side-effect-free-entrypoint.test.js +0 -6
- package/components/localize/test-helpers/fake-imports.js +11 -6
- package/components/localize/test-helpers/localizeTearDown.js +0 -1
- package/components/menu/src/InteractiveListMixin.js +637 -638
- package/components/menu/src/LionMenu.js +46 -59
- package/components/menu/src/MoreButtonMenuMixin.js +215 -238
- package/components/menu/src/MultiLevelListMixin.js +240 -246
- package/components/menu/src/utils/isInView.js +0 -1
- package/components/menu/src/utils/listItemInteractions.js +4 -4
- package/components/menu/test/InteractiveListMixin.test.js +0 -1
- package/components/menu/test/MoreButtonMenuMixin.test.js +3 -2
- package/components/menu/test/MultiLevelListMixin.test.js +0 -1
- package/components/menu/test/lion-menu-interactions.test.js +0 -1
- package/components/menu/test/lion-menu.test.js +6 -2
- package/components/menu/test-helpers/mimicKeyPress.js +12 -2
- package/components/menu/test-suites/InteractiveListMixin.suite.js +4 -43
- package/components/menu/test-suites/LionMenu.suite.js +1 -8
- package/components/menu/test-suites/LionMenuInteractions.suite.js +22 -44
- package/components/menu/test-suites/MoreButtonMenuMixin.suite.js +34 -41
- package/components/menu/test-suites/MultiLevelListMixin.suite.js +5 -23
- package/components/overlays/src/ArrowMixin.js +111 -127
- package/components/overlays/src/OverlayController.js +172 -152
- package/components/overlays/src/OverlayMixin.js +64 -69
- package/components/overlays/src/OverlaysManager.js +30 -32
- package/components/overlays/src/configurations/visibility-trigger-partials/withClickInteraction.js +0 -1
- package/components/overlays/src/configurations/visibility-trigger-partials/withHoverInteraction.js +11 -11
- package/components/overlays/src/configurations/withBottomSheetConfig.js +12 -13
- package/components/overlays/src/configurations/withDropdownConfig.js +4 -2
- package/components/overlays/src/configurations/withModalDialogConfig.js +12 -13
- package/components/overlays/src/configurations/withPopoverConfig.js +27 -25
- package/components/overlays/src/configurations/withTooltipConfig.js +15 -13
- package/components/overlays/src/overlayDocumentStyle.js +1 -1
- package/components/overlays/src/overlayShadowDomStyle.js +0 -1
- package/components/overlays/src/singleton.js +0 -2
- package/components/overlays/src/utils/adopt-styles.js +18 -18
- package/components/overlays/src/utils/deep-contains.js +7 -6
- package/components/overlays/src/utils/get-focusable-elements.js +7 -10
- package/components/overlays/src/utils/inert-siblings.js +2 -4
- package/components/overlays/src/utils/is-equal-config.js +2 -3
- package/components/overlays/src/utils/is-visible.js +0 -1
- package/components/overlays/src/utils/simulate-tab.js +1 -4
- package/components/overlays/src/utils/sort-by-tabindex.js +2 -4
- package/components/overlays/test/ArrowMixin.test.js +18 -30
- package/components/overlays/test/OverlayController.test.js +406 -555
- package/components/overlays/test/OverlayMixin.test.js +0 -2
- package/components/overlays/test/OverlaysManager.test.js +30 -35
- package/components/overlays/test/global-positioning.test.js +6 -10
- package/components/overlays/test/invoker-compatibility.test.js +37 -0
- package/components/overlays/test/local-positioning.test.js +101 -103
- package/components/overlays/test/utils-tests/active-element.test.js +12 -27
- package/components/overlays/test/utils-tests/adopt-styles.test.js +25 -56
- package/components/overlays/test/utils-tests/deep-contains.test.js +73 -74
- package/components/overlays/test/utils-tests/get-focusable-elements.test.js +6 -23
- package/components/overlays/test/utils-tests/is-equal-config.test.js +32 -13
- package/components/overlays/test/utils-tests/visibility.test.js +44 -79
- package/components/overlays/test-helpers/createShadowHost.js +5 -3
- package/components/overlays/test-helpers/normalizeTransformStyle.js +2 -4
- package/components/overlays/test-suites/OverlayMixin.suite.js +152 -181
- package/components/overlays/test-suites/WithHoverInteraction.suite.js +96 -79
- package/components/overlays/translations/bg-BG.js +0 -1
- package/components/overlays/translations/cs-CZ.js +0 -1
- package/components/overlays/translations/de-DE.js +0 -1
- package/components/overlays/translations/en-AU.js +0 -1
- package/components/overlays/translations/en-GB.js +0 -1
- package/components/overlays/translations/en-US.js +0 -1
- package/components/overlays/translations/es-ES.js +0 -1
- package/components/overlays/translations/fr-BE.js +0 -1
- package/components/overlays/translations/fr-FR.js +0 -1
- package/components/overlays/translations/hu-HU.js +0 -1
- package/components/overlays/translations/it-IT.js +0 -1
- package/components/overlays/translations/nl-BE.js +0 -1
- package/components/overlays/translations/nl-NL.js +0 -1
- package/components/overlays/translations/pl-PL.js +0 -1
- package/components/overlays/translations/ro-RO.js +0 -1
- package/components/overlays/translations/ru-RU.js +0 -1
- package/components/overlays/translations/sk-SK.js +0 -1
- package/components/overlays/translations/tr-TR.js +0 -1
- package/components/overlays/translations/uk-UA.js +0 -1
- package/components/pagination/src/LionPagination.js +9 -12
- package/components/pagination/test/lion-pagination.test.js +18 -50
- package/components/progress-indicator/src/LionProgressIndicator.js +10 -12
- package/components/progress-indicator/test/lion-progress-indicator.test.js +1 -22
- package/components/radio-group/src/LionRadioGroup.js +1 -2
- package/components/radio-group/test/lion-radio-group-integrations.test.js +0 -1
- package/components/radio-group/test/lion-radio-group.test.js +27 -27
- package/components/radio-group/test/lion-radio-integrations.test.js +3 -2
- package/components/radio-group/test/lion-radio.test.js +30 -16
- package/components/select/src/LionSelect.js +12 -13
- package/components/select/test/lion-select.test.js +7 -12
- package/components/select-rich/src/LionSelectInvoker.js +18 -11
- package/components/select-rich/src/LionSelectRich.js +22 -44
- package/components/select-rich/test/demos.screenshots-test.js +40 -9
- package/components/select-rich/test/lion-select-invoker.test.js +26 -43
- package/components/select-rich/test/lion-select-listbox-suite-integration.test.js +3 -3
- package/components/select-rich/test/lion-select-rich-dialog-integration.test.js +4 -9
- package/components/select-rich/test/lion-select-rich-interaction.test.js +116 -116
- package/components/select-rich/test/lion-select-rich-upgrade.test.js +3 -7
- package/components/select-rich/test/lion-select-rich.test.js +153 -195
- package/components/select-rich/test-helpers/getSelectRichMembers.js +4 -1
- package/components/steps/src/LionStep.js +21 -12
- package/components/steps/src/LionSteps.js +25 -25
- package/components/steps/test/lion-step.test.js +18 -25
- package/components/steps/test/lion-steps.test.js +45 -78
- package/components/switch/src/LionSwitch.js +2 -7
- package/components/switch/src/LionSwitchButton.js +5 -6
- package/components/switch/test/lion-switch-button.test.js +16 -28
- package/components/switch/test/lion-switch.test.js +17 -31
- package/components/tabs/src/LionTabs.js +25 -28
- package/components/tabs/test/lion-tabs.test.js +156 -154
- package/components/textarea/src/LionTextarea.js +4 -23
- package/components/textarea/test/lion-textarea-integrations.test.js +0 -5
- package/components/textarea/test/lion-textarea.test.js +2 -28
- package/components/tooltip/src/LionTooltip.js +6 -6
- package/components/tooltip/test/lion-tooltip.test.js +75 -102
- package/components/validate-messages/src/getLocalizedMessage.js +8 -7
- package/components/validate-messages/src/loadDefaultFeedbackMessages.js +3 -1
- package/components/validate-messages/src/loadDefaultFeedbackMessagesNoSideEffects.js +9 -5
- package/components/validate-messages/src/per-entrypoint/loadComboboxMessagesNoSideEffects.js +5 -2
- package/components/validate-messages/src/per-entrypoint/loadFormCoreMessagesNoSideEffects.js +99 -35
- package/components/validate-messages/src/per-entrypoint/loadInputTelMessagesNoSideEffects.js +4 -3
- package/components/validate-messages/test/loadDefaultFeedbackMessages.test.js +5 -3
- package/components/validate-messages/test/loadDefaultFeedbackMessagesNoSideEffects.test.js +80 -45
- package/components/validate-messages/translations/bg-BG.js +0 -1
- package/components/validate-messages/translations/cs-CZ.js +0 -1
- package/components/validate-messages/translations/de-DE.js +0 -1
- package/components/validate-messages/translations/en-AU.js +0 -1
- package/components/validate-messages/translations/en-GB.js +0 -1
- package/components/validate-messages/translations/en-PH.js +0 -1
- package/components/validate-messages/translations/en-US.js +0 -1
- package/components/validate-messages/translations/es-ES.js +0 -1
- package/components/validate-messages/translations/fr-BE.js +0 -1
- package/components/validate-messages/translations/fr-FR.js +0 -1
- package/components/validate-messages/translations/hu-HU.js +0 -1
- package/components/validate-messages/translations/it-IT.js +0 -1
- package/components/validate-messages/translations/nl-BE.js +0 -1
- package/components/validate-messages/translations/nl-NL.js +0 -1
- package/components/validate-messages/translations/pl-PL.js +0 -1
- package/components/validate-messages/translations/ro-RO.js +0 -1
- package/components/validate-messages/translations/ru-RU.js +0 -1
- package/components/validate-messages/translations/sk-SK.js +0 -1
- package/components/validate-messages/translations/tr-TR.js +0 -1
- package/components/validate-messages/translations/uk-UA.js +0 -1
- package/custom-elements.json +229 -85
- package/dist-types/components/core/src/SlotMixin.d.ts +6 -1
- package/dist-types/components/core/src/SlotMixin.d.ts.map +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts +5 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts.map +1 -1
- package/dist-types/components/form-core/src/LionField.d.ts +3 -1
- package/dist-types/components/form-core/src/LionField.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/LionInputTel.d.ts +6 -6
- package/dist-types/components/input-tel/src/LionInputTel.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/PhoneUtilManager.d.ts +2 -2
- package/dist-types/components/input-tel/src/PhoneUtilManager.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/formatters.d.ts +2 -2
- package/dist-types/components/input-tel/src/formatters.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/preprocessors.d.ts +2 -2
- package/dist-types/components/input-tel/src/preprocessors.d.ts.map +1 -1
- package/dist-types/components/input-tel/test/validators.test.d.ts +1 -1
- package/dist-types/components/input-tel/test/validators.test.d.ts.map +1 -1
- package/dist-types/components/input-tel/test-helpers/mockPhoneUtilManager.d.ts +5 -0
- package/dist-types/components/input-tel/test-helpers/mockPhoneUtilManager.d.ts.map +1 -1
- package/dist-types/components/listbox/src/LionListbox.d.ts +2 -2
- package/dist-types/components/listbox/src/LionListbox.d.ts.map +1 -1
- package/dist-types/components/listbox/src/LionOption.d.ts +5 -2
- package/dist-types/components/listbox/src/LionOption.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlayController.d.ts +3 -1
- package/dist-types/components/overlays/src/OverlayController.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlayMixin.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlaysManager.d.ts.map +1 -1
- package/dist-types/components/overlays/src/overlayDocumentStyle.d.ts.map +1 -1
- package/dist-types/components/overlays/test/invoker-compatibility.test.d.ts +3 -0
- package/dist-types/components/overlays/test/invoker-compatibility.test.d.ts.map +1 -0
- package/dist-types/components/select-rich/src/LionSelectInvoker.d.ts +3 -1
- package/dist-types/components/select-rich/src/LionSelectInvoker.d.ts.map +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts +6 -5
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/accordion/overview.md +2 -2
- package/docs/components/accordion/reference.md +2 -2
- package/docs/components/accordion/use-cases.md +2 -2
- package/docs/components/button/examples.md +2 -2
- package/docs/components/button/extensions.md +2 -2
- package/docs/components/button/overview.md +2 -2
- package/docs/components/button/use-cases.md +2 -2
- package/docs/components/calendar/overview.md +2 -2
- package/docs/components/calendar/use-cases.md +2 -2
- package/docs/components/checkbox-group/overview.md +4 -4
- package/docs/components/checkbox-group/use-cases.md +2 -2
- package/docs/components/collapsible/examples.md +2 -2
- package/docs/components/collapsible/overview.md +3 -3
- package/docs/components/collapsible/use-cases.md +2 -2
- package/docs/components/combobox/api-table.md +1 -1
- package/docs/components/combobox/extensions.md +2 -2
- package/docs/components/combobox/overview.md +3 -3
- package/docs/components/combobox/use-cases.md +3 -3
- package/docs/components/dialog/overview.md +3 -3
- package/docs/components/dialog/use-cases.md +2 -2
- package/docs/components/drawer/overview.md +2 -2
- package/docs/components/drawer/use-cases.md +2 -2
- package/docs/components/fieldset/overview.md +7 -7
- package/docs/components/fieldset/use-cases.md +2 -2
- package/docs/components/form/overview.md +5 -5
- package/docs/components/form/use-cases.md +4 -4
- package/docs/components/icon/overview.md +2 -2
- package/docs/components/icon/use-cases.md +3 -3
- package/docs/components/input/overview.md +3 -3
- package/docs/components/input/use-cases.md +2 -2
- package/docs/components/input-amount/overview.md +5 -5
- package/docs/components/input-amount/use-cases.md +2 -2
- package/docs/components/input-amount-dropdown/use-cases.md +2 -2
- package/docs/components/input-date/overview.md +5 -5
- package/docs/components/input-date/use-cases.md +2 -2
- package/docs/components/input-datepicker/overview.md +7 -7
- package/docs/components/input-datepicker/use-cases.md +2 -2
- package/docs/components/input-email/overview.md +4 -4
- package/docs/components/input-email/use-cases.md +2 -2
- package/docs/components/input-file/overview.md +3 -3
- package/docs/components/input-file/use-cases.md +2 -2
- package/docs/components/input-iban/overview.md +4 -4
- package/docs/components/input-iban/use-cases.md +2 -2
- package/docs/components/input-range/overview.md +4 -4
- package/docs/components/input-range/use-cases.md +2 -2
- package/docs/components/input-stepper/overview.md +3 -3
- package/docs/components/input-stepper/use-cases.md +2 -2
- package/docs/components/input-tel/overview.md +3 -3
- package/docs/components/input-tel/use-cases.md +8 -8
- package/docs/components/input-tel-dropdown/extensions.md +2 -2
- package/docs/components/input-tel-dropdown/overview.md +3 -3
- package/docs/components/input-tel-dropdown/use-cases.md +2 -2
- package/docs/components/listbox/api-table.md +4 -4
- package/docs/components/listbox/overview.md +2 -2
- package/docs/components/listbox/use-cases.md +3 -3
- package/docs/components/menu/extensions.md +2 -2
- package/docs/components/menu/migration.md +2 -2
- package/docs/components/menu/overview.md +2 -2
- package/docs/components/menu/use-cases.md +1 -1
- package/docs/components/pagination/overview.md +2 -2
- package/docs/components/pagination/use-cases.md +2 -2
- package/docs/components/progress-indicator/examples.md +2 -2
- package/docs/components/progress-indicator/overview.md +2 -2
- package/docs/components/radio-group/overview.md +5 -5
- package/docs/components/radio-group/use-cases.md +2 -2
- package/docs/components/select/overview.md +2 -2
- package/docs/components/select/use-cases.md +3 -3
- package/docs/components/select-rich/api-table.md +1 -1
- package/docs/components/select-rich/examples.md +2 -2
- package/docs/components/select-rich/overview.md +2 -2
- package/docs/components/select-rich/use-cases.md +4 -4
- package/docs/components/steps/overview.md +2 -2
- package/docs/components/steps/use-cases.md +2 -2
- package/docs/components/switch/overview.md +2 -2
- package/docs/components/switch/reference.md +2 -2
- package/docs/components/switch/use-cases.md +2 -2
- package/docs/components/tabs/examples.md +3 -3
- package/docs/components/tabs/overview.md +2 -2
- package/docs/components/tabs/use-cases.md +2 -2
- package/docs/components/textarea/overview.md +2 -2
- package/docs/components/textarea/use-cases.md +2 -2
- package/docs/components/tooltip/examples.md +2 -2
- package/docs/components/tooltip/overview.md +2 -2
- package/docs/components/tooltip/use-cases.md +2 -2
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/index.md +2 -2
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/overview.md +2 -2
- package/docs/fundamentals/node-tools/providence-analytics/index.md +2 -2
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +2 -2
- package/docs/fundamentals/node-tools/publish-docs/index.md +2 -2
- package/docs/fundamentals/node-tools/publish-docs/overview.md +5 -5
- package/docs/fundamentals/node-tools/remark-extend/index.md +2 -2
- package/docs/fundamentals/node-tools/remark-extend/overview.md +2 -2
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/index.md +2 -2
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +4 -4
- package/docs/fundamentals/rationales/TypeScript.md +62 -2
- package/docs/fundamentals/rationales/accessibility.md +5 -5
- package/docs/fundamentals/rationales/side-effects.md +2 -2
- package/docs/fundamentals/rationales/versioning.md +2 -2
- package/docs/fundamentals/systems/core/SlotMixin.md +3 -3
- package/docs/fundamentals/systems/core/index.md +2 -2
- package/docs/fundamentals/systems/core/overview.md +3 -3
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +6 -6
- package/docs/fundamentals/systems/form/index.md +2 -2
- package/docs/fundamentals/systems/form/interaction-states.md +2 -2
- package/docs/fundamentals/systems/form/model-value.md +3 -3
- package/docs/fundamentals/systems/form/overview.md +30 -30
- package/docs/fundamentals/systems/form/styling.md +2 -2
- package/docs/fundamentals/systems/form/use-cases.md +2 -2
- package/docs/fundamentals/systems/form/validate.md +4 -4
- package/docs/fundamentals/systems/icon/index.md +2 -2
- package/docs/fundamentals/systems/icon/overview.md +2 -2
- package/docs/fundamentals/systems/localize/dates.md +2 -2
- package/docs/fundamentals/systems/localize/index.md +2 -2
- package/docs/fundamentals/systems/localize/numbers.md +2 -2
- package/docs/fundamentals/systems/localize/overview.md +6 -6
- package/docs/fundamentals/systems/localize/rationale.md +2 -2
- package/docs/fundamentals/systems/localize/text.md +2 -2
- package/docs/fundamentals/systems/localize/use-cases.md +2 -2
- package/docs/fundamentals/systems/overlays/_edge-cases.md +2 -2
- package/docs/fundamentals/systems/overlays/api-table.md +1 -1
- package/docs/fundamentals/systems/overlays/configuration.md +4 -4
- package/docs/fundamentals/systems/overlays/index.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +7 -7
- package/docs/fundamentals/systems/overlays/rationale.md +2 -2
- package/docs/fundamentals/systems/overlays/use-cases.md +4 -4
- package/docs/fundamentals/tools/ajax/index.md +2 -2
- package/docs/fundamentals/tools/ajax/overview.md +2 -2
- package/docs/fundamentals/tools/ajax/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/action-logger.md +2 -2
- package/docs/fundamentals/tools/helpers/index.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +3 -3
- package/docs/fundamentals/tools/singleton-manager/example-complex/index.md +2 -2
- package/docs/fundamentals/tools/singleton-manager/example-fail/index.md +2 -2
- package/docs/fundamentals/tools/singleton-manager/example-success/index.md +2 -2
- package/docs/fundamentals/tools/singleton-manager/index.md +2 -2
- package/docs/fundamentals/tools/singleton-manager/overview.md +6 -6
- package/docs/guides/how-to/create-a-custom-field.md +7 -7
- package/docs/guides/how-to/create-a-form.md +6 -6
- package/docs/guides/how-to/extend-a-native-input.md +4 -4
- package/docs/guides/how-to/get-started.md +2 -2
- package/docs/guides/how-to/index.md +1 -1
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/definitions-and-terms.md +2 -2
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/scoped-elements.md +2 -2
- package/docs/guides/principles/styling.md +3 -3
- package/docs/guides/principles/subclasser-apis.md +2 -2
- package/exports/define/lion-accordion.js +0 -1
- package/exports/define/lion-button-reset.js +0 -1
- package/exports/define/lion-button-submit.js +0 -1
- package/exports/define/lion-button.js +0 -1
- package/exports/define/lion-calendar.js +0 -1
- package/exports/define/lion-checkbox-group.js +0 -1
- package/exports/define/lion-checkbox-indeterminate.js +0 -1
- package/exports/define/lion-checkbox.js +0 -1
- package/exports/define/lion-collapsible.js +0 -1
- package/exports/define/lion-combobox.js +0 -1
- package/exports/define/lion-dialog.js +0 -1
- package/exports/define/lion-drawer.js +0 -1
- package/exports/define/lion-field.js +0 -1
- package/exports/define/lion-fieldset.js +0 -1
- package/exports/define/lion-form.js +0 -1
- package/exports/define/lion-icon.js +0 -1
- package/exports/define/lion-input-amount-dropdown.js +0 -1
- package/exports/define/lion-input-amount.js +0 -1
- package/exports/define/lion-input-date.js +0 -1
- package/exports/define/lion-input-datepicker.js +0 -1
- package/exports/define/lion-input-email.js +0 -1
- package/exports/define/lion-input-file.js +0 -1
- package/exports/define/lion-input-iban.js +0 -1
- package/exports/define/lion-input-range.js +0 -1
- package/exports/define/lion-input-stepper.js +0 -1
- package/exports/define/lion-input-tel-dropdown.js +0 -1
- package/exports/define/lion-input-tel.js +0 -1
- package/exports/define/lion-input.js +0 -1
- package/exports/define/lion-item.js +0 -1
- package/exports/define/lion-listbox.js +0 -1
- package/exports/define/lion-menu.js +0 -1
- package/exports/define/lion-menuitem.js +0 -1
- package/exports/define/lion-option.js +0 -1
- package/exports/define/lion-options.js +0 -1
- package/exports/define/lion-pagination.js +0 -1
- package/exports/define/lion-progress-indicator.js +0 -1
- package/exports/define/lion-radio-group.js +0 -1
- package/exports/define/lion-radio.js +0 -1
- package/exports/define/lion-select-invoker.js +0 -1
- package/exports/define/lion-select-rich.js +0 -1
- package/exports/define/lion-select.js +0 -1
- package/exports/define/lion-selected-file-list.js +0 -1
- package/exports/define/lion-step.js +0 -1
- package/exports/define/lion-steps.js +0 -1
- package/exports/define/lion-switch-button.js +0 -1
- package/exports/define/lion-switch.js +0 -1
- package/exports/define/lion-tabs.js +0 -1
- package/exports/define/lion-textarea.js +0 -1
- package/exports/define/lion-tooltip.js +0 -1
- package/exports/define/lion-validation-feedback.js +0 -1
- package/exports/define-helpers/sb-action-logger.js +0 -1
- package/exports/define-helpers/sb-locale-switcher.js +0 -1
- package/exports/form-core.js +0 -8
- package/exports/localize-no-side-effects.js +0 -1
- package/exports/localize.js +0 -2
- package/exports/overlays.js +0 -4
- package/generated/awesome-phonenumber/LICENSE +22 -0
- package/generated/awesome-phonenumber/LICENSE.closure-library +176 -0
- package/generated/awesome-phonenumber/LICENSE.libphonenumber +176 -0
- package/generated/awesome-phonenumber/checksums.json +6 -0
- package/generated/awesome-phonenumber/index-esm.mjs +817 -0
- package/generated/awesome-phonenumber/index.d.ts +227 -0
- package/generated/awesome-phonenumber/index.js +45 -0
- package/generated/awesome-phonenumber/lib/index.js +710 -0
- package/generated/awesome-phonenumber/package.json +9 -0
- package/generated/awesome-phonenumber/provenance.json +13 -0
- package/package.json +38 -15
- package/vscode.html-custom-data.json +5 -5
- package/web-types.json +1 -1
- package/vendor/README.md +0 -61
- package/vendor/awesome-phonenumber-7.9.0-tlouisse.libphonenumber-9.0.41.tgz +0 -0
|
@@ -15,7 +15,6 @@ import { defineCE, expect, fixture, html, unsafeStatic, waitUntil } from '@open-
|
|
|
15
15
|
import { sendKeys } from '@web/test-runner-commands';
|
|
16
16
|
import { LitElement, nothing } from 'lit';
|
|
17
17
|
import sinon from 'sinon';
|
|
18
|
-
|
|
19
18
|
import { isActiveElement } from '../../core/test-helpers/isActiveElement.js';
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -27,7 +26,8 @@ import { isActiveElement } from '../../core/test-helpers/isActiveElement.js';
|
|
|
27
26
|
* @param {{ autocomplete?:'none'|'list'|'both', matchMode?:'begin'|'all', disabled?: boolean, readonly?: boolean }} config
|
|
28
27
|
*/
|
|
29
28
|
async function fruitFixture({ autocomplete, matchMode, disabled, readonly } = {}) {
|
|
30
|
-
const el =
|
|
29
|
+
const el =
|
|
30
|
+
/** @type {LionCombobox} */
|
|
31
31
|
await fixture(html`
|
|
32
32
|
<lion-combobox label="Search" name="foo">
|
|
33
33
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -35,8 +35,7 @@ async function fruitFixture({ autocomplete, matchMode, disabled, readonly } = {}
|
|
|
35
35
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
36
36
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
37
37
|
</lion-combobox>
|
|
38
|
-
`)
|
|
39
|
-
);
|
|
38
|
+
`);
|
|
40
39
|
if (autocomplete) {
|
|
41
40
|
el.autocomplete = autocomplete;
|
|
42
41
|
}
|
|
@@ -52,7 +51,6 @@ async function fruitFixture({ autocomplete, matchMode, disabled, readonly } = {}
|
|
|
52
51
|
await el.updateComplete;
|
|
53
52
|
return [el, el.formElements];
|
|
54
53
|
}
|
|
55
|
-
|
|
56
54
|
describe('lion-combobox', () => {
|
|
57
55
|
describe('Rendering on API change', () => {
|
|
58
56
|
it('renders when options changed', async () => {
|
|
@@ -78,59 +76,54 @@ describe('lion-combobox', () => {
|
|
|
78
76
|
label: 'Pineapple',
|
|
79
77
|
},
|
|
80
78
|
];
|
|
81
|
-
|
|
82
79
|
class Wrapper extends LitElement {
|
|
83
80
|
static properties = {
|
|
84
81
|
...super.properties,
|
|
85
|
-
entries: {
|
|
82
|
+
entries: {
|
|
83
|
+
type: Array,
|
|
84
|
+
},
|
|
86
85
|
};
|
|
87
|
-
|
|
88
86
|
constructor() {
|
|
89
87
|
super();
|
|
90
88
|
this.entries = entries;
|
|
91
89
|
}
|
|
92
|
-
|
|
93
90
|
render() {
|
|
94
91
|
return html`<lion-combobox name="foo">
|
|
95
92
|
${this.entries.map(
|
|
96
|
-
entry => html`<lion-option .choiceValue="${entry.id}">${entry.label}</lion-option>`,
|
|
93
|
+
(entry) => html`<lion-option .choiceValue="${entry.id}">${entry.label}</lion-option>`,
|
|
97
94
|
)}
|
|
98
95
|
</lion-combobox>`;
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
|
-
|
|
102
98
|
const tagString = defineCE(Wrapper);
|
|
103
99
|
const tag = unsafeStatic(tagString);
|
|
104
|
-
const wrapperElement = /** @type {Wrapper} */
|
|
100
|
+
const wrapperElement = /** @type {Wrapper} */ await fixture(html`<${tag}></${tag}>`);
|
|
105
101
|
await waitUntil(
|
|
106
102
|
() =>
|
|
107
103
|
wrapperElement?.shadowRoot?.querySelector('lion-options')?.querySelectorAll('lion-option')
|
|
108
104
|
.length === entries.length,
|
|
109
105
|
);
|
|
110
|
-
|
|
111
106
|
wrapperElement.entries = [
|
|
112
107
|
{
|
|
113
108
|
id: '4',
|
|
114
109
|
label: 'Banana',
|
|
115
110
|
},
|
|
116
111
|
];
|
|
117
|
-
|
|
118
112
|
await waitUntil(
|
|
119
113
|
() =>
|
|
120
114
|
wrapperElement?.shadowRoot?.querySelector('lion-options')?.querySelectorAll('lion-option')
|
|
121
115
|
.length === wrapperElement.entries.length,
|
|
122
116
|
);
|
|
123
|
-
|
|
124
117
|
const optionElements = wrapperElement.shadowRoot?.querySelectorAll('lion-option');
|
|
125
118
|
expect(optionElements?.length).to.equal(wrapperElement.entries.length);
|
|
126
119
|
const optionElement = optionElements?.item(0);
|
|
127
120
|
expect(optionElement?.textContent).to.equal('Banana');
|
|
128
121
|
});
|
|
129
122
|
});
|
|
130
|
-
|
|
131
123
|
describe('Options visibility', () => {
|
|
132
124
|
it('hides options when text in input node is cleared after typing something by default', async () => {
|
|
133
|
-
const el =
|
|
125
|
+
const el =
|
|
126
|
+
/** @type {LionCombobox} */
|
|
134
127
|
await fixture(html`
|
|
135
128
|
<lion-combobox name="foo">
|
|
136
129
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -138,12 +131,9 @@ describe('lion-combobox', () => {
|
|
|
138
131
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
139
132
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
140
133
|
</lion-combobox>
|
|
141
|
-
`)
|
|
142
|
-
);
|
|
143
|
-
|
|
134
|
+
`);
|
|
144
135
|
const options = el.formElements;
|
|
145
|
-
const visibleOptions = () => options.filter(o => o.getAttribute('aria-hidden') !== 'true');
|
|
146
|
-
|
|
136
|
+
const visibleOptions = () => options.filter((o) => o.getAttribute('aria-hidden') !== 'true');
|
|
147
137
|
async function performChecks() {
|
|
148
138
|
await mimicUserTyping(el, 'c');
|
|
149
139
|
await el.updateComplete;
|
|
@@ -153,7 +143,6 @@ describe('lion-combobox', () => {
|
|
|
153
143
|
await el.updateComplete;
|
|
154
144
|
expect(visibleOptions().length).to.equal(0, `autocompleteMode is ${el.autocomplete}`);
|
|
155
145
|
}
|
|
156
|
-
|
|
157
146
|
el.autocomplete = 'none';
|
|
158
147
|
await performChecks();
|
|
159
148
|
el.autocomplete = 'list';
|
|
@@ -163,9 +152,9 @@ describe('lion-combobox', () => {
|
|
|
163
152
|
el.autocomplete = 'both';
|
|
164
153
|
await performChecks();
|
|
165
154
|
});
|
|
166
|
-
|
|
167
155
|
it('hides all options on reset()', async () => {
|
|
168
|
-
const el =
|
|
156
|
+
const el =
|
|
157
|
+
/** @type {LionCombobox} */
|
|
169
158
|
await fixture(html`
|
|
170
159
|
<lion-combobox name="foo">
|
|
171
160
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -173,12 +162,9 @@ describe('lion-combobox', () => {
|
|
|
173
162
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
174
163
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
175
164
|
</lion-combobox>
|
|
176
|
-
`)
|
|
177
|
-
);
|
|
178
|
-
|
|
165
|
+
`);
|
|
179
166
|
const options = el.formElements;
|
|
180
|
-
const visibleOptions = () => options.filter(o => o.style.display !== 'none');
|
|
181
|
-
|
|
167
|
+
const visibleOptions = () => options.filter((o) => o.style.display !== 'none');
|
|
182
168
|
await mimicUserTyping(el, 'cha');
|
|
183
169
|
await el.updateComplete;
|
|
184
170
|
expect(visibleOptions().length).to.equal(1);
|
|
@@ -186,9 +172,9 @@ describe('lion-combobox', () => {
|
|
|
186
172
|
await el.updateComplete;
|
|
187
173
|
expect(visibleOptions().length).to.equal(0);
|
|
188
174
|
});
|
|
189
|
-
|
|
190
175
|
it('shows all options on reset() when showAllOnEmpty is set to true and overlay was open', async () => {
|
|
191
|
-
const el =
|
|
176
|
+
const el =
|
|
177
|
+
/** @type {LionCombobox} */
|
|
192
178
|
await fixture(html`
|
|
193
179
|
<lion-combobox name="foo" show-all-on-empty>
|
|
194
180
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -196,24 +182,20 @@ describe('lion-combobox', () => {
|
|
|
196
182
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
197
183
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
198
184
|
</lion-combobox>
|
|
199
|
-
`)
|
|
200
|
-
);
|
|
201
|
-
|
|
185
|
+
`);
|
|
202
186
|
const options = el.formElements;
|
|
203
|
-
const visibleOptions = () => options.filter(o => o.getAttribute('aria-hidden') !== 'true');
|
|
204
|
-
|
|
187
|
+
const visibleOptions = () => options.filter((o) => o.getAttribute('aria-hidden') !== 'true');
|
|
205
188
|
await mimicUserTyping(el, 'cha');
|
|
206
189
|
await el.updateComplete;
|
|
207
190
|
expect(visibleOptions().length).to.equal(1);
|
|
208
191
|
expect(el.opened).to.be.true;
|
|
209
|
-
|
|
210
192
|
el.reset();
|
|
211
193
|
await el.updateComplete;
|
|
212
194
|
expect(visibleOptions().length).to.equal(4);
|
|
213
195
|
});
|
|
214
|
-
|
|
215
196
|
it('hides listbox on click/enter (when multiple-choice is false)', async () => {
|
|
216
|
-
const el =
|
|
197
|
+
const el =
|
|
198
|
+
/** @type {LionCombobox} */
|
|
217
199
|
await fixture(html`
|
|
218
200
|
<lion-combobox name="foo">
|
|
219
201
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -221,19 +203,15 @@ describe('lion-combobox', () => {
|
|
|
221
203
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
222
204
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
223
205
|
</lion-combobox>
|
|
224
|
-
`)
|
|
225
|
-
);
|
|
226
|
-
|
|
206
|
+
`);
|
|
227
207
|
const { _listboxNode } = getComboboxMembers(el);
|
|
228
|
-
|
|
229
208
|
async function open() {
|
|
230
209
|
await mimicUserTyping(el, 'ch');
|
|
231
210
|
return el.updateComplete;
|
|
232
211
|
}
|
|
233
|
-
|
|
234
212
|
await open();
|
|
235
213
|
expect(el.opened).to.be.true;
|
|
236
|
-
const visibleOptions = el.formElements.filter(o => o.style.display !== 'none');
|
|
214
|
+
const visibleOptions = el.formElements.filter((o) => o.style.display !== 'none');
|
|
237
215
|
visibleOptions[0].click();
|
|
238
216
|
expect(el.opened).to.be.false;
|
|
239
217
|
await open();
|
|
@@ -243,10 +221,10 @@ describe('lion-combobox', () => {
|
|
|
243
221
|
await el.updateComplete;
|
|
244
222
|
expect(el.opened).to.be.false;
|
|
245
223
|
});
|
|
246
|
-
|
|
247
224
|
describe('With ".showAllOnEmpty"', () => {
|
|
248
225
|
it('keeps showing options when text in input node is cleared after typing something', async () => {
|
|
249
|
-
const el =
|
|
226
|
+
const el =
|
|
227
|
+
/** @type {LionCombobox} */
|
|
250
228
|
await fixture(html`
|
|
251
229
|
<lion-combobox name="foo" autocomplete="list" show-all-on-empty>
|
|
252
230
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -254,12 +232,10 @@ describe('lion-combobox', () => {
|
|
|
254
232
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
255
233
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
256
234
|
</lion-combobox>
|
|
257
|
-
`)
|
|
258
|
-
);
|
|
259
|
-
|
|
235
|
+
`);
|
|
260
236
|
const options = el.formElements;
|
|
261
|
-
const visibleOptions = () =>
|
|
262
|
-
|
|
237
|
+
const visibleOptions = () =>
|
|
238
|
+
options.filter((o) => o.getAttribute('aria-hidden') !== 'true');
|
|
263
239
|
async function performChecks() {
|
|
264
240
|
await mimicUserTyping(el, 'c');
|
|
265
241
|
await el.updateComplete;
|
|
@@ -268,7 +244,6 @@ describe('lion-combobox', () => {
|
|
|
268
244
|
await el.updateComplete;
|
|
269
245
|
expect(visibleOptions().length).to.equal(options.length);
|
|
270
246
|
}
|
|
271
|
-
|
|
272
247
|
el.autocomplete = 'none';
|
|
273
248
|
await performChecks();
|
|
274
249
|
el.autocomplete = 'list';
|
|
@@ -278,9 +253,9 @@ describe('lion-combobox', () => {
|
|
|
278
253
|
el.autocomplete = 'both';
|
|
279
254
|
await performChecks();
|
|
280
255
|
});
|
|
281
|
-
|
|
282
256
|
it('shows overlay on click', async () => {
|
|
283
|
-
const el =
|
|
257
|
+
const el =
|
|
258
|
+
/** @type {LionCombobox} */
|
|
284
259
|
await fixture(html`
|
|
285
260
|
<lion-combobox name="foo" .showAllOnEmpty="${true}">
|
|
286
261
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -288,18 +263,21 @@ describe('lion-combobox', () => {
|
|
|
288
263
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
289
264
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
290
265
|
</lion-combobox>
|
|
291
|
-
`)
|
|
292
|
-
);
|
|
266
|
+
`);
|
|
293
267
|
const { _inputNode } = getComboboxMembers(el);
|
|
294
|
-
|
|
295
268
|
expect(el.opened).to.be.false;
|
|
296
|
-
_inputNode.dispatchEvent(
|
|
269
|
+
_inputNode.dispatchEvent(
|
|
270
|
+
new Event('click', {
|
|
271
|
+
bubbles: true,
|
|
272
|
+
composed: true,
|
|
273
|
+
}),
|
|
274
|
+
);
|
|
297
275
|
await el.updateComplete;
|
|
298
276
|
expect(el.opened).to.be.true;
|
|
299
277
|
});
|
|
300
|
-
|
|
301
278
|
it('hides overlay on [Escape] after being opened', async () => {
|
|
302
|
-
const el =
|
|
279
|
+
const el =
|
|
280
|
+
/** @type {LionCombobox} */
|
|
303
281
|
await fixture(html`
|
|
304
282
|
<lion-combobox name="foo" .showAllOnEmpty="${true}" opened>
|
|
305
283
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -307,19 +285,20 @@ describe('lion-combobox', () => {
|
|
|
307
285
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
308
286
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
309
287
|
</lion-combobox>
|
|
310
|
-
`)
|
|
311
|
-
);
|
|
288
|
+
`);
|
|
312
289
|
await el.updateComplete;
|
|
313
|
-
|
|
314
290
|
const { _inputNode } = getComboboxMembers(el);
|
|
315
|
-
|
|
316
|
-
|
|
291
|
+
_inputNode.dispatchEvent(
|
|
292
|
+
new KeyboardEvent('keyup', {
|
|
293
|
+
key: 'Escape',
|
|
294
|
+
}),
|
|
295
|
+
);
|
|
317
296
|
await el.updateComplete;
|
|
318
297
|
expect(el.opened).to.be.false;
|
|
319
298
|
});
|
|
320
|
-
|
|
321
299
|
it('hides listbox on click/enter (when multiple-choice is false)', async () => {
|
|
322
|
-
const el =
|
|
300
|
+
const el =
|
|
301
|
+
/** @type {LionCombobox} */
|
|
323
302
|
await fixture(html`
|
|
324
303
|
<lion-combobox name="foo" .showAllOnEmpty="${true}">
|
|
325
304
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -327,11 +306,8 @@ describe('lion-combobox', () => {
|
|
|
327
306
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
328
307
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
329
308
|
</lion-combobox>
|
|
330
|
-
`)
|
|
331
|
-
);
|
|
332
|
-
|
|
309
|
+
`);
|
|
333
310
|
const { _listboxNode, _inputNode } = getComboboxMembers(el);
|
|
334
|
-
|
|
335
311
|
async function open() {
|
|
336
312
|
await mimicUserTyping(el, 'ch');
|
|
337
313
|
return el.updateComplete;
|
|
@@ -345,75 +321,66 @@ describe('lion-combobox', () => {
|
|
|
345
321
|
if (isSafari) {
|
|
346
322
|
return;
|
|
347
323
|
}
|
|
348
|
-
|
|
349
324
|
await open();
|
|
350
325
|
expect(el.opened).to.be.true;
|
|
351
|
-
const visibleOptions = el.formElements.filter(o => o.style.display !== 'none');
|
|
326
|
+
const visibleOptions = el.formElements.filter((o) => o.style.display !== 'none');
|
|
352
327
|
visibleOptions[0].click();
|
|
353
328
|
await el.updateComplete;
|
|
354
329
|
expect(el.opened).to.be.false;
|
|
355
|
-
|
|
356
330
|
_inputNode.value = '';
|
|
357
331
|
_inputNode.blur();
|
|
358
332
|
await open();
|
|
359
333
|
await el.updateComplete;
|
|
360
|
-
|
|
361
334
|
el.activeIndex = el.formElements.indexOf(visibleOptions[0]);
|
|
362
335
|
mimicKeyPress(_listboxNode, 'Enter');
|
|
363
336
|
expect(el.opened).to.be.false;
|
|
364
337
|
});
|
|
365
338
|
});
|
|
366
339
|
});
|
|
367
|
-
|
|
368
340
|
describe('Structure', () => {
|
|
369
341
|
it('has a listbox node', async () => {
|
|
370
|
-
const el =
|
|
342
|
+
const el =
|
|
343
|
+
/** @type {LionCombobox} */
|
|
371
344
|
await fixture(html`
|
|
372
345
|
<lion-combobox name="foo">
|
|
373
346
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
374
347
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
375
348
|
</lion-combobox>
|
|
376
|
-
`)
|
|
377
|
-
);
|
|
349
|
+
`);
|
|
378
350
|
const { _listboxNode } = getComboboxMembers(el);
|
|
379
|
-
|
|
380
351
|
expect(_listboxNode).to.exist;
|
|
381
352
|
// TODO: worked before, find out what has changed in ScopedElements
|
|
382
353
|
// expect(_listboxNode instanceof LionOptions).to.be.true;
|
|
383
354
|
expect(el.querySelector('[role=listbox]')).to.equal(_listboxNode);
|
|
384
355
|
});
|
|
385
|
-
|
|
386
356
|
it('has a textbox element', async () => {
|
|
387
|
-
const el =
|
|
357
|
+
const el =
|
|
358
|
+
/** @type {LionCombobox} */
|
|
388
359
|
await fixture(html`
|
|
389
360
|
<lion-combobox name="foo">
|
|
390
361
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
391
362
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
392
363
|
</lion-combobox>
|
|
393
|
-
`)
|
|
394
|
-
);
|
|
364
|
+
`);
|
|
395
365
|
const { _comboboxNode } = getComboboxMembers(el);
|
|
396
|
-
|
|
397
366
|
expect(_comboboxNode).to.exist;
|
|
398
367
|
expect(el.querySelector('[role=combobox]')).to.equal(_comboboxNode);
|
|
399
368
|
});
|
|
400
|
-
|
|
401
369
|
it('has validator "MatchesOption" applied by default', async () => {
|
|
402
|
-
const el =
|
|
370
|
+
const el =
|
|
371
|
+
/** @type {LionCombobox} */
|
|
403
372
|
await fixture(html`
|
|
404
373
|
<lion-combobox name="foo">
|
|
405
374
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
406
375
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
407
376
|
</lion-combobox>
|
|
408
|
-
`)
|
|
409
|
-
);
|
|
377
|
+
`);
|
|
410
378
|
await mimicUserTyping(el, '30');
|
|
411
379
|
await el.updateComplete;
|
|
412
380
|
expect(el.hasFeedbackFor).to.include('error');
|
|
413
381
|
expect(el.validationStates).to.have.property('error');
|
|
414
382
|
expect(el.validationStates.error).to.have.property('MatchesOption');
|
|
415
383
|
});
|
|
416
|
-
|
|
417
384
|
it('keeps slottable provided in `slots` getter as direct host child', async () => {
|
|
418
385
|
class MyEl extends SlotMixin(LionCombobox) {
|
|
419
386
|
// @ts-ignore
|
|
@@ -428,7 +395,6 @@ describe('lion-combobox', () => {
|
|
|
428
395
|
}),
|
|
429
396
|
};
|
|
430
397
|
}
|
|
431
|
-
|
|
432
398
|
_labelTemplate() {
|
|
433
399
|
return html`
|
|
434
400
|
<div class="form-field__label">
|
|
@@ -438,7 +404,6 @@ describe('lion-combobox', () => {
|
|
|
438
404
|
</div>
|
|
439
405
|
`;
|
|
440
406
|
}
|
|
441
|
-
|
|
442
407
|
constructor() {
|
|
443
408
|
super();
|
|
444
409
|
this.renderSlot = false;
|
|
@@ -446,44 +411,39 @@ describe('lion-combobox', () => {
|
|
|
446
411
|
}
|
|
447
412
|
const tagName = defineCE(MyEl);
|
|
448
413
|
const wrappingTag = unsafeStatic(tagName);
|
|
449
|
-
|
|
450
|
-
|
|
414
|
+
const el =
|
|
415
|
+
/** @type {MyEl} */
|
|
451
416
|
await fixture(html`
|
|
452
417
|
<${wrappingTag} label="my label">
|
|
453
418
|
<lion-option .choiceValue="${'1'}">${'one'}</lion-option>
|
|
454
419
|
</${wrappingTag}>
|
|
455
|
-
`)
|
|
456
|
-
);
|
|
420
|
+
`);
|
|
457
421
|
await el.registrationComplete;
|
|
458
|
-
|
|
459
422
|
el.renderSlot = true;
|
|
460
423
|
await el.updateComplete;
|
|
461
424
|
const lazyRenderedSlot = el.querySelector('#lazyRenderedSlotId');
|
|
462
425
|
expect(lazyRenderedSlot?.parentElement === el).to.be.true;
|
|
463
426
|
});
|
|
464
427
|
});
|
|
465
|
-
|
|
466
428
|
describe('Values', () => {
|
|
467
429
|
it('syncs modelValue with textbox', async () => {
|
|
468
|
-
const el =
|
|
430
|
+
const el =
|
|
431
|
+
/** @type {LionCombobox} */
|
|
469
432
|
await fixture(html`
|
|
470
433
|
<lion-combobox name="foo" .modelValue="${'10'}">
|
|
471
434
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
472
435
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
473
436
|
</lion-combobox>
|
|
474
|
-
`)
|
|
475
|
-
);
|
|
437
|
+
`);
|
|
476
438
|
const { _inputNode } = getComboboxMembers(el);
|
|
477
|
-
|
|
478
439
|
expect(_inputNode.value).to.equal('10');
|
|
479
|
-
|
|
480
440
|
el.modelValue = '20';
|
|
481
441
|
await el.updateComplete;
|
|
482
442
|
expect(_inputNode.value).to.equal('20');
|
|
483
443
|
});
|
|
484
|
-
|
|
485
444
|
it('sets modelValue to Unparseable if no option is selected', async () => {
|
|
486
|
-
const el =
|
|
445
|
+
const el =
|
|
446
|
+
/** @type {LionCombobox} */
|
|
487
447
|
await fixture(html`
|
|
488
448
|
<lion-combobox name="foo" .modelValue="${'Artichoke'}">
|
|
489
449
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -491,10 +451,8 @@ describe('lion-combobox', () => {
|
|
|
491
451
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
492
452
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
493
453
|
</lion-combobox>
|
|
494
|
-
`)
|
|
495
|
-
);
|
|
454
|
+
`);
|
|
496
455
|
const { _inputNode } = getComboboxMembers(el);
|
|
497
|
-
|
|
498
456
|
expect(el.modelValue).to.equal('Artichoke');
|
|
499
457
|
expect(el.formElements[0].checked).to.be.true;
|
|
500
458
|
el.setCheckedIndex(-1);
|
|
@@ -503,7 +461,6 @@ describe('lion-combobox', () => {
|
|
|
503
461
|
expect(el.modelValue instanceof Unparseable).to.be.true;
|
|
504
462
|
expect(el.modelValue.viewValue).to.equal('Artichoke');
|
|
505
463
|
expect(el.formElements[0].checked).to.be.false;
|
|
506
|
-
|
|
507
464
|
el.setCheckedIndex(-1);
|
|
508
465
|
_inputNode.value = 'Foo';
|
|
509
466
|
el.__shouldAutocompleteNextUpdate = true;
|
|
@@ -511,7 +468,6 @@ describe('lion-combobox', () => {
|
|
|
511
468
|
expect(el.modelValue instanceof Unparseable).to.be.true;
|
|
512
469
|
expect(el.modelValue.viewValue).to.equal('Foo');
|
|
513
470
|
expect(el.formElements[0].checked).to.be.false;
|
|
514
|
-
|
|
515
471
|
el.setCheckedIndex(0);
|
|
516
472
|
el.__shouldAutocompleteNextUpdate = true;
|
|
517
473
|
await el.updateComplete;
|
|
@@ -519,9 +475,9 @@ describe('lion-combobox', () => {
|
|
|
519
475
|
expect(el.modelValue).to.equal('Artichoke');
|
|
520
476
|
expect(el.formElements[0].checked).to.be.true;
|
|
521
477
|
});
|
|
522
|
-
|
|
523
478
|
it('sets modelValue to _inputNode.value if no option is selected when requireOptionMatch is false', async () => {
|
|
524
|
-
const el =
|
|
479
|
+
const el =
|
|
480
|
+
/** @type {LionCombobox} */
|
|
525
481
|
await fixture(html`
|
|
526
482
|
<lion-combobox name="foo" .modelValue="${'Artichoke'}" .requireOptionMatch="${false}">
|
|
527
483
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -529,10 +485,8 @@ describe('lion-combobox', () => {
|
|
|
529
485
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
530
486
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
531
487
|
</lion-combobox>
|
|
532
|
-
`)
|
|
533
|
-
);
|
|
488
|
+
`);
|
|
534
489
|
const { _inputNode } = getComboboxMembers(el);
|
|
535
|
-
|
|
536
490
|
expect(el.modelValue).to.equal('Artichoke');
|
|
537
491
|
expect(el.formElements[0].checked).to.be.true;
|
|
538
492
|
el.setCheckedIndex(-1);
|
|
@@ -540,7 +494,6 @@ describe('lion-combobox', () => {
|
|
|
540
494
|
await el.updateComplete;
|
|
541
495
|
expect(el.modelValue).to.equal('Artichoke');
|
|
542
496
|
expect(el.formElements[0].checked).to.be.true;
|
|
543
|
-
|
|
544
497
|
el.setCheckedIndex(-1);
|
|
545
498
|
_inputNode.value = 'Foo';
|
|
546
499
|
el.__shouldAutocompleteNextUpdate = true;
|
|
@@ -548,9 +501,9 @@ describe('lion-combobox', () => {
|
|
|
548
501
|
expect(el.modelValue).to.equal('Foo');
|
|
549
502
|
expect(el.formElements[0].checked).to.be.false;
|
|
550
503
|
});
|
|
551
|
-
|
|
552
504
|
it('sets modelValue to empty array if no option is selected for multiple choice', async () => {
|
|
553
|
-
const el =
|
|
505
|
+
const el =
|
|
506
|
+
/** @type {LionCombobox} */
|
|
554
507
|
await fixture(html`
|
|
555
508
|
<lion-combobox name="foo" multiple-choice .modelValue="${['Artichoke']}">
|
|
556
509
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -558,8 +511,7 @@ describe('lion-combobox', () => {
|
|
|
558
511
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
559
512
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
560
513
|
</lion-combobox>
|
|
561
|
-
`)
|
|
562
|
-
);
|
|
514
|
+
`);
|
|
563
515
|
expect(el.modelValue).to.deep.equal(['Artichoke']);
|
|
564
516
|
expect(el.formElements[0].checked).to.be.true;
|
|
565
517
|
el.setCheckedIndex([]);
|
|
@@ -567,9 +519,9 @@ describe('lion-combobox', () => {
|
|
|
567
519
|
expect(el.modelValue).to.deep.equal([]);
|
|
568
520
|
expect(el.formElements[0].checked).to.be.false;
|
|
569
521
|
});
|
|
570
|
-
|
|
571
522
|
it('clears modelValue and textbox value on clear()', async () => {
|
|
572
|
-
const el =
|
|
523
|
+
const el =
|
|
524
|
+
/** @type {LionCombobox} */
|
|
573
525
|
await fixture(html`
|
|
574
526
|
<lion-combobox name="foo" .modelValue="${'Artichoke'}">
|
|
575
527
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -577,16 +529,13 @@ describe('lion-combobox', () => {
|
|
|
577
529
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
578
530
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
579
531
|
</lion-combobox>
|
|
580
|
-
`)
|
|
581
|
-
);
|
|
582
|
-
|
|
532
|
+
`);
|
|
583
533
|
const { _inputNode } = getComboboxMembers(el);
|
|
584
|
-
|
|
585
534
|
el.clear();
|
|
586
535
|
expect(el.modelValue).to.equal('');
|
|
587
536
|
expect(_inputNode.value).to.equal('');
|
|
588
|
-
|
|
589
|
-
|
|
537
|
+
const el2 =
|
|
538
|
+
/** @type {LionCombobox} */
|
|
590
539
|
await fixture(html`
|
|
591
540
|
<lion-combobox name="foo" multiple-choice .modelValue="${['Artichoke']}">
|
|
592
541
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -594,43 +543,36 @@ describe('lion-combobox', () => {
|
|
|
594
543
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
595
544
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
596
545
|
</lion-combobox>
|
|
597
|
-
`)
|
|
598
|
-
);
|
|
599
|
-
|
|
546
|
+
`);
|
|
600
547
|
el2.clear();
|
|
601
548
|
expect(el2.modelValue).to.eql([]);
|
|
602
549
|
// @ts-ignore [allow-protected] in test
|
|
603
550
|
expect(el2._inputNode.value).to.equal('');
|
|
604
551
|
});
|
|
605
|
-
|
|
606
552
|
it('correctly emits event with an empty value when clear() is called', async () => {
|
|
607
|
-
const el =
|
|
553
|
+
const el =
|
|
554
|
+
/** @type {LionCombobox} */
|
|
608
555
|
await fixture(
|
|
609
556
|
html`<lion-combobox>
|
|
610
557
|
<lion-option .choiceValue=${'red'}>Red</lion-option>
|
|
611
558
|
<lion-option .choiceValue=${'green'}>Green</lion-option>
|
|
612
559
|
<lion-option .choiceValue=${'blue'}>Blue</lion-option>
|
|
613
560
|
</lion-combobox>`,
|
|
614
|
-
)
|
|
615
|
-
);
|
|
616
|
-
|
|
561
|
+
);
|
|
617
562
|
el.modelValue = 'red';
|
|
618
563
|
await el.updateComplete;
|
|
619
|
-
|
|
620
564
|
el.addEventListener('model-value-changed', ({ target }) => {
|
|
621
565
|
expect(target).to.not.be.null;
|
|
622
|
-
|
|
623
|
-
const { modelValue, value } = /** @type {LionCombobox} */ (target);
|
|
566
|
+
const { modelValue, value } = /** @type {LionCombobox} */ target;
|
|
624
567
|
expect(value).to.equal('');
|
|
625
568
|
expect(modelValue).to.equal('');
|
|
626
569
|
});
|
|
627
|
-
|
|
628
570
|
el.clear();
|
|
629
571
|
await el.updateComplete;
|
|
630
572
|
});
|
|
631
|
-
|
|
632
573
|
it('updates option list after clear()', async () => {
|
|
633
|
-
const el =
|
|
574
|
+
const el =
|
|
575
|
+
/** @type {LionCombobox} */
|
|
634
576
|
await fixture(html`
|
|
635
577
|
<lion-combobox name="foo" multiple-choice>
|
|
636
578
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -638,22 +580,19 @@ describe('lion-combobox', () => {
|
|
|
638
580
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
639
581
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
640
582
|
</lion-combobox>
|
|
641
|
-
`)
|
|
642
|
-
);
|
|
583
|
+
`);
|
|
643
584
|
const options = el.formElements;
|
|
644
585
|
await mimicUserTyping(el, 'a');
|
|
645
586
|
await el.updateComplete;
|
|
646
|
-
|
|
647
|
-
const visibleOptions = () => options.filter(o => o.style.display !== 'none');
|
|
587
|
+
const visibleOptions = () => options.filter((o) => o.style.display !== 'none');
|
|
648
588
|
expect(visibleOptions().length).to.equal(3, 'after input');
|
|
649
|
-
|
|
650
589
|
el.clear();
|
|
651
590
|
await el.updateComplete;
|
|
652
591
|
expect(visibleOptions().length).to.equal(0, 'after clear');
|
|
653
592
|
});
|
|
654
|
-
|
|
655
593
|
it('keeps interaction states on clear()', async () => {
|
|
656
|
-
const el =
|
|
594
|
+
const el =
|
|
595
|
+
/** @type {LionCombobox} */
|
|
657
596
|
await fixture(html`
|
|
658
597
|
<lion-combobox name="foo">
|
|
659
598
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -661,19 +600,17 @@ describe('lion-combobox', () => {
|
|
|
661
600
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
662
601
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
663
602
|
</lion-combobox>
|
|
664
|
-
`)
|
|
665
|
-
);
|
|
603
|
+
`);
|
|
666
604
|
await mimicUserTyping(el, 'a');
|
|
667
605
|
await el.updateComplete;
|
|
668
606
|
expect(el.dirty).to.equal(true);
|
|
669
|
-
|
|
670
607
|
el.clear();
|
|
671
608
|
await el.updateComplete;
|
|
672
609
|
expect(el.dirty).to.equal(true);
|
|
673
610
|
});
|
|
674
|
-
|
|
675
611
|
it('resets modelValue and textbox value on reset()', async () => {
|
|
676
|
-
const el =
|
|
612
|
+
const el =
|
|
613
|
+
/** @type {LionCombobox} */
|
|
677
614
|
await fixture(html`
|
|
678
615
|
<lion-combobox name="foo" .modelValue="${'Artichoke'}">
|
|
679
616
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -681,16 +618,14 @@ describe('lion-combobox', () => {
|
|
|
681
618
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
682
619
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
683
620
|
</lion-combobox>
|
|
684
|
-
`)
|
|
685
|
-
);
|
|
686
|
-
|
|
621
|
+
`);
|
|
687
622
|
const { _inputNode } = getComboboxMembers(el);
|
|
688
623
|
el.modelValue = 'Chard';
|
|
689
624
|
el.reset();
|
|
690
625
|
expect(el.modelValue).to.equal('Artichoke');
|
|
691
626
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
692
|
-
|
|
693
|
-
|
|
627
|
+
const el2 =
|
|
628
|
+
/** @type {LionCombobox} */
|
|
694
629
|
await fixture(html`
|
|
695
630
|
<lion-combobox name="foo" multiple-choice .modelValue="${['Artichoke']}">
|
|
696
631
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -698,40 +633,37 @@ describe('lion-combobox', () => {
|
|
|
698
633
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
699
634
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
700
635
|
</lion-combobox>
|
|
701
|
-
`)
|
|
702
|
-
);
|
|
636
|
+
`);
|
|
703
637
|
el2.modelValue = ['Artichoke', 'Chard'];
|
|
704
638
|
el2.reset();
|
|
705
639
|
expect(el2.modelValue).to.deep.equal(['Artichoke']);
|
|
706
640
|
// @ts-ignore [allow-protected] in test
|
|
707
641
|
expect(el2._inputNode.value).to.equal('');
|
|
708
642
|
});
|
|
709
|
-
|
|
710
643
|
it('syncs textbox to modelValue', async () => {
|
|
711
644
|
for (const autocompleteMode of ['none', 'list', 'inline', 'both']) {
|
|
712
|
-
const el =
|
|
645
|
+
const el =
|
|
646
|
+
/** @type {LionCombobox} */
|
|
713
647
|
await fixture(html`
|
|
714
648
|
<lion-combobox name="foo" show-all-on-empty .autocomplete="${autocompleteMode}">
|
|
715
649
|
<lion-option .choiceValue="${'Aa'}" checked>Aa</lion-option>
|
|
716
650
|
<lion-option .choiceValue="${'Bb'}">Bb</lion-option>
|
|
717
651
|
</lion-combobox>
|
|
718
|
-
`)
|
|
719
|
-
);
|
|
652
|
+
`);
|
|
720
653
|
const { _inputNode } = getComboboxMembers(el);
|
|
721
|
-
|
|
722
654
|
expect(_inputNode.value).to.equal('Aa', `autocompleteMode is ${autocompleteMode}`);
|
|
723
|
-
|
|
724
655
|
el.formElements[0].click();
|
|
725
656
|
await el.updateComplete;
|
|
726
|
-
|
|
727
657
|
expect(_inputNode.value).to.equal('Aa', `autocompleteMode is ${autocompleteMode}`);
|
|
728
658
|
expect(el.checkedIndex).to.equal(0, `autocompleteMode is ${autocompleteMode}`);
|
|
729
|
-
|
|
730
659
|
await mimicUserTyping(el, 'B');
|
|
731
660
|
await el.updateComplete;
|
|
732
661
|
if (autocompleteMode === 'none' || autocompleteMode === 'list') {
|
|
733
662
|
expect(el.modelValue).to.deep.equal(
|
|
734
|
-
{
|
|
663
|
+
{
|
|
664
|
+
type: 'unparseable',
|
|
665
|
+
viewValue: 'B',
|
|
666
|
+
},
|
|
735
667
|
`autocompleteMode is ${autocompleteMode}`,
|
|
736
668
|
);
|
|
737
669
|
await el.updateComplete;
|
|
@@ -742,9 +674,9 @@ describe('lion-combobox', () => {
|
|
|
742
674
|
}
|
|
743
675
|
}
|
|
744
676
|
});
|
|
745
|
-
|
|
746
677
|
it('works with Required validator', async () => {
|
|
747
|
-
const el =
|
|
678
|
+
const el =
|
|
679
|
+
/** @type {LionCombobox} */
|
|
748
680
|
await fixture(html`
|
|
749
681
|
<lion-combobox name="foo" .validators=${[new Required()]}>
|
|
750
682
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -752,17 +684,16 @@ describe('lion-combobox', () => {
|
|
|
752
684
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
753
685
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
754
686
|
</lion-combobox>
|
|
755
|
-
`)
|
|
756
|
-
);
|
|
687
|
+
`);
|
|
757
688
|
el.submitted = true;
|
|
758
689
|
await el.feedbackComplete;
|
|
759
690
|
expect(el.hasFeedbackFor).to.include('error', 'hasFeedbackFor');
|
|
760
691
|
await el.feedbackComplete;
|
|
761
692
|
expect(el.showsFeedbackFor).to.include('error', 'showsFeedbackFor');
|
|
762
693
|
});
|
|
763
|
-
|
|
764
694
|
it('ignores empty string modelValue inputs', async () => {
|
|
765
|
-
const el =
|
|
695
|
+
const el =
|
|
696
|
+
/** @type {LionCombobox} */
|
|
766
697
|
await fixture(html`
|
|
767
698
|
<lion-combobox name="foo" multiple-choice autocomplete="none">
|
|
768
699
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -770,26 +701,22 @@ describe('lion-combobox', () => {
|
|
|
770
701
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
771
702
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
772
703
|
</lion-combobox>
|
|
773
|
-
`)
|
|
774
|
-
);
|
|
775
|
-
|
|
704
|
+
`);
|
|
776
705
|
el.requireOptionMatch = false;
|
|
777
706
|
await el.updateComplete;
|
|
778
707
|
const { _inputNode } = getComboboxMembers(el);
|
|
779
|
-
|
|
780
708
|
mimicKeyPress(_inputNode, 'Enter');
|
|
781
709
|
await el.updateComplete;
|
|
782
710
|
expect(el.modelValue).to.eql([]);
|
|
783
|
-
|
|
784
711
|
await mimicUserTyping(el, ' ');
|
|
785
712
|
await el.updateComplete;
|
|
786
713
|
mimicKeyPress(_inputNode, 'Enter');
|
|
787
714
|
await el.updateComplete;
|
|
788
715
|
expect(el.modelValue).to.eql([]);
|
|
789
716
|
});
|
|
790
|
-
|
|
791
717
|
it('allows a value outside of the option list when requireOptionMatch is false', async () => {
|
|
792
|
-
const el =
|
|
718
|
+
const el =
|
|
719
|
+
/** @type {LionCombobox} */
|
|
793
720
|
await fixture(html`
|
|
794
721
|
<lion-combobox name="foo" .validators=${[new Required()]}>
|
|
795
722
|
<lion-option checked .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -797,23 +724,20 @@ describe('lion-combobox', () => {
|
|
|
797
724
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
798
725
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
799
726
|
</lion-combobox>
|
|
800
|
-
`)
|
|
801
|
-
);
|
|
727
|
+
`);
|
|
802
728
|
el.requireOptionMatch = false;
|
|
803
729
|
const { _inputNode } = getComboboxMembers(el);
|
|
804
730
|
expect(el.checkedIndex).to.equal(0);
|
|
805
|
-
|
|
806
731
|
await mimicUserTyping(el, 'Foo');
|
|
807
732
|
_inputNode.dispatchEvent(new Event('input'));
|
|
808
733
|
await el.updateComplete;
|
|
809
|
-
|
|
810
734
|
expect(el.checkedIndex).to.equal(-1);
|
|
811
735
|
expect(el.modelValue).to.equal('Foo');
|
|
812
736
|
expect(_inputNode.value).to.equal('Foo');
|
|
813
737
|
});
|
|
814
|
-
|
|
815
738
|
it('fires "model-value-changed" on every textbox change when requireOptionMatch is false and autocomplete is both', async () => {
|
|
816
|
-
const el =
|
|
739
|
+
const el =
|
|
740
|
+
/** @type {LionCombobox} */
|
|
817
741
|
await fixture(html`
|
|
818
742
|
<lion-combobox name="foo" autocomplete="both" .requireOptionMatch="${false}">
|
|
819
743
|
<lion-option checked .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -821,12 +745,9 @@ describe('lion-combobox', () => {
|
|
|
821
745
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
822
746
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
823
747
|
</lion-combobox>
|
|
824
|
-
`)
|
|
825
|
-
);
|
|
826
|
-
|
|
827
|
-
const fake = sinon.fake(ev => ev.target.modelValue);
|
|
748
|
+
`);
|
|
749
|
+
const fake = sinon.fake((ev) => ev.target.modelValue);
|
|
828
750
|
el.addEventListener('model-value-changed', fake);
|
|
829
|
-
|
|
830
751
|
await mimicUserTyping(el, 'Foo');
|
|
831
752
|
await el.updateComplete;
|
|
832
753
|
expect(fake).to.have.been.calledThrice;
|
|
@@ -835,9 +756,9 @@ describe('lion-combobox', () => {
|
|
|
835
756
|
expect(fake.thirdCall.returnValue).to.equal('Foo');
|
|
836
757
|
expect(el.modelValue).to.equal('Foo');
|
|
837
758
|
});
|
|
838
|
-
|
|
839
759
|
it('fires "model-value-changed" on every textbox change when requireOptionMatch is false and autocomplete is none', async () => {
|
|
840
|
-
const el =
|
|
760
|
+
const el =
|
|
761
|
+
/** @type {LionCombobox} */
|
|
841
762
|
await fixture(html`
|
|
842
763
|
<lion-combobox name="foo" autocomplete="none" .requireOptionMatch="${false}">
|
|
843
764
|
<lion-option checked .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -845,12 +766,9 @@ describe('lion-combobox', () => {
|
|
|
845
766
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
846
767
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
847
768
|
</lion-combobox>
|
|
848
|
-
`)
|
|
849
|
-
);
|
|
850
|
-
|
|
851
|
-
const fake = sinon.fake(ev => ev.target.modelValue);
|
|
769
|
+
`);
|
|
770
|
+
const fake = sinon.fake((ev) => ev.target.modelValue);
|
|
852
771
|
el.addEventListener('model-value-changed', fake);
|
|
853
|
-
|
|
854
772
|
await mimicUserTyping(el, 'Foo');
|
|
855
773
|
await el.updateComplete;
|
|
856
774
|
expect(fake.callCount).to.equal(4);
|
|
@@ -860,9 +778,9 @@ describe('lion-combobox', () => {
|
|
|
860
778
|
expect(fake.getCall(3).returnValue).to.equal('Foo');
|
|
861
779
|
expect(el.modelValue).to.equal('Foo');
|
|
862
780
|
});
|
|
863
|
-
|
|
864
781
|
it('does not fire "model-value-changed" when requireOptionMatch is false but the textbox value did not change', async () => {
|
|
865
|
-
const el =
|
|
782
|
+
const el =
|
|
783
|
+
/** @type {LionCombobox} */
|
|
866
784
|
await fixture(html`
|
|
867
785
|
<lion-combobox name="foo" autocomplete="none" .requireOptionMatch="${false}">
|
|
868
786
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -870,23 +788,20 @@ describe('lion-combobox', () => {
|
|
|
870
788
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
871
789
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
872
790
|
</lion-combobox>
|
|
873
|
-
`)
|
|
874
|
-
);
|
|
791
|
+
`);
|
|
875
792
|
await mimicUserTyping(el, 'Foo');
|
|
876
793
|
await el.updateComplete;
|
|
877
|
-
|
|
878
794
|
const spy = sinon.spy();
|
|
879
795
|
el.addEventListener('model-value-changed', spy);
|
|
880
796
|
|
|
881
797
|
// Re-triggering autocompletion with the exact same textbox value should not dispatch again
|
|
882
798
|
el.__shouldAutocompleteNextUpdate = true;
|
|
883
799
|
await el.updateComplete;
|
|
884
|
-
|
|
885
800
|
expect(spy).to.not.have.been.called;
|
|
886
801
|
});
|
|
887
|
-
|
|
888
802
|
it('fires "model-value-changed" via checked option repropagation (not the manual dispatch) when requireOptionMatch is true', async () => {
|
|
889
|
-
const el =
|
|
803
|
+
const el =
|
|
804
|
+
/** @type {LionCombobox} */
|
|
890
805
|
await fixture(html`
|
|
891
806
|
<lion-combobox name="foo" autocomplete="both">
|
|
892
807
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -894,16 +809,13 @@ describe('lion-combobox', () => {
|
|
|
894
809
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
895
810
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
896
811
|
</lion-combobox>
|
|
897
|
-
`)
|
|
898
|
-
);
|
|
812
|
+
`);
|
|
899
813
|
const spy = sinon.spy();
|
|
900
814
|
el.addEventListener('model-value-changed', spy);
|
|
901
|
-
|
|
902
815
|
await mimicUserTyping(el, 'cha');
|
|
903
816
|
await el.updateComplete;
|
|
904
817
|
expect(el.modelValue).to.equal('Chard');
|
|
905
818
|
expect(spy).to.have.been.calledOnce;
|
|
906
|
-
|
|
907
819
|
spy.resetHistory();
|
|
908
820
|
// No option matches "xyz", so checkedIndex stays -1 and requireOptionMatch is true:
|
|
909
821
|
// no event should be manually dispatched (normal Unparseable flow, no double event)
|
|
@@ -912,9 +824,9 @@ describe('lion-combobox', () => {
|
|
|
912
824
|
expect(el.modelValue instanceof Unparseable).to.be.true;
|
|
913
825
|
expect(spy).to.have.been.calledOnce;
|
|
914
826
|
});
|
|
915
|
-
|
|
916
827
|
it('fires "model-value-changed" via checked option repropagation (not the manual dispatch) when requireOptionMatch is false and no option matches the input', async () => {
|
|
917
|
-
const el =
|
|
828
|
+
const el =
|
|
829
|
+
/** @type {LionCombobox} */
|
|
918
830
|
await fixture(html`
|
|
919
831
|
<lion-combobox name="foo" autocomplete="both">
|
|
920
832
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -922,12 +834,9 @@ describe('lion-combobox', () => {
|
|
|
922
834
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
923
835
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
924
836
|
</lion-combobox>
|
|
925
|
-
`)
|
|
926
|
-
);
|
|
927
|
-
|
|
837
|
+
`);
|
|
928
838
|
el.requireOptionMatch = false;
|
|
929
839
|
await el.updateComplete;
|
|
930
|
-
|
|
931
840
|
const spy = sinon.spy();
|
|
932
841
|
el.addEventListener('model-value-changed', spy);
|
|
933
842
|
|
|
@@ -939,9 +848,9 @@ describe('lion-combobox', () => {
|
|
|
939
848
|
expect(spy.args.length).to.equal(3);
|
|
940
849
|
expect(spy.args[2][0].target.modelValue).to.equal('Chicorys');
|
|
941
850
|
});
|
|
942
|
-
|
|
943
851
|
it("doesn't select any similar options after using delete when requireOptionMatch is false", async () => {
|
|
944
|
-
const el =
|
|
852
|
+
const el =
|
|
853
|
+
/** @type {LionCombobox} */
|
|
945
854
|
await fixture(html`
|
|
946
855
|
<lion-combobox name="foo" .validators=${[new Required()]}>
|
|
947
856
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -949,29 +858,24 @@ describe('lion-combobox', () => {
|
|
|
949
858
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
950
859
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
951
860
|
</lion-combobox>
|
|
952
|
-
`)
|
|
953
|
-
);
|
|
861
|
+
`);
|
|
954
862
|
el.requireOptionMatch = false;
|
|
955
863
|
const { _inputNode } = getComboboxMembers(el);
|
|
956
|
-
|
|
957
864
|
await mimicUserTyping(el, 'Art');
|
|
958
865
|
await el.updateComplete;
|
|
959
|
-
|
|
960
866
|
await mimicUserTypingAdvanced(el, ['Delete']);
|
|
961
867
|
await el.updateComplete;
|
|
962
868
|
await el.updateComplete;
|
|
963
|
-
|
|
964
869
|
mimicKeyPress(_inputNode, 'Enter');
|
|
965
870
|
await el.updateComplete;
|
|
966
|
-
|
|
967
871
|
expect(el.checkedIndex).to.equal(-1);
|
|
968
872
|
expect(el.modelValue).to.equal('Art');
|
|
969
873
|
expect(_inputNode.value).to.equal('Art');
|
|
970
874
|
});
|
|
971
|
-
|
|
972
875
|
it("when removing a letter it won't select the option", async () => {
|
|
973
876
|
// We don't autocomplete when characters are removed
|
|
974
|
-
const el =
|
|
877
|
+
const el =
|
|
878
|
+
/** @type {LionCombobox} */
|
|
975
879
|
await fixture(html`
|
|
976
880
|
<lion-combobox name="foo">
|
|
977
881
|
<lion-option checked .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -979,8 +883,7 @@ describe('lion-combobox', () => {
|
|
|
979
883
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
980
884
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
981
885
|
</lion-combobox>
|
|
982
|
-
`)
|
|
983
|
-
);
|
|
886
|
+
`);
|
|
984
887
|
const { _inputNode } = getComboboxMembers(el);
|
|
985
888
|
expect(el.checkedIndex).to.equal(0);
|
|
986
889
|
|
|
@@ -992,28 +895,25 @@ describe('lion-combobox', () => {
|
|
|
992
895
|
_inputNode.value = arr.join('');
|
|
993
896
|
await el.updateComplete;
|
|
994
897
|
el.dispatchEvent(new Event('blur'));
|
|
995
|
-
|
|
996
898
|
expect(el.checkedIndex).to.equal(-1);
|
|
997
899
|
expect(el.modelValue instanceof Unparseable).to.be.true;
|
|
998
900
|
expect(el.modelValue.viewValue).to.equal('Artichok');
|
|
999
901
|
});
|
|
1000
|
-
|
|
1001
902
|
it('allows the user to override the parser', async () => {
|
|
1002
|
-
const el =
|
|
903
|
+
const el =
|
|
904
|
+
/** @type {LionCombobox} */
|
|
1003
905
|
await fixture(html`
|
|
1004
906
|
<lion-combobox
|
|
1005
907
|
name="foo"
|
|
1006
|
-
.parser="${/** @param {string} value */ value => value.replace(/[0-9]/g, '')}"
|
|
908
|
+
.parser="${/** @param {string} value */ (value) => value.replace(/[0-9]/g, '')}"
|
|
1007
909
|
>
|
|
1008
910
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
1009
911
|
<lion-option .choiceValue="${'Chard'}">Chard</lion-option>
|
|
1010
912
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1011
913
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1012
914
|
</lion-combobox>
|
|
1013
|
-
`)
|
|
1014
|
-
);
|
|
915
|
+
`);
|
|
1015
916
|
const { _inputNode } = getComboboxMembers(el);
|
|
1016
|
-
|
|
1017
917
|
el.setCheckedIndex(-1);
|
|
1018
918
|
_inputNode.value = 'Foo123';
|
|
1019
919
|
el.__shouldAutocompleteNextUpdate = true;
|
|
@@ -1021,9 +921,9 @@ describe('lion-combobox', () => {
|
|
|
1021
921
|
expect(el.modelValue).to.equal('Foo');
|
|
1022
922
|
expect(el.formElements[0].checked).to.be.false;
|
|
1023
923
|
});
|
|
1024
|
-
|
|
1025
924
|
it('allows custom selections when multi-choice when requireOptionMatch is false', async () => {
|
|
1026
|
-
const el =
|
|
925
|
+
const el =
|
|
926
|
+
/** @type {LionCombobox} */
|
|
1027
927
|
await fixture(html`
|
|
1028
928
|
<lion-combobox
|
|
1029
929
|
name="foo"
|
|
@@ -1036,32 +936,26 @@ describe('lion-combobox', () => {
|
|
|
1036
936
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1037
937
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1038
938
|
</lion-combobox>
|
|
1039
|
-
`)
|
|
1040
|
-
);
|
|
1041
|
-
|
|
939
|
+
`);
|
|
1042
940
|
el.requireOptionMatch = false;
|
|
1043
941
|
await el.updateComplete;
|
|
1044
|
-
|
|
1045
942
|
const { _inputNode } = getComboboxMembers(el);
|
|
1046
943
|
expect(el.modelValue).to.eql(['Chard']);
|
|
1047
944
|
expect(el.checkedIndex).to.eql([1]);
|
|
1048
|
-
|
|
1049
945
|
await mimicUserTyping(el, 'Foo');
|
|
1050
946
|
await el.updateComplete;
|
|
1051
947
|
mimicKeyPress(_inputNode, 'Enter');
|
|
1052
948
|
await el.updateComplete;
|
|
1053
|
-
|
|
1054
949
|
expect(el.modelValue).to.eql(['Chard', 'Foo']);
|
|
1055
950
|
expect(el.checkedIndex).to.eql([1]);
|
|
1056
|
-
|
|
1057
951
|
await mimicUserTyping(el, 'Bar');
|
|
1058
952
|
await el.updateComplete;
|
|
1059
953
|
mimicKeyPress(_inputNode, 'Enter');
|
|
1060
954
|
await el.updateComplete;
|
|
1061
955
|
});
|
|
1062
|
-
|
|
1063
956
|
it('allows many custom selections when multi-choice when requireOptionMatch is false', async () => {
|
|
1064
|
-
const el =
|
|
957
|
+
const el =
|
|
958
|
+
/** @type {LionCombobox} */
|
|
1065
959
|
await fixture(html`
|
|
1066
960
|
<lion-combobox
|
|
1067
961
|
name="foo"
|
|
@@ -1074,33 +968,26 @@ describe('lion-combobox', () => {
|
|
|
1074
968
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1075
969
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1076
970
|
</lion-combobox>
|
|
1077
|
-
`)
|
|
1078
|
-
);
|
|
1079
|
-
|
|
971
|
+
`);
|
|
1080
972
|
el.requireOptionMatch = false;
|
|
1081
973
|
await el.updateComplete;
|
|
1082
|
-
|
|
1083
974
|
const { _inputNode } = getComboboxMembers(el);
|
|
1084
|
-
|
|
1085
975
|
await mimicUserTyping(el, 'Foo');
|
|
1086
976
|
await el.updateComplete;
|
|
1087
977
|
mimicKeyPress(_inputNode, 'Enter');
|
|
1088
978
|
await el.updateComplete;
|
|
1089
|
-
|
|
1090
979
|
expect(el.modelValue).to.eql(['Foo']);
|
|
1091
980
|
expect(el.checkedIndex).to.eql([]);
|
|
1092
|
-
|
|
1093
981
|
await mimicUserTyping(el, 'Bar');
|
|
1094
982
|
await el.updateComplete;
|
|
1095
983
|
mimicKeyPress(_inputNode, 'Enter');
|
|
1096
984
|
await el.updateComplete;
|
|
1097
|
-
|
|
1098
985
|
expect(el.modelValue).to.eql(['Foo', 'Bar']);
|
|
1099
986
|
expect(el.checkedIndex).to.eql([]);
|
|
1100
987
|
});
|
|
1101
|
-
|
|
1102
988
|
it('allows new options when multi-choice when requireOptionMatch=false and autocomplete="both", without selecting similar values', async () => {
|
|
1103
|
-
const el =
|
|
989
|
+
const el =
|
|
990
|
+
/** @type {LionCombobox} */
|
|
1104
991
|
await fixture(html`
|
|
1105
992
|
<lion-combobox
|
|
1106
993
|
name="foo"
|
|
@@ -1113,23 +1000,18 @@ describe('lion-combobox', () => {
|
|
|
1113
1000
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1114
1001
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1115
1002
|
</lion-combobox>
|
|
1116
|
-
`)
|
|
1117
|
-
);
|
|
1118
|
-
|
|
1003
|
+
`);
|
|
1119
1004
|
await el.updateComplete;
|
|
1120
|
-
|
|
1121
1005
|
const { _inputNode } = getComboboxMembers(el);
|
|
1122
|
-
|
|
1123
1006
|
await mimicUserTyping(el, 'Artist');
|
|
1124
1007
|
await el.updateComplete;
|
|
1125
1008
|
mimicKeyPress(_inputNode, 'Enter');
|
|
1126
1009
|
await el.updateComplete;
|
|
1127
|
-
|
|
1128
1010
|
expect(el.modelValue).to.eql(['Artist']);
|
|
1129
1011
|
});
|
|
1130
|
-
|
|
1131
1012
|
it('allows new options when multi-choice when requireOptionMatch=false and autocomplete="both", when deleting autocomplete values using Backspace', async () => {
|
|
1132
|
-
const el =
|
|
1013
|
+
const el =
|
|
1014
|
+
/** @type {LionCombobox} */
|
|
1133
1015
|
await fixture(html`
|
|
1134
1016
|
<lion-combobox
|
|
1135
1017
|
name="foo"
|
|
@@ -1142,11 +1024,8 @@ describe('lion-combobox', () => {
|
|
|
1142
1024
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1143
1025
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1144
1026
|
</lion-combobox>
|
|
1145
|
-
`)
|
|
1146
|
-
);
|
|
1147
|
-
|
|
1027
|
+
`);
|
|
1148
1028
|
await el.updateComplete;
|
|
1149
|
-
|
|
1150
1029
|
const { _inputNode } = getComboboxMembers(el);
|
|
1151
1030
|
await mimicUserTyping(el, 'Art');
|
|
1152
1031
|
await el.updateComplete;
|
|
@@ -1154,12 +1033,11 @@ describe('lion-combobox', () => {
|
|
|
1154
1033
|
await el.updateComplete;
|
|
1155
1034
|
mimicKeyPress(_inputNode, 'Enter');
|
|
1156
1035
|
await el.updateComplete;
|
|
1157
|
-
|
|
1158
1036
|
expect(el.modelValue).to.eql(['Art']);
|
|
1159
1037
|
});
|
|
1160
|
-
|
|
1161
1038
|
it('allows new custom options when multi-choice when requireOptionMatch=false and autocomplete="both", when deleting autocompleted values using Delete', async () => {
|
|
1162
|
-
const el =
|
|
1039
|
+
const el =
|
|
1040
|
+
/** @type {LionCombobox} */
|
|
1163
1041
|
await fixture(html`
|
|
1164
1042
|
<lion-combobox
|
|
1165
1043
|
name="foo"
|
|
@@ -1172,14 +1050,10 @@ describe('lion-combobox', () => {
|
|
|
1172
1050
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1173
1051
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1174
1052
|
</lion-combobox>
|
|
1175
|
-
`)
|
|
1176
|
-
);
|
|
1177
|
-
|
|
1053
|
+
`);
|
|
1178
1054
|
await el.updateComplete;
|
|
1179
|
-
|
|
1180
1055
|
const { _inputNode } = getComboboxMembers(el);
|
|
1181
1056
|
el.modelValue = [];
|
|
1182
|
-
|
|
1183
1057
|
await mimicUserTyping(el, 'Art');
|
|
1184
1058
|
await el.updateComplete;
|
|
1185
1059
|
await mimicUserTypingAdvanced(el, ['Delete']);
|
|
@@ -1188,12 +1062,11 @@ describe('lion-combobox', () => {
|
|
|
1188
1062
|
await el.updateComplete;
|
|
1189
1063
|
expect(el.modelValue).to.eql(['Art']);
|
|
1190
1064
|
});
|
|
1191
|
-
|
|
1192
1065
|
it('allows prefilling the combobox', async () => {
|
|
1193
1066
|
const autocompleteValues = ['inline', 'none', 'both', 'list'];
|
|
1194
|
-
|
|
1195
1067
|
for (const autocompleteValue of autocompleteValues) {
|
|
1196
|
-
const el =
|
|
1068
|
+
const el =
|
|
1069
|
+
/** @type {LionCombobox} */
|
|
1197
1070
|
await fixture(html`
|
|
1198
1071
|
<lion-combobox autocomplete="${autocompleteValue}" .modelValue="${'Chard'}" name="foo">
|
|
1199
1072
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1201,18 +1074,16 @@ describe('lion-combobox', () => {
|
|
|
1201
1074
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1202
1075
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1203
1076
|
</lion-combobox>
|
|
1204
|
-
`)
|
|
1205
|
-
);
|
|
1206
|
-
|
|
1077
|
+
`);
|
|
1207
1078
|
expect(el.modelValue).to.equal('Chard');
|
|
1208
1079
|
// @ts-expect-error
|
|
1209
1080
|
expect(el._inputNode.value).to.equal('Chard');
|
|
1210
1081
|
}
|
|
1211
1082
|
});
|
|
1212
|
-
|
|
1213
1083
|
it('submits form on [Enter] when listbox is closed', async () => {
|
|
1214
|
-
const submitSpy = sinon.spy(e => e.preventDefault());
|
|
1215
|
-
const el =
|
|
1084
|
+
const submitSpy = sinon.spy((e) => e.preventDefault());
|
|
1085
|
+
const el =
|
|
1086
|
+
/** @type {HTMLFormElement} */
|
|
1216
1087
|
await fixture(html`
|
|
1217
1088
|
<form @submit=${submitSpy}>
|
|
1218
1089
|
<lion-combobox name="foo">
|
|
@@ -1223,9 +1094,8 @@ describe('lion-combobox', () => {
|
|
|
1223
1094
|
</lion-combobox>
|
|
1224
1095
|
<button type="submit">submit</button>
|
|
1225
1096
|
</form>
|
|
1226
|
-
`)
|
|
1227
|
-
);
|
|
1228
|
-
const combobox = /** @type {LionCombobox} */ (el.querySelector('[name="foo"]'));
|
|
1097
|
+
`);
|
|
1098
|
+
const combobox = /** @type {LionCombobox} */ el.querySelector('[name="foo"]');
|
|
1229
1099
|
const { _inputNode } = getComboboxMembers(combobox);
|
|
1230
1100
|
await combobox.updateComplete;
|
|
1231
1101
|
_inputNode.focus();
|
|
@@ -1234,10 +1104,10 @@ describe('lion-combobox', () => {
|
|
|
1234
1104
|
});
|
|
1235
1105
|
expect(submitSpy.callCount).to.equal(1);
|
|
1236
1106
|
});
|
|
1237
|
-
|
|
1238
1107
|
it('does not submit form on [Enter] when listbox is opened', async () => {
|
|
1239
|
-
const submitSpy = sinon.spy(e => e.preventDefault());
|
|
1240
|
-
const el =
|
|
1108
|
+
const submitSpy = sinon.spy((e) => e.preventDefault());
|
|
1109
|
+
const el =
|
|
1110
|
+
/** @type {HTMLFormElement} */
|
|
1241
1111
|
await fixture(html`
|
|
1242
1112
|
<form @submit=${submitSpy}>
|
|
1243
1113
|
<lion-combobox name="foo">
|
|
@@ -1248,9 +1118,8 @@ describe('lion-combobox', () => {
|
|
|
1248
1118
|
</lion-combobox>
|
|
1249
1119
|
<button type="submit">submit</button>
|
|
1250
1120
|
</form>
|
|
1251
|
-
`)
|
|
1252
|
-
);
|
|
1253
|
-
const combobox = /** @type {LionCombobox} */ (el.querySelector('[name="foo"]'));
|
|
1121
|
+
`);
|
|
1122
|
+
const combobox = /** @type {LionCombobox} */ el.querySelector('[name="foo"]');
|
|
1254
1123
|
const { _inputNode } = getComboboxMembers(combobox);
|
|
1255
1124
|
combobox.opened = true;
|
|
1256
1125
|
await combobox.updateComplete;
|
|
@@ -1261,10 +1130,10 @@ describe('lion-combobox', () => {
|
|
|
1261
1130
|
expect(submitSpy.callCount).to.equal(0);
|
|
1262
1131
|
});
|
|
1263
1132
|
});
|
|
1264
|
-
|
|
1265
1133
|
describe('Overlay visibility', () => {
|
|
1266
1134
|
it('does not show overlay on click', async () => {
|
|
1267
|
-
const el =
|
|
1135
|
+
const el =
|
|
1136
|
+
/** @type {LionCombobox} */
|
|
1268
1137
|
await fixture(html`
|
|
1269
1138
|
<lion-combobox name="foo">
|
|
1270
1139
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1272,27 +1141,28 @@ describe('lion-combobox', () => {
|
|
|
1272
1141
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1273
1142
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1274
1143
|
</lion-combobox>
|
|
1275
|
-
`)
|
|
1276
|
-
);
|
|
1144
|
+
`);
|
|
1277
1145
|
const { _comboboxNode } = getComboboxMembers(el);
|
|
1278
|
-
|
|
1279
1146
|
expect(el.opened).to.equal(false);
|
|
1280
|
-
_comboboxNode.dispatchEvent(
|
|
1147
|
+
_comboboxNode.dispatchEvent(
|
|
1148
|
+
new Event('click', {
|
|
1149
|
+
bubbles: true,
|
|
1150
|
+
composed: true,
|
|
1151
|
+
}),
|
|
1152
|
+
);
|
|
1281
1153
|
await el.updateComplete;
|
|
1282
1154
|
expect(el.opened).to.equal(false);
|
|
1283
1155
|
});
|
|
1284
|
-
|
|
1285
1156
|
it('does not flash the menu when _showOverlayCondition returns "false"', async () => {
|
|
1286
1157
|
class ComplexCombobox extends LionCombobox {
|
|
1287
1158
|
_showOverlayCondition() {
|
|
1288
1159
|
return false;
|
|
1289
1160
|
}
|
|
1290
1161
|
}
|
|
1291
|
-
|
|
1292
1162
|
const tagName = defineCE(ComplexCombobox);
|
|
1293
1163
|
const tag = unsafeStatic(tagName);
|
|
1294
|
-
|
|
1295
|
-
|
|
1164
|
+
const el =
|
|
1165
|
+
/** @type {LionCombobox} */
|
|
1296
1166
|
await fixture(html`
|
|
1297
1167
|
<${tag} name="combo" label="Display only the label once selected">
|
|
1298
1168
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1300,15 +1170,13 @@ describe('lion-combobox', () => {
|
|
|
1300
1170
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1301
1171
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1302
1172
|
</${tag}>
|
|
1303
|
-
`)
|
|
1304
|
-
);
|
|
1305
|
-
|
|
1173
|
+
`);
|
|
1306
1174
|
const dialog = el.shadowRoot?.querySelector('dialog');
|
|
1307
1175
|
/**
|
|
1308
1176
|
* hasDropdownFlashed is `true` if the menu was shown for a short period of time and then got closed
|
|
1309
1177
|
*/
|
|
1310
1178
|
let hasDropdownFlashed = false;
|
|
1311
|
-
const observer = new MutationObserver(mutationList => {
|
|
1179
|
+
const observer = new MutationObserver((mutationList) => {
|
|
1312
1180
|
// eslint-disable-next-line no-unused-vars
|
|
1313
1181
|
for (const mutation of mutationList) {
|
|
1314
1182
|
if (dialog?.style.display === '') {
|
|
@@ -1316,8 +1184,9 @@ describe('lion-combobox', () => {
|
|
|
1316
1184
|
}
|
|
1317
1185
|
}
|
|
1318
1186
|
});
|
|
1319
|
-
observer.observe(/** @type {Node} */
|
|
1320
|
-
|
|
1187
|
+
observer.observe(/** @type {Node} */ dialog, {
|
|
1188
|
+
attributeFilter: ['style'],
|
|
1189
|
+
});
|
|
1321
1190
|
const { _inputNode } = getComboboxMembers(el);
|
|
1322
1191
|
_inputNode.focus();
|
|
1323
1192
|
await sendKeys({
|
|
@@ -1325,9 +1194,9 @@ describe('lion-combobox', () => {
|
|
|
1325
1194
|
});
|
|
1326
1195
|
expect(hasDropdownFlashed).to.be.false;
|
|
1327
1196
|
});
|
|
1328
|
-
|
|
1329
1197
|
it('shows overlay on click when filled', async () => {
|
|
1330
|
-
const el =
|
|
1198
|
+
const el =
|
|
1199
|
+
/** @type {LionCombobox} */
|
|
1331
1200
|
await fixture(html`
|
|
1332
1201
|
<lion-combobox name="foo">
|
|
1333
1202
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1335,16 +1204,19 @@ describe('lion-combobox', () => {
|
|
|
1335
1204
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1336
1205
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1337
1206
|
</lion-combobox>
|
|
1338
|
-
`)
|
|
1339
|
-
);
|
|
1207
|
+
`);
|
|
1340
1208
|
const { _comboboxNode } = getComboboxMembers(el);
|
|
1341
1209
|
el.modelValue = 'Art';
|
|
1342
1210
|
expect(el.opened).to.equal(false);
|
|
1343
|
-
_comboboxNode.dispatchEvent(
|
|
1211
|
+
_comboboxNode.dispatchEvent(
|
|
1212
|
+
new Event('click', {
|
|
1213
|
+
bubbles: true,
|
|
1214
|
+
composed: true,
|
|
1215
|
+
}),
|
|
1216
|
+
);
|
|
1344
1217
|
await el.updateComplete;
|
|
1345
1218
|
expect(el.opened).to.equal(false);
|
|
1346
1219
|
});
|
|
1347
|
-
|
|
1348
1220
|
it('shows overlay again after select and char keyup', async () => {
|
|
1349
1221
|
/**
|
|
1350
1222
|
* Scenario:
|
|
@@ -1354,7 +1226,8 @@ describe('lion-combobox', () => {
|
|
|
1354
1226
|
* still has focus
|
|
1355
1227
|
* [4] user changes textbox value to "Artichoke": the overlay should show again
|
|
1356
1228
|
*/
|
|
1357
|
-
const el =
|
|
1229
|
+
const el =
|
|
1230
|
+
/** @type {LionCombobox} */
|
|
1358
1231
|
await fixture(html`
|
|
1359
1232
|
<lion-combobox name="foo">
|
|
1360
1233
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1362,15 +1235,18 @@ describe('lion-combobox', () => {
|
|
|
1362
1235
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1363
1236
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1364
1237
|
</lion-combobox>
|
|
1365
|
-
`)
|
|
1366
|
-
);
|
|
1238
|
+
`);
|
|
1367
1239
|
const options = el.formElements;
|
|
1368
1240
|
const { _inputNode } = getComboboxMembers(el);
|
|
1369
|
-
|
|
1370
1241
|
expect(el.opened).to.equal(false);
|
|
1371
1242
|
|
|
1372
1243
|
// step [1]
|
|
1373
|
-
_inputNode.dispatchEvent(
|
|
1244
|
+
_inputNode.dispatchEvent(
|
|
1245
|
+
new Event('click', {
|
|
1246
|
+
bubbles: true,
|
|
1247
|
+
composed: true,
|
|
1248
|
+
}),
|
|
1249
|
+
);
|
|
1374
1250
|
await el.updateComplete;
|
|
1375
1251
|
expect(el.opened).to.equal(false);
|
|
1376
1252
|
|
|
@@ -1391,40 +1267,34 @@ describe('lion-combobox', () => {
|
|
|
1391
1267
|
await el.updateComplete;
|
|
1392
1268
|
expect(el.opened).to.equal(true);
|
|
1393
1269
|
});
|
|
1394
|
-
|
|
1395
1270
|
it('syncs a manually checked selection on overlay close while the input remains focused', async () => {
|
|
1396
|
-
const el =
|
|
1271
|
+
const el =
|
|
1272
|
+
/** @type {LionCombobox} */
|
|
1397
1273
|
await fixture(html`
|
|
1398
1274
|
<lion-combobox name="foo" autocomplete="list">
|
|
1399
1275
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
1400
1276
|
<lion-option .choiceValue="${'Chard'}">Chard</lion-option>
|
|
1401
1277
|
</lion-combobox>
|
|
1402
|
-
`)
|
|
1403
|
-
);
|
|
1278
|
+
`);
|
|
1404
1279
|
const { _inputNode } = getComboboxMembers(el);
|
|
1405
|
-
|
|
1406
1280
|
_inputNode.focus();
|
|
1407
1281
|
el.opened = true;
|
|
1408
1282
|
await el.updateComplete;
|
|
1409
1283
|
expect(el.opened).to.equal(true);
|
|
1410
1284
|
expect(isActiveElement(_inputNode)).to.be.true;
|
|
1411
|
-
|
|
1412
1285
|
el.setCheckedIndex(0);
|
|
1413
1286
|
await el.updateComplete;
|
|
1414
|
-
|
|
1415
1287
|
expect(el.modelValue).to.equal('Artichoke');
|
|
1416
1288
|
expect(el.checkedIndex).to.equal(0);
|
|
1417
1289
|
expect(_inputNode.value).to.equal('');
|
|
1418
|
-
|
|
1419
1290
|
el.opened = false;
|
|
1420
1291
|
await el.updateComplete;
|
|
1421
|
-
|
|
1422
1292
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
1423
1293
|
expect(isActiveElement(_inputNode)).to.be.true;
|
|
1424
1294
|
});
|
|
1425
|
-
|
|
1426
1295
|
it('hides (and clears) overlay on [Escape]', async () => {
|
|
1427
|
-
const el =
|
|
1296
|
+
const el =
|
|
1297
|
+
/** @type {LionCombobox} */
|
|
1428
1298
|
await fixture(html`
|
|
1429
1299
|
<lion-combobox name="foo">
|
|
1430
1300
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1432,23 +1302,23 @@ describe('lion-combobox', () => {
|
|
|
1432
1302
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1433
1303
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1434
1304
|
</lion-combobox>
|
|
1435
|
-
`)
|
|
1436
|
-
);
|
|
1437
|
-
|
|
1305
|
+
`);
|
|
1438
1306
|
const { _inputNode } = getComboboxMembers(el);
|
|
1439
|
-
|
|
1440
1307
|
await mimicUserTyping(el, 'art');
|
|
1441
1308
|
await el.updateComplete;
|
|
1442
1309
|
expect(el.opened).to.equal(true);
|
|
1443
1310
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
1444
|
-
|
|
1445
|
-
|
|
1311
|
+
_inputNode.dispatchEvent(
|
|
1312
|
+
new KeyboardEvent('keydown', {
|
|
1313
|
+
key: 'Escape',
|
|
1314
|
+
}),
|
|
1315
|
+
);
|
|
1446
1316
|
expect(el.opened).to.equal(false);
|
|
1447
1317
|
expect(_inputNode.value).to.equal('');
|
|
1448
1318
|
});
|
|
1449
|
-
|
|
1450
1319
|
it('hides overlay on [Enter]', async () => {
|
|
1451
|
-
const el =
|
|
1320
|
+
const el =
|
|
1321
|
+
/** @type {LionCombobox} */
|
|
1452
1322
|
await fixture(html`
|
|
1453
1323
|
<lion-combobox name="foo">
|
|
1454
1324
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1456,11 +1326,8 @@ describe('lion-combobox', () => {
|
|
|
1456
1326
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1457
1327
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1458
1328
|
</lion-combobox>
|
|
1459
|
-
`)
|
|
1460
|
-
);
|
|
1461
|
-
|
|
1329
|
+
`);
|
|
1462
1330
|
const { _inputNode } = getComboboxMembers(el);
|
|
1463
|
-
|
|
1464
1331
|
await mimicUserTyping(el, 'art');
|
|
1465
1332
|
await el.updateComplete;
|
|
1466
1333
|
expect(el.opened).to.equal(true);
|
|
@@ -1468,13 +1335,17 @@ describe('lion-combobox', () => {
|
|
|
1468
1335
|
|
|
1469
1336
|
// N.B. we do only trigger keydown here (and not mimicKeypress (both keyup and down)),
|
|
1470
1337
|
// because this closely mimics what happens in the browser
|
|
1471
|
-
_inputNode.dispatchEvent(
|
|
1338
|
+
_inputNode.dispatchEvent(
|
|
1339
|
+
new KeyboardEvent('keydown', {
|
|
1340
|
+
key: 'Enter',
|
|
1341
|
+
}),
|
|
1342
|
+
);
|
|
1472
1343
|
expect(el.opened).to.equal(false);
|
|
1473
1344
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
1474
1345
|
});
|
|
1475
|
-
|
|
1476
1346
|
it('hides overlay on [Tab]', async () => {
|
|
1477
|
-
const el =
|
|
1347
|
+
const el =
|
|
1348
|
+
/** @type {LionCombobox} */
|
|
1478
1349
|
await fixture(html`
|
|
1479
1350
|
<lion-combobox name="foo">
|
|
1480
1351
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1482,11 +1353,8 @@ describe('lion-combobox', () => {
|
|
|
1482
1353
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1483
1354
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1484
1355
|
</lion-combobox>
|
|
1485
|
-
`)
|
|
1486
|
-
);
|
|
1487
|
-
|
|
1356
|
+
`);
|
|
1488
1357
|
const { _inputNode } = getComboboxMembers(el);
|
|
1489
|
-
|
|
1490
1358
|
await mimicUserTyping(el, 'art');
|
|
1491
1359
|
await el.updateComplete;
|
|
1492
1360
|
expect(el.opened).to.equal(true);
|
|
@@ -1494,13 +1362,17 @@ describe('lion-combobox', () => {
|
|
|
1494
1362
|
|
|
1495
1363
|
// N.B. we do only trigger keydown here (and not mimicKeypress (both keyup and down)),
|
|
1496
1364
|
// because this closely mimics what happens in the browser
|
|
1497
|
-
_inputNode.dispatchEvent(
|
|
1365
|
+
_inputNode.dispatchEvent(
|
|
1366
|
+
new KeyboardEvent('keydown', {
|
|
1367
|
+
key: 'Tab',
|
|
1368
|
+
}),
|
|
1369
|
+
);
|
|
1498
1370
|
expect(el.opened).to.equal(false);
|
|
1499
1371
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
1500
1372
|
});
|
|
1501
|
-
|
|
1502
1373
|
it('keeps overlay open on [Shift]', async () => {
|
|
1503
|
-
const el =
|
|
1374
|
+
const el =
|
|
1375
|
+
/** @type {LionCombobox} */
|
|
1504
1376
|
await fixture(html`
|
|
1505
1377
|
<lion-combobox name="foo">
|
|
1506
1378
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1508,11 +1380,8 @@ describe('lion-combobox', () => {
|
|
|
1508
1380
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1509
1381
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1510
1382
|
</lion-combobox>
|
|
1511
|
-
`)
|
|
1512
|
-
);
|
|
1513
|
-
|
|
1383
|
+
`);
|
|
1514
1384
|
const { _inputNode } = getComboboxMembers(el);
|
|
1515
|
-
|
|
1516
1385
|
await mimicUserTyping(el, 'art');
|
|
1517
1386
|
await el.updateComplete;
|
|
1518
1387
|
expect(el.opened).to.equal(true);
|
|
@@ -1520,13 +1389,17 @@ describe('lion-combobox', () => {
|
|
|
1520
1389
|
|
|
1521
1390
|
// N.B. we do only trigger keydown here (and not mimicKeypress (both keyup and down)),
|
|
1522
1391
|
// because this closely mimics what happens in the browser
|
|
1523
|
-
_inputNode.dispatchEvent(
|
|
1392
|
+
_inputNode.dispatchEvent(
|
|
1393
|
+
new KeyboardEvent('keydown', {
|
|
1394
|
+
key: 'Shift',
|
|
1395
|
+
}),
|
|
1396
|
+
);
|
|
1524
1397
|
expect(el.opened).to.equal(true);
|
|
1525
1398
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
1526
1399
|
});
|
|
1527
|
-
|
|
1528
1400
|
it('clears checkedIndex on empty text', async () => {
|
|
1529
|
-
const el =
|
|
1401
|
+
const el =
|
|
1402
|
+
/** @type {LionCombobox} */
|
|
1530
1403
|
await fixture(html`
|
|
1531
1404
|
<lion-combobox name="foo">
|
|
1532
1405
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1534,11 +1407,8 @@ describe('lion-combobox', () => {
|
|
|
1534
1407
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1535
1408
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1536
1409
|
</lion-combobox>
|
|
1537
|
-
`)
|
|
1538
|
-
);
|
|
1539
|
-
|
|
1410
|
+
`);
|
|
1540
1411
|
const { _inputNode } = getComboboxMembers(el);
|
|
1541
|
-
|
|
1542
1412
|
await mimicUserTyping(el, 'art');
|
|
1543
1413
|
await el.updateComplete;
|
|
1544
1414
|
expect(el.opened).to.equal(true);
|
|
@@ -1546,15 +1416,17 @@ describe('lion-combobox', () => {
|
|
|
1546
1416
|
expect(el.checkedIndex).to.equal(0);
|
|
1547
1417
|
|
|
1548
1418
|
// await mimicUserTyping(el, '');
|
|
1549
|
-
await sendKeys({
|
|
1419
|
+
await sendKeys({
|
|
1420
|
+
press: 'Backspace',
|
|
1421
|
+
});
|
|
1550
1422
|
await el.updateComplete;
|
|
1551
1423
|
el.opened = false;
|
|
1552
1424
|
await el.updateComplete;
|
|
1553
1425
|
expect(el.checkedIndex).to.equal(-1);
|
|
1554
1426
|
});
|
|
1555
|
-
|
|
1556
1427
|
it('has the correct Overlay Config defined', async () => {
|
|
1557
|
-
const el =
|
|
1428
|
+
const el =
|
|
1429
|
+
/** @type {LionCombobox} */
|
|
1558
1430
|
await fixture(html`
|
|
1559
1431
|
<lion-combobox name="foo" .showAllOnEmpty="${true}">
|
|
1560
1432
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1562,15 +1434,12 @@ describe('lion-combobox', () => {
|
|
|
1562
1434
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1563
1435
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1564
1436
|
</lion-combobox>
|
|
1565
|
-
`)
|
|
1566
|
-
);
|
|
1437
|
+
`);
|
|
1567
1438
|
// @ts-expect-error [allow-protected] in test
|
|
1568
1439
|
const overlayCfg = el._defineOverlayConfig();
|
|
1569
|
-
|
|
1570
1440
|
const equalsOrContainsInput = (/** @type {HTMLInputElement|HTMLDivElement} */ invokerNode) =>
|
|
1571
1441
|
// @ts-expect-error [allow-protected] in test
|
|
1572
1442
|
invokerNode === el._inputNode || invokerNode.contains(el._inputNode);
|
|
1573
|
-
|
|
1574
1443
|
expect(overlayCfg.elementToFocusAfterHide).to.equal(undefined);
|
|
1575
1444
|
// @ts-expect-error
|
|
1576
1445
|
expect(equalsOrContainsInput(overlayCfg.invokerNode)).to.be.true;
|
|
@@ -1591,8 +1460,8 @@ describe('lion-combobox', () => {
|
|
|
1591
1460
|
}
|
|
1592
1461
|
const tagName = defineCE(ShowOverlayConditionCombobox);
|
|
1593
1462
|
const tag = unsafeStatic(tagName);
|
|
1594
|
-
|
|
1595
|
-
|
|
1463
|
+
const el =
|
|
1464
|
+
/** @type {LionCombobox} */
|
|
1596
1465
|
await fixture(html`
|
|
1597
1466
|
<${tag} name="foo">
|
|
1598
1467
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1600,13 +1469,10 @@ describe('lion-combobox', () => {
|
|
|
1600
1469
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1601
1470
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1602
1471
|
</${tag}>
|
|
1603
|
-
`)
|
|
1604
|
-
);
|
|
1605
|
-
|
|
1472
|
+
`);
|
|
1606
1473
|
await mimicUserTyping(el, 'aaa');
|
|
1607
1474
|
expect(el.opened).to.be.false;
|
|
1608
1475
|
});
|
|
1609
|
-
|
|
1610
1476
|
it('allows to control overlay visibility via "_showOverlayCondition": should display overlay if currentValue length condition is fulfilled', async () => {
|
|
1611
1477
|
class ShowOverlayConditionCombobox extends LionCombobox {
|
|
1612
1478
|
/** @param {{ currentValue: string, lastKey:string }} options */
|
|
@@ -1619,8 +1485,8 @@ describe('lion-combobox', () => {
|
|
|
1619
1485
|
}
|
|
1620
1486
|
const tagName = defineCE(ShowOverlayConditionCombobox);
|
|
1621
1487
|
const tag = unsafeStatic(tagName);
|
|
1622
|
-
|
|
1623
|
-
|
|
1488
|
+
const el =
|
|
1489
|
+
/** @type {LionCombobox} */
|
|
1624
1490
|
await fixture(html`
|
|
1625
1491
|
<${tag} name="foo">
|
|
1626
1492
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1628,13 +1494,10 @@ describe('lion-combobox', () => {
|
|
|
1628
1494
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1629
1495
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1630
1496
|
</${tag}>
|
|
1631
|
-
`)
|
|
1632
|
-
);
|
|
1633
|
-
|
|
1497
|
+
`);
|
|
1634
1498
|
await mimicUserTyping(el, 'aaaa');
|
|
1635
1499
|
expect(el.opened).to.be.true;
|
|
1636
1500
|
});
|
|
1637
|
-
|
|
1638
1501
|
it('allows to control overlay visibility via "_showOverlayCondition": should not display overlay if currentValue length condition is not fulfilled after once fulfilled', async () => {
|
|
1639
1502
|
class ShowOverlayConditionCombobox extends LionCombobox {
|
|
1640
1503
|
/** @param {{ currentValue: string, lastKey:string }} options */
|
|
@@ -1647,8 +1510,8 @@ describe('lion-combobox', () => {
|
|
|
1647
1510
|
}
|
|
1648
1511
|
const tagName = defineCE(ShowOverlayConditionCombobox);
|
|
1649
1512
|
const tag = unsafeStatic(tagName);
|
|
1650
|
-
|
|
1651
|
-
|
|
1513
|
+
const el =
|
|
1514
|
+
/** @type {LionCombobox} */
|
|
1652
1515
|
await fixture(html`
|
|
1653
1516
|
<${tag} name="foo">
|
|
1654
1517
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1656,21 +1519,18 @@ describe('lion-combobox', () => {
|
|
|
1656
1519
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1657
1520
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1658
1521
|
</${tag}>
|
|
1659
|
-
`)
|
|
1660
|
-
);
|
|
1661
|
-
|
|
1522
|
+
`);
|
|
1662
1523
|
await mimicUserTyping(el, 'aaaa');
|
|
1663
1524
|
expect(el.opened).to.be.true;
|
|
1664
|
-
|
|
1665
1525
|
await mimicUserTyping(el, 'aaa');
|
|
1666
1526
|
await el.updateComplete;
|
|
1667
1527
|
expect(el.opened).to.be.false;
|
|
1668
1528
|
});
|
|
1669
1529
|
});
|
|
1670
|
-
|
|
1671
1530
|
describe('Accessibility', () => {
|
|
1672
1531
|
it('sets "aria-posinset" and "aria-setsize" on visible entries', async () => {
|
|
1673
|
-
const el =
|
|
1532
|
+
const el =
|
|
1533
|
+
/** @type {LionCombobox} */
|
|
1674
1534
|
await fixture(html`
|
|
1675
1535
|
<lion-combobox name="foo" multiple-choice>
|
|
1676
1536
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1678,16 +1538,13 @@ describe('lion-combobox', () => {
|
|
|
1678
1538
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1679
1539
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1680
1540
|
</lion-combobox>
|
|
1681
|
-
`)
|
|
1682
|
-
);
|
|
1541
|
+
`);
|
|
1683
1542
|
const options = el.formElements;
|
|
1684
1543
|
expect(el.opened).to.equal(false);
|
|
1685
|
-
|
|
1686
1544
|
await mimicUserTyping(el, 'art');
|
|
1687
1545
|
await el.updateComplete;
|
|
1688
1546
|
expect(el.opened).to.equal(true);
|
|
1689
|
-
|
|
1690
|
-
const visibleOptions = options.filter(o => o.style.display !== 'none');
|
|
1547
|
+
const visibleOptions = options.filter((o) => o.style.display !== 'none');
|
|
1691
1548
|
expect(visibleOptions.length).to.not.equal(0);
|
|
1692
1549
|
visibleOptions.forEach((o, i) => {
|
|
1693
1550
|
expect(o.getAttribute('aria-posinset')).to.equal(`${i + 1}`);
|
|
@@ -1696,11 +1553,11 @@ describe('lion-combobox', () => {
|
|
|
1696
1553
|
/**
|
|
1697
1554
|
* @param {{ style: { display: string; }; }} o
|
|
1698
1555
|
*/
|
|
1699
|
-
const hiddenOptions = options.filter(o => o.style.display === 'none');
|
|
1556
|
+
const hiddenOptions = options.filter((o) => o.style.display === 'none');
|
|
1700
1557
|
/**
|
|
1701
1558
|
* @param {{ hasAttribute: (arg0: string) => any; }} o
|
|
1702
1559
|
*/
|
|
1703
|
-
hiddenOptions.forEach(o => {
|
|
1560
|
+
hiddenOptions.forEach((o) => {
|
|
1704
1561
|
expect(o.hasAttribute('aria-posinset')).to.equal(false);
|
|
1705
1562
|
expect(o.hasAttribute('aria-setsize')).to.equal(false);
|
|
1706
1563
|
});
|
|
@@ -1711,7 +1568,8 @@ describe('lion-combobox', () => {
|
|
|
1711
1568
|
* (like fade in/out)
|
|
1712
1569
|
*/
|
|
1713
1570
|
it('sets aria-hidden="true" on hidden entries', async () => {
|
|
1714
|
-
const el =
|
|
1571
|
+
const el =
|
|
1572
|
+
/** @type {LionCombobox} */
|
|
1715
1573
|
await fixture(html`
|
|
1716
1574
|
<lion-combobox name="foo">
|
|
1717
1575
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1719,27 +1577,24 @@ describe('lion-combobox', () => {
|
|
|
1719
1577
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1720
1578
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1721
1579
|
</lion-combobox>
|
|
1722
|
-
`)
|
|
1723
|
-
);
|
|
1580
|
+
`);
|
|
1724
1581
|
const options = el.formElements;
|
|
1725
1582
|
expect(el.opened).to.equal(false);
|
|
1726
|
-
|
|
1727
1583
|
await mimicUserTyping(el, 'art');
|
|
1728
1584
|
expect(el.opened).to.equal(true);
|
|
1729
1585
|
await el.updateComplete;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
visibleOptions.forEach(o => {
|
|
1586
|
+
const visibleOptions = options.filter((o) => o.style.display !== 'none');
|
|
1587
|
+
visibleOptions.forEach((o) => {
|
|
1733
1588
|
expect(o.hasAttribute('aria-hidden')).to.be.false;
|
|
1734
1589
|
});
|
|
1735
|
-
const hiddenOptions = options.filter(o => o.style.display === 'none');
|
|
1736
|
-
hiddenOptions.forEach(o => {
|
|
1590
|
+
const hiddenOptions = options.filter((o) => o.style.display === 'none');
|
|
1591
|
+
hiddenOptions.forEach((o) => {
|
|
1737
1592
|
expect(o.getAttribute('aria-hidden')).to.equal('true');
|
|
1738
1593
|
});
|
|
1739
1594
|
});
|
|
1740
|
-
|
|
1741
1595
|
it('dropdown has a label', async () => {
|
|
1742
|
-
const el =
|
|
1596
|
+
const el =
|
|
1597
|
+
/** @type {LionCombobox} */
|
|
1743
1598
|
await fixture(html`
|
|
1744
1599
|
<lion-combobox name="foo" .validators=${[new Required()]}>
|
|
1745
1600
|
<lion-option checked .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1747,8 +1602,7 @@ describe('lion-combobox', () => {
|
|
|
1747
1602
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1748
1603
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1749
1604
|
</lion-combobox>
|
|
1750
|
-
`)
|
|
1751
|
-
);
|
|
1605
|
+
`);
|
|
1752
1606
|
const { _overlayCtrl } = getComboboxMembers(el);
|
|
1753
1607
|
expect(_overlayCtrl.contentWrapperNode.getAttribute('aria-label')).to.equal(
|
|
1754
1608
|
'Combobox options popup',
|
|
@@ -1762,67 +1616,59 @@ describe('lion-combobox', () => {
|
|
|
1762
1616
|
describe('Invoker component integration', () => {
|
|
1763
1617
|
describe('Accessibility', () => {
|
|
1764
1618
|
it('sets role="combobox" on textbox wrapper/listbox sibling', async () => {
|
|
1765
|
-
const el =
|
|
1619
|
+
const el =
|
|
1620
|
+
/** @type {LionCombobox} */
|
|
1766
1621
|
await fixture(html`
|
|
1767
1622
|
<lion-combobox name="foo">
|
|
1768
1623
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1769
1624
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
1770
1625
|
</lion-combobox>
|
|
1771
|
-
`)
|
|
1772
|
-
);
|
|
1626
|
+
`);
|
|
1773
1627
|
const { _comboboxNode } = getComboboxMembers(el);
|
|
1774
|
-
|
|
1775
1628
|
expect(_comboboxNode.getAttribute('role')).to.equal('combobox');
|
|
1776
1629
|
});
|
|
1777
|
-
|
|
1778
1630
|
it('sets aria-expanded to element with role="combobox" in wai-aria 1.0 and 1.1', async () => {
|
|
1779
|
-
const el =
|
|
1631
|
+
const el =
|
|
1632
|
+
/** @type {LionCombobox} */
|
|
1780
1633
|
await fixture(html`
|
|
1781
1634
|
<lion-combobox name="foo" ._ariaVersion="${'1.0'}">
|
|
1782
1635
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1783
1636
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
1784
1637
|
</lion-combobox>
|
|
1785
|
-
`)
|
|
1786
|
-
);
|
|
1638
|
+
`);
|
|
1787
1639
|
const { _comboboxNode } = getComboboxMembers(el);
|
|
1788
|
-
|
|
1789
1640
|
expect(_comboboxNode.getAttribute('aria-expanded')).to.equal('false');
|
|
1790
1641
|
el.opened = true;
|
|
1791
1642
|
await el.updateComplete;
|
|
1792
1643
|
expect(_comboboxNode.getAttribute('aria-expanded')).to.equal('true');
|
|
1793
|
-
|
|
1794
|
-
|
|
1644
|
+
const el2 =
|
|
1645
|
+
/** @type {LionCombobox} */
|
|
1795
1646
|
await fixture(html`
|
|
1796
1647
|
<lion-combobox name="foo" ._ariaVersion="${'1.1'}">
|
|
1797
1648
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1798
1649
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
1799
1650
|
</lion-combobox>
|
|
1800
|
-
`)
|
|
1801
|
-
);
|
|
1651
|
+
`);
|
|
1802
1652
|
const { _comboboxNode: comboboxNode2 } = getComboboxMembers(el2);
|
|
1803
|
-
|
|
1804
1653
|
expect(comboboxNode2.getAttribute('aria-expanded')).to.equal('false');
|
|
1805
1654
|
el2.opened = true;
|
|
1806
1655
|
await el2.updateComplete;
|
|
1807
1656
|
expect(_comboboxNode.getAttribute('aria-expanded')).to.equal('true');
|
|
1808
1657
|
});
|
|
1809
|
-
|
|
1810
1658
|
it('makes sure listbox node is not focusable', async () => {
|
|
1811
|
-
const el =
|
|
1659
|
+
const el =
|
|
1660
|
+
/** @type {LionCombobox} */
|
|
1812
1661
|
await fixture(html`
|
|
1813
1662
|
<lion-combobox name="foo">
|
|
1814
1663
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1815
1664
|
<lion-option .choiceValue="${'20'}">Item 2</lion-option>
|
|
1816
1665
|
</lion-combobox>
|
|
1817
|
-
`)
|
|
1818
|
-
);
|
|
1666
|
+
`);
|
|
1819
1667
|
const { _listboxNode } = getComboboxMembers(el);
|
|
1820
|
-
|
|
1821
1668
|
expect(_listboxNode.hasAttribute('tabindex')).to.be.false;
|
|
1822
1669
|
});
|
|
1823
1670
|
});
|
|
1824
1671
|
});
|
|
1825
|
-
|
|
1826
1672
|
describe('Selection display', () => {
|
|
1827
1673
|
class MySelectionDisplay extends LitElement {
|
|
1828
1674
|
/**
|
|
@@ -1839,43 +1685,39 @@ describe('lion-combobox', () => {
|
|
|
1839
1685
|
}
|
|
1840
1686
|
}
|
|
1841
1687
|
const selectionDisplayTag = unsafeStatic(defineCE(MySelectionDisplay));
|
|
1842
|
-
|
|
1843
1688
|
it('stores internal reference _selectionDisplayNode in LionCombobox', async () => {
|
|
1844
|
-
const el =
|
|
1689
|
+
const el =
|
|
1690
|
+
/** @type {LionCombobox} */
|
|
1845
1691
|
await fixture(html`
|
|
1846
1692
|
<lion-combobox name="foo">
|
|
1847
1693
|
<${selectionDisplayTag} slot="selection-display"></${selectionDisplayTag}>
|
|
1848
1694
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1849
1695
|
</lion-combobox>
|
|
1850
|
-
`)
|
|
1851
|
-
);
|
|
1696
|
+
`);
|
|
1852
1697
|
const { _selectionDisplayNode } = getComboboxMembers(el);
|
|
1853
|
-
|
|
1854
1698
|
expect(_selectionDisplayNode).to.equal(el.querySelector('[slot=selection-display]'));
|
|
1855
1699
|
});
|
|
1856
|
-
|
|
1857
1700
|
it('sets a reference to combobox element in _selectionDisplayNode', async () => {
|
|
1858
|
-
const el =
|
|
1701
|
+
const el =
|
|
1702
|
+
/** @type {LionCombobox} */
|
|
1859
1703
|
await fixture(html`
|
|
1860
1704
|
<lion-combobox name="foo">
|
|
1861
1705
|
<${selectionDisplayTag} slot="selection-display"></${selectionDisplayTag}>
|
|
1862
1706
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1863
1707
|
</lion-combobox>
|
|
1864
|
-
`)
|
|
1865
|
-
);
|
|
1708
|
+
`);
|
|
1866
1709
|
// @ts-ignore allow protected members
|
|
1867
1710
|
expect(el._selectionDisplayNode.comboboxElement).to.equal(el);
|
|
1868
1711
|
});
|
|
1869
|
-
|
|
1870
1712
|
it('calls "onComboboxElementUpdated(changedProperties)" on "updated" in _selectionDisplayNode', async () => {
|
|
1871
|
-
const el =
|
|
1713
|
+
const el =
|
|
1714
|
+
/** @type {LionCombobox} */
|
|
1872
1715
|
await fixture(html`
|
|
1873
1716
|
<lion-combobox name="foo">
|
|
1874
1717
|
<${selectionDisplayTag} slot="selection-display"></${selectionDisplayTag}>
|
|
1875
1718
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1876
1719
|
</lion-combobox>
|
|
1877
|
-
`)
|
|
1878
|
-
);
|
|
1720
|
+
`);
|
|
1879
1721
|
// @ts-ignore sinon type error
|
|
1880
1722
|
const spy = sinon.spy(el._selectionDisplayNode, 'onComboboxElementUpdated');
|
|
1881
1723
|
el.requestUpdate('modelValue', undefined);
|
|
@@ -1947,21 +1789,20 @@ describe('lion-combobox', () => {
|
|
|
1947
1789
|
// });
|
|
1948
1790
|
});
|
|
1949
1791
|
});
|
|
1950
|
-
|
|
1951
1792
|
describe('Autocompletion', () => {
|
|
1952
1793
|
it('has autocomplete "both" by default', async () => {
|
|
1953
|
-
const el =
|
|
1794
|
+
const el =
|
|
1795
|
+
/** @type {LionCombobox} */
|
|
1954
1796
|
await fixture(html`
|
|
1955
1797
|
<lion-combobox name="foo">
|
|
1956
1798
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
1957
1799
|
</lion-combobox>
|
|
1958
|
-
`)
|
|
1959
|
-
);
|
|
1800
|
+
`);
|
|
1960
1801
|
expect(el.autocomplete).to.equal('both');
|
|
1961
1802
|
});
|
|
1962
|
-
|
|
1963
1803
|
it('filters options when autocomplete is "both"', async () => {
|
|
1964
|
-
const el =
|
|
1804
|
+
const el =
|
|
1805
|
+
/** @type {LionCombobox} */
|
|
1965
1806
|
await fixture(html`
|
|
1966
1807
|
<lion-combobox name="foo" autocomplete="both">
|
|
1967
1808
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1969,15 +1810,14 @@ describe('lion-combobox', () => {
|
|
|
1969
1810
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1970
1811
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1971
1812
|
</lion-combobox>
|
|
1972
|
-
`)
|
|
1973
|
-
);
|
|
1813
|
+
`);
|
|
1974
1814
|
await mimicUserTyping(el, 'ch');
|
|
1975
1815
|
await el.updateComplete;
|
|
1976
1816
|
expect(getFilteredOptionValues(el)).to.eql(['Artichoke', 'Chard', 'Chicory']);
|
|
1977
1817
|
});
|
|
1978
|
-
|
|
1979
1818
|
it('completes textbox when autocomplete is "both"', async () => {
|
|
1980
|
-
const el =
|
|
1819
|
+
const el =
|
|
1820
|
+
/** @type {LionCombobox} */
|
|
1981
1821
|
await fixture(html`
|
|
1982
1822
|
<lion-combobox name="foo" autocomplete="both">
|
|
1983
1823
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -1985,12 +1825,10 @@ describe('lion-combobox', () => {
|
|
|
1985
1825
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1986
1826
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1987
1827
|
</lion-combobox>
|
|
1988
|
-
`)
|
|
1989
|
-
);
|
|
1828
|
+
`);
|
|
1990
1829
|
await mimicUserTyping(el, 'ch');
|
|
1991
1830
|
await el.updateComplete;
|
|
1992
1831
|
const { _inputNode } = getComboboxMembers(el);
|
|
1993
|
-
|
|
1994
1832
|
expect(_inputNode.value).to.equal('Chard');
|
|
1995
1833
|
expect(_inputNode.selectionStart).to.equal(2);
|
|
1996
1834
|
expect(_inputNode.selectionEnd).to.equal(_inputNode.value.length);
|
|
@@ -2000,9 +1838,9 @@ describe('lion-combobox', () => {
|
|
|
2000
1838
|
expect(_inputNode.value).to.equal('c');
|
|
2001
1839
|
expect(_inputNode.selectionStart).to.equal(_inputNode.value.length);
|
|
2002
1840
|
});
|
|
2003
|
-
|
|
2004
1841
|
it('filters options when autocomplete is "list"', async () => {
|
|
2005
|
-
const el =
|
|
1842
|
+
const el =
|
|
1843
|
+
/** @type {LionCombobox} */
|
|
2006
1844
|
await fixture(html`
|
|
2007
1845
|
<lion-combobox name="foo" autocomplete="list">
|
|
2008
1846
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2010,18 +1848,16 @@ describe('lion-combobox', () => {
|
|
|
2010
1848
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2011
1849
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2012
1850
|
</lion-combobox>
|
|
2013
|
-
`)
|
|
2014
|
-
);
|
|
1851
|
+
`);
|
|
2015
1852
|
const { _inputNode } = getComboboxMembers(el);
|
|
2016
|
-
|
|
2017
1853
|
await mimicUserTyping(el, 'ch');
|
|
2018
1854
|
await el.updateComplete;
|
|
2019
1855
|
expect(getFilteredOptionValues(el)).to.eql(['Artichoke', 'Chard', 'Chicory']);
|
|
2020
1856
|
expect(_inputNode.value).to.equal('ch');
|
|
2021
1857
|
});
|
|
2022
|
-
|
|
2023
1858
|
it('does not filter options when autocomplete is "none"', async () => {
|
|
2024
|
-
const el =
|
|
1859
|
+
const el =
|
|
1860
|
+
/** @type {LionCombobox} */
|
|
2025
1861
|
await fixture(html`
|
|
2026
1862
|
<lion-combobox name="foo" autocomplete="none">
|
|
2027
1863
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2029,8 +1865,7 @@ describe('lion-combobox', () => {
|
|
|
2029
1865
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2030
1866
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2031
1867
|
</lion-combobox>
|
|
2032
|
-
`)
|
|
2033
|
-
);
|
|
1868
|
+
`);
|
|
2034
1869
|
await mimicUserTyping(el, 'ch');
|
|
2035
1870
|
await el.updateComplete;
|
|
2036
1871
|
expect(getFilteredOptionValues(el)).to.eql([
|
|
@@ -2040,17 +1875,16 @@ describe('lion-combobox', () => {
|
|
|
2040
1875
|
'Victoria Plum',
|
|
2041
1876
|
]);
|
|
2042
1877
|
});
|
|
2043
|
-
|
|
2044
1878
|
it('does not autocomplete on [Enter] when textbox content does not match options', async () => {
|
|
2045
|
-
const el =
|
|
1879
|
+
const el =
|
|
1880
|
+
/** @type {LionCombobox} */
|
|
2046
1881
|
await fixture(html`
|
|
2047
1882
|
<lion-combobox name="foo">
|
|
2048
1883
|
<lion-option .choiceValue="${'Mango'}">Mango</lion-option>
|
|
2049
1884
|
<lion-option .choiceValue="${'Lemon'}">Lemon</lion-option>
|
|
2050
1885
|
<lion-option .choiceValue="${'Apple'}">Apple</lion-option>
|
|
2051
1886
|
</lion-combobox>
|
|
2052
|
-
`)
|
|
2053
|
-
);
|
|
1887
|
+
`);
|
|
2054
1888
|
const { _inputNode } = getComboboxMembers(el);
|
|
2055
1889
|
mimicUserTypingAdvanced(el, ['m', 'a', 'k']);
|
|
2056
1890
|
await el.updateComplete;
|
|
@@ -2059,17 +1893,16 @@ describe('lion-combobox', () => {
|
|
|
2059
1893
|
await el.updateComplete;
|
|
2060
1894
|
expect(_inputNode.value).to.equal('Mak');
|
|
2061
1895
|
});
|
|
2062
|
-
|
|
2063
1896
|
it('does not autocomplete on [Enter] when textbox content does not match options and content was cleared via [Backspace]', async () => {
|
|
2064
|
-
const el =
|
|
1897
|
+
const el =
|
|
1898
|
+
/** @type {LionCombobox} */
|
|
2065
1899
|
await fixture(html`
|
|
2066
1900
|
<lion-combobox name="foo">
|
|
2067
1901
|
<lion-option .choiceValue="${'Mango'}">Mango</lion-option>
|
|
2068
1902
|
<lion-option .choiceValue="${'Lemon'}">Lemon</lion-option>
|
|
2069
1903
|
<lion-option .choiceValue="${'Apple'}">Apple</lion-option>
|
|
2070
1904
|
</lion-combobox>
|
|
2071
|
-
`)
|
|
2072
|
-
);
|
|
1905
|
+
`);
|
|
2073
1906
|
const { _inputNode } = getComboboxMembers(el);
|
|
2074
1907
|
mimicUserTypingAdvanced(el, ['m', 'o', 'Backspace', 'Backspace', 'm', 'o']);
|
|
2075
1908
|
await el.updateComplete;
|
|
@@ -2081,9 +1914,9 @@ describe('lion-combobox', () => {
|
|
|
2081
1914
|
await el.updateComplete;
|
|
2082
1915
|
expect(_inputNode.value).to.equal('Mo');
|
|
2083
1916
|
});
|
|
2084
|
-
|
|
2085
1917
|
it('does not filter options when autocomplete is "inline"', async () => {
|
|
2086
|
-
const el =
|
|
1918
|
+
const el =
|
|
1919
|
+
/** @type {LionCombobox} */
|
|
2087
1920
|
await fixture(html`
|
|
2088
1921
|
<lion-combobox name="foo" autocomplete="inline">
|
|
2089
1922
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2091,8 +1924,7 @@ describe('lion-combobox', () => {
|
|
|
2091
1924
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2092
1925
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2093
1926
|
</lion-combobox>
|
|
2094
|
-
`)
|
|
2095
|
-
);
|
|
1927
|
+
`);
|
|
2096
1928
|
await mimicUserTyping(el, 'ch');
|
|
2097
1929
|
await el.updateComplete;
|
|
2098
1930
|
expect(getFilteredOptionValues(el)).to.eql([
|
|
@@ -2102,9 +1934,9 @@ describe('lion-combobox', () => {
|
|
|
2102
1934
|
'Victoria Plum',
|
|
2103
1935
|
]);
|
|
2104
1936
|
});
|
|
2105
|
-
|
|
2106
1937
|
it('resets "checkedIndex" when going from matched to unmatched textbox value', async () => {
|
|
2107
|
-
const el =
|
|
1938
|
+
const el =
|
|
1939
|
+
/** @type {LionCombobox} */
|
|
2108
1940
|
await fixture(html`
|
|
2109
1941
|
<lion-combobox name="foo" autocomplete="inline">
|
|
2110
1942
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2112,19 +1944,17 @@ describe('lion-combobox', () => {
|
|
|
2112
1944
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2113
1945
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2114
1946
|
</lion-combobox>
|
|
2115
|
-
`)
|
|
2116
|
-
);
|
|
2117
|
-
|
|
1947
|
+
`);
|
|
2118
1948
|
await mimicUserTyping(el, 'ch');
|
|
2119
1949
|
await el.updateComplete;
|
|
2120
1950
|
expect(el.checkedIndex).to.equal(1);
|
|
2121
|
-
|
|
2122
1951
|
await mimicUserTyping(el, 'cho');
|
|
2123
1952
|
await el.updateComplete;
|
|
2124
1953
|
expect(el.checkedIndex).to.equal(-1);
|
|
2125
1954
|
|
|
2126
1955
|
// Works for autocomplete 'both' as well.
|
|
2127
|
-
const el2 =
|
|
1956
|
+
const el2 =
|
|
1957
|
+
/** @type {LionCombobox} */
|
|
2128
1958
|
await fixture(html`
|
|
2129
1959
|
<lion-combobox name="foo" autocomplete="both">
|
|
2130
1960
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2132,9 +1962,7 @@ describe('lion-combobox', () => {
|
|
|
2132
1962
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2133
1963
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2134
1964
|
</lion-combobox>
|
|
2135
|
-
`)
|
|
2136
|
-
);
|
|
2137
|
-
|
|
1965
|
+
`);
|
|
2138
1966
|
await mimicUserTyping(el2, 'ch');
|
|
2139
1967
|
await el2.updateComplete;
|
|
2140
1968
|
expect(el2.checkedIndex).to.equal(1);
|
|
@@ -2144,9 +1972,9 @@ describe('lion-combobox', () => {
|
|
|
2144
1972
|
await el2.updateComplete;
|
|
2145
1973
|
expect(el2.checkedIndex).to.equal(-1);
|
|
2146
1974
|
});
|
|
2147
|
-
|
|
2148
1975
|
it('resets "checkedIndex" when going from matched to another matched textbox value', async () => {
|
|
2149
|
-
const el =
|
|
1976
|
+
const el =
|
|
1977
|
+
/** @type {LionCombobox} */
|
|
2150
1978
|
await fixture(html`
|
|
2151
1979
|
<lion-combobox name="foo" autocomplete="both">
|
|
2152
1980
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2154,19 +1982,17 @@ describe('lion-combobox', () => {
|
|
|
2154
1982
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2155
1983
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2156
1984
|
</lion-combobox>
|
|
2157
|
-
`)
|
|
2158
|
-
);
|
|
1985
|
+
`);
|
|
2159
1986
|
|
|
2160
1987
|
/** Goes from 2nd option Chard to 3rd option Chicory */
|
|
2161
1988
|
await mimicUserTyping(el, 'ch');
|
|
2162
1989
|
await el.updateComplete;
|
|
2163
1990
|
expect(el.checkedIndex).to.equal(1);
|
|
2164
|
-
|
|
2165
1991
|
await mimicUserTyping(el, 'chi');
|
|
2166
1992
|
await el.updateComplete;
|
|
2167
1993
|
expect(el.checkedIndex).to.equal(2);
|
|
2168
|
-
|
|
2169
|
-
|
|
1994
|
+
const el2 =
|
|
1995
|
+
/** @type {LionCombobox} */
|
|
2170
1996
|
await fixture(html`
|
|
2171
1997
|
<lion-combobox name="foo" autocomplete="both">
|
|
2172
1998
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2174,9 +2000,7 @@ describe('lion-combobox', () => {
|
|
|
2174
2000
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2175
2001
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2176
2002
|
</lion-combobox>
|
|
2177
|
-
`)
|
|
2178
|
-
);
|
|
2179
|
-
|
|
2003
|
+
`);
|
|
2180
2004
|
await mimicUserTyping(el2, 'ch');
|
|
2181
2005
|
await el2.updateComplete;
|
|
2182
2006
|
expect(el2.checkedIndex).to.equal(1);
|
|
@@ -2189,9 +2013,9 @@ describe('lion-combobox', () => {
|
|
|
2189
2013
|
expect(el2.checkedIndex).to.equal(-1);
|
|
2190
2014
|
expect(getFilteredOptionValues(el2)).to.eql(['Artichoke']);
|
|
2191
2015
|
});
|
|
2192
|
-
|
|
2193
2016
|
it('sets "checkedIndex" only if the match, matches from the beginning of the word', async () => {
|
|
2194
|
-
const el =
|
|
2017
|
+
const el =
|
|
2018
|
+
/** @type {LionCombobox} */
|
|
2195
2019
|
await fixture(html`
|
|
2196
2020
|
<lion-combobox name="foo" autocomplete="both">
|
|
2197
2021
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2199,8 +2023,7 @@ describe('lion-combobox', () => {
|
|
|
2199
2023
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2200
2024
|
<lion-option .choiceValue="${'Daikon'}">Daikon</lion-option>
|
|
2201
2025
|
</lion-combobox>
|
|
2202
|
-
`)
|
|
2203
|
-
);
|
|
2026
|
+
`);
|
|
2204
2027
|
|
|
2205
2028
|
// first match is Char'd', but better match is 'D'aikon
|
|
2206
2029
|
await mimicUserTyping(el, 'd');
|
|
@@ -2208,9 +2031,9 @@ describe('lion-combobox', () => {
|
|
|
2208
2031
|
expect(el.checkedIndex).to.equal(3);
|
|
2209
2032
|
expect(getFilteredOptionValues(el)).to.eql(['Chard', 'Daikon']);
|
|
2210
2033
|
});
|
|
2211
|
-
|
|
2212
2034
|
it('completes chars inside textbox', async () => {
|
|
2213
|
-
const el =
|
|
2035
|
+
const el =
|
|
2036
|
+
/** @type {LionCombobox} */
|
|
2214
2037
|
await fixture(html`
|
|
2215
2038
|
<lion-combobox name="foo" autocomplete="inline">
|
|
2216
2039
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2218,16 +2041,13 @@ describe('lion-combobox', () => {
|
|
|
2218
2041
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2219
2042
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2220
2043
|
</lion-combobox>
|
|
2221
|
-
`)
|
|
2222
|
-
);
|
|
2044
|
+
`);
|
|
2223
2045
|
const { _inputNode } = getComboboxMembers(el);
|
|
2224
|
-
|
|
2225
2046
|
await mimicUserTyping(el, 'ch');
|
|
2226
2047
|
await el.updateComplete;
|
|
2227
2048
|
expect(_inputNode.value).to.equal('Chard');
|
|
2228
2049
|
expect(_inputNode.selectionStart).to.equal('ch'.length);
|
|
2229
2050
|
expect(_inputNode.selectionEnd).to.equal('Chard'.length);
|
|
2230
|
-
|
|
2231
2051
|
await mimicUserTypingAdvanced(el, ['i', 'c']);
|
|
2232
2052
|
await el.updateComplete;
|
|
2233
2053
|
expect(_inputNode.value).to.equal('Chicory');
|
|
@@ -2241,9 +2061,9 @@ describe('lion-combobox', () => {
|
|
|
2241
2061
|
expect(_inputNode.selectionStart).to.equal('ch'.length);
|
|
2242
2062
|
expect(_inputNode.selectionEnd).to.equal('ch'.length);
|
|
2243
2063
|
});
|
|
2244
|
-
|
|
2245
2064
|
it('synchronizes textbox on overlay close', async () => {
|
|
2246
|
-
const el =
|
|
2065
|
+
const el =
|
|
2066
|
+
/** @type {LionCombobox} */
|
|
2247
2067
|
await fixture(html`
|
|
2248
2068
|
<lion-combobox name="foo" autocomplete="none">
|
|
2249
2069
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2251,8 +2071,7 @@ describe('lion-combobox', () => {
|
|
|
2251
2071
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2252
2072
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2253
2073
|
</lion-combobox>
|
|
2254
|
-
`)
|
|
2255
|
-
);
|
|
2074
|
+
`);
|
|
2256
2075
|
const { _inputNode } = getComboboxMembers(el);
|
|
2257
2076
|
await el.updateComplete;
|
|
2258
2077
|
expect(_inputNode.value).to.equal('');
|
|
@@ -2274,21 +2093,19 @@ describe('lion-combobox', () => {
|
|
|
2274
2093
|
await el.updateComplete;
|
|
2275
2094
|
expect(_inputNode.value).to.equal(valueOnClose, autocomplete);
|
|
2276
2095
|
}
|
|
2277
|
-
|
|
2278
2096
|
await performChecks('none', 0, 'Artichoke');
|
|
2279
2097
|
await performChecks('list', 0, 'Artichoke');
|
|
2280
2098
|
await performChecks('inline', 0, 'Artichoke');
|
|
2281
2099
|
await performChecks('both', 0, 'Artichoke');
|
|
2282
|
-
|
|
2283
2100
|
el.multipleChoice = true;
|
|
2284
2101
|
await performChecks('none', [0, 1], '');
|
|
2285
2102
|
await performChecks('list', [0, 1], '');
|
|
2286
2103
|
await performChecks('inline', [0, 1], '');
|
|
2287
2104
|
await performChecks('both', [0, 1], '');
|
|
2288
2105
|
});
|
|
2289
|
-
|
|
2290
2106
|
it('is possible to adjust textbox synchronize condition on overlay close', async () => {
|
|
2291
|
-
const el =
|
|
2107
|
+
const el =
|
|
2108
|
+
/** @type {LionCombobox} */
|
|
2292
2109
|
await fixture(html`
|
|
2293
2110
|
<lion-combobox name="foo" autocomplete="none" ._syncToTextboxCondition="${() => false}">
|
|
2294
2111
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2296,9 +2113,7 @@ describe('lion-combobox', () => {
|
|
|
2296
2113
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2297
2114
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2298
2115
|
</lion-combobox>
|
|
2299
|
-
`)
|
|
2300
|
-
);
|
|
2301
|
-
|
|
2116
|
+
`);
|
|
2302
2117
|
const { _inputNode } = getComboboxMembers(el);
|
|
2303
2118
|
expect(_inputNode.value).to.equal('');
|
|
2304
2119
|
|
|
@@ -2318,21 +2133,19 @@ describe('lion-combobox', () => {
|
|
|
2318
2133
|
await el.updateComplete;
|
|
2319
2134
|
expect(_inputNode.value).to.equal(valueOnClose);
|
|
2320
2135
|
}
|
|
2321
|
-
|
|
2322
2136
|
await performChecks('none', 0, '');
|
|
2323
2137
|
await performChecks('list', 0, '');
|
|
2324
2138
|
await performChecks('inline', 0, '');
|
|
2325
2139
|
await performChecks('both', 0, '');
|
|
2326
|
-
|
|
2327
2140
|
el.multipleChoice = true;
|
|
2328
2141
|
await performChecks('none', [0, 1], '');
|
|
2329
2142
|
await performChecks('list', [0, 1], '');
|
|
2330
2143
|
await performChecks('inline', [0, 1], '');
|
|
2331
2144
|
await performChecks('both', [0, 1], '');
|
|
2332
2145
|
});
|
|
2333
|
-
|
|
2334
2146
|
it('does inline autocompletion when adding chars', async () => {
|
|
2335
|
-
const el =
|
|
2147
|
+
const el =
|
|
2148
|
+
/** @type {LionCombobox} */
|
|
2336
2149
|
await fixture(html`
|
|
2337
2150
|
<lion-combobox name="foo" autocomplete="inline">
|
|
2338
2151
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2340,27 +2153,23 @@ describe('lion-combobox', () => {
|
|
|
2340
2153
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2341
2154
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2342
2155
|
</lion-combobox>
|
|
2343
|
-
`)
|
|
2344
|
-
);
|
|
2345
|
-
|
|
2156
|
+
`);
|
|
2346
2157
|
await mimicUserTyping(el, 'ch'); // ch
|
|
2347
2158
|
await el.updateComplete; // Ch[ard]
|
|
2348
2159
|
expect(el.activeIndex).to.equal(1);
|
|
2349
2160
|
expect(el.checkedIndex).to.equal(1);
|
|
2350
|
-
|
|
2351
2161
|
await mimicUserTypingAdvanced(el, ['i', 'c']); // Chic
|
|
2352
2162
|
await el.updateComplete; // Chic[ory]
|
|
2353
2163
|
expect(el.activeIndex).to.equal(2);
|
|
2354
2164
|
expect(el.checkedIndex).to.equal(2);
|
|
2355
|
-
|
|
2356
2165
|
await mimicUserTypingAdvanced(el, ['Backspace', 'Backspace', 'Backspace', 'Backspace', 'h']); // Ch
|
|
2357
2166
|
await el.updateComplete; // Ch[ard]
|
|
2358
2167
|
expect(el.activeIndex).to.equal(1);
|
|
2359
2168
|
expect(el.checkedIndex).to.equal(1);
|
|
2360
2169
|
});
|
|
2361
|
-
|
|
2362
2170
|
it('does inline autocompletion when changing the word', async () => {
|
|
2363
|
-
const el =
|
|
2171
|
+
const el =
|
|
2172
|
+
/** @type {LionCombobox} */
|
|
2364
2173
|
await fixture(html`
|
|
2365
2174
|
<lion-combobox name="foo" autocomplete="inline">
|
|
2366
2175
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2368,14 +2177,11 @@ describe('lion-combobox', () => {
|
|
|
2368
2177
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2369
2178
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2370
2179
|
</lion-combobox>
|
|
2371
|
-
`)
|
|
2372
|
-
);
|
|
2373
|
-
|
|
2180
|
+
`);
|
|
2374
2181
|
await mimicUserTyping(el, 'ch');
|
|
2375
2182
|
await el.updateComplete;
|
|
2376
2183
|
expect(el.activeIndex).to.equal(1);
|
|
2377
2184
|
expect(el.checkedIndex).to.equal(1);
|
|
2378
|
-
|
|
2379
2185
|
await mimicUserTypingAdvanced(el, ['i']);
|
|
2380
2186
|
await el.updateComplete;
|
|
2381
2187
|
expect(el.activeIndex).to.equal(2);
|
|
@@ -2387,9 +2193,9 @@ describe('lion-combobox', () => {
|
|
|
2387
2193
|
expect(el.activeIndex).to.equal(0);
|
|
2388
2194
|
expect(el.checkedIndex).to.equal(0);
|
|
2389
2195
|
});
|
|
2390
|
-
|
|
2391
2196
|
it('filters options correctly when changing the middle of the word', async () => {
|
|
2392
|
-
const el =
|
|
2197
|
+
const el =
|
|
2198
|
+
/** @type {LionCombobox} */
|
|
2393
2199
|
await fixture(html`
|
|
2394
2200
|
<lion-combobox name="foo" autocomplete="list" match-mode="all">
|
|
2395
2201
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2397,17 +2203,13 @@ describe('lion-combobox', () => {
|
|
|
2397
2203
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2398
2204
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2399
2205
|
</lion-combobox>
|
|
2400
|
-
`)
|
|
2401
|
-
);
|
|
2402
|
-
|
|
2206
|
+
`);
|
|
2403
2207
|
const { _inputNode } = getComboboxMembers(el);
|
|
2404
|
-
|
|
2405
2208
|
await mimicUserTyping(el, 'char');
|
|
2406
2209
|
expect(_inputNode.value).to.equal('char');
|
|
2407
2210
|
await el.updateComplete; // Char
|
|
2408
2211
|
|
|
2409
2212
|
expect(getFilteredOptionValues(el)).to.eql(['Chard']);
|
|
2410
|
-
|
|
2411
2213
|
_inputNode.setSelectionRange(3, 3);
|
|
2412
2214
|
await mimicUserTypingAdvanced(el, ['Backspace', 'i', 'c', 'o']);
|
|
2413
2215
|
await el.updateComplete; // Chicor
|
|
@@ -2415,9 +2217,9 @@ describe('lion-combobox', () => {
|
|
|
2415
2217
|
expect(_inputNode.value).to.equal('chicor');
|
|
2416
2218
|
expect(getFilteredOptionValues(el)).to.eql(['Chicory']);
|
|
2417
2219
|
});
|
|
2418
|
-
|
|
2419
2220
|
it('computation of "user intends autofill" works correctly afer autofill', async () => {
|
|
2420
|
-
const el =
|
|
2221
|
+
const el =
|
|
2222
|
+
/** @type {LionCombobox} */
|
|
2421
2223
|
await fixture(html`
|
|
2422
2224
|
<lion-combobox name="foo" autocomplete="inline">
|
|
2423
2225
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2425,10 +2227,8 @@ describe('lion-combobox', () => {
|
|
|
2425
2227
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2426
2228
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2427
2229
|
</lion-combobox>
|
|
2428
|
-
`)
|
|
2429
|
-
);
|
|
2230
|
+
`);
|
|
2430
2231
|
const { _inputNode } = getComboboxMembers(el);
|
|
2431
|
-
|
|
2432
2232
|
await mimicUserTyping(el, 'ch');
|
|
2433
2233
|
await el.updateComplete;
|
|
2434
2234
|
expect(_inputNode.value).to.equal('Chard');
|
|
@@ -2443,42 +2243,35 @@ describe('lion-combobox', () => {
|
|
|
2443
2243
|
expect(_inputNode.selectionStart).to.equal('Ch'.length);
|
|
2444
2244
|
expect(_inputNode.selectionEnd).to.equal('Ch'.length);
|
|
2445
2245
|
});
|
|
2446
|
-
|
|
2447
2246
|
describe('Server side completion support', () => {
|
|
2448
2247
|
const listboxData = ['lorem', 'ipsum', 'dolor', 'sit', 'amet'];
|
|
2449
|
-
|
|
2450
2248
|
class MyEl extends LitElement {
|
|
2451
2249
|
constructor() {
|
|
2452
2250
|
super();
|
|
2453
2251
|
/** @type {string[]} */
|
|
2454
2252
|
this.options = [...listboxData];
|
|
2455
2253
|
}
|
|
2456
|
-
|
|
2457
2254
|
clearOptions() {
|
|
2458
2255
|
/** @type {string[]} */
|
|
2459
2256
|
this.options = [];
|
|
2460
2257
|
this.requestUpdate();
|
|
2461
2258
|
}
|
|
2462
|
-
|
|
2463
2259
|
addOption() {
|
|
2464
2260
|
this.options.push(`option ${this.options.length + 1}`);
|
|
2465
2261
|
this.requestUpdate();
|
|
2466
2262
|
}
|
|
2467
|
-
|
|
2468
2263
|
fillAllOptions() {
|
|
2469
2264
|
this.options = [...listboxData];
|
|
2470
2265
|
this.requestUpdate();
|
|
2471
2266
|
}
|
|
2472
|
-
|
|
2473
2267
|
get combobox() {
|
|
2474
|
-
return /** @type {LionCombobox} */
|
|
2268
|
+
return /** @type {LionCombobox} */ this.shadowRoot?.querySelector('#combobox');
|
|
2475
2269
|
}
|
|
2476
|
-
|
|
2477
2270
|
render() {
|
|
2478
2271
|
return html`
|
|
2479
2272
|
<lion-combobox id="combobox" label="Server side completion">
|
|
2480
2273
|
${this.options.map(
|
|
2481
|
-
option => html` <lion-option .choiceValue="${option}">${option}</lion-option> `,
|
|
2274
|
+
(option) => html` <lion-option .choiceValue="${option}">${option}</lion-option> `,
|
|
2482
2275
|
)}
|
|
2483
2276
|
</lion-combobox>
|
|
2484
2277
|
`;
|
|
@@ -2486,9 +2279,8 @@ describe('lion-combobox', () => {
|
|
|
2486
2279
|
}
|
|
2487
2280
|
const tagName = defineCE(MyEl);
|
|
2488
2281
|
const wrappingTag = unsafeStatic(tagName);
|
|
2489
|
-
|
|
2490
2282
|
it('calls "_handleAutocompletion" after externally changing options', async () => {
|
|
2491
|
-
const el = /** @type {MyEl} */
|
|
2283
|
+
const el = /** @type {MyEl} */ await fixture(html`<${wrappingTag}></${wrappingTag}>`);
|
|
2492
2284
|
await el.combobox.registrationComplete;
|
|
2493
2285
|
// @ts-ignore [allow-protected] in test
|
|
2494
2286
|
const spy = sinon.spy(el.combobox, '_handleAutocompletion');
|
|
@@ -2501,10 +2293,9 @@ describe('lion-combobox', () => {
|
|
|
2501
2293
|
await el.updateComplete;
|
|
2502
2294
|
expect(spy).to.have.been.calledTwice;
|
|
2503
2295
|
});
|
|
2504
|
-
|
|
2505
2296
|
it('should handle dynamic options', async () => {
|
|
2506
2297
|
// Arrange
|
|
2507
|
-
const el = /** @type {MyEl} */
|
|
2298
|
+
const el = /** @type {MyEl} */ await fixture(html`<${wrappingTag}></${wrappingTag}>`);
|
|
2508
2299
|
await el.combobox.registrationComplete;
|
|
2509
2300
|
const { _inputNode } = getComboboxMembers(el.combobox);
|
|
2510
2301
|
|
|
@@ -2546,7 +2337,6 @@ describe('lion-combobox', () => {
|
|
|
2546
2337
|
expect(_inputNode.selectionStart).to.equal(_inputNode.value.length);
|
|
2547
2338
|
});
|
|
2548
2339
|
});
|
|
2549
|
-
|
|
2550
2340
|
describe('Subclassers', () => {
|
|
2551
2341
|
it('allows to configure autoselect', async () => {
|
|
2552
2342
|
class X extends LionCombobox {
|
|
@@ -2556,8 +2346,8 @@ describe('lion-combobox', () => {
|
|
|
2556
2346
|
}
|
|
2557
2347
|
const tagName = defineCE(X);
|
|
2558
2348
|
const tag = unsafeStatic(tagName);
|
|
2559
|
-
|
|
2560
|
-
|
|
2349
|
+
const el =
|
|
2350
|
+
/** @type {LionCombobox} */
|
|
2561
2351
|
await fixture(html`
|
|
2562
2352
|
<${tag} name="foo" opened>
|
|
2563
2353
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2565,17 +2355,15 @@ describe('lion-combobox', () => {
|
|
|
2565
2355
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2566
2356
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2567
2357
|
</${tag}>
|
|
2568
|
-
`)
|
|
2569
|
-
);
|
|
2570
|
-
|
|
2358
|
+
`);
|
|
2571
2359
|
await mimicUserTypingAdvanced(el, ['v', 'i']); // so we have options ['Victoria Plum']
|
|
2572
2360
|
await el.updateComplete;
|
|
2573
2361
|
expect(el.checkedIndex).to.equal(3);
|
|
2574
2362
|
});
|
|
2575
2363
|
});
|
|
2576
|
-
|
|
2577
2364
|
it('highlights first occurrence of matching option', async () => {
|
|
2578
|
-
const el =
|
|
2365
|
+
const el =
|
|
2366
|
+
/** @type {LionCombobox} */
|
|
2579
2367
|
await fixture(html`
|
|
2580
2368
|
<lion-combobox name="foo" match-mode="all">
|
|
2581
2369
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2583,12 +2371,9 @@ describe('lion-combobox', () => {
|
|
|
2583
2371
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2584
2372
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2585
2373
|
</lion-combobox>
|
|
2586
|
-
`)
|
|
2587
|
-
);
|
|
2374
|
+
`);
|
|
2588
2375
|
const options = el.formElements;
|
|
2589
|
-
|
|
2590
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'c');
|
|
2591
|
-
|
|
2376
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'c');
|
|
2592
2377
|
await el.updateComplete;
|
|
2593
2378
|
expect(options[0]).lightDom.to.equal(`<span aria-label="Artichoke">Arti<b>c</b>hoke</span>`);
|
|
2594
2379
|
expect(options[1]).lightDom.to.equal(`<span aria-label="Chard"><b>C</b>hard</span>`);
|
|
@@ -2596,26 +2381,22 @@ describe('lion-combobox', () => {
|
|
|
2596
2381
|
expect(options[3]).lightDom.to.equal(
|
|
2597
2382
|
`<span aria-label="Victoria Plum">Vi<b>c</b>toria Plum</span>`,
|
|
2598
2383
|
);
|
|
2599
|
-
|
|
2600
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'ch');
|
|
2601
|
-
|
|
2384
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
2602
2385
|
await el.updateComplete;
|
|
2603
2386
|
expect(options[0]).lightDom.to.equal(`<span aria-label="Artichoke">Arti<b>ch</b>oke</span>`);
|
|
2604
2387
|
expect(options[1]).lightDom.to.equal(`<span aria-label="Chard"><b>Ch</b>ard</span>`);
|
|
2605
2388
|
expect(options[2]).lightDom.to.equal(`<span aria-label="Chicory"><b>Ch</b>icory</span>`);
|
|
2606
2389
|
expect(options[3]).lightDom.to.equal(`Victoria Plum`);
|
|
2607
|
-
|
|
2608
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'D');
|
|
2609
|
-
|
|
2390
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'D');
|
|
2610
2391
|
await el.updateComplete;
|
|
2611
2392
|
expect(options[0]).lightDom.to.equal(`Artichoke`);
|
|
2612
2393
|
expect(options[1]).lightDom.to.equal(`<span aria-label="Chard">Char<b>d</b></span>`);
|
|
2613
2394
|
expect(options[2]).lightDom.to.equal(`Chicory`);
|
|
2614
2395
|
expect(options[3]).lightDom.to.equal(`Victoria Plum`);
|
|
2615
2396
|
});
|
|
2616
|
-
|
|
2617
2397
|
it('highlights matching complex options', async () => {
|
|
2618
|
-
const el =
|
|
2398
|
+
const el =
|
|
2399
|
+
/** @type {LionCombobox} */
|
|
2619
2400
|
await fixture(html`
|
|
2620
2401
|
<lion-combobox name="foo" match-mode="all">
|
|
2621
2402
|
<lion-option .choiceValue="${'Artichoke'}">
|
|
@@ -2635,12 +2416,9 @@ describe('lion-combobox', () => {
|
|
|
2635
2416
|
<small>Prunus domestica</small>
|
|
2636
2417
|
</lion-option>
|
|
2637
2418
|
</lion-combobox>
|
|
2638
|
-
`)
|
|
2639
|
-
);
|
|
2419
|
+
`);
|
|
2640
2420
|
const options = el.formElements;
|
|
2641
|
-
|
|
2642
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'ch');
|
|
2643
|
-
|
|
2421
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
2644
2422
|
await el.updateComplete;
|
|
2645
2423
|
expect(options[0]).lightDom.to.equal(
|
|
2646
2424
|
`<span aria-label=" Artichoke Cardoon "><div>Arti<b>ch</b>oke</div><small>Cardoon</small>`,
|
|
@@ -2655,9 +2433,9 @@ describe('lion-combobox', () => {
|
|
|
2655
2433
|
`<div>Victoria Plum</div><small>Prunus domestica</small>`,
|
|
2656
2434
|
);
|
|
2657
2435
|
});
|
|
2658
|
-
|
|
2659
2436
|
it('resets removes highlights on reset()', async () => {
|
|
2660
|
-
const el =
|
|
2437
|
+
const el =
|
|
2438
|
+
/** @type {LionCombobox} */
|
|
2661
2439
|
await fixture(html`
|
|
2662
2440
|
<lion-combobox name="foo" match-mode="all">
|
|
2663
2441
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2665,21 +2443,18 @@ describe('lion-combobox', () => {
|
|
|
2665
2443
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2666
2444
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2667
2445
|
</lion-combobox>
|
|
2668
|
-
`)
|
|
2669
|
-
);
|
|
2446
|
+
`);
|
|
2670
2447
|
const options = el.formElements;
|
|
2671
|
-
|
|
2672
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'c');
|
|
2673
|
-
|
|
2448
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'c');
|
|
2674
2449
|
await el.updateComplete;
|
|
2675
2450
|
expect(options[0]).lightDom.to.equal(`<span aria-label="Artichoke">Arti<b>c</b>hoke</span>`);
|
|
2676
2451
|
el.reset();
|
|
2677
2452
|
await el.updateComplete;
|
|
2678
2453
|
expect(options[0]).lightDom.to.equal(`Artichoke`);
|
|
2679
2454
|
});
|
|
2680
|
-
|
|
2681
2455
|
it('synchronizes textbox when autocomplete is "inline" or "both"', async () => {
|
|
2682
|
-
const el =
|
|
2456
|
+
const el =
|
|
2457
|
+
/** @type {LionCombobox} */
|
|
2683
2458
|
await fixture(html`
|
|
2684
2459
|
<lion-combobox name="foo" autocomplete="none">
|
|
2685
2460
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2687,38 +2462,32 @@ describe('lion-combobox', () => {
|
|
|
2687
2462
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2688
2463
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2689
2464
|
</lion-combobox>
|
|
2690
|
-
`)
|
|
2691
|
-
);
|
|
2465
|
+
`);
|
|
2692
2466
|
const { _inputNode } = getComboboxMembers(el);
|
|
2693
|
-
|
|
2694
2467
|
expect(_inputNode.value).to.equal('');
|
|
2695
|
-
|
|
2696
2468
|
el.setCheckedIndex(-1);
|
|
2697
2469
|
el.autocomplete = 'list';
|
|
2698
2470
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2699
2471
|
expect(_inputNode.value).to.equal('art');
|
|
2700
|
-
|
|
2701
2472
|
el.setCheckedIndex(-1);
|
|
2702
2473
|
el.value = '';
|
|
2703
2474
|
el.autocomplete = 'none';
|
|
2704
2475
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2705
2476
|
expect(_inputNode.value).to.equal('art');
|
|
2706
|
-
|
|
2707
2477
|
el.setCheckedIndex(-1);
|
|
2708
2478
|
el.value = '';
|
|
2709
2479
|
el.autocomplete = 'inline';
|
|
2710
2480
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2711
2481
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
2712
|
-
|
|
2713
2482
|
el.setCheckedIndex(-1);
|
|
2714
2483
|
el.value = '';
|
|
2715
2484
|
el.autocomplete = 'both';
|
|
2716
2485
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2717
2486
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
2718
2487
|
});
|
|
2719
|
-
|
|
2720
2488
|
it('synchronizes last index to textbox when autocomplete is "inline" or "both" when multipleChoice', async () => {
|
|
2721
|
-
const el =
|
|
2489
|
+
const el =
|
|
2490
|
+
/** @type {LionCombobox} */
|
|
2722
2491
|
await fixture(html`
|
|
2723
2492
|
<lion-combobox name="foo" autocomplete="none" multiple-choice>
|
|
2724
2493
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2726,37 +2495,30 @@ describe('lion-combobox', () => {
|
|
|
2726
2495
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2727
2496
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2728
2497
|
</lion-combobox>
|
|
2729
|
-
`)
|
|
2730
|
-
);
|
|
2498
|
+
`);
|
|
2731
2499
|
const { _inputNode } = getComboboxMembers(el);
|
|
2732
|
-
|
|
2733
2500
|
expect(_inputNode.value).to.eql('');
|
|
2734
|
-
|
|
2735
2501
|
el.setCheckedIndex(-1);
|
|
2736
2502
|
el.setCheckedIndex(-1);
|
|
2737
2503
|
el.autocomplete = 'list';
|
|
2738
2504
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2739
2505
|
expect(_inputNode.value).to.equal('art');
|
|
2740
|
-
|
|
2741
2506
|
el.setCheckedIndex(-1);
|
|
2742
2507
|
el.value = '';
|
|
2743
2508
|
el.autocomplete = 'none';
|
|
2744
2509
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2745
2510
|
expect(_inputNode.value).to.equal('art');
|
|
2746
|
-
|
|
2747
2511
|
el.setCheckedIndex(-1);
|
|
2748
2512
|
el.value = '';
|
|
2749
2513
|
el.autocomplete = 'inline';
|
|
2750
2514
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2751
2515
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
2752
|
-
|
|
2753
2516
|
el.setCheckedIndex(-1);
|
|
2754
2517
|
el.value = '';
|
|
2755
2518
|
el.autocomplete = 'both';
|
|
2756
2519
|
await mimicUserTypingAdvanced(el, ['a', 'r', 't']);
|
|
2757
2520
|
expect(_inputNode.value).to.equal('Artichoke');
|
|
2758
2521
|
});
|
|
2759
|
-
|
|
2760
2522
|
describe('Subclassers', () => {
|
|
2761
2523
|
it('allows to override "_syncCheckedWithTextboxMultiple"', async () => {
|
|
2762
2524
|
class X extends LionCombobox {
|
|
@@ -2778,8 +2540,8 @@ describe('lion-combobox', () => {
|
|
|
2778
2540
|
}
|
|
2779
2541
|
const tagName = defineCE(X);
|
|
2780
2542
|
const tag = unsafeStatic(tagName);
|
|
2781
|
-
|
|
2782
|
-
|
|
2543
|
+
const el =
|
|
2544
|
+
/** @type {LionCombobox} */
|
|
2783
2545
|
await fixture(html`
|
|
2784
2546
|
<${tag} name="foo" autocomplete="none" multiple-choice>
|
|
2785
2547
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -2787,31 +2549,25 @@ describe('lion-combobox', () => {
|
|
|
2787
2549
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
2788
2550
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
2789
2551
|
</${tag}>
|
|
2790
|
-
`)
|
|
2791
|
-
);
|
|
2552
|
+
`);
|
|
2792
2553
|
const { _inputNode } = getComboboxMembers(el);
|
|
2793
|
-
|
|
2794
2554
|
el.setCheckedIndex(-1);
|
|
2795
2555
|
el.autocomplete = 'none';
|
|
2796
2556
|
el.setCheckedIndex([0]);
|
|
2797
2557
|
expect(_inputNode.value).to.equal('Artichoke--multi');
|
|
2798
|
-
|
|
2799
2558
|
el.setCheckedIndex(-1);
|
|
2800
2559
|
el.autocomplete = 'list';
|
|
2801
2560
|
el.setCheckedIndex([0]);
|
|
2802
2561
|
expect(_inputNode.value).to.equal('Artichoke--multi');
|
|
2803
|
-
|
|
2804
2562
|
el.setCheckedIndex(-1);
|
|
2805
2563
|
el.autocomplete = 'inline';
|
|
2806
2564
|
el.setCheckedIndex([0]);
|
|
2807
2565
|
expect(_inputNode.value).to.equal('Artichoke--multi');
|
|
2808
|
-
|
|
2809
2566
|
el.setCheckedIndex(-1);
|
|
2810
2567
|
el.autocomplete = 'both';
|
|
2811
2568
|
el.setCheckedIndex([0]);
|
|
2812
2569
|
expect(_inputNode.value).to.equal('Artichoke--multi');
|
|
2813
2570
|
});
|
|
2814
|
-
|
|
2815
2571
|
describe('Override _getTextboxValueFromOption', () => {
|
|
2816
2572
|
it('allows to override "_getTextboxValueFromOption" and sync to textbox when multiple', async () => {
|
|
2817
2573
|
class X extends LionCombobox {
|
|
@@ -2828,8 +2584,8 @@ describe('lion-combobox', () => {
|
|
|
2828
2584
|
}
|
|
2829
2585
|
const tagName = defineCE(X);
|
|
2830
2586
|
const tag = unsafeStatic(tagName);
|
|
2831
|
-
|
|
2832
|
-
|
|
2587
|
+
const el =
|
|
2588
|
+
/** @type {LionCombobox} */
|
|
2833
2589
|
await fixture(html`
|
|
2834
2590
|
<${tag} name="foo" autocomplete="both" multiple-choice>
|
|
2835
2591
|
<lion-option .label="${'Artichoke as label'}" .choiceValue="${{
|
|
@@ -2845,8 +2601,7 @@ describe('lion-combobox', () => {
|
|
|
2845
2601
|
value: 'Victoria Plum',
|
|
2846
2602
|
}}">Victoria Plum</lion-option>
|
|
2847
2603
|
</${tag}>
|
|
2848
|
-
`)
|
|
2849
|
-
);
|
|
2604
|
+
`);
|
|
2850
2605
|
const { _inputNode } = getComboboxMembers(el);
|
|
2851
2606
|
el.setCheckedIndex(-1);
|
|
2852
2607
|
|
|
@@ -2862,7 +2617,6 @@ describe('lion-combobox', () => {
|
|
|
2862
2617
|
// Assert
|
|
2863
2618
|
expect(_inputNode.value).to.equal('Victoria Plum as label');
|
|
2864
2619
|
});
|
|
2865
|
-
|
|
2866
2620
|
it('allows to override "_getTextboxValueFromOption" and sync modelValue with textbox', async () => {
|
|
2867
2621
|
class X extends LionCombobox {
|
|
2868
2622
|
/**
|
|
@@ -2881,8 +2635,8 @@ describe('lion-combobox', () => {
|
|
|
2881
2635
|
}
|
|
2882
2636
|
const tagName = defineCE(X);
|
|
2883
2637
|
const tag = unsafeStatic(tagName);
|
|
2884
|
-
|
|
2885
|
-
|
|
2638
|
+
const el =
|
|
2639
|
+
/** @type {LionCombobox} */
|
|
2886
2640
|
await fixture(html`
|
|
2887
2641
|
<${tag} name="foo">
|
|
2888
2642
|
<lion-option .label="${'Artichoke as label'}" .choiceValue="${{
|
|
@@ -2898,21 +2652,21 @@ describe('lion-combobox', () => {
|
|
|
2898
2652
|
value: 'Victoria Plum',
|
|
2899
2653
|
}}">Victoria Plum</lion-option>
|
|
2900
2654
|
</${tag}>
|
|
2901
|
-
`)
|
|
2902
|
-
);
|
|
2655
|
+
`);
|
|
2903
2656
|
const { _inputNode } = getComboboxMembers(el);
|
|
2904
2657
|
|
|
2905
2658
|
// Assume
|
|
2906
2659
|
expect(_inputNode.value).to.equal('Chard as label');
|
|
2907
2660
|
|
|
2908
2661
|
// Act
|
|
2909
|
-
el.modelValue = {
|
|
2662
|
+
el.modelValue = {
|
|
2663
|
+
value: 'Chicory',
|
|
2664
|
+
};
|
|
2910
2665
|
await el.updateComplete;
|
|
2911
2666
|
|
|
2912
2667
|
// Assert
|
|
2913
2668
|
expect(_inputNode.value).to.equal('Chicory as label');
|
|
2914
2669
|
});
|
|
2915
|
-
|
|
2916
2670
|
it('allows to override "_getTextboxValueFromOption" and clears modelValue and textbox value on clear()', async () => {
|
|
2917
2671
|
class X extends LionCombobox {
|
|
2918
2672
|
/**
|
|
@@ -2931,10 +2685,12 @@ describe('lion-combobox', () => {
|
|
|
2931
2685
|
}
|
|
2932
2686
|
const tagName = defineCE(X);
|
|
2933
2687
|
const tag = unsafeStatic(tagName);
|
|
2934
|
-
|
|
2935
|
-
|
|
2688
|
+
const el =
|
|
2689
|
+
/** @type {LionCombobox} */
|
|
2936
2690
|
await fixture(html`
|
|
2937
|
-
<${tag} name="foo" .modelValue="${{
|
|
2691
|
+
<${tag} name="foo" .modelValue="${{
|
|
2692
|
+
value: 'Artichoke',
|
|
2693
|
+
}}">
|
|
2938
2694
|
<lion-option .label="${'Artichoke as label'}" .choiceValue="${{
|
|
2939
2695
|
value: 'Artichoke',
|
|
2940
2696
|
}}">Artichoke</lion-option>
|
|
@@ -2948,8 +2704,7 @@ describe('lion-combobox', () => {
|
|
|
2948
2704
|
value: 'Victoria Plum',
|
|
2949
2705
|
}}">Victoria Plum</lion-option>
|
|
2950
2706
|
</${tag}>
|
|
2951
|
-
`)
|
|
2952
|
-
);
|
|
2707
|
+
`);
|
|
2953
2708
|
const { _inputNode } = getComboboxMembers(el);
|
|
2954
2709
|
|
|
2955
2710
|
// Assume
|
|
@@ -2962,7 +2717,6 @@ describe('lion-combobox', () => {
|
|
|
2962
2717
|
expect(el.modelValue).to.equal('');
|
|
2963
2718
|
expect(_inputNode.value).to.equal('');
|
|
2964
2719
|
});
|
|
2965
|
-
|
|
2966
2720
|
it('allows to override "_getTextboxValueFromOption" and syncs textbox to modelValue', async () => {
|
|
2967
2721
|
class X extends LionCombobox {
|
|
2968
2722
|
/**
|
|
@@ -2978,8 +2732,8 @@ describe('lion-combobox', () => {
|
|
|
2978
2732
|
}
|
|
2979
2733
|
const tagName = defineCE(X);
|
|
2980
2734
|
const tag = unsafeStatic(tagName);
|
|
2981
|
-
|
|
2982
|
-
|
|
2735
|
+
const el =
|
|
2736
|
+
/** @type {LionCombobox} */
|
|
2983
2737
|
await fixture(html`
|
|
2984
2738
|
<${tag} name="foo">
|
|
2985
2739
|
<lion-option .label="${'Artichoke as label'}" .choiceValue="${{
|
|
@@ -2995,31 +2749,25 @@ describe('lion-combobox', () => {
|
|
|
2995
2749
|
value: 'Victoria Plum',
|
|
2996
2750
|
}}">Victoria Plum</lion-option>
|
|
2997
2751
|
</${tag}>
|
|
2998
|
-
`)
|
|
2999
|
-
);
|
|
2752
|
+
`);
|
|
3000
2753
|
const { _inputNode } = getComboboxMembers(el);
|
|
3001
2754
|
|
|
3002
2755
|
/** @param {string} autocompleteMode */
|
|
3003
2756
|
async function performChecks(autocompleteMode) {
|
|
3004
2757
|
await el.updateComplete;
|
|
3005
|
-
|
|
3006
2758
|
await mimicUserTypingAdvanced(el, ['A', 'r', 't', 'i']);
|
|
3007
2759
|
await el.updateComplete;
|
|
3008
2760
|
expect(_inputNode.value).to.equal('Arti', `autocompleteMode is ${autocompleteMode}`);
|
|
3009
|
-
|
|
3010
2761
|
await el.updateComplete;
|
|
3011
2762
|
expect(el.checkedIndex).to.equal(-1, `autocompleteMode is ${autocompleteMode}`);
|
|
3012
2763
|
_inputNode.value = '';
|
|
3013
2764
|
}
|
|
3014
|
-
|
|
3015
2765
|
el.autocomplete = 'none';
|
|
3016
2766
|
await performChecks('none');
|
|
3017
|
-
|
|
3018
2767
|
el.autocomplete = 'list';
|
|
3019
2768
|
await performChecks('list');
|
|
3020
2769
|
});
|
|
3021
2770
|
});
|
|
3022
|
-
|
|
3023
2771
|
it('allows to override "_onFilterMatch" and "_onFilterUmatch"', async () => {
|
|
3024
2772
|
class X extends LionCombobox {
|
|
3025
2773
|
/**
|
|
@@ -3029,7 +2777,7 @@ describe('lion-combobox', () => {
|
|
|
3029
2777
|
* @protected
|
|
3030
2778
|
*/
|
|
3031
2779
|
_onFilterMatch(option, matchingString) {
|
|
3032
|
-
Array.from(option.children).forEach(child => {
|
|
2780
|
+
Array.from(option.children).forEach((child) => {
|
|
3033
2781
|
if (child.hasAttribute('data-key')) {
|
|
3034
2782
|
this._highlightMatchedOption(child, matchingString);
|
|
3035
2783
|
}
|
|
@@ -3047,7 +2795,7 @@ describe('lion-combobox', () => {
|
|
|
3047
2795
|
*/
|
|
3048
2796
|
// eslint-disable-next-line no-unused-vars
|
|
3049
2797
|
_onFilterUnmatch(option, curValue, prevValue) {
|
|
3050
|
-
Array.from(option.children).forEach(child => {
|
|
2798
|
+
Array.from(option.children).forEach((child) => {
|
|
3051
2799
|
if (child.hasAttribute('data-key')) {
|
|
3052
2800
|
this._unhighlightMatchedOption(child);
|
|
3053
2801
|
}
|
|
@@ -3058,8 +2806,8 @@ describe('lion-combobox', () => {
|
|
|
3058
2806
|
}
|
|
3059
2807
|
const tagName = defineCE(X);
|
|
3060
2808
|
const tag = unsafeStatic(tagName);
|
|
3061
|
-
|
|
3062
|
-
|
|
2809
|
+
const el =
|
|
2810
|
+
/** @type {LionCombobox} */
|
|
3063
2811
|
await fixture(html`
|
|
3064
2812
|
<${tag} name="foo" autocomplete="both">
|
|
3065
2813
|
<lion-option .choiceValue="${'Artichoke'}">
|
|
@@ -3079,12 +2827,9 @@ describe('lion-combobox', () => {
|
|
|
3079
2827
|
<small>Prunus domestica</small>
|
|
3080
2828
|
</lion-option>
|
|
3081
2829
|
</${tag}>
|
|
3082
|
-
`)
|
|
3083
|
-
);
|
|
2830
|
+
`);
|
|
3084
2831
|
const options = el.formElements;
|
|
3085
|
-
|
|
3086
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'ch');
|
|
3087
|
-
|
|
2832
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
3088
2833
|
await el.updateComplete;
|
|
3089
2834
|
expect(options[0]).lightDom.to.equal(
|
|
3090
2835
|
`<div data-key><span aria-label="Artichoke">Arti<b>ch</b>oke</span></div><small>Cardoon</small>`,
|
|
@@ -3098,9 +2843,7 @@ describe('lion-combobox', () => {
|
|
|
3098
2843
|
expect(options[3]).lightDom.to.equal(
|
|
3099
2844
|
`<div data-key>Victoria Plum</div><small>Prunus domestica</small>`,
|
|
3100
2845
|
);
|
|
3101
|
-
|
|
3102
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'D');
|
|
3103
|
-
|
|
2846
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'D');
|
|
3104
2847
|
await el.updateComplete;
|
|
3105
2848
|
expect(options[0]).lightDom.to.equal(`<div data-key>Artichoke</div><small>Cardoon</small>`);
|
|
3106
2849
|
expect(options[1]).lightDom.to.equal(
|
|
@@ -3112,10 +2855,10 @@ describe('lion-combobox', () => {
|
|
|
3112
2855
|
);
|
|
3113
2856
|
});
|
|
3114
2857
|
});
|
|
3115
|
-
|
|
3116
2858
|
describe('Active index behavior', () => {
|
|
3117
2859
|
it('sets the active index to the closest match on open by default', async () => {
|
|
3118
|
-
const el =
|
|
2860
|
+
const el =
|
|
2861
|
+
/** @type {LionCombobox} */
|
|
3119
2862
|
await fixture(html`
|
|
3120
2863
|
<lion-combobox name="foo">
|
|
3121
2864
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3123,13 +2866,11 @@ describe('lion-combobox', () => {
|
|
|
3123
2866
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3124
2867
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3125
2868
|
</lion-combobox>
|
|
3126
|
-
`)
|
|
3127
|
-
);
|
|
3128
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'cha');
|
|
2869
|
+
`);
|
|
2870
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'cha');
|
|
3129
2871
|
await el.updateComplete;
|
|
3130
2872
|
expect(el.activeIndex).to.equal(1);
|
|
3131
2873
|
});
|
|
3132
|
-
|
|
3133
2874
|
it('changes whether activeIndex is set to the closest match automatically depending on autocomplete', async () => {
|
|
3134
2875
|
/**
|
|
3135
2876
|
* Automatic selection (setting activeIndex to closest matching option) in lion is set for
|
|
@@ -3137,7 +2878,8 @@ describe('lion-combobox', () => {
|
|
|
3137
2878
|
* For 'list' & 'none' autocomplete, it is turned off and manual selection is required.
|
|
3138
2879
|
* TODO: Make this configurable for list & none autocomplete?
|
|
3139
2880
|
*/
|
|
3140
|
-
const el =
|
|
2881
|
+
const el =
|
|
2882
|
+
/** @type {LionCombobox} */
|
|
3141
2883
|
await fixture(html`
|
|
3142
2884
|
<lion-combobox name="foo" autocomplete="none">
|
|
3143
2885
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3145,8 +2887,7 @@ describe('lion-combobox', () => {
|
|
|
3145
2887
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3146
2888
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3147
2889
|
</lion-combobox>
|
|
3148
|
-
`)
|
|
3149
|
-
);
|
|
2890
|
+
`);
|
|
3150
2891
|
const { _inputNode } = getComboboxMembers(el);
|
|
3151
2892
|
|
|
3152
2893
|
/**
|
|
@@ -3169,12 +2910,10 @@ describe('lion-combobox', () => {
|
|
|
3169
2910
|
// Example 1. List Autocomplete with Manual Selection:
|
|
3170
2911
|
// does not set active at all until user selects
|
|
3171
2912
|
await setup(el, 'none');
|
|
3172
|
-
|
|
3173
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'cha');
|
|
2913
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'cha');
|
|
3174
2914
|
await el.updateComplete;
|
|
3175
2915
|
expect(el.activeIndex).to.equal(-1);
|
|
3176
2916
|
expect(el.opened).to.be.true;
|
|
3177
|
-
|
|
3178
2917
|
mimicKeyPress(_inputNode, 'Enter');
|
|
3179
2918
|
expect(el.opened).to.be.false;
|
|
3180
2919
|
expect(el.activeIndex).to.equal(-1);
|
|
@@ -3183,12 +2922,10 @@ describe('lion-combobox', () => {
|
|
|
3183
2922
|
// Example 2. List Autocomplete with Automatic Selection:
|
|
3184
2923
|
// does not set active at all until user selects
|
|
3185
2924
|
await setup(el, 'list');
|
|
3186
|
-
|
|
3187
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'cha');
|
|
2925
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'cha');
|
|
3188
2926
|
await el.updateComplete;
|
|
3189
2927
|
expect(el.opened).to.be.true;
|
|
3190
2928
|
expect(el.activeIndex).to.equal(-1);
|
|
3191
|
-
|
|
3192
2929
|
mimicKeyPress(_inputNode, 'Enter');
|
|
3193
2930
|
expect(el.activeIndex).to.equal(-1);
|
|
3194
2931
|
expect(el.opened).to.be.false;
|
|
@@ -3196,37 +2933,33 @@ describe('lion-combobox', () => {
|
|
|
3196
2933
|
// https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
|
|
3197
2934
|
// Example 3. List with Inline Autocomplete (mostly, but with aria-autocomplete="inline")
|
|
3198
2935
|
await setup(el, 'inline');
|
|
3199
|
-
|
|
3200
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), '');
|
|
2936
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, '');
|
|
3201
2937
|
await el.updateComplete;
|
|
3202
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
2938
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'cha');
|
|
3203
2939
|
await el.updateComplete;
|
|
3204
2940
|
await el.updateComplete;
|
|
3205
2941
|
expect(el.opened).to.be.true;
|
|
3206
|
-
|
|
3207
2942
|
expect(el.activeIndex).to.equal(1);
|
|
3208
|
-
|
|
3209
2943
|
mimicKeyPress(_inputNode, 'Enter');
|
|
3210
2944
|
await el.updateComplete;
|
|
3211
2945
|
await el.updateComplete;
|
|
3212
|
-
|
|
3213
2946
|
expect(el.activeIndex).to.equal(-1);
|
|
3214
2947
|
expect(el.opened).to.be.false;
|
|
3215
2948
|
|
|
3216
2949
|
// https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
|
|
3217
2950
|
// Example 3. List with Inline Autocomplete
|
|
3218
2951
|
await setup(el, 'both');
|
|
3219
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
2952
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, '');
|
|
3220
2953
|
await el.updateComplete;
|
|
3221
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
2954
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'cha');
|
|
3222
2955
|
await el.updateComplete;
|
|
3223
2956
|
mimicKeyPress(_inputNode, 'Enter');
|
|
3224
2957
|
expect(el.activeIndex).to.equal(1);
|
|
3225
2958
|
expect(el.opened).to.be.false;
|
|
3226
2959
|
});
|
|
3227
|
-
|
|
3228
2960
|
it('sets the active index to the closest match on autocomplete', async () => {
|
|
3229
|
-
const el =
|
|
2961
|
+
const el =
|
|
2962
|
+
/** @type {LionCombobox} */
|
|
3230
2963
|
await fixture(html`
|
|
3231
2964
|
<lion-combobox name="foo" autocomplete="both">
|
|
3232
2965
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3234,37 +2967,32 @@ describe('lion-combobox', () => {
|
|
|
3234
2967
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3235
2968
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3236
2969
|
</lion-combobox>
|
|
3237
|
-
`)
|
|
3238
|
-
);
|
|
2970
|
+
`);
|
|
3239
2971
|
const { _inputNode } = getComboboxMembers(el);
|
|
3240
|
-
|
|
3241
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'cha');
|
|
2972
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'cha');
|
|
3242
2973
|
await el.updateComplete;
|
|
3243
2974
|
expect(el.activeIndex).to.equal(1);
|
|
3244
|
-
|
|
3245
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'ch');
|
|
2975
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
3246
2976
|
await el.updateComplete;
|
|
3247
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
2977
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'chi');
|
|
3248
2978
|
// Chard no longer matches, so should switch active to Chicory
|
|
3249
2979
|
await el.updateComplete;
|
|
3250
|
-
|
|
3251
2980
|
expect(el.activeIndex).to.equal(2);
|
|
3252
2981
|
|
|
3253
2982
|
// select artichoke
|
|
3254
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
2983
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'artichoke');
|
|
3255
2984
|
await el.updateComplete;
|
|
3256
2985
|
mimicKeyPress(_inputNode, 'Enter');
|
|
3257
|
-
|
|
3258
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), '');
|
|
2986
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, '');
|
|
3259
2987
|
await el.updateComplete;
|
|
3260
2988
|
// change selection, active index should update to closest match
|
|
3261
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
2989
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'vic');
|
|
3262
2990
|
await el.updateComplete;
|
|
3263
2991
|
expect(el.activeIndex).to.equal(3);
|
|
3264
2992
|
});
|
|
3265
|
-
|
|
3266
2993
|
it('supports clearing by [Escape] key and resets active state on all options', async () => {
|
|
3267
|
-
const el =
|
|
2994
|
+
const el =
|
|
2995
|
+
/** @type {LionCombobox} */
|
|
3268
2996
|
await fixture(html`
|
|
3269
2997
|
<lion-combobox name="foo">
|
|
3270
2998
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3272,56 +3000,56 @@ describe('lion-combobox', () => {
|
|
|
3272
3000
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3273
3001
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3274
3002
|
</lion-combobox>
|
|
3275
|
-
`)
|
|
3276
|
-
);
|
|
3003
|
+
`);
|
|
3277
3004
|
const { _inputNode } = getComboboxMembers(el);
|
|
3278
3005
|
|
|
3279
3006
|
// Select something
|
|
3280
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3007
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'cha');
|
|
3281
3008
|
await el.updateComplete;
|
|
3282
3009
|
mimicKeyPress(_inputNode, 'Enter');
|
|
3283
3010
|
expect(el.activeIndex).to.equal(1);
|
|
3284
|
-
|
|
3285
3011
|
mimicKeyPress(_inputNode, 'Escape');
|
|
3286
3012
|
await el.updateComplete;
|
|
3287
3013
|
expect(_inputNode.textContent).to.equal('');
|
|
3288
|
-
|
|
3289
|
-
el.formElements.forEach(option => expect(option.active).to.be.false);
|
|
3014
|
+
el.formElements.forEach((option) => expect(option.active).to.be.false);
|
|
3290
3015
|
|
|
3291
3016
|
// change selection, active index should update to closest match
|
|
3292
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3017
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'vic');
|
|
3293
3018
|
await el.updateComplete;
|
|
3294
3019
|
expect(el.activeIndex).to.equal(3);
|
|
3295
3020
|
});
|
|
3296
3021
|
});
|
|
3297
|
-
|
|
3298
3022
|
describe('Accessibility', () => {
|
|
3299
3023
|
it('synchronizes autocomplete option to textbox', async () => {
|
|
3300
3024
|
let el;
|
|
3301
|
-
[el] = await fruitFixture({
|
|
3025
|
+
[el] = await fruitFixture({
|
|
3026
|
+
autocomplete: 'both',
|
|
3027
|
+
});
|
|
3302
3028
|
expect(
|
|
3303
|
-
getComboboxMembers(/** @type {LionCombobox} */
|
|
3029
|
+
getComboboxMembers(/** @type {LionCombobox} */ el)._inputNode.getAttribute(
|
|
3304
3030
|
'aria-autocomplete',
|
|
3305
3031
|
),
|
|
3306
3032
|
).to.equal('both');
|
|
3307
|
-
|
|
3308
|
-
|
|
3033
|
+
[el] = await fruitFixture({
|
|
3034
|
+
autocomplete: 'list',
|
|
3035
|
+
});
|
|
3309
3036
|
expect(
|
|
3310
|
-
getComboboxMembers(/** @type {LionCombobox} */
|
|
3037
|
+
getComboboxMembers(/** @type {LionCombobox} */ el)._inputNode.getAttribute(
|
|
3311
3038
|
'aria-autocomplete',
|
|
3312
3039
|
),
|
|
3313
3040
|
).to.equal('list');
|
|
3314
|
-
|
|
3315
|
-
|
|
3041
|
+
[el] = await fruitFixture({
|
|
3042
|
+
autocomplete: 'none',
|
|
3043
|
+
});
|
|
3316
3044
|
expect(
|
|
3317
|
-
getComboboxMembers(/** @type {LionCombobox} */
|
|
3045
|
+
getComboboxMembers(/** @type {LionCombobox} */ el)._inputNode.getAttribute(
|
|
3318
3046
|
'aria-autocomplete',
|
|
3319
3047
|
),
|
|
3320
3048
|
).to.equal('none');
|
|
3321
3049
|
});
|
|
3322
|
-
|
|
3323
3050
|
it('updates aria-activedescendant on textbox node', async () => {
|
|
3324
|
-
const el =
|
|
3051
|
+
const el =
|
|
3052
|
+
/** @type {LionCombobox} */
|
|
3325
3053
|
await fixture(html`
|
|
3326
3054
|
<lion-combobox name="foo" autocomplete="none">
|
|
3327
3055
|
<lion-option .choiceValue="${'Artichoke'}" id="artichoke-option"
|
|
@@ -3331,17 +3059,13 @@ describe('lion-combobox', () => {
|
|
|
3331
3059
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3332
3060
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3333
3061
|
</lion-combobox>
|
|
3334
|
-
`)
|
|
3335
|
-
);
|
|
3336
|
-
|
|
3062
|
+
`);
|
|
3337
3063
|
const elProts = getComboboxMembers(el);
|
|
3338
|
-
|
|
3339
3064
|
expect(elProts._activeDescendantOwnerNode.getAttribute('aria-activedescendant')).to.equal(
|
|
3340
3065
|
null,
|
|
3341
3066
|
);
|
|
3342
3067
|
expect(el.formElements[1].active).to.equal(false);
|
|
3343
|
-
|
|
3344
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'ch');
|
|
3068
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
3345
3069
|
await el.updateComplete;
|
|
3346
3070
|
expect(elProts._activeDescendantOwnerNode.getAttribute('aria-activedescendant')).to.equal(
|
|
3347
3071
|
null,
|
|
@@ -3352,8 +3076,8 @@ describe('lion-combobox', () => {
|
|
|
3352
3076
|
'artichoke-option',
|
|
3353
3077
|
);
|
|
3354
3078
|
expect(el.formElements[1].active).to.equal(false);
|
|
3355
|
-
|
|
3356
|
-
|
|
3079
|
+
const el2 =
|
|
3080
|
+
/** @type {LionCombobox} */
|
|
3357
3081
|
await fixture(html`
|
|
3358
3082
|
<lion-combobox name="foo" autocomplete="both" match-mode="begin">
|
|
3359
3083
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3361,39 +3085,37 @@ describe('lion-combobox', () => {
|
|
|
3361
3085
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3362
3086
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3363
3087
|
</lion-combobox>
|
|
3364
|
-
`)
|
|
3365
|
-
);
|
|
3366
|
-
|
|
3088
|
+
`);
|
|
3367
3089
|
const el2Prots = getComboboxMembers(el2);
|
|
3368
|
-
|
|
3369
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el2), 'ch');
|
|
3090
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el2, 'ch');
|
|
3370
3091
|
await el2.updateComplete;
|
|
3371
3092
|
expect(el2Prots._activeDescendantOwnerNode.getAttribute('aria-activedescendant')).to.equal(
|
|
3372
3093
|
el2.formElements[1].id,
|
|
3373
3094
|
);
|
|
3374
3095
|
expect(el2.formElements[1].active).to.equal(true);
|
|
3375
|
-
|
|
3376
3096
|
el2.autocomplete = 'list';
|
|
3377
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3097
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
3378
3098
|
await el2.updateComplete;
|
|
3379
3099
|
expect(el2Prots._activeDescendantOwnerNode.getAttribute('aria-activedescendant')).to.equal(
|
|
3380
3100
|
el2.formElements[1].id,
|
|
3381
3101
|
);
|
|
3382
3102
|
expect(el2.formElements[1].active).to.equal(true);
|
|
3383
3103
|
});
|
|
3384
|
-
|
|
3385
3104
|
it('adds aria-label to highlighted options', async () => {
|
|
3386
|
-
const [el, options] = await fruitFixture({
|
|
3387
|
-
|
|
3105
|
+
const [el, options] = await fruitFixture({
|
|
3106
|
+
autocomplete: 'both',
|
|
3107
|
+
matchMode: 'all',
|
|
3108
|
+
});
|
|
3109
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'choke');
|
|
3388
3110
|
await el.updateComplete;
|
|
3389
3111
|
// @ts-ignore [dynamic-key-access-in-test]
|
|
3390
3112
|
const labelledElement = options[0].querySelector('span[aria-label="Artichoke"]');
|
|
3391
3113
|
expect(labelledElement).to.not.be.null;
|
|
3392
3114
|
expect(labelledElement.innerText).to.equal('Artichoke');
|
|
3393
3115
|
});
|
|
3394
|
-
|
|
3395
3116
|
it('adds aria-label to highlighted complex options', async () => {
|
|
3396
|
-
const el =
|
|
3117
|
+
const el =
|
|
3118
|
+
/** @type {LionCombobox} */
|
|
3397
3119
|
await fixture(html`
|
|
3398
3120
|
<lion-combobox name="foo" match-mode="all">
|
|
3399
3121
|
<lion-option .choiceValue="${'Artichoke'}">
|
|
@@ -3401,11 +3123,9 @@ describe('lion-combobox', () => {
|
|
|
3401
3123
|
<small>Cardoon</small>
|
|
3402
3124
|
</lion-option>
|
|
3403
3125
|
</lion-combobox>
|
|
3404
|
-
`)
|
|
3405
|
-
);
|
|
3126
|
+
`);
|
|
3406
3127
|
const options = el.formElements;
|
|
3407
|
-
|
|
3408
|
-
await mimicUserTyping(/** @type {LionCombobox} */ (el), 'choke');
|
|
3128
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'choke');
|
|
3409
3129
|
await el.updateComplete;
|
|
3410
3130
|
const labelledElement = options[0].querySelector('span[aria-label=" Artichoke Cardoon "]');
|
|
3411
3131
|
expect(labelledElement).to.not.be.null;
|
|
@@ -3413,60 +3133,51 @@ describe('lion-combobox', () => {
|
|
|
3413
3133
|
});
|
|
3414
3134
|
});
|
|
3415
3135
|
});
|
|
3416
|
-
|
|
3417
3136
|
describe('Accessibility', () => {
|
|
3418
3137
|
describe('Aria versions', () => {
|
|
3419
3138
|
it('[role=combobox] wraps input node in v1.1', async () => {
|
|
3420
|
-
const el =
|
|
3139
|
+
const el =
|
|
3140
|
+
/** @type {LionCombobox} */
|
|
3421
3141
|
await fixture(html`
|
|
3422
3142
|
<lion-combobox name="foo" ._ariaVersion="${'1.1'}">
|
|
3423
3143
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
3424
3144
|
</lion-combobox>
|
|
3425
|
-
`)
|
|
3426
|
-
);
|
|
3145
|
+
`);
|
|
3427
3146
|
const { _comboboxNode, _inputNode } = getComboboxMembers(el);
|
|
3428
|
-
|
|
3429
3147
|
expect(_comboboxNode.contains(_inputNode)).to.be.true;
|
|
3430
3148
|
});
|
|
3431
|
-
|
|
3432
3149
|
it('has one input node with [role=combobox] in v1.0', async () => {
|
|
3433
|
-
const el =
|
|
3150
|
+
const el =
|
|
3151
|
+
/** @type {LionCombobox} */
|
|
3434
3152
|
await fixture(html`
|
|
3435
3153
|
<lion-combobox name="foo" ._ariaVersion="${'1.0'}">
|
|
3436
3154
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
3437
3155
|
</lion-combobox>
|
|
3438
|
-
`)
|
|
3439
|
-
);
|
|
3156
|
+
`);
|
|
3440
3157
|
const { _comboboxNode, _inputNode } = getComboboxMembers(el);
|
|
3441
|
-
|
|
3442
3158
|
expect(_comboboxNode).to.equal(_inputNode);
|
|
3443
3159
|
});
|
|
3444
|
-
|
|
3445
3160
|
it('autodetects aria version and sets it to 1.1 on Chromium browsers', async () => {
|
|
3446
3161
|
const browserDetectionIsChromiumOriginal = browserDetection.isChromium;
|
|
3447
|
-
|
|
3448
3162
|
browserDetection.isChromium = true;
|
|
3449
|
-
const el =
|
|
3163
|
+
const el =
|
|
3164
|
+
/** @type {LionCombobox} */
|
|
3450
3165
|
await fixture(html`
|
|
3451
3166
|
<lion-combobox name="foo">
|
|
3452
3167
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
3453
3168
|
</lion-combobox>
|
|
3454
|
-
`)
|
|
3455
|
-
);
|
|
3169
|
+
`);
|
|
3456
3170
|
const elProts = getComboboxMembers(el);
|
|
3457
|
-
|
|
3458
3171
|
expect(elProts._ariaVersion).to.equal('1.1');
|
|
3459
|
-
|
|
3460
3172
|
browserDetection.isChromium = false;
|
|
3461
|
-
const el2 =
|
|
3173
|
+
const el2 =
|
|
3174
|
+
/** @type {LionCombobox} */
|
|
3462
3175
|
await fixture(html`
|
|
3463
3176
|
<lion-combobox name="foo">
|
|
3464
3177
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
|
3465
3178
|
</lion-combobox>
|
|
3466
|
-
`)
|
|
3467
|
-
);
|
|
3179
|
+
`);
|
|
3468
3180
|
const el2Prots = getComboboxMembers(el2);
|
|
3469
|
-
|
|
3470
3181
|
expect(el2Prots._ariaVersion).to.equal('1.0');
|
|
3471
3182
|
|
|
3472
3183
|
// restore...
|
|
@@ -3474,11 +3185,11 @@ describe('lion-combobox', () => {
|
|
|
3474
3185
|
});
|
|
3475
3186
|
});
|
|
3476
3187
|
});
|
|
3477
|
-
|
|
3478
3188
|
describe('Multiple Choice', () => {
|
|
3479
3189
|
// TODO: possibly later share test with select-rich if it officially supports multipleChoice
|
|
3480
3190
|
it('does not close listbox on click', async () => {
|
|
3481
|
-
const el =
|
|
3191
|
+
const el =
|
|
3192
|
+
/** @type {LionCombobox} */
|
|
3482
3193
|
await fixture(html`
|
|
3483
3194
|
<lion-combobox name="foo" multiple-choice>
|
|
3484
3195
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3486,21 +3197,19 @@ describe('lion-combobox', () => {
|
|
|
3486
3197
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3487
3198
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3488
3199
|
</lion-combobox>
|
|
3489
|
-
`)
|
|
3490
|
-
);
|
|
3200
|
+
`);
|
|
3491
3201
|
|
|
3492
3202
|
// activate opened listbox
|
|
3493
3203
|
await mimicUserTyping(el, 'ch');
|
|
3494
3204
|
await el.updateComplete;
|
|
3495
|
-
|
|
3496
3205
|
expect(el.opened).to.equal(true);
|
|
3497
|
-
const visibleOptions = el.formElements.filter(o => o.style.display !== 'none');
|
|
3206
|
+
const visibleOptions = el.formElements.filter((o) => o.style.display !== 'none');
|
|
3498
3207
|
visibleOptions[0].click();
|
|
3499
3208
|
expect(el.opened).to.equal(true);
|
|
3500
3209
|
});
|
|
3501
|
-
|
|
3502
3210
|
it('does not close listbox on [Enter]', async () => {
|
|
3503
|
-
const el =
|
|
3211
|
+
const el =
|
|
3212
|
+
/** @type {LionCombobox} */
|
|
3504
3213
|
await fixture(html`
|
|
3505
3214
|
<lion-combobox name="foo" multiple-choice>
|
|
3506
3215
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3508,23 +3217,24 @@ describe('lion-combobox', () => {
|
|
|
3508
3217
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3509
3218
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3510
3219
|
</lion-combobox>
|
|
3511
|
-
`)
|
|
3512
|
-
);
|
|
3513
|
-
|
|
3220
|
+
`);
|
|
3514
3221
|
const { _inputNode } = getComboboxMembers(el);
|
|
3515
|
-
|
|
3516
3222
|
await mimicUserTyping(el, 'art');
|
|
3517
3223
|
await el.updateComplete;
|
|
3518
3224
|
expect(el.opened).to.equal(true);
|
|
3519
3225
|
|
|
3520
3226
|
// N.B. we do only trigger keydown here (and not mimicKeypress (both keyup and down)),
|
|
3521
3227
|
// because this closely mimics what happens in the browser
|
|
3522
|
-
_inputNode.dispatchEvent(
|
|
3228
|
+
_inputNode.dispatchEvent(
|
|
3229
|
+
new KeyboardEvent('keydown', {
|
|
3230
|
+
key: 'Enter',
|
|
3231
|
+
}),
|
|
3232
|
+
);
|
|
3523
3233
|
expect(el.opened).to.equal(true);
|
|
3524
3234
|
});
|
|
3525
|
-
|
|
3526
3235
|
it('clears textbox after selection of a new item on [enter]', async () => {
|
|
3527
|
-
const el =
|
|
3236
|
+
const el =
|
|
3237
|
+
/** @type {LionCombobox} */
|
|
3528
3238
|
await fixture(html`
|
|
3529
3239
|
<lion-combobox name="foo" multiple-choice>
|
|
3530
3240
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3532,29 +3242,29 @@ describe('lion-combobox', () => {
|
|
|
3532
3242
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3533
3243
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3534
3244
|
</lion-combobox>
|
|
3535
|
-
`)
|
|
3536
|
-
);
|
|
3537
|
-
|
|
3245
|
+
`);
|
|
3538
3246
|
const { _inputNode } = getComboboxMembers(el);
|
|
3539
3247
|
const options = el.formElements;
|
|
3540
|
-
|
|
3541
3248
|
await mimicUserTyping(el, 'art');
|
|
3542
3249
|
await el.updateComplete;
|
|
3543
|
-
|
|
3544
3250
|
expect(el.opened).to.equal(true);
|
|
3545
|
-
const visibleOptions = () => options.filter(o => o.style.display !== 'none');
|
|
3251
|
+
const visibleOptions = () => options.filter((o) => o.style.display !== 'none');
|
|
3546
3252
|
expect(visibleOptions().length).to.equal(1);
|
|
3547
3253
|
|
|
3548
3254
|
// N.B. we do only trigger keydown here (and not mimicKeypress (both keyup and down)),
|
|
3549
3255
|
// because this closely mimics what happens in the browser
|
|
3550
|
-
_inputNode.dispatchEvent(
|
|
3256
|
+
_inputNode.dispatchEvent(
|
|
3257
|
+
new KeyboardEvent('keydown', {
|
|
3258
|
+
key: 'Enter',
|
|
3259
|
+
}),
|
|
3260
|
+
);
|
|
3551
3261
|
expect(el.opened).to.equal(true);
|
|
3552
3262
|
expect(visibleOptions().length).to.equal(0);
|
|
3553
3263
|
expect(_inputNode.value).to.equal('');
|
|
3554
3264
|
});
|
|
3555
|
-
|
|
3556
3265
|
it('clears textbox after selection of a new item on click', async () => {
|
|
3557
|
-
const el =
|
|
3266
|
+
const el =
|
|
3267
|
+
/** @type {LionCombobox} */
|
|
3558
3268
|
await fixture(html`
|
|
3559
3269
|
<lion-combobox name="foo" multiple-choice>
|
|
3560
3270
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
@@ -3562,28 +3272,23 @@ describe('lion-combobox', () => {
|
|
|
3562
3272
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
3563
3273
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
3564
3274
|
</lion-combobox>
|
|
3565
|
-
`)
|
|
3566
|
-
);
|
|
3567
|
-
|
|
3275
|
+
`);
|
|
3568
3276
|
const { _inputNode } = getComboboxMembers(el);
|
|
3569
3277
|
const options = el.formElements;
|
|
3570
|
-
|
|
3571
3278
|
await mimicUserTyping(el, 'art');
|
|
3572
3279
|
await el.updateComplete;
|
|
3573
|
-
|
|
3574
3280
|
expect(el.opened).to.equal(true);
|
|
3575
|
-
const visibleOptions = () => options.filter(o => o.style.display !== 'none');
|
|
3281
|
+
const visibleOptions = () => options.filter((o) => o.style.display !== 'none');
|
|
3576
3282
|
expect(visibleOptions().length).to.equal(1);
|
|
3577
|
-
|
|
3578
3283
|
visibleOptions()[0].click();
|
|
3579
3284
|
expect(el.opened).to.equal(true);
|
|
3580
3285
|
expect(visibleOptions().length).to.equal(0);
|
|
3581
3286
|
expect(_inputNode.value).to.equal('');
|
|
3582
3287
|
});
|
|
3583
|
-
|
|
3584
3288
|
it('submits form on [Enter] when listbox is closed', async () => {
|
|
3585
|
-
const submitSpy = sinon.spy(e => e.preventDefault());
|
|
3586
|
-
const el =
|
|
3289
|
+
const submitSpy = sinon.spy((e) => e.preventDefault());
|
|
3290
|
+
const el =
|
|
3291
|
+
/** @type {HTMLFormElement} */
|
|
3587
3292
|
await fixture(html`
|
|
3588
3293
|
<form @submit=${submitSpy}>
|
|
3589
3294
|
<lion-combobox name="foo" multiple-choice>
|
|
@@ -3594,9 +3299,8 @@ describe('lion-combobox', () => {
|
|
|
3594
3299
|
</lion-combobox>
|
|
3595
3300
|
<button type="submit">submit</button>
|
|
3596
3301
|
</form>
|
|
3597
|
-
`)
|
|
3598
|
-
);
|
|
3599
|
-
const combobox = /** @type {LionCombobox} */ (el.querySelector('[name="foo"]'));
|
|
3302
|
+
`);
|
|
3303
|
+
const combobox = /** @type {LionCombobox} */ el.querySelector('[name="foo"]');
|
|
3600
3304
|
const { _inputNode } = getComboboxMembers(combobox);
|
|
3601
3305
|
await combobox.updateComplete;
|
|
3602
3306
|
_inputNode.focus();
|
|
@@ -3605,10 +3309,10 @@ describe('lion-combobox', () => {
|
|
|
3605
3309
|
});
|
|
3606
3310
|
expect(submitSpy.callCount).to.equal(1);
|
|
3607
3311
|
});
|
|
3608
|
-
|
|
3609
3312
|
it('does not submit form on [Enter] when listbox is opened', async () => {
|
|
3610
|
-
const submitSpy = sinon.spy(e => e.preventDefault());
|
|
3611
|
-
const el =
|
|
3313
|
+
const submitSpy = sinon.spy((e) => e.preventDefault());
|
|
3314
|
+
const el =
|
|
3315
|
+
/** @type {HTMLFormElement} */
|
|
3612
3316
|
await fixture(html`
|
|
3613
3317
|
<form @submit=${submitSpy}>
|
|
3614
3318
|
<lion-combobox name="foo" multiple-choice>
|
|
@@ -3619,9 +3323,8 @@ describe('lion-combobox', () => {
|
|
|
3619
3323
|
</lion-combobox>
|
|
3620
3324
|
<button type="submit">submit</button>
|
|
3621
3325
|
</form>
|
|
3622
|
-
`)
|
|
3623
|
-
);
|
|
3624
|
-
const combobox = /** @type {LionCombobox} */ (el.querySelector('[name="foo"]'));
|
|
3326
|
+
`);
|
|
3327
|
+
const combobox = /** @type {LionCombobox} */ el.querySelector('[name="foo"]');
|
|
3625
3328
|
const { _inputNode } = getComboboxMembers(combobox);
|
|
3626
3329
|
combobox.opened = true;
|
|
3627
3330
|
await combobox.updateComplete;
|
|
@@ -3632,35 +3335,30 @@ describe('lion-combobox', () => {
|
|
|
3632
3335
|
expect(submitSpy.callCount).to.equal(0);
|
|
3633
3336
|
});
|
|
3634
3337
|
});
|
|
3635
|
-
|
|
3636
3338
|
describe('Match Mode', () => {
|
|
3637
3339
|
it('has a default value of "all"', async () => {
|
|
3638
3340
|
const [el] = await fruitFixture();
|
|
3639
3341
|
expect(el.matchMode).to.equal('all');
|
|
3640
3342
|
});
|
|
3641
|
-
|
|
3642
3343
|
it('will suggest partial matches (in the middle of the word) when set to "all"', async () => {
|
|
3643
3344
|
const [el] = await fruitFixture();
|
|
3644
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3345
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'c');
|
|
3645
3346
|
await el.updateComplete;
|
|
3646
|
-
expect(getFilteredOptionValues(/** @type {LionCombobox} */
|
|
3347
|
+
expect(getFilteredOptionValues(/** @type {LionCombobox} */ el)).to.eql([
|
|
3647
3348
|
'Artichoke',
|
|
3648
3349
|
'Chard',
|
|
3649
3350
|
'Chicory',
|
|
3650
3351
|
'Victoria Plum',
|
|
3651
3352
|
]);
|
|
3652
3353
|
});
|
|
3653
|
-
|
|
3654
3354
|
it('will only suggest beginning matches when set to "begin"', async () => {
|
|
3655
|
-
const [el] = await fruitFixture({
|
|
3656
|
-
|
|
3355
|
+
const [el] = await fruitFixture({
|
|
3356
|
+
matchMode: 'begin',
|
|
3357
|
+
});
|
|
3358
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
3657
3359
|
await el.updateComplete;
|
|
3658
|
-
expect(getFilteredOptionValues(/** @type {LionCombobox} */
|
|
3659
|
-
'Chard',
|
|
3660
|
-
'Chicory',
|
|
3661
|
-
]);
|
|
3360
|
+
expect(getFilteredOptionValues(/** @type {LionCombobox} */ el)).to.eql(['Chard', 'Chicory']);
|
|
3662
3361
|
});
|
|
3663
|
-
|
|
3664
3362
|
describe('Subclassers', () => {
|
|
3665
3363
|
it('allows for custom matching functions', async () => {
|
|
3666
3364
|
const [el] = await fruitFixture();
|
|
@@ -3672,65 +3370,71 @@ describe('lion-combobox', () => {
|
|
|
3672
3370
|
return option.value === curValue;
|
|
3673
3371
|
}
|
|
3674
3372
|
el.matchCondition = onlyExactMatches;
|
|
3675
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3373
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'Chicory');
|
|
3676
3374
|
await el.updateComplete;
|
|
3677
|
-
expect(getFilteredOptionValues(/** @type {LionCombobox} */
|
|
3678
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3375
|
+
expect(getFilteredOptionValues(/** @type {LionCombobox} */ el)).to.eql(['Chicory']);
|
|
3376
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'Chicor');
|
|
3679
3377
|
await el.updateComplete;
|
|
3680
|
-
expect(getFilteredOptionValues(/** @type {LionCombobox} */
|
|
3378
|
+
expect(getFilteredOptionValues(/** @type {LionCombobox} */ el)).to.eql([]);
|
|
3681
3379
|
});
|
|
3682
3380
|
});
|
|
3683
3381
|
});
|
|
3684
|
-
|
|
3685
3382
|
describe('Disabled state', () => {
|
|
3686
3383
|
it('does not open overlay or allow input when disabled', async () => {
|
|
3687
|
-
const [el] = await fruitFixture({
|
|
3384
|
+
const [el] = await fruitFixture({
|
|
3385
|
+
disabled: true,
|
|
3386
|
+
});
|
|
3688
3387
|
expect(el.disabled).to.equal(true);
|
|
3689
|
-
|
|
3690
|
-
const { _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ (el));
|
|
3691
|
-
|
|
3388
|
+
const { _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ el);
|
|
3692
3389
|
expect(el.disabled).to.be.true;
|
|
3693
3390
|
expect(_inputNode.disabled).to.be.true;
|
|
3694
3391
|
|
|
3695
3392
|
// Try to open overlay by clicking input
|
|
3696
|
-
_inputNode.dispatchEvent(
|
|
3393
|
+
_inputNode.dispatchEvent(
|
|
3394
|
+
new Event('click', {
|
|
3395
|
+
bubbles: true,
|
|
3396
|
+
composed: true,
|
|
3397
|
+
}),
|
|
3398
|
+
);
|
|
3697
3399
|
await el.updateComplete;
|
|
3698
3400
|
expect(el.opened).to.be.false;
|
|
3699
3401
|
});
|
|
3700
|
-
|
|
3701
3402
|
it('does open overlay or allow input when disabled state is removed after it was previously disabled', async () => {
|
|
3702
|
-
const [el] = await fruitFixture({
|
|
3403
|
+
const [el] = await fruitFixture({
|
|
3404
|
+
disabled: true,
|
|
3405
|
+
});
|
|
3703
3406
|
expect(el.disabled).to.equal(true);
|
|
3704
|
-
|
|
3705
|
-
const { _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ (el));
|
|
3706
|
-
|
|
3407
|
+
const { _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ el);
|
|
3707
3408
|
expect(el.disabled).to.be.true;
|
|
3708
3409
|
expect(_inputNode.disabled).to.be.true;
|
|
3709
3410
|
|
|
3710
3411
|
// Try to open overlay by clicking input
|
|
3711
|
-
_inputNode.dispatchEvent(
|
|
3412
|
+
_inputNode.dispatchEvent(
|
|
3413
|
+
new Event('click', {
|
|
3414
|
+
bubbles: true,
|
|
3415
|
+
composed: true,
|
|
3416
|
+
}),
|
|
3417
|
+
);
|
|
3712
3418
|
await el.updateComplete;
|
|
3713
3419
|
expect(el.opened).to.be.false;
|
|
3714
|
-
|
|
3715
3420
|
el.disabled = false;
|
|
3716
3421
|
await el.updateComplete;
|
|
3717
|
-
|
|
3718
3422
|
expect(el.disabled).to.be.false;
|
|
3719
3423
|
expect(_inputNode.disabled).to.be.false;
|
|
3720
3424
|
|
|
3721
3425
|
// Try to open overlay by clicking input
|
|
3722
3426
|
async function open() {
|
|
3723
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3427
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
3724
3428
|
return el.updateComplete;
|
|
3725
3429
|
}
|
|
3726
|
-
|
|
3727
3430
|
await open();
|
|
3728
3431
|
expect(el.opened).to.be.true;
|
|
3729
3432
|
});
|
|
3730
|
-
|
|
3731
3433
|
it('sets aria-disabled and disables focus when combobox is disabled', async () => {
|
|
3732
|
-
const [el] = await fruitFixture({
|
|
3733
|
-
|
|
3434
|
+
const [el] = await fruitFixture({
|
|
3435
|
+
disabled: true,
|
|
3436
|
+
});
|
|
3437
|
+
const { _comboboxNode, _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ el);
|
|
3734
3438
|
|
|
3735
3439
|
// input should not be focusable
|
|
3736
3440
|
expect(_comboboxNode.tabIndex).to.equal(-1);
|
|
@@ -3741,13 +3445,13 @@ describe('lion-combobox', () => {
|
|
|
3741
3445
|
|
|
3742
3446
|
// aria-disabled should be set
|
|
3743
3447
|
expect(_inputNode.getAttribute('aria-disabled')).to.equal('true');
|
|
3744
|
-
|
|
3745
3448
|
await expect(el).to.be.accessible();
|
|
3746
3449
|
});
|
|
3747
|
-
|
|
3748
3450
|
it('ensure focus when combobox is readonly', async () => {
|
|
3749
|
-
const [el] = await fruitFixture({
|
|
3750
|
-
|
|
3451
|
+
const [el] = await fruitFixture({
|
|
3452
|
+
readonly: true,
|
|
3453
|
+
});
|
|
3454
|
+
const { _comboboxNode, _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ el);
|
|
3751
3455
|
|
|
3752
3456
|
// input should be focusable
|
|
3753
3457
|
expect(_inputNode.tabIndex).to.equal(0);
|
|
@@ -3757,61 +3461,65 @@ describe('lion-combobox', () => {
|
|
|
3757
3461
|
|
|
3758
3462
|
// aria-disabled should be set
|
|
3759
3463
|
expect(_inputNode.getAttribute('aria-readonly')).to.equal('true');
|
|
3760
|
-
|
|
3761
3464
|
await expect(el).to.be.accessible();
|
|
3762
3465
|
});
|
|
3763
3466
|
});
|
|
3764
|
-
|
|
3765
3467
|
describe('Readonly state', () => {
|
|
3766
3468
|
it('does not open overlay or allow input when readonly', async () => {
|
|
3767
|
-
const [el] = await fruitFixture({
|
|
3768
|
-
|
|
3769
|
-
|
|
3469
|
+
const [el] = await fruitFixture({
|
|
3470
|
+
readonly: true,
|
|
3471
|
+
});
|
|
3472
|
+
const { _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ el);
|
|
3770
3473
|
expect(el.readOnly).to.equal(true);
|
|
3771
|
-
|
|
3772
3474
|
expect(el.readOnly).to.be.true;
|
|
3773
3475
|
expect(_inputNode.readOnly).to.be.true;
|
|
3774
3476
|
|
|
3775
3477
|
// Try to open overlay by clicking input
|
|
3776
|
-
_inputNode.dispatchEvent(
|
|
3478
|
+
_inputNode.dispatchEvent(
|
|
3479
|
+
new Event('click', {
|
|
3480
|
+
bubbles: true,
|
|
3481
|
+
composed: true,
|
|
3482
|
+
}),
|
|
3483
|
+
);
|
|
3777
3484
|
await el.updateComplete;
|
|
3778
3485
|
expect(el.opened).to.be.false;
|
|
3779
3486
|
});
|
|
3780
|
-
|
|
3781
3487
|
it('does open overlay or allow input when readonly state is removed after it was previously set', async () => {
|
|
3782
|
-
const [el] = await fruitFixture({
|
|
3488
|
+
const [el] = await fruitFixture({
|
|
3489
|
+
readonly: true,
|
|
3490
|
+
});
|
|
3783
3491
|
expect(el.readOnly).to.equal(true);
|
|
3784
|
-
|
|
3785
|
-
const { _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ (el));
|
|
3786
|
-
|
|
3492
|
+
const { _inputNode } = getComboboxMembers(/** @type {LionCombobox} */ el);
|
|
3787
3493
|
expect(el.readOnly).to.be.true;
|
|
3788
3494
|
expect(_inputNode.readOnly).to.be.true;
|
|
3789
3495
|
|
|
3790
3496
|
// Try to open overlay by clicking input
|
|
3791
|
-
_inputNode.dispatchEvent(
|
|
3497
|
+
_inputNode.dispatchEvent(
|
|
3498
|
+
new Event('click', {
|
|
3499
|
+
bubbles: true,
|
|
3500
|
+
composed: true,
|
|
3501
|
+
}),
|
|
3502
|
+
);
|
|
3792
3503
|
await el.updateComplete;
|
|
3793
3504
|
expect(el.opened).to.be.false;
|
|
3794
|
-
|
|
3795
3505
|
el.readOnly = false;
|
|
3796
3506
|
await el.updateComplete;
|
|
3797
|
-
|
|
3798
3507
|
expect(el.readOnly).to.be.false;
|
|
3799
3508
|
expect(_inputNode.readOnly).to.be.false;
|
|
3800
3509
|
|
|
3801
3510
|
// Try to open overlay by clicking input
|
|
3802
3511
|
async function open() {
|
|
3803
|
-
await mimicUserTyping(/** @type {LionCombobox} */
|
|
3512
|
+
await mimicUserTyping(/** @type {LionCombobox} */ el, 'ch');
|
|
3804
3513
|
return el.updateComplete;
|
|
3805
3514
|
}
|
|
3806
|
-
|
|
3807
3515
|
await open();
|
|
3808
3516
|
expect(el.opened).to.be.true;
|
|
3809
3517
|
});
|
|
3810
3518
|
});
|
|
3811
|
-
|
|
3812
3519
|
describe('Special Characters in Search', () => {
|
|
3813
3520
|
it('correctly escapes all regex special characters in search queries', async () => {
|
|
3814
|
-
const el =
|
|
3521
|
+
const el =
|
|
3522
|
+
/** @type {LionCombobox} */
|
|
3815
3523
|
await fixture(html`
|
|
3816
3524
|
<lion-combobox label="Search" name="foo">
|
|
3817
3525
|
<lion-option .choiceValue="${'test.com'}">test.com</lion-option>
|
|
@@ -3833,8 +3541,7 @@ describe('lion-combobox', () => {
|
|
|
3833
3541
|
<lion-option .choiceValue="${'funcXargX'}">funcXargX</lion-option>
|
|
3834
3542
|
<lion-option .choiceValue="${'arrayX0X'}">arrayX0X</lion-option>
|
|
3835
3543
|
</lion-combobox>
|
|
3836
|
-
`)
|
|
3837
|
-
);
|
|
3544
|
+
`);
|
|
3838
3545
|
|
|
3839
3546
|
// Test dot - should not act as wildcard
|
|
3840
3547
|
await mimicUserTyping(el, 'test.com');
|