import DownOutlined from '@ant-design/icons/DownOutlined'; import * as React from 'react'; import warning from '../_util/warning'; import { ConfigContext } from '../config-provider'; import type { DropdownProps } from '../dropdown/dropdown'; import Dropdown from '../dropdown/dropdown'; export interface BreadcrumbItemProps { prefixCls?: string; separator?: React.ReactNode; href?: string; menu?: DropdownProps['menu']; dropdownProps?: DropdownProps; onClick?: React.MouseEventHandler; className?: string; children?: React.ReactNode; // Deprecated /** @deprecated Please use `menu` instead */ overlay?: DropdownProps['overlay']; } type CompoundedComponent = React.FC & { __ANT_BREADCRUMB_ITEM: boolean; }; const BreadcrumbItem: CompoundedComponent = (props) => { const { prefixCls: customizePrefixCls, separator = '/', children, menu, overlay, dropdownProps, ...restProps } = props; const { getPrefixCls } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls); // Warning for deprecated usage if (process.env.NODE_ENV !== 'production') { warning( !('overlay' in props), 'Breadcrumb.Item', '`overlay` is deprecated. Please use `menu` instead.', ); } /** If overlay is have Wrap a Dropdown */ const renderBreadcrumbNode = (breadcrumbItem: React.ReactNode) => { if (menu || overlay) { const mergeDropDownProps: DropdownProps = { ...dropdownProps, }; if ('overlay' in props) { mergeDropDownProps.overlay = overlay; } return ( {breadcrumbItem} ); } return breadcrumbItem; }; let link: React.ReactNode; if ('href' in restProps) { link = ( {children} ); } else { link = ( {children} ); } // wrap to dropDown link = renderBreadcrumbNode(link); if (children !== undefined && children !== null) { return (
  • {link} {separator && {separator}}
  • ); } return null; }; BreadcrumbItem.__ANT_BREADCRUMB_ITEM = true; export default BreadcrumbItem;