@@ -20,25 +20,23 @@ import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
20
20
import { _StructuralStylesLoader } from '../core' ;
21
21
22
22
/**
23
- * Section within a chip.
23
+ * A non-interactive section of a chip.
24
24
* @docs -private
25
25
*/
26
26
@Directive ( {
27
- selector : '[matChipAction ]' ,
27
+ selector : '[matChipContent ]' ,
28
28
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' ,
30
31
'[class.mdc-evolution-chip__action--primary]' : '_isPrimary' ,
31
- '[class.mdc-evolution-chip__action--presentational]' : '!isInteractive' ,
32
32
'[class.mdc-evolution-chip__action--secondary]' : '!_isPrimary' ,
33
33
'[class.mdc-evolution-chip__action--trailing]' : '!_isPrimary && !_isLeading' ,
34
- '[attr.tabindex]' : '_getTabindex()' ,
35
34
'[attr.disabled]' : '_getDisabledAttribute()' ,
36
35
'[attr.aria-disabled]' : 'disabled' ,
37
- '(click)' : '_handleClick($event)' ,
38
- '(keydown)' : '_handleKeydown($event)' ,
39
36
} ,
37
+ standalone : true ,
40
38
} )
41
- export class MatChipAction {
39
+ export class MatChipContent {
42
40
_elementRef = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
43
41
protected _parentChip = inject < {
44
42
_handlePrimaryActionInteraction ( ) : void ;
@@ -48,9 +46,6 @@ export class MatChipAction {
48
46
_isEditing ?: boolean ;
49
47
} > ( MAT_CHIP ) ;
50
48
51
- /** Whether the action is interactive. */
52
- @Input ( ) isInteractive = true ;
53
-
54
49
/** Whether this is the primary action in the chip. */
55
50
_isPrimary = true ;
56
51
@@ -88,15 +83,6 @@ export class MatChipAction {
88
83
return this . disabled && ! this . _allowFocusWhenDisabled ? '' : null ;
89
84
}
90
85
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
-
100
86
constructor ( ...args : unknown [ ] ) ;
101
87
102
88
constructor ( ) {
@@ -109,9 +95,32 @@ export class MatChipAction {
109
95
focus ( ) {
110
96
this . _elementRef . nativeElement . focus ( ) ;
111
97
}
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
+ }
112
121
113
122
_handleClick ( event : MouseEvent ) {
114
- if ( ! this . disabled && this . isInteractive && this . _isPrimary ) {
123
+ if ( ! this . disabled && this . _isPrimary ) {
115
124
event . preventDefault ( ) ;
116
125
this . _parentChip . _handlePrimaryActionInteraction ( ) ;
117
126
}
@@ -121,7 +130,6 @@ export class MatChipAction {
121
130
if (
122
131
( event . keyCode === ENTER || event . keyCode === SPACE ) &&
123
132
! this . disabled &&
124
- this . isInteractive &&
125
133
this . _isPrimary &&
126
134
! this . _parentChip . _isEditing
127
135
) {
0 commit comments