2016-09-09 13:55:21 +08:00
|
|
|
import React from 'react';
|
|
|
|
import moment from 'moment';
|
2016-08-24 16:56:29 +08:00
|
|
|
import assign from 'object-assign';
|
2016-03-21 21:16:38 +08:00
|
|
|
import RcCalendar from 'rc-calendar';
|
2015-10-20 16:47:55 +08:00
|
|
|
import MonthCalendar from 'rc-calendar/lib/MonthCalendar';
|
2016-03-30 09:50:44 +08:00
|
|
|
import createPicker from './createPicker';
|
2016-03-30 10:52:15 +08:00
|
|
|
import wrapPicker from './wrapPicker';
|
2016-03-21 21:16:38 +08:00
|
|
|
import RangePicker from './RangePicker';
|
2016-03-30 09:41:18 +08:00
|
|
|
import Calendar from './Calendar';
|
2016-08-19 17:11:06 +08:00
|
|
|
import { TimePickerProps } from '../time-picker';
|
2015-08-25 17:27:38 +08:00
|
|
|
|
2016-09-13 15:31:29 +08:00
|
|
|
export interface PickerProps {
|
2016-08-19 17:11:06 +08:00
|
|
|
format?: string;
|
|
|
|
disabled?: boolean;
|
|
|
|
style?: React.CSSProperties;
|
|
|
|
popupStyle?: React.CSSProperties;
|
|
|
|
locale?: any;
|
|
|
|
size?: 'large' | 'small' | 'default';
|
2016-10-18 11:55:00 +08:00
|
|
|
getCalendarContainer?: (trigger: any) => React.ReactNode;
|
2016-09-14 16:18:33 +08:00
|
|
|
prefixCls?: string;
|
|
|
|
inputPrefixCls?: string;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
|
|
|
|
2016-09-13 15:31:29 +08:00
|
|
|
export interface SinglePickerProps {
|
2016-09-09 13:55:21 +08:00
|
|
|
value?: moment.Moment;
|
|
|
|
defaultValue?: moment.Moment;
|
|
|
|
defaultPickerValue?: moment.Moment;
|
|
|
|
onChange?: (date: moment.Moment, dateString: string) => void;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface DatePickerProps extends PickerProps, SinglePickerProps {
|
2016-09-19 10:17:07 +08:00
|
|
|
showTime?: TimePickerProps | boolean;
|
|
|
|
open?: boolean;
|
|
|
|
toggleOpen?: (e: {open: boolean}) => void;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
|
|
|
const DatePicker = wrapPicker(createPicker(RcCalendar)) as React.ClassicComponentClass<DatePickerProps>;
|
|
|
|
|
|
|
|
export interface MonthPickerProps extends PickerProps, SinglePickerProps {
|
|
|
|
}
|
2016-09-09 13:55:21 +08:00
|
|
|
const MonthPicker = wrapPicker(createPicker(MonthCalendar), 'YYYY-MM') as React.ClassicComponentClass<MonthPickerProps>;
|
2016-08-19 17:11:06 +08:00
|
|
|
|
|
|
|
export interface RangePickerProps extends PickerProps {
|
2016-09-09 13:55:21 +08:00
|
|
|
value?: [moment.Moment, moment.Moment];
|
|
|
|
defaultValue?: [moment.Moment, moment.Moment];
|
|
|
|
defaultPickerValue?: [moment.Moment, moment.Moment];
|
|
|
|
onChange?: (dates: [moment.Moment, moment.Moment], dateStrings: [string, string]) => void;
|
2016-09-19 10:17:07 +08:00
|
|
|
showTime?: TimePickerProps | boolean;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
2015-08-24 14:30:08 +08:00
|
|
|
|
2016-08-24 16:56:29 +08:00
|
|
|
assign(DatePicker, {
|
|
|
|
RangePicker: wrapPicker(RangePicker) as React.ClassicComponentClass<RangePickerProps>,
|
|
|
|
Calendar,
|
|
|
|
MonthPicker,
|
|
|
|
});
|
2015-08-24 14:30:08 +08:00
|
|
|
|
2016-03-21 21:16:38 +08:00
|
|
|
export default DatePicker;
|