UNPKG

1.98 kBJavaScriptView Raw
1import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
3import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
4import classNames from 'classnames';
5import React from 'react';
6import PropTypes from 'prop-types';
7import SafeAnchor from './SafeAnchor';
8var propTypes = {
9 /**
10 * If set to true, renders `span` instead of `a`
11 */
12 active: PropTypes.bool,
13
14 /**
15 * `href` attribute for the inner `a` element
16 */
17 href: PropTypes.string,
18
19 /**
20 * `title` attribute for the inner `a` element
21 */
22 title: PropTypes.node,
23
24 /**
25 * `target` attribute for the inner `a` element
26 */
27 target: PropTypes.string
28};
29var defaultProps = {
30 active: false
31};
32
33var BreadcrumbItem =
34/*#__PURE__*/
35function (_React$Component) {
36 _inheritsLoose(BreadcrumbItem, _React$Component);
37
38 function BreadcrumbItem() {
39 return _React$Component.apply(this, arguments) || this;
40 }
41
42 var _proto = BreadcrumbItem.prototype;
43
44 _proto.render = function render() {
45 var _this$props = this.props,
46 active = _this$props.active,
47 href = _this$props.href,
48 title = _this$props.title,
49 target = _this$props.target,
50 className = _this$props.className,
51 props = _objectWithoutPropertiesLoose(_this$props, ["active", "href", "title", "target", "className"]); // Don't try to render these props on non-active <span>.
52
53
54 var linkProps = {
55 href: href,
56 title: title,
57 target: target
58 };
59 return React.createElement("li", {
60 className: classNames(className, {
61 active: active
62 })
63 }, active ? React.createElement("span", props) : React.createElement(SafeAnchor, _extends({}, props, linkProps)));
64 };
65
66 return BreadcrumbItem;
67}(React.Component);
68
69BreadcrumbItem.propTypes = propTypes;
70BreadcrumbItem.defaultProps = defaultProps;
71export default BreadcrumbItem;
\No newline at end of file