aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Combobox.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Combobox.jsx')
-rw-r--r--src/Combobox.jsx31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/Combobox.jsx b/src/Combobox.jsx
index 477c5ee..1eed4d2 100644
--- a/src/Combobox.jsx
+++ b/src/Combobox.jsx
@@ -1,4 +1,5 @@
1import React, { PropTypes } from 'react'; 1import React, { Component } from 'react';
2import PropTypes from 'prop-types';
2import Select from './Select'; 3import Select from './Select';
3 4
4const formatOption = (option, disabledOptions) => { 5const formatOption = (option, disabledOptions) => {
@@ -18,8 +19,8 @@ const formatOption = (option, disabledOptions) => {
18 }; 19 };
19}; 20};
20 21
21const Combobox = React.createClass({ 22class Combobox extends Component {
22 propTypes: { 23 static propTypes = {
23 format: PropTypes.string, 24 format: PropTypes.string,
24 defaultOpenValue: PropTypes.object, 25 defaultOpenValue: PropTypes.object,
25 prefixCls: PropTypes.string, 26 prefixCls: PropTypes.string,
@@ -36,9 +37,9 @@ const Combobox = React.createClass({
36 disabledSeconds: PropTypes.func, 37 disabledSeconds: PropTypes.func,
37 onCurrentSelectPanelChange: PropTypes.func, 38 onCurrentSelectPanelChange: PropTypes.func,
38 use12Hours: PropTypes.bool, 39 use12Hours: PropTypes.bool,
39 }, 40 };
40 41
41 onItemChange(type, itemValue) { 42 onItemChange = (type, itemValue) => {
42 const { onChange, defaultOpenValue, use12Hours } = this.props; 43 const { onChange, defaultOpenValue, use12Hours } = this.props;
43 const value = (this.props.value || defaultOpenValue).clone(); 44 const value = (this.props.value || defaultOpenValue).clone();
44 45
@@ -71,11 +72,11 @@ const Combobox = React.createClass({
71 value.second(+itemValue); 72 value.second(+itemValue);
72 } 73 }
73 onChange(value); 74 onChange(value);
74 }, 75 }
75 76
76 onEnterSelectPanel(range) { 77 onEnterSelectPanel = (range) => {
77 this.props.onCurrentSelectPanelChange(range); 78 this.props.onCurrentSelectPanelChange(range);
78 }, 79 }
79 80
80 getHourSelect(hour) { 81 getHourSelect(hour) {
81 const { prefixCls, hourOptions, disabledHours, showHour, use12Hours } = this.props; 82 const { prefixCls, hourOptions, disabledHours, showHour, use12Hours } = this.props;
@@ -103,7 +104,7 @@ const Combobox = React.createClass({
103 onMouseEnter={this.onEnterSelectPanel.bind(this, 'hour')} 104 onMouseEnter={this.onEnterSelectPanel.bind(this, 'hour')}
104 /> 105 />
105 ); 106 );
106 }, 107 }
107 108
108 getMinuteSelect(minute) { 109 getMinuteSelect(minute) {
109 const { prefixCls, minuteOptions, disabledMinutes, defaultOpenValue, showMinute } = this.props; 110 const { prefixCls, minuteOptions, disabledMinutes, defaultOpenValue, showMinute } = this.props;
@@ -123,7 +124,7 @@ const Combobox = React.createClass({
123 onMouseEnter={this.onEnterSelectPanel.bind(this, 'minute')} 124 onMouseEnter={this.onEnterSelectPanel.bind(this, 'minute')}
124 /> 125 />
125 ); 126 );
126 }, 127 }
127 128
128 getSecondSelect(second) { 129 getSecondSelect(second) {
129 const { prefixCls, secondOptions, disabledSeconds, showSecond, defaultOpenValue } = this.props; 130 const { prefixCls, secondOptions, disabledSeconds, showSecond, defaultOpenValue } = this.props;
@@ -143,7 +144,7 @@ const Combobox = React.createClass({
143 onMouseEnter={this.onEnterSelectPanel.bind(this, 'second')} 144 onMouseEnter={this.onEnterSelectPanel.bind(this, 'second')}
144 /> 145 />
145 ); 146 );
146 }, 147 }
147 148
148 getAMPMSelect() { 149 getAMPMSelect() {
149 const { prefixCls, use12Hours, format } = this.props; 150 const { prefixCls, use12Hours, format } = this.props;
@@ -167,12 +168,12 @@ const Combobox = React.createClass({
167 onMouseEnter={this.onEnterSelectPanel.bind(this, 'ampm')} 168 onMouseEnter={this.onEnterSelectPanel.bind(this, 'ampm')}
168 /> 169 />
169 ); 170 );
170 }, 171 }
171 172
172 isAM() { 173 isAM() {
173 const value = (this.props.value || this.props.defaultOpenValue); 174 const value = (this.props.value || this.props.defaultOpenValue);
174 return value.hour() >= 0 && value.hour() < 12; 175 return value.hour() >= 0 && value.hour() < 12;
175 }, 176 }
176 177
177 render() { 178 render() {
178 const { prefixCls, defaultOpenValue } = this.props; 179 const { prefixCls, defaultOpenValue } = this.props;
@@ -185,7 +186,7 @@ const Combobox = React.createClass({
185 {this.getAMPMSelect(value.hour())} 186 {this.getAMPMSelect(value.hour())}
186 </div> 187 </div>
187 ); 188 );
188 }, 189 }
189}); 190}
190 191
191export default Combobox; 192export default Combobox;