mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
* removed daisy from config * removed tw-elements artefact * removed comments from tailwind config * removed safelist * migrated to tailwind4 and daisyui5 * deleted tailwind.config.js which is not eeded anymore * 3.0.79 * version number * fixed broken layouts * more fixing * more layout fixing * tested theming * small fixes * adapt snapshots to changes * package.json: add unit test update script * more ui refactoring & theme controller * ui improvements * package-lock.json * fix linting * fixed tabs * fix linting * fixed typing --------- Co-authored-by: mahula <lenzmath@posteo.de>
65 lines
1.5 KiB
TypeScript
65 lines
1.5 KiB
TypeScript
import { useEffect, useRef, useState } from 'react'
|
|
|
|
interface TextAreaProps {
|
|
labelTitle?: string
|
|
labelStyle?: string
|
|
containerStyle?: string
|
|
dataField?: string
|
|
inputStyle?: string
|
|
defaultValue: string
|
|
placeholder?: string
|
|
required?: boolean
|
|
updateFormValue?: (value: string) => void
|
|
}
|
|
|
|
/**
|
|
* @category Input
|
|
*/
|
|
export function TextAreaInput({
|
|
labelTitle,
|
|
dataField,
|
|
labelStyle,
|
|
containerStyle,
|
|
inputStyle,
|
|
defaultValue,
|
|
placeholder,
|
|
required = true,
|
|
updateFormValue,
|
|
}: TextAreaProps) {
|
|
const ref = useRef<HTMLTextAreaElement>(null)
|
|
const [inputValue, setInputValue] = useState<string>(defaultValue)
|
|
|
|
useEffect(() => {
|
|
setInputValue(defaultValue)
|
|
}, [defaultValue])
|
|
|
|
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
const newValue = e.target.value
|
|
setInputValue(newValue)
|
|
if (updateFormValue) {
|
|
updateFormValue(newValue)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className={`tw:form-control tw:w-full ${containerStyle ?? ''}`}>
|
|
{labelTitle ? (
|
|
<label className='tw:label'>
|
|
<span className={`tw:label-text tw:text-base-content ${labelStyle ?? ''}`}>
|
|
{labelTitle}
|
|
</span>
|
|
</label>
|
|
) : null}
|
|
<textarea
|
|
required={required}
|
|
ref={ref}
|
|
value={inputValue}
|
|
name={dataField}
|
|
className={`tw:textarea tw:textarea-bordered tw:w-full tw:leading-5 ${inputStyle ?? ''}`}
|
|
placeholder={placeholder ?? ''}
|
|
onChange={handleChange}
|
|
></textarea>
|
|
</div>
|
|
)
|
|
}
|