UNPKG

@carbon/ibm-products

Version:

Carbon for IBM Products

105 lines (101 loc) 3.23 kB
/** * Copyright IBM Corp. 2020, 2025 * * 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 React__default, { forwardRef } from 'react'; import { AddSelect } from '../AddSelect/AddSelect.js'; import PropTypes from '../../_virtual/index.js'; import { getDevtoolsProps } from '../../global/js/utils/devtools.js'; import { pkg } from '../../settings.js'; import { prepareProps } from '../../global/js/utils/props-helper.js'; const componentName = 'SingleAddSelect'; /** * Used to add or select one or more items from larger lists or hierarchies. */ let SingleAddSelect = /*#__PURE__*/forwardRef((props, ref) => { // remove multi add select specific props const validProps = prepareProps(props, ['columnInputPlaceholder', 'globalFilters', 'globalFiltersIconDescription', 'globalFiltersPlaceholderText', 'globalFiltersPrimaryButtonText', 'globalFiltersSecondaryButtonText', 'influencerTitle', 'multi', 'noSelectionDescription', 'noSelectionTitle', 'removeIconDescription']); return /*#__PURE__*/React__default.createElement(AddSelect, _extends({}, validProps, { ref: ref }, getDevtoolsProps(componentName), { multi: false })); }); SingleAddSelect = pkg.checkComponentEnabled(SingleAddSelect, componentName); SingleAddSelect.propTypes = { /** * optional class name */ /**@ts-ignore */ className: PropTypes.string, /** * text description that appears under the title */ description: PropTypes.string, /** * label for global search input */ globalSearchLabel: PropTypes.string, /** * placeholder for global search input */ globalSearchPlaceholder: PropTypes.string, /** * object that contains the item data. for more information reference the * "Structuring items" section in the docs tab */ /**@ts-ignore */ items: PropTypes.shape({ entries: PropTypes.arrayOf(PropTypes.shape({ children: PropTypes.object, id: PropTypes.string.isRequired, title: PropTypes.string.isRequired, value: PropTypes.string.isRequired })) }), /** * label that display above the list of items */ itemsLabel: PropTypes.string, /** * text to display when no results are found from the global search */ noResultsDescription: PropTypes.string, /** * title to display when no results are found from the global search */ noResultsTitle: PropTypes.string, /** * function to call when the close button clicked */ onClose: PropTypes.func, /** * text for close button */ onCloseButtonText: PropTypes.string, /** * function to call when the submit button is clicked. returns a selection */ onSubmit: PropTypes.func, /** * text for the submit button */ onSubmitButtonText: PropTypes.string, /** * specifies if the component is open or not */ open: PropTypes.bool, /** * text that displays when displaying filtered items */ searchResultsLabel: PropTypes.string, /** * header text */ title: PropTypes.string }; SingleAddSelect.displayName = componentName; export { SingleAddSelect };