You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

64 lines
2.0 KiB

  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
  3. import React from 'react';
  4. import PropTypes from 'prop-types';
  5. import classNames from 'classnames';
  6. import { mapToCssModules, tagPropType } from './utils';
  7. var propTypes = {
  8. tabs: PropTypes.bool,
  9. pills: PropTypes.bool,
  10. vertical: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
  11. horizontal: PropTypes.string,
  12. justified: PropTypes.bool,
  13. fill: PropTypes.bool,
  14. navbar: PropTypes.bool,
  15. card: PropTypes.bool,
  16. tag: tagPropType,
  17. className: PropTypes.string,
  18. cssModule: PropTypes.object
  19. };
  20. var defaultProps = {
  21. tag: 'ul',
  22. vertical: false
  23. };
  24. var getVerticalClass = function getVerticalClass(vertical) {
  25. if (vertical === false) {
  26. return false;
  27. } else if (vertical === true || vertical === 'xs') {
  28. return 'flex-column';
  29. }
  30. return "flex-" + vertical + "-column";
  31. };
  32. var Nav = function Nav(props) {
  33. var className = props.className,
  34. cssModule = props.cssModule,
  35. tabs = props.tabs,
  36. pills = props.pills,
  37. vertical = props.vertical,
  38. horizontal = props.horizontal,
  39. justified = props.justified,
  40. fill = props.fill,
  41. navbar = props.navbar,
  42. card = props.card,
  43. Tag = props.tag,
  44. attributes = _objectWithoutPropertiesLoose(props, ["className", "cssModule", "tabs", "pills", "vertical", "horizontal", "justified", "fill", "navbar", "card", "tag"]);
  45. var classes = mapToCssModules(classNames(className, navbar ? 'navbar-nav' : 'nav', horizontal ? "justify-content-" + horizontal : false, getVerticalClass(vertical), {
  46. 'nav-tabs': tabs,
  47. 'card-header-tabs': card && tabs,
  48. 'nav-pills': pills,
  49. 'card-header-pills': card && pills,
  50. 'nav-justified': justified,
  51. 'nav-fill': fill
  52. }), cssModule);
  53. return React.createElement(Tag, _extends({}, attributes, {
  54. className: classes
  55. }));
  56. };
  57. Nav.propTypes = propTypes;
  58. Nav.defaultProps = defaultProps;
  59. export default Nav;