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 classnames from 'classnames';
import { Col, ButtonToolbar } from 'react-bootstrap';
import { Panel } from '../../Panel';
import { Block } from '../../Block';
import { Row } from '../../Row';
var VIEW_MODE_DETAILS = 'VIEW_MODE_DETAILS';
var VIEW_MODE_FULL = 'VIEW_MODE_FULL';
var CommonListLayout = /** @class */ (function (_super) {
    __extends(CommonListLayout, _super);
    function CommonListLayout() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CommonListLayout.prototype.renderListActionsToolbar = function () {
        if (!this.props.listActions) {
            if (this.props.viewMode === VIEW_MODE_FULL) {
                return null;
            }
            else if (!this.props.withoutToolbarGap) {
                return React.createElement("div", { className: "rc-list-actions-toolbar-gap" });
            }
            return null;
        }
        var classes = classnames({
            'bottom-border': this.props.viewMode === VIEW_MODE_FULL
        });
        return (React.createElement("div", { className: classes },
            React.createElement(ButtonToolbar, { className: "no-offset cta-toolbar" }, this.props.listActions)));
    };
    CommonListLayout.prototype.renderHeader = function () {
        var middleSection = null;
        var _a = this.props, filtersColSize = _a.filtersColSize, actionsColSize = _a.actionsColSize, filters = _a.filters, actions = _a.actions, head = _a.head, subhead = _a.subhead;
        if (!filters && !actions && !head && !subhead) {
            return null;
        }
        if (filters || actions) {
            middleSection = (React.createElement(Block, { noOffset: true },
                React.createElement(Row, null,
                    React.createElement(Col, { xs: filtersColSize }, filters),
                    React.createElement(Col, { xs: actionsColSize },
                        React.createElement("div", { className: "pull-right" }, actions)))));
        }
        return (React.createElement("div", null,
            React.createElement(Block, { cancelTopOffset: true, cancelHorizontalOffset: true }, head),
            middleSection,
            subhead));
    };
    CommonListLayout.prototype.renderFooter = function () {
        var _a = this
            .props, viewMode = _a.viewMode, subFooter = _a.subFooter, renderCounterText = _a.renderCounterText, renderPagination = _a.renderPagination, withoutGrid = _a.withoutGrid;
        if (withoutGrid || viewMode !== VIEW_MODE_FULL) {
            return null;
        }
        var paginationBlock = null;
        if (this.props.hasPagination) {
            paginationBlock = (React.createElement(Col, { xs: 9, className: "vcenter text-right" }, renderPagination()));
        }
        return (React.createElement("div", null,
            React.createElement(Block, { noOffset: true },
                React.createElement(Row, null,
                    React.createElement(Col, { xs: 3, className: "vcenter" }, renderCounterText()),
                    paginationBlock)),
            subFooter));
    };
    CommonListLayout.prototype.renderDetails = function () {
        return this.props.details;
    };
    CommonListLayout.prototype.renderBody = function () {
        var _a = this.props, viewMode = _a.viewMode, list = _a.list, hasPagination = _a.hasPagination, listShortViewCol = _a.listShortViewCol, detailsShortViewCol = _a.detailsShortViewCol, renderPagination = _a.renderPagination;
        if (viewMode === VIEW_MODE_FULL) {
            return React.createElement("div", { "data-test-automation-id": "listContainer" }, list);
        }
        var paginationBlock = null;
        if (hasPagination) {
            paginationBlock = (React.createElement(Block, { addLeftOffset: true, addRightOffset: true },
                React.createElement(Row, null,
                    React.createElement(Col, { xs: 12 },
                        React.createElement("div", { className: "pull-right" }, renderPagination(false))))));
        }
        return (React.createElement(Row, { className: "rc-list-wrapper" },
            React.createElement(Col, { xs: listShortViewCol, className: "rc-list-left" },
                React.createElement(Panel, { noPadding: true, noLeftBorder: true },
                    React.createElement(Block, { "data-test-automation-id": "listContainer" }, list),
                    paginationBlock)),
            React.createElement(Col, { xs: detailsShortViewCol, "data-test-automation-id": "detailsContainer", className: "rc-list-details-container" }, this.renderDetails())));
    };
    CommonListLayout.prototype.renderPanelBody = function () {
        if (this.props['withoutGrid']) {
            return null;
        }
        return (React.createElement(Row, null,
            React.createElement(Col, { xs: 12 },
                this.renderListActionsToolbar(),
                this.renderBody())));
    };
    CommonListLayout.prototype.render = function () {
        var _a = this.props, isTransparent = _a.isTransparent, cancelMinHeight = _a.cancelMinHeight;
        return (React.createElement(Panel, { testAutomationId: this.props.testAutomationId, className: classnames(this.props.className, 'rc-list-layout'), header: this.renderHeader(), footer: this.renderFooter(), isTransparent: isTransparent, noBorder: isTransparent, cancelMinHeight: cancelMinHeight, noPadding: true }, this.renderPanelBody()));
    };
    CommonListLayout.propTypes = {
        renderCounterText: PropTypes.func.isRequired,
        renderPagination: PropTypes.func.isRequired,
        className: PropTypes.string,
        testAutomationId: PropTypes.string,
        list: PropTypes.node.isRequired,
        viewMode: PropTypes.oneOf([VIEW_MODE_DETAILS, VIEW_MODE_FULL]),
        details: PropTypes.node,
        head: PropTypes.node,
        subhead: PropTypes.node,
        filters: PropTypes.node,
        filtersColSize: PropTypes.number,
        actions: PropTypes.node,
        actionsColSize: PropTypes.number,
        listActions: PropTypes.node,
        subFooter: PropTypes.node,
        withoutToolbarGap: PropTypes.bool,
        isTransparent: PropTypes.bool,
        hasPagination: PropTypes.bool,
        listShortViewCol: PropTypes.number,
        detailsShortViewCol: PropTypes.number,
        cancelMinHeight: PropTypes.bool,
        withoutGrid: PropTypes.bool
    };
    CommonListLayout.defaultProps = {
        className: null,
        testAutomationId: 'panel',
        viewMode: VIEW_MODE_FULL,
        details: null,
        head: null,
        subhead: null,
        filters: null,
        filtersColSize: 7,
        actions: null,
        actionsColSize: 5,
        listActions: null,
        subFooter: null,
        withoutToolbarGap: false,
        isTransparent: false,
        hasPagination: true,
        listShortViewCol: 4,
        detailsShortViewCol: 8,
        cancelMinHeight: false,
        withoutGrid: false
    };
    CommonListLayout.VIEW_MODE_DETAILS = VIEW_MODE_DETAILS;
    CommonListLayout.VIEW_MODE_FULL = VIEW_MODE_FULL;
    return CommonListLayout;
}(React.Component));
export { CommonListLayout };
//# sourceMappingURL=CommonListLayout.js.map