mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-17 19:00:15 +08:00
f56fee1333
* site: update site/demo style * fix: fix lint
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import type { GenerateConfig } from 'rc-picker/lib/generate/index';
|
|
|
|
import type { AnyObject } from '../../_util/type';
|
|
import generateRangePicker from './generateRangePicker';
|
|
import generateSinglePicker from './generateSinglePicker';
|
|
|
|
export type { PickerLocale, PickerProps } from './interface';
|
|
|
|
const generatePicker = <DateType extends AnyObject = AnyObject>(
|
|
generateConfig: GenerateConfig<DateType>,
|
|
) => {
|
|
// =========================== Picker ===========================
|
|
const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker } =
|
|
generateSinglePicker(generateConfig);
|
|
|
|
// ======================== Range Picker ========================
|
|
const RangePicker = generateRangePicker(generateConfig);
|
|
|
|
// =========================== Export ===========================
|
|
type MergedDatePickerType = typeof DatePicker & {
|
|
displayName?: string;
|
|
WeekPicker: typeof WeekPicker;
|
|
MonthPicker: typeof MonthPicker;
|
|
YearPicker: typeof YearPicker;
|
|
RangePicker: typeof RangePicker;
|
|
TimePicker: typeof TimePicker;
|
|
QuarterPicker: typeof QuarterPicker;
|
|
};
|
|
|
|
const MergedDatePicker = DatePicker as MergedDatePickerType;
|
|
|
|
MergedDatePicker.WeekPicker = WeekPicker;
|
|
MergedDatePicker.MonthPicker = MonthPicker;
|
|
MergedDatePicker.YearPicker = YearPicker;
|
|
MergedDatePicker.RangePicker = RangePicker;
|
|
MergedDatePicker.TimePicker = TimePicker;
|
|
MergedDatePicker.QuarterPicker = QuarterPicker;
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
MergedDatePicker.displayName = 'DatePicker';
|
|
}
|
|
|
|
return MergedDatePicker;
|
|
};
|
|
|
|
export default generatePicker;
|