@@ -8,7 +8,22 @@ export interface TimeSelectorProps extends TimePickerProps {
88 containerClassName ?: string ;
99}
1010
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+
1227 render ( ) : ReactNode {
1328 return (
1429 < FormGroup
@@ -23,12 +38,13 @@ export class TimeSelector extends Component<TimeSelectorProps> {
2338 ) }
2439 >
2540 < TimePicker
41+ className = { this . state . focus ? "focus" : "" }
2642 value = { this . props . value }
2743 placement = "bottomLeft"
2844 prefixCls = "time-input-widget"
2945 onChange = { this . props . onChange }
30- onOpen = { this . props . onOpen }
31- onClose = { this . props . onClose }
46+ onOpen = { this . onOpen }
47+ onClose = { this . onClose }
3248 allowEmpty = { false }
3349 use12Hours = { this . props . use12Hours }
3450 showHour = { this . props . showHour }
@@ -54,4 +70,18 @@ export class TimeSelector extends Component<TimeSelectorProps> {
5470 const { label } = this . props ;
5571 return label === null ? null : < label className = { classnames ( "control-label" , "col-sm-3" ) } > { label } </ label > ;
5672 }
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+ }
5787}
0 commit comments