UNPKG

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