@@ -8,7 +8,22 @@ export interface TimeSelectorProps extends TimePickerProps {
8
8
containerClassName ?: string ;
9
9
}
10
10
11
- export class TimeSelector extends Component < TimeSelectorProps > {
11
+ interface TimeSelectorState {
12
+ focus : boolean ;
13
+ }
14
+
15
+ export class TimeSelector extends Component < TimeSelectorProps , TimeSelectorState > {
16
+ onOpen = this . openHandler . bind ( this ) ;
17
+ onClose = this . closeHandler . bind ( this ) ;
18
+
19
+ constructor ( props : TimeSelectorProps ) {
20
+ super ( props ) ;
21
+
22
+ this . state = {
23
+ focus : false
24
+ } ;
25
+ }
26
+
12
27
render ( ) : ReactNode {
13
28
return (
14
29
< FormGroup
@@ -23,12 +38,13 @@ export class TimeSelector extends Component<TimeSelectorProps> {
23
38
) }
24
39
>
25
40
< TimePicker
41
+ className = { this . state . focus ? "focus" : "" }
26
42
value = { this . props . value }
27
43
placement = "bottomLeft"
28
44
prefixCls = "time-input-widget"
29
45
onChange = { this . props . onChange }
30
- onOpen = { this . props . onOpen }
31
- onClose = { this . props . onClose }
46
+ onOpen = { this . onOpen }
47
+ onClose = { this . onClose }
32
48
allowEmpty = { false }
33
49
use12Hours = { this . props . use12Hours }
34
50
showHour = { this . props . showHour }
@@ -54,4 +70,18 @@ export class TimeSelector extends Component<TimeSelectorProps> {
54
70
const { label } = this . props ;
55
71
return label === null ? null : < label className = { classnames ( "control-label" , "col-sm-3" ) } > { label } </ label > ;
56
72
}
73
+
74
+ openHandler ( ) : void {
75
+ this . setState ( { focus : true } ) ;
76
+ if ( this . props . onOpen ) {
77
+ this . props . onOpen ( { open : true } ) ;
78
+ }
79
+ }
80
+
81
+ closeHandler ( ) : void {
82
+ this . setState ( { focus : false } ) ;
83
+ if ( this . props . onClose ) {
84
+ this . props . onClose ( { open : false } ) ;
85
+ }
86
+ }
57
87
}
0 commit comments