@carbon/react
Version:
React components for the Carbon Design System
59 lines (57 loc) • 1.93 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 PasswordInput from "../TextInput/PasswordInput.js";
import TextInput_default from "../TextInput/index.js";
import classNames from "classnames";
import React from "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/FluidTextInput/FluidTextInput.tsx
/**
* Copyright IBM Corp. 2016, 2023
*
* 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 FluidTextInput = React.forwardRef(({ className, isPassword, ...other }, ref) => {
const classNames$1 = classNames(className, { [`${usePrefix()}--text-input--fluid`]: !isPassword });
return /* @__PURE__ */ jsx(FormContext.Provider, {
value: { isFluid: true },
children: isPassword ? /* @__PURE__ */ jsx(PasswordInput, {
className: classNames$1,
ref,
...other
}) : /* @__PURE__ */ jsx(TextInput_default, {
className: classNames$1,
ref,
...other
})
});
});
FluidTextInput.propTypes = {
className: PropTypes.string,
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
disabled: PropTypes.bool,
id: PropTypes.string.isRequired,
invalid: PropTypes.bool,
invalidText: PropTypes.node,
isPassword: PropTypes.bool,
maxCount: PropTypes.number,
enableCounter: PropTypes.bool,
labelText: PropTypes.node.isRequired,
onChange: PropTypes.func,
onClick: PropTypes.func,
placeholder: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
warn: PropTypes.bool,
warnText: PropTypes.node,
readOnly: PropTypes.bool
};
//#endregion
export { FluidTextInput as default };