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 { InfoCard } from '../InfoCard';
import { FlexBlock } from '../flexBlock/FlexBlock';
import { scrollElementIntoView } from '../../utils/functions';
var CatalogGridDetails = /** @class */ (function (_super) {
    __extends(CatalogGridDetails, _super);
    function CatalogGridDetails() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.ref = React.createRef();
        return _this;
    }
    CatalogGridDetails.prototype.componentDidMount = function () {
        var shouldScrollIntoView = this.props.shouldScrollIntoView;
        if (shouldScrollIntoView) {
            scrollElementIntoView(this.ref.current);
        }
    };
    CatalogGridDetails.prototype.renderIcon = function () {
        return React.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.createElement(FlexBlock, { align: FlexBlock.CENTER },
            this.renderIcon(),
            React.createElement("div", { className: "rc-catalog-grid-details__title", "data-test-automation-id": "title" }, title)));
        return (React.createElement(InfoCard, { testAutomationId: testAutomationId, tipOffset: InfoCard.calculateTipPositionWithColumns(index, colCount), title: titleNode, onClose: close, shouldScrollIntoView: shouldScrollIntoView }, children));
    };
    CatalogGridDetails.propTypes = {
        testAutomationId: PropTypes.string,
        index: PropTypes.number.isRequired,
        colCount: PropTypes.number.isRequired,
        icon: PropTypes.node.isRequired,
        title: PropTypes.string.isRequired,
        close: PropTypes.func,
        shouldScrollIntoView: PropTypes.bool
    };
    CatalogGridDetails.defaultProps = {
        testAutomationId: 'catalogGridDetails',
        close: null,
        shouldScrollIntoView: false
    };
    return CatalogGridDetails;
}(React.Component));
export { CatalogGridDetails };
//# sourceMappingURL=CatalogGridDetails.js.map