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 * as _ from "lodash";
import * as PropTypes from "prop-types";
import * as React from "react";
import * as classnames from "classnames";
import MorePropTypes from "../utils/MorePropTypes";
import { NavLink } from "./NavLink";
import "./NavGroup.less";
var propTypes = {
    children: MorePropTypes.oneOrManyOf(MorePropTypes.instanceOfComponent(NavLink)).isRequired,
    className: PropTypes.string,
    icon: PropTypes.element.isRequired,
    id: PropTypes.string.isRequired,
    label: PropTypes.node.isRequired,
    title: PropTypes.string,
    // Internal use only:
    _collapsed: PropTypes.bool,
    _onClick: PropTypes.func,
    _open: PropTypes.bool,
    _withActiveNavGroups: PropTypes.bool,
    _withTooltips: PropTypes.bool,
};
export var cssClass = {
    CONTAINER: "NavGroup",
    OPEN: "NavGroup--open",
};
// NavGroup doesn't render its children because LeftNav will render them in
// a drawer if the NavGroup is open.
var NavGroup = /** @class */ (function (_super) {
    __extends(NavGroup, _super);
    function NavGroup() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    NavGroup.prototype.render = function () {
        var _a = this.props, _collapsed = _a._collapsed, _onClick = _a._onClick, _open = _a._open, _withActiveNavGroups = _a._withActiveNavGroups, _withTooltips = _a._withTooltips, children = _a.children, className = _a.className, icon = _a.icon, label = _a.label, title = _a.title;
        var childSelected = !!_.find(React.Children.toArray(children), function (item) { return item.props.selected; });
        return (React.createElement(NavLink, { className: classnames(cssClass.CONTAINER, _open && cssClass.OPEN, className), icon: icon, label: label, title: (title || label), onClick: _onClick, selected: _withActiveNavGroups && childSelected, _collapsed: _collapsed, _withArrow: true, _withTooltips: _withTooltips }));
    };
    NavGroup.propTypes = propTypes;
    return NavGroup;
}(React.PureComponent));
export { NavGroup };
