2020-11-01 15:03:33 +08:00
|
|
|
import { App, DefineComponent, Plugin } from 'vue';
|
2019-01-12 11:33:27 +08:00
|
|
|
import VcCalendar from '../vc-calendar';
|
|
|
|
import MonthCalendar from '../vc-calendar/src/MonthCalendar';
|
|
|
|
import createPicker from './createPicker';
|
|
|
|
import wrapPicker from './wrapPicker';
|
|
|
|
import RangePicker from './RangePicker';
|
|
|
|
import WeekPicker from './WeekPicker';
|
2020-10-15 13:39:17 +08:00
|
|
|
import { DatePickerProps, MonthPickerProps, WeekPickerProps, RangePickerProps } from './props';
|
|
|
|
import {
|
|
|
|
DatePickerPropsTypes,
|
|
|
|
RangePickerPropsTypes,
|
|
|
|
MonthPickerPropsTypes,
|
|
|
|
WeekPickerPropsTypes,
|
|
|
|
} from './interface';
|
2018-03-15 21:40:34 +08:00
|
|
|
|
2020-10-16 10:18:06 +08:00
|
|
|
const WrappedRangePicker = (wrapPicker(
|
2021-01-07 19:18:59 +08:00
|
|
|
RangePicker as any,
|
2020-10-16 10:18:06 +08:00
|
|
|
RangePickerProps,
|
|
|
|
'date',
|
|
|
|
) as unknown) as DefineComponent<RangePickerPropsTypes>;
|
2018-03-15 21:40:34 +08:00
|
|
|
|
2020-10-16 10:18:06 +08:00
|
|
|
const WrappedWeekPicker = (wrapPicker(
|
2021-01-07 19:18:59 +08:00
|
|
|
WeekPicker as any,
|
2020-10-16 10:18:06 +08:00
|
|
|
WeekPickerProps,
|
|
|
|
'week',
|
|
|
|
) as unknown) as DefineComponent<WeekPickerPropsTypes>;
|
|
|
|
|
|
|
|
const DatePicker = (wrapPicker(
|
2021-01-07 19:18:59 +08:00
|
|
|
createPicker(VcCalendar as any, DatePickerProps, 'ADatePicker'),
|
2020-10-16 10:18:06 +08:00
|
|
|
DatePickerProps,
|
|
|
|
'date',
|
|
|
|
) as unknown) as DefineComponent<DatePickerPropsTypes> & {
|
|
|
|
readonly RangePicker: typeof WrappedRangePicker;
|
|
|
|
readonly MonthPicker: typeof MonthPicker;
|
|
|
|
readonly WeekPicker: typeof WrappedWeekPicker;
|
|
|
|
};
|
|
|
|
|
|
|
|
const MonthPicker = (wrapPicker(
|
2021-01-07 19:18:59 +08:00
|
|
|
createPicker(MonthCalendar as any, MonthPickerProps, 'AMonthPicker'),
|
2020-10-16 10:18:06 +08:00
|
|
|
MonthPickerProps,
|
|
|
|
'month',
|
|
|
|
) as unknown) as DefineComponent<MonthPickerPropsTypes>;
|
2018-03-15 21:40:34 +08:00
|
|
|
|
|
|
|
Object.assign(DatePicker, {
|
2020-10-16 10:18:06 +08:00
|
|
|
RangePicker: WrappedRangePicker,
|
2018-03-15 21:40:34 +08:00
|
|
|
MonthPicker,
|
2020-10-16 10:18:06 +08:00
|
|
|
WeekPicker: WrappedWeekPicker,
|
2019-01-12 11:33:27 +08:00
|
|
|
});
|
2018-03-15 21:40:34 +08:00
|
|
|
|
2018-09-19 13:21:57 +08:00
|
|
|
/* istanbul ignore next */
|
2020-10-14 23:12:51 +08:00
|
|
|
DatePicker.install = function(app: App) {
|
2020-07-22 17:47:08 +08:00
|
|
|
app.component(DatePicker.name, DatePicker);
|
|
|
|
app.component(DatePicker.RangePicker.name, DatePicker.RangePicker);
|
|
|
|
app.component(DatePicker.MonthPicker.name, DatePicker.MonthPicker);
|
|
|
|
app.component(DatePicker.WeekPicker.name, DatePicker.WeekPicker);
|
2020-10-13 19:14:56 +08:00
|
|
|
return app;
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-09-19 13:21:57 +08:00
|
|
|
|
2020-11-03 11:53:59 +08:00
|
|
|
export default DatePicker as typeof DatePicker & Plugin;
|