2020-10-16 13:16:01 +00:00
|
|
|
import React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
2021-02-03 15:03:27 +00:00
|
|
|
import { StyledTextarea, StyledScrollbar } from "./styled-textarea";
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-12-03 13:42:55 +00:00
|
|
|
// eslint-disable-next-line react/prop-types, no-unused-vars
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
class Textarea extends React.PureComponent {
|
2019-07-29 16:42:44 +00:00
|
|
|
render() {
|
2019-12-03 10:08:50 +00:00
|
|
|
// 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,
|
2020-10-16 13:16:01 +00:00
|
|
|
value,
|
2020-10-28 10:20:21 +00:00
|
|
|
fontSize,
|
2020-10-28 10:59:20 +00:00
|
|
|
heightTextArea,
|
2020-12-07 07:40:18 +00:00
|
|
|
color,
|
2019-12-17 10:49:53 +00:00
|
|
|
} = this.props;
|
2021-03-11 11:50:58 +00:00
|
|
|
|
2019-07-29 16:42:44 +00:00
|
|
|
return (
|
|
|
|
<StyledScrollbar
|
2019-12-17 10:49:53 +00:00
|
|
|
className={className}
|
|
|
|
style={style}
|
2020-10-16 13:16:01 +00:00
|
|
|
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}
|
2020-10-28 10:59:20 +00:00
|
|
|
heighttextarea={heightTextArea}
|
2019-07-29 16:42:44 +00:00
|
|
|
>
|
2019-07-31 12:44:48 +00:00
|
|
|
<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}
|
2020-10-28 10:20:21 +00:00
|
|
|
fontSize={fontSize}
|
2020-12-07 07:40:18 +00:00
|
|
|
color={color}
|
2019-08-06 13:36:41 +00:00
|
|
|
/>
|
2019-07-29 16:42:44 +00:00
|
|
|
</StyledScrollbar>
|
2020-10-16 13:16:01 +00:00
|
|
|
);
|
2019-07-29 16:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
Textarea.propTypes = {
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Class name */
|
2019-12-17 10:49:53 +00:00
|
|
|
className: PropTypes.string,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Used as HTML `id` property */
|
2019-07-31 12:44:48 +00:00
|
|
|
id: PropTypes.string,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Indicates that the field cannot be used */
|
2019-07-31 12:44:48 +00:00
|
|
|
isDisabled: PropTypes.bool,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Indicates that the field is displaying read-only content */
|
2019-07-31 12:44:48 +00:00
|
|
|
isReadOnly: PropTypes.bool,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Indicates the input field has an error */
|
2020-07-08 13:57:34 +00:00
|
|
|
hasError: PropTypes.bool,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Indicates the input field has scale */
|
2020-07-13 11:15:44 +00:00
|
|
|
heightScale: PropTypes.bool,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Max Length of value */
|
2019-07-31 12:44:48 +00:00
|
|
|
maxLength: PropTypes.number,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Used as HTML `name` property */
|
2019-07-31 12:44:48 +00:00
|
|
|
name: PropTypes.string,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Allow you to handle changing events of component */
|
2019-07-29 16:42:44 +00:00
|
|
|
onChange: PropTypes.func,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Placeholder for Textarea */
|
2019-07-31 12:44:48 +00:00
|
|
|
placeholder: PropTypes.string,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Accepts css style */
|
2019-12-17 10:49:53 +00:00
|
|
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Used as HTML `tabindex` property */
|
2019-07-31 12:44:48 +00:00
|
|
|
tabIndex: PropTypes.number,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Value for Textarea */
|
2019-09-13 11:11:45 +00:00
|
|
|
value: PropTypes.string,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Value for font-size */
|
2020-10-28 10:20:21 +00:00
|
|
|
fontSize: PropTypes.number,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Value for height text-area */
|
2020-10-28 10:59:20 +00:00
|
|
|
heightTextArea: PropTypes.number,
|
2021-03-11 11:50:58 +00:00
|
|
|
/** Specifies the text color */
|
2020-12-07 07:40:18 +00:00
|
|
|
color: PropTypes.string,
|
2020-10-16 13:16:01 +00:00
|
|
|
};
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
Textarea.defaultProps = {
|
2020-10-16 13:16:01 +00:00
|
|
|
className: "",
|
2019-07-31 12:44:48 +00:00
|
|
|
isDisabled: false,
|
|
|
|
isReadOnly: false,
|
2020-07-08 13:57:34 +00:00
|
|
|
hasError: false,
|
2020-07-13 11:15:44 +00:00
|
|
|
heightScale: false,
|
2020-10-16 13:16:01 +00:00
|
|
|
placeholder: "",
|
2019-07-31 12:44:48 +00:00
|
|
|
tabIndex: -1,
|
2020-10-16 13:16:01 +00:00
|
|
|
value: "",
|
2020-10-28 10:59:20 +00:00
|
|
|
fontSize: 13,
|
2020-12-07 07:40:18 +00:00
|
|
|
color: "#333333",
|
2020-10-16 13:16:01 +00:00
|
|
|
};
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
export default Textarea;
|