GoScrobble/web/node_modules/reactstrap/es/NavLink.js

76 lines
2.2 KiB
JavaScript

import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { mapToCssModules, tagPropType } from './utils';
var propTypes = {
tag: tagPropType,
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
disabled: PropTypes.bool,
active: PropTypes.bool,
className: PropTypes.string,
cssModule: PropTypes.object,
onClick: PropTypes.func,
href: PropTypes.any
};
var defaultProps = {
tag: 'a'
};
var NavLink = /*#__PURE__*/function (_React$Component) {
_inheritsLoose(NavLink, _React$Component);
function NavLink(props) {
var _this;
_this = _React$Component.call(this, props) || this;
_this.onClick = _this.onClick.bind(_assertThisInitialized(_this));
return _this;
}
var _proto = NavLink.prototype;
_proto.onClick = function onClick(e) {
if (this.props.disabled) {
e.preventDefault();
return;
}
if (this.props.href === '#') {
e.preventDefault();
}
if (this.props.onClick) {
this.props.onClick(e);
}
};
_proto.render = function render() {
var _this$props = this.props,
className = _this$props.className,
cssModule = _this$props.cssModule,
active = _this$props.active,
Tag = _this$props.tag,
innerRef = _this$props.innerRef,
attributes = _objectWithoutPropertiesLoose(_this$props, ["className", "cssModule", "active", "tag", "innerRef"]);
var classes = mapToCssModules(classNames(className, 'nav-link', {
disabled: attributes.disabled,
active: active
}), cssModule);
return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
ref: innerRef,
onClick: this.onClick,
className: classes
}));
};
return NavLink;
}(React.Component);
NavLink.propTypes = propTypes;
NavLink.defaultProps = defaultProps;
export default NavLink;