UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

88 lines (84 loc) 2.96 kB
/** * MSKCC 2021, 2024 */ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js'; import PropTypes from 'prop-types'; import React__default from 'react'; import cx from 'classnames'; import Link from '../Link/Link.js'; import { Icon } from '../Icon/MskIcon.js'; import { usePrefix } from '../../internal/usePrefix.js'; const BreadcrumbItem = /*#__PURE__*/React__default.forwardRef(function BreadcrumbItem(_ref, ref) { let { 'aria-current': ariaCurrent, children, className: customClassName, href, isCurrentPage, ...rest } = _ref; const prefix = usePrefix(); const className = cx({ [`${prefix}--breadcrumb-item`]: true, // We set the current class only if `isCurrentPage` is passed in and we do // not have an `aria-current="page"` set for the breadcrumb item [`${prefix}--breadcrumb-item--current`]: isCurrentPage && ariaCurrent !== 'page', [customClassName]: !!customClassName }); if (children.type && children.type.displayName !== undefined && children.type.displayName.includes('OverflowMenu')) { const horizontalOverflowIcon = /*#__PURE__*/React__default.createElement(Icon, { icon: "more_horiz", className: `${prefix}--overflow-menu__icon` }); return /*#__PURE__*/React__default.createElement("li", _extends({ className: className }, rest), /*#__PURE__*/React__default.cloneElement(children, { menuOptionsClass: `${prefix}--breadcrumb-menu-options`, menuOffset: { top: 10, left: 59 }, renderIcon: () => horizontalOverflowIcon })); } if (typeof children === 'string') { return /*#__PURE__*/React__default.createElement("li", _extends({ className: className, ref: ref }, rest), href ? /*#__PURE__*/React__default.createElement(Link, { href: href, "aria-current": ariaCurrent }, children) : /*#__PURE__*/React__default.createElement("span", { className: `${prefix}--link` }, children)); } return /*#__PURE__*/React__default.createElement("li", _extends({ className: className, ref: ref }, rest), /*#__PURE__*/React__default.cloneElement(children, { 'aria-current': ariaCurrent, className: cx(`${prefix}--link`, children.props.className) })); }); BreadcrumbItem.displayName = 'BreadcrumbItem'; BreadcrumbItem.propTypes = { 'aria-current': PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), /** * Pass in content that will be inside of the BreadcrumbItem */ children: PropTypes.node, /** * Specify an optional className to be applied to the container node */ className: PropTypes.string, /** * Optional string representing the link location for the BreadcrumbItem */ href: PropTypes.string, /** * Provide if this breadcrumb item represents the current page */ isCurrentPage: PropTypes.bool }; var BreadcrumbItem$1 = BreadcrumbItem; export { BreadcrumbItem$1 as default };