Browse Source

Merge branch 'AdonLee-master'

pull/38380/head
afc163 2 years ago
parent
commit
3bb6f4af4f
  1. 7
      components/date-picker/__tests__/type.test.tsx
  2. 23
      components/date-picker/generatePicker/generateRangePicker.tsx
  3. 19
      components/date-picker/generatePicker/generateSinglePicker.tsx

7
components/date-picker/__tests__/type.test.tsx

@ -58,4 +58,11 @@ describe('DatePicker.typescript', () => {
);
expect(datePicker).toBeTruthy();
});
it('DatePicker and RangePicker supports popupClassName', () => {
const datePicker = <DatePicker popupClassName="popupClassName" />;
expect(datePicker).toBeTruthy();
const rangePicker = <DatePicker.RangePicker popupClassName="popupClassName" />;
expect(rangePicker).toBeTruthy();
});
});

23
components/date-picker/generatePicker/generateRangePicker.tsx

@ -21,21 +21,20 @@ import { getRangePlaceholder, transPlacement2DropdownAlign } from '../util';
import type { CommonPickerMethods, PickerComponentClass } from './interface';
import warning from '../../_util/warning';
export default function generateRangePicker<DateType>(
generateConfig: GenerateConfig<DateType>,
): PickerComponentClass<RangePickerProps<DateType>> {
export default function generateRangePicker<DateType>(generateConfig: GenerateConfig<DateType>) {
type InternalRangePickerProps = RangePickerProps<DateType> & {};
type DateRangePickerProps = RangePickerProps<DateType> & {
/**
* @deprecated `dropdownClassName` is deprecated which will be removed in next major
* version.Please use `popupClassName` instead.
*/
dropdownClassName?: string;
popupClassName?: string;
};
const RangePicker = forwardRef<
InternalRangePickerProps | CommonPickerMethods,
RangePickerProps<DateType> & {
/**
* @deprecated `dropdownClassName` is deprecated which will be removed in next major
* version.Please use `popupClassName` instead.
*/
dropdownClassName: string;
popupClassName?: string;
}
DateRangePickerProps
>((props, ref) => {
const {
prefixCls: customizePrefixCls,
@ -149,5 +148,5 @@ export default function generateRangePicker<DateType>(
);
});
return RangePicker as unknown as PickerComponentClass<RangePickerProps<DateType>>;
return RangePicker as unknown as PickerComponentClass<DateRangePickerProps>;
}

19
components/date-picker/generatePicker/generateSinglePicker.tsx

@ -8,7 +8,7 @@ import type { PickerMode } from 'rc-picker/lib/interface';
import * as React from 'react';
import { forwardRef, useContext, useImperativeHandle } from 'react';
import { useCompactItemContext } from '../../space/Compact';
import type { PickerDateProps, PickerProps, PickerTimeProps } from '.';
import type { PickerProps, PickerTimeProps } from '.';
import { Components, getTimeProps } from '.';
import { ConfigContext } from '../../config-provider';
import DisabledContext from '../../config-provider/DisabledContext';
@ -23,7 +23,7 @@ import { getPlaceholder, transPlacement2DropdownAlign } from '../util';
import type { CommonPickerMethods, DatePickRef, PickerComponentClass } from './interface';
export default function generatePicker<DateType>(generateConfig: GenerateConfig<DateType>) {
type DatePickerProps = PickerProps<DateType> & {
type CustomPickerProps = {
status?: InputStatus;
/**
* @deprecated `dropdownClassName` is deprecated which will be removed in next major
@ -31,7 +31,10 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
*/
dropdownClassName?: string;
popupClassName?: string;
};
}
type DatePickerProps = PickerProps<DateType> & CustomPickerProps;
type TimePickerProps = PickerTimeProps<DateType> & CustomPickerProps
function getPicker<InnerPickerProps extends DatePickerProps>(
picker?: PickerMode,
displayName?: string,
@ -172,11 +175,11 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
}
const DatePicker = getPicker<DatePickerProps>();
const WeekPicker = getPicker<Omit<PickerDateProps<DateType>, 'picker'>>('week', 'WeekPicker');
const MonthPicker = getPicker<Omit<PickerDateProps<DateType>, 'picker'>>('month', 'MonthPicker');
const YearPicker = getPicker<Omit<PickerDateProps<DateType>, 'picker'>>('year', 'YearPicker');
const TimePicker = getPicker<Omit<PickerTimeProps<DateType>, 'picker'>>('time', 'TimePicker');
const QuarterPicker = getPicker<Omit<PickerTimeProps<DateType>, 'picker'>>(
const WeekPicker = getPicker<Omit<DatePickerProps, 'picker'>>('week', 'WeekPicker');
const MonthPicker = getPicker<Omit<DatePickerProps, 'picker'>>('month', 'MonthPicker');
const YearPicker = getPicker<Omit<DatePickerProps, 'picker'>>('year', 'YearPicker');
const TimePicker = getPicker<Omit<TimePickerProps, 'picker'>>('time', 'TimePicker');
const QuarterPicker = getPicker<Omit<TimePickerProps, 'picker'>>(
'quarter',
'QuarterPicker',
);

Loading…
Cancel
Save