]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
Add popupClassName 2.4.0
authorafc163 <afc163@gmail.com>
Tue, 2 May 2017 03:31:42 +0000 (11:31 +0800)
committerafc163 <afc163@gmail.com>
Tue, 2 May 2017 03:31:42 +0000 (11:31 +0800)
HISTORY.md
README.md
package.json
src/TimePicker.jsx

index 2436cb8f1e4d3690c776e306f56ff3bfb657a2c7..e18638c9fee40169b86139b658443b487c486baa 100644 (file)
@@ -2,6 +2,11 @@
 
 ---
 
+2.4.0 / 2017-05-02
+---------------------------
+
+Add `popupClassName` prop.
+
 2.3.0 / 2017-03-08
 ---------------------------
 
index 1c44e76c63df8dddb380b15aecebf5862be07f86..a2758b9faec55ea530b2692da26b0a9ae0e38201 100644 (file)
--- a/README.md
+++ b/README.md
@@ -59,6 +59,8 @@ API
 | defaultOpenValue        | moment                            | moment() | default open panel value, used to set utcOffset,locale if value/defaultValue absent |
 | value                   | moment                            | null | current value |
 | placeholder             | String                            | '' | time input's placeholder |
+| className               | String                            | '' | time picker className |
+| popupClassName          | String                            | '' | time panel className |
 | showHour                | Boolean                           | true | whether show hour | |
 | showMinute              | Boolean                           | true | whether show minute |
 | showSecond              | Boolean                           | true | whether show second |
index fa956bfda5dc6a022499d23fc9fa1ba000eb006b..d219fab595c233614444254a21a6d29401c4b7e8 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "rc-time-picker",
-  "version": "2.3.5",
+  "version": "2.4.0",
   "description": "React TimePicker",
   "keywords": [
     "react",
index 1a3516e974ebdff4d2c3c191531783d3fd81cbed..91745c629c177359bb7849872a99c2c07d72db8b 100644 (file)
@@ -34,6 +34,7 @@ class Picker extends Component {
     showSecond: PropTypes.bool,
     style: PropTypes.object,
     className: PropTypes.string,
+    popupClassName: PropTypes.string,
     disabledHours: PropTypes.func,
     disabledMinutes: PropTypes.func,
     disabledSeconds: PropTypes.func,
@@ -53,6 +54,7 @@ class Picker extends Component {
     defaultOpen: false,
     style: {},
     className: '',
+    popupClassName: '',
     align: {},
     defaultOpenValue: moment(),
     allowEmpty: true,
@@ -183,6 +185,30 @@ class Picker extends Component {
     );
   }
 
+  getPopupClassName() {
+    const { showHour, showMinute, showSecond, use12Hours, prefixCls } = this.props;
+    let popupClassName = this.props.popupClassName;
+    // Keep it for old compatibility
+    if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
+      popupClassName += ` ${prefixCls}-panel-narrow`;
+    }
+    let selectColumnCount = 0;
+    if (showHour) {
+      selectColumnCount += 1;
+    }
+    if (showMinute) {
+      selectColumnCount += 1;
+    }
+    if (showSecond) {
+      selectColumnCount += 1;
+    }
+    if (use12Hours) {
+      selectColumnCount += 1;
+    }
+    popupClassName += ` ${prefixCls}-panel-column-${selectColumnCount}`;
+    return popupClassName;
+  }
+
   setOpen(open) {
     const { onOpen, onClose } = this.props;
     if (this.state.open !== open) {
@@ -204,15 +230,10 @@ class Picker extends Component {
   render() {
     const {
       prefixCls, placeholder, placement, align,
-      disabled, transitionName, style, className, showHour,
-      showMinute, showSecond, getPopupContainer, name, autoComplete,
-      use12Hours,
+      disabled, transitionName, style, className, getPopupContainer, name, autoComplete,
     } = this.props;
     const { open, value } = this.state;
-    let popupClassName;
-    if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
-      popupClassName = `${prefixCls}-panel-narrow`;
-    }
+    const popupClassName = this.getPopupClassName();
     return (
       <Trigger
         prefixCls={`${prefixCls}-panel`}