UNPKG

@carbon/react

Version:

React components for the Carbon Design System

115 lines (109 loc) 3.27 kB
/** * 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. */ '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'); require('../TextInput/ControlledPasswordInput.js'); var PasswordInput = require('../TextInput/PasswordInput.js'); var usePrefix = require('../../internal/usePrefix.js'); var FormContext = require('../FluidForm/FormContext.js'); const FluidPasswordInput = ({ className, ...other }) => { const prefix = usePrefix.usePrefix(); const classNames = cx(className, `${prefix}--text-input--fluid`); return /*#__PURE__*/React.createElement(FormContext.FormContext.Provider, { value: { isFluid: true } }, /*#__PURE__*/React.createElement(PasswordInput.default, _rollupPluginBabelHelpers.extends({ className: classNames }, other))); }; FluidPasswordInput.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, /** * "Hide password" tooltip text on password visibility toggle */ hidePasswordLabel: PropTypes.string, /** * 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, /** * Callback function that is called whenever the toggle password visibility * button is clicked */ onTogglePasswordVisibility: PropTypes.func, /** * Specify the placeholder attribute for the `<input>` */ placeholder: PropTypes.string, /** * "Show password" tooltip text on password visibility toggle */ showPasswordLabel: 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, /** * Whether or not the component is readonly */ readOnly: PropTypes.bool }; exports.default = FluidPasswordInput;