]> git.immae.eu Git - github/fretlink/time-picker.git/blobdiff - src/TimePicker.jsx
Readme file was updated to reflect show12Hours option
[github/fretlink/time-picker.git] / src / TimePicker.jsx
index 7d2395d3558d255c7fc966acd9a12b2efb8da669..f73d2b14cb60777b87b93aa4b2e8f93df38ca8e1 100644 (file)
@@ -43,6 +43,7 @@ const Picker = React.createClass({
     addon: PropTypes.func,
     name: PropTypes.string,
     autoComplete: PropTypes.string,
+    show12Hours: PropTypes.bool,
   },
 
   getDefaultProps() {
@@ -67,6 +68,7 @@ const Picker = React.createClass({
       onOpen: noop,
       onClose: noop,
       addon: noop,
+      show12Hours: false,
     };
   },
 
@@ -107,7 +109,7 @@ const Picker = React.createClass({
 
   onEsc() {
     this.setOpen(false);
-    this.picker.focus();
+    this.focus();
   },
 
   onKeyDown(e) {
@@ -142,7 +144,7 @@ const Picker = React.createClass({
       prefixCls, placeholder, disabledHours,
       disabledMinutes, disabledSeconds, hideDisabledOptions,
       allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
-      addon,
+      addon, show12Hours,
     } = this.props;
     return (
       <Panel
@@ -164,34 +166,35 @@ const Picker = React.createClass({
         disabledMinutes={disabledMinutes}
         disabledSeconds={disabledSeconds}
         hideDisabledOptions={hideDisabledOptions}
+        show12Hours={show12Hours}
         addon={addon}
       />
     );
   },
 
-  setOpen(open, callback) {
+  setOpen(open) {
     const { onOpen, onClose } = this.props;
     if (this.state.open !== open) {
-      this.setState({
-        open,
-      }, callback);
-      const event = {
-        open,
-      };
+      if (!('open' in this.props)) {
+        this.setState({ open });
+      }
       if (open) {
-        onOpen(event);
+        onOpen({ open });
       } else {
-        onClose(event);
+        onClose({ open });
       }
     }
   },
 
+  focus() {
+    this.picker.focus();
+  },
+
   render() {
     const {
       prefixCls, placeholder, placement, align,
       disabled, transitionName, style, className, showHour,
-      showMinute, showSecond, getPopupContainer, name,
-      showSecond, getPopupContainer, autoComplete,
+      showMinute, showSecond, getPopupContainer, name, autoComplete,
     } = this.props;
     const { open, value } = this.state;
     let popupClassName;