@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
63 lines (55 loc) • 2.06 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var PropTypes = require('prop-types');
var usePrefix = require('../../internal/usePrefix.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);
/**
* `ListBoxField` is responsible for creating the containing node for valid
* elements inside of a field. It also provides a11y-related attributes like
* `role` to make sure a user can focus the given field.
*/
function ListBoxField(_ref) {
let {
children,
disabled,
tabIndex,
...rest
} = _ref;
const prefix = usePrefix.usePrefix();
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
className: `${prefix}--list-box__field`,
tabIndex: !disabled && tabIndex || -1
}, rest), children);
}
ListBoxField.propTypes = {
/**
* Typically set by `getToggleButtonProps`, this should specify whether the
* field has a popup.
*/
'aria-haspopup': PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].bool]),
/**
* Provide the contents of your ListBoxField
*/
children: PropTypes__default["default"].node,
/**
* Specify if the parent <ListBox> is disabled
*/
disabled: PropTypes__default["default"].bool,
/**
* The role for the component, should be set by `getToggleButtonProps` coming
* from Downshift
*/
role: PropTypes__default["default"].string,
/**
* Optional prop to specify the tabIndex of the <ListBox> trigger button
*/
tabIndex: PropTypes__default["default"].oneOfType([PropTypes__default["default"].number, PropTypes__default["default"].string])
};
exports["default"] = ListBoxField;