]> git.immae.eu Git - github/fretlink/time-picker.git/blobdiff - src/TimePicker.jsx
show12Hours prop was renamed to use12Hours
[github/fretlink/time-picker.git] / src / TimePicker.jsx
index 28857a07796da025a5a139d436f6e019ff19353e..6b762230223844c7a1f28ca0ebe2aebdb4b45f5a 100644 (file)
@@ -41,6 +41,9 @@ const Picker = React.createClass({
     onOpen: PropTypes.func,
     onClose: PropTypes.func,
     addon: PropTypes.func,
+    name: PropTypes.string,
+    autoComplete: PropTypes.string,
+    use12Hours: PropTypes.bool,
   },
 
   getDefaultProps() {
@@ -65,6 +68,7 @@ const Picker = React.createClass({
       onOpen: noop,
       onClose: noop,
       addon: noop,
+      use12Hours: false,
     };
   },
 
@@ -105,7 +109,7 @@ const Picker = React.createClass({
 
   onEsc() {
     this.setOpen(false);
-    this.picker.focus();
+    this.focus();
   },
 
   onKeyDown(e) {
@@ -140,7 +144,7 @@ const Picker = React.createClass({
       prefixCls, placeholder, disabledHours,
       disabledMinutes, disabledSeconds, hideDisabledOptions,
       allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
-      addon,
+      addon, use12Hours,
     } = this.props;
     return (
       <Panel
@@ -162,33 +166,35 @@ const Picker = React.createClass({
         disabledMinutes={disabledMinutes}
         disabledSeconds={disabledSeconds}
         hideDisabledOptions={hideDisabledOptions}
+        use12Hours={use12Hours}
         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,
+      showMinute, showSecond, getPopupContainer, name, autoComplete,
     } = this.props;
     const { open, value } = this.state;
     let popupClassName;
@@ -213,10 +219,14 @@ const Picker = React.createClass({
         <span className={`${prefixCls} ${className}`} style={style}>
           <input
             className={`${prefixCls}-input`}
-            ref={this.saveInputRef} type="text" placeholder={placeholder}
+            ref={this.saveInputRef}
+            type="text"
+            placeholder={placeholder}
+            name={name}
             readOnly
             onKeyDown={this.onKeyDown}
             disabled={disabled} value={value && value.format(this.getFormat()) || ''}
+            autoComplete={autoComplete}
           />
           <span className={`${prefixCls}-icon`}/>
         </span>