@@ -32,10 +32,10 @@ import { SbbOptionParentComponent, SBB_OPTION_PARENT_COMPONENT } from './option-
32
32
let uniqueIdCounter = 0 ;
33
33
34
34
/** Event object emitted by SbbOption when selected or deselected. */
35
- export class SbbOptionSelectionChange {
35
+ export class SbbOptionSelectionChange < T = any > {
36
36
constructor (
37
37
/** Reference to the option that emitted the event. */
38
- public source : SbbOption ,
38
+ public source : SbbOption < T > ,
39
39
/** Whether the change in the option's value was a result of a user action. */
40
40
public isUserInput = false
41
41
) { }
@@ -61,7 +61,9 @@ export class SbbOptionSelectionChange {
61
61
'[class.sbb-disabled]' : 'disabled' ,
62
62
} ,
63
63
} )
64
- export class SbbOption implements AfterViewChecked , OnDestroy , FocusableOption , Highlightable {
64
+ export class SbbOption < T = any >
65
+ implements AfterViewChecked , OnDestroy , FocusableOption , Highlightable
66
+ {
65
67
private _selected = false ;
66
68
private _active = false ;
67
69
private _disabled = false ;
@@ -81,7 +83,7 @@ export class SbbOption implements AfterViewChecked, OnDestroy, FocusableOption,
81
83
}
82
84
83
85
/** The form value of the option. */
84
- @Input ( ) value : any ;
86
+ @Input ( ) value : T ;
85
87
86
88
/** The unique ID of the option. */
87
89
@Input ( ) id : string = `sbb-option-${ uniqueIdCounter ++ } ` ;
@@ -98,7 +100,7 @@ export class SbbOption implements AfterViewChecked, OnDestroy, FocusableOption,
98
100
99
101
/** Event emitted when the option is selected or deselected. */
100
102
// tslint:disable-next-line:no-output-on-prefix
101
- @Output ( ) readonly onSelectionChange = new EventEmitter < SbbOptionSelectionChange > ( ) ;
103
+ @Output ( ) readonly onSelectionChange = new EventEmitter < SbbOptionSelectionChange < T > > ( ) ;
102
104
103
105
/** Emits when the state of the option changes and any parents have to be notified. */
104
106
readonly _stateChanges = new Subject < void > ( ) ;
@@ -341,7 +343,7 @@ export class SbbOption implements AfterViewChecked, OnDestroy, FocusableOption,
341
343
342
344
/** Emits the selection change event. */
343
345
private _emitSelectionChangeEvent ( isUserInput = false ) : void {
344
- this . onSelectionChange . emit ( new SbbOptionSelectionChange ( this , isUserInput ) ) ;
346
+ this . onSelectionChange . emit ( new SbbOptionSelectionChange < T > ( this , isUserInput ) ) ;
345
347
}
346
348
}
347
349
0 commit comments