aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Panel.jsx22
-rw-r--r--src/TimePicker.jsx8
2 files changed, 23 insertions, 7 deletions
diff --git a/src/Panel.jsx b/src/Panel.jsx
index 957c021..a1b7c77 100644
--- a/src/Panel.jsx
+++ b/src/Panel.jsx
@@ -8,9 +8,9 @@ import classNames from 'classnames';
8function noop() { 8function noop() {
9} 9}
10 10
11function generateOptions(length, disabledOptions, hideDisabledOptions) { 11function 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 focusOnOpen: PropTypes.bool, 46 focusOnOpen: PropTypes.bool,
44 onKeyDown: PropTypes.func, 47 onKeyDown: PropTypes.func,
@@ -92,7 +95,8 @@ class Panel extends Component {
92 const { 95 const {
93 prefixCls, className, placeholder, disabledHours, disabledMinutes, 96 prefixCls, className, placeholder, disabledHours, disabledMinutes,
94 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, 97 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond,
95 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, focusOnOpen, onKeyDown, 98 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear,
99 focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep,
96 } = this.props; 100 } = this.props;
97 const { 101 const {
98 value, currentSelectPanel, 102 value, currentSelectPanel,
@@ -101,9 +105,15 @@ class Panel extends Component {
101 const disabledMinuteOptions = disabledMinutes(value ? value.hour() : null); 105 const disabledMinuteOptions = disabledMinutes(value ? value.hour() : null);
102 const disabledSecondOptions = disabledSeconds(value ? value.hour() : null, 106 const disabledSecondOptions = disabledSeconds(value ? value.hour() : null,
103 value ? value.minute() : null); 107 value ? value.minute() : null);
104 const hourOptions = generateOptions(24, disabledHourOptions, hideDisabledOptions); 108 const hourOptions = generateOptions(
105 const minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions); 109 24, disabledHourOptions, hideDisabledOptions, hourStep
106 const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions); 110 );
111 const minuteOptions = generateOptions(
112 60, disabledMinuteOptions, hideDisabledOptions, minuteStep
113 );
114 const secondOptions = generateOptions(
115 60, disabledSecondOptions, hideDisabledOptions, secondStep
116 );
107 117
108 return ( 118 return (
109 <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: !!className })}> 119 <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: !!className })}>
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index 70327d7..c7ff80a 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -48,6 +48,9 @@ export default class Picker extends Component {
48 name: PropTypes.string, 48 name: PropTypes.string,
49 autoComplete: PropTypes.string, 49 autoComplete: PropTypes.string,
50 use12Hours: PropTypes.bool, 50 use12Hours: PropTypes.bool,
51 hourStep: PropTypes.number,
52 minuteStep: PropTypes.number,
53 secondStep: PropTypes.number,
51 focusOnOpen: PropTypes.bool, 54 focusOnOpen: PropTypes.bool,
52 onKeyDown: PropTypes.func, 55 onKeyDown: PropTypes.func,
53 }; 56 };
@@ -165,7 +168,7 @@ export default class Picker extends Component {
165 prefixCls, placeholder, disabledHours, 168 prefixCls, placeholder, disabledHours,
166 disabledMinutes, disabledSeconds, hideDisabledOptions, 169 disabledMinutes, disabledSeconds, hideDisabledOptions,
167 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, 170 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
168 addon, use12Hours, focusOnOpen, onKeyDown, 171 addon, use12Hours, focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep,
169 } = this.props; 172 } = this.props;
170 return ( 173 return (
171 <Panel 174 <Panel
@@ -188,6 +191,9 @@ export default class Picker extends Component {
188 disabledSeconds={disabledSeconds} 191 disabledSeconds={disabledSeconds}
189 hideDisabledOptions={hideDisabledOptions} 192 hideDisabledOptions={hideDisabledOptions}
190 use12Hours={use12Hours} 193 use12Hours={use12Hours}
194 hourStep={hourStep}
195 minuteStep={minuteStep}
196 secondStep={secondStep}
191 addon={addon} 197 addon={addon}
192 focusOnOpen={focusOnOpen} 198 focusOnOpen={focusOnOpen}
193 onKeyDown={onKeyDown} 199 onKeyDown={onKeyDown}