mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 18:33:53 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
27 lines
778 B
TypeScript
27 lines
778 B
TypeScript
// @ts-expect-error no types from library
|
|
import autosize from 'autosize/dist/autosize';
|
|
import { RefObject, useEffect } from 'react';
|
|
|
|
import Textarea, { type TextareaProps } from '../textarea/Textarea';
|
|
|
|
interface AutoTextAreaProps extends TextareaProps {
|
|
inputref: RefObject<HTMLTextAreaElement | null>;
|
|
}
|
|
|
|
/**
|
|
* A textarea that automatically resizes based on its content
|
|
*/
|
|
export function AutoTextarea({ value, inputref, ...textAreaProps }: AutoTextAreaProps) {
|
|
// when the value changes, we use the ref to reapply autosize
|
|
useEffect(() => {
|
|
const node = inputref.current;
|
|
autosize(inputref.current);
|
|
|
|
return () => {
|
|
autosize.destroy(node);
|
|
};
|
|
}, [inputref, value]);
|
|
|
|
return <Textarea ref={inputref} value={value} {...textAreaProps} />;
|
|
}
|