@@ -7,14 +7,31 @@ import {
77 css ,
88 DevupThemeTypography ,
99 Input as DevupInput ,
10+ Text ,
1011} from '@devup-ui/react'
1112import { ComponentProps , useState } from 'react'
1213
13- interface InputProps extends ComponentProps < 'input' > {
14+ interface InputProps extends Omit < ComponentProps < 'input' > , 'className '> {
1415 typography ?: keyof DevupThemeTypography
1516 error ?: boolean
1617 errorMessage ?: string
1718 allowClear ?: boolean
19+ classNames ?: {
20+ input ?: string
21+ icon ?: string
22+ errorMessage ?: string
23+ }
24+ colors ?: {
25+ primary ?: string
26+ error ?: string
27+ text ?: string
28+ base ?: string
29+ iconBold ?: string
30+ border ?: string
31+ inputBackground ?: string
32+ primaryFocus ?: string
33+ negative20 ?: string
34+ }
1835 icon ?: React . ReactNode
1936}
2037
@@ -27,6 +44,9 @@ export function Input({
2744 errorMessage,
2845 allowClear = false ,
2946 icon,
47+ colors,
48+ disabled,
49+ classNames,
3050 ...props
3151} : InputProps ) {
3252 const [ value , setValue ] = useState ( defaultValue ?? '' )
@@ -36,7 +56,7 @@ export function Input({
3656 const handleClear = ( ) => {
3757 setValue ( '' )
3858 }
39- const clearButtonVisible = value && ! props . disabled
59+ const clearButtonVisible = value && ! disabled
4060
4161 return (
4262 < Box
@@ -47,9 +67,15 @@ export function Input({
4767 { icon && (
4868 < Center
4969 boxSize = "24px"
50- color = "$base"
70+ className = { classNames ?. icon }
71+ color = {
72+ disabled
73+ ? 'var(--inputDisabledText, light-dark(#D6D7DE, #373737))'
74+ : 'var(--iconBold, light-dark(#8D8C9A, #666577))'
75+ }
5176 left = "12px"
5277 pos = "absolute"
78+ styleOrder = { 1 }
5379 top = "50%"
5480 transform = "translateY(-50%)"
5581 >
@@ -60,38 +86,46 @@ export function Input({
6086 _disabled = { {
6187 selectors : {
6288 '&::placeholder' : {
63- color : '$ inputDisabledText' ,
89+ color : 'var(-- inputDisabledText, light-dark(#D6D7DE, #373737)) ' ,
6490 } ,
6591 } ,
66- bg : '$ inputDisabledBg' ,
67- border : '1px solid $ border' ,
68- color : '$ inputDisabledText' ,
92+ bg : 'var(-- inputDisabledBg, light-dark(#F0F0F3, #414244)) ' ,
93+ border : '1px solid var(-- border, light-dark(#E4E4E4, #434343)) ' ,
94+ color : 'var(-- inputDisabledText, light-dark(#D6D7DE, #373737)) ' ,
6995 } }
7096 _focus = { {
71- bg : '$ primaryBg' ,
72- border : '1px solid $ primary' ,
97+ bg : 'var(-- primaryBg, light-dark(#F4F3FA, #F4F3FA0D)) ' ,
98+ border : '1px solid var(-- primary, light-dark(#674DC7, #8163E1)) ' ,
7399 outline : 'none' ,
74100 } }
75101 _hover = { {
76- border : '1px solid $ primary' ,
102+ border : '1px solid var(-- primary, light-dark(red, blue)) ' ,
77103 } }
78- bg = "$inputBg"
79- border = { error ? '1px solid $error' : '1px solid $border' }
104+ bg = "var(--inputBg, light-dark(#FFFFFF, #2E2E2E))"
105+ borderColor = {
106+ error
107+ ? 'var(--error, light-dark(#D52B2E, #FF5B5E))'
108+ : 'var(--border, light-dark(#E4E4E4, #434343))'
109+ }
80110 borderRadius = "8px"
111+ borderStyle = "solid"
112+ borderWidth = "1px"
113+ className = { classNames ?. input }
114+ disabled = { disabled }
81115 onChange = { onChangeProp ?? handleChange }
82116 pl = { icon ? '36px' : '12px' }
83117 pr = { [ '36px' , null , allowClear ? '36px' : '12px' ] }
84118 py = "12px"
85119 selectors = { {
86120 '&::placeholder' : {
87- color : '$ inputPlaceholder' ,
121+ color : 'var(-- inputPlaceholder, light-dark(#A9A8AB, #CBCBCB)) ' ,
88122 } ,
89123 } }
90124 styleOrder = { 1 }
125+ styleVars = { Object . assign ( { } , colors ) }
91126 transition = "all 0.1s ease-in-out"
92127 typography = { typography }
93128 value = { valueProp ?? value }
94- w = "200px"
95129 { ...props }
96130 />
97131 { clearButtonVisible && (
@@ -102,6 +136,20 @@ export function Input({
102136 onClick = { handleClear }
103137 />
104138 ) }
139+ { errorMessage && (
140+ < Text
141+ bottom = "-8px"
142+ className = { classNames ?. errorMessage }
143+ color = "var(--error, light-dark(#D52B2E, #FF5B5E))"
144+ left = "0"
145+ pos = "absolute"
146+ styleOrder = { 1 }
147+ transform = "translateY(100%)"
148+ typography = "inputPlaceholder"
149+ >
150+ { errorMessage }
151+ </ Text >
152+ ) }
105153 </ Box >
106154 )
107155}
@@ -110,11 +158,11 @@ export function ClearButton(props: ComponentProps<'button'>) {
110158 return (
111159 < Button
112160 alignItems = "center"
113- bg = "$ negative20"
161+ bg = "var(-- negative20, light-dark(#00000033, #FFFFFF66)) "
114162 border = "none"
115163 borderRadius = "50%"
116164 boxSize = "20px"
117- color = "$ base"
165+ color = "var(-- base, light-dark(#FFF, #000)) "
118166 cursor = "pointer"
119167 display = "flex"
120168 justifyContent = "center"
0 commit comments