]> git.immae.eu Git - github/fretlink/time-picker.git/blobdiff - src/Panel.jsx
Added more tests
[github/fretlink/time-picker.git] / src / Panel.jsx
index f5cf7bc6c1184b20646222a7b0db0a286cf2f9fb..df128ff67d75741216952588899a005c570bb30f 100644 (file)
@@ -34,8 +34,11 @@ const Panel = React.createClass({
     onEsc: PropTypes.func,
     allowEmpty: PropTypes.bool,
     showHour: PropTypes.bool,
+    showMinute: PropTypes.bool,
     showSecond: PropTypes.bool,
     onClear: PropTypes.func,
+    use12Hours: PropTypes.bool,
+    addon: PropTypes.func,
   },
 
   getDefaultProps() {
@@ -47,6 +50,8 @@ const Panel = React.createClass({
       disabledMinutes: noop,
       disabledSeconds: noop,
       defaultOpenValue: moment(),
+      use12Hours: false,
+      addon: noop,
     };
   },
 
@@ -79,11 +84,15 @@ const Panel = React.createClass({
     this.setState({ currentSelectPanel });
   },
 
+  close() {
+    this.props.onEsc();
+  },
+
   render() {
     const {
       prefixCls, className, placeholder, disabledHours, disabledMinutes,
-      disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond,
-      format, defaultOpenValue, clearText, onEsc,
+      disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond,
+      format, defaultOpenValue, clearText, onEsc, addon, use12Hours,
     } = this.props;
     const {
       value, currentSelectPanel,
@@ -97,7 +106,7 @@ const Panel = React.createClass({
     const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions);
 
     return (
-      <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: className })}>
+      <div className={classNames({ [`${prefixCls}-inner`]: true, [className]: !!className })}>
         <Header
           clearText={clearText}
           prefixCls={prefixCls}
@@ -124,6 +133,7 @@ const Panel = React.createClass({
           format={format}
           onChange={this.onChange}
           showHour={showHour}
+          showMinute={showMinute}
           showSecond={showSecond}
           hourOptions={hourOptions}
           minuteOptions={minuteOptions}
@@ -132,7 +142,9 @@ const Panel = React.createClass({
           disabledMinutes={disabledMinutes}
           disabledSeconds={disabledSeconds}
           onCurrentSelectPanelChange={this.onCurrentSelectPanelChange}
+          use12Hours={use12Hours}
         />
+        {addon(this)}
       </div>
     );
   },