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 { CatalogItemIcon } from './CatalogItemIcon';
import { Icon } from '../Icon';
import { FlexBlock } from '../flexBlock/FlexBlock';
import { scrollEelementIntoView } 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) {
            scrollEelementIntoView(this.ref.current);
        }
    };
    CatalogGridDetails.prototype.renderIcon = function () {
        var _a = this.props, icon = _a.icon, color = _a.color;
        if (React.isValidElement(icon)) {
            return icon;
        }
        return React.createElement(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.createElement("div", { ref: this.ref, className: "rc-catalog-grid-details", "data-test-automation-id": testAutomationId },
            React.createElement("div", { style: { left: (100 / colCount) * ((index % colCount) + 0.5) + "%" }, className: "rc-catalog-grid-details__tip" }),
            React.createElement(FlexBlock, { justify: FlexBlock.SPACE_BETWEEN, className: "rc-catalog-grid-details__header" },
                React.createElement(FlexBlock, { align: FlexBlock.CENTER },
                    this.renderIcon(),
                    React.createElement("div", { className: "rc-catalog-grid-details__title", "data-test-automation-id": "title" }, title)),
                React.createElement("button", { onClick: close, className: "rc-catalog-grid-details__close", "data-test-automation-id": "closeButton" },
                    React.createElement(Icon, { name: "close" }))),
            React.createElement("div", { "data-test-automation-id": "gridDetailsChildren" }, children)));
    };
    CatalogGridDetails.propTypes = {
        testAutomationId: PropTypes.string,
        index: PropTypes.number.isRequired,
        colCount: PropTypes.number.isRequired,
        icon: PropTypes.string,
        color: PropTypes.string,
        title: PropTypes.string.isRequired,
        close: PropTypes.func,
        shouldScrollIntoView: PropTypes.bool
    };
    CatalogGridDetails.defaultProps = {
        testAutomationId: 'catalogGridDetails',
        icon: null,
        color: null,
        close: null,
        shouldScrollIntoView: false
    };
    return CatalogGridDetails;
}(React.Component));
export { CatalogGridDetails };
//# sourceMappingURL=CatalogGridDetails.js.map