diff --git a/src/material-experimental/mdc-chips/chip-input.ts b/src/material-experimental/mdc-chips/chip-input.ts index e77a2aa98d63..18d3f2ad2453 100644 --- a/src/material-experimental/mdc-chips/chip-input.ts +++ b/src/material-experimental/mdc-chips/chip-input.ts @@ -27,21 +27,13 @@ import {MatChipTextControl} from './chip-text-control'; /** Represents an input event on a `matChipInput`. */ export interface MatChipInputEvent { - /** - * The native `` element that the event is being fired for. - * @deprecated Use `MatChipInputEvent#chipInput.inputElement` instead. - * @breaking-change 13.0.0 This property will be removed. - */ - input: HTMLInputElement; - /** The value of the input. */ value: string; /** * Reference to the chip input that emitted the event. - * @breaking-change 13.0.0 This property will be made required. */ - chipInput?: MatChipInput; + chipInput: MatChipInput; } // Increasing integer for generating unique ids. @@ -215,7 +207,6 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha if (!event || this._isSeparatorKey(event)) { this.chipEnd.emit({ - input: this.inputElement, value: this.inputElement.value, chipInput: this, }); diff --git a/src/material-experimental/mdc-chips/testing/chip-harness.ts b/src/material-experimental/mdc-chips/testing/chip-harness.ts index 2ca3a9f0757d..51ad1df02053 100644 --- a/src/material-experimental/mdc-chips/testing/chip-harness.ts +++ b/src/material-experimental/mdc-chips/testing/chip-harness.ts @@ -19,11 +19,11 @@ import {MatChipRemoveHarness} from './chip-remove-harness'; export class MatChipHarness extends ContentContainerComponentHarness { static hostSelector = '.mat-mdc-basic-chip, .mat-mdc-chip'; + // Note(mmalerba): generics are used as a workaround for lack of polymorphic `this` in static + // methods. See https://github.com/microsoft/TypeScript/issues/5863 /** * Gets a `HarnessPredicate` that can be used to search for a chip with specific attributes. */ - // Note(mmalerba): generics are used as a workaround for lack of polymorphic `this` in static - // methods. See https://github.com/microsoft/TypeScript/issues/5863 static with(this: T, options: ChipHarnessFilters = {}): HarnessPredicate> { return new HarnessPredicate(MatChipHarness, options) diff --git a/src/material-experimental/mdc-chips/testing/chip-option-harness.ts b/src/material-experimental/mdc-chips/testing/chip-option-harness.ts index 059201609d7b..bb40b391501c 100644 --- a/src/material-experimental/mdc-chips/testing/chip-option-harness.ts +++ b/src/material-experimental/mdc-chips/testing/chip-option-harness.ts @@ -14,12 +14,12 @@ import {ChipOptionHarnessFilters} from './chip-harness-filters'; export class MatChipOptionHarness extends MatChipHarness { static override hostSelector = '.mat-mdc-chip-option'; + // Note(mmalerba): generics are used as a workaround for lack of polymorphic `this` in static + // methods. See https://github.com/microsoft/TypeScript/issues/5863 /** * Gets a `HarnessPredicate` that can be used to search for a chip option with specific * attributes. */ - // Note(mmalerba): generics are used as a workaround for lack of polymorphic `this` in static - // methods. See https://github.com/microsoft/TypeScript/issues/5863 static override with( this: T, options: ChipOptionHarnessFilters = {}): HarnessPredicate> { return new HarnessPredicate(MatChipOptionHarness, options) diff --git a/src/material/chips/chip-input.ts b/src/material/chips/chip-input.ts index 72d74072e629..f743b8b5c858 100644 --- a/src/material/chips/chip-input.ts +++ b/src/material/chips/chip-input.ts @@ -25,21 +25,13 @@ import {MatChipTextControl} from './chip-text-control'; /** Represents an input event on a `matChipInput`. */ export interface MatChipInputEvent { - /** - * The native `` element that the event is being fired for. - * @deprecated Use `MatChipInputEvent#chipInput.inputElement` instead. - * @breaking-change 13.0.0 This property will be removed. - */ - input: HTMLInputElement; - /** The value of the input. */ value: string; /** * Reference to the chip input that emitted the event. - * @breaking-change 13.0.0 This property will be made required. */ - chipInput?: MatChipInput; + chipInput: MatChipInput; } // Increasing integer for generating unique ids. @@ -201,7 +193,6 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A if (!event || this._isSeparatorKey(event)) { this.chipEnd.emit({ - input: this.inputElement, value: this.inputElement.value, chipInput: this, }); diff --git a/src/material/chips/testing/chip-harness-filters.ts b/src/material/chips/testing/chip-harness-filters.ts index c3926451b4ad..5f3007bae293 100644 --- a/src/material/chips/testing/chip-harness-filters.ts +++ b/src/material/chips/testing/chip-harness-filters.ts @@ -11,12 +11,6 @@ import {BaseHarnessFilters} from '@angular/cdk/testing'; export interface ChipHarnessFilters extends BaseHarnessFilters { /** Only find instances whose text matches the given value. */ text?: string | RegExp; - /** - * Only find chip instances whose selected state matches the given value. - * @deprecated Use `MatChipOptionHarness` together with `ChipOptionHarnessFilters`. - * @breaking-change 12.0.0 - */ - selected?: boolean; } /** A set of criteria that can be used to filter a list of selectable chip instances. */ diff --git a/src/material/chips/testing/chip-harness.ts b/src/material/chips/testing/chip-harness.ts index e993e6c14dfd..775231825eee 100644 --- a/src/material/chips/testing/chip-harness.ts +++ b/src/material/chips/testing/chip-harness.ts @@ -26,12 +26,12 @@ export class MatChipHarness extends ContentContainerComponentHarness { * @param options Options for filtering which chip instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ - static with(options: ChipHarnessFilters = {}): HarnessPredicate { + static with(options: ChipHarnessFilters = {}): + HarnessPredicate> { return new HarnessPredicate(MatChipHarness, options) - .addOption('text', options.text, - (harness, label) => HarnessPredicate.stringMatches(harness.getText(), label)) - .addOption('selected', options.selected, - async (harness, selected) => (await harness.isSelected()) === selected); + .addOption('text', options.text, (harness, label) => { + return HarnessPredicate.stringMatches(harness.getText(), label); + }) as unknown as HarnessPredicate>; } /** Gets the text of the chip. */ @@ -41,51 +41,11 @@ export class MatChipHarness extends ContentContainerComponentHarness { }); } - /** - * Whether the chip is selected. - * @deprecated Use `MatChipOptionHarness.isSelected` instead. - * @breaking-change 12.0.0 - */ - async isSelected(): Promise { - return (await this.host()).hasClass('mat-chip-selected'); - } - /** Whether the chip is disabled. */ async isDisabled(): Promise { return (await this.host()).hasClass('mat-chip-disabled'); } - /** - * Selects the given chip. Only applies if it's selectable. - * @deprecated Use `MatChipOptionHarness.select` instead. - * @breaking-change 12.0.0 - */ - async select(): Promise { - if (!(await this.isSelected())) { - await this.toggle(); - } - } - - /** - * Deselects the given chip. Only applies if it's selectable. - * @deprecated Use `MatChipOptionHarness.deselect` instead. - * @breaking-change 12.0.0 - */ - async deselect(): Promise { - if (await this.isSelected()) { - await this.toggle(); - } - } - - /** - * Toggles the selected state of the given chip. Only applies if it's selectable. - * @deprecated Use `MatChipOptionHarness.toggle` instead. - * @breaking-change 12.0.0 - */ - async toggle(): Promise { - return (await this.host()).sendKeys(' '); - } - /** Removes the given chip. Only applies if it's removable. */ async remove(): Promise { await (await this.host()).sendKeys(TestKey.DELETE); diff --git a/src/material/chips/testing/chip-list-harness.ts b/src/material/chips/testing/chip-list-harness.ts index 83b89cb35ce6..791169b9658a 100644 --- a/src/material/chips/testing/chip-list-harness.ts +++ b/src/material/chips/testing/chip-list-harness.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ComponentHarness, HarnessPredicate, parallel} from '@angular/cdk/testing'; +import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing'; import {MatChipHarness} from './chip-harness'; import {MatChipInputHarness} from './chip-input-harness'; import { @@ -67,21 +67,6 @@ export class MatChipListHarness extends _MatChipListHarnessBase { return this.locatorForAll(MatChipHarness.with(filter))(); } - /** - * Selects a chip inside the chip list. - * @param filter An optional filter to apply to the child chips. - * All the chips matching the filter will be selected. - * @deprecated Use `MatChipListboxHarness.selectChips` instead. - * @breaking-change 12.0.0 - */ - async selectChips(filter: ChipHarnessFilters = {}): Promise { - const chips = await this.getChips(filter); - if (!chips.length) { - throw Error(`Cannot find chip matching filter ${JSON.stringify(filter)}`); - } - await parallel(() => chips.map(chip => chip.select())); - } - /** * Gets the `MatChipInput` inside the chip list. * @param filter Optionally filters which chip input is included. diff --git a/src/material/chips/testing/chip-option-harness.ts b/src/material/chips/testing/chip-option-harness.ts index 2f78d60cb8c7..c0ee76fd3ccc 100644 --- a/src/material/chips/testing/chip-option-harness.ts +++ b/src/material/chips/testing/chip-option-harness.ts @@ -14,42 +14,46 @@ export class MatChipOptionHarness extends MatChipHarness { /** The selector for the host element of a selectable chip instance. */ static override hostSelector = '.mat-chip'; + // Note(mmalerba): generics are used as a workaround for lack of polymorphic `this` in static + // methods. See https://github.com/microsoft/TypeScript/issues/5863 /** * Gets a `HarnessPredicate` that can be used to search for a `MatChipOptionHarness` * that meets certain criteria. * @param options Options for filtering which chip instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ - static override with(options: ChipOptionHarnessFilters = {}): - HarnessPredicate { + static override with( + this: T, options: ChipOptionHarnessFilters = {}): + HarnessPredicate> { return new HarnessPredicate(MatChipOptionHarness, options) .addOption('text', options.text, (harness, label) => HarnessPredicate.stringMatches(harness.getText(), label)) .addOption('selected', options.selected, - async (harness, selected) => (await harness.isSelected()) === selected); + async (harness, selected) => (await harness.isSelected()) === selected) as + unknown as HarnessPredicate>; } /** Whether the chip is selected. */ - override async isSelected(): Promise { + async isSelected(): Promise { return (await this.host()).hasClass('mat-chip-selected'); } /** Selects the given chip. Only applies if it's selectable. */ - override async select(): Promise { + async select(): Promise { if (!(await this.isSelected())) { await this.toggle(); } } /** Deselects the given chip. Only applies if it's selectable. */ - override async deselect(): Promise { + async deselect(): Promise { if (await this.isSelected()) { await this.toggle(); } } /** Toggles the selected state of the given chip. */ - override async toggle(): Promise { + async toggle(): Promise { return (await this.host()).sendKeys(' '); } } diff --git a/tools/public_api_guard/material/chips-testing.md b/tools/public_api_guard/material/chips-testing.md index e993d3a879ea..6134cf5292f7 100644 --- a/tools/public_api_guard/material/chips-testing.md +++ b/tools/public_api_guard/material/chips-testing.md @@ -16,8 +16,6 @@ export interface ChipAvatarHarnessFilters extends BaseHarnessFilters { // @public export interface ChipHarnessFilters extends BaseHarnessFilters { - // @deprecated - selected?: boolean; text?: string | RegExp; } @@ -46,21 +44,13 @@ export interface ChipRemoveHarnessFilters extends BaseHarnessFilters { // @public export class MatChipHarness extends ContentContainerComponentHarness { - // @deprecated - deselect(): Promise; getAvatar(filter?: ChipAvatarHarnessFilters): Promise; getRemoveButton(filter?: ChipRemoveHarnessFilters): Promise; getText(): Promise; static hostSelector: string; isDisabled(): Promise; - // @deprecated - isSelected(): Promise; remove(): Promise; - // @deprecated - select(): Promise; - // @deprecated - toggle(): Promise; - static with(options?: ChipHarnessFilters): HarnessPredicate; + static with(options?: ChipHarnessFilters): HarnessPredicate>; } // @public @@ -92,8 +82,6 @@ export class MatChipListHarness extends _MatChipListHarnessBase { getChips(filter?: ChipHarnessFilters): Promise; getInput(filter?: ChipInputHarnessFilters): Promise; static hostSelector: string; - // @deprecated - selectChips(filter?: ChipHarnessFilters): Promise; static with(options?: ChipListHarnessFilters): HarnessPredicate; } @@ -104,7 +92,7 @@ export class MatChipOptionHarness extends MatChipHarness { isSelected(): Promise; select(): Promise; toggle(): Promise; - static with(options?: ChipOptionHarnessFilters): HarnessPredicate; + static with(this: T, options?: ChipOptionHarnessFilters): HarnessPredicate>; } // @public diff --git a/tools/public_api_guard/material/chips.md b/tools/public_api_guard/material/chips.md index c55e68db5839..aa0dcdd9f3ba 100644 --- a/tools/public_api_guard/material/chips.md +++ b/tools/public_api_guard/material/chips.md @@ -188,9 +188,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A // @public export interface MatChipInputEvent { - chipInput?: MatChipInput; - // @deprecated - input: HTMLInputElement; + chipInput: MatChipInput; value: string; }