diff options
Diffstat (limited to 'src/Combobox.jsx')
-rw-r--r-- | src/Combobox.jsx | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/Combobox.jsx b/src/Combobox.jsx index 19fbd19..ae53356 100644 --- a/src/Combobox.jsx +++ b/src/Combobox.jsx | |||
@@ -37,6 +37,7 @@ class Combobox extends Component { | |||
37 | disabledSeconds: PropTypes.func, | 37 | disabledSeconds: PropTypes.func, |
38 | onCurrentSelectPanelChange: PropTypes.func, | 38 | onCurrentSelectPanelChange: PropTypes.func, |
39 | use12Hours: PropTypes.bool, | 39 | use12Hours: PropTypes.bool, |
40 | isAM: PropTypes.bool, | ||
40 | }; | 41 | }; |
41 | 42 | ||
42 | onItemChange = (type, itemValue) => { | 43 | onItemChange = (type, itemValue) => { |
@@ -45,7 +46,7 @@ class Combobox extends Component { | |||
45 | 46 | ||
46 | if (type === 'hour') { | 47 | if (type === 'hour') { |
47 | if (use12Hours) { | 48 | if (use12Hours) { |
48 | if (this.isAM()) { | 49 | if (this.props.isAM) { |
49 | value.hour(+itemValue % 12); | 50 | value.hour(+itemValue % 12); |
50 | } else { | 51 | } else { |
51 | value.hour((+itemValue % 12) + 12); | 52 | value.hour((+itemValue % 12) + 12); |
@@ -83,20 +84,12 @@ class Combobox extends Component { | |||
83 | if (!showHour) { | 84 | if (!showHour) { |
84 | return null; | 85 | return null; |
85 | } | 86 | } |
86 | let disabledOptions = disabledHours(); | 87 | const disabledOptions = disabledHours(); |
87 | let hourOptionsAdj; | 88 | let hourOptionsAdj; |
88 | let hourAdj; | 89 | let hourAdj; |
89 | if (use12Hours) { | 90 | if (use12Hours) { |
90 | hourOptionsAdj = [12].concat(hourOptions.filter(h => h < 12 && h > 0)); | 91 | hourOptionsAdj = [12].concat(hourOptions.filter(h => h < 12 && h > 0)); |
91 | hourAdj = (hour % 12) || 12; | 92 | hourAdj = (hour % 12) || 12; |
92 | |||
93 | if (Array.isArray(disabledOptions)) { | ||
94 | if (this.isAM()) { | ||
95 | disabledOptions = disabledOptions.filter(h => h < 12).map(h => (h === 0 ? 12 : h)); | ||
96 | } else { | ||
97 | disabledOptions = disabledOptions.map(h => (h === 12 ? 12 : h - 12)); | ||
98 | } | ||
99 | } | ||
100 | } else { | 93 | } else { |
101 | hourOptionsAdj = hourOptions; | 94 | hourOptionsAdj = hourOptions; |
102 | hourAdj = hour; | 95 | hourAdj = hour; |
@@ -164,7 +157,7 @@ class Combobox extends Component { | |||
164 | .map(c => format.match(/\sA/) ? c.toUpperCase() : c) | 157 | .map(c => format.match(/\sA/) ? c.toUpperCase() : c) |
165 | .map(c => ({ value: c })); | 158 | .map(c => ({ value: c })); |
166 | 159 | ||
167 | const selected = this.isAM() ? 0 : 1; | 160 | const selected = this.props.isAM ? 0 : 1; |
168 | 161 | ||
169 | return ( | 162 | return ( |
170 | <Select | 163 | <Select |
@@ -178,11 +171,6 @@ class Combobox extends Component { | |||
178 | ); | 171 | ); |
179 | } | 172 | } |
180 | 173 | ||
181 | isAM() { | ||
182 | const value = (this.props.value || this.props.defaultOpenValue); | ||
183 | return value.hour() >= 0 && value.hour() < 12; | ||
184 | } | ||
185 | |||
186 | render() { | 174 | render() { |
187 | const { prefixCls, defaultOpenValue } = this.props; | 175 | const { prefixCls, defaultOpenValue } = this.props; |
188 | const value = this.props.value || defaultOpenValue; | 176 | const value = this.props.value || defaultOpenValue; |