2019-07-30 07:39:54 +00:00
|
|
|
import React from 'react';
|
|
|
|
import styled from 'styled-components';
|
2019-07-29 16:42:44 +00:00
|
|
|
import Scrollbar from '../scrollbar/index';
|
2019-07-30 07:39:54 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import commonInputStyle from '../text-input/common-input-styles';
|
2019-07-31 12:44:48 +00:00
|
|
|
import TextareaAutosize from 'react-autosize-textarea';
|
2019-07-29 16:42:44 +00:00
|
|
|
|
|
|
|
const StyledScrollbar = styled(Scrollbar)`
|
2019-07-30 07:39:54 +00:00
|
|
|
${commonInputStyle};
|
|
|
|
:focus-within {
|
|
|
|
border-color: #2DA7DB;
|
|
|
|
}
|
|
|
|
:focus{
|
|
|
|
outline: none;
|
|
|
|
}
|
2019-07-29 16:42:44 +00:00
|
|
|
width: 100% !important;
|
|
|
|
height: 91px !important;
|
2019-07-31 12:44:48 +00:00
|
|
|
background-color: ${props => props.isDisabled && '#F8F9F9'};
|
2019-07-29 16:42:44 +00:00
|
|
|
|
|
|
|
@media only screen and (max-width: 768px) {
|
|
|
|
height: 190px !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
2019-07-31 12:44:48 +00:00
|
|
|
const StyledTextarea = styled(TextareaAutosize)`
|
|
|
|
${commonInputStyle};
|
|
|
|
width: 100%;
|
|
|
|
height: 96%;
|
|
|
|
border: none;
|
|
|
|
outline: none;
|
|
|
|
resize: none;
|
|
|
|
overflow: hidden;
|
|
|
|
padding: 5px 8px 2px 8px;
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-07-31 12:44:48 +00:00
|
|
|
:focus-within {
|
|
|
|
border-color: #2DA7DB;
|
|
|
|
}
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-07-31 12:44:48 +00:00
|
|
|
:focus {
|
|
|
|
outline: none;
|
|
|
|
}
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-07-31 12:44:48 +00:00
|
|
|
`;
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-07-31 12:44:48 +00:00
|
|
|
class TextArea extends React.PureComponent {
|
2019-07-29 16:42:44 +00:00
|
|
|
|
2019-07-31 12:44:48 +00:00
|
|
|
onChange = (e) => this.props.onChange && this.props.onChange(e);
|
2019-07-29 16:42:44 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
// console.log('TextArea render');
|
|
|
|
return (
|
|
|
|
<StyledScrollbar
|
|
|
|
stype='preMediumBlack'
|
2019-07-31 12:44:48 +00:00
|
|
|
isDisabled={this.props.isDisabled}
|
2019-07-29 16:42:44 +00:00
|
|
|
>
|
2019-07-31 12:44:48 +00:00
|
|
|
<StyledTextarea
|
|
|
|
id={this.props.id}
|
|
|
|
placeholder={this.props.placeholder}
|
|
|
|
onChange={this.onChange}
|
|
|
|
maxLength={this.props.maxLength}
|
|
|
|
name={this.props.name}
|
|
|
|
tabIndex={this.props.tabIndex}
|
|
|
|
isDisabled={this.props.isDisabled}
|
|
|
|
disabled={this.props.isDisabled}
|
|
|
|
readOnly={this.props.isReadOnly}
|
2019-07-29 16:42:44 +00:00
|
|
|
>
|
2019-07-31 12:44:48 +00:00
|
|
|
{this.props.value}
|
|
|
|
</StyledTextarea>
|
2019-07-29 16:42:44 +00:00
|
|
|
</StyledScrollbar>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextArea.propTypes = {
|
2019-07-31 12:44:48 +00:00
|
|
|
id: PropTypes.string,
|
|
|
|
isDisabled: PropTypes.bool,
|
|
|
|
isReadOnly: PropTypes.bool,
|
|
|
|
maxLength: PropTypes.number,
|
|
|
|
name: PropTypes.string,
|
2019-07-29 16:42:44 +00:00
|
|
|
onChange: PropTypes.func,
|
2019-07-31 12:44:48 +00:00
|
|
|
placeholder: PropTypes.string,
|
|
|
|
tabIndex: PropTypes.number,
|
|
|
|
value: PropTypes.string
|
2019-07-29 16:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextArea.defaultProps = {
|
2019-07-31 12:44:48 +00:00
|
|
|
isDisabled: false,
|
|
|
|
isReadOnly: false,
|
2019-07-29 16:42:44 +00:00
|
|
|
placeholder: '',
|
2019-07-31 12:44:48 +00:00
|
|
|
value: '',
|
|
|
|
tabIndex: -1,
|
2019-07-29 16:42:44 +00:00
|
|
|
}
|
|
|
|
|
2019-07-31 12:44:48 +00:00
|
|
|
export default TextArea;
|