feat: add DatePicker[allowClear], close: #3618

This commit is contained in:
Benjy Cui 2016-10-28 10:10:02 +08:00
parent b240494dd5
commit f7e480ad53
3 changed files with 8 additions and 5 deletions

View File

@ -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`}

View File

@ -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}

View File

@ -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 {