@atlaskit/dropdown-menu
Version:
A dropdown menu displays a list of actions or options to a user.
59 lines • 2.21 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "hasSeparator", "id", "isList", "isScrollable", "testId", "title", "titleId", "label"];
import React from 'react';
import { useId } from '@atlaskit/ds-lib/use-id';
import Section from '@atlaskit/menu/section';
import { fg } from '@atlaskit/platform-feature-flags/fg';
import DropdownMenuItemGroup from '../dropdown-menu-item-group';
import GroupTitle from '../internal/components/group-title';
import { CheckboxGroupContext } from '../internal/context/checkbox-group-context';
/**
* __Dropdown item checkbox group__
*
* A wrapping element for dropdown menu checkbox items.
*
*/
export var DropdownItemCheckboxGroup = function DropdownItemCheckboxGroup(_ref) {
var children = _ref.children,
hasSeparator = _ref.hasSeparator,
id = _ref.id,
isList = _ref.isList,
isScrollable = _ref.isScrollable,
testId = _ref.testId,
title = _ref.title,
titleId = _ref.titleId,
label = _ref.label,
rest = _objectWithoutProperties(_ref, _excluded);
var uid = useId();
var groupTitleId = titleId || "dropdown-menu-item-checkbox-group-title-".concat(uid);
if (fg('platform-dst-new-menu')) {
return /*#__PURE__*/React.createElement(CheckboxGroupContext.Provider, {
value: id
}, /*#__PURE__*/React.createElement(DropdownMenuItemGroup, {
id: id,
hasSeparator: hasSeparator,
isScrollable: isScrollable,
testId: testId,
title: title,
titleId: groupTitleId,
label: label
}, children));
}
return /*#__PURE__*/React.createElement(CheckboxGroupContext.Provider, {
value: id
}, /*#__PURE__*/React.createElement(Section, _extends({
hasSeparator: hasSeparator,
id: id,
isList: isList,
isScrollable: isScrollable,
testId: testId,
titleId: title ? groupTitleId : undefined,
label: label
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
}, rest), title && /*#__PURE__*/React.createElement(GroupTitle, {
id: groupTitleId,
title: title
}), children));
};
export default DropdownItemCheckboxGroup;