onClose: PropTypes.func,
addon: PropTypes.func,
name: PropTypes.string,
+ autoComplete: PropTypes.string,
+ use12Hours: PropTypes.bool,
},
getDefaultProps() {
onOpen: noop,
onClose: noop,
addon: noop,
+ use12Hours: false,
};
},
},
getFormat() {
- const { format, showHour, showMinute, showSecond } = this.props;
+ 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' : '',
prefixCls, placeholder, disabledHours,
disabledMinutes, disabledSeconds, hideDisabledOptions,
allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
- addon,
+ addon, use12Hours,
} = this.props;
return (
<Panel
disabledMinutes={disabledMinutes}
disabledSeconds={disabledSeconds}
hideDisabledOptions={hideDisabledOptions}
+ use12Hours={use12Hours}
addon={addon}
/>
);
},
- 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 });
}
}
},
const {
prefixCls, placeholder, placement, align,
disabled, transitionName, style, className, showHour,
- showMinute, showSecond, getPopupContainer, name,
+ showMinute, showSecond, getPopupContainer, name, autoComplete,
+ use12Hours,
} = this.props;
const { open, value } = this.state;
let popupClassName;
- if (!showHour || !showMinute || !showSecond) {
+ if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
popupClassName = `${prefixCls}-panel-narrow`;
}
return (
readOnly
onKeyDown={this.onKeyDown}
disabled={disabled} value={value && value.format(this.getFormat()) || ''}
+ autoComplete={autoComplete}
/>
<span className={`${prefixCls}-icon`}/>
</span>