@atlaskit/dropdown-menu
Version:
A dropdown menu displays a list of actions or options to a user.
59 lines • 1.84 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
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 const DropdownItemCheckboxGroup = ({
children,
hasSeparator,
id,
isList,
isScrollable,
testId,
title,
titleId,
label,
// DSP-13312 TODO: remove spread props in future major release
...rest
}) => {
const uid = useId();
const groupTitleId = titleId || `dropdown-menu-item-checkbox-group-title-${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;