"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 InfoCard_1 = require("../InfoCard");
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.scrollElementIntoView(this.ref.current);
        }
    };
    CatalogGridDetails.prototype.renderIcon = function () {
        return react_1.default.cloneElement(this.props.icon, { size: 40, isRound: true });
    };
    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, shouldScrollIntoView = _a.shouldScrollIntoView;
        var titleNode = (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)));
        return (react_1.default.createElement(InfoCard_1.InfoCard, { testAutomationId: testAutomationId, tipOffset: InfoCard_1.InfoCard.calculateTipPositionWithColumns(index, colCount), title: titleNode, onClose: close, shouldScrollIntoView: shouldScrollIntoView }, 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.node.isRequired,
        title: prop_types_1.default.string.isRequired,
        close: prop_types_1.default.func,
        shouldScrollIntoView: prop_types_1.default.bool
    };
    CatalogGridDetails.defaultProps = {
        testAutomationId: 'catalogGridDetails',
        close: null,
        shouldScrollIntoView: false
    };
    return CatalogGridDetails;
}(react_1.default.Component));
exports.CatalogGridDetails = CatalogGridDetails;
//# sourceMappingURL=CatalogGridDetails.js.map