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.

пре 2 месеци
пре 2 месеци
пре 2 месеци
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. onFocus?: () => void
  26. onBlur?: () => void
  27. } & React.TextareaHTMLAttributes<HTMLTextAreaElement> & VariantProps<typeof textareaVariants>
  28. const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
  29. ({ className, value, onChange, disabled, size, destructive, styleCss, onFocus, onBlur, ...props }, ref) => {
  30. return (
  31. <textarea
  32. onFocus={onFocus}
  33. onBlur={onBlur}
  34. ref={ref}
  35. style={styleCss}
  36. className={cn(
  37. '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',
  38. textareaVariants({ size }),
  39. 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',
  40. 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',
  41. className,
  42. )}
  43. value={value ?? ''}
  44. onChange={onChange}
  45. disabled={disabled}
  46. {...props}
  47. >
  48. </textarea>
  49. )
  50. },
  51. )
  52. Textarea.displayName = 'Textarea'
  53. export default Textarea
  54. export { Textarea, textareaVariants }