44 Box ,
55 Button ,
66 Center ,
7- css ,
87 DevupThemeTypography ,
98 Input as DevupInput ,
109 Text ,
@@ -44,27 +43,29 @@ export function Input({
4443 typography,
4544 error = false ,
4645 errorMessage,
47- allowClear = false ,
46+ allowClear = true ,
4847 icon,
4948 colors,
5049 disabled,
5150 classNames,
51+ ref,
5252 ...props
5353} : InputProps ) {
54- const [ value , setValue ] = useState ( defaultValue ?? '' )
54+ const [ value , setValue ] = useState ( defaultValue || '' )
5555 const handleChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
5656 setValue ( e . target . value )
57+ onChangeProp ?.( e )
5758 }
5859 const handleClear = ( ) => {
5960 setValue ( '' )
6061 }
61- const clearButtonVisible = value && ! disabled
62+ const clearButtonVisible = value && ! disabled && allowClear
6263
6364 return (
6465 < Box
66+ display = "inline-block"
6567 pos = "relative"
6668 selectors = { { '&,&>*' : { boxSizing : 'border-box' } } }
67- w = "fit-content"
6869 >
6970 { icon && (
7071 < Center
@@ -86,11 +87,10 @@ export function Input({
8687 </ Center >
8788 ) }
8889 < DevupInput
90+ ref = { ref }
8991 _disabled = { {
90- selectors : {
91- '&::placeholder' : {
92- color : 'var(--inputDisabledText, light-dark(#D6D7DE, #373737))' ,
93- } ,
92+ _placeholder : {
93+ color : 'var(--inputDisabledText, light-dark(#D6D7DE, #373737))' ,
9494 } ,
9595 bg : 'var(--inputDisabledBg, light-dark(#F0F0F3, #414244))' ,
9696 border : '1px solid var(--border, light-dark(#E4E4E4, #434343))' ,
@@ -104,6 +104,9 @@ export function Input({
104104 _hover = { {
105105 border : '1px solid var(--primary, light-dark(red, blue))' ,
106106 } }
107+ _placeholder = { {
108+ color : 'var(--inputPlaceholder, light-dark(#A9A8AB, #CBCBCB))' ,
109+ } }
107110 aria-label = "input"
108111 bg = "var(--inputBg, light-dark(#FFFFFF, #2E2E2E))"
109112 borderColor = {
@@ -116,15 +119,10 @@ export function Input({
116119 borderWidth = "1px"
117120 className = { classNames ?. input }
118121 disabled = { disabled }
119- onChange = { onChangeProp ?? handleChange }
122+ onChange = { handleChange }
120123 pl = { icon ? '36px' : '12px' }
121124 pr = { [ '36px' , null , allowClear ? '36px' : '12px' ] }
122125 py = "12px"
123- selectors = { {
124- '&::placeholder' : {
125- color : 'var(--inputPlaceholder, light-dark(#A9A8AB, #CBCBCB))' ,
126- } ,
127- } }
128126 styleOrder = { 1 }
129127 styleVars = { {
130128 primary : colors ?. primary ,
@@ -142,14 +140,7 @@ export function Input({
142140 value = { valueProp ?? value }
143141 { ...props }
144142 />
145- { clearButtonVisible && (
146- < ClearButton
147- className = { css ( {
148- display : [ 'flex' , null , allowClear ? 'flex' : 'none' ] ,
149- } ) }
150- onClick = { handleClear }
151- />
152- ) }
143+ { clearButtonVisible && < ClearButton onClick = { handleClear } /> }
153144 { errorMessage && (
154145 < Text
155146 aria-label = "error-message"
@@ -174,7 +165,7 @@ export function ClearButton(props: ComponentProps<'button'>) {
174165 < Button
175166 alignItems = "center"
176167 aria-label = "clear-button"
177- bg = "var(--negative20, light-dark(#00000033 , #FFFFFF66 ))"
168+ bg = "var(--negative20, light-dark(#0003 , #FFF6 ))"
178169 border = "none"
179170 borderRadius = "50%"
180171 boxSize = "20px"
0 commit comments