UNPKG

3.75 kBJavaScriptView Raw
1var _excluded = ["className", "cssModule", "tabs", "pills", "vertical", "horizontal", "justified", "fill", "navbar", "card", "tag"];
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 /** Adding card prop adds `.card-header-tabs` or `.card-header-pills` class */
11 card: PropTypes.bool,
12 /** Add custom class */
13 className: PropTypes.string,
14 /** Change underlying component's CSS base class name */
15 cssModule: PropTypes.object,
16 /** fills the nav to extend to full available width */
17 fill: PropTypes.bool,
18 /** Change the horizontal alignment of your nav */
19 horizontal: PropTypes.oneOf(['center', 'end']),
20 /** All horizontal space will be occupied by nav links, but unlike the `fill` above, every nav item will be the same width. */
21 justified: PropTypes.bool,
22 /** Add navbar for a full-height and lightweight navigation */
23 navbar: PropTypes.bool,
24 /** Make NavItems look like pills */
25 pills: PropTypes.bool,
26 /** Make NavItems look like tabs */
27 tabs: PropTypes.bool,
28 /** Set a custom element for this component */
29 tag: tagPropType,
30 /** Stack your navigation by changing the flex item direction */
31 vertical: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
32};
33var getVerticalClass = function getVerticalClass(vertical) {
34 if (vertical === false) {
35 return false;
36 }
37 if (vertical === true || vertical === 'xs') {
38 return 'flex-column';
39 }
40 return "flex-".concat(vertical, "-column");
41};
42function Nav(props) {
43 var className = props.className,
44 cssModule = props.cssModule,
45 tabs = props.tabs,
46 pills = props.pills,
47 _props$vertical = props.vertical,
48 vertical = _props$vertical === void 0 ? false : _props$vertical,
49 horizontal = props.horizontal,
50 justified = props.justified,
51 fill = props.fill,
52 navbar = props.navbar,
53 card = props.card,
54 _props$tag = props.tag,
55 Tag = _props$tag === void 0 ? 'ul' : _props$tag,
56 attributes = _objectWithoutProperties(props, _excluded);
57 var classes = mapToCssModules(classNames(className, navbar ? 'navbar-nav' : 'nav', horizontal ? "justify-content-".concat(horizontal) : false, getVerticalClass(vertical), {
58 'nav-tabs': tabs,
59 'card-header-tabs': card && tabs,
60 'nav-pills': pills,
61 'card-header-pills': card && pills,
62 'nav-justified': justified,
63 'nav-fill': fill
64 }), cssModule);
65 return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
66 className: classes
67 }));
68}
69Nav.propTypes = propTypes;
70export default Nav;
\No newline at end of file