@@ -24,6 +24,7 @@ import {
2424import { fromEvent , Subject } from 'rxjs' ;
2525import { takeUntil } from 'rxjs/operators' ;
2626
27+ import { MDCComponent } from '@angular-mdc/web/base' ;
2728import {
2829 toBoolean ,
2930 Platform
@@ -37,7 +38,10 @@ import {
3738} from '@angular-mdc/web/icon' ;
3839
3940import { cssClasses } from '@material/chips/chip/constants' ;
40- import { MDCChipFoundation } from '@material/chips/chip' ;
41+ import {
42+ MDCChipAdapter ,
43+ MDCChipFoundation
44+ } from '@material/chips/chip' ;
4145
4246export interface MdcChipInteractionEvent {
4347 detail : {
@@ -129,7 +133,7 @@ export class MdcChipText {
129133 changeDetection : ChangeDetectionStrategy . OnPush ,
130134 providers : [ MdcRipple ]
131135} )
132- export class MdcChip implements AfterViewInit , OnDestroy {
136+ export class MdcChip extends MDCComponent < any > implements AfterViewInit , OnDestroy {
133137 /** Emits whenever the component is destroyed. */
134138 private _destroyed = new Subject < void > ( ) ;
135139
@@ -248,8 +252,8 @@ export class MdcChip implements AfterViewInit, OnDestroy {
248252 @ContentChild ( MdcChipCheckmark ) _checkmark ?: MdcChipCheckmark ;
249253 @ContentChildren ( forwardRef ( ( ) => MdcChipIcon ) , { descendants : true } ) _icons ! : QueryList < MdcChipIcon > ;
250254
251- private _createAdapter ( ) {
252- return {
255+ getDefaultFoundation ( ) {
256+ const adapter : MDCChipAdapter = {
253257 addClass : ( className : string ) => this . _getHostElement ( ) . classList . add ( className ) ,
254258 removeClass : ( className : string ) => this . _getHostElement ( ) . classList . remove ( className ) ,
255259 hasClass : ( className : string ) => this . _getHostElement ( ) . classList . contains ( className ) ,
@@ -265,10 +269,11 @@ export class MdcChip implements AfterViewInit, OnDestroy {
265269 } ,
266270 eventTargetHasClass : ( target : HTMLElement , className : string ) => target . classList . contains ( className ) ,
267271 notifyInteraction : ( ) => this . _emitSelectionChangeEvent ( true ) ,
272+ notifySelection : ( ) => { } ,
268273 notifyTrailingIconInteraction : ( ) => this . trailingIconInteraction . emit ( { detail : { chipId : this . id } } ) ,
269274 notifyRemoval : ( ) => this . removed . emit ( { detail : { chipId : this . id , root : this } } ) ,
270275 getComputedStyleValue : ( propertyName : string ) => {
271- if ( ! this . _platform . isBrowser ) { return ; }
276+ if ( ! this . _platform . isBrowser ) { return '' ; }
272277 return window . getComputedStyle ( this . _getHostElement ( ) ) . getPropertyValue ( propertyName ) ;
273278 } ,
274279 setStyleProperty : ( propertyName : string , value : string ) =>
@@ -278,26 +283,18 @@ export class MdcChip implements AfterViewInit, OnDestroy {
278283 getCheckmarkBoundingClientRect : ( ) => this . _checkmark ?
279284 this . _checkmark . elementRef . nativeElement . getBoundingClientRect ( ) : null
280285 } ;
286+ return new MDCChipFoundation ( adapter ) ;
281287 }
282288
283- private _foundation : {
284- init ( ) : void ,
285- destroy ( ) : void ,
286- setSelected ( selected : boolean ) : void ,
287- setShouldRemoveOnTrailingIconClick ( shouldRemove : boolean ) : void ,
288- handleInteraction ( evt : KeyboardEvent | MouseEvent ) : void ,
289- handleTransitionEnd ( evt : TransitionEvent ) : void ,
290- handleTrailingIconInteraction ( evt : KeyboardEvent | MouseEvent ) : void ,
291- getDimensions ( ) : ClientRect
292- } = new MDCChipFoundation ( this . _createAdapter ( ) ) ;
293-
294289 constructor (
295290 private _platform : Platform ,
296291 private _ngZone : NgZone ,
297292 private _changeDetectorRef : ChangeDetectorRef ,
298293 private _ripple : MdcRipple ,
299294 public elementRef : ElementRef < HTMLElement > ,
300- @Optional ( ) @Inject ( MDC_CHIPSET_PARENT_COMPONENT ) private _parent : MdcChipSetParentComponent ) { }
295+ @Optional ( ) @Inject ( MDC_CHIPSET_PARENT_COMPONENT ) private _parent : MdcChipSetParentComponent ) {
296+ super ( elementRef ) ;
297+ }
301298
302299 ngAfterViewInit ( ) : void {
303300 this . _foundation . init ( ) ;
0 commit comments