You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/date-picker/index.ts

60 lines
1.8 KiB

import { App, DefineComponent, Plugin } from 'vue';
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';
import { DatePickerProps, MonthPickerProps, WeekPickerProps, RangePickerProps } from './props';
import {
DatePickerPropsTypes,
RangePickerPropsTypes,
MonthPickerPropsTypes,
WeekPickerPropsTypes,
} from './interface';
const WrappedRangePicker = (wrapPicker(
RangePicker as any,
RangePickerProps,
'date',
) as unknown) as DefineComponent<RangePickerPropsTypes>;
const WrappedWeekPicker = (wrapPicker(
WeekPicker as any,
WeekPickerProps,
'week',
) as unknown) as DefineComponent<WeekPickerPropsTypes>;
const DatePicker = (wrapPicker(
createPicker(VcCalendar as any, 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 as any, MonthPickerProps, 'AMonthPicker'),
MonthPickerProps,
'month',
) as unknown) as DefineComponent<MonthPickerPropsTypes>;
Object.assign(DatePicker, {
RangePicker: WrappedRangePicker,
MonthPicker,
WeekPicker: WrappedWeekPicker,
});
/* istanbul ignore next */
DatePicker.install = function(app: App) {
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);
return app;
};
export default DatePicker as typeof DatePicker & Plugin;