diff --git a/components/calendar/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/calendar/__tests__/__snapshots__/demo-extend.test.ts.snap
index 16ab4c4b1b..5bac2482c9 100644
--- a/components/calendar/__tests__/__snapshots__/demo-extend.test.ts.snap
+++ b/components/calendar/__tests__/__snapshots__/demo-extend.test.ts.snap
@@ -865,7 +865,7 @@ exports[`renders components/calendar/demo/basic.tsx extend context correctly 1`]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;
+ calendarProps?: PickerPanelProps ;
calendarHeaderProps?: CalendarHeaderProps;
} = {};
@@ -37,7 +34,7 @@ jest.mock('rc-picker', () => {
const PickerPanelComponent = RcPicker.PickerPanel;
return {
...RcPicker,
- PickerPanel: (props: PickerPanelProps) => {
+ PickerPanel: (props: PickerPanelProps) => {
ref.calendarProps = props;
return ;
},
@@ -152,8 +149,8 @@ describe('Calendar', () => {
it('getDateRange should returns a disabledDate function', () => {
const validRange: [Dayjs.Dayjs, Dayjs.Dayjs] = [Dayjs('2018-02-02'), Dayjs('2018-05-18')];
render();
- expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-06-02'), {} as any)).toBe(true);
- expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-04-02'), {} as any)).toBe(false);
+ expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-06-02'))).toBe(true);
+ expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-04-02'))).toBe(false);
});
it('validRange should work with disabledDate function', () => {
@@ -165,11 +162,11 @@ describe('Calendar', () => {
/>,
);
- expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-01'), {} as any)).toBe(true);
- expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-02'), {} as any)).toBe(false);
- expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-03'), {} as any)).toBe(true);
- expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-04'), {} as any)).toBe(false);
- expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-06-01'), {} as any)).toBe(true);
+ expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-01'))).toBe(true);
+ expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-02'))).toBe(false);
+ expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-03'))).toBe(true);
+ expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-02-04'))).toBe(false);
+ expect(ref.calendarProps?.disabledDate?.(Dayjs('2018-06-01'))).toBe(true);
});
it('Calendar MonthSelect should display correct label', () => {
diff --git a/components/calendar/generateCalendar.tsx b/components/calendar/generateCalendar.tsx
index 1202acf854..0c5d95c7cf 100644
--- a/components/calendar/generateCalendar.tsx
+++ b/components/calendar/generateCalendar.tsx
@@ -3,9 +3,13 @@ import classNames from 'classnames';
import { PickerPanel as RCPickerPanel } from 'rc-picker';
import type { GenerateConfig } from 'rc-picker/lib/generate';
import type { CellRenderInfo } from 'rc-picker/lib/interface';
+import type {
+ PickerPanelBaseProps as RCPickerPanelBaseProps,
+ PickerPanelDateProps as RCPickerPanelDateProps,
+ PickerPanelTimeProps as RCPickerPanelTimeProps,
+} from 'rc-picker/lib/PickerPanel';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
-import type { AnyObject } from '../_util/type';
import { devUseWarning } from '../_util/warning';
import { ConfigContext } from '../config-provider';
import { useLocale } from '../locale';
@@ -13,6 +17,24 @@ import CalendarHeader from './Header';
import enUS from './locale/en_US';
import useStyle from './style';
+type InjectDefaultProps = Omit<
+ Props,
+ 'locale' | 'generateConfig' | 'prevIcon' | 'nextIcon' | 'superPrevIcon' | 'superNextIcon'
+> & {
+ locale?: typeof enUS;
+ size?: 'large' | 'default' | 'small';
+};
+
+// Picker Props
+export type PickerPanelBaseProps = InjectDefaultProps>;
+export type PickerPanelDateProps = InjectDefaultProps>;
+export type PickerPanelTimeProps = InjectDefaultProps>;
+
+export type PickerProps =
+ | PickerPanelBaseProps
+ | PickerPanelDateProps
+ | PickerPanelTimeProps;
+
export type CalendarMode = 'year' | 'month';
export type HeaderRender = (config: {
value: DateType;
@@ -53,7 +75,7 @@ export interface CalendarProps {
onSelect?: (date: DateType, selectInfo: SelectInfo) => void;
}
-function generateCalendar(generateConfig: GenerateConfig) {
+function generateCalendar(generateConfig: GenerateConfig) {
function isSameYear(date1: DateType, date2: DateType) {
return date1 && date2 && generateConfig.getYear(date1) === generateConfig.getYear(date2);
}
diff --git a/components/config-provider/__tests__/__snapshots__/components.test.tsx.snap b/components/config-provider/__tests__/__snapshots__/components.test.tsx.snap
index e8dca60f0c..b257c47ba8 100644
--- a/components/config-provider/__tests__/__snapshots__/components.test.tsx.snap
+++ b/components/config-provider/__tests__/__snapshots__/components.test.tsx.snap
@@ -1860,7 +1860,7 @@ exports[`ConfigProvider components Calendar configProvider 1`] = `
|
|
| | | | |