diff options
Diffstat (limited to 'src/TimePicker.jsx')
-rw-r--r-- | src/TimePicker.jsx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index 358b596..e9f18a9 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx | |||
@@ -29,9 +29,10 @@ const Picker = React.createClass({ | |||
29 | placeholder: PropTypes.string, | 29 | placeholder: PropTypes.string, |
30 | format: PropTypes.string, | 30 | format: PropTypes.string, |
31 | showHour: PropTypes.bool, | 31 | showHour: PropTypes.bool, |
32 | showMinute: PropTypes.bool, | ||
33 | showSecond: PropTypes.bool, | ||
32 | style: PropTypes.object, | 34 | style: PropTypes.object, |
33 | className: PropTypes.string, | 35 | className: PropTypes.string, |
34 | showSecond: PropTypes.bool, | ||
35 | disabledHours: PropTypes.func, | 36 | disabledHours: PropTypes.func, |
36 | disabledMinutes: PropTypes.func, | 37 | disabledMinutes: PropTypes.func, |
37 | disabledSeconds: PropTypes.func, | 38 | disabledSeconds: PropTypes.func, |
@@ -53,6 +54,7 @@ const Picker = React.createClass({ | |||
53 | defaultOpenValue: moment(), | 54 | defaultOpenValue: moment(), |
54 | allowEmpty: true, | 55 | allowEmpty: true, |
55 | showHour: true, | 56 | showHour: true, |
57 | showMinute: true, | ||
56 | showSecond: true, | 58 | showSecond: true, |
57 | disabledHours: noop, | 59 | disabledHours: noop, |
58 | disabledMinutes: noop, | 60 | disabledMinutes: noop, |
@@ -121,24 +123,22 @@ const Picker = React.createClass({ | |||
121 | }, | 123 | }, |
122 | 124 | ||
123 | getFormat() { | 125 | getFormat() { |
124 | const format = this.props.format; | 126 | const { format, showHour, showMinute, showSecond } = this.props; |
125 | if (format) { | 127 | if (format) { |
126 | return format; | 128 | return format; |
127 | } | 129 | } |
128 | if (!this.props.showSecond) { | 130 | return [ |
129 | return 'HH:mm'; | 131 | showHour ? 'HH' : '', |
130 | } | 132 | showMinute ? 'mm' : '', |
131 | if (!this.props.showHour) { | 133 | showSecond ? 'ss' : '', |
132 | return 'mm:ss'; | 134 | ].filter(item => !!item).join(':'); |
133 | } | ||
134 | return 'HH:mm:ss'; | ||
135 | }, | 135 | }, |
136 | 136 | ||
137 | getPanelElement() { | 137 | getPanelElement() { |
138 | const { | 138 | const { |
139 | prefixCls, placeholder, disabledHours, | 139 | prefixCls, placeholder, disabledHours, |
140 | disabledMinutes, disabledSeconds, hideDisabledOptions, | 140 | disabledMinutes, disabledSeconds, hideDisabledOptions, |
141 | allowEmpty, showHour, showSecond, defaultOpenValue, clearText, | 141 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, |
142 | addon, | 142 | addon, |
143 | } = this.props; | 143 | } = this.props; |
144 | return ( | 144 | return ( |
@@ -151,8 +151,9 @@ const Picker = React.createClass({ | |||
151 | onClear={this.onPanelClear} | 151 | onClear={this.onPanelClear} |
152 | defaultOpenValue={defaultOpenValue} | 152 | defaultOpenValue={defaultOpenValue} |
153 | showHour={showHour} | 153 | showHour={showHour} |
154 | onEsc={this.onEsc} | 154 | showMinute={showMinute} |
155 | showSecond={showSecond} | 155 | showSecond={showSecond} |
156 | onEsc={this.onEsc} | ||
156 | allowEmpty={allowEmpty} | 157 | allowEmpty={allowEmpty} |
157 | format={this.getFormat()} | 158 | format={this.getFormat()} |
158 | placeholder={placeholder} | 159 | placeholder={placeholder} |