83 lines
3.1 KiB
JavaScript
83 lines
3.1 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
|
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
|
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
|
var _all = _interopRequireDefault(require("prop-types-extra/lib/all"));
|
|
|
|
var _react = _interopRequireWildcard(require("react"));
|
|
|
|
var _uncontrollable = require("uncontrollable");
|
|
|
|
var _ThemeProvider = require("./ThemeProvider");
|
|
|
|
var _NavbarContext = _interopRequireDefault(require("./NavbarContext"));
|
|
|
|
var _CardContext = _interopRequireDefault(require("./CardContext"));
|
|
|
|
var _AbstractNav = _interopRequireDefault(require("./AbstractNav"));
|
|
|
|
var _NavItem = _interopRequireDefault(require("./NavItem"));
|
|
|
|
var _NavLink = _interopRequireDefault(require("./NavLink"));
|
|
|
|
var defaultProps = {
|
|
justify: false,
|
|
fill: false
|
|
};
|
|
|
|
var Nav = _react.default.forwardRef(function (uncontrolledProps, ref) {
|
|
var _classNames;
|
|
|
|
var _useUncontrolled = (0, _uncontrollable.useUncontrolled)(uncontrolledProps, {
|
|
activeKey: 'onSelect'
|
|
}),
|
|
_useUncontrolled$as = _useUncontrolled.as,
|
|
as = _useUncontrolled$as === void 0 ? 'div' : _useUncontrolled$as,
|
|
bsPrefix = _useUncontrolled.bsPrefix,
|
|
variant = _useUncontrolled.variant,
|
|
fill = _useUncontrolled.fill,
|
|
justify = _useUncontrolled.justify,
|
|
navbar = _useUncontrolled.navbar,
|
|
className = _useUncontrolled.className,
|
|
children = _useUncontrolled.children,
|
|
activeKey = _useUncontrolled.activeKey,
|
|
props = (0, _objectWithoutPropertiesLoose2.default)(_useUncontrolled, ["as", "bsPrefix", "variant", "fill", "justify", "navbar", "className", "children", "activeKey"]);
|
|
|
|
bsPrefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, 'nav');
|
|
var navbarBsPrefix, cardHeaderBsPrefix;
|
|
var navbarContext = (0, _react.useContext)(_NavbarContext.default);
|
|
var cardContext = (0, _react.useContext)(_CardContext.default);
|
|
|
|
if (navbarContext) {
|
|
navbarBsPrefix = navbarContext.bsPrefix;
|
|
navbar = navbar == null ? true : navbar;
|
|
} else if (cardContext) {
|
|
cardHeaderBsPrefix = cardContext.cardHeaderBsPrefix;
|
|
}
|
|
|
|
return _react.default.createElement(_AbstractNav.default, (0, _extends2.default)({
|
|
as: as,
|
|
ref: ref,
|
|
activeKey: activeKey,
|
|
className: (0, _classnames.default)(className, (_classNames = {}, _classNames[bsPrefix] = !navbar, _classNames[navbarBsPrefix + "-nav"] = navbar, _classNames[cardHeaderBsPrefix + "-" + variant] = !!cardHeaderBsPrefix, _classNames[bsPrefix + "-" + variant] = !!variant, _classNames[bsPrefix + "-fill"] = fill, _classNames[bsPrefix + "-justified"] = justify, _classNames))
|
|
}, props), children);
|
|
});
|
|
|
|
Nav.displayName = 'Nav';
|
|
Nav.defaultProps = defaultProps;
|
|
Nav.Item = _NavItem.default;
|
|
Nav.Link = _NavLink.default;
|
|
var _default = Nav;
|
|
exports.default = _default;
|
|
module.exports = exports["default"]; |