@@ -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
@@ -151,10 +142,10 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
151
142
/** @docs -private Sets the theme color of the panel. */
152
143
_setColor ( value : ThemePalette ) {
153
144
this . _color = value ;
154
- this . _setThemeClasses ( this . _classList ) ;
145
+ this . _changeDetectorRef . markForCheck ( ) ;
155
146
}
156
147
/** @docs -private theme color of the panel */
157
- private _color : ThemePalette ;
148
+ protected _color : ThemePalette ;
158
149
159
150
// The @ViewChild query for TemplateRef here needs to be static because some code paths
160
151
// lead to the overlay being created before change detection has finished for this component.
@@ -227,23 +218,10 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
227
218
*/
228
219
@Input ( 'class' )
229
220
set classList ( value : string | string [ ] ) {
230
- if ( value && value . length ) {
231
- this . _classList = coerceStringArray ( value ) . reduce (
232
- ( classList , className ) => {
233
- classList [ className ] = true ;
234
- return classList ;
235
- } ,
236
- { } as { [ key : string ] : boolean } ,
237
- ) ;
238
- } else {
239
- this . _classList = { } ;
240
- }
241
-
242
- this . _setVisibilityClasses ( this . _classList ) ;
243
- this . _setThemeClasses ( this . _classList ) ;
221
+ this . _classList = value ;
244
222
this . _elementRef . nativeElement . className = '' ;
245
223
}
246
- _classList : { [ key : string ] : boolean } = { } ;
224
+ _classList : string | string [ ] ;
247
225
248
226
/** Whether checkmark indicator for single-selection options is hidden. */
249
227
@Input ( { transform : booleanAttribute } )
@@ -329,7 +307,6 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
329
307
/** Panel should hide itself when the option list is empty. */
330
308
_setVisibility ( ) {
331
309
this . showPanel = ! ! this . options . length ;
332
- this . _setVisibilityClasses ( this . _classList ) ;
333
310
this . _changeDetectorRef . markForCheck ( ) ;
334
311
}
335
312
@@ -349,19 +326,6 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
349
326
return this . ariaLabelledby ? labelExpression + this . ariaLabelledby : labelId ;
350
327
}
351
328
352
- /** Sets the autocomplete visibility classes on a classlist based on the panel is visible. */
353
- private _setVisibilityClasses ( classList : { [ key : string ] : boolean } ) {
354
- classList [ this . _visibleClass ] = this . showPanel ;
355
- classList [ this . _hiddenClass ] = ! this . showPanel ;
356
- }
357
-
358
- /** Sets the theming classes on a classlist based on the theme of the panel. */
359
- private _setThemeClasses ( classList : { [ key : string ] : boolean } ) {
360
- classList [ 'mat-primary' ] = this . _color === 'primary' ;
361
- classList [ 'mat-warn' ] = this . _color === 'warn' ;
362
- classList [ 'mat-accent' ] = this . _color === 'accent' ;
363
- }
364
-
365
329
// `skipPredicate` determines if key manager should avoid putting a given option in the tab
366
330
// order. Allow disabled list items to receive focus via keyboard to align with WAI ARIA
367
331
// recommendation.
0 commit comments