@@ -19,26 +19,28 @@ import {MAT_CHIP} from './tokens';
1919import { _CdkPrivateStyleLoader } from '@angular/cdk/private' ;
2020import { _StructuralStylesLoader } from '../core' ;
2121
22+ const chipActionHostBase = {
23+ 'class' : 'mdc-evolution-chip__action mat-mdc-chip-action' ,
24+ '[class.mdc-evolution-chip__action--primary]' : '_isPrimary' ,
25+ '[class.mdc-evolution-chip__action--secondary]' : '!_isPrimary' ,
26+ '[class.mdc-evolution-chip__action--trailing]' : '!_isPrimary && !_isLeading' ,
27+ '[attr.disabled]' : '_getDisabledAttribute()' ,
28+ '[attr.aria-disabled]' : 'disabled' ,
29+ } ;
30+
2231/**
23- * Section within a chip.
32+ * A non-interactive section of a chip.
2433 * @docs -private
2534 */
2635@Directive ( {
27- selector : '[matChipAction ]' ,
36+ selector : '[matChipContent ]' ,
2837 host : {
29- 'class' : 'mdc-evolution-chip__action mat-mdc-chip-action' ,
30- '[class.mdc-evolution-chip__action--primary]' : '_isPrimary' ,
31- '[class.mdc-evolution-chip__action--presentational]' : '!isInteractive' ,
32- '[class.mdc-evolution-chip__action--secondary]' : '!_isPrimary' ,
33- '[class.mdc-evolution-chip__action--trailing]' : '!_isPrimary && !_isLeading' ,
34- '[attr.tabindex]' : '_getTabindex()' ,
35- '[attr.disabled]' : '_getDisabledAttribute()' ,
36- '[attr.aria-disabled]' : 'disabled' ,
37- '(click)' : 'isInteractive ? _handleClick($event) : null' ,
38- '(keydown)' : '_handleKeydown($event)' ,
38+ ...chipActionHostBase ,
39+ '[class.mdc-evolution-chip__action--presentational]' : 'true' ,
3940 } ,
41+ standalone : true ,
4042} )
41- export class MatChipAction {
43+ export class MatChipContent {
4244 _elementRef = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
4345 protected _parentChip = inject < {
4446 _handlePrimaryActionInteraction ( ) : void ;
@@ -48,9 +50,6 @@ export class MatChipAction {
4850 _isEditing ?: boolean ;
4951 } > ( MAT_CHIP ) ;
5052
51- /** Whether the action is interactive. */
52- @Input ( ) isInteractive = true ;
53-
5453 /** Whether this is the primary action in the chip. */
5554 _isPrimary = true ;
5655
@@ -88,15 +87,6 @@ export class MatChipAction {
8887 return this . disabled && ! this . _allowFocusWhenDisabled ? '' : null ;
8988 }
9089
91- /**
92- * Determine the value of the tabindex attribute for this chip action.
93- */
94- protected _getTabindex ( ) : string | null {
95- return ( this . disabled && ! this . _allowFocusWhenDisabled ) || ! this . isInteractive
96- ? null
97- : this . tabIndex . toString ( ) ;
98- }
99-
10090 constructor ( ...args : unknown [ ] ) ;
10191
10292 constructor ( ) {
@@ -109,9 +99,32 @@ export class MatChipAction {
10999 focus ( ) {
110100 this . _elementRef . nativeElement . focus ( ) ;
111101 }
102+ }
103+
104+ /**
105+ * Interactive section of a chip.
106+ * @docs -private
107+ */
108+ @Directive ( {
109+ selector : '[matChipAction]' ,
110+ host : {
111+ ...chipActionHostBase ,
112+ '[attr.tabindex]' : '_getTabindex()' ,
113+ '(click)' : '_handleClick($event)' ,
114+ '(keydown)' : '_handleKeydown($event)' ,
115+ } ,
116+ standalone : true ,
117+ } )
118+ export class MatChipAction extends MatChipContent {
119+ /**
120+ * Determine the value of the tabindex attribute for this chip action.
121+ */
122+ protected _getTabindex ( ) : string | null {
123+ return this . disabled && ! this . _allowFocusWhenDisabled ? null : this . tabIndex . toString ( ) ;
124+ }
112125
113126 _handleClick ( event : MouseEvent ) {
114- if ( ! this . disabled && this . isInteractive && this . _isPrimary ) {
127+ if ( ! this . disabled && this . _isPrimary ) {
115128 event . preventDefault ( ) ;
116129 this . _parentChip . _handlePrimaryActionInteraction ( ) ;
117130 }
@@ -121,7 +134,6 @@ export class MatChipAction {
121134 if (
122135 ( event . keyCode === ENTER || event . keyCode === SPACE ) &&
123136 ! this . disabled &&
124- this . isInteractive &&
125137 this . _isPrimary &&
126138 ! this . _parentChip . _isEditing
127139 ) {
0 commit comments