From: Wei Zhu Date: Fri, 23 Feb 2018 03:16:42 +0000 (+0800) Subject: Lift disabledHours to Panel X-Git-Tag: 3.3.1~2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=7211e9ba9d88c89444e7909190e7c51d298200ad;p=github%2Ffretlink%2Ftime-picker.git Lift disabledHours to Panel --- 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 { disabledSeconds: PropTypes.func, onCurrentSelectPanelChange: PropTypes.func, use12Hours: PropTypes.bool, + isAM: PropTypes.bool, }; onItemChange = (type, itemValue) => { @@ -45,7 +46,7 @@ class Combobox extends Component { if (type === 'hour') { if (use12Hours) { - if (this.isAM()) { + if (this.props.isAM) { value.hour(+itemValue % 12); } else { value.hour((+itemValue % 12) + 12); @@ -83,20 +84,12 @@ class Combobox extends Component { if (!showHour) { return null; } - let disabledOptions = disabledHours(); + const disabledOptions = disabledHours(); let hourOptionsAdj; let hourAdj; if (use12Hours) { hourOptionsAdj = [12].concat(hourOptions.filter(h => h < 12 && h > 0)); hourAdj = (hour % 12) || 12; - - if (Array.isArray(disabledOptions)) { - if (this.isAM()) { - disabledOptions = disabledOptions.filter(h => h < 12).map(h => (h === 0 ? 12 : h)); - } else { - disabledOptions = disabledOptions.map(h => (h === 12 ? 12 : h - 12)); - } - } } else { hourOptionsAdj = hourOptions; hourAdj = hour; @@ -164,7 +157,7 @@ class Combobox extends Component { .map(c => format.match(/\sA/) ? c.toUpperCase() : c) .map(c => ({ value: c })); - const selected = this.isAM() ? 0 : 1; + const selected = this.props.isAM ? 0 : 1; return (