@carbon/react
Version:
React components for the Carbon Design System
125 lines (121 loc) • 3.73 kB
JavaScript
/**
* 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.
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import TextArea from '../TextArea/TextArea.js';
import '../TextArea/TextArea.Skeleton.js';
import { deprecate } from '../../prop-types/deprecate.js';
import { usePrefix } from '../../internal/usePrefix.js';
import { FormContext } from '../FluidForm/FormContext.js';
const FluidTextArea = ({
className,
...other
}) => {
const prefix = usePrefix();
const classNames = cx(`${prefix}--text-area--fluid`, className);
return /*#__PURE__*/React.createElement(FormContext.Provider, {
value: {
isFluid: true
}
}, /*#__PURE__*/React.createElement(TextArea, _extends({
className: classNames
}, other)));
};
FluidTextArea.propTypes = {
/**
* Provide a custom className that is applied directly to the underlying
* `<textarea>` node
*/
className: PropTypes.string,
/**
* Specify the `cols` attribute for the underlying `<textarea>` node
*/
cols: PropTypes.number,
/**
* Optionally provide the default value of the `<textarea>`
*/
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* Specify whether the control is disabled
*/
disabled: PropTypes.bool,
/**
* Specify whether to display the character counter
*/
enableCounter: PropTypes.bool,
/**
* Provide text that is used alongside the control label for additional help
*/
helperText: PropTypes.node,
/**
* Specify whether you want the underlying label to be visually hidden
*/
hideLabel: PropTypes.bool,
/**
* Provide a unique identifier for the control
*/
id: PropTypes.string,
/**
* 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,
/**
* Provide the text that will be read by a screen reader when visiting this
* control
*/
labelText: PropTypes.node.isRequired,
/**
* `true` to use the light version. For use on $ui-01 backgrounds only.
* Don't use this to make tile background color same as container background color.
*/
light: deprecate(PropTypes.bool, 'The `light` prop for `FluidTextArea` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
/**
* Max character count allowed for the textarea. This is needed in order for enableCounter to display
*/
maxCount: PropTypes.number,
/**
* Optionally provide an `onChange` handler that is called whenever `<textarea>`
* is updated
*/
onChange: PropTypes.func,
/**
* Optionally provide an `onClick` handler that is called whenever the
* `<textarea>` is clicked
*/
onClick: PropTypes.func,
/**
* Specify the placeholder attribute for the `<textarea>`
*/
placeholder: PropTypes.string,
/**
* Specify the rows attribute for the `<textarea>`
*/
rows: PropTypes.number,
/**
* Provide the current value of the `<textarea>`
*/
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
};
export { FluidTextArea as default };