ant-design-vue/components/date-picker/index.ts

60 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-10-16 02:18:06 +00:00
import { App, DefineComponent } 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';
import {
DatePickerPropsTypes,
RangePickerPropsTypes,
MonthPickerPropsTypes,
WeekPickerPropsTypes,
} from './interface';
2018-03-15 13:40:34 +00:00
2020-10-16 02:18:06 +00:00
const WrappedRangePicker = (wrapPicker(
RangePicker,
RangePickerProps,
'date',
) as unknown) as DefineComponent<RangePickerPropsTypes>;
2018-03-15 13:40:34 +00:00
2020-10-16 02:18:06 +00:00
const WrappedWeekPicker = (wrapPicker(
WeekPicker,
WeekPickerProps,
'week',
) as unknown) as DefineComponent<WeekPickerPropsTypes>;
const DatePicker = (wrapPicker(
createPicker(VcCalendar, DatePickerProps, 'ADatePicker'),
DatePickerProps,
'date',
) as unknown) as DefineComponent<DatePickerPropsTypes> & {
readonly RangePicker: typeof WrappedRangePicker;
readonly MonthPicker: typeof MonthPicker;
readonly WeekPicker: typeof WrappedWeekPicker;
};
const MonthPicker = (wrapPicker(
createPicker(MonthCalendar, MonthPickerProps, 'AMonthPicker'),
MonthPickerProps,
'month',
) 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
/* istanbul ignore next */
2020-10-14 15:12:51 +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
};
2020-10-16 02:18:06 +00:00
export default DatePicker;