2021-03-11 11:50:58 +00:00
|
|
|
import React from "react";
|
2021-02-03 15:03:27 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
import TextareaAutosize from "react-autosize-textarea";
|
|
|
|
|
|
|
|
import Scrollbar from "../scrollbar/index";
|
|
|
|
import commonInputStyle from "../text-input/common-input-styles";
|
2021-02-25 21:19:45 +00:00
|
|
|
import Base from "../themes/base";
|
2021-02-03 15:03:27 +00:00
|
|
|
|
|
|
|
const ClearScrollbar = ({ isDisabled, heightScale, hasError, ...props }) => (
|
|
|
|
<Scrollbar {...props} />
|
|
|
|
);
|
|
|
|
const StyledScrollbar = styled(ClearScrollbar)`
|
|
|
|
${commonInputStyle};
|
|
|
|
|
|
|
|
:focus-within {
|
|
|
|
border-color: ${(props) =>
|
|
|
|
props.hasError
|
|
|
|
? props.theme.textArea.focusErrorBorderColor
|
|
|
|
: props.theme.textArea.focusBorderColor};
|
|
|
|
}
|
|
|
|
|
|
|
|
:focus {
|
|
|
|
outline: ${(props) => props.theme.textArea.focusOutline};
|
|
|
|
}
|
|
|
|
|
|
|
|
width: ${(props) => props.theme.textArea.scrollWidth} !important;
|
|
|
|
height: ${(props) =>
|
|
|
|
props.heightScale
|
|
|
|
? "67vh"
|
|
|
|
: props.heighttextarea
|
|
|
|
? props.heighttextarea + 2 + "px"
|
|
|
|
: "91px"} !important;
|
|
|
|
|
|
|
|
background-color: ${(props) =>
|
|
|
|
props.isDisabled && props.theme.textArea.disabledColor};
|
|
|
|
`;
|
|
|
|
|
|
|
|
StyledScrollbar.defaultProps = {
|
|
|
|
theme: Base,
|
|
|
|
};
|
|
|
|
|
|
|
|
// eslint-disable-next-line react/prop-types, no-unused-vars
|
|
|
|
const ClearTextareaAutosize = ({
|
|
|
|
isDisabled,
|
|
|
|
heightScale,
|
|
|
|
hasError,
|
|
|
|
color,
|
|
|
|
...props
|
|
|
|
}) => <TextareaAutosize {...props} />;
|
|
|
|
|
|
|
|
const StyledTextarea = styled(ClearTextareaAutosize)`
|
|
|
|
${commonInputStyle};
|
|
|
|
|
|
|
|
width: ${(props) => props.theme.textArea.width};
|
|
|
|
height: ${(props) => props.theme.textArea.height};
|
|
|
|
border: ${(props) => props.theme.textArea.border};
|
|
|
|
outline: ${(props) => props.theme.textArea.outline};
|
|
|
|
resize: ${(props) => props.theme.textArea.resize};
|
|
|
|
overflow: ${(props) => props.theme.textArea.overflow};
|
|
|
|
padding: ${(props) => props.theme.textArea.padding};
|
|
|
|
font-size: ${(props) => props.fontSize + "px"};
|
|
|
|
font-family: ${(props) => props.theme.fontFamily};
|
|
|
|
line-height: ${(props) => props.theme.textArea.lineHeight};
|
|
|
|
|
|
|
|
:focus-within {
|
|
|
|
border-color: ${(props) => props.theme.textArea.focusBorderColor};
|
|
|
|
}
|
|
|
|
|
|
|
|
:focus {
|
|
|
|
outline: ${(props) => props.theme.textArea.focusOutline};
|
|
|
|
}
|
|
|
|
|
|
|
|
::-webkit-input-placeholder {
|
|
|
|
color: ${(props) => props.theme.textInput.placeholderColor};
|
|
|
|
font-family: ${(props) => props.theme.fontFamily};
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
:-moz-placeholder {
|
|
|
|
color: ${(props) => props.theme.textInput.placeholderColor};
|
|
|
|
font-family: ${(props) => props.theme.fontFamily};
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
::-moz-placeholder {
|
|
|
|
color: ${(props) => props.theme.textInput.placeholderColor};
|
|
|
|
font-family: ${(props) => props.theme.fontFamily};
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
:-ms-input-placeholder {
|
|
|
|
color: ${(props) => props.theme.textInput.placeholderColor};
|
|
|
|
font-family: ${(props) => props.theme.fontFamily};
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
::placeholder {
|
|
|
|
color: ${(props) => props.theme.textInput.placeholderColor};
|
|
|
|
font-family: ${(props) => props.theme.fontFamily};
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
StyledTextarea.defaultProps = {
|
|
|
|
theme: Base,
|
|
|
|
};
|
|
|
|
|
|
|
|
export { StyledTextarea, StyledScrollbar };
|