@carbon/react
Version:
React components for the Carbon Design System
77 lines (75 loc) • 2.53 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 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 { usePrefix } from "../../internal/usePrefix.js";
import { FormContext } from "../FluidForm/FormContext.js";
import { FilterableMultiSelect } from "../MultiSelect/FilterableMultiSelect.js";
import { MultiSelect } from "../MultiSelect/MultiSelect.js";
import classNames from "classnames";
import React from "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/FluidMultiSelect/FluidMultiSelect.tsx
/**
* Copyright IBM Corp. 2022, 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.
*/
const FluidMultiSelect = React.forwardRef(function FluidMultiSelect({ className, isCondensed, isFilterable, ...other }, ref) {
const prefix = usePrefix();
const classNames$1 = classNames(`${prefix}--list-box__wrapper--fluid`, className, { [`${prefix}--list-box__wrapper--fluid--condensed`]: isCondensed });
return /* @__PURE__ */ jsx(FormContext.Provider, {
value: { isFluid: true },
children: isFilterable ? /* @__PURE__ */ jsx(FilterableMultiSelect, {
ref,
className: classNames$1,
...other
}) : /* @__PURE__ */ jsx(MultiSelect, {
ref,
className: classNames$1,
...other
})
});
});
FluidMultiSelect.propTypes = {
className: PropTypes.string,
clearSelectionDescription: PropTypes.string,
clearSelectionText: PropTypes.string,
compareItems: PropTypes.func,
direction: PropTypes.oneOf(["top", "bottom"]),
disabled: PropTypes.bool,
downshiftProps: PropTypes.object,
id: PropTypes.string.isRequired,
initialSelectedItems: PropTypes.array,
invalid: PropTypes.bool,
invalidText: PropTypes.node,
isCondensed: PropTypes.bool,
isFilterable: PropTypes.bool,
itemToElement: PropTypes.func,
itemToString: PropTypes.func,
items: PropTypes.array.isRequired,
label: PropTypes.node.isRequired,
locale: PropTypes.string,
onChange: PropTypes.func,
onInputValueChange: PropTypes.func,
onMenuChange: PropTypes.func,
readOnly: PropTypes.bool,
selectedItems: PropTypes.array,
selectionFeedback: PropTypes.oneOf([
"top",
"fixed",
"top-after-reopen"
]),
sortItems: PropTypes.func,
titleText: PropTypes.node,
translateWithId: PropTypes.func,
useTitleInItem: PropTypes.bool,
warn: PropTypes.bool,
warnText: PropTypes.node
};
//#endregion
export { FluidMultiSelect as default };