@@ -34,7 +34,7 @@ export interface MdChipEvent {
34
34
35
35
/** Event object emitted by MdChip when selected or deselected. */
36
36
export class MdChipSelectionChange {
37
- constructor ( public source : MdChip , public isUserInput = false ) { }
37
+ constructor ( public source : MdChip , public selected : boolean , public isUserInput = false ) { }
38
38
}
39
39
40
40
@@ -98,7 +98,11 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr
98
98
get selected ( ) : boolean { return this . _selected ; }
99
99
set selected ( value : boolean ) {
100
100
this . _selected = coerceBooleanProperty ( value ) ;
101
- this . onSelectionChange . emit ( { source : this , isUserInput : false } ) ;
101
+ this . selectionChange . emit ( {
102
+ source : this ,
103
+ isUserInput : false ,
104
+ selected : value
105
+ } ) ;
102
106
}
103
107
104
108
/** The value of the chip. Defaults to the content inside <md-chip> tags. */
@@ -132,13 +136,25 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr
132
136
_onBlur = new Subject < MdChipEvent > ( ) ;
133
137
134
138
/** Emitted when the chip is selected or deselected. */
135
- @Output ( ) onSelectionChange = new EventEmitter < MdChipSelectionChange > ( ) ;
139
+ @Output ( ) selectionChange = new EventEmitter < MdChipSelectionChange > ( ) ;
136
140
137
141
/** Emitted when the chip is destroyed. */
138
- @Output ( ) destroy = new EventEmitter < MdChipEvent > ( ) ;
142
+ @Output ( ) destroyed = new EventEmitter < MdChipEvent > ( ) ;
143
+
144
+ /**
145
+ * Emitted when the chip is destroyed.
146
+ * @deprecated Use 'destroyed' instead.
147
+ */
148
+ @Output ( ) destroy = this . destroyed ;
139
149
140
150
/** Emitted when a chip is to be removed. */
141
- @Output ( 'remove' ) onRemove = new EventEmitter < MdChipEvent > ( ) ;
151
+ @Output ( ) removed = new EventEmitter < MdChipEvent > ( ) ;
152
+
153
+ /**
154
+ * Emitted when a chip is to be removed.
155
+ * @deprecated Use `removed` instead.
156
+ */
157
+ @Output ( 'remove' ) onRemove = this . removed ;
142
158
143
159
get ariaSelected ( ) : string | null {
144
160
return this . selectable ? this . selected . toString ( ) : null ;
@@ -149,32 +165,50 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr
149
165
}
150
166
151
167
ngOnDestroy ( ) : void {
152
- this . destroy . emit ( { chip : this } ) ;
168
+ this . destroyed . emit ( { chip : this } ) ;
153
169
}
154
170
155
171
/** Selects the chip. */
156
172
select ( ) : void {
157
173
this . _selected = true ;
158
- this . onSelectionChange . emit ( { source : this , isUserInput : false } ) ;
174
+ this . selectionChange . emit ( {
175
+ source : this ,
176
+ isUserInput : false ,
177
+ selected : true
178
+ } ) ;
159
179
}
160
180
161
181
/** Deselects the chip. */
162
182
deselect ( ) : void {
163
183
this . _selected = false ;
164
- this . onSelectionChange . emit ( { source : this , isUserInput : false } ) ;
184
+ this . selectionChange . emit ( {
185
+ source : this ,
186
+ isUserInput : false ,
187
+ selected : false
188
+ } ) ;
165
189
}
166
190
167
191
/** Select this chip and emit selected event */
168
- selectViaInteraction ( ) {
192
+ selectViaInteraction ( ) : void {
169
193
this . _selected = true ;
170
194
// Emit select event when selected changes.
171
- this . onSelectionChange . emit ( { source : this , isUserInput : true } ) ;
195
+ this . selectionChange . emit ( {
196
+ source : this ,
197
+ isUserInput : true ,
198
+ selected : true
199
+ } ) ;
172
200
}
173
201
174
202
/** Toggles the current selected state of this chip. */
175
203
toggleSelected ( isUserInput : boolean = false ) : boolean {
176
204
this . _selected = ! this . selected ;
177
- this . onSelectionChange . emit ( { source : this , isUserInput} ) ;
205
+
206
+ this . selectionChange . emit ( {
207
+ source : this ,
208
+ isUserInput,
209
+ selected : this . _selected
210
+ } ) ;
211
+
178
212
return this . selected ;
179
213
}
180
214
@@ -192,7 +226,7 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr
192
226
*/
193
227
remove ( ) : void {
194
228
if ( this . removable ) {
195
- this . onRemove . emit ( { chip : this } ) ;
229
+ this . removed . emit ( { chip : this } ) ;
196
230
}
197
231
}
198
232
@@ -210,7 +244,7 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr
210
244
}
211
245
212
246
/** Handle custom key presses. */
213
- _handleKeydown ( event : KeyboardEvent ) {
247
+ _handleKeydown ( event : KeyboardEvent ) : void {
214
248
if ( this . disabled ) {
215
249
return ;
216
250
}
@@ -235,7 +269,7 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr
235
269
}
236
270
}
237
271
238
- _blur ( ) {
272
+ _blur ( ) : void {
239
273
this . _hasFocus = false ;
240
274
this . _onBlur . next ( { chip : this } ) ;
241
275
}
@@ -266,7 +300,7 @@ export class MdChipRemove {
266
300
constructor ( protected _parentChip : MdChip ) { }
267
301
268
302
/** Calls the parent chip's public `remove()` method if applicable. */
269
- _handleClick ( ) {
303
+ _handleClick ( ) : void {
270
304
if ( this . _parentChip . removable ) {
271
305
this . _parentChip . remove ( ) ;
272
306
}
0 commit comments