UNPKG

@carbon/react

Version:

React components for the Carbon Design System

64 lines (55 loc) 2.14 kB
/** * Copyright IBM Corp. 2016, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js'); var React = require('react'); var usePrefix = require('../../internal/usePrefix.js'); var PropTypes = require('prop-types'); var ListBoxMenuItem = require('./ListBoxMenuItem.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var React__default = /*#__PURE__*/_interopDefaultLegacy(React); var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); const frFn = React.forwardRef; /** * `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 = frFn(({ children, id, ...rest }, ref) => { const prefix = usePrefix.usePrefix(); return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["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__default["default"].oneOfType([PropTypes__default["default"].node, PropTypes__default["default"].arrayOf(PropTypes__default["default"].oneOf([ListBoxMenuItem["default"]])), /** * allow single item using the workaround for functional components * https://github.com/facebook/react/issues/2979#issuecomment-222379916 */ PropTypes__default["default"].shape({ type: PropTypes__default["default"].oneOf([ListBoxMenuItem["default"]]) }), PropTypes__default["default"].bool // used in Dropdown for closed state ]), /** * Specify a custom `id` */ id: PropTypes__default["default"].string.isRequired }; exports["default"] = ListBoxMenu;