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-12-17 10:49:53 +00:00
|
|
|
const {
|
|
|
|
className,
|
|
|
|
id,
|
|
|
|
isDisabled,
|
|
|
|
isReadOnly,
|
2020-07-08 13:57:34 +00:00
|
|
|
hasError,
|
2019-12-17 10:49:53 +00:00
|
|
|
maxLength,
|
|
|
|
name,
|
|
|
|
onChange,
|
|
|
|
placeholder,
|
|
|
|
style,
|
|
|
|
tabIndex,
|
|
|
|
value
|
|
|
|
} = this.props;
|
2019-07-29 16:42:44 +00:00
|
|
|
return (
|
|
|
|
<StyledScrollbar
|
2019-12-17 10:49:53 +00:00
|
|
|
className={className}
|
|
|
|
style={style}
|
2019-07-29 16:42:44 +00:00
|
|
|
stype='preMediumBlack'
|
2019-12-17 10:49:53 +00:00
|
|
|
isDisabled={isDisabled}
|
2020-07-08 13:57:34 +00:00
|
|
|
hasError={hasError}
|
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}
|
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-12-17 10:49:53 +00:00
|
|
|
className: PropTypes.string,
|
2019-07-31 12:44:48 +00:00
|
|
|
id: PropTypes.string,
|
|
|
|
isDisabled: PropTypes.bool,
|
|
|
|
isReadOnly: PropTypes.bool,
|
2020-07-08 13:57:34 +00:00
|
|
|
hasError: PropTypes.bool,
|
2019-07-31 12:44:48 +00:00
|
|
|
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,
|
2019-12-17 10:49:53 +00:00
|
|
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
2019-07-31 12:44:48 +00:00
|
|
|
tabIndex: PropTypes.number,
|
2019-09-13 11:11:45 +00:00
|
|
|
value: PropTypes.string,
|
2019-07-29 16:42:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
Textarea.defaultProps = {
|
2019-12-17 10:49:53 +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,
|
2019-07-29 16:42:44 +00:00
|
|
|
placeholder: '',
|
2019-07-31 12:44:48 +00:00
|
|
|
tabIndex: -1,
|
2019-12-17 10:49:53 +00:00
|
|
|
value: '',
|
2019-07-29 16:42:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 13:36:41 +00:00
|
|
|
export default Textarea;
|