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