@@ -44,8 +44,14 @@ import {
44
44
} from '../core' ;
45
45
import { Subject , Subscription , merge } from 'rxjs' ;
46
46
import { MatChipAction } from './chip-action' ;
47
- import { MatChipAvatar , MatChipRemove , MatChipTrailingIcon } from './chip-icons' ;
48
- import { MAT_CHIP , MAT_CHIP_AVATAR , MAT_CHIP_REMOVE , MAT_CHIP_TRAILING_ICON } from './tokens' ;
47
+ import { MatChipAvatar , MatChipEdit , MatChipRemove , MatChipTrailingIcon } from './chip-icons' ;
48
+ import {
49
+ MAT_CHIP ,
50
+ MAT_CHIP_AVATAR ,
51
+ MAT_CHIP_EDIT ,
52
+ MAT_CHIP_REMOVE ,
53
+ MAT_CHIP_TRAILING_ICON ,
54
+ } from './tokens' ;
49
55
50
56
/** Represents an event fired on an individual `mat-chip`. */
51
57
export interface MatChipEvent {
@@ -133,6 +139,10 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
133
139
@ContentChildren ( MAT_CHIP_TRAILING_ICON , { descendants : true } )
134
140
protected _allTrailingIcons : QueryList < MatChipTrailingIcon > ;
135
141
142
+ /** All edit icons present in the chip. */
143
+ @ContentChildren ( MAT_CHIP_EDIT , { descendants : true } )
144
+ protected _allEditIcons : QueryList < MatChipEdit > ;
145
+
136
146
/** All remove icons present in the chip. */
137
147
@ContentChildren ( MAT_CHIP_REMOVE , { descendants : true } )
138
148
protected _allRemoveIcons : QueryList < MatChipRemove > ;
@@ -225,6 +235,9 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
225
235
/** The chip's leading icon. */
226
236
@ContentChild ( MAT_CHIP_AVATAR ) leadingIcon : MatChipAvatar ;
227
237
238
+ /** The chip's leading edit icon. */
239
+ @ContentChild ( MAT_CHIP_EDIT ) editIcon : MatChipEdit ;
240
+
228
241
/** The chip's trailing icon. */
229
242
@ContentChild ( MAT_CHIP_TRAILING_ICON ) trailingIcon : MatChipTrailingIcon ;
230
243
@@ -279,6 +292,7 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
279
292
this . _actionChanges = merge (
280
293
this . _allLeadingIcons . changes ,
281
294
this . _allTrailingIcons . changes ,
295
+ this . _allEditIcons . changes ,
282
296
this . _allRemoveIcons . changes ,
283
297
) . subscribe ( ( ) => this . _changeDetectorRef . markForCheck ( ) ) ;
284
298
}
@@ -358,6 +372,10 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
358
372
_getActions ( ) : MatChipAction [ ] {
359
373
const result : MatChipAction [ ] = [ ] ;
360
374
375
+ if ( this . editIcon ) {
376
+ result . push ( this . editIcon ) ;
377
+ }
378
+
361
379
if ( this . primaryAction ) {
362
380
result . push ( this . primaryAction ) ;
363
381
}
@@ -378,6 +396,11 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
378
396
// Empty here, but is overwritten in child classes.
379
397
}
380
398
399
+ /** Handles interactions with the edit action of the chip. */
400
+ _edit ( event : Event ) {
401
+ // Empty here, but is overwritten in child classes.
402
+ }
403
+
381
404
/** Starts the focus monitoring process on the chip. */
382
405
private _monitorFocus ( ) {
383
406
this . _focusMonitor . monitor ( this . _elementRef , true ) . subscribe ( origin => {
0 commit comments