@carbon/react
Version:
React components for the Carbon Design System
73 lines (71 loc) • 2.19 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 { NumberFormatOptionsPropType } from "../NumberInput/NumberFormatPropTypes.js";
import { NumberInput } from "../NumberInput/NumberInput.js";
import classNames from "classnames";
import React from "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/FluidNumberInput/FluidNumberInput.tsx
/**
* Copyright IBM Corp. 2022, 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.
*/
const FluidNumberInput = React.forwardRef(({ className, ...other }, ref) => {
const classNames$1 = classNames(`${usePrefix()}--number-input--fluid`, className);
return /* @__PURE__ */ jsx(FormContext.Provider, {
value: { isFluid: true },
children: /* @__PURE__ */ jsx(NumberInput, {
ref,
className: classNames$1,
...other
})
});
});
FluidNumberInput.propTypes = {
allowEmpty: PropTypes.bool,
className: PropTypes.string,
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
disableWheel: PropTypes.bool,
disabled: PropTypes.bool,
formatOptions: NumberFormatOptionsPropType,
iconDescription: PropTypes.string,
id: PropTypes.string.isRequired,
inputMode: PropTypes.oneOf([
"none",
"text",
"tel",
"url",
"email",
"numeric",
"decimal",
"search"
]),
invalid: PropTypes.bool,
invalidText: PropTypes.node,
label: PropTypes.node,
locale: PropTypes.string,
max: PropTypes.number,
min: PropTypes.number,
onChange: PropTypes.func,
onClick: PropTypes.func,
onKeyUp: PropTypes.func,
pattern: PropTypes.string,
step: PropTypes.number,
translateWithId: PropTypes.func,
type: PropTypes.oneOf(["number", "text"]),
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
warn: PropTypes.bool,
warnText: PropTypes.node,
readOnly: PropTypes.bool
};
//#endregion
export { FluidNumberInput as default };