@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
52 lines (47 loc) • 1.47 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default from 'react';
import { usePrefix } from '../../internal/usePrefix.js';
import PropTypes from 'prop-types';
import ListBoxMenuItem from './ListBoxMenuItem.js';
/**
* `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
* class into a single component. It is also being used to validate given
* `children` components.
*/
const ListBoxMenu = /*#__PURE__*/React__default.forwardRef(function ListBoxMenu(_ref, ref) {
let {
children,
id,
...rest
} = _ref;
const prefix = usePrefix();
return /*#__PURE__*/React__default.createElement("div", _extends({
ref: ref,
id: id,
className: `${prefix}--list-box__menu`,
role: "listbox"
}, rest), children);
});
ListBoxMenu.displayName = 'ListBoxMenu';
ListBoxMenu.propTypes = {
/**
* Provide the contents of your ListBoxMenu
*/
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.oneOf([ListBoxMenuItem])),
/**
* allow single item using the workaround for functional components
* https://github.com/facebook/react/issues/2979#issuecomment-222379916
*/
PropTypes.shape({
type: PropTypes.oneOf([ListBoxMenuItem])
}), PropTypes.bool // used in Dropdown for closed state
]),
/**
* Specify a custom `id`
*/
id: PropTypes.string.isRequired
};
export { ListBoxMenu as default };