"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 react_1 = __importDefault(require("react"));
var prop_types_1 = __importDefault(require("prop-types"));
var CatalogItemIcon_1 = require("./CatalogItemIcon");
var Icon_1 = require("../Icon");
var FlexBlock_1 = require("../flexBlock/FlexBlock");
var functions_1 = require("../../utils/functions");
var CatalogGridDetails = /** @class */ (function (_super) {
    __extends(CatalogGridDetails, _super);
    function CatalogGridDetails() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.ref = react_1.default.createRef();
        return _this;
    }
    CatalogGridDetails.prototype.componentDidMount = function () {
        var shouldScrollIntoView = this.props.shouldScrollIntoView;
        if (shouldScrollIntoView) {
            functions_1.scrollEelementIntoView(this.ref.current);
        }
    };
    CatalogGridDetails.prototype.renderIcon = function () {
        var _a = this.props, icon = _a.icon, color = _a.color;
        if (react_1.default.isValidElement(icon)) {
            return icon;
        }
        return react_1.default.createElement(CatalogItemIcon_1.CatalogItemIcon, { isRound: true, size: 40, iconName: icon, backgroundColor: color });
    };
    CatalogGridDetails.prototype.render = function () {
        var _a = this.props, colCount = _a.colCount, index = _a.index, children = _a.children, testAutomationId = _a.testAutomationId, title = _a.title, close = _a.close;
        return (react_1.default.createElement("div", { ref: this.ref, className: "rc-catalog-grid-details", "data-test-automation-id": testAutomationId },
            react_1.default.createElement("div", { style: { left: (100 / colCount) * ((index % colCount) + 0.5) + "%" }, className: "rc-catalog-grid-details__tip" }),
            react_1.default.createElement(FlexBlock_1.FlexBlock, { justify: FlexBlock_1.FlexBlock.SPACE_BETWEEN, className: "rc-catalog-grid-details__header" },
                react_1.default.createElement(FlexBlock_1.FlexBlock, { align: FlexBlock_1.FlexBlock.CENTER },
                    this.renderIcon(),
                    react_1.default.createElement("div", { className: "rc-catalog-grid-details__title", "data-test-automation-id": "title" }, title)),
                react_1.default.createElement("button", { onClick: close, className: "rc-catalog-grid-details__close", "data-test-automation-id": "closeButton" },
                    react_1.default.createElement(Icon_1.Icon, { name: "close" }))),
            react_1.default.createElement("div", { "data-test-automation-id": "gridDetailsChildren" }, children)));
    };
    CatalogGridDetails.propTypes = {
        testAutomationId: prop_types_1.default.string,
        index: prop_types_1.default.number.isRequired,
        colCount: prop_types_1.default.number.isRequired,
        icon: prop_types_1.default.string,
        color: prop_types_1.default.string,
        title: prop_types_1.default.string.isRequired,
        close: prop_types_1.default.func,
        shouldScrollIntoView: prop_types_1.default.bool
    };
    CatalogGridDetails.defaultProps = {
        testAutomationId: 'catalogGridDetails',
        icon: null,
        color: null,
        close: null,
        shouldScrollIntoView: false
    };
    return CatalogGridDetails;
}(react_1.default.Component));
exports.CatalogGridDetails = CatalogGridDetails;
//# sourceMappingURL=CatalogGridDetails.js.map