@carbon/react
Version:
React components for the Carbon Design System
64 lines (62 loc) • 2 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 ComboBox_default from "../ComboBox/index.js";
import classNames from "classnames";
import React from "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/FluidComboBox/FluidComboBox.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 FluidComboBox = React.forwardRef(function FluidComboBox({ className, isCondensed, ...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: /* @__PURE__ */ jsx(ComboBox_default, {
ref,
className: classNames$1,
...other
})
});
});
FluidComboBox.propTypes = {
className: PropTypes.string,
direction: PropTypes.oneOf(["top", "bottom"]),
disabled: PropTypes.bool,
id: PropTypes.string.isRequired,
initialSelectedItem: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string,
PropTypes.number
]),
invalid: PropTypes.bool,
invalidText: PropTypes.node,
isCondensed: PropTypes.bool,
itemToElement: PropTypes.func,
itemToString: PropTypes.func,
items: PropTypes.array.isRequired,
label: PropTypes.node.isRequired,
onChange: PropTypes.func.isRequired,
selectedItem: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string,
PropTypes.number
]),
titleText: PropTypes.node,
translateWithId: PropTypes.func,
warn: PropTypes.bool,
warnText: PropTypes.node
};
//#endregion
export { FluidComboBox as default };