shineout
Version:
Shein 前端组件库
58 lines (45 loc) • 1.6 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/objectSpread";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { PureComponent } from 'react';
import classnames from 'classnames';
import { tabsClass } from './styles';
import { isLink } from '../utils/is';
var Link =
/*#__PURE__*/
function (_PureComponent) {
_inheritsLoose(Link, _PureComponent);
function Link() {
return _PureComponent.apply(this, arguments) || this;
}
var _proto = Link.prototype;
_proto.render = function render() {
var _this$props = this.props,
children = _this$props.children,
href = _this$props.href,
className = _this$props.className,
other = _objectWithoutPropertiesLoose(_this$props, ["children", "href", "className"]);
var mergeClass = classnames(className, tabsClass('link'));
var props = _objectSpread({
className: mergeClass,
href: href
}, other);
if (isLink(children)) {
if (children.props.onClick) {
props.onClick = function () {
children.props.onClick();
if (other.onClick) {
other.onClick();
}
};
}
return React.cloneElement(children, _objectSpread({}, props));
}
return React.createElement("a", props, children);
};
return Link;
}(PureComponent);
_defineProperty(Link, "isTabLink", void 0);
Link.isTabLink = true;
export default Link;