@@ -4,13 +4,13 @@ import { Upload, X, FileText, Loader2 } from "lucide-react";
44type FileUploaderProps = {
55 files ?: File [ ] | File | null ;
66 setFiles ?: React . Dispatch < React . SetStateAction < File [ ] > > ;
7- handleFileUpload : any
7+ handleFileUpload : any ;
88 removeFile ?: any ;
9-
9+
1010 singleFile ?: boolean ;
1111 previewUrl ?: string | null ;
1212 fileName ?: string ;
13-
13+
1414 isUploading ?: boolean ;
1515 accept : string ;
1616 maxFiles ?: number ;
@@ -45,7 +45,7 @@ const FileUploader: React.FC<FileUploaderProps> = ({
4545 maxSize = "Max 1 MB files are allowed" ,
4646 allowedFileTypes,
4747 height = "h-32" ,
48- fileSize
48+ fileSize,
4949} ) => {
5050 const handleDragOver = ( e : React . DragEvent < HTMLDivElement > ) => {
5151 e . preventDefault ( ) ;
@@ -70,35 +70,35 @@ const FileUploader: React.FC<FileUploaderProps> = ({
7070 if ( ! files || ! Array . isArray ( files ) || files . length === 0 ) return null ;
7171
7272 return (
73- < div className = " w-full mb-4" >
73+ < div className = ' w-full mb-4' >
7474 { files . map ( ( file , index ) => (
7575 < div
7676 key = { index }
77- className = " flex items-center justify-between p-3 border border-[var(--default-border-color)] rounded-md mb-2"
77+ className = ' flex items-center justify-between p-3 border border-[var(--default-border-color)] rounded-md mb-2'
7878 >
79- < div className = " flex items-center" >
79+ < div className = ' flex items-center' >
8080 < FileText
81- className = " h-5 w-5 mr-2"
82- color = " var(--white-text-color)"
81+ className = ' h-5 w-5 mr-2'
82+ color = ' var(--white-text-color)'
8383 />
84- < div className = " text-sm" >
85- < p className = " text-[var(--primary-text-color)] font-medium" >
84+ < div className = ' text-sm' >
85+ < p className = ' text-[var(--primary-text-color)] font-medium' >
8686 { file . name }
8787 </ p >
88- < p className = " text-xs text-[var(--secondary-text-color)]" >
88+ < p className = ' text-xs text-[var(--secondary-text-color)]' >
8989 { Math . round ( file . size / 1024 ) } kb
9090 </ p >
9191 </ div >
9292 </ div >
9393 < button
94- type = " button"
94+ type = ' button'
9595 onClick = { ( e ) => {
9696 e . stopPropagation ( ) ;
9797 removeFile ( index ) ;
9898 } }
99- className = " text-gray-500 hover:text-gray-700"
99+ className = ' text-gray-500 hover:text-gray-700'
100100 >
101- < X className = " h-4 w-4" color = " var(--white-text-color)" />
101+ < X className = ' h-4 w-4' color = ' var(--white-text-color)' />
102102 </ button >
103103 </ div >
104104 ) ) }
@@ -111,36 +111,36 @@ const FileUploader: React.FC<FileUploaderProps> = ({
111111
112112 return (
113113 < div
114- className = " rounded-md my-2 flex flex-col border border-[var(--default-border-color)] p-3 text-sm cursor-pointer"
114+ className = ' rounded-md my-2 flex flex-col border border-[var(--default-border-color)] p-3 text-sm cursor-pointer'
115115 onClick = { ( ) => document . getElementById ( inputId ) ?. click ( ) }
116116 >
117117 { previewUrl && (
118- < div className = " rounded flex items-center overflow-hidden relative" >
119- < div className = " flex gap-3" >
118+ < div className = ' rounded flex items-center overflow-hidden relative' >
119+ < div className = ' flex gap-3' >
120120 < img
121121 src = { previewUrl }
122- alt = " File preview"
123- className = " object-cover w-12 h-12 rounded-full"
122+ alt = ' File preview'
123+ className = ' object-cover w-12 h-12 rounded-full'
124124 />
125- < div className = " flex flex-col" >
126- < span className = " truncate" > { fileName } </ span >
127- < p className = " text-xs text-left text-[var(--secondary-text-color)]" >
125+ < div className = ' flex flex-col' >
126+ < span className = ' truncate' > { fileName } </ span >
127+ < p className = ' text-xs text-left text-[var(--secondary-text-color)]' >
128128 { fileSize && `${ Math . round ( fileSize / 1024 ) } kb` }
129129 </ p >
130130 </ div >
131131 </ div >
132132 < X
133133 onClick = { ( e ) => {
134- e . stopPropagation ( )
135- removeFile ?.( previewUrl )
134+ e . stopPropagation ( ) ;
135+ removeFile ?.( previewUrl ) ;
136136 } }
137- className = " h-4 w-4 flex justify-end absolute right-0 top-0 z-50"
138- color = " var(--white-text-color)"
137+ className = ' h-4 w-4 flex justify-end absolute right-0 top-0 z-50'
138+ color = ' var(--white-text-color)'
139139 />
140140 < input
141- type = " file"
141+ type = ' file'
142142 accept = { accept }
143- className = " hidden"
143+ className = ' hidden'
144144 id = { inputId }
145145 onChange = { ( e ) => {
146146 if ( e . target . files && e . target . files . length > 0 ) {
@@ -149,8 +149,6 @@ const FileUploader: React.FC<FileUploaderProps> = ({
149149 }
150150 } }
151151 />
152-
153-
154152 </ div >
155153 ) }
156154 </ div >
@@ -175,23 +173,23 @@ const FileUploader: React.FC<FileUploaderProps> = ({
175173 >
176174 { isUploading ? (
177175 < Loader2
178- className = " animate-spin"
176+ className = ' animate-spin'
179177 size = { 24 }
180- color = " var(--white-text-color)"
178+ color = ' var(--white-text-color)'
181179 />
182180 ) : (
183181 < >
184182 < Upload
185183 size = { 24 }
186- className = " text-[#6b6b74] dark:text-[#A1A1AA] mb-2"
187- color = " var(--white-text-color)"
184+ className = ' text-[#6b6b74] dark:text-[#A1A1AA] mb-2'
185+ color = ' var(--white-text-color)'
188186 />
189- < p className = " text-sm text-[#6b6b74] dark:text-[#A1A1AA]" >
187+ < p className = ' text-sm text-[#6b6b74] dark:text-[#A1A1AA]' >
190188 Drag your file(s) or{ " " }
191189 < input
192- type = " file"
190+ type = ' file'
193191 accept = { accept }
194- className = " hidden"
192+ className = ' hidden'
195193 id = { inputId }
196194 multiple = { ! singleFile }
197195 onChange = { ( e ) => {
@@ -208,14 +206,14 @@ const FileUploader: React.FC<FileUploaderProps> = ({
208206 />
209207 < label
210208 htmlFor = { inputId }
211- className = " text-[var(--primary-text-color)] underline cursor-pointer ml-1"
209+ className = ' text-[var(--primary-text-color)] underline cursor-pointer ml-1'
212210 onClick = { ( e ) => e . stopPropagation ( ) }
213211 >
214212 browse
215213 </ label >
216214 </ p >
217215 { ( maxSize || allowedFileTypes ) && (
218- < p className = " text-xs text-[#6b6b74] dark:text-[#A1A1AA] mt-1" >
216+ < p className = ' text-xs text-[#6b6b74] dark:text-[#A1A1AA] mt-1' >
219217 { maxSize } { allowedFileTypes ? `(${ allowedFileTypes } )` : "" }
220218 </ p >
221219 ) }
@@ -226,22 +224,22 @@ const FileUploader: React.FC<FileUploaderProps> = ({
226224 } ;
227225
228226 return (
229- < div className = " mb-6" >
227+ < div className = ' mb-6' >
230228 { label && (
231- < label className = " block text-sm" >
229+ < label className = ' block text-sm' >
232230 { label }
233- { required && < span className = " text-[#FB2C36]" > *</ span > }
231+ { required && < span className = ' text-[#FB2C36]' > *</ span > }
234232 </ label >
235233 ) }
236234
237235 { recommendedSize && (
238- < p className = " text-xs text-[#6b6b74] dark:text-[#A1A1AA] mb-2" >
236+ < p className = ' text-xs text-[#6b6b74] dark:text-[#A1A1AA] mb-2' >
239237 { recommendedSize }
240238 </ p >
241239 ) }
242240
243241 { description && (
244- < p className = " text-xs text-[#6b6b74] dark:text-[#A1A1AA] mb-2" >
242+ < p className = ' text-xs text-[#6b6b74] dark:text-[#A1A1AA] mb-2' >
245243 { description }
246244 </ p >
247245 ) }
0 commit comments