mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
import { Input } from 'ui'
|
|
import React, { useState, useEffect, useRef } from 'react'
|
|
|
|
const AutoTextArea = (props) => {
|
|
const textAreaRef = useRef(null)
|
|
const [text, setText] = useState('')
|
|
const [textAreaHeight, setTextAreaHeight] = useState('auto')
|
|
const [parentHeight, setParentHeight] = useState('auto')
|
|
|
|
// useEffect(() => {
|
|
// setParentHeight(`${textAreaRef?.current.scrollHeight}px`)
|
|
// setTextAreaHeight(`${textAreaRef?.current.scrollHeight}px`)
|
|
// }, [text])
|
|
|
|
// const onChangeHandler = (event) => {
|
|
// setTextAreaHeight('auto')
|
|
// setParentHeight(`${textAreaRef?.current.scrollHeight}px`)
|
|
// setText(event.target.value)
|
|
|
|
// if (props.onChange) {
|
|
// props.onChange(event)
|
|
// }
|
|
// }
|
|
|
|
return (
|
|
<div
|
|
style={{
|
|
minHeight: parentHeight,
|
|
}}
|
|
>
|
|
<Input.TextArea
|
|
{...props}
|
|
label={props.label}
|
|
size="small"
|
|
// ref={textAreaRef}
|
|
rows={1}
|
|
style={{
|
|
height: textAreaHeight,
|
|
overflow: 'hidden',
|
|
resize: 'none',
|
|
}}
|
|
// onChange={onChangeHandler}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default AutoTextArea
|