2022-02-14 14:40:40 +08:00
|
|
|
import type { Dayjs } from 'dayjs';
|
|
|
|
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs';
|
2023-09-15 12:23:57 +08:00
|
|
|
|
2022-07-13 23:06:28 +08:00
|
|
|
import genPurePanel from '../_util/PurePanel';
|
2024-01-29 15:34:48 +08:00
|
|
|
import generatePicker from './generatePicker';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type {
|
2023-04-12 17:20:08 +08:00
|
|
|
RangePickerProps as BaseRangePickerProps,
|
2022-06-22 14:57:09 +08:00
|
|
|
PickerProps,
|
2024-01-29 15:34:48 +08:00
|
|
|
PickerPropsWithMultiple,
|
|
|
|
} from './generatePicker/interface';
|
2023-04-19 23:07:47 +08:00
|
|
|
import { transPlacement2DropdownAlign } from './util';
|
2020-01-14 19:46:05 +08:00
|
|
|
|
2024-01-29 15:34:48 +08:00
|
|
|
export type DatePickerProps<ValueType = Dayjs | Dayjs> = PickerPropsWithMultiple<
|
|
|
|
Dayjs,
|
|
|
|
PickerProps<Dayjs>,
|
|
|
|
ValueType
|
|
|
|
>;
|
|
|
|
export type MonthPickerProps<ValueType = Dayjs | Dayjs> = Omit<
|
|
|
|
DatePickerProps<ValueType>,
|
|
|
|
'picker'
|
|
|
|
>;
|
|
|
|
export type WeekPickerProps<ValueType = Dayjs | Dayjs> = Omit<DatePickerProps<ValueType>, 'picker'>;
|
2022-02-14 14:40:40 +08:00
|
|
|
export type RangePickerProps = BaseRangePickerProps<Dayjs>;
|
2015-08-25 17:27:38 +08:00
|
|
|
|
2022-02-14 14:40:40 +08:00
|
|
|
const DatePicker = generatePicker<Dayjs>(dayjsGenerateConfig);
|
2016-08-19 17:11:06 +08:00
|
|
|
|
2023-04-12 17:20:08 +08:00
|
|
|
export type DatePickerType = typeof DatePicker & {
|
|
|
|
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
|
|
|
|
_InternalRangePanelDoNotUseOrYouWillBeFired: typeof PureRangePanel;
|
|
|
|
generatePicker: typeof generatePicker;
|
|
|
|
};
|
|
|
|
|
2023-04-19 23:07:47 +08:00
|
|
|
function postPureProps(props: DatePickerProps) {
|
|
|
|
const dropdownAlign = transPlacement2DropdownAlign(props.direction, props.placement);
|
|
|
|
|
|
|
|
dropdownAlign.overflow!.adjustY = false;
|
|
|
|
dropdownAlign.overflow!.adjustX = false;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...props,
|
|
|
|
dropdownAlign,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-11 14:58:59 +08:00
|
|
|
// We don't care debug panel
|
2023-06-07 21:59:21 +08:00
|
|
|
/* istanbul ignore next */
|
2023-04-19 23:07:47 +08:00
|
|
|
const PurePanel = genPurePanel(DatePicker, 'picker', null, postPureProps);
|
2023-04-12 17:20:08 +08:00
|
|
|
(DatePicker as DatePickerType)._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
|
2023-04-19 23:07:47 +08:00
|
|
|
const PureRangePanel = genPurePanel(DatePicker.RangePicker, 'picker', null, postPureProps);
|
2023-04-12 17:20:08 +08:00
|
|
|
(DatePicker as DatePickerType)._InternalRangePanelDoNotUseOrYouWillBeFired = PureRangePanel;
|
|
|
|
(DatePicker as DatePickerType).generatePicker = generatePicker;
|
2022-07-11 14:58:59 +08:00
|
|
|
|
2024-01-29 15:34:48 +08:00
|
|
|
export default (DatePicker as DatePickerType);
|