UNPKG

@carbon/ibm-products

Version:

Carbon for IBM Products

54 lines (50 loc) 1.69 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 from 'react'; import PropTypes from '../../_virtual/index.js'; import cx from 'classnames'; import { pkg } from '../../settings.js'; import { AddSelectRow } from './AddSelectRow.js'; import useFocus from './hooks/useFocus.js'; const blockClass = `${pkg.prefix}--add-select__selections`; const componentName = 'AddSelectList'; let AddSelectList = _ref => { let { filteredItems, multi, ...rest } = _ref; const [focus, setFocus] = useFocus(filteredItems.length); return /*#__PURE__*/React__default.createElement("div", { id: "add-select-focus", className: cx(`${blockClass}-wrapper`, { [`${blockClass}-wrapper-multi`]: multi }) }, /*#__PURE__*/React__default.createElement("div", { className: `${blockClass}` }, /*#__PURE__*/React__default.createElement("div", { className: `${blockClass}-body`, role: "treegrid", "aria-label": "add select tree label" }, filteredItems.map((item, index) => /*#__PURE__*/React__default.createElement(AddSelectRow, _extends({ key: item.id, index: index, focus: focus, setSize: filteredItems.length, item: item, multi: multi, setFocus: setFocus }, rest)))))); }; AddSelectList.propTypes = { filteredItems: PropTypes.array, focus: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), multi: PropTypes.bool }; AddSelectList.displayName = componentName; export { AddSelectList };