- this.setOpen(open, () => {
- if (open) {
- ReactDOM.findDOMNode(this.refs.picker).blur();
- ReactDOM.findDOMNode(this.panelInstance).focus();
- }
- });
+ this.setOpen(open);
+ },
+
+ onEsc() {
+ this.setOpen(false);
+ this.focus();
+ },
+
+ onKeyDown(e) {
+ if (e.keyCode === 40) {
+ this.setOpen(true);
+ }
+ },
+
+ setValue(value) {
+ if (!('value' in this.props)) {
+ this.setState({
+ value,
+ });
+ }
+ this.props.onChange(value);
+ },
+
+ getFormat() {
+ const { format, showHour, showMinute, showSecond, use12Hours } = this.props;
+ if (format) {
+ return format;
+ }
+
+ if (use12Hours) {
+ const fmtString = ([
+ showHour ? 'h' : '',
+ showMinute ? 'mm' : '',
+ showSecond ? 'ss' : '',
+ ].filter(item => !!item).join(':'));
+
+ return fmtString.concat(' a');
+ }
+
+ return [
+ showHour ? 'HH' : '',
+ showMinute ? 'mm' : '',
+ showSecond ? 'ss' : '',
+ ].filter(item => !!item).join(':');