import _defineProperty from"babel-runtime/helpers/defineProperty";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";import*as React from"react";import*as PropTypes from"prop-types";import classNames from"classnames";var AnchorLink=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.handleClick=function(){e.context.antAnchor.scrollTo(e.props.href)},e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){this.context.antAnchor.registerLink(this.props.href)}},{key:"componentWillUnmount",value:function(){this.context.antAnchor.unregisterLink(this.props.href)}},{key:"render",value:function(){var e=this.props,t=e.prefixCls,r=e.href,n=e.title,o=e.children,i=this.context.antAnchor.activeLink===r,s=classNames(t+"-link",_defineProperty({},t+"-link-active",i)),a=classNames(t+"-link-title",_defineProperty({},t+"-link-title-active",i));return React.createElement("div",{className:s},React.createElement("a",{className:a,href:r,title:"string"==typeof n?n:"",onClick:this.handleClick},n),o)}}]),t}(React.Component);export default AnchorLink;AnchorLink.defaultProps={prefixCls:"dt-anchor",href:"#"},AnchorLink.contextTypes={antAnchor:PropTypes.object};