"use strict";
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 __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = __importDefault(require("lodash"));
var react_1 = __importDefault(require("react"));
var prop_types_1 = __importDefault(require("prop-types"));
var Icon_1 = require("./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 (lodash_1.default.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 (lodash_1.default.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_1.default.createElement(Icon_1.Icon, { name: "link" }) : null;
        return (react_1.default.createElement("li", { id: id, role: "presentation", "data-test-automation-id": id },
            react_1.default.createElement("a", { href: href, role: role, tabIndex: tabIndex, onClick: this.onClick, onKeyDown: this.onKeyDown, target: "_blank", className: "link-item" },
                title,
                icon)));
    };
    ExternalLink.propTypes = {
        tabIndex: prop_types_1.default.number,
        id: prop_types_1.default.string.isRequired,
        title: prop_types_1.default.string.isRequired,
        href: prop_types_1.default.string.isRequired,
        role: prop_types_1.default.string,
        onClick: prop_types_1.default.func,
        onKeyDown: prop_types_1.default.func,
        withIcon: prop_types_1.default.bool
    };
    ExternalLink.defaultProps = {
        tabIndex: -1,
        onClick: null,
        onKeyDown: null,
        role: null,
        withIcon: false
    };
    return ExternalLink;
}(react_1.default.Component));
exports.ExternalLink = ExternalLink;
//# sourceMappingURL=ExternalLink.js.map