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