UNPKG

2.88 kBJavaScriptView Raw
1var _excluded = ["className", "listClassName", "cssModule", "children", "tag", "listTag", "aria-label"];
2function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5import React from 'react';
6import PropTypes from 'prop-types';
7import classNames from 'classnames';
8import { mapToCssModules, tagPropType } from './utils';
9var propTypes = {
10 /** Aria label */
11 'aria-label': PropTypes.string,
12 /** Pass children so this component can wrap them */
13 children: PropTypes.node,
14 /** Add custom class */
15 className: PropTypes.string,
16 /** Change existing className with a new className */
17 cssModule: PropTypes.object,
18 /** Add custom class to list tag */
19 listClassName: PropTypes.string,
20 /** Set a custom element for list tag */
21 listTag: tagPropType,
22 /** Set a custom element for this component */
23 tag: tagPropType
24};
25function Breadcrumb(props) {
26 var className = props.className,
27 listClassName = props.listClassName,
28 cssModule = props.cssModule,
29 children = props.children,
30 _props$tag = props.tag,
31 Tag = _props$tag === void 0 ? 'nav' : _props$tag,
32 _props$listTag = props.listTag,
33 ListTag = _props$listTag === void 0 ? 'ol' : _props$listTag,
34 _props$ariaLabel = props['aria-label'],
35 label = _props$ariaLabel === void 0 ? 'breadcrumb' : _props$ariaLabel,
36 attributes = _objectWithoutProperties(props, _excluded);
37 var classes = mapToCssModules(classNames(className), cssModule);
38 var listClasses = mapToCssModules(classNames('breadcrumb', listClassName), cssModule);
39 return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
40 className: classes,
41 "aria-label": label
42 }), /*#__PURE__*/React.createElement(ListTag, {
43 className: listClasses
44 }, children));
45}
46Breadcrumb.propTypes = propTypes;
47export default Breadcrumb;
\No newline at end of file