11import  {  BooleanInput ,  coerceBooleanProperty  }  from  '@angular/cdk/coercion' ; 
22import  { 
3+   AfterViewInit , 
34  Directive , 
45  DoCheck , 
56  ElementRef , 
@@ -21,7 +22,7 @@ import { MdbAbstractFormControl } from './form-control';
2122  providers : [ {  provide : MdbAbstractFormControl ,  useExisting : MdbInputDirective  } ] , 
2223} ) 
2324// eslint-disable-next-line @angular-eslint/component-class-suffix 
24- export  class  MdbInputDirective  implements  MdbAbstractFormControl < any > ,  DoCheck  { 
25+ export  class  MdbInputDirective  implements  MdbAbstractFormControl < any > ,  DoCheck ,   AfterViewInit  { 
2526  constructor ( 
2627    private  _elementRef : ElementRef , 
2728    private  _renderer : Renderer2 , 
@@ -31,6 +32,14 @@ export class MdbInputDirective implements MdbAbstractFormControl<any>, DoCheck {
3132  readonly  stateChanges : Subject < void >  =  new  Subject < void > ( ) ; 
3233
3334  private  _focused  =  false ; 
35+   private  _color  =  '' ; 
36+ 
37+   ngAfterViewInit ( )  { 
38+     this . _color  =  getComputedStyle ( this . _elementRef . nativeElement ) . color ; 
39+     if  ( this . _elementRef . nativeElement . type  ===  'date' )  { 
40+       this . _updateTextColorForDateType ( ) ; 
41+     } 
42+   } 
3443
3544  private  _currentNativeValue : any ; 
3645
@@ -74,21 +83,35 @@ export class MdbInputDirective implements MdbAbstractFormControl<any>, DoCheck {
7483  } 
7584  private  _value : any ; 
7685
86+   private  _updateTextColorForDateType ( )  { 
87+     const  actualColor  =  getComputedStyle ( this . _elementRef . nativeElement ) . color ; 
88+     this . _color  =  actualColor  !==  'rgba(0, 0, 0, 0)'  ? actualColor  : this . _color ; 
89+ 
90+     const  color  =  this . labelActive  ? this . _color  : `transparent` ; 
91+ 
92+     this . _renderer . setStyle ( this . _elementRef . nativeElement ,  'color' ,  color ) ; 
93+   } 
94+ 
7795  @HostListener ( 'focus' ) 
7896  _onFocus ( ) : void { 
7997    this . _focused  =  true ; 
98+     if  ( this . _elementRef . nativeElement . type  ===  'date' )  { 
99+       this . _updateTextColorForDateType ( ) ; 
100+     } 
80101    this . stateChanges . next ( ) ; 
81102  } 
82103
83104  @HostListener ( 'blur' ) 
84105  _onBlur ( ) : void { 
85106    this . _focused  =  false ; 
107+     if  ( this . _elementRef . nativeElement . type  ===  'date' )  { 
108+       this . _updateTextColorForDateType ( ) ; 
109+     } 
86110    this . stateChanges . next ( ) ; 
87111  } 
88112
89113  ngDoCheck ( ) : void { 
90114    const  value  =  this . _elementRef . nativeElement . value ; 
91- 
92115    if  ( this . _currentNativeValue  !==  value )  { 
93116      this . _currentNativeValue  =  value ; 
94117      this . stateChanges . next ( ) ; 
0 commit comments