提交 26c5c8e1 编写于 作者: B Benjy Cui 提交者: 偏右

fix: should work with latest rc-time-picker (#3810)

上级 7dc0328c
......@@ -6,6 +6,20 @@ import warning from '../_util/warning';
import getLocale from '../_util/getLocale';
declare const require: Function;
function getColumns({ showHour, showMinute, showSecond }) {
let column = 0;
if (showHour) {
column += 1;
}
if (showMinute) {
column += 1;
}
if (showSecond) {
column += 1;
}
return column;
}
export default function wrapPicker(Picker, defaultFormat?) {
const PickerWrapper = React.createClass({
getDefaultProps() {
......@@ -68,11 +82,13 @@ export default function wrapPicker(Picker, defaultFormat?) {
const rcTimePickerProps = {
format: timeFormat,
showSecond: timeFormat.indexOf('ss') >= 0,
showMinute: timeFormat.indexOf('mm') >= 0,
showHour: timeFormat.indexOf('HH') >= 0,
};
const columns = getColumns(rcTimePickerProps);
const timePickerCls = classNames({
[`${prefixCls}-time-picker-1-column`]: !(rcTimePickerProps.showSecond || rcTimePickerProps.showHour),
[`${prefixCls}-time-picker-2-columns`]: rcTimePickerProps.showSecond !== rcTimePickerProps.showHour,
[`${prefixCls}-time-picker-1-column`]: columns === 1,
[`${prefixCls}-time-picker-2-columns`]: columns === 2,
});
const timePicker = props.showTime ? (
<TimePickerPanel
......
......@@ -40,11 +40,28 @@ function disabledMinutes(h) {
ReactDOM.render(
<div>
<em>Just Disabled: </em>
<TimePicker disabledHours={disabledHours} disabledMinutes={disabledMinutes} /><br />
<em>Hide Directly: </em>
<TimePicker disabledHours={disabledHours} disabledMinutes={disabledMinutes} hideDisabledOptions />
<TimePicker
disabledHours={disabledHours}
disabledMinutes={disabledMinutes}
placeholder="Just Disabled"
/>
<TimePicker
disabledHours={disabledHours}
disabledMinutes={disabledMinutes}
hideDisabledOptions
placeholder="Hide Directly"
/>
</div>,
mountNode
);
````
<style>
#components-time-picker-demo-disable-options .ant-time-picker {
width: 120px;
}
#components-time-picker-demo-disable-options .ant-time-picker .ant-time-picker-input {
width: 120px;
margin-right: 8px;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册