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 React from 'react';
import PropTypes from 'prop-types';
import lang from '../../../../lang/common/index-en_US';
var CommonList = /** @class */ (function (_super) {
    __extends(CommonList, _super);
    function CommonList() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CommonList.prototype.rowClickHandler = function (fn) {
        return function (event) {
            var isInsideStopper = false;
            var currentNode = event.target;
            var rootNode = event.currentTarget;
            var stopperAttribute;
            while (currentNode && currentNode !== rootNode) {
                stopperAttribute = currentNode.dataset
                    ? currentNode.dataset.stopRowClick
                    : currentNode.getAttribute('data-stop-row-click'); // for IE <= 10
                isInsideStopper = String(stopperAttribute).toLowerCase() === 'true';
                if (isInsideStopper) {
                    break;
                }
                else {
                    currentNode = currentNode.parentNode;
                }
            }
            if (isInsideStopper) {
                event.stopPropagation();
            }
            else {
                fn(event);
            }
        };
    };
    CommonList.prototype.renderEmpty = function () {
        return this.props.noResultsText;
    };
    CommonList.prototype.isEmptyListMessageVisible = function () { };
    CommonList.prototype.hasItems = function () { };
    CommonList.prototype.renderItems = function () { };
    CommonList.prototype.isEmptyList = function () { };
    CommonList.prototype.renderEmptyListMessage = function () {
        if (!this.isEmptyListMessageVisible()) {
            return null;
        }
        var _a = this.props, emptyListText = _a.emptyListText, noResultsText = _a.noResultsText;
        if (emptyListText && this.isEmptyList()) {
            return (React.createElement("div", { className: "grid-empty-list-message", "data-test-automation-id": "emptyListMessage" }, emptyListText));
        }
        return (React.createElement("div", { className: "grid-empty-list-message", "data-test-automation-id": "noResultsMessage" }, noResultsText));
    };
    CommonList.prototype.renderBlockedMessage = function () {
        if (this.props.isBlocked) {
            return (React.createElement("div", { className: "grid-blocked-list-container" },
                React.createElement("div", { className: "grid-blocked-list-message" }, this.props.blockedText)));
        }
    };
    CommonList.prototype.renderItem = function (item, index, array) {
        throw new Error('Overwrite renderItem method to use List');
    };
    CommonList.prototype.render = function () {
        return this.hasItems() ? this.renderItems() : this.renderEmpty();
    };
    CommonList.defaultProps = {
        isBlocked: false,
        emptyListText: null,
        get noResultsText() {
            return lang.NO_RESULTS;
        },
        get blockedText() {
            return lang.PLEASE_WAIT_WHILE_LOADING;
        }
    };
    CommonList.propTypes = {
        isBlocked: PropTypes.bool,
        emptyListText: PropTypes.node,
        noResultsText: PropTypes.node,
        blockedText: PropTypes.string
    };
    return CommonList;
}(React.Component));
export { CommonList };
//# sourceMappingURL=CommonList.js.map