@lion/ui 0.23.0 → 0.24.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 +40 -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 +7 -6
- 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 +4 -1
- 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 +166 -151
- package/components/overlays/src/OverlayMixin.js +61 -63
- 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 +375 -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/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 +20 -43
- 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 +191 -56
- 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/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/OverlaysManager.d.ts.map +1 -1
- package/dist-types/components/overlays/src/overlayDocumentStyle.d.ts.map +1 -1
- 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 +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/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/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/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/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 +32 -10
- 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
|
@@ -2,7 +2,6 @@ import { LitElement } from 'lit';
|
|
|
2
2
|
import { IsNumber, Required, LionField, Validator, FormGroupMixin } from '@lion/ui/form-core.js';
|
|
3
3
|
import '@lion/ui/define/lion-field.js';
|
|
4
4
|
import '@lion/ui/define/lion-validation-feedback.js';
|
|
5
|
-
|
|
6
5
|
import { localizeTearDown } from '@lion/ui/localize-test-helpers.js';
|
|
7
6
|
import {
|
|
8
7
|
aTimeout,
|
|
@@ -29,9 +28,7 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
const childTagString = cfg.childTagString || defineCE(FormChild);
|
|
34
|
-
|
|
35
32
|
class FormGroup extends FormGroupMixin(LitElement) {
|
|
36
33
|
constructor() {
|
|
37
34
|
super();
|
|
@@ -41,7 +38,6 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
41
38
|
this._repropagationRole = 'fieldset'; // configures FormControlMixin
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
const tagString = cfg.tagString || defineCE(FormGroup);
|
|
46
42
|
const tag = unsafeStatic(tagString);
|
|
47
43
|
const childTag = unsafeStatic(childTagString);
|
|
@@ -52,47 +48,42 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
52
48
|
<${childTag} name="hobbies[]"></${childTag}>
|
|
53
49
|
<${childTag} name="hobbies[]"></${childTag}>
|
|
54
50
|
`;
|
|
55
|
-
|
|
56
51
|
beforeEach(() => {
|
|
57
52
|
localizeTearDown();
|
|
58
53
|
});
|
|
59
|
-
|
|
60
54
|
describe('FormGroupMixin', () => {
|
|
61
55
|
// TODO: Tests below belong to FormControlMixin. Preferably run suite integration test
|
|
62
56
|
it(`has a fieldName based on the label`, async () => {
|
|
63
|
-
const el1 =
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
const el1 =
|
|
58
|
+
/** @type {FormGroup} */
|
|
59
|
+
await fixture(html`<${tag} label="foo">${inputSlots}</${tag}>`);
|
|
66
60
|
const { _labelNode: _labelNode1 } = getFormControlMembers(el1);
|
|
67
61
|
expect(el1.fieldName).to.equal(_labelNode1.textContent);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
await fixture(html`<${tag}><label slot="label">bar</label>${inputSlots}</${tag}>`)
|
|
71
|
-
);
|
|
62
|
+
const el2 =
|
|
63
|
+
/** @type {FormGroup} */
|
|
64
|
+
await fixture(html`<${tag}><label slot="label">bar</label>${inputSlots}</${tag}>`);
|
|
72
65
|
const { _labelNode: _labelNode2 } = getFormControlMembers(el2);
|
|
73
66
|
expect(el2.fieldName).to.equal(_labelNode2.textContent);
|
|
74
67
|
});
|
|
75
|
-
|
|
76
68
|
it(`has a fieldName based on the name if no label exists`, async () => {
|
|
77
|
-
const el =
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
const el =
|
|
70
|
+
/** @type {FormGroup} */
|
|
71
|
+
await fixture(html`<${tag} name="foo">${inputSlots}</${tag}>`);
|
|
80
72
|
expect(el.fieldName).to.equal(el.name);
|
|
81
73
|
});
|
|
82
|
-
|
|
83
74
|
it(`can override fieldName`, async () => {
|
|
84
|
-
const el =
|
|
75
|
+
const el =
|
|
76
|
+
/** @type {FormGroup} */
|
|
85
77
|
await fixture(html`
|
|
86
78
|
<${tag} label="foo" .fieldName="${'bar'}">${inputSlots}</${tag}>
|
|
87
|
-
`)
|
|
88
|
-
);
|
|
79
|
+
`);
|
|
89
80
|
// @ts-ignore [allow-protected] in test
|
|
90
81
|
expect(el.__fieldName).to.equal(el.fieldName);
|
|
91
82
|
});
|
|
92
83
|
|
|
93
84
|
// TODO: Tests below belong to FormRegistrarMixin. Preferably run suite integration test
|
|
94
85
|
it(`${tagString} has an up to date list of every form element in .formElements`, async () => {
|
|
95
|
-
const el = /** @type {FormGroup} */
|
|
86
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
96
87
|
// @ts-ignore [allow-protected] in test
|
|
97
88
|
expect(el.formElements._keys().length).to.equal(3);
|
|
98
89
|
expect(el.formElements['hobbies[]'].length).to.equal(2);
|
|
@@ -101,27 +92,33 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
101
92
|
expect(el.formElements._keys().length).to.equal(3);
|
|
102
93
|
expect(el.formElements['hobbies[]'].length).to.equal(1);
|
|
103
94
|
});
|
|
104
|
-
|
|
105
95
|
it(`supports in html wrapped form elements`, async () => {
|
|
106
|
-
const el =
|
|
96
|
+
const el =
|
|
97
|
+
/** @type {FormGroup} */
|
|
107
98
|
await fixture(html`
|
|
108
99
|
<${tag}>
|
|
109
100
|
<div>
|
|
110
101
|
<${childTag} name="foo"></${childTag}>
|
|
111
102
|
</div>
|
|
112
103
|
</${tag}>
|
|
113
|
-
`)
|
|
114
|
-
);
|
|
104
|
+
`);
|
|
115
105
|
expect(el.formElements.length).to.equal(1);
|
|
116
106
|
el.children[0].removeChild(el.formElements.foo);
|
|
117
107
|
expect(el.formElements.length).to.equal(0);
|
|
118
108
|
});
|
|
119
|
-
|
|
120
109
|
it('handles names with ending [] as an array', async () => {
|
|
121
|
-
const el = /** @type {FormGroup} */
|
|
122
|
-
el.formElements['gender[]'][0].modelValue = {
|
|
123
|
-
|
|
124
|
-
|
|
110
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
111
|
+
el.formElements['gender[]'][0].modelValue = {
|
|
112
|
+
value: 'male',
|
|
113
|
+
};
|
|
114
|
+
el.formElements['hobbies[]'][0].modelValue = {
|
|
115
|
+
checked: false,
|
|
116
|
+
value: 'chess',
|
|
117
|
+
};
|
|
118
|
+
el.formElements['hobbies[]'][1].modelValue = {
|
|
119
|
+
checked: false,
|
|
120
|
+
value: 'rugby',
|
|
121
|
+
};
|
|
125
122
|
|
|
126
123
|
// @ts-ignore
|
|
127
124
|
expect(el.formElements._keys().length).to.equal(3);
|
|
@@ -129,81 +126,79 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
129
126
|
expect(el.formElements['hobbies[]'][0].modelValue.value).to.equal('chess');
|
|
130
127
|
expect(el.formElements['gender[]'][0].modelValue.value).to.equal('male');
|
|
131
128
|
expect(el.modelValue['hobbies[]']).to.deep.equal([
|
|
132
|
-
{
|
|
133
|
-
|
|
129
|
+
{
|
|
130
|
+
checked: false,
|
|
131
|
+
value: 'chess',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
checked: false,
|
|
135
|
+
value: 'rugby',
|
|
136
|
+
},
|
|
134
137
|
]);
|
|
135
138
|
});
|
|
136
|
-
|
|
137
139
|
it('throws if name is the same as its parent', async () => {
|
|
138
140
|
const orig = console.info;
|
|
139
141
|
console.info = () => {};
|
|
140
|
-
|
|
141
142
|
let error;
|
|
142
|
-
const el = /** @type {FormGroup} */
|
|
143
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag} name="foo"></${tag}>`);
|
|
143
144
|
try {
|
|
144
145
|
// we test the api directly as errors thrown from a web component are in a
|
|
145
146
|
// different context and we can not catch them here => register fake elements
|
|
146
147
|
el.addFormElement(
|
|
147
|
-
/** @type {HTMLElement & import('../../types/FormControlMixinTypes.js').FormControlHost} */
|
|
148
|
+
/** @type {HTMLElement & import('../../types/FormControlMixinTypes.js').FormControlHost} */ {
|
|
148
149
|
name: 'foo',
|
|
149
|
-
}
|
|
150
|
+
},
|
|
150
151
|
);
|
|
151
152
|
} catch (err) {
|
|
152
153
|
error = err;
|
|
153
154
|
}
|
|
154
155
|
expect(error).to.be.instanceOf(TypeError);
|
|
155
|
-
expect(/** @type {TypeError} */
|
|
156
|
+
expect(/** @type {TypeError} */ error.message).to.equal(
|
|
156
157
|
'You can not have the same name "foo" as your parent',
|
|
157
158
|
);
|
|
158
|
-
|
|
159
159
|
console.info = orig; // restore original console
|
|
160
160
|
});
|
|
161
|
-
|
|
162
161
|
it('throws if same name without ending [] is used', async () => {
|
|
163
162
|
const orig = console.info;
|
|
164
163
|
console.info = () => {};
|
|
165
|
-
|
|
166
164
|
let error;
|
|
167
|
-
const el = /** @type {FormGroup} */
|
|
165
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag}></${tag}>`);
|
|
168
166
|
try {
|
|
169
167
|
// we test the api directly as errors thrown from a web component are in a
|
|
170
168
|
// different context and we can not catch them here => register fake elements
|
|
171
169
|
el.addFormElement(
|
|
172
|
-
/** @type {HTMLElement & import('../../types/FormControlMixinTypes.js').FormControlHost} */
|
|
170
|
+
/** @type {HTMLElement & import('../../types/FormControlMixinTypes.js').FormControlHost} */ {
|
|
173
171
|
name: 'fooBar',
|
|
174
|
-
}
|
|
172
|
+
},
|
|
175
173
|
);
|
|
176
174
|
el.addFormElement(
|
|
177
|
-
/** @type {HTMLElement & import('../../types/FormControlMixinTypes.js').FormControlHost} */
|
|
175
|
+
/** @type {HTMLElement & import('../../types/FormControlMixinTypes.js').FormControlHost} */ {
|
|
178
176
|
name: 'fooBar',
|
|
179
|
-
}
|
|
177
|
+
},
|
|
180
178
|
);
|
|
181
179
|
} catch (err) {
|
|
182
180
|
error = err;
|
|
183
181
|
}
|
|
184
182
|
expect(error).to.be.instanceOf(TypeError);
|
|
185
|
-
expect(/** @type {TypeError} */
|
|
183
|
+
expect(/** @type {TypeError} */ error.message).to.equal(
|
|
186
184
|
'Name "fooBar" is already registered - if you want an array add [] to the end',
|
|
187
185
|
);
|
|
188
|
-
|
|
189
186
|
console.info = orig; // restore original console
|
|
190
187
|
});
|
|
191
188
|
/* eslint-enable no-console */
|
|
192
189
|
|
|
193
190
|
it('can dynamically add/remove elements', async () => {
|
|
194
|
-
const el = /** @type {FormGroup} */
|
|
195
|
-
const newField =
|
|
196
|
-
|
|
197
|
-
|
|
191
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
192
|
+
const newField =
|
|
193
|
+
/** @type {FormGroup} */
|
|
194
|
+
await fixture(html`<${childTag} name="lastName"></${childTag}>`);
|
|
198
195
|
const { _inputNode } = getFormControlMembers(el);
|
|
199
196
|
|
|
200
197
|
// @ts-ignore [allow-protected] in test
|
|
201
198
|
expect(el.formElements._keys().length).to.equal(3);
|
|
202
|
-
|
|
203
199
|
el.appendChild(newField);
|
|
204
200
|
// @ts-ignore [allow-protected] in test
|
|
205
201
|
expect(el.formElements._keys().length).to.equal(4);
|
|
206
|
-
|
|
207
202
|
_inputNode.removeChild(newField);
|
|
208
203
|
// @ts-ignore [allow-protected] in test
|
|
209
204
|
expect(el.formElements._keys().length).to.equal(3);
|
|
@@ -212,34 +207,63 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
212
207
|
// TODO: Tests below belong to FormGroupMixin. Preferably run suite integration test
|
|
213
208
|
|
|
214
209
|
it('can read/write all values (of every input) via this.modelValue', async () => {
|
|
215
|
-
const el =
|
|
210
|
+
const el =
|
|
211
|
+
/** @type {FormGroup} */
|
|
216
212
|
await fixture(html`
|
|
217
213
|
<${tag}>
|
|
218
214
|
<${childTag} name="lastName"></${childTag}>
|
|
219
215
|
<${tag} name="newfieldset">${inputSlots}</${tag}>
|
|
220
216
|
</${tag}>
|
|
221
|
-
`)
|
|
222
|
-
);
|
|
223
|
-
const newFieldset = /** @type {FormGroup} */ (el.querySelector(tagString));
|
|
217
|
+
`);
|
|
218
|
+
const newFieldset = /** @type {FormGroup} */ el.querySelector(tagString);
|
|
224
219
|
el.formElements.lastName.modelValue = 'Bar';
|
|
225
|
-
newFieldset.formElements['hobbies[]'][0].modelValue = {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
newFieldset.formElements.
|
|
230
|
-
|
|
220
|
+
newFieldset.formElements['hobbies[]'][0].modelValue = {
|
|
221
|
+
checked: true,
|
|
222
|
+
value: 'chess',
|
|
223
|
+
};
|
|
224
|
+
newFieldset.formElements['hobbies[]'][1].modelValue = {
|
|
225
|
+
checked: false,
|
|
226
|
+
value: 'football',
|
|
227
|
+
};
|
|
228
|
+
newFieldset.formElements['gender[]'][0].modelValue = {
|
|
229
|
+
checked: false,
|
|
230
|
+
value: 'male',
|
|
231
|
+
};
|
|
232
|
+
newFieldset.formElements['gender[]'][1].modelValue = {
|
|
233
|
+
checked: false,
|
|
234
|
+
value: 'female',
|
|
235
|
+
};
|
|
236
|
+
newFieldset.formElements.color.modelValue = {
|
|
237
|
+
checked: false,
|
|
238
|
+
value: 'blue',
|
|
239
|
+
};
|
|
231
240
|
expect(el.modelValue).to.deep.equal({
|
|
232
241
|
lastName: 'Bar',
|
|
233
242
|
newfieldset: {
|
|
234
243
|
'hobbies[]': [
|
|
235
|
-
{
|
|
236
|
-
|
|
244
|
+
{
|
|
245
|
+
checked: true,
|
|
246
|
+
value: 'chess',
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
checked: false,
|
|
250
|
+
value: 'football',
|
|
251
|
+
},
|
|
237
252
|
],
|
|
238
253
|
'gender[]': [
|
|
239
|
-
{
|
|
240
|
-
|
|
254
|
+
{
|
|
255
|
+
checked: false,
|
|
256
|
+
value: 'male',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
checked: false,
|
|
260
|
+
value: 'female',
|
|
261
|
+
},
|
|
241
262
|
],
|
|
242
|
-
color: {
|
|
263
|
+
color: {
|
|
264
|
+
checked: false,
|
|
265
|
+
value: 'blue',
|
|
266
|
+
},
|
|
243
267
|
},
|
|
244
268
|
});
|
|
245
269
|
|
|
@@ -249,17 +273,31 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
249
273
|
lastName: 2,
|
|
250
274
|
newfieldset: {
|
|
251
275
|
'hobbies[]': [
|
|
252
|
-
{
|
|
253
|
-
|
|
276
|
+
{
|
|
277
|
+
checked: true,
|
|
278
|
+
value: 'chess',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
checked: false,
|
|
282
|
+
value: 'baseball',
|
|
283
|
+
},
|
|
254
284
|
],
|
|
255
285
|
'gender[]': [
|
|
256
|
-
{
|
|
257
|
-
|
|
286
|
+
{
|
|
287
|
+
checked: false,
|
|
288
|
+
value: 'male',
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
checked: false,
|
|
292
|
+
value: 'female',
|
|
293
|
+
},
|
|
258
294
|
],
|
|
259
|
-
color: {
|
|
295
|
+
color: {
|
|
296
|
+
checked: false,
|
|
297
|
+
value: 'blue',
|
|
298
|
+
},
|
|
260
299
|
},
|
|
261
300
|
};
|
|
262
|
-
|
|
263
301
|
expect(newFieldset.formElements['hobbies[]'][0].modelValue).to.deep.equal({
|
|
264
302
|
checked: true,
|
|
265
303
|
value: 'chess',
|
|
@@ -270,26 +308,24 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
270
308
|
});
|
|
271
309
|
expect(el.formElements.lastName.modelValue).to.equal(2);
|
|
272
310
|
});
|
|
273
|
-
|
|
274
311
|
it('works with document.createElement', async () => {
|
|
275
|
-
const el = /** @type {FormGroup} */
|
|
276
|
-
const childEl = /** @type {FormChild} */
|
|
312
|
+
const el = /** @type {FormGroup} */ document.createElement(tagString);
|
|
313
|
+
const childEl = /** @type {FormChild} */ document.createElement(childTagString);
|
|
277
314
|
childEl.name = 'planet';
|
|
278
315
|
childEl.modelValue = 'earth';
|
|
279
316
|
expect(el.formElements.length).to.equal(0);
|
|
280
|
-
|
|
281
317
|
const wrapper = await fixture('<div></div>');
|
|
282
318
|
el.appendChild(childEl);
|
|
283
319
|
wrapper.appendChild(el);
|
|
284
|
-
|
|
285
320
|
expect(el.formElements.length).to.equal(1);
|
|
286
|
-
|
|
287
321
|
await el.registrationComplete;
|
|
288
|
-
expect(el.modelValue).to.deep.equal({
|
|
322
|
+
expect(el.modelValue).to.deep.equal({
|
|
323
|
+
planet: 'earth',
|
|
324
|
+
});
|
|
289
325
|
});
|
|
290
|
-
|
|
291
326
|
it('does not list disabled values in this.modelValue', async () => {
|
|
292
|
-
const el =
|
|
327
|
+
const el =
|
|
328
|
+
/** @type {FormGroup} */
|
|
293
329
|
await fixture(html`
|
|
294
330
|
<${tag}>
|
|
295
331
|
<${childTag} name="a" disabled .modelValue="${'x'}"></${childTag}>
|
|
@@ -302,8 +338,7 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
302
338
|
<${childTag} name="e" .modelValue="${'x'}"></${childTag}>
|
|
303
339
|
</${tag}>
|
|
304
340
|
</${tag}>
|
|
305
|
-
`)
|
|
306
|
-
);
|
|
341
|
+
`);
|
|
307
342
|
expect(el.modelValue).to.deep.equal({
|
|
308
343
|
b: 'x',
|
|
309
344
|
newFieldset: {
|
|
@@ -311,7 +346,6 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
311
346
|
},
|
|
312
347
|
});
|
|
313
348
|
});
|
|
314
|
-
|
|
315
349
|
it('allows overriding whether fields are included in when fetching modelValue/serializedValue etc.', async () => {
|
|
316
350
|
class FormGroupSubclass extends FormGroupMixin(LitElement) {
|
|
317
351
|
constructor() {
|
|
@@ -334,10 +368,10 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
334
368
|
return true;
|
|
335
369
|
}
|
|
336
370
|
}
|
|
337
|
-
|
|
338
371
|
const tagStringSubclass = defineCE(FormGroupSubclass);
|
|
339
372
|
const tagSubclass = unsafeStatic(tagStringSubclass);
|
|
340
|
-
const el =
|
|
373
|
+
const el =
|
|
374
|
+
/** @type {FormGroup} */
|
|
341
375
|
await fixture(html`
|
|
342
376
|
<${tagSubclass}>
|
|
343
377
|
<${childTag} name="a" disabled .modelValue="${'x'}"></${childTag}>
|
|
@@ -350,8 +384,7 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
350
384
|
<${childTag} name="e" .modelValue="${'x'}"></${childTag}>
|
|
351
385
|
</${tagSubclass}>
|
|
352
386
|
</${tagSubclass}>
|
|
353
|
-
`)
|
|
354
|
-
);
|
|
387
|
+
`);
|
|
355
388
|
expect(el.modelValue).to.deep.equal({
|
|
356
389
|
a: 'x',
|
|
357
390
|
b: 'x',
|
|
@@ -363,7 +396,6 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
363
396
|
e: 'x',
|
|
364
397
|
},
|
|
365
398
|
});
|
|
366
|
-
|
|
367
399
|
expect(el.serializedValue).to.deep.equal({
|
|
368
400
|
b: 'x',
|
|
369
401
|
newFieldset: {
|
|
@@ -371,7 +403,6 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
371
403
|
},
|
|
372
404
|
});
|
|
373
405
|
});
|
|
374
|
-
|
|
375
406
|
it('allows imperatively passing a filter function to _getFromAllFormElements', async () => {
|
|
376
407
|
class FormGroupSubclass extends FormGroupMixin(LitElement) {
|
|
377
408
|
constructor() {
|
|
@@ -393,10 +424,10 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
393
424
|
return true;
|
|
394
425
|
}
|
|
395
426
|
}
|
|
396
|
-
|
|
397
427
|
const tagStringSubclass = defineCE(FormGroupSubclass);
|
|
398
428
|
const tagSubclass = unsafeStatic(tagStringSubclass);
|
|
399
|
-
const el =
|
|
429
|
+
const el =
|
|
430
|
+
/** @type {FormGroup} */
|
|
400
431
|
await fixture(html`
|
|
401
432
|
<${tagSubclass}>
|
|
402
433
|
<${childTag} name="a" disabled .modelValue="${'x'}"></${childTag}>
|
|
@@ -409,8 +440,7 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
409
440
|
<${childTag} name="e" .modelValue="${'x'}"></${childTag}>
|
|
410
441
|
</${tagSubclass}>
|
|
411
442
|
</${tagSubclass}>
|
|
412
|
-
`)
|
|
413
|
-
);
|
|
443
|
+
`);
|
|
414
444
|
|
|
415
445
|
// @ts-ignore -- we are testing a protected method here
|
|
416
446
|
expect(el._getFromAllFormElements('serializedValue')).to.eql({
|
|
@@ -430,86 +460,80 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
430
460
|
disabledFieldset: {},
|
|
431
461
|
});
|
|
432
462
|
});
|
|
433
|
-
|
|
434
463
|
it('does not throw if setter data of this.modelValue can not be handled', async () => {
|
|
435
|
-
const el =
|
|
464
|
+
const el =
|
|
465
|
+
/** @type {FormGroup} */
|
|
436
466
|
await fixture(html`
|
|
437
467
|
<${tag}>
|
|
438
468
|
<${childTag} name="firstName" .modelValue=${'foo'}></${childTag}>
|
|
439
469
|
<${childTag} name="lastName" .modelValue=${'bar'}></${childTag}>
|
|
440
470
|
</${tag}>
|
|
441
|
-
`)
|
|
442
|
-
);
|
|
471
|
+
`);
|
|
443
472
|
const initState = {
|
|
444
473
|
firstName: 'foo',
|
|
445
474
|
lastName: 'bar',
|
|
446
475
|
};
|
|
447
476
|
expect(el.modelValue).to.deep.equal(initState);
|
|
448
|
-
|
|
449
477
|
el.modelValue = undefined;
|
|
450
478
|
expect(el.modelValue).to.deep.equal(initState);
|
|
451
|
-
|
|
452
479
|
el.modelValue = null;
|
|
453
480
|
expect(el.modelValue).to.deep.equal(initState);
|
|
454
481
|
});
|
|
455
|
-
|
|
456
482
|
it('disables/enables all its formElements if it becomes disabled/enabled', async () => {
|
|
457
|
-
const el =
|
|
458
|
-
|
|
459
|
-
|
|
483
|
+
const el =
|
|
484
|
+
/** @type {FormGroup} */
|
|
485
|
+
await fixture(html`<${tag} disabled>${inputSlots}</${tag}>`);
|
|
460
486
|
expect(el.formElements.color.disabled).to.be.true;
|
|
461
487
|
expect(el.formElements['hobbies[]'][0].disabled).to.be.true;
|
|
462
488
|
expect(el.formElements['hobbies[]'][1].disabled).to.be.true;
|
|
463
|
-
|
|
464
489
|
el.disabled = false;
|
|
465
490
|
await el.updateComplete;
|
|
466
491
|
expect(el.formElements.color.disabled).to.equal(false);
|
|
467
492
|
expect(el.formElements['hobbies[]'][0].disabled).to.equal(false);
|
|
468
493
|
expect(el.formElements['hobbies[]'][1].disabled).to.equal(false);
|
|
469
494
|
});
|
|
470
|
-
|
|
471
495
|
it('does not propagate/override initial disabled value on nested form elements', async () => {
|
|
472
|
-
const el =
|
|
496
|
+
const el =
|
|
497
|
+
/** @type {FormGroup} */
|
|
473
498
|
await fixture(html`
|
|
474
499
|
<${tag}>
|
|
475
500
|
<${tag} name="sub" disabled>${inputSlots}</${tag}>
|
|
476
501
|
</${tag}>
|
|
477
|
-
`)
|
|
478
|
-
);
|
|
479
|
-
|
|
502
|
+
`);
|
|
480
503
|
expect(el.disabled).to.equal(false);
|
|
481
504
|
expect(el.formElements.sub.disabled).to.be.true;
|
|
482
505
|
expect(el.formElements.sub.formElements.color.disabled).to.be.true;
|
|
483
506
|
expect(el.formElements.sub.formElements['hobbies[]'][0].disabled).to.be.true;
|
|
484
507
|
expect(el.formElements.sub.formElements['hobbies[]'][1].disabled).to.be.true;
|
|
485
508
|
});
|
|
486
|
-
|
|
487
509
|
it('can set initial modelValue on creation', async () => {
|
|
488
|
-
const el =
|
|
510
|
+
const el =
|
|
511
|
+
/** @type {FormGroup} */
|
|
489
512
|
await fixture(html`
|
|
490
|
-
<${tag} .modelValue=${{
|
|
513
|
+
<${tag} .modelValue=${{
|
|
514
|
+
lastName: 'Bar',
|
|
515
|
+
}}>
|
|
491
516
|
<${childTag} name="lastName"></${childTag}>
|
|
492
517
|
</${tag}>
|
|
493
|
-
`)
|
|
494
|
-
);
|
|
495
|
-
|
|
518
|
+
`);
|
|
496
519
|
expect(el.modelValue).to.eql({
|
|
497
520
|
lastName: 'Bar',
|
|
498
521
|
});
|
|
499
522
|
});
|
|
500
|
-
|
|
501
523
|
it('can set initial serializedValue on creation', async () => {
|
|
502
|
-
const el =
|
|
524
|
+
const el =
|
|
525
|
+
/** @type {FormGroup} */
|
|
503
526
|
await fixture(html`
|
|
504
|
-
<${tag} .modelValue=${{
|
|
527
|
+
<${tag} .modelValue=${{
|
|
528
|
+
lastName: 'Bar',
|
|
529
|
+
}}>
|
|
505
530
|
<${childTag} name="lastName"></${childTag}>
|
|
506
531
|
</${tag}>
|
|
507
|
-
`)
|
|
508
|
-
)
|
|
509
|
-
|
|
510
|
-
|
|
532
|
+
`);
|
|
533
|
+
expect(el.modelValue).to.eql({
|
|
534
|
+
lastName: 'Bar',
|
|
535
|
+
});
|
|
511
536
|
});
|
|
512
|
-
|
|
513
537
|
describe('Validation', () => {
|
|
514
538
|
it('validates on init', async () => {
|
|
515
539
|
class IsCat extends Validator {
|
|
@@ -525,27 +549,24 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
525
549
|
return hasError;
|
|
526
550
|
}
|
|
527
551
|
}
|
|
528
|
-
|
|
529
|
-
|
|
552
|
+
const el =
|
|
553
|
+
/** @type {FormGroup} */
|
|
530
554
|
await fixture(html`
|
|
531
555
|
<${tag}>
|
|
532
|
-
<${childTag} name="color" .validators=${[
|
|
533
|
-
new IsCat(),
|
|
534
|
-
]} .modelValue=${'blue'}></${childTag}>
|
|
556
|
+
<${childTag} name="color" .validators=${[new IsCat()]} .modelValue=${'blue'}></${childTag}>
|
|
535
557
|
</${tag}>
|
|
536
|
-
`)
|
|
537
|
-
);
|
|
558
|
+
`);
|
|
538
559
|
expect(el.formElements.color.validationStates.error.IsCat).to.be.true;
|
|
539
560
|
});
|
|
540
|
-
|
|
541
561
|
it('validates when a value changes', async () => {
|
|
542
|
-
const el = /** @type {FormGroup} */
|
|
543
|
-
|
|
562
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
544
563
|
const spy = sinon.spy(el, 'validate');
|
|
545
|
-
el.formElements.color.modelValue = {
|
|
564
|
+
el.formElements.color.modelValue = {
|
|
565
|
+
checked: true,
|
|
566
|
+
value: 'red',
|
|
567
|
+
};
|
|
546
568
|
expect(spy.callCount).to.equal(1);
|
|
547
569
|
});
|
|
548
|
-
|
|
549
570
|
it('has a special validator for all children - can be checked via this.error.FormElementsHaveNoError', async () => {
|
|
550
571
|
class IsCat extends Validator {
|
|
551
572
|
static get validatorName() {
|
|
@@ -560,32 +581,27 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
560
581
|
return hasError;
|
|
561
582
|
}
|
|
562
583
|
}
|
|
563
|
-
|
|
564
|
-
|
|
584
|
+
const el =
|
|
585
|
+
/** @type {FormGroup} */
|
|
565
586
|
await fixture(html`
|
|
566
587
|
<${tag}>
|
|
567
|
-
<${childTag} name="color" .validators=${[
|
|
568
|
-
new IsCat(),
|
|
569
|
-
]} .modelValue=${'blue'}></${childTag}>
|
|
588
|
+
<${childTag} name="color" .validators=${[new IsCat()]} .modelValue=${'blue'}></${childTag}>
|
|
570
589
|
</${tag}>
|
|
571
|
-
`)
|
|
572
|
-
);
|
|
573
|
-
|
|
590
|
+
`);
|
|
574
591
|
expect(el.validationStates.error.FormElementsHaveNoError).to.be.true;
|
|
575
592
|
expect(el.formElements.color.validationStates.error.IsCat).to.be.true;
|
|
576
593
|
el.formElements.color.modelValue = 'cat';
|
|
577
594
|
expect(el.validationStates.error).to.deep.equal({});
|
|
578
595
|
});
|
|
579
|
-
|
|
580
596
|
it('works with Required', async () => {
|
|
581
|
-
const el =
|
|
597
|
+
const el =
|
|
598
|
+
/** @type {FormGroup} */
|
|
582
599
|
await fixture(html`
|
|
583
600
|
<${tag} name="myGroup" .validators="${[new Required()]}">
|
|
584
601
|
<${childTag} name="fieldA"></${childTag}>
|
|
585
602
|
<${childTag} name="fieldB"></${childTag}>
|
|
586
603
|
</${tag}>
|
|
587
|
-
`)
|
|
588
|
-
);
|
|
604
|
+
`);
|
|
589
605
|
// initially the group is invalid
|
|
590
606
|
expect(el.validationStates.error.Required).to.be.true;
|
|
591
607
|
el.formElements.fieldA.modelValue = 'foo';
|
|
@@ -595,15 +611,14 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
595
611
|
el.formElements.fieldA.modelValue = '';
|
|
596
612
|
expect(el.validationStates.error.Required).to.be.true;
|
|
597
613
|
});
|
|
598
|
-
|
|
599
614
|
it('does not show error feedback (nor aria-invalid) for invalid children before interaction', async () => {
|
|
600
|
-
const el =
|
|
615
|
+
const el =
|
|
616
|
+
/** @type {FormGroup} */
|
|
601
617
|
await fixture(html`
|
|
602
618
|
<${tag}>
|
|
603
619
|
<${childTag} name="myField" .validators=${[new Required()]}></${childTag}>
|
|
604
620
|
</${tag}>
|
|
605
|
-
`)
|
|
606
|
-
);
|
|
621
|
+
`);
|
|
607
622
|
await el.updateComplete;
|
|
608
623
|
await el.feedbackComplete;
|
|
609
624
|
|
|
@@ -620,7 +635,6 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
620
635
|
expect(el.showsFeedbackFor).to.deep.equal(['error']);
|
|
621
636
|
expect(el.getAttribute('aria-invalid')).to.equal('true');
|
|
622
637
|
});
|
|
623
|
-
|
|
624
638
|
it('validates on children (de)registration', async () => {
|
|
625
639
|
class HasEvenNumberOfChildren extends Validator {
|
|
626
640
|
static get validatorName() {
|
|
@@ -635,115 +649,103 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
635
649
|
return hasError;
|
|
636
650
|
}
|
|
637
651
|
}
|
|
638
|
-
const el =
|
|
652
|
+
const el =
|
|
653
|
+
/** @type {FormGroup} */
|
|
639
654
|
await fixture(html`
|
|
640
655
|
<${tag} .validators=${[new HasEvenNumberOfChildren()]}>
|
|
641
656
|
<${childTag} id="c1" name="c1"></${childTag}>
|
|
642
657
|
</${tag}>
|
|
643
|
-
`)
|
|
644
|
-
|
|
645
|
-
|
|
658
|
+
`);
|
|
659
|
+
const child2 =
|
|
660
|
+
/** @type {FormGroup} */
|
|
646
661
|
await fixture(html`
|
|
647
662
|
<${childTag} name="c2"></${childTag}>
|
|
648
|
-
`)
|
|
649
|
-
);
|
|
663
|
+
`);
|
|
650
664
|
expect(el.validationStates.error.HasEvenNumberOfChildren).to.be.true;
|
|
651
|
-
|
|
652
665
|
el.appendChild(child2);
|
|
653
666
|
expect(el.validationStates.error.HasEvenNumberOfChildren).to.equal(undefined);
|
|
654
|
-
|
|
655
667
|
el.removeChild(child2);
|
|
656
668
|
expect(el.validationStates.error.HasEvenNumberOfChildren).to.be.true;
|
|
657
669
|
|
|
658
670
|
// Edge case: remove all children
|
|
659
|
-
el.removeChild(/** @type {Node} */
|
|
660
|
-
|
|
671
|
+
el.removeChild(/** @type {Node} */ el.querySelector('[id=c1]'));
|
|
661
672
|
expect(el.validationStates.error.HasEvenNumberOfChildren).to.equal(undefined);
|
|
662
673
|
});
|
|
663
674
|
});
|
|
664
|
-
|
|
665
675
|
describe('Interaction states', () => {
|
|
666
676
|
it('has false states (dirty, touched, prefilled) on init', async () => {
|
|
667
|
-
const fieldset =
|
|
668
|
-
|
|
669
|
-
|
|
677
|
+
const fieldset =
|
|
678
|
+
/** @type {FormGroup} */
|
|
679
|
+
await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
670
680
|
expect(fieldset.dirty).to.equal(false, 'dirty');
|
|
671
681
|
expect(fieldset.touched).to.equal(false, 'touched');
|
|
672
682
|
expect(fieldset.prefilled).to.equal(false, 'prefilled');
|
|
673
683
|
});
|
|
674
|
-
|
|
675
684
|
it('sets dirty when value changed', async () => {
|
|
676
|
-
const fieldset =
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
685
|
+
const fieldset =
|
|
686
|
+
/** @type {FormGroup} */
|
|
687
|
+
await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
688
|
+
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
689
|
+
checked: true,
|
|
690
|
+
value: 'football',
|
|
691
|
+
};
|
|
680
692
|
expect(fieldset.dirty).to.be.true;
|
|
681
693
|
});
|
|
682
|
-
|
|
683
694
|
it('sets touched when last field in fieldset left after focus', async () => {
|
|
684
|
-
const el = /** @type {FormGroup} */
|
|
695
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
685
696
|
const { _inputNode: hobbyInputNode } = getFormControlMembers(
|
|
686
697
|
el.formElements['hobbies[]'][0],
|
|
687
698
|
);
|
|
688
699
|
const { _inputNode: genderInputNode } = getFormControlMembers(
|
|
689
700
|
el.formElements['hobbies[]'][el.formElements['gender[]'].length - 1],
|
|
690
701
|
);
|
|
691
|
-
|
|
692
702
|
await triggerFocusFor(hobbyInputNode);
|
|
693
703
|
await triggerFocusFor(genderInputNode);
|
|
694
|
-
const button = /** @type {FormGroup} */
|
|
704
|
+
const button = /** @type {FormGroup} */ await fixture(html`<button>Button</button>`);
|
|
695
705
|
button.focus();
|
|
696
|
-
|
|
697
706
|
expect(el.touched).to.be.true;
|
|
698
707
|
});
|
|
699
|
-
|
|
700
708
|
it('sets attributes [touched][dirty]', async () => {
|
|
701
|
-
const el = /** @type {FormGroup} */
|
|
709
|
+
const el = /** @type {FormGroup} */ await fixture(html`<${tag}></${tag}>`);
|
|
702
710
|
el.touched = true;
|
|
703
711
|
await el.updateComplete;
|
|
704
712
|
expect(el).to.have.attribute('touched');
|
|
705
|
-
|
|
706
713
|
el.dirty = true;
|
|
707
714
|
await el.updateComplete;
|
|
708
715
|
expect(el).to.have.attribute('dirty');
|
|
709
716
|
});
|
|
710
|
-
|
|
711
717
|
it('becomes prefilled if all form elements are prefilled', async () => {
|
|
712
|
-
const el =
|
|
718
|
+
const el =
|
|
719
|
+
/** @type {FormGroup} */
|
|
713
720
|
await fixture(html`
|
|
714
721
|
<${tag}>
|
|
715
722
|
<${childTag} name="input1" .modelValue="${'prefilled'}"></${childTag}>
|
|
716
723
|
<${childTag} name="input2"></${childTag}>
|
|
717
724
|
</${tag}>
|
|
718
|
-
`)
|
|
719
|
-
);
|
|
725
|
+
`);
|
|
720
726
|
expect(el.prefilled).to.be.false;
|
|
721
|
-
|
|
722
|
-
|
|
727
|
+
const el2 =
|
|
728
|
+
/** @type {FormGroup} */
|
|
723
729
|
await fixture(html`
|
|
724
730
|
<${tag}>
|
|
725
731
|
<${childTag} name="input1" .modelValue="${'prefilled'}"></${childTag}>
|
|
726
732
|
<${childTag} name="input2" .modelValue="${'prefilled'}"></${childTag}>
|
|
727
733
|
</${tag}>
|
|
728
|
-
`)
|
|
729
|
-
);
|
|
734
|
+
`);
|
|
730
735
|
expect(el2.prefilled).to.be.true;
|
|
731
736
|
});
|
|
732
|
-
|
|
733
737
|
it(`becomes "touched" once the last element of a group becomes blurred by keyboard
|
|
734
738
|
interaction (e.g. tabbing through the checkbox-group)`, async () => {
|
|
735
|
-
const el =
|
|
739
|
+
const el =
|
|
740
|
+
/** @type {FormGroup} */
|
|
736
741
|
await fixture(html`
|
|
737
742
|
<${tag}>
|
|
738
743
|
<label slot="label">My group</label>
|
|
739
744
|
<${childTag} name="myGroup[]" label="Option 1" value="1"></${childTag}>
|
|
740
745
|
<${childTag} name="myGroup[]" label="Option 2" value="2"></${childTag}>
|
|
741
746
|
</${tag}>
|
|
742
|
-
`)
|
|
743
|
-
);
|
|
744
|
-
|
|
745
|
-
const button = /** @type {HTMLButtonElement} */ (await fixture(`<button>Blur</button>`));
|
|
746
|
-
|
|
747
|
+
`);
|
|
748
|
+
const button = /** @type {HTMLButtonElement} */ await fixture(`<button>Blur</button>`);
|
|
747
749
|
expect(el.touched).to.equal(false, 'initially, touched state is false');
|
|
748
750
|
el.formElements[1].focus();
|
|
749
751
|
expect(el.touched).to.equal(false, 'focus is on second checkbox');
|
|
@@ -753,44 +755,38 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
753
755
|
`focus is on element behind second checkbox (group has blurred)`,
|
|
754
756
|
);
|
|
755
757
|
});
|
|
756
|
-
|
|
757
758
|
it(`becomes "touched" once the group as a whole becomes blurred via mouse interaction after
|
|
758
759
|
keyboard interaction (e.g. focus is moved inside the group and user clicks somewhere outside
|
|
759
760
|
the group)`, async () => {
|
|
760
|
-
const el =
|
|
761
|
+
const el =
|
|
762
|
+
/** @type {FormGroup} */
|
|
761
763
|
await fixture(html`
|
|
762
764
|
<${tag}>
|
|
763
765
|
<${childTag} name="input1"></${childTag}>
|
|
764
766
|
<${childTag} name="input2"></${childTag}>
|
|
765
767
|
</${tag}>
|
|
766
|
-
`)
|
|
767
|
-
|
|
768
|
-
|
|
768
|
+
`);
|
|
769
|
+
const el2 =
|
|
770
|
+
/** @type {FormGroup} */
|
|
769
771
|
await fixture(html`
|
|
770
772
|
<${tag}>
|
|
771
773
|
<${childTag} name="input1"></${childTag}>
|
|
772
774
|
<${childTag} name="input2"></${childTag}>
|
|
773
775
|
</${tag}>
|
|
774
|
-
`)
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
await fixture(html`<button>outside</button>`)
|
|
779
|
-
);
|
|
780
|
-
|
|
776
|
+
`);
|
|
777
|
+
const outside =
|
|
778
|
+
/** @type {HTMLButtonElement} */
|
|
779
|
+
await fixture(html`<button>outside</button>`);
|
|
781
780
|
outside.click();
|
|
782
781
|
expect(el.touched, 'unfocused fieldset should stay untouched').to.be.false;
|
|
783
|
-
|
|
784
782
|
el.formElements[0].focus();
|
|
785
783
|
el.formElements[1].focus();
|
|
786
784
|
expect(el.touched).to.be.false;
|
|
787
|
-
|
|
788
785
|
outside.click(); // blur the group via a click
|
|
789
786
|
outside.focus(); // a real mouse click moves focus as well
|
|
790
787
|
expect(el.touched).to.be.true;
|
|
791
788
|
expect(el2.touched).to.be.false;
|
|
792
789
|
});
|
|
793
|
-
|
|
794
790
|
it('potentially shows fieldset error message on interaction change', async () => {
|
|
795
791
|
class Input1IsTen extends Validator {
|
|
796
792
|
static get validatorName() {
|
|
@@ -805,27 +801,24 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
805
801
|
return hasError;
|
|
806
802
|
}
|
|
807
803
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
await fixture(html`<button>outside</button>`)
|
|
811
|
-
|
|
812
|
-
|
|
804
|
+
const outSideButton =
|
|
805
|
+
/** @type {FormGroup} */
|
|
806
|
+
await fixture(html`<button>outside</button>`);
|
|
807
|
+
const el =
|
|
808
|
+
/** @type {FormGroup} */
|
|
813
809
|
await fixture(html`
|
|
814
810
|
<${tag} .validators=${[new Input1IsTen()]}>
|
|
815
811
|
<${childTag} name="input1" .validators=${[new IsNumber()]}></${childTag}>
|
|
816
812
|
</${tag}>
|
|
817
|
-
`)
|
|
818
|
-
);
|
|
819
|
-
const input1 = /** @type {FormChild} */ (el.querySelector('[name=input1]'));
|
|
813
|
+
`);
|
|
814
|
+
const input1 = /** @type {FormChild} */ el.querySelector('[name=input1]');
|
|
820
815
|
input1.modelValue = 2;
|
|
821
816
|
input1.focus();
|
|
822
817
|
outSideButton.focus();
|
|
823
|
-
|
|
824
818
|
await el.updateComplete;
|
|
825
819
|
expect(el.validationStates.error.Input1IsTen).to.be.true;
|
|
826
820
|
expect(el.showsFeedbackFor).to.deep.equal(['error']);
|
|
827
821
|
});
|
|
828
|
-
|
|
829
822
|
it('show error if tabbing "out" of last ', async () => {
|
|
830
823
|
class Input1IsTen extends Validator {
|
|
831
824
|
static get validatorName() {
|
|
@@ -838,46 +831,48 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
838
831
|
return hasError;
|
|
839
832
|
}
|
|
840
833
|
}
|
|
841
|
-
const outSideButton =
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
const el =
|
|
834
|
+
const outSideButton =
|
|
835
|
+
/** @type {FormGroup} */
|
|
836
|
+
await fixture(html`<button>outside</button>`);
|
|
837
|
+
const el =
|
|
838
|
+
/** @type {FormGroup} */
|
|
845
839
|
await fixture(html`
|
|
846
840
|
<${tag} .validators=${[new Input1IsTen()]}>
|
|
847
841
|
<${childTag} name="input1" .validators=${[new IsNumber()]}></${childTag}>
|
|
848
842
|
<${childTag} name="input2" .validators=${[new IsNumber()]}></${childTag}>
|
|
849
843
|
</${tag}>
|
|
850
|
-
`)
|
|
851
|
-
);
|
|
852
|
-
const inputs = /** @type {FormChild[]} */ (Array.from(el.querySelectorAll(childTagString)));
|
|
844
|
+
`);
|
|
845
|
+
const inputs = /** @type {FormChild[]} */ Array.from(el.querySelectorAll(childTagString));
|
|
853
846
|
inputs[1].modelValue = 2; // make it dirty
|
|
854
847
|
inputs[1].focus();
|
|
855
|
-
|
|
856
848
|
outSideButton.focus();
|
|
857
|
-
|
|
858
849
|
expect(el.validationStates.error.Input1IsTen).to.be.true;
|
|
859
850
|
expect(el.hasFeedbackFor).to.deep.equal(['error']);
|
|
860
851
|
});
|
|
861
|
-
|
|
862
852
|
it('does not become dirty when elements are prefilled', async () => {
|
|
863
|
-
const el =
|
|
853
|
+
const el =
|
|
854
|
+
/** @type {FormGroup} */
|
|
864
855
|
await fixture(html`
|
|
865
|
-
<${tag} .serializedValue="${{
|
|
856
|
+
<${tag} .serializedValue="${{
|
|
857
|
+
input1: 'x',
|
|
858
|
+
input2: 'y',
|
|
859
|
+
}}">
|
|
866
860
|
<${childTag} name="input1" ></${childTag}>
|
|
867
861
|
<${childTag} name="input2"></${childTag}>
|
|
868
862
|
</${tag}>
|
|
869
|
-
`)
|
|
870
|
-
);
|
|
863
|
+
`);
|
|
871
864
|
expect(el.dirty).to.be.false;
|
|
872
|
-
|
|
873
|
-
|
|
865
|
+
const el2 =
|
|
866
|
+
/** @type {FormGroup} */
|
|
874
867
|
await fixture(html`
|
|
875
|
-
<${tag} .modelValue="${{
|
|
868
|
+
<${tag} .modelValue="${{
|
|
869
|
+
input1: 'x',
|
|
870
|
+
input2: 'y',
|
|
871
|
+
}}">
|
|
876
872
|
<${childTag} name="input1" ></${childTag}>
|
|
877
873
|
<${childTag} name="input2"></${childTag}>
|
|
878
874
|
</${tag}>
|
|
879
|
-
`)
|
|
880
|
-
);
|
|
875
|
+
`);
|
|
881
876
|
expect(el2.dirty).to.be.false;
|
|
882
877
|
});
|
|
883
878
|
});
|
|
@@ -885,75 +880,149 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
885
880
|
// TODO: this should be tested in FormGroupMixin
|
|
886
881
|
describe('serializedValue', () => {
|
|
887
882
|
it('use form elements serializedValue', async () => {
|
|
888
|
-
const fieldset =
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
fieldset.formElements['hobbies[]'][0].serializer = /** @param {any} v */ v =>
|
|
883
|
+
const fieldset =
|
|
884
|
+
/** @type {FormGroup} */
|
|
885
|
+
await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
886
|
+
fieldset.formElements['hobbies[]'][0].serializer = /** @param {any} v */ (v) =>
|
|
892
887
|
`${v.value}-serialized`;
|
|
893
|
-
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
fieldset.formElements.
|
|
888
|
+
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
889
|
+
checked: false,
|
|
890
|
+
value: 'Bar',
|
|
891
|
+
};
|
|
892
|
+
fieldset.formElements['hobbies[]'][1].modelValue = {
|
|
893
|
+
checked: false,
|
|
894
|
+
value: 'rugby',
|
|
895
|
+
};
|
|
896
|
+
fieldset.formElements['gender[]'][0].modelValue = {
|
|
897
|
+
checked: false,
|
|
898
|
+
value: 'male',
|
|
899
|
+
};
|
|
900
|
+
fieldset.formElements['gender[]'][1].modelValue = {
|
|
901
|
+
checked: false,
|
|
902
|
+
value: 'female',
|
|
903
|
+
};
|
|
904
|
+
fieldset.formElements.color.modelValue = {
|
|
905
|
+
checked: false,
|
|
906
|
+
value: 'blue',
|
|
907
|
+
};
|
|
898
908
|
expect(fieldset.formElements['hobbies[]'][0].serializedValue).to.equal('Bar-serialized');
|
|
899
909
|
expect(fieldset.serializedValue).to.deep.equal({
|
|
900
|
-
'hobbies[]': [
|
|
910
|
+
'hobbies[]': [
|
|
911
|
+
'Bar-serialized',
|
|
912
|
+
{
|
|
913
|
+
checked: false,
|
|
914
|
+
value: 'rugby',
|
|
915
|
+
},
|
|
916
|
+
],
|
|
901
917
|
'gender[]': [
|
|
902
|
-
{
|
|
903
|
-
|
|
918
|
+
{
|
|
919
|
+
checked: false,
|
|
920
|
+
value: 'male',
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
checked: false,
|
|
924
|
+
value: 'female',
|
|
925
|
+
},
|
|
904
926
|
],
|
|
905
|
-
color: {
|
|
927
|
+
color: {
|
|
928
|
+
checked: false,
|
|
929
|
+
value: 'blue',
|
|
930
|
+
},
|
|
906
931
|
});
|
|
907
932
|
});
|
|
908
|
-
|
|
909
933
|
it('treats names with ending [] as arrays', async () => {
|
|
910
|
-
const fieldset =
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
fieldset.formElements.
|
|
934
|
+
const fieldset =
|
|
935
|
+
/** @type {FormGroup} */
|
|
936
|
+
await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
937
|
+
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
938
|
+
checked: false,
|
|
939
|
+
value: 'chess',
|
|
940
|
+
};
|
|
941
|
+
fieldset.formElements['hobbies[]'][1].modelValue = {
|
|
942
|
+
checked: false,
|
|
943
|
+
value: 'rugby',
|
|
944
|
+
};
|
|
945
|
+
fieldset.formElements['gender[]'][0].modelValue = {
|
|
946
|
+
checked: false,
|
|
947
|
+
value: 'male',
|
|
948
|
+
};
|
|
949
|
+
fieldset.formElements['gender[]'][1].modelValue = {
|
|
950
|
+
checked: false,
|
|
951
|
+
value: 'female',
|
|
952
|
+
};
|
|
953
|
+
fieldset.formElements.color.modelValue = {
|
|
954
|
+
checked: false,
|
|
955
|
+
value: 'blue',
|
|
956
|
+
};
|
|
918
957
|
expect(fieldset.serializedValue).to.deep.equal({
|
|
919
958
|
'hobbies[]': [
|
|
920
|
-
{
|
|
921
|
-
|
|
959
|
+
{
|
|
960
|
+
checked: false,
|
|
961
|
+
value: 'chess',
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
checked: false,
|
|
965
|
+
value: 'rugby',
|
|
966
|
+
},
|
|
922
967
|
],
|
|
923
968
|
'gender[]': [
|
|
924
|
-
{
|
|
925
|
-
|
|
969
|
+
{
|
|
970
|
+
checked: false,
|
|
971
|
+
value: 'male',
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
checked: false,
|
|
975
|
+
value: 'female',
|
|
976
|
+
},
|
|
926
977
|
],
|
|
927
|
-
color: {
|
|
978
|
+
color: {
|
|
979
|
+
checked: false,
|
|
980
|
+
value: 'blue',
|
|
981
|
+
},
|
|
928
982
|
});
|
|
929
983
|
});
|
|
930
|
-
|
|
931
984
|
it('0 is a valid value to be serialized', async () => {
|
|
932
|
-
const fieldset =
|
|
985
|
+
const fieldset =
|
|
986
|
+
/** @type {FormGroup} */
|
|
933
987
|
await fixture(html`
|
|
934
988
|
<${tag}>
|
|
935
989
|
<${childTag} name="price"></${childTag}>
|
|
936
|
-
</${tag}>`)
|
|
937
|
-
);
|
|
990
|
+
</${tag}>`);
|
|
938
991
|
fieldset.formElements.price.modelValue = 0;
|
|
939
|
-
expect(fieldset.serializedValue).to.deep.equal({
|
|
992
|
+
expect(fieldset.serializedValue).to.deep.equal({
|
|
993
|
+
price: 0,
|
|
994
|
+
});
|
|
940
995
|
});
|
|
941
|
-
|
|
942
996
|
it('allows for nested fieldsets', async () => {
|
|
943
|
-
const fieldset =
|
|
997
|
+
const fieldset =
|
|
998
|
+
/** @type {FormGroup} */
|
|
944
999
|
await fixture(html`
|
|
945
1000
|
<${tag} name="userData">
|
|
946
1001
|
<${childTag} name="comment"></${childTag}>
|
|
947
1002
|
<${tag} name="newfieldset">${inputSlots}</${tag}>
|
|
948
1003
|
</${tag}>
|
|
949
|
-
`)
|
|
950
|
-
);
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
newFieldset.formElements['
|
|
956
|
-
|
|
1004
|
+
`);
|
|
1005
|
+
const newFieldset = /** @type {FormGroup} */ fieldset.querySelector(tagString);
|
|
1006
|
+
newFieldset.formElements['hobbies[]'][0].modelValue = {
|
|
1007
|
+
checked: false,
|
|
1008
|
+
value: 'chess',
|
|
1009
|
+
};
|
|
1010
|
+
newFieldset.formElements['hobbies[]'][1].modelValue = {
|
|
1011
|
+
checked: false,
|
|
1012
|
+
value: 'rugby',
|
|
1013
|
+
};
|
|
1014
|
+
newFieldset.formElements['gender[]'][0].modelValue = {
|
|
1015
|
+
checked: false,
|
|
1016
|
+
value: 'male',
|
|
1017
|
+
};
|
|
1018
|
+
newFieldset.formElements['gender[]'][1].modelValue = {
|
|
1019
|
+
checked: false,
|
|
1020
|
+
value: 'female',
|
|
1021
|
+
};
|
|
1022
|
+
newFieldset.formElements.color.modelValue = {
|
|
1023
|
+
checked: false,
|
|
1024
|
+
value: 'blue',
|
|
1025
|
+
};
|
|
957
1026
|
fieldset.formElements.comment.modelValue = 'Foo';
|
|
958
1027
|
// @ts-ignore
|
|
959
1028
|
expect(fieldset.formElements._keys().length).to.equal(2);
|
|
@@ -963,93 +1032,143 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
963
1032
|
comment: 'Foo',
|
|
964
1033
|
newfieldset: {
|
|
965
1034
|
'hobbies[]': [
|
|
966
|
-
{
|
|
967
|
-
|
|
1035
|
+
{
|
|
1036
|
+
checked: false,
|
|
1037
|
+
value: 'chess',
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
checked: false,
|
|
1041
|
+
value: 'rugby',
|
|
1042
|
+
},
|
|
968
1043
|
],
|
|
969
1044
|
'gender[]': [
|
|
970
|
-
{
|
|
971
|
-
|
|
1045
|
+
{
|
|
1046
|
+
checked: false,
|
|
1047
|
+
value: 'male',
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
checked: false,
|
|
1051
|
+
value: 'female',
|
|
1052
|
+
},
|
|
972
1053
|
],
|
|
973
|
-
color: {
|
|
1054
|
+
color: {
|
|
1055
|
+
checked: false,
|
|
1056
|
+
value: 'blue',
|
|
1057
|
+
},
|
|
974
1058
|
},
|
|
975
1059
|
});
|
|
976
1060
|
});
|
|
977
|
-
|
|
978
1061
|
it('does not serialize disabled values', async () => {
|
|
979
|
-
const fieldset =
|
|
1062
|
+
const fieldset =
|
|
1063
|
+
/** @type {FormGroup} */
|
|
980
1064
|
await fixture(html`
|
|
981
1065
|
<${tag}>
|
|
982
1066
|
<${childTag} name="custom[]"></${childTag}>
|
|
983
1067
|
<${childTag} name="custom[]"></${childTag}>
|
|
984
1068
|
</${tag}>
|
|
985
|
-
`)
|
|
986
|
-
);
|
|
1069
|
+
`);
|
|
987
1070
|
fieldset.formElements['custom[]'][0].modelValue = 'custom 1';
|
|
988
1071
|
fieldset.formElements['custom[]'][1].disabled = true;
|
|
989
|
-
|
|
990
1072
|
expect(fieldset.serializedValue).to.deep.equal({
|
|
991
1073
|
'custom[]': ['custom 1'],
|
|
992
1074
|
});
|
|
993
1075
|
});
|
|
994
|
-
|
|
995
1076
|
it('will exclude form elements within a disabled fieldset', async () => {
|
|
996
|
-
const fieldset =
|
|
1077
|
+
const fieldset =
|
|
1078
|
+
/** @type {FormGroup} */
|
|
997
1079
|
await fixture(html`
|
|
998
1080
|
<${tag} name="userData">
|
|
999
1081
|
<${childTag} name="comment"></${childTag}>
|
|
1000
1082
|
<${tag} name="newfieldset">${inputSlots}</${tag}>
|
|
1001
1083
|
</${tag}>
|
|
1002
|
-
`)
|
|
1003
|
-
);
|
|
1004
|
-
|
|
1005
|
-
const newFieldset = /** @type {FormGroup} */ (fieldset.querySelector(tagString));
|
|
1084
|
+
`);
|
|
1085
|
+
const newFieldset = /** @type {FormGroup} */ fieldset.querySelector(tagString);
|
|
1006
1086
|
fieldset.formElements.comment.modelValue = 'Foo';
|
|
1007
|
-
newFieldset.formElements['hobbies[]'][0].modelValue = {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
newFieldset.formElements.
|
|
1087
|
+
newFieldset.formElements['hobbies[]'][0].modelValue = {
|
|
1088
|
+
checked: false,
|
|
1089
|
+
value: 'chess',
|
|
1090
|
+
};
|
|
1091
|
+
newFieldset.formElements['hobbies[]'][1].modelValue = {
|
|
1092
|
+
checked: false,
|
|
1093
|
+
value: 'rugby',
|
|
1094
|
+
};
|
|
1095
|
+
newFieldset.formElements['gender[]'][0].modelValue = {
|
|
1096
|
+
checked: false,
|
|
1097
|
+
value: 'male',
|
|
1098
|
+
};
|
|
1099
|
+
newFieldset.formElements['gender[]'][1].modelValue = {
|
|
1100
|
+
checked: false,
|
|
1101
|
+
value: 'female',
|
|
1102
|
+
};
|
|
1103
|
+
newFieldset.formElements.color.modelValue = {
|
|
1104
|
+
checked: false,
|
|
1105
|
+
value: 'blue',
|
|
1106
|
+
};
|
|
1012
1107
|
newFieldset.formElements.color.disabled = true;
|
|
1013
|
-
|
|
1014
1108
|
expect(fieldset.serializedValue).to.deep.equal({
|
|
1015
1109
|
comment: 'Foo',
|
|
1016
1110
|
newfieldset: {
|
|
1017
1111
|
'hobbies[]': [
|
|
1018
|
-
{
|
|
1019
|
-
|
|
1112
|
+
{
|
|
1113
|
+
checked: false,
|
|
1114
|
+
value: 'chess',
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
checked: false,
|
|
1118
|
+
value: 'rugby',
|
|
1119
|
+
},
|
|
1020
1120
|
],
|
|
1021
1121
|
'gender[]': [
|
|
1022
|
-
{
|
|
1023
|
-
|
|
1122
|
+
{
|
|
1123
|
+
checked: false,
|
|
1124
|
+
value: 'male',
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
checked: false,
|
|
1128
|
+
value: 'female',
|
|
1129
|
+
},
|
|
1024
1130
|
],
|
|
1025
1131
|
},
|
|
1026
1132
|
});
|
|
1027
|
-
|
|
1028
1133
|
newFieldset.formElements.color.disabled = false;
|
|
1029
1134
|
expect(fieldset.serializedValue).to.deep.equal({
|
|
1030
1135
|
comment: 'Foo',
|
|
1031
1136
|
newfieldset: {
|
|
1032
1137
|
'hobbies[]': [
|
|
1033
|
-
{
|
|
1034
|
-
|
|
1138
|
+
{
|
|
1139
|
+
checked: false,
|
|
1140
|
+
value: 'chess',
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
checked: false,
|
|
1144
|
+
value: 'rugby',
|
|
1145
|
+
},
|
|
1035
1146
|
],
|
|
1036
1147
|
'gender[]': [
|
|
1037
|
-
{
|
|
1038
|
-
|
|
1148
|
+
{
|
|
1149
|
+
checked: false,
|
|
1150
|
+
value: 'male',
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
checked: false,
|
|
1154
|
+
value: 'female',
|
|
1155
|
+
},
|
|
1039
1156
|
],
|
|
1040
|
-
color: {
|
|
1157
|
+
color: {
|
|
1158
|
+
checked: false,
|
|
1159
|
+
value: 'blue',
|
|
1160
|
+
},
|
|
1041
1161
|
},
|
|
1042
1162
|
});
|
|
1043
1163
|
});
|
|
1044
|
-
|
|
1045
1164
|
it('updates the formElements keys when a name attribute changes', async () => {
|
|
1046
|
-
const fieldset =
|
|
1165
|
+
const fieldset =
|
|
1166
|
+
/** @type {FormGroup} */
|
|
1047
1167
|
await fixture(html`
|
|
1048
1168
|
<${tag}>
|
|
1049
1169
|
<${childTag} name="foo" .modelValue=${'qux'}></${childTag}>
|
|
1050
1170
|
</${tag}>
|
|
1051
|
-
`)
|
|
1052
|
-
);
|
|
1171
|
+
`);
|
|
1053
1172
|
expect(fieldset.serializedValue.foo).to.equal('qux');
|
|
1054
1173
|
fieldset.formElements[0].name = 'bar';
|
|
1055
1174
|
await fieldset.updateComplete;
|
|
@@ -1057,83 +1176,94 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1057
1176
|
expect(fieldset.serializedValue.bar).to.equal('qux');
|
|
1058
1177
|
});
|
|
1059
1178
|
});
|
|
1060
|
-
|
|
1061
1179
|
describe('Reset', () => {
|
|
1062
1180
|
it('restores default values if changes were made', async () => {
|
|
1063
|
-
const el =
|
|
1181
|
+
const el =
|
|
1182
|
+
/** @type {FormGroup} */
|
|
1064
1183
|
await fixture(html`
|
|
1065
1184
|
<${tag}>
|
|
1066
1185
|
<${childTag} id="firstName" name="firstName" .modelValue="${'Foo'}"></${childTag}>
|
|
1067
1186
|
</${tag}>
|
|
1068
|
-
`)
|
|
1069
|
-
);
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
const input = /** @type {FormChild} */ (el.querySelector('#firstName'));
|
|
1073
|
-
|
|
1187
|
+
`);
|
|
1188
|
+
await /** @type {FormChild} */ el.querySelector(childTagString).updateComplete;
|
|
1189
|
+
const input = /** @type {FormChild} */ el.querySelector('#firstName');
|
|
1074
1190
|
input.modelValue = 'Bar';
|
|
1075
|
-
expect(el.modelValue).to.deep.equal({
|
|
1191
|
+
expect(el.modelValue).to.deep.equal({
|
|
1192
|
+
firstName: 'Bar',
|
|
1193
|
+
});
|
|
1076
1194
|
expect(input.modelValue).to.equal('Bar');
|
|
1077
|
-
|
|
1078
1195
|
el.resetGroup();
|
|
1079
|
-
expect(el.modelValue).to.deep.equal({
|
|
1196
|
+
expect(el.modelValue).to.deep.equal({
|
|
1197
|
+
firstName: 'Foo',
|
|
1198
|
+
});
|
|
1080
1199
|
expect(input.modelValue).to.equal('Foo');
|
|
1081
1200
|
});
|
|
1082
|
-
|
|
1083
1201
|
it('restores default values of arrays if changes were made', async () => {
|
|
1084
|
-
const el =
|
|
1202
|
+
const el =
|
|
1203
|
+
/** @type {FormGroup} */
|
|
1085
1204
|
await fixture(html`
|
|
1086
1205
|
<${tag}>
|
|
1087
1206
|
<${childTag} id="firstName" name="firstName[]" .modelValue="${'Foo'}"></${childTag}>
|
|
1088
1207
|
</${tag}>
|
|
1089
|
-
`)
|
|
1090
|
-
);
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
const input = /** @type {FormChild} */ (el.querySelector('#firstName'));
|
|
1094
|
-
|
|
1208
|
+
`);
|
|
1209
|
+
await /** @type {FormChild} */ el.querySelector(childTagString).updateComplete;
|
|
1210
|
+
const input = /** @type {FormChild} */ el.querySelector('#firstName');
|
|
1095
1211
|
input.modelValue = 'Bar';
|
|
1096
|
-
expect(el.modelValue).to.deep.equal({
|
|
1212
|
+
expect(el.modelValue).to.deep.equal({
|
|
1213
|
+
'firstName[]': ['Bar'],
|
|
1214
|
+
});
|
|
1097
1215
|
expect(input.modelValue).to.equal('Bar');
|
|
1098
|
-
|
|
1099
1216
|
el.resetGroup();
|
|
1100
|
-
expect(el.modelValue).to.deep.equal({
|
|
1217
|
+
expect(el.modelValue).to.deep.equal({
|
|
1218
|
+
'firstName[]': ['Foo'],
|
|
1219
|
+
});
|
|
1101
1220
|
expect(input.modelValue).to.equal('Foo');
|
|
1102
1221
|
});
|
|
1103
|
-
|
|
1104
1222
|
it('restores default values of a nested fieldset if changes were made', async () => {
|
|
1105
|
-
const el =
|
|
1223
|
+
const el =
|
|
1224
|
+
/** @type {FormGroup} */
|
|
1106
1225
|
await fixture(html`
|
|
1107
1226
|
<${tag}>
|
|
1108
1227
|
<${tag} id="name" name="name[]">
|
|
1109
1228
|
<${childTag} id="firstName" name="firstName" .modelValue="${'Foo'}"></${childTag}>
|
|
1110
1229
|
</${tag}>
|
|
1111
1230
|
</${tag}>
|
|
1112
|
-
`)
|
|
1113
|
-
);
|
|
1231
|
+
`);
|
|
1114
1232
|
await Promise.all([
|
|
1115
|
-
/** @type {FormChild} */
|
|
1116
|
-
/** @type {FormChild} */
|
|
1233
|
+
/** @type {FormChild} */ el.querySelector(tagString).updateComplete,
|
|
1234
|
+
/** @type {FormChild} */ el.querySelector(childTagString).updateComplete,
|
|
1117
1235
|
]);
|
|
1118
|
-
|
|
1119
|
-
const
|
|
1120
|
-
const nestedFieldset = /** @type {FormGroup} */ (el.querySelector('#name'));
|
|
1121
|
-
|
|
1236
|
+
const input = /** @type {FormChild} */ el.querySelector('#firstName');
|
|
1237
|
+
const nestedFieldset = /** @type {FormGroup} */ el.querySelector('#name');
|
|
1122
1238
|
input.modelValue = 'Bar';
|
|
1123
|
-
expect(el.modelValue).to.deep.equal({
|
|
1124
|
-
|
|
1239
|
+
expect(el.modelValue).to.deep.equal({
|
|
1240
|
+
'name[]': [
|
|
1241
|
+
{
|
|
1242
|
+
firstName: 'Bar',
|
|
1243
|
+
},
|
|
1244
|
+
],
|
|
1245
|
+
});
|
|
1246
|
+
expect(nestedFieldset.modelValue).to.deep.equal({
|
|
1247
|
+
firstName: 'Bar',
|
|
1248
|
+
});
|
|
1125
1249
|
expect(input.modelValue).to.equal('Bar');
|
|
1126
|
-
|
|
1127
1250
|
el.resetGroup();
|
|
1128
|
-
expect(el.modelValue).to.deep.equal({
|
|
1129
|
-
|
|
1251
|
+
expect(el.modelValue).to.deep.equal({
|
|
1252
|
+
'name[]': [
|
|
1253
|
+
{
|
|
1254
|
+
firstName: 'Foo',
|
|
1255
|
+
},
|
|
1256
|
+
],
|
|
1257
|
+
});
|
|
1258
|
+
expect(nestedFieldset.modelValue).to.deep.equal({
|
|
1259
|
+
firstName: 'Foo',
|
|
1260
|
+
});
|
|
1130
1261
|
expect(input.modelValue).to.equal('Foo');
|
|
1131
1262
|
});
|
|
1132
|
-
|
|
1133
1263
|
it('clears interaction state', async () => {
|
|
1134
|
-
const el =
|
|
1135
|
-
|
|
1136
|
-
|
|
1264
|
+
const el =
|
|
1265
|
+
/** @type {FormGroup} */
|
|
1266
|
+
await fixture(html`<${tag} touched dirty>${inputSlots}</${tag}>`);
|
|
1137
1267
|
// Safety check initially
|
|
1138
1268
|
// @ts-ignore [allow-protected] in test
|
|
1139
1269
|
el._setValueForAllFormElements('prefilled', true);
|
|
@@ -1151,26 +1281,26 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1151
1281
|
|
|
1152
1282
|
// Reset all children states with prefilled true
|
|
1153
1283
|
// @ts-ignore [allow-protected] in test
|
|
1154
|
-
el._setValueForAllFormElements('modelValue', {
|
|
1284
|
+
el._setValueForAllFormElements('modelValue', {
|
|
1285
|
+
checked: true,
|
|
1286
|
+
}); // not prefilled
|
|
1155
1287
|
el.resetInteractionState();
|
|
1156
1288
|
expect(el.dirty).to.equal(false, 'not "dirty" after 2nd reset');
|
|
1157
1289
|
expect(el.touched).to.equal(false, 'not "touched" after 2nd reset');
|
|
1158
1290
|
// prefilled state is dependant on value
|
|
1159
1291
|
expect(el.prefilled).to.equal(true, '"prefilled" after 2nd reset');
|
|
1160
1292
|
});
|
|
1161
|
-
|
|
1162
1293
|
it('clears submitted state', async () => {
|
|
1163
|
-
const fieldset =
|
|
1164
|
-
|
|
1165
|
-
|
|
1294
|
+
const fieldset =
|
|
1295
|
+
/** @type {FormGroup} */
|
|
1296
|
+
await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
1166
1297
|
fieldset.submitted = true;
|
|
1167
1298
|
fieldset.resetGroup();
|
|
1168
1299
|
expect(fieldset.submitted).to.equal(false);
|
|
1169
|
-
fieldset.formElements.forEach(el => {
|
|
1300
|
+
fieldset.formElements.forEach((el) => {
|
|
1170
1301
|
expect(el.submitted).to.equal(false);
|
|
1171
1302
|
});
|
|
1172
1303
|
});
|
|
1173
|
-
|
|
1174
1304
|
it('has correct validation afterwards', async () => {
|
|
1175
1305
|
class IsCat extends Validator {
|
|
1176
1306
|
static validatorName = 'IsCat';
|
|
@@ -1197,35 +1327,31 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1197
1327
|
return hasError;
|
|
1198
1328
|
}
|
|
1199
1329
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1330
|
+
const el =
|
|
1331
|
+
/** @type {FormGroup} */
|
|
1202
1332
|
await fixture(html`
|
|
1203
1333
|
<${tag} .validators=${[new ColorContainsA()]}>
|
|
1204
1334
|
<${childTag} name="color" .validators=${[new IsCat()]}></${childTag}>
|
|
1205
1335
|
<${childTag} name="color2"></${childTag}>
|
|
1206
1336
|
</${tag}>
|
|
1207
|
-
`)
|
|
1208
|
-
);
|
|
1337
|
+
`);
|
|
1209
1338
|
expect(el.hasFeedbackFor).to.deep.equal(['error']);
|
|
1210
1339
|
expect(el.validationStates.error.ColorContainsA).to.be.true;
|
|
1211
1340
|
expect(el.formElements.color.hasFeedbackFor).to.deep.equal([]);
|
|
1212
|
-
|
|
1213
1341
|
el.formElements.color.modelValue = 'onlyb';
|
|
1214
1342
|
expect(el.hasFeedbackFor).to.deep.equal(['error']);
|
|
1215
1343
|
expect(el.validationStates.error.ColorContainsA).to.be.true;
|
|
1216
1344
|
expect(el.formElements.color.validationStates.error.IsCat).to.be.true;
|
|
1217
|
-
|
|
1218
1345
|
el.formElements.color.modelValue = 'cat';
|
|
1219
1346
|
expect(el.hasFeedbackFor).to.deep.equal([]);
|
|
1220
|
-
|
|
1221
1347
|
el.resetGroup();
|
|
1222
1348
|
expect(el.hasFeedbackFor).to.deep.equal(['error']);
|
|
1223
1349
|
expect(el.validationStates.error.ColorContainsA).to.be.true;
|
|
1224
1350
|
expect(el.formElements.color.hasFeedbackFor).to.deep.equal([]);
|
|
1225
1351
|
});
|
|
1226
|
-
|
|
1227
1352
|
it('has access to `_initialModelValue` based on initial children states', async () => {
|
|
1228
|
-
const el =
|
|
1353
|
+
const el =
|
|
1354
|
+
/** @type {FormGroup} */
|
|
1229
1355
|
await fixture(html`
|
|
1230
1356
|
<${tag}>
|
|
1231
1357
|
<${childTag} name="child[]" .modelValue="${'foo1'}">
|
|
@@ -1233,38 +1359,36 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1233
1359
|
<${childTag} name="child[]" .modelValue="${'bar1'}">
|
|
1234
1360
|
</${childTag}>
|
|
1235
1361
|
</${tag}>
|
|
1236
|
-
`)
|
|
1237
|
-
);
|
|
1362
|
+
`);
|
|
1238
1363
|
await el.updateComplete;
|
|
1239
1364
|
el.modelValue['child[]'] = ['foo2', 'bar2'];
|
|
1240
1365
|
// @ts-ignore [allow-protected] in test
|
|
1241
1366
|
expect(el._initialModelValue['child[]']).to.eql(['foo1', 'bar1']);
|
|
1242
1367
|
});
|
|
1243
|
-
|
|
1244
1368
|
it('does not wrongly recompute `_initialModelValue` after dynamic changes of children', async () => {
|
|
1245
|
-
const el =
|
|
1369
|
+
const el =
|
|
1370
|
+
/** @type {FormGroup} */
|
|
1246
1371
|
await fixture(html`
|
|
1247
1372
|
<${tag}>
|
|
1248
1373
|
<${childTag} name="child[]" .modelValue="${'foo1'}">
|
|
1249
1374
|
</${childTag}>
|
|
1250
1375
|
</${tag}>
|
|
1251
|
-
`)
|
|
1252
|
-
);
|
|
1376
|
+
`);
|
|
1253
1377
|
el.modelValue['child[]'] = ['foo2'];
|
|
1254
|
-
const childEl =
|
|
1378
|
+
const childEl =
|
|
1379
|
+
/** @type {FormGroup} */
|
|
1255
1380
|
await fixture(html`
|
|
1256
1381
|
<${childTag} name="child[]" .modelValue="${'bar1'}">
|
|
1257
1382
|
</${childTag}>
|
|
1258
|
-
`)
|
|
1259
|
-
);
|
|
1383
|
+
`);
|
|
1260
1384
|
el.appendChild(childEl);
|
|
1261
1385
|
// @ts-ignore [allow-protected] in test
|
|
1262
1386
|
expect(el._initialModelValue['child[]']).to.eql(['foo1', 'bar1']);
|
|
1263
1387
|
});
|
|
1264
|
-
|
|
1265
1388
|
describe('resetGroup method', () => {
|
|
1266
1389
|
it('calls resetGroup on children fieldsets', async () => {
|
|
1267
|
-
const el =
|
|
1390
|
+
const el =
|
|
1391
|
+
/** @type {FormGroup} */
|
|
1268
1392
|
await fixture(html`
|
|
1269
1393
|
<${tag} name="parentFieldset">
|
|
1270
1394
|
<${tag} name="childFieldset">
|
|
@@ -1272,16 +1396,15 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1272
1396
|
</${childTag}>
|
|
1273
1397
|
</${tag}>
|
|
1274
1398
|
</${tag}>
|
|
1275
|
-
`)
|
|
1276
|
-
);
|
|
1277
|
-
const childFieldsetEl = /** @type {FormGroup} */ (el.querySelector(tagString));
|
|
1399
|
+
`);
|
|
1400
|
+
const childFieldsetEl = /** @type {FormGroup} */ el.querySelector(tagString);
|
|
1278
1401
|
const resetGroupSpy = sinon.spy(childFieldsetEl, 'resetGroup');
|
|
1279
1402
|
el.resetGroup();
|
|
1280
1403
|
expect(resetGroupSpy.callCount).to.equal(1);
|
|
1281
1404
|
});
|
|
1282
|
-
|
|
1283
1405
|
it('calls reset on children fields', async () => {
|
|
1284
|
-
const el =
|
|
1406
|
+
const el =
|
|
1407
|
+
/** @type {FormGroup} */
|
|
1285
1408
|
await fixture(html`
|
|
1286
1409
|
<${tag} name="parentFieldset">
|
|
1287
1410
|
<${tag} name="childFieldset">
|
|
@@ -1289,18 +1412,17 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1289
1412
|
</${childTag}>
|
|
1290
1413
|
</${tag}>
|
|
1291
1414
|
</${tag}>
|
|
1292
|
-
`)
|
|
1293
|
-
);
|
|
1294
|
-
const childFieldsetEl = /** @type {FormChild} */ (el.querySelector(childTagString));
|
|
1415
|
+
`);
|
|
1416
|
+
const childFieldsetEl = /** @type {FormChild} */ el.querySelector(childTagString);
|
|
1295
1417
|
const resetSpy = sinon.spy(childFieldsetEl, 'reset');
|
|
1296
1418
|
el.resetGroup();
|
|
1297
1419
|
expect(resetSpy.callCount).to.equal(1);
|
|
1298
1420
|
});
|
|
1299
1421
|
});
|
|
1300
|
-
|
|
1301
1422
|
describe('clearGroup method', () => {
|
|
1302
1423
|
it('calls clearGroup on children fieldset', async () => {
|
|
1303
|
-
const el =
|
|
1424
|
+
const el =
|
|
1425
|
+
/** @type {FormGroup} */
|
|
1304
1426
|
await fixture(html`
|
|
1305
1427
|
<${tag} name="parentFieldset">
|
|
1306
1428
|
<${tag} name="childFieldset">
|
|
@@ -1308,16 +1430,15 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1308
1430
|
</${childTag}>
|
|
1309
1431
|
</${tag}>
|
|
1310
1432
|
</${tag}>
|
|
1311
|
-
`)
|
|
1312
|
-
);
|
|
1313
|
-
const childFieldsetEl = /** @type {FormGroup} */ (el.querySelector(tagString));
|
|
1433
|
+
`);
|
|
1434
|
+
const childFieldsetEl = /** @type {FormGroup} */ el.querySelector(tagString);
|
|
1314
1435
|
const clearGroupSpy = sinon.spy(childFieldsetEl, 'clearGroup');
|
|
1315
1436
|
el.clearGroup();
|
|
1316
1437
|
expect(clearGroupSpy.callCount).to.equal(1);
|
|
1317
1438
|
});
|
|
1318
|
-
|
|
1319
1439
|
it('calls clear on children fields', async () => {
|
|
1320
|
-
const el =
|
|
1440
|
+
const el =
|
|
1441
|
+
/** @type {FormGroup} */
|
|
1321
1442
|
await fixture(html`
|
|
1322
1443
|
<${tag} name="parentFieldset">
|
|
1323
1444
|
<${tag} name="childFieldset">
|
|
@@ -1325,16 +1446,15 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1325
1446
|
</${childTag}>
|
|
1326
1447
|
</${tag}>
|
|
1327
1448
|
</${tag}>
|
|
1328
|
-
`)
|
|
1329
|
-
);
|
|
1330
|
-
const childFieldsetEl = /** @type {FormChild} */ (el.querySelector(childTagString));
|
|
1449
|
+
`);
|
|
1450
|
+
const childFieldsetEl = /** @type {FormChild} */ el.querySelector(childTagString);
|
|
1331
1451
|
const clearSpy = sinon.spy(childFieldsetEl, 'clear');
|
|
1332
1452
|
el.clearGroup();
|
|
1333
1453
|
expect(clearSpy.callCount).to.equal(1);
|
|
1334
1454
|
});
|
|
1335
|
-
|
|
1336
1455
|
it('should clear the value of fields', async () => {
|
|
1337
|
-
const el =
|
|
1456
|
+
const el =
|
|
1457
|
+
/** @type {FormGroup} */
|
|
1338
1458
|
await fixture(html`
|
|
1339
1459
|
<${tag} name="parentFieldset">
|
|
1340
1460
|
<${tag} name="childFieldset">
|
|
@@ -1342,73 +1462,84 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1342
1462
|
</${childTag}>
|
|
1343
1463
|
</${tag}>
|
|
1344
1464
|
</${tag}>
|
|
1345
|
-
`)
|
|
1346
|
-
);
|
|
1465
|
+
`);
|
|
1347
1466
|
el.clearGroup();
|
|
1348
|
-
expect(
|
|
1349
|
-
|
|
1350
|
-
)
|
|
1467
|
+
expect(/** @type {FormChild} */ el.querySelector('[name="child"]').modelValue).to.equal(
|
|
1468
|
+
'',
|
|
1469
|
+
);
|
|
1351
1470
|
});
|
|
1352
1471
|
});
|
|
1353
1472
|
});
|
|
1354
|
-
|
|
1355
1473
|
describe('Accessibility', () => {
|
|
1356
1474
|
it('has role="group" set', async () => {
|
|
1357
|
-
const fieldset =
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
fieldset.formElements.
|
|
1475
|
+
const fieldset =
|
|
1476
|
+
/** @type {FormGroup} */
|
|
1477
|
+
await fixture(html`<${tag}>${inputSlots}</${tag}>`);
|
|
1478
|
+
fieldset.formElements['hobbies[]'][0].modelValue = {
|
|
1479
|
+
checked: false,
|
|
1480
|
+
value: 'chess',
|
|
1481
|
+
};
|
|
1482
|
+
fieldset.formElements['hobbies[]'][1].modelValue = {
|
|
1483
|
+
checked: false,
|
|
1484
|
+
value: 'rugby',
|
|
1485
|
+
};
|
|
1486
|
+
fieldset.formElements['gender[]'][0].modelValue = {
|
|
1487
|
+
checked: false,
|
|
1488
|
+
value: 'male',
|
|
1489
|
+
};
|
|
1490
|
+
fieldset.formElements['gender[]'][1].modelValue = {
|
|
1491
|
+
checked: false,
|
|
1492
|
+
value: 'female',
|
|
1493
|
+
};
|
|
1494
|
+
fieldset.formElements.color.modelValue = {
|
|
1495
|
+
checked: false,
|
|
1496
|
+
value: 'blue',
|
|
1497
|
+
};
|
|
1365
1498
|
expect(fieldset.hasAttribute('role')).to.be.true;
|
|
1366
1499
|
expect(fieldset.getAttribute('role')).to.contain('group');
|
|
1367
1500
|
});
|
|
1368
|
-
|
|
1369
1501
|
it('has an aria-labelledby from element with slot="label"', async () => {
|
|
1370
|
-
const el =
|
|
1502
|
+
const el =
|
|
1503
|
+
/** @type {FormGroup} */
|
|
1371
1504
|
await fixture(html`
|
|
1372
1505
|
<${tag}>
|
|
1373
1506
|
<label slot="label">My Label</label>
|
|
1374
1507
|
${inputSlots}
|
|
1375
1508
|
</${tag}>
|
|
1376
|
-
`)
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
Array.from(el.children).find(child => child.slot === 'label')
|
|
1380
|
-
);
|
|
1509
|
+
`);
|
|
1510
|
+
const label =
|
|
1511
|
+
/** @type {HTMLElement} */
|
|
1512
|
+
Array.from(el.children).find((child) => child.slot === 'label');
|
|
1381
1513
|
expect(el.hasAttribute('aria-labelledby')).to.equal(true);
|
|
1382
1514
|
expect(el.getAttribute('aria-labelledby')).contains(label.id);
|
|
1383
1515
|
});
|
|
1384
|
-
|
|
1385
1516
|
it('sets an aria-describedby to its children from element with slot="feedback"', async () => {
|
|
1386
|
-
const el =
|
|
1517
|
+
const el =
|
|
1518
|
+
/** @type {FormGroup} */
|
|
1387
1519
|
await fixture(html`
|
|
1388
1520
|
<${tag}>
|
|
1389
1521
|
<label slot="label">My Label</label>
|
|
1390
1522
|
<div slot="feedback">My Feedback</div>
|
|
1391
1523
|
${inputSlots}
|
|
1392
1524
|
</${tag}>
|
|
1393
|
-
`)
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
Array.from(el.children).find(child => child.slot === 'feedback')
|
|
1397
|
-
);
|
|
1525
|
+
`);
|
|
1526
|
+
const feedback =
|
|
1527
|
+
/** @type {HTMLElement} */
|
|
1528
|
+
Array.from(el.children).find((child) => child.slot === 'feedback');
|
|
1398
1529
|
expect(el.formElements[0]._inputNode.getAttribute('aria-describedby')).contains(
|
|
1399
1530
|
feedback.id,
|
|
1400
1531
|
);
|
|
1401
1532
|
});
|
|
1402
1533
|
});
|
|
1403
|
-
|
|
1404
1534
|
describe('Dynamically rendered children', () => {
|
|
1405
1535
|
class DynamicCWrapper extends LitElement {
|
|
1406
1536
|
static get properties() {
|
|
1407
1537
|
return {
|
|
1408
|
-
fields: {
|
|
1538
|
+
fields: {
|
|
1539
|
+
type: Array,
|
|
1540
|
+
},
|
|
1409
1541
|
};
|
|
1410
1542
|
}
|
|
1411
|
-
|
|
1412
1543
|
constructor() {
|
|
1413
1544
|
super();
|
|
1414
1545
|
/** @type {any[]} */
|
|
@@ -1418,13 +1549,12 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1418
1549
|
/** @type {object|undefined} */
|
|
1419
1550
|
this.serializedValue = undefined;
|
|
1420
1551
|
}
|
|
1421
|
-
|
|
1422
1552
|
render() {
|
|
1423
1553
|
return html`
|
|
1424
1554
|
<${tag}
|
|
1425
1555
|
.modelValue=${this.modelValue}
|
|
1426
1556
|
.serializedValue=${this.serializedValue}>
|
|
1427
|
-
${this.fields.map(field => {
|
|
1557
|
+
${this.fields.map((field) => {
|
|
1428
1558
|
if (typeof field === 'object') {
|
|
1429
1559
|
return html`<${childTag} name="${field.name}" .modelValue="${field.value}"></${childTag}>`;
|
|
1430
1560
|
}
|
|
@@ -1436,114 +1566,119 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1436
1566
|
}
|
|
1437
1567
|
const dynamicChildrenTagString = defineCE(DynamicCWrapper);
|
|
1438
1568
|
const dynamicChildrenTag = unsafeStatic(dynamicChildrenTagString);
|
|
1439
|
-
|
|
1440
1569
|
it(`when rendering children right from the start, sets their values correctly
|
|
1441
1570
|
based on prefilled model/serializedValue`, async () => {
|
|
1442
|
-
const el =
|
|
1571
|
+
const el =
|
|
1572
|
+
/** @type {DynamicCWrapper} */
|
|
1443
1573
|
await fixture(html`
|
|
1444
1574
|
<${dynamicChildrenTag}
|
|
1445
1575
|
.fields="${['firstName', 'lastName']}"
|
|
1446
|
-
.modelValue="${{
|
|
1576
|
+
.modelValue="${{
|
|
1577
|
+
firstName: 'foo',
|
|
1578
|
+
lastName: 'bar',
|
|
1579
|
+
}}"
|
|
1447
1580
|
>
|
|
1448
1581
|
</${dynamicChildrenTag}>
|
|
1449
|
-
`)
|
|
1450
|
-
);
|
|
1582
|
+
`);
|
|
1451
1583
|
await el.updateComplete;
|
|
1452
|
-
const fieldset =
|
|
1453
|
-
/** @type {
|
|
1454
|
-
|
|
1584
|
+
const fieldset =
|
|
1585
|
+
/** @type {FormGroup} */
|
|
1586
|
+
/** @type {ShadowRoot} */ el.shadowRoot.querySelector(tagString);
|
|
1455
1587
|
expect(fieldset.formElements[0].modelValue).to.equal('foo');
|
|
1456
1588
|
expect(fieldset.formElements[1].modelValue).to.equal('bar');
|
|
1457
|
-
|
|
1458
|
-
|
|
1589
|
+
const el2 =
|
|
1590
|
+
/** @type {DynamicCWrapper} */
|
|
1459
1591
|
await fixture(html`
|
|
1460
1592
|
<${dynamicChildrenTag}
|
|
1461
1593
|
.fields="${['firstName', 'lastName']}"
|
|
1462
|
-
.serializedValue="${{
|
|
1594
|
+
.serializedValue="${{
|
|
1595
|
+
firstName: 'foo',
|
|
1596
|
+
lastName: 'bar',
|
|
1597
|
+
}}"
|
|
1463
1598
|
>
|
|
1464
1599
|
</${dynamicChildrenTag}>
|
|
1465
|
-
`)
|
|
1466
|
-
);
|
|
1600
|
+
`);
|
|
1467
1601
|
await el2.updateComplete;
|
|
1468
|
-
const fieldset2 =
|
|
1469
|
-
/** @type {
|
|
1470
|
-
|
|
1602
|
+
const fieldset2 =
|
|
1603
|
+
/** @type {FormGroup} */
|
|
1604
|
+
/** @type {ShadowRoot} */ el2.shadowRoot.querySelector(tagString);
|
|
1471
1605
|
expect(fieldset2.formElements[0].serializedValue).to.equal('foo');
|
|
1472
1606
|
expect(fieldset2.formElements[1].serializedValue).to.equal('bar');
|
|
1473
1607
|
});
|
|
1474
|
-
|
|
1475
1608
|
it(`when rendering children delayed, sets their values
|
|
1476
1609
|
correctly based on prefilled model/serializedValue`, async () => {
|
|
1477
|
-
const el =
|
|
1610
|
+
const el =
|
|
1611
|
+
/** @type {DynamicCWrapper} */
|
|
1478
1612
|
await fixture(html`
|
|
1479
|
-
<${dynamicChildrenTag} .modelValue="${{
|
|
1613
|
+
<${dynamicChildrenTag} .modelValue="${{
|
|
1614
|
+
firstName: 'foo',
|
|
1615
|
+
lastName: 'bar',
|
|
1616
|
+
}}">
|
|
1480
1617
|
</${dynamicChildrenTag}>
|
|
1481
|
-
`)
|
|
1482
|
-
);
|
|
1618
|
+
`);
|
|
1483
1619
|
await el.updateComplete;
|
|
1484
|
-
const fieldset =
|
|
1485
|
-
/** @type {
|
|
1486
|
-
|
|
1620
|
+
const fieldset =
|
|
1621
|
+
/** @type {FormGroup} */
|
|
1622
|
+
/** @type {ShadowRoot} */ el.shadowRoot.querySelector(tagString);
|
|
1487
1623
|
el.fields = ['firstName', 'lastName'];
|
|
1488
1624
|
await el.updateComplete;
|
|
1489
1625
|
expect(fieldset.formElements[0].modelValue).to.equal('foo');
|
|
1490
1626
|
expect(fieldset.formElements[1].modelValue).to.equal('bar');
|
|
1491
|
-
|
|
1492
|
-
|
|
1627
|
+
const el2 =
|
|
1628
|
+
/** @type {DynamicCWrapper} */
|
|
1493
1629
|
await fixture(html`
|
|
1494
|
-
<${dynamicChildrenTag} .serializedValue="${{
|
|
1630
|
+
<${dynamicChildrenTag} .serializedValue="${{
|
|
1631
|
+
firstName: 'foo',
|
|
1632
|
+
lastName: 'bar',
|
|
1633
|
+
}}">
|
|
1495
1634
|
</${dynamicChildrenTag}>
|
|
1496
|
-
`)
|
|
1497
|
-
);
|
|
1635
|
+
`);
|
|
1498
1636
|
await el2.updateComplete;
|
|
1499
|
-
const fieldset2 =
|
|
1500
|
-
/** @type {
|
|
1501
|
-
|
|
1637
|
+
const fieldset2 =
|
|
1638
|
+
/** @type {FormGroup} */
|
|
1639
|
+
/** @type {ShadowRoot} */ el2.shadowRoot.querySelector(tagString);
|
|
1502
1640
|
el2.fields = ['firstName', 'lastName'];
|
|
1503
1641
|
await el2.updateComplete;
|
|
1504
1642
|
expect(fieldset2.formElements[0].serializedValue).to.equal('foo');
|
|
1505
1643
|
expect(fieldset2.formElements[1].serializedValue).to.equal('bar');
|
|
1506
1644
|
});
|
|
1507
|
-
|
|
1508
1645
|
it(`when rendering children partly delayed, sets their values correctly based on
|
|
1509
1646
|
prefilled model/serializedValue`, async () => {
|
|
1510
|
-
const el =
|
|
1647
|
+
const el =
|
|
1648
|
+
/** @type {DynamicCWrapper} */
|
|
1511
1649
|
await fixture(html`
|
|
1512
1650
|
<${dynamicChildrenTag} .fields="${['firstName']}" .modelValue="${{
|
|
1513
1651
|
firstName: 'foo',
|
|
1514
1652
|
lastName: 'bar',
|
|
1515
1653
|
}}">
|
|
1516
1654
|
</${dynamicChildrenTag}>
|
|
1517
|
-
`)
|
|
1518
|
-
);
|
|
1655
|
+
`);
|
|
1519
1656
|
await el.updateComplete;
|
|
1520
|
-
const fieldset =
|
|
1521
|
-
/** @type {
|
|
1522
|
-
|
|
1657
|
+
const fieldset =
|
|
1658
|
+
/** @type {FormGroup} */
|
|
1659
|
+
/** @type {ShadowRoot} */ el.shadowRoot.querySelector(tagString);
|
|
1523
1660
|
el.fields = ['firstName', 'lastName'];
|
|
1524
1661
|
await el.updateComplete;
|
|
1525
1662
|
expect(fieldset.formElements[0].modelValue).to.equal('foo');
|
|
1526
1663
|
expect(fieldset.formElements[1].modelValue).to.equal('bar');
|
|
1527
|
-
|
|
1528
|
-
|
|
1664
|
+
const el2 =
|
|
1665
|
+
/** @type {DynamicCWrapper} */
|
|
1529
1666
|
await fixture(html`
|
|
1530
1667
|
<${dynamicChildrenTag} .fields="${['firstName']}" .serializedValue="${{
|
|
1531
1668
|
firstName: 'foo',
|
|
1532
1669
|
lastName: 'bar',
|
|
1533
1670
|
}}">
|
|
1534
1671
|
</${dynamicChildrenTag}>
|
|
1535
|
-
`)
|
|
1536
|
-
);
|
|
1672
|
+
`);
|
|
1537
1673
|
await el2.updateComplete;
|
|
1538
|
-
const fieldset2 =
|
|
1539
|
-
/** @type {
|
|
1540
|
-
|
|
1674
|
+
const fieldset2 =
|
|
1675
|
+
/** @type {FormGroup} */
|
|
1676
|
+
/** @type {ShadowRoot} */ el2.shadowRoot.querySelector(tagString);
|
|
1541
1677
|
el2.fields = ['firstName', 'lastName'];
|
|
1542
1678
|
await el2.updateComplete;
|
|
1543
1679
|
expect(fieldset2.formElements[0].serializedValue).to.equal('foo');
|
|
1544
1680
|
expect(fieldset2.formElements[1].serializedValue).to.equal('bar');
|
|
1545
1681
|
});
|
|
1546
|
-
|
|
1547
1682
|
it(`does not change interaction states when values set for delayed children`, async () => {
|
|
1548
1683
|
function expectInteractionStatesToBeCorrectFor(/** @type {FormChild|FormGroup} */ elm) {
|
|
1549
1684
|
expect(Boolean(elm.submitted)).to.be.false;
|
|
@@ -1551,88 +1686,94 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1551
1686
|
expect(elm.touched).to.be.false;
|
|
1552
1687
|
expect(elm.prefilled).to.be.true;
|
|
1553
1688
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1689
|
+
const el =
|
|
1690
|
+
/** @type {DynamicCWrapper} */
|
|
1556
1691
|
await fixture(html`
|
|
1557
1692
|
<${dynamicChildrenTag} .fields="${['firstName']}" .modelValue="${{
|
|
1558
1693
|
firstName: 'foo',
|
|
1559
1694
|
lastName: 'bar',
|
|
1560
1695
|
}}">
|
|
1561
1696
|
</${dynamicChildrenTag}>
|
|
1562
|
-
`)
|
|
1563
|
-
);
|
|
1697
|
+
`);
|
|
1564
1698
|
await el.updateComplete;
|
|
1565
|
-
const fieldset =
|
|
1566
|
-
/** @type {
|
|
1567
|
-
|
|
1699
|
+
const fieldset =
|
|
1700
|
+
/** @type {FormGroup} */
|
|
1701
|
+
/** @type {ShadowRoot} */ el.shadowRoot.querySelector(tagString);
|
|
1568
1702
|
await fieldset.registrationComplete;
|
|
1569
|
-
|
|
1570
1703
|
el.fields = ['firstName', 'lastName'];
|
|
1571
1704
|
await el.updateComplete;
|
|
1572
1705
|
expectInteractionStatesToBeCorrectFor(fieldset.formElements[0]);
|
|
1573
1706
|
expectInteractionStatesToBeCorrectFor(fieldset.formElements[1]);
|
|
1574
1707
|
expectInteractionStatesToBeCorrectFor(fieldset);
|
|
1575
|
-
|
|
1576
|
-
|
|
1708
|
+
const el2 =
|
|
1709
|
+
/** @type {DynamicCWrapper} */
|
|
1577
1710
|
await fixture(html`
|
|
1578
1711
|
<${dynamicChildrenTag} .fields="${['firstName']}" .serializedValue="${{
|
|
1579
1712
|
firstName: 'foo',
|
|
1580
1713
|
lastName: 'bar',
|
|
1581
1714
|
}}">
|
|
1582
1715
|
</${dynamicChildrenTag}>
|
|
1583
|
-
`)
|
|
1584
|
-
);
|
|
1716
|
+
`);
|
|
1585
1717
|
await el2.updateComplete;
|
|
1586
|
-
const fieldset2 =
|
|
1587
|
-
/** @type {
|
|
1588
|
-
|
|
1718
|
+
const fieldset2 =
|
|
1719
|
+
/** @type {FormGroup} */
|
|
1720
|
+
/** @type {ShadowRoot} */ el2.shadowRoot.querySelector(tagString);
|
|
1589
1721
|
await fieldset2.registrationComplete;
|
|
1590
|
-
|
|
1591
1722
|
el2.fields = ['firstName', 'lastName'];
|
|
1592
1723
|
await el2.updateComplete;
|
|
1593
1724
|
expectInteractionStatesToBeCorrectFor(fieldset2.formElements[0]);
|
|
1594
1725
|
expectInteractionStatesToBeCorrectFor(fieldset2.formElements[1]);
|
|
1595
1726
|
expectInteractionStatesToBeCorrectFor(fieldset2);
|
|
1596
1727
|
});
|
|
1597
|
-
|
|
1598
1728
|
it(`prefilled children values take precedence over parent values`, async () => {
|
|
1599
|
-
const el =
|
|
1729
|
+
const el =
|
|
1730
|
+
/** @type {DynamicCWrapper} */
|
|
1600
1731
|
await fixture(html`
|
|
1601
1732
|
<${dynamicChildrenTag} .modelValue="${{
|
|
1602
1733
|
firstName: 'foo',
|
|
1603
1734
|
lastName: 'bar',
|
|
1604
1735
|
}}">
|
|
1605
1736
|
</${dynamicChildrenTag}>
|
|
1606
|
-
`)
|
|
1607
|
-
);
|
|
1737
|
+
`);
|
|
1608
1738
|
await el.updateComplete;
|
|
1609
|
-
const fieldset =
|
|
1610
|
-
/** @type {
|
|
1611
|
-
|
|
1739
|
+
const fieldset =
|
|
1740
|
+
/** @type {FormGroup} */
|
|
1741
|
+
/** @type {ShadowRoot} */ el.shadowRoot.querySelector(tagString);
|
|
1612
1742
|
el.fields = [
|
|
1613
|
-
{
|
|
1614
|
-
|
|
1743
|
+
{
|
|
1744
|
+
name: 'firstName',
|
|
1745
|
+
value: 'wins',
|
|
1746
|
+
},
|
|
1747
|
+
{
|
|
1748
|
+
name: 'lastName',
|
|
1749
|
+
value: 'winsAsWell',
|
|
1750
|
+
},
|
|
1615
1751
|
];
|
|
1616
1752
|
await el.updateComplete;
|
|
1617
1753
|
expect(fieldset.formElements[0].modelValue).to.equal('wins');
|
|
1618
1754
|
expect(fieldset.formElements[1].modelValue).to.equal('winsAsWell');
|
|
1619
|
-
|
|
1620
|
-
|
|
1755
|
+
const el2 =
|
|
1756
|
+
/** @type {DynamicCWrapper} */
|
|
1621
1757
|
await fixture(html`
|
|
1622
1758
|
<${dynamicChildrenTag} .serializedValue="${{
|
|
1623
1759
|
firstName: 'foo',
|
|
1624
1760
|
lastName: 'bar',
|
|
1625
1761
|
}}">
|
|
1626
1762
|
</${dynamicChildrenTag}>
|
|
1627
|
-
`)
|
|
1628
|
-
);
|
|
1763
|
+
`);
|
|
1629
1764
|
await el2.updateComplete;
|
|
1630
|
-
const fieldset2 =
|
|
1631
|
-
/** @type {
|
|
1632
|
-
|
|
1765
|
+
const fieldset2 =
|
|
1766
|
+
/** @type {FormGroup} */
|
|
1767
|
+
/** @type {ShadowRoot} */ el2.shadowRoot.querySelector(tagString);
|
|
1633
1768
|
el2.fields = [
|
|
1634
|
-
{
|
|
1635
|
-
|
|
1769
|
+
{
|
|
1770
|
+
name: 'firstName',
|
|
1771
|
+
value: 'wins',
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
name: 'lastName',
|
|
1775
|
+
value: 'winsAsWell',
|
|
1776
|
+
},
|
|
1636
1777
|
];
|
|
1637
1778
|
await el2.updateComplete;
|
|
1638
1779
|
expect(fieldset2.formElements[0].serializedValue).to.equal('wins');
|