isLimitedWidth prop was deleted / showCopyIcon was renamed to enableCopy

This commit is contained in:
Vladimir Khvan 2023-04-03 16:29:57 +05:00
parent 5063cfaccb
commit 9afc84e087
3 changed files with 11 additions and 18 deletions

View File

@ -38,10 +38,9 @@ const Textarea = ({
areaSelect,
isJSONField,
copyInfoText,
showCopyIcon,
enableCopy,
hasNumeration,
isFullHeight,
isLimitedWidth,
isFullHeight
}) => {
const areaRef = useRef(null);
const [isError, setIsError] = useState(hasError);
@ -92,10 +91,9 @@ const Textarea = ({
return (
<Wrapper
isJSONField={isJSONField}
onFocus={isJSONField ? onTextareaClick : undefined}
isLimitedWidth={isLimitedWidth}
onFocus={enableCopy ? onTextareaClick : undefined}
>
{showCopyIcon && (
{enableCopy && (
<StyledCopyIcon
onClick={() => {
copy(modifiedValue);
@ -127,7 +125,7 @@ const Textarea = ({
id={id}
paddingLeftProp={paddingLeftProp}
isJSONField={isJSONField}
showCopyIcon={showCopyIcon}
enableCopy={enableCopy}
placeholder={placeholder}
onChange={(e) => onChange && onChange(e)}
maxLength={maxLength}
@ -189,13 +187,11 @@ Textarea.propTypes = {
/** Indicates the text of toast/informational alarm */
copyInfoText: PropTypes.string,
/** Shows copy icon */
showCopyIcon: PropTypes.bool,
enableCopy: PropTypes.bool,
/** Inserts numeration */
hasNumeration: PropTypes.bool,
/** Calculating height of content depending on number of lines */
isFullHeight: PropTypes.bool,
/** Limits max width to 1200px */
isLimitedWidth: PropTypes.bool,
};
Textarea.defaultProps = {
@ -212,10 +208,9 @@ Textarea.defaultProps = {
areaSelect: false,
isJSONField: false,
copyInfoText: "Content was copied successfully!",
showCopyIcon: false,
enableCopy: false,
hasNumeration: false,
isFullHeight: false,
isLimitedWidth: false,
};
export default Textarea;

View File

@ -71,7 +71,7 @@ const StyledTextarea = styled(ClearTextareaAutosize).attrs(
outline: none;
resize: none;
overflow: ${(props) => (props.isJSONField ? "visible !important" : "hidden")};
padding: ${(props) => (props.showCopyIcon ? "5px 28px 2px" : "5px 8px 2px")};
padding: ${(props) => (props.enableCopy ? "5px 28px 2px" : "5px 8px 2px")};
padding-left: ${(props) => props.paddingLeftProp};
font-size: ${(props) => props.fontSize + "px"};
font-family: ${(props) => props.theme.fontFamily};
@ -143,7 +143,7 @@ const Wrapper = styled.div`
position: relative;
min-width: ${(props) => (props.isJSONField ? "600px" : "none")};
max-width: ${(props) => (props.isLimitedWidth ? "1200px" : "none")};
max-width: 1200px;
`;
const Numeration = styled.pre`

View File

@ -46,10 +46,9 @@ Default.args = {
value:
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae",
isJSONField: false,
showCopyIcon: false,
enableCopy: false,
hasNumeration: false,
isFullHeight: false,
isLimitedWidth: false,
};
export const JsonViewer = Template.bind({});
@ -67,8 +66,7 @@ JsonViewer.args = {
value:
'{"menu": {"id": "file","value": "File","popup": {"menuitem": [{"value": "New", "onclick": "CreateNewDoc()"},{"value": "Open", "onclick": "OpenDoc()"},{"value": "Close", "onclick": "CloseDoc()"}]}}}',
isJSONField: true,
showCopyIcon: true,
enableCopy: true,
hasNumeration: true,
isFullHeight: true,
isLimitedWidth: true,
};