mirror of
https://github.com/cpvalente/ontime.git
synced 2026-07-26 10:38:55 +00:00
9e04a1dcfa
--------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com> Co-authored-by: Carlos Valente <carlosvalente@pm.me>
29 lines
697 B
TypeScript
29 lines
697 B
TypeScript
import { RefObject, useEffect } from 'react';
|
|
import { Textarea, TextareaProps } from '@chakra-ui/react';
|
|
// @ts-expect-error no types from library
|
|
import autosize from 'autosize/dist/autosize';
|
|
|
|
export const AutoTextArea = (props: TextareaProps & { inputref: RefObject<unknown> }) => {
|
|
const { value, inputref } = props;
|
|
|
|
useEffect(() => {
|
|
const node = inputref.current;
|
|
autosize(inputref.current);
|
|
return () => {
|
|
autosize.destroy(node);
|
|
};
|
|
}, [inputref, value]);
|
|
|
|
return (
|
|
<Textarea
|
|
overflow='hidden'
|
|
w='100%'
|
|
ref={inputref}
|
|
resize='none'
|
|
transition='height none'
|
|
variant='ontime-transparent'
|
|
{...props}
|
|
/>
|
|
);
|
|
};
|