Skip to content

Commit

Permalink
fix: add missing combo-box mixin classes (#3082) (#3091)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Nov 19, 2021
1 parent cec9659 commit a666fcb
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 20 deletions.
6 changes: 6 additions & 0 deletions packages/combo-box/src/vaadin-combo-box-light.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Copyright (c) 2021 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
import { ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
Expand Down Expand Up @@ -127,6 +130,9 @@ declare class ComboBoxLight<TItem = ComboBoxDefaultItem> extends HTMLElement {
interface ComboBoxLight<TItem = ComboBoxDefaultItem>
extends ComboBoxDataProviderMixinClass<TItem>,
ComboBoxMixinClass<TItem>,
KeyboardMixinClass,
InputMixinClass,
DisabledMixinClass,
ThemableMixinClass {}

declare global {
Expand Down
20 changes: 20 additions & 0 deletions packages/combo-box/src/vaadin-combo-box.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
import { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
import { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
import { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
import { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
import { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
import { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
import { PatternMixinClass } from '@vaadin/field-base/src/pattern-mixin.js';
import { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
import { ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
Expand Down Expand Up @@ -206,8 +216,18 @@ declare class ComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
interface ComboBox<TItem = ComboBoxDefaultItem>
extends ComboBoxDataProviderMixinClass<TItem>,
ComboBoxMixinClass<TItem>,
ValidateMixinClass,
PatternMixinClass,
LabelMixinClass,
KeyboardMixinClass,
InputMixinClass,
InputControlMixinClass,
InputConstraintsMixinClass,
FocusMixinClass,
FieldMixinClass,
DisabledMixinClass,
DelegateStateMixinClass,
DelegateFocusMixinClass,
ThemableMixinClass,
ElementMixinClass,
ControllerMixinClass {}
Expand Down
119 changes: 99 additions & 20 deletions packages/combo-box/test/typings/combo-box.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
import { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
import { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
import { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
import { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
import { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
import { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
import { PatternMixinClass } from '@vaadin/field-base/src/pattern-mixin.js';
import { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin';
import { ComboBoxDataProviderMixinClass } from '../../src/vaadin-combo-box-data-provider-mixin';
import { ComboBoxMixinClass } from '../../src/vaadin-combo-box-mixin';
Expand All @@ -9,6 +21,7 @@ import {
ComboBoxFilterChangedEvent,
ComboBoxInvalidChangedEvent,
ComboBoxOpenedChangedEvent,
ComboBoxRenderer,
ComboBoxSelectedItemChangedEvent,
ComboBoxValueChangedEvent
} from '../../vaadin-combo-box';
Expand All @@ -28,16 +41,11 @@ interface TestComboBoxItem {

const assertType = <TExpected>(actual: TExpected) => actual;

/* ComboBoxElement */
/* ComboBox */
const genericComboBox = document.createElement('vaadin-combo-box');
assertType<ComboBox>(genericComboBox);

const narrowedComboBox = genericComboBox as ComboBox<TestComboBoxItem>;
assertType<ComboBox>(narrowedComboBox);
assertType<ControllerMixinClass>(narrowedComboBox);
assertType<ElementMixinClass>(narrowedComboBox);
assertType<ComboBoxDataProviderMixinClass<TestComboBoxItem>>(narrowedComboBox);
assertType<ComboBoxMixinClass<TestComboBoxItem>>(narrowedComboBox);
assertType<ThemableMixinClass>(narrowedComboBox);

narrowedComboBox.addEventListener('custom-value-set', (event) => {
assertType<ComboBoxCustomValueSetEvent>(event);
Expand Down Expand Up @@ -69,41 +77,112 @@ narrowedComboBox.addEventListener('selected-item-changed', (event) => {
assertType<TestComboBoxItem | null | undefined>(event.detail.value);
});

/* ComboBoxLightElement */
const genericComboBoxLightElement = document.createElement('vaadin-combo-box-light');
assertType<ComboBoxLight>(genericComboBoxLightElement);
// ComboBox properties
assertType<() => boolean>(narrowedComboBox.checkValidity);
assertType<() => boolean>(narrowedComboBox.validate);
assertType<() => void>(narrowedComboBox.close);
assertType<() => void>(narrowedComboBox.open);
assertType<() => void>(narrowedComboBox.requestContentUpdate);
assertType<boolean>(narrowedComboBox.allowCustomValue);
assertType<boolean>(narrowedComboBox.autofocus);
assertType<boolean>(narrowedComboBox.autoselect);
assertType<boolean | null | undefined>(narrowedComboBox.autoOpenDisabled);
assertType<boolean>(narrowedComboBox.opened);
assertType<string>(narrowedComboBox.filter);
assertType<TestComboBoxItem[] | undefined>(narrowedComboBox.filteredItems);
assertType<TestComboBoxItem[] | undefined>(narrowedComboBox.items);
assertType<string | null | undefined>(narrowedComboBox.itemIdPath);
assertType<string>(narrowedComboBox.itemLabelPath);
assertType<string>(narrowedComboBox.itemValuePath);
assertType<boolean>(narrowedComboBox.loading);
assertType<ComboBoxRenderer<TestComboBoxItem> | null | undefined>(narrowedComboBox.renderer);
assertType<TestComboBoxItem | null | undefined>(narrowedComboBox.selectedItem);
assertType<boolean>(narrowedComboBox.invalid);
assertType<HTMLElement | null | undefined>(narrowedComboBox.focusElement);
assertType<boolean>(narrowedComboBox.disabled);
assertType<boolean>(narrowedComboBox.clearButtonVisible);
assertType<string | null | undefined>(narrowedComboBox.errorMessage);
assertType<string>(narrowedComboBox.placeholder);
assertType<string | null | undefined>(narrowedComboBox.helperText);
assertType<string>(narrowedComboBox.pattern);
assertType<boolean | null | undefined>(narrowedComboBox.preventInvalidInput);
assertType<boolean>(narrowedComboBox.readonly);
assertType<string | null | undefined>(narrowedComboBox.label);
assertType<string>(narrowedComboBox.value);
assertType<boolean>(narrowedComboBox.required);
assertType<string>(narrowedComboBox.name);

// ComboBox mixins
assertType<ComboBoxDataProviderMixinClass<TestComboBoxItem>>(narrowedComboBox);
assertType<ComboBoxMixinClass<TestComboBoxItem>>(narrowedComboBox);
assertType<ControllerMixinClass>(narrowedComboBox);
assertType<ElementMixinClass>(narrowedComboBox);
assertType<DelegateFocusMixinClass>(narrowedComboBox);
assertType<DelegateStateMixinClass>(narrowedComboBox);
assertType<DisabledMixinClass>(narrowedComboBox);
assertType<FieldMixinClass>(narrowedComboBox);
assertType<FocusMixinClass>(narrowedComboBox);
assertType<InputConstraintsMixinClass>(narrowedComboBox);
assertType<InputControlMixinClass>(narrowedComboBox);
assertType<InputMixinClass>(narrowedComboBox);
assertType<KeyboardMixinClass>(narrowedComboBox);
assertType<LabelMixinClass>(narrowedComboBox);
assertType<PatternMixinClass>(narrowedComboBox);
assertType<ValidateMixinClass>(narrowedComboBox);
assertType<ThemableMixinClass>(narrowedComboBox);

/* ComboBoxLight */
const genericComboBoxLight = document.createElement('vaadin-combo-box-light');
assertType<ComboBoxLight>(genericComboBoxLight);

const narrowedComboBoxLightElement = genericComboBoxLightElement as ComboBoxLight<TestComboBoxItem>;
assertType<ComboBoxDataProviderMixinClass<TestComboBoxItem>>(narrowedComboBoxLightElement);
assertType<ComboBoxMixinClass<TestComboBoxItem>>(narrowedComboBoxLightElement);
assertType<ThemableMixinClass>(narrowedComboBoxLightElement);
const narrowedComboBoxLight = genericComboBoxLight as ComboBoxLight<TestComboBoxItem>;

narrowedComboBoxLightElement.addEventListener('custom-value-set', (event) => {
narrowedComboBoxLight.addEventListener('custom-value-set', (event) => {
assertType<ComboBoxLightCustomValueSetEvent>(event);
assertType<string>(event.detail);
});

narrowedComboBoxLightElement.addEventListener('opened-changed', (event) => {
narrowedComboBoxLight.addEventListener('opened-changed', (event) => {
assertType<ComboBoxLightOpenedChangedEvent>(event);
assertType<boolean>(event.detail.value);
});

narrowedComboBoxLightElement.addEventListener('invalid-changed', (event) => {
narrowedComboBoxLight.addEventListener('invalid-changed', (event) => {
assertType<ComboBoxLightInvalidChangedEvent>(event);
assertType<boolean>(event.detail.value);
});

narrowedComboBoxLightElement.addEventListener('value-changed', (event) => {
narrowedComboBoxLight.addEventListener('value-changed', (event) => {
assertType<ComboBoxLightValueChangedEvent>(event);
assertType<string>(event.detail.value);
});

narrowedComboBoxLightElement.addEventListener('filter-changed', (event) => {
narrowedComboBoxLight.addEventListener('filter-changed', (event) => {
assertType<ComboBoxLightFilterChangedEvent>(event);
assertType<string>(event.detail.value);
});

narrowedComboBoxLightElement.addEventListener('selected-item-changed', (event) => {
narrowedComboBoxLight.addEventListener('selected-item-changed', (event) => {
assertType<ComboBoxLightSelectedItemChangedEvent<TestComboBoxItem>>(event);
assertType<TestComboBoxItem | null | undefined>(event.detail.value);
});

// ComboBoxLight properties
assertType<() => boolean>(narrowedComboBoxLight.checkValidity);
assertType<() => boolean>(narrowedComboBoxLight.validate);
assertType<() => void>(narrowedComboBoxLight.close);
assertType<() => void>(narrowedComboBoxLight.open);
assertType<boolean | null | undefined>(narrowedComboBoxLight.autoOpenDisabled);
assertType<boolean>(narrowedComboBoxLight.opened);
assertType<boolean>(narrowedComboBoxLight.invalid);
assertType<boolean>(narrowedComboBoxLight.disabled);
assertType<boolean>(narrowedComboBoxLight.readonly);
assertType<string>(narrowedComboBoxLight.value);

// ComboBoxLight mixins
assertType<ComboBoxDataProviderMixinClass<TestComboBoxItem>>(narrowedComboBoxLight);
assertType<ComboBoxMixinClass<TestComboBoxItem>>(narrowedComboBoxLight);
assertType<DisabledMixinClass>(narrowedComboBoxLight);
assertType<InputMixinClass>(narrowedComboBoxLight);
assertType<KeyboardMixinClass>(narrowedComboBoxLight);
assertType<ThemableMixinClass>(narrowedComboBoxLight);

0 comments on commit a666fcb

Please sign in to comment.