@carbon/ibm-products
Version:
Carbon for IBM Products
116 lines (114 loc) • 3.02 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* 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 { getDevtoolsProps } from "../../global/js/utils/devtools.js";
import { prepareProps } from "../../global/js/utils/props-helper.js";
import { AddSelect } from "../AddSelect/AddSelect.js";
import React, { forwardRef } from "react";
import PropTypes from "prop-types";
//#region src/components/SingleAddSelect/SingleAddSelect.tsx
const componentName = "SingleAddSelect";
/**
* Used to add or select one or more items from larger lists or hierarchies.
*/
const SingleAddSelect = forwardRef((props, ref) => {
const validProps = prepareProps(props, [
"columnInputPlaceholder",
"globalFilters",
"globalFiltersIconDescription",
"globalFiltersPlaceholderText",
"globalFiltersPrimaryButtonText",
"globalFiltersSecondaryButtonText",
"influencerTitle",
"multi",
"noSelectionDescription",
"noSelectionTitle",
"removeIconDescription"
]);
return /* @__PURE__ */ React.createElement(AddSelect, {
...validProps,
ref,
...getDevtoolsProps(componentName),
multi: false
});
});
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,
/**
* Determines if the component should be rendered within a Tearsheet component
*/
noTearsheet: PropTypes.bool,
/**
* 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;
//#endregion
export { SingleAddSelect };