@@ -14,15 +14,16 @@ import {
1414 ViewChild ,
1515 ViewEncapsulation
1616} from '@angular/core' ;
17+ import { NG_VALUE_ACCESSOR , ControlValueAccessor } from '@angular/forms' ;
1718import { fromEvent , Subject } from 'rxjs' ;
1819import { takeUntil , filter } from 'rxjs/operators' ;
1920
20- import { NG_VALUE_ACCESSOR , ControlValueAccessor } from '@angular/forms ' ;
21+ import { MDCComponent } from '@angular-mdc/web/base ' ;
2122import { Platform , toBoolean } from '@angular-mdc/web/common' ;
2223import { MdcRipple } from '@angular-mdc/web/ripple' ;
2324import { MdcFormField , MdcFormFieldControl } from '@angular-mdc/web/form-field' ;
2425
25- import { MDCCheckboxFoundation } from '@material/checkbox' ;
26+ import { MDCCheckboxFoundation , MDCCheckboxAdapter } from '@material/checkbox' ;
2627
2728let nextUniqueId = 0 ;
2829
@@ -89,7 +90,7 @@ export const MDC_CHECKBOX_CONTROL_VALUE_ACCESSOR: any = {
8990 encapsulation : ViewEncapsulation . None ,
9091 changeDetection : ChangeDetectionStrategy . OnPush
9192} )
92- export class MdcCheckbox implements AfterViewInit , ControlValueAccessor ,
93+ export class MdcCheckbox extends MDCComponent < MDCCheckboxFoundation > implements AfterViewInit , ControlValueAccessor ,
9394 OnDestroy , MdcFormFieldControl < any > {
9495 /** Emits whenever the component is destroyed. */
9596 private _destroy = new Subject < void > ( ) ;
@@ -184,8 +185,8 @@ export class MdcCheckbox implements AfterViewInit, ControlValueAccessor,
184185 /** View to model callback called when component has been touched */
185186 _onTouched : ( ) => any = ( ) => { } ;
186187
187- private _createAdapter ( ) {
188- return {
188+ getDefaultFoundation ( ) {
189+ const adapter : MDCCheckboxAdapter = {
189190 addClass : ( className : string ) => this . _getHostElement ( ) . classList . add ( className ) ,
190191 removeClass : ( className : string ) => this . _getHostElement ( ) . classList . remove ( className ) ,
191192 setNativeControlAttr : ( attr : string , value : string ) =>
@@ -200,23 +201,17 @@ export class MdcCheckbox implements AfterViewInit, ControlValueAccessor,
200201 forceLayout : ( ) => this . _getHostElement ( ) . offsetWidth ,
201202 isAttachedToDOM : ( ) => true
202203 } ;
204+ return new MDCCheckboxFoundation ( adapter ) ;
203205 }
204206
205- private _foundation : {
206- init ( ) : void ,
207- destroy ( ) : void ,
208- setDisabled ( disabled : boolean ) : void ,
209- handleChange ( ) : void ,
210- handleAnimationEnd ( ) : void
211- } = new MDCCheckboxFoundation ( this . _createAdapter ( ) ) ;
212-
213207 constructor (
214208 private _platform : Platform ,
215209 private _ngZone : NgZone ,
216210 private _changeDetectorRef : ChangeDetectorRef ,
217211 public elementRef : ElementRef < HTMLElement > ,
218212 public ripple : MdcRipple ,
219213 @Optional ( ) private _parentFormField : MdcFormField ) {
214+ super ( elementRef ) ;
220215
221216 if ( this . _parentFormField ) {
222217 _parentFormField . elementRef . nativeElement . classList . add ( 'mdc-form-field' ) ;
0 commit comments