From 67191681921550b7e4e0c587880e4db25686c589 Mon Sep 17 00:00:00 2001 From: Boyi Li Date: Fri, 27 Oct 2023 14:26:30 -0700 Subject: [PATCH] feat(material/chips): expose _chipGrid in MatChipInput and add a stream of chip removal events (#28012) (#28013) --- src/material/chips/chip-input.ts | 5 ++++- src/material/chips/chip-set.ts | 7 ++++++- tools/public_api_guard/material/chips.md | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/material/chips/chip-input.ts b/src/material/chips/chip-input.ts index b4b2d9428e32..e0a8161c06a6 100644 --- a/src/material/chips/chip-input.ts +++ b/src/material/chips/chip-input.ts @@ -75,16 +75,19 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha /** Whether the control is focused. */ focused: boolean = false; - _chipGrid: MatChipGrid; /** Register input for chip list */ @Input('matChipInputFor') + get chipGrid(): MatChipGrid { + return this._chipGrid; + } set chipGrid(value: MatChipGrid) { if (value) { this._chipGrid = value; this._chipGrid.registerInput(this); } } + private _chipGrid: MatChipGrid; /** * Whether or not the chipEnd event will be emitted when the input is blurred. diff --git a/src/material/chips/chip-set.ts b/src/material/chips/chip-set.ts index e85da22a55d0..45ae22bc0eb4 100644 --- a/src/material/chips/chip-set.ts +++ b/src/material/chips/chip-set.ts @@ -80,11 +80,16 @@ export class MatChipSet return this._getChipStream(chip => chip._onFocus); } - /** Combined stream of all of the child chips' remove events. */ + /** Combined stream of all of the child chips' destroy events. */ get chipDestroyedChanges(): Observable { return this._getChipStream(chip => chip.destroyed); } + /** Combined stream of all of the child chips' remove events. */ + get chipRemovedChanges(): Observable { + return this._getChipStream(chip => chip.removed); + } + /** Whether the chip set is disabled. */ @Input() get disabled(): boolean { diff --git a/tools/public_api_guard/material/chips.md b/tools/public_api_guard/material/chips.md index 66a167b61624..38d0123d2057 100644 --- a/tools/public_api_guard/material/chips.md +++ b/tools/public_api_guard/material/chips.md @@ -243,9 +243,8 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha _addOnBlur: boolean; _blur(): void; readonly chipEnd: EventEmitter; + get chipGrid(): MatChipGrid; set chipGrid(value: MatChipGrid); - // (undocumented) - _chipGrid: MatChipGrid; clear(): void; get disabled(): boolean; set disabled(value: BooleanInput); @@ -443,6 +442,7 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterViewInit, H _chipActions: QueryList; get chipDestroyedChanges(): Observable; get chipFocusChanges(): Observable; + get chipRemovedChanges(): Observable; _chips: QueryList; protected _defaultRole: string; protected _destroyed: Subject;