aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/module/Combobox.jsx
diff options
context:
space:
mode:
authorMG12 <wuzhao.mail@gmail.com>2015-12-14 00:50:41 +0800
committerMG12 <wuzhao.mail@gmail.com>2015-12-14 00:50:41 +0800
commit71bd9bc11f2ca6068f7977ff3511b2798f73d0c6 (patch)
treee24404e929db29204fa008546377351d314f9480 /src/module/Combobox.jsx
parent0e62bf0b7bdc260e882fd185492939cbaed04d56 (diff)
downloadtime-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.tar.gz
time-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.tar.zst
time-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.zip
update disabled options
Diffstat (limited to 'src/module/Combobox.jsx')
-rw-r--r--src/module/Combobox.jsx22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/module/Combobox.jsx b/src/module/Combobox.jsx
index 1e172a7..7374b39 100644
--- a/src/module/Combobox.jsx
+++ b/src/module/Combobox.jsx
@@ -31,9 +31,9 @@ const Combobox = React.createClass({
31 hourOptions: PropTypes.array, 31 hourOptions: PropTypes.array,
32 minuteOptions: PropTypes.array, 32 minuteOptions: PropTypes.array,
33 secondOptions: PropTypes.array, 33 secondOptions: PropTypes.array,
34 disabledHours: PropTypes.array, 34 disabledHours: PropTypes.func,
35 disabledMinutes: PropTypes.array, 35 disabledMinutes: PropTypes.func,
36 disabledSeconds: PropTypes.array, 36 disabledSeconds: PropTypes.func,
37 onCurrentSelectPanelChange: PropTypes.func, 37 onCurrentSelectPanelChange: PropTypes.func,
38 }, 38 },
39 39
@@ -64,10 +64,12 @@ const Combobox = React.createClass({
64 if (!showHour) { 64 if (!showHour) {
65 return null; 65 return null;
66 } 66 }
67 const disabledOptions = disabledHours();
68
67 return ( 69 return (
68 <Select 70 <Select
69 prefixCls={prefixCls} 71 prefixCls={prefixCls}
70 options={hourOptions.map(option => formatOption(option, disabledHours))} 72 options={hourOptions.map(option => formatOption(option, disabledOptions))}
71 selectedIndex={hourOptions.indexOf(hour)} 73 selectedIndex={hourOptions.indexOf(hour)}
72 type="hour" 74 type="hour"
73 onSelect={this.onItemChange} 75 onSelect={this.onItemChange}
@@ -77,11 +79,13 @@ const Combobox = React.createClass({
77 }, 79 },
78 80
79 getMinuteSelect(minute) { 81 getMinuteSelect(minute) {
80 const { prefixCls, minuteOptions, disabledMinutes } = this.props; 82 const { prefixCls, minuteOptions, disabledMinutes, value } = this.props;
83 const disabledOptions = disabledMinutes(value.getHourOfDay());
84
81 return ( 85 return (
82 <Select 86 <Select
83 prefixCls={prefixCls} 87 prefixCls={prefixCls}
84 options={minuteOptions.map(option => formatOption(option, disabledMinutes))} 88 options={minuteOptions.map(option => formatOption(option, disabledOptions))}
85 selectedIndex={minuteOptions.indexOf(minute)} 89 selectedIndex={minuteOptions.indexOf(minute)}
86 type="minute" 90 type="minute"
87 onSelect={this.onItemChange} 91 onSelect={this.onItemChange}
@@ -91,14 +95,16 @@ const Combobox = React.createClass({
91 }, 95 },
92 96
93 getSecondSelect(second) { 97 getSecondSelect(second) {
94 const { prefixCls, secondOptions, disabledSeconds, showSecond } = this.props; 98 const { prefixCls, secondOptions, disabledSeconds, showSecond, value } = this.props;
95 if (!showSecond) { 99 if (!showSecond) {
96 return null; 100 return null;
97 } 101 }
102 const disabledOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes());
103
98 return ( 104 return (
99 <Select 105 <Select
100 prefixCls={prefixCls} 106 prefixCls={prefixCls}
101 options={secondOptions.map(option => formatOption(option, disabledSeconds))} 107 options={secondOptions.map(option => formatOption(option, disabledOptions))}
102 selectedIndex={secondOptions.indexOf(second)} 108 selectedIndex={secondOptions.indexOf(second)}
103 type="second" 109 type="second"
104 onSelect={this.onItemChange} 110 onSelect={this.onItemChange}