UNPKG

@carbon/react

Version:

React components for the Carbon Design System

64 lines (58 loc) 1.54 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 PropTypes = require('prop-types'); var React = require('react'); var cx = require('classnames'); var usePrefix = require('../../internal/usePrefix.js'); const SelectItem = ({ className, value = '', disabled = false, hidden = false, text = '', ...other }) => { const prefix = usePrefix.usePrefix(); const selectItemClasses = cx({ [`${prefix}--select-option`]: true, ...(className && { [className]: className }) }); return /*#__PURE__*/React.createElement("option", _rollupPluginBabelHelpers.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 }; exports.default = SelectItem;