aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Panel.jsx
diff options
context:
space:
mode:
authorArtem Vasiliev <artem.job@gmail.com>2016-10-20 00:00:17 +0300
committerArtem Vasiliev <artem.job@gmail.com>2016-10-20 00:00:17 +0300
commitb86fe1d16a4ad06951bba9ac2990ec3e4563637a (patch)
tree16cdd2ca2bb19b0a898b2b90b313f96a86f8fe79 /src/Panel.jsx
parent9c01af6e34f7d63843bacfcffb8c7ad45d6866cf (diff)
downloadtime-picker-b86fe1d16a4ad06951bba9ac2990ec3e4563637a.tar.gz
time-picker-b86fe1d16a4ad06951bba9ac2990ec3e4563637a.tar.zst
time-picker-b86fe1d16a4ad06951bba9ac2990ec3e4563637a.zip
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> ) }} /> ```
Diffstat (limited to 'src/Panel.jsx')
-rw-r--r--src/Panel.jsx9
1 files changed, 8 insertions, 1 deletions
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({
36 showHour: PropTypes.bool, 36 showHour: PropTypes.bool,
37 showSecond: PropTypes.bool, 37 showSecond: PropTypes.bool,
38 onClear: PropTypes.func, 38 onClear: PropTypes.func,
39 addon: PropTypes.func,
39 }, 40 },
40 41
41 getDefaultProps() { 42 getDefaultProps() {
@@ -47,6 +48,7 @@ const Panel = React.createClass({
47 disabledMinutes: noop, 48 disabledMinutes: noop,
48 disabledSeconds: noop, 49 disabledSeconds: noop,
49 defaultOpenValue: moment(), 50 defaultOpenValue: moment(),
51 addon: noop,
50 }; 52 };
51 }, 53 },
52 54
@@ -79,11 +81,15 @@ const Panel = React.createClass({
79 this.setState({ currentSelectPanel }); 81 this.setState({ currentSelectPanel });
80 }, 82 },
81 83
84 close() {
85 this.props.onEsc();
86 },
87
82 render() { 88 render() {
83 const { 89 const {
84 prefixCls, className, placeholder, disabledHours, disabledMinutes, 90 prefixCls, className, placeholder, disabledHours, disabledMinutes,
85 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond, 91 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond,
86 format, defaultOpenValue, clearText, onEsc, 92 format, defaultOpenValue, clearText, onEsc, addon,
87 } = this.props; 93 } = this.props;
88 const { 94 const {
89 value, currentSelectPanel, 95 value, currentSelectPanel,
@@ -133,6 +139,7 @@ const Panel = React.createClass({
133 disabledSeconds={disabledSeconds} 139 disabledSeconds={disabledSeconds}
134 onCurrentSelectPanelChange={this.onCurrentSelectPanelChange} 140 onCurrentSelectPanelChange={this.onCurrentSelectPanelChange}
135 /> 141 />
142 {addon(this)}
136 </div> 143 </div>
137 ); 144 );
138 }, 145 },