UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

99 lines (95 loc) 2.79 kB
/** * MSKCC 2021, 2024 */ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js'; import PropTypes from 'prop-types'; import React__default from 'react'; import cx from 'classnames'; import TextInput from '../TextInput/TextInput.js'; import '../TextInput/TextInput.Skeleton.js'; import '../TextInput/ControlledPasswordInput.js'; import PasswordInput from '../TextInput/PasswordInput.js'; import { usePrefix } from '../../internal/usePrefix.js'; import { FormContext } from '../FluidForm/FormContext.js'; function FluidTextInput(_ref) { let { className, isPassword, ...other } = _ref; const prefix = usePrefix(); const classNames = cx(className, { [`${prefix}--text-input--fluid`]: !isPassword }); return /*#__PURE__*/React__default.createElement(FormContext.Provider, { value: { isFluid: true } }, isPassword ? /*#__PURE__*/React__default.createElement(PasswordInput, _extends({ className: classNames }, other)) : /*#__PURE__*/React__default.createElement(TextInput, _extends({ className: classNames }, other))); } FluidTextInput.propTypes = { /** * Specify an optional className to be applied to the outer FluidForm wrapper */ className: PropTypes.string, /** * Optionally provide the default value of the `<input>` */ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** * Specify whether the `<input>` should be disabled */ disabled: PropTypes.bool, /** * Specify a custom `id` for the `<input>` */ id: PropTypes.string.isRequired, /** * Specify whether the control is currently invalid */ invalid: PropTypes.bool, /** * Provide the text that is displayed when the control is in an invalid state */ invalidText: PropTypes.node, /** * Specify whether the control is a password input */ isPassword: PropTypes.bool, /** * Provide the text that will be read by a screen reader when visiting this * control */ labelText: PropTypes.node.isRequired, /** * Optionally provide an `onChange` handler that is called whenever `<input>` * is updated */ onChange: PropTypes.func, /** * Optionally provide an `onClick` handler that is called whenever the * `<input>` is clicked */ onClick: PropTypes.func, /** * Specify the placeholder attribute for the `<input>` */ placeholder: PropTypes.string, /** * Specify the value of the `<input>` */ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** * Specify whether the control is currently in warning state */ warn: PropTypes.bool, /** * Provide the text that is displayed when the control is in warning state */ warnText: PropTypes.node }; export { FluidTextInput as default };