mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
8501b708ea
* 📦 samller bundlesize limit * 🗑️ remove React static PropTypes * 🗑️ remove react-lifecycles-compat * 🗑️ remove matchMedia polyfill * 🗑️ remove Transfer buggy lazy prop * 🗑️ remove enquire.js dep * 🗑️ remove Transfer lazy related code and fix ci * 🗑️ remove used dom-closest * ⚡ replace dom-scroll-into-view to scroll-into-view for bundle size * ✅ fix eslint * 🆙 upgrade browserslist * ✅ fix test cases * 🗑️ remove @ant-design/create-react-context * 🆙 upgrade @ant-design/bisheng-plugin * 🆙 upgrade rc-slider * ✅ fix ci * 🆙 upgrade rc-tabs and rc-mentions * 📦 scroll-into-view -> scroll-into-view-if-needed * remove unused devDep * docs: 📝 update instruction about IE9/10 * 📦 reduce css bundle size by drop IE9/10 support * 🆙 upgrade rc-upload * 🗑️ drop unused swing motion css * ✅ update upload snapshots * 📦 lift css bundlesize limit to 55kb
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
import * as React from 'react';
|
|
import { DownOutlined } from '@ant-design/icons';
|
|
import omit from 'omit.js';
|
|
|
|
import DropDown, { DropDownProps } from '../dropdown/dropdown';
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
|
|
|
export interface BreadcrumbItemProps {
|
|
prefixCls?: string;
|
|
separator?: React.ReactNode;
|
|
href?: string;
|
|
overlay?: DropDownProps['overlay'];
|
|
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
|
|
}
|
|
|
|
export default class BreadcrumbItem extends React.Component<BreadcrumbItemProps, any> {
|
|
static __ANT_BREADCRUMB_ITEM = true;
|
|
|
|
static defaultProps = {
|
|
separator: '/',
|
|
};
|
|
|
|
renderBreadcrumbItem = ({ getPrefixCls }: ConfigConsumerProps) => {
|
|
const { prefixCls: customizePrefixCls, separator, children, ...restProps } = this.props;
|
|
const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
|
|
let link;
|
|
if ('href' in this.props) {
|
|
link = (
|
|
<a className={`${prefixCls}-link`} {...omit(restProps, ['overlay'])}>
|
|
{children}
|
|
</a>
|
|
);
|
|
} else {
|
|
link = (
|
|
<span className={`${prefixCls}-link`} {...omit(restProps, ['overlay'])}>
|
|
{children}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
// wrap to dropDown
|
|
link = this.renderBreadcrumbNode(link, prefixCls);
|
|
if (children) {
|
|
return (
|
|
<span>
|
|
{link}
|
|
{separator && separator !== '' && (
|
|
<span className={`${prefixCls}-separator`}>{separator}</span>
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* if overlay is have
|
|
* Wrap a DropDown
|
|
*/
|
|
renderBreadcrumbNode = (breadcrumbItem: React.ReactNode, prefixCls: string) => {
|
|
const { overlay } = this.props;
|
|
if (overlay) {
|
|
return (
|
|
<DropDown overlay={overlay} placement="bottomCenter">
|
|
<span className={`${prefixCls}-overlay-link`}>
|
|
{breadcrumbItem}
|
|
<DownOutlined />
|
|
</span>
|
|
</DropDown>
|
|
);
|
|
}
|
|
return breadcrumbItem;
|
|
};
|
|
|
|
render() {
|
|
return <ConfigConsumer>{this.renderBreadcrumbItem}</ConfigConsumer>;
|
|
}
|
|
}
|