| defaultOpenValue | moment | moment() | default open panel value, used to set utcOffset,locale if value/defaultValue absent |
| value | moment | null | current value |
| placeholder | String | '' | time input's placeholder |
+| className | String | '' | time picker className |
+| popupClassName | String | '' | time panel className |
| showHour | Boolean | true | whether show hour | |
| showMinute | Boolean | true | whether show minute |
| showSecond | Boolean | true | whether show second |
showSecond: PropTypes.bool,
style: PropTypes.object,
className: PropTypes.string,
+ popupClassName: PropTypes.string,
disabledHours: PropTypes.func,
disabledMinutes: PropTypes.func,
disabledSeconds: PropTypes.func,
defaultOpen: false,
style: {},
className: '',
+ popupClassName: '',
align: {},
defaultOpenValue: moment(),
allowEmpty: true,
);
}
+ getPopupClassName() {
+ const { showHour, showMinute, showSecond, use12Hours, prefixCls } = this.props;
+ let popupClassName = this.props.popupClassName;
+ // Keep it for old compatibility
+ if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
+ popupClassName += ` ${prefixCls}-panel-narrow`;
+ }
+ let selectColumnCount = 0;
+ if (showHour) {
+ selectColumnCount += 1;
+ }
+ if (showMinute) {
+ selectColumnCount += 1;
+ }
+ if (showSecond) {
+ selectColumnCount += 1;
+ }
+ if (use12Hours) {
+ selectColumnCount += 1;
+ }
+ popupClassName += ` ${prefixCls}-panel-column-${selectColumnCount}`;
+ return popupClassName;
+ }
+
setOpen(open) {
const { onOpen, onClose } = this.props;
if (this.state.open !== open) {
render() {
const {
prefixCls, placeholder, placement, align,
- disabled, transitionName, style, className, showHour,
- showMinute, showSecond, getPopupContainer, name, autoComplete,
- use12Hours,
+ disabled, transitionName, style, className, getPopupContainer, name, autoComplete,
} = this.props;
const { open, value } = this.state;
- let popupClassName;
- if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
- popupClassName = `${prefixCls}-panel-narrow`;
- }
+ const popupClassName = this.getPopupClassName();
return (
<Trigger
prefixCls={`${prefixCls}-panel`}