You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import type { CSSProperties } from 'react'
  2. import React from 'react'
  3. import { type VariantProps, cva } from 'class-variance-authority'
  4. import cn from '@/utils/classnames'
  5. const textareaVariants = cva(
  6. '',
  7. {
  8. variants: {
  9. size: {
  10. small: 'py-1 rounded-md system-xs-regular',
  11. regular: 'px-3 rounded-md system-sm-regular',
  12. large: 'px-4 rounded-lg system-md-regular',
  13. },
  14. },
  15. defaultVariants: {
  16. size: 'regular',
  17. },
  18. },
  19. )
  20. export type TextareaProps = {
  21. value: string
  22. disabled?: boolean
  23. destructive?: boolean
  24. styleCss?: CSSProperties
  25. } & React.TextareaHTMLAttributes<HTMLTextAreaElement> & VariantProps<typeof textareaVariants>
  26. const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
  27. ({ className, value, onChange, disabled, size, destructive, styleCss, ...props }, ref) => {
  28. return (
  29. <textarea
  30. ref={ref}
  31. style={styleCss}
  32. className={cn(
  33. 'min-h-20 w-full appearance-none border border-transparent bg-components-input-bg-normal p-2 text-components-input-text-filled caret-primary-600 outline-none placeholder:text-components-input-text-placeholder hover:border-components-input-border-hover hover:bg-components-input-bg-hover focus:border-components-input-border-active focus:bg-components-input-bg-active focus:shadow-xs',
  34. textareaVariants({ size }),
  35. disabled && 'cursor-not-allowed border-transparent bg-components-input-bg-disabled text-components-input-text-filled-disabled hover:border-transparent hover:bg-components-input-bg-disabled',
  36. destructive && 'border-components-input-border-destructive bg-components-input-bg-destructive text-components-input-text-filled hover:border-components-input-border-destructive hover:bg-components-input-bg-destructive focus:border-components-input-border-destructive focus:bg-components-input-bg-destructive',
  37. className,
  38. )}
  39. value={value}
  40. onChange={onChange}
  41. disabled={disabled}
  42. {...props}
  43. >
  44. </textarea>
  45. )
  46. },
  47. )
  48. Textarea.displayName = 'Textarea'
  49. export default Textarea
  50. export { Textarea, textareaVariants }