"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 Collapse_1 = __importDefault(require("react-bootstrap/lib/Collapse"));
var Button_1 = require("./Button");
var Block_1 = require("./Block");
var Icon_1 = require("./Icon");
var Row_1 = require("./Row");
var Col_1 = __importDefault(require("react-bootstrap/lib/Col"));
var index_en_US_1 = __importDefault(require("../../lang/common/index-en_US"));
var CollapsibleToolbar = /** @class */ (function (_super) {
    __extends(CollapsibleToolbar, _super);
    function CollapsibleToolbar(props, context) {
        var _this = _super.call(this, props, context) || this;
        _this.state = {
            isCollapsed: true
        };
        return _this;
    }
    CollapsibleToolbar.prototype.handleToggleClick = function () {
        this.setState({
            isCollapsed: !this.state.isCollapsed
        });
    };
    CollapsibleToolbar.prototype.getMoreButton = function () {
        var isCollapsed = this.state.isCollapsed;
        var _a = this.props, moreButtonText = _a.moreButtonText, moreButtonLabel = _a.moreButtonLabel;
        var iconName = isCollapsed ? 'chevron-down-small' : 'chevron-up-small';
        return (react_1.default.createElement(Button_1.Button, { "aria-label": moreButtonLabel, "aria-expanded": !isCollapsed, onClick: this.handleToggleClick.bind(this), withIcon: true, bsStyle: "link" },
            moreButtonText,
            react_1.default.createElement(Icon_1.Icon, { name: iconName })));
    };
    CollapsibleToolbar.prototype.wrapMoreButton = function (moreButton) {
        return react_1.default.createElement(Col_1.default, { xs: 2 }, moreButton);
    };
    CollapsibleToolbar.prototype.render = function () {
        var _a = this.props, header = _a.header, footer = _a.footer, collapsibleContent = _a.collapsibleContent, hasBodyPadding = _a.hasBodyPadding, testAutomationId = _a.testAutomationId;
        var headline = (react_1.default.createElement(Row_1.Row, null,
            header,
            this.wrapMoreButton(this.getMoreButton())));
        var body;
        if (hasBodyPadding) {
            body = (react_1.default.createElement(Block_1.Block, { noOffset: true },
                react_1.default.createElement(Block_1.Block, { condensed: true }),
                collapsibleContent));
        }
        else {
            body = collapsibleContent;
        }
        return (react_1.default.createElement("div", { "data-test-automation-id": testAutomationId },
            headline,
            react_1.default.createElement(Collapse_1.default, { in: !this.state.isCollapsed }, body),
            footer));
    };
    CollapsibleToolbar.propTypes = {
        testAutomationId: prop_types_1.default.string,
        header: prop_types_1.default.arrayOf(prop_types_1.default.node).isRequired,
        collapsibleContent: prop_types_1.default.node.isRequired,
        footer: prop_types_1.default.node,
        hasBodyPadding: prop_types_1.default.bool,
        moreButtonText: prop_types_1.default.string,
        moreButtonLabel: prop_types_1.default.string
    };
    CollapsibleToolbar.defaultProps = {
        testAutomationId: 'collapsibleToolbar',
        get moreButtonText() {
            return index_en_US_1.default.MORE;
        },
        get moreButtonLabel() {
            return index_en_US_1.default.MORE_ADVANCED_FILTERS;
        },
        hasBodyPadding: true,
        footer: null
    };
    return CollapsibleToolbar;
}(react_1.default.Component));
exports.CollapsibleToolbar = CollapsibleToolbar;
//# sourceMappingURL=CollapsibleToolbar.js.map