diff options
author | 偏右 <afc163@gmail.com> | 2017-10-22 16:25:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-22 16:25:33 +0800 |
commit | cc2dca8a2bb0bf3b820903043be2586fb413c458 (patch) | |
tree | 4e0621e9b18f7938ffc31b87263182c79793d581 /src | |
parent | 5827568ef882ae5a474f37ff5c843e931528ebe8 (diff) | |
parent | b6767d8a08ccfc52836e09e3a0886a5cf225b93f (diff) | |
download | time-picker-cc2dca8a2bb0bf3b820903043be2586fb413c458.tar.gz time-picker-cc2dca8a2bb0bf3b820903043be2586fb413c458.tar.zst time-picker-cc2dca8a2bb0bf3b820903043be2586fb413c458.zip |
Merge branch 'master' into picker-step
Diffstat (limited to 'src')
-rw-r--r-- | src/Header.jsx | 6 | ||||
-rw-r--r-- | src/Panel.jsx | 5 | ||||
-rw-r--r-- | src/Select.jsx | 8 | ||||
-rw-r--r-- | src/TimePicker.jsx | 12 |
4 files changed, 26 insertions, 5 deletions
diff --git a/src/Header.jsx b/src/Header.jsx index 91e8549..f6dd241 100644 --- a/src/Header.jsx +++ b/src/Header.jsx | |||
@@ -22,6 +22,7 @@ class Header extends Component { | |||
22 | allowEmpty: PropTypes.bool, | 22 | allowEmpty: PropTypes.bool, |
23 | defaultOpenValue: PropTypes.object, | 23 | defaultOpenValue: PropTypes.object, |
24 | currentSelectPanel: PropTypes.string, | 24 | currentSelectPanel: PropTypes.string, |
25 | onKeyDown: PropTypes.func, | ||
25 | }; | 26 | }; |
26 | 27 | ||
27 | constructor(props) { | 28 | constructor(props) { |
@@ -122,9 +123,12 @@ class Header extends Component { | |||
122 | } | 123 | } |
123 | 124 | ||
124 | onKeyDown = (e) => { | 125 | onKeyDown = (e) => { |
126 | const { onEsc, onKeyDown } = this.props; | ||
125 | if (e.keyCode === 27) { | 127 | if (e.keyCode === 27) { |
126 | this.props.onEsc(); | 128 | onEsc(); |
127 | } | 129 | } |
130 | |||
131 | onKeyDown(e); | ||
128 | } | 132 | } |
129 | 133 | ||
130 | onClear = () => { | 134 | onClear = () => { |
diff --git a/src/Panel.jsx b/src/Panel.jsx index 468eb37..4e09b57 100644 --- a/src/Panel.jsx +++ b/src/Panel.jsx | |||
@@ -43,6 +43,7 @@ class Panel extends Component { | |||
43 | minuteStep: PropTypes.number, | 43 | minuteStep: PropTypes.number, |
44 | secondStep: PropTypes.number, | 44 | secondStep: PropTypes.number, |
45 | addon: PropTypes.func, | 45 | addon: PropTypes.func, |
46 | onKeyDown: PropTypes.func, | ||
46 | }; | 47 | }; |
47 | 48 | ||
48 | static defaultProps = { | 49 | static defaultProps = { |
@@ -55,6 +56,7 @@ class Panel extends Component { | |||
55 | defaultOpenValue: moment(), | 56 | defaultOpenValue: moment(), |
56 | use12Hours: false, | 57 | use12Hours: false, |
57 | addon: noop, | 58 | addon: noop, |
59 | onKeyDown: noop, | ||
58 | }; | 60 | }; |
59 | 61 | ||
60 | constructor(props) { | 62 | constructor(props) { |
@@ -92,7 +94,7 @@ class Panel extends Component { | |||
92 | const { | 94 | const { |
93 | prefixCls, className, placeholder, disabledHours, disabledMinutes, | 95 | prefixCls, className, placeholder, disabledHours, disabledMinutes, |
94 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, | 96 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, |
95 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, | 97 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, onKeyDown, |
96 | hourStep, minuteStep, secondStep, | 98 | hourStep, minuteStep, secondStep, |
97 | } = this.props; | 99 | } = this.props; |
98 | const { | 100 | const { |
@@ -132,6 +134,7 @@ class Panel extends Component { | |||
132 | onChange={this.onChange} | 134 | onChange={this.onChange} |
133 | onClear={onClear} | 135 | onClear={onClear} |
134 | allowEmpty={allowEmpty} | 136 | allowEmpty={allowEmpty} |
137 | onKeyDown={onKeyDown} | ||
135 | /> | 138 | /> |
136 | <Combobox | 139 | <Combobox |
137 | prefixCls={prefixCls} | 140 | 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 85dc3e2..5f2239a 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx | |||
@@ -42,6 +42,8 @@ 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, |
@@ -49,6 +51,7 @@ export default class Picker extends Component { | |||
49 | hourStep: PropTypes.number, | 51 | hourStep: PropTypes.number, |
50 | minuteStep: PropTypes.number, | 52 | minuteStep: PropTypes.number, |
51 | secondStep: PropTypes.number, | 53 | secondStep: PropTypes.number, |
54 | onKeyDown: PropTypes.func, | ||
52 | }; | 55 | }; |
53 | 56 | ||
54 | static defaultProps = { | 57 | static defaultProps = { |
@@ -72,8 +75,11 @@ export default class Picker extends Component { | |||
72 | onChange: noop, | 75 | onChange: noop, |
73 | onOpen: noop, | 76 | onOpen: noop, |
74 | onClose: noop, | 77 | onClose: noop, |
78 | onFocus: noop, | ||
79 | onBlur: noop, | ||
75 | addon: noop, | 80 | addon: noop, |
76 | use12Hours: false, | 81 | use12Hours: false, |
82 | onKeyDown: noop, | ||
77 | }; | 83 | }; |
78 | 84 | ||
79 | constructor(props) { | 85 | constructor(props) { |
@@ -160,7 +166,7 @@ export default class Picker extends Component { | |||
160 | prefixCls, placeholder, disabledHours, | 166 | prefixCls, placeholder, disabledHours, |
161 | disabledMinutes, disabledSeconds, hideDisabledOptions, | 167 | disabledMinutes, disabledSeconds, hideDisabledOptions, |
162 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, | 168 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, |
163 | addon, use12Hours, hourStep, minuteStep, secondStep, | 169 | addon, use12Hours, onKeyDown, hourStep, minuteStep, secondStep, |
164 | } = this.props; | 170 | } = this.props; |
165 | return ( | 171 | return ( |
166 | <Panel | 172 | <Panel |
@@ -187,6 +193,7 @@ export default class Picker extends Component { | |||
187 | minuteStep={minuteStep} | 193 | minuteStep={minuteStep} |
188 | secondStep={secondStep} | 194 | secondStep={secondStep} |
189 | addon={addon} | 195 | addon={addon} |
196 | onKeyDown={onKeyDown} | ||
190 | /> | 197 | /> |
191 | ); | 198 | ); |
192 | } | 199 | } |
@@ -237,6 +244,7 @@ export default class Picker extends Component { | |||
237 | const { | 244 | const { |
238 | prefixCls, placeholder, placement, align, | 245 | prefixCls, placeholder, placement, align, |
239 | disabled, transitionName, style, className, getPopupContainer, name, autoComplete, | 246 | disabled, transitionName, style, className, getPopupContainer, name, autoComplete, |
247 | onFocus, onBlur, | ||
240 | } = this.props; | 248 | } = this.props; |
241 | const { open, value } = this.state; | 249 | const { open, value } = this.state; |
242 | const popupClassName = this.getPopupClassName(); | 250 | const popupClassName = this.getPopupClassName(); |
@@ -266,6 +274,8 @@ export default class Picker extends Component { | |||
266 | onKeyDown={this.onKeyDown} | 274 | onKeyDown={this.onKeyDown} |
267 | disabled={disabled} value={value && value.format(this.getFormat()) || ''} | 275 | disabled={disabled} value={value && value.format(this.getFormat()) || ''} |
268 | autoComplete={autoComplete} | 276 | autoComplete={autoComplete} |
277 | onFocus={onFocus} | ||
278 | onBlur={onBlur} | ||
269 | /> | 279 | /> |
270 | <span className={`${prefixCls}-icon`}/> | 280 | <span className={`${prefixCls}-icon`}/> |
271 | </span> | 281 | </span> |