Merge branch 'RaoHai-datepicker-improvement' into 1.x-stable

This commit is contained in:
afc163 2016-06-23 15:42:16 +08:00
commit e900063865
5 changed files with 56 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import MonthCalendar from 'rc-calendar/lib/MonthCalendar';
import RcDatePicker from 'rc-calendar/lib/Picker';
import GregorianCalendar from 'gregorian-calendar';
import classNames from 'classnames';
import Icon from '../icon';
export default function createPicker(TheCalendar) {
return class CalenderWrapper extends React.Component {
@ -21,7 +22,12 @@ export default function createPicker(TheCalendar) {
});
}
}
clearSelection = (e) => {
e.preventDefault();
e.stopPropagation();
this.setState({ value: null });
this.handleChange(null);
}
handleChange = (value) => {
const props = this.props;
if (!('value' in props)) {
@ -70,6 +76,11 @@ export default function createPicker(TheCalendar) {
pickerStyle.width = 180;
}
const clearIcon = (!props.disabled && this.state.value) ?
<Icon type="cross-circle"
className="ant-calendar-picker-clear"
onClick={this.clearSelection}
/> : null;
return (
<span className={props.pickerClass} style={{ ...pickerStyle, ...props.style }}>
<RcDatePicker
@ -97,6 +108,7 @@ export default function createPicker(TheCalendar) {
placeholder={placeholder}
className={props.pickerInputClass}
/>
{clearIcon}
<span className="ant-calendar-picker-icon" />
</span>
);

View File

@ -246,6 +246,7 @@
}
.@{calendar-prefix-cls}-clear-btn {
display: none;
position: absolute;
right: 5px;
text-indent: -76px;

View File

@ -37,7 +37,29 @@
> input {
outline: none;
}
&-clear {
opacity: 0;
position: absolute;
right: 8px;
z-index: 1;
background: #fff;
top: 50%;
font-size: 12px;
color: #ccc;
width: 14px;
height: 14px;
margin-top: -7px;
line-height: 14px;
cursor: pointer;
transition: color 0.3s ease, opacity 0.15s ease;
&:hover {
color: #999;
}
}
&:hover &-clear {
opacity: 1;
}
&-icon {
position: absolute;
user-select: none;

View File

@ -57,11 +57,19 @@
margin-left: -29px;
}
.@{calendar-prefix-cls}-time-picker-wrap {
left: 115px;
}
&-right .@{calendar-prefix-cls}-time-picker-wrap {
left: 100px;
}
&.@{calendar-prefix-cls}-time &-right .@{calendar-prefix-cls}-date-input-wrap {
margin-left: -15px;
}
.@{calendar-prefix-cls}-input-wrap {
position: relative;
height: @input-box-height;
}
.@{calendar-prefix-cls}-input {

View File

@ -11,14 +11,17 @@
.@{calendar-prefix-cls}-clear-btn {
direction: ltr;
}
.@{calendar-prefix-cls}-time-picker-wrap {
position: absolute;
right: 0;
}
}
.@{calendar-prefix-cls}-input,
.@{timepicker-prefix-cls}-input {
.input;
border-radius: @border-radius-sm;
height: @input-height-sm;
width: 96px;
margin-right: 6px;
// .input;
}
.@{timepicker-prefix-cls}-input {
display: none;
}
.@{calendar-prefix-cls}-input {
padding-right: 21px;
@ -27,6 +30,9 @@
min-width: 168px;
}
.@{timepicker-prefix-cls}-icon {
display: none;
font-family: "anticon" !important;
position: relative;
content: "\E643";
display: inline;
}
}