"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 __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.NavGroup = exports.cssClass = void 0;
var _ = require("lodash");
var PropTypes = require("prop-types");
var React = require("react");
var classnames = require("classnames");
var MorePropTypes_1 = require("../utils/MorePropTypes");
var NavLink_1 = require("./NavLink");
require("./NavGroup.less");
var propTypes = {
    children: MorePropTypes_1.default.oneOrManyOf(MorePropTypes_1.default.instanceOfComponent(NavLink_1.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,
};
exports.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_1.NavLink, { className: classnames(exports.cssClass.CONTAINER, _open && exports.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));
exports.NavGroup = NavGroup;
