UNPKG

@carbon/react

Version:

React components for the Carbon Design System

60 lines (56 loc) 1.42 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. */ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js'; import PropTypes from 'prop-types'; import React from 'react'; import cx from 'classnames'; import { usePrefix } from '../../internal/usePrefix.js'; const SelectItem = ({ className, value = '', disabled = false, hidden = false, text = '', ...other }) => { const prefix = usePrefix(); const selectItemClasses = cx({ [`${prefix}--select-option`]: true, ...(className && { [className]: className }) }); return /*#__PURE__*/React.createElement("option", _extends({}, other, { className: selectItemClasses, value: value, disabled: disabled, hidden: hidden }), text); }; SelectItem.propTypes = { /** * Specify an optional className to be applied to the node */ className: PropTypes.string, /** * Specify whether the <SelectItem> should be disabled */ disabled: PropTypes.bool, /** * Specify whether the <SelectItem> is hidden */ hidden: PropTypes.bool, /** * Provide the contents of your <SelectItem> */ text: PropTypes.string.isRequired, /** * Specify the value of the <SelectItem> */ value: PropTypes.any.isRequired }; export { SelectItem as default };