6
6
ElementRef ,
7
7
EventEmitter ,
8
8
HostBinding ,
9
+ Input ,
9
10
OnDestroy ,
10
11
OnInit ,
11
12
QueryList ,
@@ -15,6 +16,8 @@ import {
15
16
import { Subscription } from 'rxjs/Subscription' ;
16
17
import { startWith } from 'rxjs/operators/startWith' ;
17
18
19
+ import { toBoolean , EventRegistry } from '@angular-mdc/web/common' ;
20
+
18
21
import { MdcChip } from './chip' ;
19
22
import { MDCChipSetAdapter } from '@material/chips/chip-set/adapter' ;
20
23
import { MDCChipSetFoundation } from '@material/chips' ;
@@ -36,9 +39,23 @@ export class MdcChipSetChange {
36
39
encapsulation : ViewEncapsulation . None ,
37
40
changeDetection : ChangeDetectionStrategy . OnPush ,
38
41
preserveWhitespaces : false ,
42
+ providers : [ EventRegistry ]
39
43
} )
40
44
export class MdcChipSet implements AfterContentInit , OnInit , OnDestroy {
45
+ /**
46
+ * Indicates that the chips in the set are choice chips, which allow a single selection from a set of options.
47
+ */
48
+ @Input ( )
49
+ get choice ( ) : boolean { return this . _choice ; }
50
+ set choice ( value : boolean ) {
51
+ this . _choice = toBoolean ( value ) ;
52
+ }
53
+ protected _choice : boolean = false ;
54
+
41
55
@HostBinding ( 'class.mdc-chip-set' ) isHostClass = true ;
56
+ @HostBinding ( 'class.mdc-chip-set--choice' ) get classChoice ( ) : string {
57
+ return this . _choice ? 'mdc-chip-set--choice' : '' ;
58
+ }
42
59
@ContentChildren ( MdcChip ) chips : QueryList < MdcChip > ;
43
60
44
61
/** Subscription to changes in the chip list. */
@@ -48,6 +65,10 @@ export class MdcChipSet implements AfterContentInit, OnInit, OnDestroy {
48
65
hasClass : ( className : string ) => {
49
66
return this . _getHostElement ( ) . classList . contains ( className ) ;
50
67
} ,
68
+ registerInteractionHandler : ( evtType : string , handler : EventListener ) =>
69
+ this . _registry . listen ( evtType , handler , this . _getHostElement ( ) ) ,
70
+ deregisterInteractionHandler : ( evtType : string , handler : EventListener ) =>
71
+ this . _registry . unlisten ( evtType , handler ) ,
51
72
} ;
52
73
53
74
private _foundation : {
@@ -57,7 +78,8 @@ export class MdcChipSet implements AfterContentInit, OnInit, OnDestroy {
57
78
58
79
constructor (
59
80
private _renderer : Renderer2 ,
60
- public elementRef : ElementRef ) { }
81
+ public elementRef : ElementRef ,
82
+ private _registry : EventRegistry ) { }
61
83
62
84
ngAfterContentInit ( ) : void {
63
85
// When the list changes, re-subscribe
0 commit comments