@@ -34,11 +34,9 @@ import {
34
34
ThemePalette ,
35
35
} from '@angular/material/core' ;
36
36
import { ActiveDescendantKeyManager } from '@angular/cdk/a11y' ;
37
- import { coerceStringArray } from '@angular/cdk/coercion' ;
38
37
import { Platform } from '@angular/cdk/platform' ;
39
38
import { panelAnimation } from './animations' ;
40
39
import { Subscription } from 'rxjs' ;
41
- import { NgClass } from '@angular/common' ;
42
40
43
41
/**
44
42
* Autocomplete IDs need to be unique across components, so this counter exists outside of
@@ -119,17 +117,10 @@ export function MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY(): MatAutocompleteDefau
119
117
providers : [ { provide : MAT_OPTION_PARENT_COMPONENT , useExisting : MatAutocomplete } ] ,
120
118
animations : [ panelAnimation ] ,
121
119
standalone : true ,
122
- imports : [ NgClass ] ,
123
120
} )
124
121
export class MatAutocomplete implements AfterContentInit , OnDestroy {
125
122
private _activeOptionChanges = Subscription . EMPTY ;
126
123
127
- /** Class to apply to the panel when it's visible. */
128
- private _visibleClass = 'mat-mdc-autocomplete-visible' ;
129
-
130
- /** Class to apply to the panel when it's hidden. */
131
- private _hiddenClass = 'mat-mdc-autocomplete-hidden' ;
132
-
133
124
/** Emits when the panel animation is done. Null if the panel doesn't animate. */
134
125
_animationDone = new EventEmitter < AnimationEvent > ( ) ;
135
126
@@ -148,10 +139,10 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
148
139
/** @docs -private Sets the theme color of the panel. */
149
140
_setColor ( value : ThemePalette ) {
150
141
this . _color = value ;
151
- this . _setThemeClasses ( this . _classList ) ;
142
+ this . _changeDetectorRef . markForCheck ( ) ;
152
143
}
153
144
/** @docs -private theme color of the panel */
154
- private _color : ThemePalette ;
145
+ protected _color : ThemePalette ;
155
146
156
147
// The @ViewChild query for TemplateRef here needs to be static because some code paths
157
148
// lead to the overlay being created before change detection has finished for this component.
@@ -224,23 +215,10 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
224
215
*/
225
216
@Input ( 'class' )
226
217
set classList ( value : string | string [ ] ) {
227
- if ( value && value . length ) {
228
- this . _classList = coerceStringArray ( value ) . reduce (
229
- ( classList , className ) => {
230
- classList [ className ] = true ;
231
- return classList ;
232
- } ,
233
- { } as { [ key : string ] : boolean } ,
234
- ) ;
235
- } else {
236
- this . _classList = { } ;
237
- }
238
-
239
- this . _setVisibilityClasses ( this . _classList ) ;
240
- this . _setThemeClasses ( this . _classList ) ;
218
+ this . _classList = value ;
241
219
this . _elementRef . nativeElement . className = '' ;
242
220
}
243
- _classList : { [ key : string ] : boolean } = { } ;
221
+ _classList : string | string [ ] ;
244
222
245
223
/** Whether checkmark indicator for single-selection options is hidden. */
246
224
@Input ( { transform : booleanAttribute } )
@@ -326,7 +304,6 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
326
304
/** Panel should hide itself when the option list is empty. */
327
305
_setVisibility ( ) {
328
306
this . showPanel = ! ! this . options . length ;
329
- this . _setVisibilityClasses ( this . _classList ) ;
330
307
this . _changeDetectorRef . markForCheck ( ) ;
331
308
}
332
309
@@ -346,19 +323,6 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
346
323
return this . ariaLabelledby ? labelExpression + this . ariaLabelledby : labelId ;
347
324
}
348
325
349
- /** Sets the autocomplete visibility classes on a classlist based on the panel is visible. */
350
- private _setVisibilityClasses ( classList : { [ key : string ] : boolean } ) {
351
- classList [ this . _visibleClass ] = this . showPanel ;
352
- classList [ this . _hiddenClass ] = ! this . showPanel ;
353
- }
354
-
355
- /** Sets the theming classes on a classlist based on the theme of the panel. */
356
- private _setThemeClasses ( classList : { [ key : string ] : boolean } ) {
357
- classList [ 'mat-primary' ] = this . _color === 'primary' ;
358
- classList [ 'mat-warn' ] = this . _color === 'warn' ;
359
- classList [ 'mat-accent' ] = this . _color === 'accent' ;
360
- }
361
-
362
326
// `skipPredicate` determines if key manager should avoid putting a given option in the tab
363
327
// order. Allow disabled list items to receive focus via keyboard to align with WAI ARIA
364
328
// recommendation.
0 commit comments