]> git.immae.eu Git - github/fretlink/time-picker.git/blobdiff - src/TimePicker.jsx
fix narrow className
[github/fretlink/time-picker.git] / src / TimePicker.jsx
index 6b762230223844c7a1f28ca0ebe2aebdb4b45f5a..d94ed940baffa48ff9868ad9ce659509639e79f6 100644 (file)
@@ -128,10 +128,21 @@ const Picker = React.createClass({
   },
 
   getFormat() {
-    const { format, showHour, showMinute, showSecond } = this.props;
+    const { format, showHour, showMinute, showSecond, use12Hours } = this.props;
     if (format) {
       return format;
     }
+
+    if (use12Hours) {
+      const fmtString = ([
+        showHour ? 'h' : '',
+        showMinute ? 'mm' : '',
+        showSecond ? 'ss' : '',
+      ].filter(item => !!item).join(':'));
+
+      return fmtString.concat(' a');
+    }
+
     return [
       showHour ? 'HH' : '',
       showMinute ? 'mm' : '',
@@ -195,10 +206,11 @@ const Picker = React.createClass({
       prefixCls, placeholder, placement, align,
       disabled, transitionName, style, className, showHour,
       showMinute, showSecond, getPopupContainer, name, autoComplete,
+      use12Hours,
     } = this.props;
     const { open, value } = this.state;
     let popupClassName;
-    if (!showHour || !showMinute || !showSecond) {
+    if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
       popupClassName = `${prefixCls}-panel-narrow`;
     }
     return (