@@ -8,12 +8,12 @@ import type {
8
8
ValidationResult
9
9
} from 'react-aria-components' ;
10
10
import {
11
- composeRenderProps ,
12
11
FieldError as FieldErrorPrimitive ,
13
12
Group ,
14
13
Input as InputPrimitive ,
15
14
Label as LabelPrimitive ,
16
- Text
15
+ Text ,
16
+ composeRenderProps
17
17
} from 'react-aria-components' ;
18
18
import { tv } from 'tailwind-variants' ;
19
19
@@ -31,15 +31,12 @@ interface FieldProps {
31
31
const fieldStyles = tv ( {
32
32
slots : {
33
33
description : 'text-pretty text-muted-fg text-sm/6' ,
34
- label : 'w-fit cursor-default font-medium text-secondary-fg text-sm' ,
35
- fieldError : 'text-danger text-sm/6 forced-colors:text-[Mark]' ,
36
- input : [
37
- 'w-full min-w-0 bg-transparent px-2.5 py-2 text-base text-fg placeholder-muted-fg outline-hidden data-focused:outline-hidden sm:text-sm [&::-ms-reveal]:hidden'
38
- ]
34
+ label : 'w-fit cursor-default font-medium text-secondary-fg text-sm/6' ,
35
+ fieldError : 'text-danger text-sm/6 forced-colors:text-[Mark]'
39
36
}
40
37
} ) ;
41
38
42
- const { description, label, fieldError, input } = fieldStyles ( ) ;
39
+ const { description, label, fieldError } = fieldStyles ( ) ;
43
40
44
41
const Label = ( { className, ...props } : LabelProps ) => {
45
42
return < LabelPrimitive { ...props } className = { label ( { className } ) } /> ;
@@ -71,12 +68,18 @@ const FieldError = ({ className, ref, ...props }: FieldErrorProps) => {
71
68
72
69
const fieldGroupStyles = tv ( {
73
70
base : [
74
- 'group flex h-10 items-center overflow-hidden rounded-lg border border-input transition duration-200 ease-out' ,
75
- 'focus-within:ring-4 group-data-invalid:focus-within:border-danger group-data-invalid:focus-within:ring-danger/20' ,
76
- '[&>[role=progressbar]]:mr-2.5' ,
77
- '**:data-[slot=icon]:size-4 **:data-[slot=icon]:shrink-0' ,
78
- '*:data-[slot=suffix]:mr-2.5 *:data-[slot=suffix]:text-muted-fg' ,
79
- '*:data-[slot=prefix]:ml-2.5 *:data-[slot=prefix]:text-muted-fg'
71
+ 'group flex h-10 items-center overflow-hidden rounded-lg border border-input shadow-xs transition duration-200 ease-out' ,
72
+ 'relative focus-within:ring-4 group-data-invalid:focus-within:border-danger group-data-invalid:focus-within:ring-danger/20' ,
73
+ '[&>[role=progressbar]:first-child]:ml-2.5 [&>[role=progressbar]:last-child]:mr-2.5' ,
74
+ '**:data-[slot=icon]:size-4 **:data-[slot=icon]:shrink-0 **:[button]:shrink-0' ,
75
+ '[&>button:has([data-slot=icon]):first-child]:left-0 [&>button:has([data-slot=icon]):last-child]:right-0 [&>button:has([data-slot=icon])]:absolute' ,
76
+ '*:data-[slot=icon]:pointer-events-none *:data-[slot=icon]:absolute *:data-[slot=icon]:top-[calc(var(--spacing)*2.7)] *:data-[slot=icon]:z-10 *:data-[slot=icon]:size-4 *:data-[slot=icon]:text-muted-fg' ,
77
+ '[&>[data-slot=icon]:first-child]:left-2.5 [&>[data-slot=icon]:last-child]:right-2.5' ,
78
+ '[&:has([data-slot=icon]+input)]:pl-6 [&:has(input+[data-slot=icon])]:pr-6' ,
79
+ '[&:has([data-slot=icon]+[role=group])]:pl-6 [&:has([role=group]+[data-slot=icon])]:pr-6' ,
80
+ 'has-[[data-slot=icon]:last-child]:[&_input]:pr-7' ,
81
+ '*:[button]:h-8 *:[button]:rounded-[calc(var(--radius-sm)-1px)] *:[button]:px-2.5' ,
82
+ '[&>button:first-child]:ml-[calc(var(--spacing)*0.7)] [&>button:last-child]:mr-[calc(var(--spacing)*0.7)]'
80
83
] ,
81
84
variants : {
82
85
isFocusWithin : focusStyles . variants . isFocused ,
@@ -104,8 +107,18 @@ const FieldGroup = ({ className, ...props }: GroupProps) => {
104
107
interface InputProps extends InputPrimitiveProps {
105
108
ref ?: React . RefObject < HTMLInputElement > ;
106
109
}
110
+
107
111
const Input = ( { className, ref, ...props } : InputProps ) => {
108
- return < InputPrimitive ref = { ref } { ...props } className = { composeTailwindRenderProps ( className , input ( ) ) } /> ;
112
+ return (
113
+ < InputPrimitive
114
+ ref = { ref }
115
+ { ...props }
116
+ className = { composeTailwindRenderProps (
117
+ className ,
118
+ 'w-full min-w-0 bg-transparent px-2.5 py-2 text-base text-fg placeholder-muted-fg outline-hidden data-focused:outline-hidden sm:text-sm/6 [&::-ms-reveal]:hidden [&::-webkit-search-cancel-button]:hidden'
119
+ ) }
120
+ />
121
+ ) ;
109
122
} ;
110
123
111
124
export { Description , FieldError , FieldGroup , Input , Label } ;
0 commit comments