mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
parent
a2736da2bd
commit
c65f201d51
@ -3,6 +3,7 @@ import MonthCalendar from 'rc-calendar/lib/MonthCalendar';
|
|||||||
import RcDatePicker from 'rc-calendar/lib/Picker';
|
import RcDatePicker from 'rc-calendar/lib/Picker';
|
||||||
import GregorianCalendar from 'gregorian-calendar';
|
import GregorianCalendar from 'gregorian-calendar';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import Icon from '../icon';
|
||||||
|
|
||||||
export default function createPicker(TheCalendar) {
|
export default function createPicker(TheCalendar) {
|
||||||
return class CalenderWrapper extends React.Component {
|
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) => {
|
handleChange = (value) => {
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
if (!('value' in props)) {
|
if (!('value' in props)) {
|
||||||
@ -89,6 +95,10 @@ export default function createPicker(TheCalendar) {
|
|||||||
pickerStyle.width = 180;
|
pickerStyle.width = 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clearIcon = (!props.disabled && this.state.value) ?
|
||||||
|
<Icon type="cross-circle"
|
||||||
|
className="ant-calendar-picker-clear"
|
||||||
|
onClick={this.clearSelection} /> : null;
|
||||||
return (
|
return (
|
||||||
<span className={props.pickerClass} style={{ ...pickerStyle, ...props.style }}>
|
<span className={props.pickerClass} style={{ ...pickerStyle, ...props.style }}>
|
||||||
<RcDatePicker
|
<RcDatePicker
|
||||||
@ -114,6 +124,7 @@ export default function createPicker(TheCalendar) {
|
|||||||
value={value ? props.getFormatter().format(value) : ''}
|
value={value ? props.getFormatter().format(value) : ''}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
className={props.pickerInputClass} />
|
className={props.pickerInputClass} />
|
||||||
|
{clearIcon}
|
||||||
<span className="ant-calendar-picker-icon" />
|
<span className="ant-calendar-picker-icon" />
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
@ -246,6 +246,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.@{calendar-prefix-cls}-clear-btn {
|
.@{calendar-prefix-cls}-clear-btn {
|
||||||
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 5px;
|
right: 5px;
|
||||||
text-indent: -76px;
|
text-indent: -76px;
|
||||||
|
@ -37,7 +37,29 @@
|
|||||||
> input {
|
> input {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
&-clear {
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 8px;
|
||||||
|
z-index: 1;
|
||||||
|
background: #fff;
|
||||||
|
top: 50%;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #ccc;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
margin-top: -6px;
|
||||||
|
line-height: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.3s ease, opacity 0.15s ease;
|
||||||
|
&:hover {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover &-clear {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
&-icon {
|
&-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
@ -57,11 +57,19 @@
|
|||||||
margin-left: -29px;
|
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 {
|
&.@{calendar-prefix-cls}-time &-right .@{calendar-prefix-cls}-date-input-wrap {
|
||||||
margin-left: -15px;
|
margin-left: -15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.@{calendar-prefix-cls}-input-wrap {
|
.@{calendar-prefix-cls}-input-wrap {
|
||||||
|
position: relative;
|
||||||
height: @input-box-height;
|
height: @input-box-height;
|
||||||
}
|
}
|
||||||
.@{calendar-prefix-cls}-input {
|
.@{calendar-prefix-cls}-input {
|
||||||
|
@ -11,14 +11,17 @@
|
|||||||
.@{calendar-prefix-cls}-clear-btn {
|
.@{calendar-prefix-cls}-clear-btn {
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
}
|
}
|
||||||
|
.@{calendar-prefix-cls}-time-picker-wrap {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.@{calendar-prefix-cls}-input,
|
.@{calendar-prefix-cls}-input,
|
||||||
.@{timepicker-prefix-cls}-input {
|
.@{timepicker-prefix-cls}-input {
|
||||||
.input;
|
// .input;
|
||||||
border-radius: @border-radius-sm;
|
}
|
||||||
height: @input-height-sm;
|
.@{timepicker-prefix-cls}-input {
|
||||||
width: 96px;
|
display: none;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
.@{calendar-prefix-cls}-input {
|
.@{calendar-prefix-cls}-input {
|
||||||
padding-right: 21px;
|
padding-right: 21px;
|
||||||
@ -27,6 +30,9 @@
|
|||||||
min-width: 168px;
|
min-width: 168px;
|
||||||
}
|
}
|
||||||
.@{timepicker-prefix-cls}-icon {
|
.@{timepicker-prefix-cls}-icon {
|
||||||
display: none;
|
font-family: "anticon" !important;
|
||||||
|
position: relative;
|
||||||
|
content: "\E643";
|
||||||
|
display: inline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user