@@ -20,25 +20,23 @@ import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
2020import { _StructuralStylesLoader } from '../core' ;
2121
2222/**
23- * Section within a chip.
23+ * A non-interactive section of a chip.
2424 * @docs -private
2525 */
2626@Directive ( {
27- selector : '[matChipAction ]' ,
27+ selector : '[matChipContent ]' ,
2828 host : {
29- 'class' : 'mdc-evolution-chip__action mat-mdc-chip-action' ,
29+ 'class' :
30+ 'mat-mdc-chip-action mdc-evolution-chip__action mdc-evolution-chip__action--presentational' ,
3031 '[class.mdc-evolution-chip__action--primary]' : '_isPrimary' ,
31- '[class.mdc-evolution-chip__action--presentational]' : '!isInteractive' ,
3232 '[class.mdc-evolution-chip__action--secondary]' : '!_isPrimary' ,
3333 '[class.mdc-evolution-chip__action--trailing]' : '!_isPrimary && !_isLeading' ,
34- '[attr.tabindex]' : '_getTabindex()' ,
3534 '[attr.disabled]' : '_getDisabledAttribute()' ,
3635 '[attr.aria-disabled]' : 'disabled' ,
37- '(click)' : '_handleClick($event)' ,
38- '(keydown)' : '_handleKeydown($event)' ,
3936 } ,
37+ standalone : true ,
4038} )
41- export class MatChipAction {
39+ export class MatChipContent {
4240 _elementRef = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
4341 protected _parentChip = inject < {
4442 _handlePrimaryActionInteraction ( ) : void ;
@@ -48,9 +46,6 @@ export class MatChipAction {
4846 _isEditing ?: boolean ;
4947 } > ( MAT_CHIP ) ;
5048
51- /** Whether the action is interactive. */
52- @Input ( ) isInteractive = true ;
53-
5449 /** Whether this is the primary action in the chip. */
5550 _isPrimary = true ;
5651
@@ -88,15 +83,6 @@ export class MatChipAction {
8883 return this . disabled && ! this . _allowFocusWhenDisabled ? '' : null ;
8984 }
9085
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-
10086 constructor ( ...args : unknown [ ] ) ;
10187
10288 constructor ( ) {
@@ -109,9 +95,32 @@ export class MatChipAction {
10995 focus ( ) {
11096 this . _elementRef . nativeElement . focus ( ) ;
11197 }
98+ }
99+
100+ /**
101+ * Interactive section of a chip.
102+ * @docs -private
103+ */
104+ @Directive ( {
105+ selector : '[matChipAction]' ,
106+ host : {
107+ '[attr.tabindex]' : '_getTabindex()' ,
108+ '[class.mdc-evolution-chip__action--presentational]' : 'false' ,
109+ '(click)' : '_handleClick($event)' ,
110+ '(keydown)' : '_handleKeydown($event)' ,
111+ } ,
112+ standalone : true ,
113+ } )
114+ export class MatChipAction extends MatChipContent {
115+ /**
116+ * Determine the value of the tabindex attribute for this chip action.
117+ */
118+ protected _getTabindex ( ) : string | null {
119+ return this . disabled && ! this . _allowFocusWhenDisabled ? null : this . tabIndex . toString ( ) ;
120+ }
112121
113122 _handleClick ( event : MouseEvent ) {
114- if ( ! this . disabled && this . isInteractive && this . _isPrimary ) {
123+ if ( ! this . disabled && this . _isPrimary ) {
115124 event . preventDefault ( ) ;
116125 this . _parentChip . _handlePrimaryActionInteraction ( ) ;
117126 }
@@ -121,7 +130,6 @@ export class MatChipAction {
121130 if (
122131 ( event . keyCode === ENTER || event . keyCode === SPACE ) &&
123132 ! this . disabled &&
124- this . isInteractive &&
125133 this . _isPrimary &&
126134 ! this . _parentChip . _isEditing
127135 ) {
0 commit comments