aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/TimePicker.jsx
diff options
context:
space:
mode:
authorafc163 <afc163@gmail.com>2016-11-11 13:55:55 +0800
committerafc163 <afc163@gmail.com>2016-11-11 13:55:55 +0800
commit37c36c09e0a4d693a2ec5623ff2ebc8d9ee16a06 (patch)
tree81fc9b6ec28ca54204cf6ed2ef035b5d7ee194ab /src/TimePicker.jsx
parent3b3350d5d710a7caf14926dfcce3684d3df3aff8 (diff)
downloadtime-picker-37c36c09e0a4d693a2ec5623ff2ebc8d9ee16a06.tar.gz
time-picker-37c36c09e0a4d693a2ec5623ff2ebc8d9ee16a06.tar.zst
time-picker-37c36c09e0a4d693a2ec5623ff2ebc8d9ee16a06.zip
Add showMinute
Diffstat (limited to 'src/TimePicker.jsx')
-rw-r--r--src/TimePicker.jsx19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index 99d1008..e9f18a9 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -29,6 +29,7 @@ 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,
32 showSecond: PropTypes.bool, 33 showSecond: PropTypes.bool,
33 style: PropTypes.object, 34 style: PropTypes.object,
34 className: PropTypes.string, 35 className: PropTypes.string,
@@ -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,6 +151,7 @@ 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 showMinute={showMinute}
154 showSecond={showSecond} 155 showSecond={showSecond}
155 onEsc={this.onEsc} 156 onEsc={this.onEsc}
156 allowEmpty={allowEmpty} 157 allowEmpty={allowEmpty}