X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FTimePicker.jsx;h=f73d2b14cb60777b87b93aa4b2e8f93df38ca8e1;hb=f8e59df8666ee32ae769f35cd01b4de4d4e4bed1;hp=01bab2c5b5185e33ba0431ac200da40c441725ab;hpb=ed8496061a1535fb82503d9723a6014a85ee7625;p=github%2Ffretlink%2Ftime-picker.git diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index 01bab2c..f73d2b1 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx @@ -41,6 +41,9 @@ const Picker = React.createClass({ onOpen: PropTypes.func, onClose: PropTypes.func, addon: PropTypes.func, + name: PropTypes.string, + autoComplete: PropTypes.string, + show12Hours: PropTypes.bool, }, getDefaultProps() { @@ -65,10 +68,12 @@ const Picker = React.createClass({ onOpen: noop, onClose: noop, addon: noop, + show12Hours: false, }; }, getInitialState() { + this.saveInputRef = refFn.bind(this, 'picker'); this.savePanelRef = refFn.bind(this, 'panelInstance'); const { defaultOpen, defaultValue, open = defaultOpen, value = defaultValue } = this.props; return { @@ -139,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 ( ); }, - 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.refs.picker.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; @@ -216,10 +219,14 @@ const Picker = React.createClass({