2023-05-19 18:57:35 +08:00
|
|
|
import type { GenerateConfig } from 'rc-picker/lib/generate/index';
|
2024-01-29 15:34:48 +08:00
|
|
|
|
|
|
|
import type { AnyObject } from '../../_util/type';
|
2020-04-02 15:46:07 +08:00
|
|
|
import generateRangePicker from './generateRangePicker';
|
2022-06-22 14:57:09 +08:00
|
|
|
import generateSinglePicker from './generateSinglePicker';
|
2020-04-02 15:46:07 +08:00
|
|
|
|
2024-01-29 15:34:48 +08:00
|
|
|
export type { PickerLocale, PickerProps } from './interface';
|
2020-04-02 15:46:07 +08:00
|
|
|
|
2024-01-29 15:34:48 +08:00
|
|
|
function generatePicker<DateType extends AnyObject>(generateConfig: GenerateConfig<DateType>) {
|
2020-04-02 15:46:07 +08:00
|
|
|
// =========================== Picker ===========================
|
2021-09-03 13:24:48 +08:00
|
|
|
const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker } =
|
|
|
|
generateSinglePicker(generateConfig);
|
2020-04-02 15:46:07 +08:00
|
|
|
|
|
|
|
// ======================== Range Picker ========================
|
|
|
|
const RangePicker = generateRangePicker(generateConfig);
|
|
|
|
|
|
|
|
// =========================== Export ===========================
|
2020-09-16 11:43:55 +08:00
|
|
|
type MergedDatePickerType = typeof DatePicker & {
|
2023-07-17 23:43:32 +08:00
|
|
|
displayName?: string;
|
2020-04-02 15:46:07 +08:00
|
|
|
WeekPicker: typeof WeekPicker;
|
|
|
|
MonthPicker: typeof MonthPicker;
|
|
|
|
YearPicker: typeof YearPicker;
|
2021-09-03 13:24:48 +08:00
|
|
|
RangePicker: typeof RangePicker;
|
2020-04-02 15:46:07 +08:00
|
|
|
TimePicker: typeof TimePicker;
|
2020-07-23 11:25:17 +08:00
|
|
|
QuarterPicker: typeof QuarterPicker;
|
2020-04-02 15:46:07 +08:00
|
|
|
};
|
|
|
|
|
2020-09-16 11:43:55 +08:00
|
|
|
const MergedDatePicker = DatePicker as MergedDatePickerType;
|
2020-04-02 15:46:07 +08:00
|
|
|
MergedDatePicker.WeekPicker = WeekPicker;
|
|
|
|
MergedDatePicker.MonthPicker = MonthPicker;
|
|
|
|
MergedDatePicker.YearPicker = YearPicker;
|
|
|
|
MergedDatePicker.RangePicker = RangePicker;
|
|
|
|
MergedDatePicker.TimePicker = TimePicker;
|
2020-07-23 11:25:17 +08:00
|
|
|
MergedDatePicker.QuarterPicker = QuarterPicker;
|
2020-04-02 15:46:07 +08:00
|
|
|
|
2023-07-17 23:43:32 +08:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
MergedDatePicker.displayName = 'DatePicker';
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:46:07 +08:00
|
|
|
return MergedDatePicker;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default generatePicker;
|