fix: DropDownProps => DropdownProps (#35161)

* fix: DropDown => Dropdown

* chore: leave DropDownProps for compatibility
This commit is contained in:
afc163 2022-04-21 22:09:59 +08:00 committed by GitHub
parent 93b55d5e8c
commit 8f06430336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 17 deletions

View File

@ -1,15 +1,15 @@
import * as React from 'react'; import * as React from 'react';
import DownOutlined from '@ant-design/icons/DownOutlined'; import DownOutlined from '@ant-design/icons/DownOutlined';
import DropDown, { DropDownProps } from '../dropdown/dropdown'; import Dropdown, { DropdownProps } from '../dropdown/dropdown';
import { ConfigContext } from '../config-provider'; import { ConfigContext } from '../config-provider';
export interface BreadcrumbItemProps { export interface BreadcrumbItemProps {
prefixCls?: string; prefixCls?: string;
separator?: React.ReactNode; separator?: React.ReactNode;
href?: string; href?: string;
overlay?: DropDownProps['overlay']; overlay?: DropdownProps['overlay'];
dropdownProps?: DropDownProps; dropdownProps?: DropdownProps;
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>; onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
className?: string; className?: string;
children?: React.ReactNode; children?: React.ReactNode;
@ -27,16 +27,16 @@ const BreadcrumbItem: BreadcrumbItemInterface = ({
}) => { }) => {
const { getPrefixCls } = React.useContext(ConfigContext); const { getPrefixCls } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls); const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
/** If overlay is have Wrap a DropDown */ /** If overlay is have Wrap a Dropdown */
const renderBreadcrumbNode = (breadcrumbItem: React.ReactNode) => { const renderBreadcrumbNode = (breadcrumbItem: React.ReactNode) => {
if (overlay) { if (overlay) {
return ( return (
<DropDown overlay={overlay} placement="bottom" {...dropdownProps}> <Dropdown overlay={overlay} placement="bottom" {...dropdownProps}>
<span className={`${prefixCls}-overlay-link`}> <span className={`${prefixCls}-overlay-link`}>
{breadcrumbItem} {breadcrumbItem}
<DownOutlined /> <DownOutlined />
</span> </span>
</DropDown> </Dropdown>
); );
} }
return breadcrumbItem; return breadcrumbItem;

View File

@ -5,13 +5,13 @@ import Button, { ButtonProps } from '../button';
import { ButtonHTMLType } from '../button/button'; import { ButtonHTMLType } from '../button/button';
import { ButtonGroupProps } from '../button/button-group'; import { ButtonGroupProps } from '../button/button-group';
import { ConfigContext } from '../config-provider'; import { ConfigContext } from '../config-provider';
import Dropdown, { DropDownProps } from './dropdown'; import Dropdown, { DropdownProps } from './dropdown';
const ButtonGroup = Button.Group; const ButtonGroup = Button.Group;
export type DropdownButtonType = 'default' | 'primary' | 'ghost' | 'dashed' | 'link' | 'text'; export type DropdownButtonType = 'default' | 'primary' | 'ghost' | 'dashed' | 'link' | 'text';
export interface DropdownButtonProps extends ButtonGroupProps, DropDownProps { export interface DropdownButtonProps extends ButtonGroupProps, DropdownProps {
type?: DropdownButtonType; type?: DropdownButtonType;
htmlType?: ButtonHTMLType; htmlType?: ButtonHTMLType;
disabled?: boolean; disabled?: boolean;
@ -76,7 +76,7 @@ const DropdownButton: DropdownButtonInterface = props => {
overlayClassName, overlayClassName,
overlayStyle, overlayStyle,
destroyPopupOnHide, destroyPopupOnHide,
} as DropDownProps; } as DropdownProps;
if ('visible' in props) { if ('visible' in props) {
dropdownProps.visible = visible; dropdownProps.visible = visible;

View File

@ -41,7 +41,7 @@ export type DropdownArrowOptions = {
pointAtCenter?: boolean; pointAtCenter?: boolean;
}; };
export interface DropDownProps { export interface DropdownProps {
arrow?: boolean | DropdownArrowOptions; arrow?: boolean | DropdownArrowOptions;
trigger?: ('click' | 'hover' | 'contextMenu')[]; trigger?: ('click' | 'hover' | 'contextMenu')[];
overlay: React.ReactElement | OverlayFunc; overlay: React.ReactElement | OverlayFunc;
@ -64,7 +64,7 @@ export interface DropDownProps {
children?: React.ReactNode; children?: React.ReactNode;
} }
interface DropdownInterface extends React.FC<DropDownProps> { interface DropdownInterface extends React.FC<DropdownProps> {
Button: typeof DropdownButton; Button: typeof DropdownButton;
} }

View File

@ -1,5 +1,10 @@
import Dropdown from './dropdown'; import Dropdown from './dropdown';
export { DropDownProps } from './dropdown'; export type {
export { DropdownButtonProps, DropdownButtonType } from './dropdown-button'; DropdownProps,
// typo, but we need to support it for backwards compatibility
// https://github.com/ant-design/ant-design/pull/35161
DropdownProps as DropDownProps,
} from './dropdown';
export type { DropdownButtonProps, DropdownButtonType } from './dropdown-button';
export default Dropdown; export default Dropdown;

View File

@ -78,7 +78,12 @@ export { default as Descriptions } from './descriptions';
export type { DividerProps } from './divider'; export type { DividerProps } from './divider';
export { default as Divider } from './divider'; export { default as Divider } from './divider';
export type { DropDownProps } from './dropdown'; export type {
DropdownProps,
// typo, but we need to support it for backwards compatibility
// https://github.com/ant-design/ant-design/pull/35161
DropdownProps as DropDownProps,
} from './dropdown';
export { default as Dropdown } from './dropdown'; export { default as Dropdown } from './dropdown';
export type { DrawerProps } from './drawer'; export type { DrawerProps } from './drawer';

View File

@ -130,7 +130,7 @@ const InternalSelect = <OptionType extends BaseOptionType | DefaultOptionType =
const selectProps = omit(props as typeof props & { itemIcon: any }, ['suffixIcon', 'itemIcon']); const selectProps = omit(props as typeof props & { itemIcon: any }, ['suffixIcon', 'itemIcon']);
const rcSelectRtlDropDownClassName = classNames(dropdownClassName, { const rcSelectRtlDropdownClassName = classNames(dropdownClassName, {
[`${prefixCls}-dropdown-${direction}`]: direction === 'rtl', [`${prefixCls}-dropdown-${direction}`]: direction === 'rtl',
}); });
@ -181,7 +181,7 @@ const InternalSelect = <OptionType extends BaseOptionType | DefaultOptionType =
notFoundContent={mergedNotFound} notFoundContent={mergedNotFound}
className={mergedClassName} className={mergedClassName}
getPopupContainer={getPopupContainer || getContextPopupContainer} getPopupContainer={getPopupContainer || getContextPopupContainer}
dropdownClassName={rcSelectRtlDropDownClassName} dropdownClassName={rcSelectRtlDropdownClassName}
showArrow={hasFeedback || showArrow} showArrow={hasFeedback || showArrow}
/> />
); );

View File

@ -2198,7 +2198,7 @@ describe('Table.filter', () => {
}); });
}); });
it('filterDropDown should support filterResetToDefaultFilteredValue', () => { it('filterDropdown should support filterResetToDefaultFilteredValue', () => {
jest.useFakeTimers(); jest.useFakeTimers();
jest.spyOn(console, 'error').mockImplementation(() => undefined); jest.spyOn(console, 'error').mockImplementation(() => undefined);