2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import * as moment from 'moment';
|
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';
|
2017-08-31 20:44:22 +08:00
|
|
|
import WeekPicker from './WeekPicker';
|
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-10-28 10:10:02 +08:00
|
|
|
prefixCls?: string;
|
|
|
|
inputPrefixCls?: string;
|
2016-08-19 17:11:06 +08:00
|
|
|
format?: string;
|
|
|
|
disabled?: boolean;
|
2016-10-28 10:10:02 +08:00
|
|
|
allowClear?: boolean;
|
2017-06-27 15:32:18 +08:00
|
|
|
className?: string;
|
2016-08-19 17:11:06 +08:00
|
|
|
style?: React.CSSProperties;
|
|
|
|
popupStyle?: React.CSSProperties;
|
|
|
|
locale?: any;
|
|
|
|
size?: 'large' | 'small' | 'default';
|
2017-03-28 13:20:05 +08:00
|
|
|
getCalendarContainer?: (triggerNode: Element) => HTMLElement;
|
2016-11-07 16:31:15 +08:00
|
|
|
open?: boolean;
|
|
|
|
onOpenChange?: (status: boolean) => void;
|
2017-02-23 12:51:40 +08:00
|
|
|
disabledDate?: (current: moment.Moment) => boolean;
|
2017-06-05 17:11:58 +08:00
|
|
|
renderExtraFooter?: () => React.ReactNode;
|
2017-09-25 22:10:26 +08:00
|
|
|
dateRender?: (current: moment.Moment, today: moment.Moment) => React.ReactNode;
|
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 {
|
2017-06-27 14:27:02 +08:00
|
|
|
className?: string;
|
2016-09-19 10:17:07 +08:00
|
|
|
showTime?: TimePickerProps | boolean;
|
2016-11-14 11:57:12 +08:00
|
|
|
showToday?: boolean;
|
2016-09-19 10:17:07 +08:00
|
|
|
open?: boolean;
|
2017-02-23 12:51:40 +08:00
|
|
|
disabledTime?: (current: moment.Moment) => {
|
2017-09-26 16:11:28 +08:00
|
|
|
disabledHours?: () => number[],
|
|
|
|
disabledMinutes?: () => number[],
|
|
|
|
disabledSeconds?: () => number[],
|
2017-02-23 12:51:40 +08:00
|
|
|
};
|
2016-10-21 16:27:26 +08:00
|
|
|
onOpenChange?: (status: boolean) => void;
|
2017-06-28 10:19:53 +08:00
|
|
|
onOk?: (selectedTime: moment.Moment) => void;
|
2016-11-14 10:57:52 +08:00
|
|
|
placeholder?: string;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
|
|
|
const DatePicker = wrapPicker(createPicker(RcCalendar)) as React.ClassicComponentClass<DatePickerProps>;
|
|
|
|
|
|
|
|
export interface MonthPickerProps extends PickerProps, SinglePickerProps {
|
2017-06-27 14:27:02 +08:00
|
|
|
className?: string;
|
2016-11-14 10:57:52 +08:00
|
|
|
placeholder?: string;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
2016-10-18 15:20:26 +08:00
|
|
|
const MonthPicker = wrapPicker(createPicker(MonthCalendar), 'YYYY-MM');
|
2016-08-19 17:11:06 +08:00
|
|
|
|
|
|
|
export interface RangePickerProps extends PickerProps {
|
2017-06-27 14:27:02 +08:00
|
|
|
className?: string;
|
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;
|
2017-12-01 10:50:25 +08:00
|
|
|
onCalendarChange?: (dates: [moment.Moment, moment.Moment], dateStrings: [string, string]) => void;
|
2017-06-28 10:19:53 +08:00
|
|
|
onOk?: (selectedTime: moment.Moment) => void;
|
2016-09-19 10:17:07 +08:00
|
|
|
showTime?: TimePickerProps | boolean;
|
2016-11-07 16:31:15 +08:00
|
|
|
ranges?: {
|
|
|
|
[range: string]: moment.Moment[],
|
|
|
|
};
|
2017-02-23 13:18:06 +08:00
|
|
|
placeholder?: [string, string];
|
2018-01-08 16:31:50 +08:00
|
|
|
mode?: string | string[];
|
2017-02-23 12:51:40 +08:00
|
|
|
disabledTime?: (current: moment.Moment, type: string) => {
|
2017-09-26 16:11:28 +08:00
|
|
|
disabledHours?: () => number[],
|
|
|
|
disabledMinutes?: () => number[],
|
|
|
|
disabledSeconds?: () => number[],
|
2017-02-23 12:51:40 +08:00
|
|
|
};
|
2018-01-08 16:43:14 +08:00
|
|
|
onPanelChange?: (value?: moment.Moment[], mode?: string | string[]) => void;
|
2016-08-19 17:11:06 +08:00
|
|
|
}
|
2015-08-24 14:30:08 +08:00
|
|
|
|
2017-08-31 20:44:22 +08:00
|
|
|
export interface WeexPickerProps extends PickerProps, SinglePickerProps {
|
|
|
|
className?: string;
|
|
|
|
placeholder?: string;
|
|
|
|
}
|
|
|
|
|
2017-07-03 16:57:11 +08:00
|
|
|
Object.assign(DatePicker, {
|
2017-07-06 23:06:21 +08:00
|
|
|
RangePicker: wrapPicker(RangePicker),
|
2016-08-24 16:56:29 +08:00
|
|
|
MonthPicker,
|
2017-08-31 20:44:22 +08:00
|
|
|
WeekPicker: wrapPicker(WeekPicker, 'YYYY-Wo'),
|
2016-08-24 16:56:29 +08:00
|
|
|
});
|
2015-08-24 14:30:08 +08:00
|
|
|
|
2016-10-18 15:20:26 +08:00
|
|
|
export interface DatePickerDecorator extends React.ClassicComponentClass<DatePickerProps> {
|
|
|
|
RangePicker: React.ClassicComponentClass<RangePickerProps>;
|
|
|
|
MonthPicker: React.ClassicComponentClass<MonthPickerProps>;
|
2017-08-31 20:44:22 +08:00
|
|
|
WeekPicker: React.ClassicComponentClass<WeexPickerProps>;
|
2016-10-18 15:20:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default DatePicker as DatePickerDecorator;
|