UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

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