import { RtFormFieldTextareaInternalProps } from '../rt-form-field-textarea.types'; export function computeMaxMinHeight( props: RtFormFieldTextareaInternalProps, element: HTMLTextAreaElement ) { const { lineHeight, paddingTop, paddingBottom, borderBottom, borderTop } = getComputedStyle(element); const paddingAndBorders = parseFloat(paddingTop) + parseFloat(paddingBottom) + parseFloat(borderTop) + parseFloat(borderBottom); const rowHeight = parseFloat(lineHeight) || 20; const totalMinHeight = rowHeight * (props.minRows || 1) + paddingAndBorders; const totalMaxHeight = props.maxRows ? rowHeight * props.maxRows + paddingAndBorders : undefined; return { totalMinHeight, totalMaxHeight }; }