"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MenuGroup = MenuGroup;
exports.default = void 0;
var _clsx = _interopRequireDefault(require("clsx"));
var _element = require("@wordpress/element");
var _compose = require("@wordpress/compose");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * External dependencies
 */

/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

/**
 * `MenuGroup` wraps a series of related `MenuItem` components into a common
 * section.
 *
 * ```jsx
 * import { MenuGroup, MenuItem } from '@wordpress/components';
 *
 * const MyMenuGroup = () => (
 *   <MenuGroup label="Settings">
 *     <MenuItem>Setting 1</MenuItem>
 *     <MenuItem>Setting 2</MenuItem>
 *   </MenuGroup>
 * );
 * ```
 */
function MenuGroup(props) {
  const {
    children,
    className = '',
    label,
    hideSeparator
  } = props;
  const instanceId = (0, _compose.useInstanceId)(MenuGroup);
  if (!_element.Children.count(children)) {
    return null;
  }
  const labelId = `components-menu-group-label-${instanceId}`;
  const classNames = (0, _clsx.default)(className, 'components-menu-group', {
    'has-hidden-separator': hideSeparator
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: classNames,
    children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "components-menu-group__label",
      id: labelId,
      "aria-hidden": "true",
      children: label
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      role: "group",
      "aria-labelledby": label ? labelId : undefined,
      children: children
    })]
  });
}
var _default = exports.default = MenuGroup;
//# sourceMappingURL=index.js.map