diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Panel.jsx | 20 | ||||
-rw-r--r-- | src/TimePicker.jsx | 8 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/Panel.jsx b/src/Panel.jsx index 1953ad4..468eb37 100644 --- a/src/Panel.jsx +++ b/src/Panel.jsx | |||
@@ -8,9 +8,9 @@ import classNames from 'classnames'; | |||
8 | function noop() { | 8 | function noop() { |
9 | } | 9 | } |
10 | 10 | ||
11 | function generateOptions(length, disabledOptions, hideDisabledOptions) { | 11 | function generateOptions(length, disabledOptions, hideDisabledOptions, step = 1) { |
12 | const arr = []; | 12 | const arr = []; |
13 | for (let value = 0; value < length; value++) { | 13 | for (let value = 0; value < length; value += step) { |
14 | if (!disabledOptions || disabledOptions.indexOf(value) < 0 || !hideDisabledOptions) { | 14 | if (!disabledOptions || disabledOptions.indexOf(value) < 0 || !hideDisabledOptions) { |
15 | arr.push(value); | 15 | arr.push(value); |
16 | } | 16 | } |
@@ -39,6 +39,9 @@ class Panel extends Component { | |||
39 | showSecond: PropTypes.bool, | 39 | showSecond: PropTypes.bool, |
40 | onClear: PropTypes.func, | 40 | onClear: PropTypes.func, |
41 | use12Hours: PropTypes.bool, | 41 | use12Hours: PropTypes.bool, |
42 | hourStep: PropTypes.number, | ||
43 | minuteStep: PropTypes.number, | ||
44 | secondStep: PropTypes.number, | ||
42 | addon: PropTypes.func, | 45 | addon: PropTypes.func, |
43 | }; | 46 | }; |
44 | 47 | ||
@@ -90,6 +93,7 @@ class Panel extends Component { | |||
90 | prefixCls, className, placeholder, disabledHours, disabledMinutes, | 93 | prefixCls, className, placeholder, disabledHours, disabledMinutes, |
91 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, | 94 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, |
92 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, | 95 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, |
96 | hourStep, minuteStep, secondStep, | ||
93 | } = this.props; | 97 | } = this.props; |
94 | const { | 98 | const { |
95 | value, currentSelectPanel, | 99 | value, currentSelectPanel, |
@@ -98,9 +102,15 @@ class Panel extends Component { | |||
98 | const disabledMinuteOptions = disabledMinutes(value ? value.hour() : null); | 102 | const disabledMinuteOptions = disabledMinutes(value ? value.hour() : null); |
99 | const disabledSecondOptions = disabledSeconds(value ? value.hour() : null, | 103 | const disabledSecondOptions = disabledSeconds(value ? value.hour() : null, |
100 | value ? value.minute() : null); | 104 | value ? value.minute() : null); |
101 | const hourOptions = generateOptions(24, disabledHourOptions, hideDisabledOptions); | 105 | const hourOptions = generateOptions( |
102 | const minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions); | 106 | 24, disabledHourOptions, hideDisabledOptions, hourStep |
103 | const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions); | 107 | ); |
108 | const minuteOptions = generateOptions( | ||
109 | 60, disabledMinuteOptions, hideDisabledOptions, minuteStep | ||
110 | ); | ||
111 | const secondOptions = generateOptions( | ||
112 | 60, disabledSecondOptions, hideDisabledOptions, secondStep | ||
113 | ); | ||
104 | 114 | ||
105 | return ( | 115 | return ( |
106 | <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: !!className })}> | 116 | <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: !!className })}> |
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index 2c6a1f1..85dc3e2 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx | |||
@@ -46,6 +46,9 @@ export default class Picker extends Component { | |||
46 | name: PropTypes.string, | 46 | name: PropTypes.string, |
47 | autoComplete: PropTypes.string, | 47 | autoComplete: PropTypes.string, |
48 | use12Hours: PropTypes.bool, | 48 | use12Hours: PropTypes.bool, |
49 | hourStep: PropTypes.number, | ||
50 | minuteStep: PropTypes.number, | ||
51 | secondStep: PropTypes.number, | ||
49 | }; | 52 | }; |
50 | 53 | ||
51 | static defaultProps = { | 54 | static defaultProps = { |
@@ -157,7 +160,7 @@ export default class Picker extends Component { | |||
157 | prefixCls, placeholder, disabledHours, | 160 | prefixCls, placeholder, disabledHours, |
158 | disabledMinutes, disabledSeconds, hideDisabledOptions, | 161 | disabledMinutes, disabledSeconds, hideDisabledOptions, |
159 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, | 162 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, |
160 | addon, use12Hours, | 163 | addon, use12Hours, hourStep, minuteStep, secondStep, |
161 | } = this.props; | 164 | } = this.props; |
162 | return ( | 165 | return ( |
163 | <Panel | 166 | <Panel |
@@ -180,6 +183,9 @@ export default class Picker extends Component { | |||
180 | disabledSeconds={disabledSeconds} | 183 | disabledSeconds={disabledSeconds} |
181 | hideDisabledOptions={hideDisabledOptions} | 184 | hideDisabledOptions={hideDisabledOptions} |
182 | use12Hours={use12Hours} | 185 | use12Hours={use12Hours} |
186 | hourStep={hourStep} | ||
187 | minuteStep={minuteStep} | ||
188 | secondStep={secondStep} | ||
183 | addon={addon} | 189 | addon={addon} |
184 | /> | 190 | /> |
185 | ); | 191 | ); |