DocSpace-client/packages/asc-web-components/textarea/index.js

107 lines
2.6 KiB
JavaScript
Raw Normal View History

import React from "react";
import PropTypes from "prop-types";
import { StyledTextarea, StyledScrollbar } from "./styled-textarea";
// eslint-disable-next-line react/prop-types, no-unused-vars
class Textarea extends React.PureComponent {
render() {
// console.log('Textarea render');
2019-12-17 10:49:53 +00:00
const {
className,
id,
isDisabled,
isReadOnly,
2020-07-08 13:57:34 +00:00
hasError,
2020-07-13 11:15:44 +00:00
heightScale,
2019-12-17 10:49:53 +00:00
maxLength,
name,
onChange,
placeholder,
style,
tabIndex,
value,
fontSize,
heightTextArea,
color,
2019-12-17 10:49:53 +00:00
} = this.props;
return (
<StyledScrollbar
2019-12-17 10:49:53 +00:00
className={className}
style={style}
stype="preMediumBlack"
2019-12-17 10:49:53 +00:00
isDisabled={isDisabled}
2020-07-08 13:57:34 +00:00
hasError={hasError}
2020-07-13 11:15:44 +00:00
heightScale={heightScale}
heighttextarea={heightTextArea}
>
<StyledTextarea
2019-12-17 10:49:53 +00:00
id={id}
placeholder={placeholder}
onChange={(e) => onChange && onChange(e)}
maxLength={maxLength}
name={name}
tabIndex={tabIndex}
isDisabled={isDisabled}
disabled={isDisabled}
readOnly={isReadOnly}
value={value}
fontSize={fontSize}
color={color}
/>
</StyledScrollbar>
);
}
}
Textarea.propTypes = {
/** Class name */
2019-12-17 10:49:53 +00:00
className: PropTypes.string,
/** Used as HTML `id` property */
id: PropTypes.string,
/** Indicates that the field cannot be used */
isDisabled: PropTypes.bool,
/** Indicates that the field is displaying read-only content */
isReadOnly: PropTypes.bool,
/** Indicates the input field has an error */
2020-07-08 13:57:34 +00:00
hasError: PropTypes.bool,
/** Indicates the input field has scale */
2020-07-13 11:15:44 +00:00
heightScale: PropTypes.bool,
/** Max Length of value */
maxLength: PropTypes.number,
/** Used as HTML `name` property */
name: PropTypes.string,
/** Allow you to handle changing events of component */
onChange: PropTypes.func,
/** Placeholder for Textarea */
placeholder: PropTypes.string,
/** Accepts css style */
2019-12-17 10:49:53 +00:00
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
/** Used as HTML `tabindex` property */
tabIndex: PropTypes.number,
/** Value for Textarea */
value: PropTypes.string,
/** Value for font-size */
fontSize: PropTypes.number,
/** Value for height text-area */
heightTextArea: PropTypes.number,
/** Specifies the text color */
color: PropTypes.string,
};
Textarea.defaultProps = {
className: "",
isDisabled: false,
isReadOnly: false,
2020-07-08 13:57:34 +00:00
hasError: false,
2020-07-13 11:15:44 +00:00
heightScale: false,
placeholder: "",
tabIndex: -1,
value: "",
fontSize: 13,
color: "#333333",
};
export default Textarea;