@@ -23,7 +23,8 @@ import {takeUntil} from 'rxjs/operators';
2323import { MatChip , MatChipEvent } from './chip' ;
2424import { MatChipAction } from './chip-action' ;
2525import { MatChipEditInput } from './chip-edit-input' ;
26- import { MAT_CHIP } from './tokens' ;
26+ import { MatChipEdit } from './chip-icons' ;
27+ import { MAT_CHIP , MAT_CHIP_EDIT } from './tokens' ;
2728
2829/** Represents an event fired on an individual `mat-chip` when it is edited. */
2930export interface MatChipEditedEvent extends MatChipEvent {
@@ -41,15 +42,15 @@ export interface MatChipEditedEvent extends MatChipEvent {
4142 styleUrl : 'chip.css' ,
4243 host : {
4344 'class' : 'mat-mdc-chip mat-mdc-chip-row mdc-evolution-chip' ,
44- '[class.mat-mdc-chip-with-avatar]' : 'leadingIcon ' ,
45+ '[class.mat-mdc-chip-with-avatar]' : '_hasLeadingIcon() ' ,
4546 '[class.mat-mdc-chip-disabled]' : 'disabled' ,
4647 '[class.mat-mdc-chip-editing]' : '_isEditing' ,
4748 '[class.mat-mdc-chip-editable]' : 'editable' ,
4849 '[class.mdc-evolution-chip--disabled]' : 'disabled' ,
4950 '[class.mdc-evolution-chip--with-trailing-action]' : '_hasTrailingIcon()' ,
50- '[class.mdc-evolution-chip--with-primary-graphic]' : 'leadingIcon ' ,
51- '[class.mdc-evolution-chip--with-primary-icon]' : 'leadingIcon ' ,
52- '[class.mdc-evolution-chip--with-avatar]' : 'leadingIcon ' ,
51+ '[class.mdc-evolution-chip--with-primary-graphic]' : '_hasLeadingIcon() ' ,
52+ '[class.mdc-evolution-chip--with-primary-icon]' : '_hasLeadingIcon() ' ,
53+ '[class.mdc-evolution-chip--with-avatar]' : '_hasLeadingIcon() ' ,
5354 '[class.mat-mdc-chip-highlighted]' : 'highlighted' ,
5455 '[class.mat-mdc-chip-with-trailing-icon]' : '_hasTrailingIcon()' ,
5556 '[id]' : 'id' ,
@@ -89,6 +90,9 @@ export class MatChipRow extends MatChip implements AfterViewInit {
8990 /** The default chip edit input that is used if none is projected into this chip row. */
9091 @ViewChild ( MatChipEditInput ) defaultEditInput ?: MatChipEditInput ;
9192
93+ /** The chip's leading edit icon. */
94+ @ContentChild ( MAT_CHIP_EDIT ) editIcon : MatChipEdit ;
95+
9296 /** The projected chip edit input. */
9397 @ContentChild ( MatChipEditInput ) contentEditInput ?: MatChipEditInput ;
9498
@@ -107,6 +111,11 @@ export class MatChipRow extends MatChip implements AfterViewInit {
107111 } ) ;
108112 }
109113
114+ /** Returns whether the chip has a leading icon. */
115+ _hasLeadingIcon ( ) {
116+ return ! ! ( this . editIcon || this . leadingIcon ) ;
117+ }
118+
110119 override _hasTrailingIcon ( ) {
111120 // The trailing icon is hidden while editing.
112121 return ! this . _isEditing && super . _hasTrailingIcon ( ) ;
0 commit comments