diff options
Diffstat (limited to 'src/Panel.jsx')
-rw-r--r-- | src/Panel.jsx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Panel.jsx b/src/Panel.jsx index 8a6c872..4e09b57 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 | onKeyDown: PropTypes.func, | 46 | onKeyDown: PropTypes.func, |
44 | }; | 47 | }; |
@@ -92,6 +95,7 @@ class Panel extends Component { | |||
92 | prefixCls, className, placeholder, disabledHours, disabledMinutes, | 95 | prefixCls, className, placeholder, disabledHours, disabledMinutes, |
93 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, | 96 | disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, |
94 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, onKeyDown, | 97 | format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, onKeyDown, |
98 | hourStep, minuteStep, secondStep, | ||
95 | } = this.props; | 99 | } = this.props; |
96 | const { | 100 | const { |
97 | value, currentSelectPanel, | 101 | value, currentSelectPanel, |
@@ -100,9 +104,15 @@ class Panel extends Component { | |||
100 | const disabledMinuteOptions = disabledMinutes(value ? value.hour() : null); | 104 | const disabledMinuteOptions = disabledMinutes(value ? value.hour() : null); |
101 | const disabledSecondOptions = disabledSeconds(value ? value.hour() : null, | 105 | const disabledSecondOptions = disabledSeconds(value ? value.hour() : null, |
102 | value ? value.minute() : null); | 106 | value ? value.minute() : null); |
103 | const hourOptions = generateOptions(24, disabledHourOptions, hideDisabledOptions); | 107 | const hourOptions = generateOptions( |
104 | const minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions); | 108 | 24, disabledHourOptions, hideDisabledOptions, hourStep |
105 | const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions); | 109 | ); |
110 | const minuteOptions = generateOptions( | ||
111 | 60, disabledMinuteOptions, hideDisabledOptions, minuteStep | ||
112 | ); | ||
113 | const secondOptions = generateOptions( | ||
114 | 60, disabledSecondOptions, hideDisabledOptions, secondStep | ||
115 | ); | ||
106 | 116 | ||
107 | return ( | 117 | return ( |
108 | <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: !!className })}> | 118 | <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: !!className })}> |