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