aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/TimePicker.jsx
diff options
context:
space:
mode:
authorafc163 <afc163@gmail.com>2017-05-02 11:31:42 +0800
committerafc163 <afc163@gmail.com>2017-05-02 11:31:42 +0800
commita7c6e7bbdec19873df69addb101a93eef87d8153 (patch)
tree94a325620e043cd9ef6b92ab072866a3c405bbe6 /src/TimePicker.jsx
parent9b7808040c6cfdf6df60fffe10c86bb2a681cd9e (diff)
downloadtime-picker-a7c6e7bbdec19873df69addb101a93eef87d8153.tar.gz
time-picker-a7c6e7bbdec19873df69addb101a93eef87d8153.tar.zst
time-picker-a7c6e7bbdec19873df69addb101a93eef87d8153.zip
Add popupClassName2.4.0
Diffstat (limited to 'src/TimePicker.jsx')
-rw-r--r--src/TimePicker.jsx35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index 1a3516e..91745c6 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -34,6 +34,7 @@ class Picker extends Component {
34 showSecond: PropTypes.bool, 34 showSecond: PropTypes.bool,
35 style: PropTypes.object, 35 style: PropTypes.object,
36 className: PropTypes.string, 36 className: PropTypes.string,
37 popupClassName: PropTypes.string,
37 disabledHours: PropTypes.func, 38 disabledHours: PropTypes.func,
38 disabledMinutes: PropTypes.func, 39 disabledMinutes: PropTypes.func,
39 disabledSeconds: PropTypes.func, 40 disabledSeconds: PropTypes.func,
@@ -53,6 +54,7 @@ class Picker extends Component {
53 defaultOpen: false, 54 defaultOpen: false,
54 style: {}, 55 style: {},
55 className: '', 56 className: '',
57 popupClassName: '',
56 align: {}, 58 align: {},
57 defaultOpenValue: moment(), 59 defaultOpenValue: moment(),
58 allowEmpty: true, 60 allowEmpty: true,
@@ -183,6 +185,30 @@ class Picker extends Component {
183 ); 185 );
184 } 186 }
185 187
188 getPopupClassName() {
189 const { showHour, showMinute, showSecond, use12Hours, prefixCls } = this.props;
190 let popupClassName = this.props.popupClassName;
191 // Keep it for old compatibility
192 if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
193 popupClassName += ` ${prefixCls}-panel-narrow`;
194 }
195 let selectColumnCount = 0;
196 if (showHour) {
197 selectColumnCount += 1;
198 }
199 if (showMinute) {
200 selectColumnCount += 1;
201 }
202 if (showSecond) {
203 selectColumnCount += 1;
204 }
205 if (use12Hours) {
206 selectColumnCount += 1;
207 }
208 popupClassName += ` ${prefixCls}-panel-column-${selectColumnCount}`;
209 return popupClassName;
210 }
211
186 setOpen(open) { 212 setOpen(open) {
187 const { onOpen, onClose } = this.props; 213 const { onOpen, onClose } = this.props;
188 if (this.state.open !== open) { 214 if (this.state.open !== open) {
@@ -204,15 +230,10 @@ class Picker extends Component {
204 render() { 230 render() {
205 const { 231 const {
206 prefixCls, placeholder, placement, align, 232 prefixCls, placeholder, placement, align,
207 disabled, transitionName, style, className, showHour, 233 disabled, transitionName, style, className, getPopupContainer, name, autoComplete,
208 showMinute, showSecond, getPopupContainer, name, autoComplete,
209 use12Hours,
210 } = this.props; 234 } = this.props;
211 const { open, value } = this.state; 235 const { open, value } = this.state;
212 let popupClassName; 236 const popupClassName = this.getPopupClassName();
213 if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
214 popupClassName = `${prefixCls}-panel-narrow`;
215 }
216 return ( 237 return (
217 <Trigger 238 <Trigger
218 prefixCls={`${prefixCls}-panel`} 239 prefixCls={`${prefixCls}-panel`}