@@ -52,15 +52,21 @@ const Input: React.FC<Props> = (e: Props) => {
5252 const getClassName = useCallback ( ( ) => {
5353 const input = inputRef . current ;
5454
55- if ( input && typeof classNames != "undefined" && typeof classNames . input === "function" ) {
56- return classNames ? .input ( input ) ;
55+ if ( input && typeof classNames !== "undefined" && typeof classNames ? .input === "function" ) {
56+ return classNames . input ( input ) ;
5757 }
5858
5959 const border = BORDER_COLOR . focus [ primaryColor as keyof typeof BORDER_COLOR . focus ] ;
6060 const ring =
6161 RING_COLOR [ "second-focus" ] [ primaryColor as keyof ( typeof RING_COLOR ) [ "second-focus" ] ] ;
62- const classNameOverload = typeof inputClassName === "string" ? inputClassName : "" ;
63- return `relative transition-all duration-300 py-2.5 pl-4 pr-14 w-full border-gray-300 dark:bg-slate-800 dark:text-white/80 dark:border-slate-600 rounded-lg tracking-wide font-light text-sm placeholder-gray-400 bg-white focus:ring disabled:opacity-40 disabled:cursor-not-allowed ${ border } ${ ring } ${ classNameOverload } ` ;
62+
63+ const defaultInputClassName = `relative transition-all duration-300 py-2.5 pl-4 pr-14 w-full border-gray-300 dark:bg-slate-800 dark:text-white/80 dark:border-slate-600 rounded-lg tracking-wide font-light text-sm placeholder-gray-400 bg-white focus:ring disabled:opacity-40 disabled:cursor-not-allowed ${ border } ${ ring } ` ;
64+
65+ return typeof inputClassName === "function"
66+ ? inputClassName ( defaultInputClassName )
67+ : typeof inputClassName === "string" && inputClassName !== ""
68+ ? inputClassName
69+ : defaultInputClassName ;
6470 } , [ inputRef , classNames , primaryColor , inputClassName ] ) ;
6571
6672 const handleInputChange = useCallback (
@@ -210,12 +216,19 @@ const Input: React.FC<Props> = (e: Props) => {
210216 if (
211217 button &&
212218 typeof classNames !== "undefined" &&
213- typeof classNames . toggleButton === "function"
219+ typeof classNames ? .toggleButton === "function"
214220 ) {
215221 return classNames . toggleButton ( button ) ;
216222 }
217223
218- return `absolute right-0 h-full px-3 text-gray-400 focus:outline-none disabled:opacity-40 disabled:cursor-not-allowed ${ toggleClassName } ` ;
224+ const defaultToggleClassName =
225+ "absolute right-0 h-full px-3 text-gray-400 focus:outline-none disabled:opacity-40 disabled:cursor-not-allowed" ;
226+
227+ return typeof toggleClassName === "function"
228+ ? toggleClassName ( defaultToggleClassName )
229+ : typeof toggleClassName === "string" && toggleClassName !== ""
230+ ? toggleClassName
231+ : defaultToggleClassName ;
219232 } , [ toggleClassName , buttonRef , classNames ] ) ;
220233
221234 return (
0 commit comments