var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import _ from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { Icon } from './Icon';
var ExternalLink = /** @class */ (function (_super) {
    __extends(ExternalLink, _super);
    function ExternalLink() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.onClick = function (e) {
            if (_.isFunction(_this.props.onClick)) {
                _this.props.onClick(e);
            }
            return false;
        };
        /*
          Add onKeyDown event handler for <ExternalLink/> Component,
          For child element of <NavDropdown/> Component should receive onKeyDown prop from parent and bind to proper element.
         */
        _this.onKeyDown = function (e) {
            if (_.isFunction(_this.props.onKeyDown)) {
                _this.props.onKeyDown(e);
            }
        };
        return _this;
    }
    ExternalLink.prototype.render = function () {
        var _a = this.props, id = _a.id, href = _a.href, tabIndex = _a.tabIndex, title = _a.title, role = _a.role, withIcon = _a.withIcon;
        var icon = withIcon ? React.createElement(Icon, { name: "link" }) : null;
        return (React.createElement("li", { id: id, role: "presentation", "data-test-automation-id": id },
            React.createElement("a", { href: href, role: role, tabIndex: tabIndex, onClick: this.onClick, onKeyDown: this.onKeyDown, target: "_blank", className: "link-item" },
                title,
                icon)));
    };
    ExternalLink.propTypes = {
        tabIndex: PropTypes.number,
        id: PropTypes.string.isRequired,
        title: PropTypes.string.isRequired,
        href: PropTypes.string.isRequired,
        role: PropTypes.string,
        onClick: PropTypes.func,
        onKeyDown: PropTypes.func,
        withIcon: PropTypes.bool
    };
    ExternalLink.defaultProps = {
        tabIndex: -1,
        onClick: null,
        onKeyDown: null,
        role: null,
        withIcon: false
    };
    return ExternalLink;
}(React.Component));
export { ExternalLink };
//# sourceMappingURL=ExternalLink.js.map