'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 __());
    };
})();
import React from 'react';
import PropTypes from 'prop-types';
import { Collapse } from 'react-bootstrap';
import _ from 'lodash';
var CollapsibleList = /** @class */ (function (_super) {
    __extends(CollapsibleList, _super);
    function CollapsibleList(props, context) {
        var _this = _super.call(this, props, context) || this;
        _this.state = {
            isCollapsed: true
        };
        return _this;
    }
    CollapsibleList.prototype.handleToggleClick = function () {
        this.setState({
            isCollapsed: !this.state.isCollapsed
        });
    };
    CollapsibleList.prototype.render = function () {
        var head = _.take(this.props.children, this.props.visibleItems);
        var tail = _.takeRight(this.props.children, this.props.children.length - this.props.visibleItems);
        var showToggle = tail.length > 0;
        var toggle;
        if (showToggle) {
            toggle = (React.createElement("span", { className: "toggle-list", onClick: this.handleToggleClick.bind(this) }, "..."));
        }
        return (React.createElement("div", { className: "collapsible-list", "data-test-automation-id": this.props.testAutomationId },
            React.createElement("div", { className: "head-wrapper" }, head),
            toggle,
            React.createElement(Collapse, { in: !this.state.isCollapsed },
                React.createElement("div", null, tail))));
    };
    CollapsibleList.propTypes = {
        testAutomationId: PropTypes.string,
        visibleItems: PropTypes.number,
        children: PropTypes.node
    };
    CollapsibleList.defaultProps = {
        testAutomationId: 'collapsibleList',
        visibleItems: 1,
        children: null
    };
    return CollapsibleList;
}(React.Component));
export { CollapsibleList };
//# sourceMappingURL=CollapsibleList.js.map