@luxfi/ui 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/textarea.tsx CHANGED
@@ -1,41 +1,32 @@
1
- import { cva } from 'class-variance-authority';
2
1
  import React from 'react';
3
2
 
4
3
  import { cn } from './utils';
5
4
 
6
- const textareaVariants = cva(
7
- [
8
- 'w-full appearance-none outline-none transition-colors resize-y',
9
- 'bg-[var(--color-input-bg)] text-[var(--color-input-fg)] border-[var(--color-input-border)]',
10
- 'placeholder:text-[var(--color-input-placeholder,theme(colors.gray.400))]',
11
- 'hover:border-[var(--color-input-border-hover,theme(colors.gray.400))]',
12
- 'focus:border-[var(--color-input-border-focus,theme(colors.blue.500))]',
13
- 'focus:placeholder:text-[var(--color-input-placeholder-focus,theme(colors.gray.300))]',
14
- 'disabled:opacity-40 disabled:cursor-not-allowed',
15
- 'read-only:opacity-70',
16
- 'data-[invalid]:border-[var(--color-input-border-invalid,theme(colors.red.500))]',
17
- ].join(' '),
18
- {
19
- variants: {
20
- size: {
21
- xs: 'px-2 py-1 text-xs rounded',
22
- sm: 'px-3 py-2 text-sm rounded-md',
23
- md: 'px-4 py-2 text-base rounded-md',
24
- lg: 'px-4 py-3 text-lg rounded-lg',
25
- '2xl': 'px-4 py-3 text-xl rounded-lg',
26
- },
27
- variant: {
28
- outline: 'border border-solid',
29
- filled: 'border-0 bg-[var(--color-input-filled-bg,theme(colors.gray.100))]',
30
- unstyled: 'border-0 bg-transparent p-0',
31
- },
32
- },
33
- defaultVariants: {
34
- size: 'md',
35
- variant: 'outline',
36
- },
37
- },
38
- );
5
+ const TEXTAREA_BASE = [
6
+ 'w-full appearance-none outline-none transition-colors resize-y',
7
+ 'bg-[var(--color-input-bg)] text-[var(--color-input-fg)] border-[var(--color-input-border)]',
8
+ 'placeholder:text-[var(--color-input-placeholder,theme(colors.gray.400))]',
9
+ 'hover:border-[var(--color-input-border-hover,theme(colors.gray.400))]',
10
+ 'focus:border-[var(--color-input-border-focus,theme(colors.blue.500))]',
11
+ 'focus:placeholder:text-[var(--color-input-placeholder-focus,theme(colors.gray.300))]',
12
+ 'disabled:opacity-40 disabled:cursor-not-allowed',
13
+ 'read-only:opacity-70',
14
+ 'data-[invalid]:border-[var(--color-input-border-invalid,theme(colors.red.500))]',
15
+ ].join(' ');
16
+
17
+ const TEXTAREA_SIZE_CLASSES: Record<string, string> = {
18
+ xs: 'px-2 py-1 text-xs rounded',
19
+ sm: 'px-3 py-2 text-sm rounded-md',
20
+ md: 'px-4 py-2 text-base rounded-md',
21
+ lg: 'px-4 py-3 text-lg rounded-lg',
22
+ '2xl': 'px-4 py-3 text-xl rounded-lg',
23
+ };
24
+
25
+ const TEXTAREA_VARIANT_CLASSES: Record<string, string> = {
26
+ outline: 'border border-solid',
27
+ filled: 'border-0 bg-[var(--color-input-filled-bg,theme(colors.gray.100))]',
28
+ unstyled: 'border-0 bg-transparent p-0',
29
+ };
39
30
 
40
31
  type TextareaSize = 'xs' | 'sm' | 'md' | 'lg' | '2xl';
41
32
  type TextareaVariant = 'outline' | 'filled' | 'unstyled';
@@ -46,11 +37,11 @@ export interface TextareaProps extends Omit<React.ComponentPropsWithRef<'textare
46
37
  }
47
38
 
48
39
  export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
49
- ({ size, variant, className, ...rest }, ref) => {
40
+ ({ size = 'md', variant = 'outline', className, ...rest }, ref) => {
50
41
  return (
51
42
  <textarea
52
43
  ref={ ref }
53
- className={ cn(textareaVariants({ size, variant }), className) }
44
+ className={ cn(TEXTAREA_BASE, TEXTAREA_SIZE_CLASSES[size], TEXTAREA_VARIANT_CLASSES[variant], className) }
54
45
  { ...rest }
55
46
  />
56
47
  );