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 Collapse from 'react-bootstrap/lib/Collapse';
import { Button } from './Button';
import { Block } from './Block';
import { Icon } from './Icon';
import { Row } from './Row';
import Col from 'react-bootstrap/lib/Col';
import lang from '../../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.createElement(Button, { "aria-label": moreButtonLabel, "aria-expanded": !isCollapsed, onClick: this.handleToggleClick.bind(this), withIcon: true, bsStyle: "link" },
            moreButtonText,
            React.createElement(Icon, { name: iconName })));
    };
    CollapsibleToolbar.prototype.wrapMoreButton = function (moreButton) {
        return React.createElement(Col, { 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.createElement(Row, null,
            header,
            this.wrapMoreButton(this.getMoreButton())));
        var body;
        if (hasBodyPadding) {
            body = (React.createElement(Block, { noOffset: true },
                React.createElement(Block, { condensed: true }),
                collapsibleContent));
        }
        else {
            body = collapsibleContent;
        }
        return (React.createElement("div", { "data-test-automation-id": testAutomationId },
            headline,
            React.createElement(Collapse, { in: !this.state.isCollapsed }, body),
            footer));
    };
    CollapsibleToolbar.propTypes = {
        testAutomationId: PropTypes.string,
        header: PropTypes.arrayOf(PropTypes.node).isRequired,
        collapsibleContent: PropTypes.node.isRequired,
        footer: PropTypes.node,
        hasBodyPadding: PropTypes.bool,
        moreButtonText: PropTypes.string,
        moreButtonLabel: PropTypes.string
    };
    CollapsibleToolbar.defaultProps = {
        testAutomationId: 'collapsibleToolbar',
        get moreButtonText() {
            return lang.MORE;
        },
        get moreButtonLabel() {
            return lang.MORE_ADVANCED_FILTERS;
        },
        hasBodyPadding: true,
        footer: null
    };
    return CollapsibleToolbar;
}(React.Component));
export { CollapsibleToolbar };
//# sourceMappingURL=CollapsibleToolbar.js.map