mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
feat: add DatePicker[allowClear], close: #3618
This commit is contained in:
parent
b240494dd5
commit
f7e480ad53
@ -8,6 +8,7 @@ import Icon from '../icon';
|
||||
export default class RangePicker extends React.Component<any, any> {
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-calendar',
|
||||
allowClear: true,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
@ -85,7 +86,7 @@ export default class RangePicker extends React.Component<any, any> {
|
||||
/>
|
||||
);
|
||||
|
||||
const clearIcon = (!props.disabled && state.value && (state.value[0] || state.value[1]))
|
||||
const clearIcon = (!props.disabled && props.allowClear && state.value && (state.value[0] || state.value[1]))
|
||||
? <Icon
|
||||
type="cross-circle"
|
||||
className={`${prefixCls}-picker-clear`}
|
||||
|
@ -14,10 +14,11 @@ export interface PickerProps {
|
||||
|
||||
export default function createPicker(TheCalendar) {
|
||||
// use class typescript error
|
||||
const CalenderWrapper = React.createClass({
|
||||
const CalenderWrapper = React.createClass<any, any>({
|
||||
getDefaultProps() {
|
||||
return {
|
||||
prefixCls: 'ant-calendar',
|
||||
allowClear: true,
|
||||
};
|
||||
},
|
||||
|
||||
@ -128,7 +129,7 @@ export default function createPicker(TheCalendar) {
|
||||
pickerStyle.width = 180;
|
||||
}
|
||||
|
||||
const clearIcon = (!props.disabled && this.state.value) ?
|
||||
const clearIcon = (!props.disabled && props.allowClear && this.state.value) ?
|
||||
<Icon type="cross-circle"
|
||||
className={`${prefixCls}-picker-clear`}
|
||||
onClick={this.clearSelection}
|
||||
|
@ -10,15 +10,16 @@ import Calendar from './Calendar';
|
||||
import { TimePickerProps } from '../time-picker';
|
||||
|
||||
export interface PickerProps {
|
||||
prefixCls?: string;
|
||||
inputPrefixCls?: string;
|
||||
format?: string;
|
||||
disabled?: boolean;
|
||||
allowClear?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
popupStyle?: React.CSSProperties;
|
||||
locale?: any;
|
||||
size?: 'large' | 'small' | 'default';
|
||||
getCalendarContainer?: (trigger: any) => React.ReactNode;
|
||||
prefixCls?: string;
|
||||
inputPrefixCls?: string;
|
||||
}
|
||||
|
||||
export interface SinglePickerProps {
|
||||
|
Loading…
Reference in New Issue
Block a user