mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-01 02:17:20 +00:00
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
import React, { useEffect } from 'react';
|
|
import { BaseInput } from './BaseComponents/BaseInput';
|
|
import { useInput } from './BaseComponents/hooks/useInput';
|
|
import { useDynamicHeight } from '@/_hooks/useDynamicHeight';
|
|
|
|
export const TextArea = (props) => {
|
|
const inputLogic = useInput(props);
|
|
const { properties, height, width, id, adjustComponentPositions, currentLayout } = props;
|
|
const { inputRef, value } = inputLogic;
|
|
|
|
const resizeTextArea = () => {
|
|
if (!inputRef.current || !properties.dynamicHeight) {
|
|
inputRef.current.style.height = `${height}px`;
|
|
return;
|
|
}
|
|
inputRef.current.style.height = 'auto';
|
|
inputRef.current.style.height = `${inputRef.current.scrollHeight + 20}px`;
|
|
};
|
|
|
|
useEffect(() => {
|
|
resizeTextArea();
|
|
}, [width, height, properties.dynamicHeight,properties.placeholder, value]);
|
|
|
|
useDynamicHeight({
|
|
dynamicHeight: properties.dynamicHeight,
|
|
id,
|
|
height,
|
|
value: JSON.stringify({ value, placeholder: properties.placeholder }),
|
|
adjustComponentPositions,
|
|
currentLayout,
|
|
width,
|
|
visibility: properties.visibility,
|
|
});
|
|
|
|
return <BaseInput {...props} {...inputLogic} inputType="textarea" />;
|
|
};
|