aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Header.jsx6
-rw-r--r--src/Panel.jsx5
-rw-r--r--src/Select.jsx8
-rw-r--r--src/TimePicker.jsx12
4 files changed, 26 insertions, 5 deletions
diff --git a/src/Header.jsx b/src/Header.jsx
index 6bed557..1520d25 100644
--- a/src/Header.jsx
+++ b/src/Header.jsx
@@ -23,6 +23,7 @@ class Header extends Component {
23 defaultOpenValue: PropTypes.object, 23 defaultOpenValue: PropTypes.object,
24 currentSelectPanel: PropTypes.string, 24 currentSelectPanel: PropTypes.string,
25 focusOnOpen: PropTypes.bool, 25 focusOnOpen: PropTypes.bool,
26 onKeyDown: PropTypes.func,
26 }; 27 };
27 28
28 constructor(props) { 29 constructor(props) {
@@ -134,9 +135,12 @@ class Header extends Component {
134 } 135 }
135 136
136 onKeyDown = (e) => { 137 onKeyDown = (e) => {
138 const { onEsc, onKeyDown } = this.props;
137 if (e.keyCode === 27) { 139 if (e.keyCode === 27) {
138 this.props.onEsc(); 140 onEsc();
139 } 141 }
142
143 onKeyDown(e);
140 } 144 }
141 145
142 onClear = () => { 146 onClear = () => {
diff --git a/src/Panel.jsx b/src/Panel.jsx
index deeba52..957c021 100644
--- a/src/Panel.jsx
+++ b/src/Panel.jsx
@@ -41,6 +41,7 @@ class Panel extends Component {
41 use12Hours: PropTypes.bool, 41 use12Hours: PropTypes.bool,
42 addon: PropTypes.func, 42 addon: PropTypes.func,
43 focusOnOpen: PropTypes.bool, 43 focusOnOpen: PropTypes.bool,
44 onKeyDown: PropTypes.func,
44 }; 45 };
45 46
46 static defaultProps = { 47 static defaultProps = {
@@ -53,6 +54,7 @@ class Panel extends Component {
53 defaultOpenValue: moment(), 54 defaultOpenValue: moment(),
54 use12Hours: false, 55 use12Hours: false,
55 addon: noop, 56 addon: noop,
57 onKeyDown: noop,
56 }; 58 };
57 59
58 constructor(props) { 60 constructor(props) {
@@ -90,7 +92,7 @@ class Panel extends Component {
90 const { 92 const {
91 prefixCls, className, placeholder, disabledHours, disabledMinutes, 93 prefixCls, className, placeholder, disabledHours, disabledMinutes,
92 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, 94 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond,
93 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, focusOnOpen, 95 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, focusOnOpen, onKeyDown,
94 } = this.props; 96 } = this.props;
95 const { 97 const {
96 value, currentSelectPanel, 98 value, currentSelectPanel,
@@ -124,6 +126,7 @@ class Panel extends Component {
124 onClear={onClear} 126 onClear={onClear}
125 allowEmpty={allowEmpty} 127 allowEmpty={allowEmpty}
126 focusOnOpen={focusOnOpen} 128 focusOnOpen={focusOnOpen}
129 onKeyDown={onKeyDown}
127 /> 130 />
128 <Combobox 131 <Combobox
129 prefixCls={prefixCls} 132 prefixCls={prefixCls}
diff --git a/src/Select.jsx b/src/Select.jsx
index 49fed5b..a51ffd2 100644
--- a/src/Select.jsx
+++ b/src/Select.jsx
@@ -79,7 +79,7 @@ class Select extends Component {
79 scrollToSelected(duration) { 79 scrollToSelected(duration) {
80 // move to selected item 80 // move to selected item
81 const select = ReactDom.findDOMNode(this); 81 const select = ReactDom.findDOMNode(this);
82 const list = ReactDom.findDOMNode(this.refs.list); 82 const list = ReactDom.findDOMNode(this.list);
83 if (!list) { 83 if (!list) {
84 return; 84 return;
85 } 85 }
@@ -101,6 +101,10 @@ class Select extends Component {
101 this.setState({ active: false }); 101 this.setState({ active: false });
102 } 102 }
103 103
104 saveList = (node) => {
105 this.list = node;
106 }
107
104 render() { 108 render() {
105 if (this.props.options.length === 0) { 109 if (this.props.options.length === 0) {
106 return null; 110 return null;
@@ -118,7 +122,7 @@ class Select extends Component {
118 onMouseEnter={this.handleMouseEnter} 122 onMouseEnter={this.handleMouseEnter}
119 onMouseLeave={this.handleMouseLeave} 123 onMouseLeave={this.handleMouseLeave}
120 > 124 >
121 <ul ref="list">{this.getOptions()}</ul> 125 <ul ref={this.saveList}>{this.getOptions()}</ul>
122 </div> 126 </div>
123 ); 127 );
124 } 128 }
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index e017527..70327d7 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -42,11 +42,14 @@ export default class Picker extends Component {
42 onChange: PropTypes.func, 42 onChange: PropTypes.func,
43 onOpen: PropTypes.func, 43 onOpen: PropTypes.func,
44 onClose: PropTypes.func, 44 onClose: PropTypes.func,
45 onFocus: PropTypes.func,
46 onBlur: PropTypes.func,
45 addon: PropTypes.func, 47 addon: PropTypes.func,
46 name: PropTypes.string, 48 name: PropTypes.string,
47 autoComplete: PropTypes.string, 49 autoComplete: PropTypes.string,
48 use12Hours: PropTypes.bool, 50 use12Hours: PropTypes.bool,
49 focusOnOpen: PropTypes.bool, 51 focusOnOpen: PropTypes.bool,
52 onKeyDown: PropTypes.func,
50 }; 53 };
51 54
52 static defaultProps = { 55 static defaultProps = {
@@ -70,9 +73,12 @@ export default class Picker extends Component {
70 onChange: noop, 73 onChange: noop,
71 onOpen: noop, 74 onOpen: noop,
72 onClose: noop, 75 onClose: noop,
76 onFocus: noop,
77 onBlur: noop,
73 addon: noop, 78 addon: noop,
74 use12Hours: false, 79 use12Hours: false,
75 focusOnOpen: false, 80 focusOnOpen: false,
81 onKeyDown: noop,
76 }; 82 };
77 83
78 constructor(props) { 84 constructor(props) {
@@ -159,7 +165,7 @@ export default class Picker extends Component {
159 prefixCls, placeholder, disabledHours, 165 prefixCls, placeholder, disabledHours,
160 disabledMinutes, disabledSeconds, hideDisabledOptions, 166 disabledMinutes, disabledSeconds, hideDisabledOptions,
161 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, 167 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
162 addon, use12Hours, focusOnOpen, 168 addon, use12Hours, focusOnOpen, onKeyDown,
163 } = this.props; 169 } = this.props;
164 return ( 170 return (
165 <Panel 171 <Panel
@@ -184,6 +190,7 @@ export default class Picker extends Component {
184 use12Hours={use12Hours} 190 use12Hours={use12Hours}
185 addon={addon} 191 addon={addon}
186 focusOnOpen={focusOnOpen} 192 focusOnOpen={focusOnOpen}
193 onKeyDown={onKeyDown}
187 /> 194 />
188 ); 195 );
189 } 196 }
@@ -234,6 +241,7 @@ export default class Picker extends Component {
234 const { 241 const {
235 prefixCls, placeholder, placement, align, 242 prefixCls, placeholder, placement, align,
236 disabled, transitionName, style, className, getPopupContainer, name, autoComplete, 243 disabled, transitionName, style, className, getPopupContainer, name, autoComplete,
244 onFocus, onBlur,
237 } = this.props; 245 } = this.props;
238 const { open, value } = this.state; 246 const { open, value } = this.state;
239 const popupClassName = this.getPopupClassName(); 247 const popupClassName = this.getPopupClassName();
@@ -263,6 +271,8 @@ export default class Picker extends Component {
263 onKeyDown={this.onKeyDown} 271 onKeyDown={this.onKeyDown}
264 disabled={disabled} value={value && value.format(this.getFormat()) || ''} 272 disabled={disabled} value={value && value.format(this.getFormat()) || ''}
265 autoComplete={autoComplete} 273 autoComplete={autoComplete}
274 onFocus={onFocus}
275 onBlur={onBlur}
266 /> 276 />
267 <span className={`${prefixCls}-icon`}/> 277 <span className={`${prefixCls}-icon`}/>
268 </span> 278 </span>