import { chakra, FormControl, FormErrorMessage, FormLabel, InputGroup, InputLeftAddon, InputRightAddon, InputRightElement, Textarea as ChakraTextarea, TextareaProps as ChakraTextareaProps, } from '@chakra-ui/react'; import { XMarkIcon } from '@heroicons/react/24/outline'; import classNames from 'classnames'; import React, { PropsWithChildren, ReactNode } from 'react'; const ClearIcon = chakra(XMarkIcon, { baseStyle: { w: 4, h: 4, }, }); export type TextareaProps = PropsWithChildren< { value?: string; className?: string; endAdornment?: ReactNode; startAdornment?: ReactNode; type?: string; placeholder?: string; onChange?: (e: any) => void; onBlur?: (e: any) => void; onClick?: (e: any) => void; name?: string; error?: string; disabled?: boolean; step?: number; label?: string; clearable?: boolean; } & ChakraTextareaProps >; export const Textarea = React.forwardRef( ( { disabled, step, label, className, startAdornment, endAdornment, placeholder, onChange, onBlur, name, value, onClick, error, clearable = false, ...props }, ref ) => { const clear = () => { if (onChange) onChange({ target: { value: '', name, }, }); }; const { size = 'md' } = props; return ( {label && {label}} {startAdornment && {startAdornment}} {/* @ts-ignore */} {endAdornment && ( {endAdornment} )} {clearable && value && value.length && ( )} {!!error && {error}} ); } );