66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { Directive , Output , EventEmitter , ElementRef , Input } from '@angular/core' ;
9+ import {
10+ Directive ,
11+ ElementRef ,
12+ Output ,
13+ EventEmitter ,
14+ Inject ,
15+ Input ,
16+ Optional ,
17+ Renderer2 ,
18+ Self ,
19+ } from '@angular/core' ;
20+ import { FormControl , FormGroupDirective , NgControl , NgForm } from '@angular/forms' ;
21+ import { Platform , getSupportedInputTypes } from '@angular/cdk/platform' ;
1022import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
1123import { ENTER } from '../core/keyboard/keycodes' ;
1224import { MdChipList } from './chip-list' ;
25+ import { MdInput } from '../input/input' ;
26+ import {
27+ defaultErrorStateMatcher ,
28+ ErrorOptions ,
29+ ErrorStateMatcher ,
30+ MD_ERROR_GLOBAL_OPTIONS
31+ } from '../core/error/error-options' ;
1332
1433export interface MdChipInputEvent {
1534 input : HTMLInputElement ;
@@ -19,12 +38,13 @@ export interface MdChipInputEvent {
1938@Directive ( {
2039 selector : 'input[mdChipInputFor], input[matChipInputFor]' ,
2140 host : {
22- 'class' : 'mat-chip-input' ,
41+ 'class' : 'mat-chip-input mat-input-element ' ,
2342 '(keydown)' : '_keydown($event)' ,
24- '(blur)' : '_blur()'
43+ '(blur)' : '_blur()' ,
44+ '(focus)' : '_focus()' ,
2545 }
2646} )
27- export class MdChipInput {
47+ export class MdChipInput extends MdInput {
2848
2949 _chipList : MdChipList ;
3050
@@ -33,7 +53,7 @@ export class MdChipInput {
3353 set chipList ( value : MdChipList ) {
3454 if ( value ) {
3555 this . _chipList = value ;
36- this . _chipList . registerInput ( this . _inputElement ) ;
56+ this . _chipList . registerInput ( this ) ;
3757 }
3858 }
3959
@@ -71,7 +91,14 @@ export class MdChipInput {
7191 /** The native input element to which this directive is attached. */
7292 protected _inputElement : HTMLInputElement ;
7393
74- constructor ( protected _elementRef : ElementRef ) {
94+ constructor ( protected _elementRef : ElementRef ,
95+ protected _renderer : Renderer2 ,
96+ protected _platform : Platform ,
97+ @Optional ( ) @Self ( ) public ngControl : NgControl ,
98+ @Optional ( ) protected _parentForm : NgForm ,
99+ @Optional ( ) protected _parentFormGroup : FormGroupDirective ,
100+ @Optional ( ) @Inject ( MD_ERROR_GLOBAL_OPTIONS ) errorOptions : ErrorOptions ) {
101+ super ( _elementRef , _renderer , _platform , ngControl , _parentForm , _parentFormGroup , errorOptions ) ;
75102 this . _inputElement = this . _elementRef . nativeElement as HTMLInputElement ;
76103 }
77104
@@ -85,6 +112,13 @@ export class MdChipInput {
85112 if ( this . addOnBlur ) {
86113 this . _emitChipEnd ( ) ;
87114 }
115+ super . _focusChanged ( false ) ;
116+ this . _chipList . stateChanges . next ( ) ;
117+ }
118+
119+ _focus ( ) {
120+ super . _focusChanged ( true ) ;
121+ this . _chipList . stateChanges . next ( ) ;
88122 }
89123
90124 /** Checks to see if the (chipEnd) event needs to be emitted. */
0 commit comments