UNPKG

@carbon/ibm-products

Version:

Carbon for IBM Products

56 lines (51 loc) 1.54 kB
/** * Copyright IBM Corp. 2020, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import React__default from 'react'; import { Breadcrumb, BreadcrumbItem } from '@carbon/react'; import PropTypes from '../../_virtual/index.js'; import cx from 'classnames'; import { pkg } from '../../settings.js'; // Copyright IBM Corp. 2022, 2022 // // This source code is licensed under the Apache-2.0 license found in the // LICENSE file in the root directory of this source tree. // const blockClass = `${pkg.prefix}--add-select__breadcrumbs`; const componentName = 'AddSelectBreadcrumbs'; let AddSelectBreadcrumbs = _ref => { let { multi, onClick, path } = _ref; const clickHandler = (e, idx) => { e.preventDefault(); onClick(idx); }; const classNames = cx(blockClass, { [`${blockClass}-multi`]: multi }); return /*#__PURE__*/React__default.createElement(Breadcrumb, { noTrailingSlash: true, className: classNames }, path.map((entry, idx) => { const isCurrentPage = idx === path.length - 1; return /*#__PURE__*/React__default.createElement(BreadcrumbItem, { key: entry.id, isCurrentPage: isCurrentPage, onClick: e => clickHandler(e, idx), href: "#" }, entry.title); })); }; AddSelectBreadcrumbs.propTypes = { multi: PropTypes.bool, onClick: PropTypes.func, path: PropTypes.array }; AddSelectBreadcrumbs.displayName = componentName; export { AddSelectBreadcrumbs };