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
|
|
|
|
2019-12-03 13:42:55 +00:00
|
|
|
// eslint-disable-next-line react/prop-types, no-unused-vars
|
2019-09-13 11:11:45 +00:00
|
|
|
const ClearScrollbar = ({ isDisabled, ...props }) => <Scrollbar {...props} />
|
2019-08-16 10:32:07 +00:00
|
|
|
const StyledScrollbar = styled(ClearScrollbar)`
|
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
|
|
|
|
|
|
|
`;
|
2019-12-03 13:42:55 +00:00
|
|
|
|
|
|
|
// eslint-disable-next-line react/prop-types, no-unused-vars
|
2019-09-13 11:11:45 +00:00
|
|
|
const ClearTextareaAutosize = ({ isDisabled, ...props }) => <TextareaAutosize {...props} />
|
2019-08-16 10:32:07 +00:00
|
|
|
const StyledTextarea = styled(ClearTextareaAutosize)`
|
2019-07-31 12:44:48 +00:00
|
|
|
${commonInputStyle};
|
|
|
|
width: 100%;
|
2019-11-21 14:41:36 +00:00
|
|
|
height: 90%;
|
2019-07-31 12:44:48 +00:00
|
|
|
border: none;
|
|
|
|
outline: none;
|
|
|
|
resize: none;
|
|
|
|
overflow: hidden;
|
|
|
|
padding: 5px 8px 2px 8px;
|
2019-08-21 08:20:37 +00:00
|
|
|
font-size: 13px;
|
|
|
|
font-family: 'Open Sans', sans-serif;
|
2019-12-05 11:18:09 +00:00
|
|
|
line-height: 1.5;
|
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-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-07-29 16:42:44 +00:00
|
|
|
return (
|
|
|
|
<StyledScrollbar
|
2019-09-13 11:11:45 +00:00
|
|
|
className={this.props.className}
|
2019-12-03 13:42:55 +00:00
|
|
|
style={this.props.style}
|
2019-07-29 16:42:44 +00:00
|
|
|
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}
|
2019-08-16 13:24:18 +00:00
|
|
|
onChange={(e) => this.props.onChange && this.props.onChange(e)}
|
2019-07-31 12:44:48 +00:00
|
|
|
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-09-13 12:48:55 +00:00
|
|
|
value={this.props.value}
|
2019-08-06 13:36:41 +00:00
|
|
|
/>
|
2019-07-29 16:42:44 +00:00
|
|
|
</StyledScrollbar>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
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,
|
2019-09-13 11:11:45 +00:00
|
|
|
value: PropTypes.string,
|
2019-12-03 13:42:55 +00:00
|
|
|
className: PropTypes.string,
|
|
|
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
|
2019-07-29 16:42:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 13:36:41 +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-09-13 11:11:45 +00:00
|
|
|
className: ''
|
2019-07-29 16:42:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
export default Textarea;
|