From b86fe1d16a4ad06951bba9ac2990ec3e4563637a Mon Sep 17 00:00:00 2001
From: Artem Vasiliev <artem.job@gmail.com>
Date: Thu, 20 Oct 2016 00:00:17 +0300
Subject: feat: 'addon' property support

..to be able to render something like OK button to timepicker:
```
            <TimePicker
              allowEmpty={false}
              addon={panel => {
                return (
                  <div className="row">
                    <a role="button" className="btn btn-sm btn-default" onClick={() => panel.close()}>
                      {__('OK')}
                    </a>
                  </div>
                )
              }}
            />

```
---
 src/Panel.jsx | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'src/Panel.jsx')

diff --git a/src/Panel.jsx b/src/Panel.jsx
index 9066b03..0ed60e9 100644
--- a/src/Panel.jsx
+++ b/src/Panel.jsx
@@ -36,6 +36,7 @@ const Panel = React.createClass({
     showHour: PropTypes.bool,
     showSecond: PropTypes.bool,
     onClear: PropTypes.func,
+    addon: PropTypes.func,
   },
 
   getDefaultProps() {
@@ -47,6 +48,7 @@ const Panel = React.createClass({
       disabledMinutes: noop,
       disabledSeconds: noop,
       defaultOpenValue: moment(),
+      addon: noop,
     };
   },
 
@@ -79,11 +81,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,
+      format, defaultOpenValue, clearText, onEsc, addon,
     } = this.props;
     const {
       value, currentSelectPanel,
@@ -133,6 +139,7 @@ const Panel = React.createClass({
           disabledSeconds={disabledSeconds}
           onCurrentSelectPanelChange={this.onCurrentSelectPanelChange}
         />
+        {addon(this)}
       </div>
     );
   },
-- 
cgit v1.2.3

