@@ -34,11 +34,9 @@ import {
3434 ThemePalette ,
3535} from '@angular/material/core' ;
3636import { ActiveDescendantKeyManager } from '@angular/cdk/a11y' ;
37- import { coerceStringArray } from '@angular/cdk/coercion' ;
3837import { Platform } from '@angular/cdk/platform' ;
3938import { panelAnimation } from './animations' ;
4039import { Subscription } from 'rxjs' ;
41- import { NgClass } from '@angular/common' ;
4240
4341/**
4442 * 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
119117 providers : [ { provide : MAT_OPTION_PARENT_COMPONENT , useExisting : MatAutocomplete } ] ,
120118 animations : [ panelAnimation ] ,
121119 standalone : true ,
122- imports : [ NgClass ] ,
123120} )
124121export class MatAutocomplete implements AfterContentInit , OnDestroy {
125122 private _activeOptionChanges = Subscription . EMPTY ;
126123
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-
133124 /** Emits when the panel animation is done. Null if the panel doesn't animate. */
134125 _animationDone = new EventEmitter < AnimationEvent > ( ) ;
135126
@@ -151,10 +142,10 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
151142 /** @docs -private Sets the theme color of the panel. */
152143 _setColor ( value : ThemePalette ) {
153144 this . _color = value ;
154- this . _setThemeClasses ( this . _classList ) ;
145+ this . _changeDetectorRef . markForCheck ( ) ;
155146 }
156147 /** @docs -private theme color of the panel */
157- private _color : ThemePalette ;
148+ protected _color : ThemePalette ;
158149
159150 // The @ViewChild query for TemplateRef here needs to be static because some code paths
160151 // lead to the overlay being created before change detection has finished for this component.
@@ -227,23 +218,10 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
227218 */
228219 @Input ( 'class' )
229220 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 ;
244222 this . _elementRef . nativeElement . className = '' ;
245223 }
246- _classList : { [ key : string ] : boolean } = { } ;
224+ _classList : string | string [ ] ;
247225
248226 /** Whether checkmark indicator for single-selection options is hidden. */
249227 @Input ( { transform : booleanAttribute } )
@@ -329,7 +307,6 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
329307 /** Panel should hide itself when the option list is empty. */
330308 _setVisibility ( ) {
331309 this . showPanel = ! ! this . options . length ;
332- this . _setVisibilityClasses ( this . _classList ) ;
333310 this . _changeDetectorRef . markForCheck ( ) ;
334311 }
335312
@@ -349,19 +326,6 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
349326 return this . ariaLabelledby ? labelExpression + this . ariaLabelledby : labelId ;
350327 }
351328
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-
365329 // `skipPredicate` determines if key manager should avoid putting a given option in the tab
366330 // order. Allow disabled list items to receive focus via keyboard to align with WAI ARIA
367331 // recommendation.
0 commit comments