mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-19 06:43:16 +08:00
feat: replace date-picker,time-picker dropdownClassName to popupClassName (#37207)
This commit is contained in:
parent
428665827b
commit
ed1bb649ba
@ -225,20 +225,6 @@ describe('DatePicker', () => {
|
||||
).toBe(60);
|
||||
});
|
||||
|
||||
it('DatePicker should show warning when use dropdownClassName', () => {
|
||||
render(<DatePicker dropdownClassName="myCustomClassName" />);
|
||||
expect(errorSpy).toHaveBeenCalledWith(
|
||||
'Warning: [antd: DatePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
});
|
||||
|
||||
it('RangePicker should show warning when use dropdownClassName', () => {
|
||||
render(<DatePicker.RangePicker dropdownClassName="myCustomClassName" />);
|
||||
expect(errorSpy).toHaveBeenCalledWith(
|
||||
'Warning: [antd: RangePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
});
|
||||
|
||||
it('DatePicker.RangePicker with defaultPickerValue and showTime', () => {
|
||||
const startDate = dayjs('1982-02-12');
|
||||
const endDate = dayjs('1982-02-22');
|
||||
|
@ -18,7 +18,6 @@ import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils';
|
||||
import enUS from '../locale/en_US';
|
||||
import { getRangePlaceholder, transPlacement2DropdownAlign } from '../util';
|
||||
import type { CommonPickerMethods, PickerComponentClass } from './interface';
|
||||
import warning from '../../_util/warning';
|
||||
|
||||
import useStyle from '../style';
|
||||
|
||||
@ -30,11 +29,6 @@ export default function generateRangePicker<DateType>(
|
||||
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;
|
||||
}
|
||||
>((props, ref) => {
|
||||
@ -48,7 +42,6 @@ export default function generateRangePicker<DateType>(
|
||||
bordered = true,
|
||||
placeholder,
|
||||
popupClassName,
|
||||
dropdownClassName,
|
||||
status: customStatus,
|
||||
...restProps
|
||||
} = props;
|
||||
@ -68,12 +61,6 @@ export default function generateRangePicker<DateType>(
|
||||
...(picker === 'time' ? getTimeProps({ format, ...props, picker }) : {}),
|
||||
};
|
||||
|
||||
warning(
|
||||
!dropdownClassName,
|
||||
'RangePicker',
|
||||
'`dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
|
||||
// ===================== Size =====================
|
||||
const size = React.useContext(SizeContext);
|
||||
const mergedSize = customizeSize || size;
|
||||
@ -143,7 +130,7 @@ export default function generateRangePicker<DateType>(
|
||||
generateConfig={generateConfig}
|
||||
components={Components}
|
||||
direction={direction}
|
||||
dropdownClassName={classNames(hashId, popupClassName || dropdownClassName)}
|
||||
dropdownClassName={classNames(hashId, popupClassName)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
|
@ -27,11 +27,6 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
||||
type DatePickerProps = PickerProps<DateType> & {
|
||||
status?: InputStatus;
|
||||
hashId?: string;
|
||||
/**
|
||||
* @deprecated `dropdownClassName` is deprecated which will be removed in next major
|
||||
* version.Please use `popupClassName` instead.
|
||||
*/
|
||||
dropdownClassName?: string;
|
||||
popupClassName?: string;
|
||||
};
|
||||
function getPicker<InnerPickerProps extends DatePickerProps>(
|
||||
@ -49,7 +44,6 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
||||
placement,
|
||||
placeholder,
|
||||
popupClassName,
|
||||
dropdownClassName,
|
||||
disabled: customDisabled,
|
||||
status: customStatus,
|
||||
...restProps
|
||||
@ -93,11 +87,6 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
||||
`DatePicker.${displayName} is legacy usage. Please use DatePicker[picker='${picker}'] directly.`,
|
||||
);
|
||||
|
||||
warning(
|
||||
!dropdownClassName,
|
||||
'DatePicker',
|
||||
'`dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
// ===================== Size =====================
|
||||
const size = React.useContext(SizeContext);
|
||||
const mergedSize = customizeSize || size;
|
||||
@ -158,7 +147,7 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
||||
components={Components}
|
||||
direction={direction}
|
||||
disabled={mergedDisabled}
|
||||
dropdownClassName={classNames(hashId, popupClassName || dropdownClassName)}
|
||||
dropdownClassName={classNames(hashId, popupClassName)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
|
@ -88,20 +88,6 @@ describe('TimePicker', () => {
|
||||
expect(container.querySelector(`.${popupClassName}`)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('RangePicker should show warning when use dropdownClassName', () => {
|
||||
render(<TimePicker.RangePicker dropdownClassName="myCustomClassName" />);
|
||||
expect(errorSpy).toHaveBeenCalledWith(
|
||||
'Warning: [antd: RangePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
});
|
||||
|
||||
it('TimePicker should show warning when use dropdownClassName', () => {
|
||||
render(<TimePicker dropdownClassName="myCustomClassName" />);
|
||||
expect(errorSpy).toHaveBeenCalledWith(
|
||||
'Warning: [antd: TimePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
});
|
||||
|
||||
it('should support bordered', () => {
|
||||
const { container } = render(
|
||||
<TimePicker
|
||||
|
@ -14,45 +14,21 @@ export interface TimePickerLocale {
|
||||
}
|
||||
|
||||
export interface TimeRangePickerProps extends Omit<RangePickerTimeProps<Dayjs>, 'picker'> {
|
||||
/**
|
||||
* @deprecated `dropdownClassName` is deprecated which will be removed in next major
|
||||
* version.Please use `popupClassName` instead.
|
||||
*/
|
||||
dropdownClassName?: string;
|
||||
popupClassName?: string;
|
||||
}
|
||||
|
||||
const RangePicker = React.forwardRef<any, TimeRangePickerProps>((props, ref) => {
|
||||
const { dropdownClassName, popupClassName } = props;
|
||||
warning(
|
||||
!dropdownClassName,
|
||||
'RangePicker',
|
||||
'`dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
return (
|
||||
<InternalRangePicker
|
||||
{...props}
|
||||
dropdownClassName={popupClassName || dropdownClassName}
|
||||
picker="time"
|
||||
mode={undefined}
|
||||
ref={ref}
|
||||
/>
|
||||
);
|
||||
});
|
||||
const RangePicker = React.forwardRef<any, TimeRangePickerProps>((props, ref) => (
|
||||
<InternalRangePicker {...props} picker="time" mode={undefined} ref={ref} />
|
||||
));
|
||||
|
||||
export interface TimePickerProps extends Omit<PickerTimeProps<Dayjs>, 'picker'> {
|
||||
addon?: () => React.ReactNode;
|
||||
popupClassName?: string;
|
||||
/**
|
||||
* @deprecated `dropdownClassName` is deprecated which will be removed in next major
|
||||
* version.Please use `popupClassName` instead.
|
||||
*/
|
||||
dropdownClassName?: string;
|
||||
status?: InputStatus;
|
||||
popupClassName?: string;
|
||||
}
|
||||
|
||||
const TimePicker = React.forwardRef<any, TimePickerProps>(
|
||||
({ addon, renderExtraFooter, popupClassName, dropdownClassName, ...restProps }, ref) => {
|
||||
({ addon, renderExtraFooter, ...restProps }, ref) => {
|
||||
const internalRenderExtraFooter = React.useMemo(() => {
|
||||
if (renderExtraFooter) {
|
||||
return renderExtraFooter;
|
||||
@ -69,15 +45,8 @@ const TimePicker = React.forwardRef<any, TimePickerProps>(
|
||||
return undefined;
|
||||
}, [addon, renderExtraFooter]);
|
||||
|
||||
warning(
|
||||
!dropdownClassName,
|
||||
'TimePicker',
|
||||
'`dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.',
|
||||
);
|
||||
|
||||
return (
|
||||
<InternalTimePicker
|
||||
dropdownClassName={popupClassName || dropdownClassName}
|
||||
{...restProps}
|
||||
mode={undefined}
|
||||
ref={ref}
|
||||
|
@ -17,4 +17,6 @@
|
||||
- Cascader 组件
|
||||
- Select 组件
|
||||
- TreeSelect 组件
|
||||
- TimePicker 组件
|
||||
- DatePicker 组件
|
||||
- open 属性转换:https://github.com/ant-design/ant-design/issues/36609
|
||||
|
Loading…
Reference in New Issue
Block a user