import React from 'react' import { ForwardedRef, forwardRef } from 'react' import { InputWrapperStyle, InputContentStyle, TextareaStyle, InputMessageStyle, } from './InputStyles' import { TextareaLabelStyle } from './LabelStyles' import { TextareaProps } from './types' function Textarea(props: TextareaProps, ref?: ForwardedRef) { const { label, error, warning, success, active = false, fullwidth = false, placeholder = ' ', className, style, variant = 'default', color = 'default', wrapperRef, children, ...rest } = props const { id, disabled = false } = props const wrapperProps = { className, style } const hasLabel = !!label && variant === 'default' const hasError = !!error const hasErrorMessage = hasError && typeof error !== 'boolean' const hasWarning = !hasError && !!warning // `error` overrides `warning` const hasWarningMessage = hasWarning && typeof warning !== 'boolean' const hasSuccess = !!success && !error const hasSuccessMessage = hasSuccess && typeof success !== 'boolean' return ( {hasLabel && ( {label} )} {hasErrorMessage && ( {error} )} {hasWarningMessage && ( {warning} )} {hasSuccessMessage && ( {success} )} ) } export default forwardRef(Textarea)