ultra-image-uploader 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -333
- package/dist/components/ImageUploader.d.ts +3 -50
- package/dist/components/ImageUploader.d.ts.map +1 -1
- package/dist/components/ImageUploader.js +86 -143
- package/dist/components/ImageUploader.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +23 -17
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +119 -27
- package/dist/providers/index.js.map +1 -1
- package/dist/types/index.d.ts +25 -32
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +14 -8
- package/dist/providers/BaseProvider.d.ts +0 -19
- package/dist/providers/BaseProvider.d.ts.map +0 -1
- package/dist/providers/BaseProvider.js +0 -48
- package/dist/providers/BaseProvider.js.map +0 -1
- package/dist/providers/CloudinaryProvider.d.ts +0 -17
- package/dist/providers/CloudinaryProvider.d.ts.map +0 -1
- package/dist/providers/CloudinaryProvider.js +0 -123
- package/dist/providers/CloudinaryProvider.js.map +0 -1
- package/dist/providers/ImgBBProvider.d.ts +0 -13
- package/dist/providers/ImgBBProvider.d.ts.map +0 -1
- package/dist/providers/ImgBBProvider.js +0 -68
- package/dist/providers/ImgBBProvider.js.map +0 -1
- package/dist/utils/imageUpload.d.ts +0 -11
- package/dist/utils/imageUpload.d.ts.map +0 -1
- package/dist/utils/imageUpload.js +0 -32
- package/dist/utils/imageUpload.js.map +0 -1
- package/dist/utils/upload.d.ts +0 -49
- package/dist/utils/upload.d.ts.map +0 -1
- package/dist/utils/upload.js +0 -62
- package/dist/utils/upload.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
A modern,
|
|
5
|
+
A modern, beautiful React image upload component with progress tracking, drag-and-drop, and multi-provider support.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/ultra-image-uploader)
|
|
8
|
-
|
|
8
|
+

|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
10
|
|
|
10
|
-
**
|
|
11
|
+
**Modern UI** • **Progress Bars** • **ImgBB & Cloudinary** • **Auto Import Ready**
|
|
11
12
|
|
|
12
13
|
</div>
|
|
13
14
|
|
|
@@ -15,32 +16,36 @@ A modern, feature-rich React image upload component with support for multiple ho
|
|
|
15
16
|
|
|
16
17
|
## Features
|
|
17
18
|
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
19
|
+
- **Modern UI** - Clean, professional file upload interface matching industry standards
|
|
20
|
+
- **Progress Tracking** - Real-time upload progress with smooth animations
|
|
21
|
+
- **Drag & Drop** - Intuitive drag-and-drop file handling
|
|
22
|
+
- **Multiple Providers** - Built-in support for ImgBB and Cloudinary
|
|
23
|
+
- **File Validation** - Type and size validation with helpful error messages
|
|
23
24
|
- **Auto Upload** - Optional automatic upload on file selection
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **Customizable** - Highly customizable styling and behavior
|
|
28
|
-
- **Tree Shakeable** - Optimized bundle size
|
|
25
|
+
- **Cancel/Remove** - Easy file management with cancel buttons
|
|
26
|
+
- **TypeScript** - Fully typed for excellent DX
|
|
27
|
+
- **Auto Import** - Works seamlessly with VS Code, WebStorm, and all popular editors
|
|
29
28
|
|
|
30
29
|
## Installation
|
|
31
30
|
|
|
31
|
+
Install with any package manager:
|
|
32
|
+
|
|
32
33
|
```bash
|
|
34
|
+
# npm
|
|
33
35
|
npm install ultra-image-uploader
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
# yarn
|
|
35
38
|
yarn add ultra-image-uploader
|
|
36
|
-
|
|
39
|
+
|
|
40
|
+
# pnpm
|
|
37
41
|
pnpm add ultra-image-uploader
|
|
42
|
+
|
|
43
|
+
# bun
|
|
44
|
+
bun add ultra-image-uploader
|
|
38
45
|
```
|
|
39
46
|
|
|
40
47
|
## Quick Start
|
|
41
48
|
|
|
42
|
-
### Basic Usage
|
|
43
|
-
|
|
44
49
|
```tsx
|
|
45
50
|
import { ImageUploader } from "ultra-image-uploader";
|
|
46
51
|
import { useState } from "react";
|
|
@@ -52,196 +57,120 @@ function App() {
|
|
|
52
57
|
<ImageUploader
|
|
53
58
|
images={images}
|
|
54
59
|
setImages={setImages}
|
|
55
|
-
multiple
|
|
56
|
-
theme="light"
|
|
60
|
+
multiple
|
|
57
61
|
/>
|
|
58
62
|
);
|
|
59
63
|
}
|
|
60
64
|
```
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
## Usage Examples
|
|
67
|
+
|
|
68
|
+
### Basic File Upload
|
|
63
69
|
|
|
64
70
|
```tsx
|
|
65
|
-
import { ImageUploader
|
|
66
|
-
import { useState } from "react";
|
|
71
|
+
import { ImageUploader } from "ultra-image-uploader";
|
|
67
72
|
|
|
68
|
-
function
|
|
73
|
+
function BasicUpload() {
|
|
69
74
|
const [images, setImages] = useState<File[]>([]);
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
const handleUpload = async () => {
|
|
74
|
-
setLoading(true);
|
|
75
|
-
try {
|
|
76
|
-
const result = await uploadImagesToImageBB(
|
|
77
|
-
images,
|
|
78
|
-
"your-imgbb-api-key-here"
|
|
79
|
-
);
|
|
80
|
-
setUploadedUrls(result.urls);
|
|
81
|
-
console.log("Uploaded URLs:", result.urls);
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error("Error uploading images:", error);
|
|
84
|
-
} finally {
|
|
85
|
-
setLoading(false);
|
|
86
|
-
}
|
|
75
|
+
|
|
76
|
+
const handleUploadComplete = (urls: string[]) => {
|
|
77
|
+
console.log('Uploaded URLs:', urls);
|
|
87
78
|
};
|
|
88
79
|
|
|
89
80
|
return (
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
>
|
|
102
|
-
{loading ? "Uploading..." : "Upload to ImgBB"}
|
|
103
|
-
</button>
|
|
104
|
-
|
|
105
|
-
{uploadedUrls.length > 0 && (
|
|
106
|
-
<div>
|
|
107
|
-
<h3>Uploaded Images:</h3>
|
|
108
|
-
{uploadedUrls.map((url) => (
|
|
109
|
-
<img key={url} src={url} alt="Uploaded" />
|
|
110
|
-
))}
|
|
111
|
-
</div>
|
|
112
|
-
)}
|
|
113
|
-
</div>
|
|
81
|
+
<ImageUploader
|
|
82
|
+
images={images}
|
|
83
|
+
setImages={setImages}
|
|
84
|
+
multiple
|
|
85
|
+
maxSize={50 * 1024 * 1024} // 50MB
|
|
86
|
+
onUploadComplete={handleUploadComplete}
|
|
87
|
+
uploadConfig={{
|
|
88
|
+
provider: 'imgbb',
|
|
89
|
+
config: { apiKey: 'your-api-key' }
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
114
92
|
);
|
|
115
93
|
}
|
|
116
94
|
```
|
|
117
95
|
|
|
118
|
-
###
|
|
96
|
+
### Upload with ImgBB
|
|
119
97
|
|
|
120
98
|
```tsx
|
|
121
|
-
import { ImageUploader
|
|
122
|
-
import { useState } from "react";
|
|
99
|
+
import { ImageUploader } from "ultra-image-uploader";
|
|
123
100
|
|
|
124
|
-
function
|
|
101
|
+
function ImgBBUpload() {
|
|
125
102
|
const [images, setImages] = useState<File[]>([]);
|
|
126
|
-
const [loading, setLoading] = useState(false);
|
|
127
|
-
|
|
128
|
-
const handleUpload = async () => {
|
|
129
|
-
setLoading(true);
|
|
130
|
-
try {
|
|
131
|
-
const results = await uploadImagesToCloudinary(
|
|
132
|
-
images,
|
|
133
|
-
{
|
|
134
|
-
cloudName: "your-cloud-name",
|
|
135
|
-
uploadPreset: "your-upload-preset", // for unsigned uploads
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
onProgress: (progress) => {
|
|
139
|
-
console.log(`Upload: ${progress.percentage}%`);
|
|
140
|
-
},
|
|
141
|
-
transformOptions: {
|
|
142
|
-
width: 800,
|
|
143
|
-
height: 600,
|
|
144
|
-
crop: "limit",
|
|
145
|
-
quality: 80,
|
|
146
|
-
},
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
console.log("Uploaded:", results);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
console.error("Error:", error);
|
|
152
|
-
} finally {
|
|
153
|
-
setLoading(false);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
103
|
|
|
157
104
|
return (
|
|
158
105
|
<div>
|
|
159
106
|
<ImageUploader
|
|
160
107
|
images={images}
|
|
161
108
|
setImages={setImages}
|
|
162
|
-
multiple
|
|
163
|
-
|
|
109
|
+
multiple
|
|
110
|
+
uploadConfig={{
|
|
111
|
+
provider: 'imgbb',
|
|
112
|
+
config: { apiKey: process.env.IMGBB_API_KEY }
|
|
113
|
+
}}
|
|
114
|
+
onUploadComplete={(urls) => {
|
|
115
|
+
console.log('Images uploaded to ImgBB:', urls);
|
|
116
|
+
}}
|
|
164
117
|
/>
|
|
165
|
-
<button onClick={handleUpload} disabled={loading}>
|
|
166
|
-
Upload to Cloudinary
|
|
167
|
-
</button>
|
|
168
118
|
</div>
|
|
169
119
|
);
|
|
170
120
|
}
|
|
171
121
|
```
|
|
172
122
|
|
|
173
|
-
###
|
|
123
|
+
### Upload with Cloudinary
|
|
174
124
|
|
|
175
125
|
```tsx
|
|
176
126
|
import { ImageUploader } from "ultra-image-uploader";
|
|
177
|
-
import { useState } from "react";
|
|
178
127
|
|
|
179
|
-
function
|
|
128
|
+
function CloudinaryUpload() {
|
|
180
129
|
const [images, setImages] = useState<File[]>([]);
|
|
181
|
-
const [uploadedUrls, setUploadedUrls] = useState<string[]>([]);
|
|
182
130
|
|
|
183
131
|
return (
|
|
184
132
|
<ImageUploader
|
|
185
133
|
images={images}
|
|
186
134
|
setImages={setImages}
|
|
187
|
-
multiple
|
|
188
|
-
autoUpload={true}
|
|
135
|
+
multiple
|
|
189
136
|
uploadConfig={{
|
|
190
|
-
provider:
|
|
191
|
-
config: {
|
|
137
|
+
provider: 'cloudinary',
|
|
138
|
+
config: {
|
|
139
|
+
cloudName: 'your-cloud-name',
|
|
140
|
+
uploadPreset: 'your-upload-preset'
|
|
141
|
+
}
|
|
192
142
|
}}
|
|
193
143
|
onUploadComplete={(urls) => {
|
|
194
|
-
|
|
195
|
-
console.log("All uploads complete!", urls);
|
|
196
|
-
}}
|
|
197
|
-
onUploadError={(error) => {
|
|
198
|
-
console.error("Upload failed:", error);
|
|
144
|
+
console.log('Images uploaded to Cloudinary:', urls);
|
|
199
145
|
}}
|
|
200
|
-
theme="colorful"
|
|
201
146
|
/>
|
|
202
147
|
);
|
|
203
148
|
}
|
|
204
149
|
```
|
|
205
150
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
### Built-in Themes
|
|
209
|
-
|
|
210
|
-
The component comes with 5 beautiful themes:
|
|
211
|
-
|
|
212
|
-
- **`light`** - Clean and modern light theme
|
|
213
|
-
- **`dark`** - Sleek dark theme
|
|
214
|
-
- **`modern`** - Purple-themed modern design
|
|
215
|
-
- **`minimal`** - Minimalist black and white
|
|
216
|
-
- **`colorful`** - Warm amber/yellow theme
|
|
151
|
+
### Auto Upload Mode
|
|
217
152
|
|
|
218
153
|
```tsx
|
|
219
|
-
<ImageUploader
|
|
154
|
+
<ImageUploader
|
|
155
|
+
images={images}
|
|
156
|
+
setImages={setImages}
|
|
157
|
+
multiple
|
|
158
|
+
autoUpload
|
|
159
|
+
uploadConfig={{
|
|
160
|
+
provider: 'imgbb',
|
|
161
|
+
config: { apiKey: 'your-api-key' }
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
220
164
|
```
|
|
221
165
|
|
|
222
|
-
###
|
|
223
|
-
|
|
224
|
-
Create your own theme with full customization:
|
|
166
|
+
### Single File Upload
|
|
225
167
|
|
|
226
168
|
```tsx
|
|
227
|
-
import { ImageUploader, type UploaderTheme } from "ultra-image-uploader";
|
|
228
|
-
|
|
229
|
-
const customTheme: UploaderTheme = {
|
|
230
|
-
primary: "#ff6b6b",
|
|
231
|
-
primaryHover: "#ee5a5a",
|
|
232
|
-
background: "#f7f7f7",
|
|
233
|
-
border: "#ddd",
|
|
234
|
-
text: "#333",
|
|
235
|
-
textSecondary: "#666",
|
|
236
|
-
error: "#e74c3c",
|
|
237
|
-
success: "#2ecc71",
|
|
238
|
-
radius: "8px",
|
|
239
|
-
};
|
|
240
|
-
|
|
241
169
|
<ImageUploader
|
|
242
|
-
images={
|
|
243
|
-
setImages={
|
|
244
|
-
|
|
170
|
+
images={avatar}
|
|
171
|
+
setImages={setAvatar}
|
|
172
|
+
multiple={false}
|
|
173
|
+
maxSize={2 * 1024 * 1024} // 2MB
|
|
245
174
|
/>
|
|
246
175
|
```
|
|
247
176
|
|
|
@@ -249,232 +178,160 @@ const customTheme: UploaderTheme = {
|
|
|
249
178
|
|
|
250
179
|
| Prop | Type | Default | Description |
|
|
251
180
|
|------|------|---------|-------------|
|
|
252
|
-
| `images` | `File[]` | **Required** |
|
|
253
|
-
| `setImages` | `(files: File[]) => void` | **Required** |
|
|
254
|
-
| `
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
258
|
-
| `
|
|
259
|
-
| `uploadText` | `string` | `'Drop images here...'` | Upload area text |
|
|
260
|
-
| `typeText` | `string` | `'PNG, JPG,...'` | File type hint text |
|
|
261
|
-
| `maxSize` | `number` | `10485760` | Max file size in bytes (10MB) |
|
|
262
|
-
| `allowedTypes` | `string[]` | `['image/jpeg', ...]` | Allowed MIME types |
|
|
263
|
-
| `showFileSize` | `boolean` | `true` | Show file size on preview |
|
|
264
|
-
| `dragAndDrop` | `boolean` | `true` | Enable drag and drop |
|
|
265
|
-
| `previewWidth` | `number` | `150` | Preview image width in px |
|
|
266
|
-
| `previewHeight` | `number` | `150` | Preview image height in px |
|
|
267
|
-
| `className` | `string` | `''` | Additional CSS classes |
|
|
268
|
-
| `autoUpload` | `boolean` | `false` | Auto-upload on file selection |
|
|
181
|
+
| `images` | `File[]` | **Required** | Selected image files |
|
|
182
|
+
| `setImages` | `(files: File[]) => void` | **Required** | Update images state |
|
|
183
|
+
| `multiple` | `boolean` | `true` | Allow multiple file selection |
|
|
184
|
+
| `maxSize` | `number` | `52428800` | Max file size in bytes (50MB) |
|
|
185
|
+
| `allowedTypes` | `string[]` | Image types | Allowed MIME types |
|
|
186
|
+
| `className` | `string` | `''` | Extra CSS classes |
|
|
187
|
+
| `autoUpload` | `boolean` | `false` | Auto-upload on selection |
|
|
269
188
|
| `uploadConfig` | `{ provider, config }` | `undefined` | Upload configuration |
|
|
270
|
-
| `onUploadComplete` | `(urls: string[]) => void` | `undefined` |
|
|
271
|
-
| `onUploadError` | `(error: Error) => void` | `undefined` |
|
|
189
|
+
| `onUploadComplete` | `(urls: string[]) => void` | `undefined` | Upload success callback |
|
|
190
|
+
| `onUploadError` | `(error: Error) => void` | `undefined` | Upload error callback |
|
|
272
191
|
|
|
273
|
-
## Upload
|
|
192
|
+
## Upload Functions
|
|
274
193
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
Free image hosting with simple API:
|
|
194
|
+
You can also use the upload functions directly:
|
|
278
195
|
|
|
279
196
|
```tsx
|
|
280
|
-
import {
|
|
197
|
+
import {
|
|
198
|
+
uploadImage,
|
|
199
|
+
uploadImages,
|
|
200
|
+
uploadImagesToImageBB,
|
|
201
|
+
uploadImagesToCloudinary
|
|
202
|
+
} from "ultra-image-uploader";
|
|
203
|
+
|
|
204
|
+
// Upload single image
|
|
205
|
+
const result = await uploadImage(file, 'imgbb', { apiKey: 'key' });
|
|
206
|
+
|
|
207
|
+
// Upload multiple images
|
|
208
|
+
const results = await uploadImages(files, 'cloudinary', {
|
|
209
|
+
cloudName: 'your-cloud'
|
|
210
|
+
});
|
|
281
211
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
);
|
|
286
|
-
console.log(result.urls);
|
|
212
|
+
// Convenience functions
|
|
213
|
+
const { urls } = await uploadImagesToImageBB(images, apiKey);
|
|
214
|
+
const uploads = await uploadImagesToCloudinary(images, config);
|
|
287
215
|
```
|
|
288
216
|
|
|
289
|
-
|
|
217
|
+
## API Configuration
|
|
290
218
|
|
|
291
|
-
###
|
|
219
|
+
### ImgBB
|
|
292
220
|
|
|
293
|
-
|
|
221
|
+
1. Go to [imgbb.com/settings/api](https://imgbb.com/settings/api)
|
|
222
|
+
2. Copy your API key
|
|
223
|
+
3. Use in the component:
|
|
294
224
|
|
|
295
225
|
```tsx
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{
|
|
301
|
-
cloudName: "your-cloud-name",
|
|
302
|
-
uploadPreset: "your-upload-preset", // optional
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
onProgress: (progress) => console.log(progress.percentage),
|
|
306
|
-
transformOptions: {
|
|
307
|
-
width: 800,
|
|
308
|
-
height: 600,
|
|
309
|
-
quality: 85,
|
|
310
|
-
crop: "limit",
|
|
311
|
-
},
|
|
312
|
-
}
|
|
313
|
-
);
|
|
226
|
+
uploadConfig={{
|
|
227
|
+
provider: 'imgbb',
|
|
228
|
+
config: { apiKey: 'your-api-key' }
|
|
229
|
+
}}
|
|
314
230
|
```
|
|
315
231
|
|
|
316
|
-
|
|
317
|
-
1. Sign up at [cloudinary.com](https://cloudinary.com)
|
|
318
|
-
2. Get your cloud name from dashboard
|
|
319
|
-
3. Create an upload preset (Settings → Upload → Upload presets)
|
|
320
|
-
|
|
321
|
-
## Advanced Usage
|
|
322
|
-
|
|
323
|
-
### Custom Provider
|
|
232
|
+
### Cloudinary
|
|
324
233
|
|
|
325
|
-
|
|
234
|
+
1. Sign up at [cloudinary.com](https://cloudinary.com)
|
|
235
|
+
2. Get your **cloud name** from dashboard
|
|
236
|
+
3. Create an **upload preset** (Settings → Upload → Upload presets)
|
|
237
|
+
4. Use in the component:
|
|
326
238
|
|
|
327
239
|
```tsx
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
async upload(file: File, config: ProviderConfig) {
|
|
334
|
-
// Your upload logic here
|
|
335
|
-
return {
|
|
336
|
-
url: "https://...",
|
|
337
|
-
provider: "custom",
|
|
338
|
-
originalFile: file,
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
async uploadMultiple(files: File[], config: ProviderConfig) {
|
|
343
|
-
return Promise.all(files.map(f => this.upload(f, config)));
|
|
240
|
+
uploadConfig={{
|
|
241
|
+
provider: 'cloudinary',
|
|
242
|
+
config: {
|
|
243
|
+
cloudName: 'your-cloud-name',
|
|
244
|
+
uploadPreset: 'your-upload-preset'
|
|
344
245
|
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Register and use
|
|
348
|
-
import { providerRegistry } from "ultra-image-uploader";
|
|
349
|
-
providerRegistry.register(new CustomProvider());
|
|
246
|
+
}}
|
|
350
247
|
```
|
|
351
248
|
|
|
352
|
-
|
|
249
|
+
## TypeScript
|
|
250
|
+
|
|
251
|
+
All exports are fully typed:
|
|
353
252
|
|
|
354
253
|
```tsx
|
|
355
|
-
import {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
254
|
+
import type {
|
|
255
|
+
ImageUploaderProps,
|
|
256
|
+
UploadProvider,
|
|
257
|
+
UploadResult,
|
|
258
|
+
ProviderConfig,
|
|
259
|
+
UploadOptions
|
|
359
260
|
} from "ultra-image-uploader";
|
|
261
|
+
```
|
|
360
262
|
|
|
361
|
-
|
|
362
|
-
const validation = validateImageFile(file, {
|
|
363
|
-
maxSize: 5 * 1024 * 1024, // 5MB
|
|
364
|
-
allowedTypes: ["image/jpeg", "image/png"],
|
|
365
|
-
});
|
|
263
|
+
## Auto Import Support
|
|
366
264
|
|
|
367
|
-
|
|
368
|
-
console.error("Errors:", validation.errors);
|
|
369
|
-
}
|
|
265
|
+
This package supports auto-import in all major editors:
|
|
370
266
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
minHeight: 600,
|
|
377
|
-
maxHeight: 3000,
|
|
378
|
-
});
|
|
379
|
-
```
|
|
267
|
+
- **VS Code** - Auto-suggestions work out of the box
|
|
268
|
+
- **WebStorm** - Full IntelliSense support
|
|
269
|
+
- **Neovim** - Works with LSP and completion plugins
|
|
270
|
+
- **Sublime Text** - Works with LSP packages
|
|
271
|
+
- **All TypeScript editors** - Full type checking and suggestions
|
|
380
272
|
|
|
381
|
-
|
|
273
|
+
## Styling
|
|
382
274
|
|
|
383
|
-
|
|
275
|
+
The component uses Tailwind CSS classes. You can add custom styling:
|
|
384
276
|
|
|
385
277
|
```tsx
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
"
|
|
390
|
-
|
|
391
|
-
width: 400,
|
|
392
|
-
height: 300,
|
|
393
|
-
crop: "fill",
|
|
394
|
-
quality: 80,
|
|
395
|
-
format: "webp",
|
|
396
|
-
}
|
|
397
|
-
);
|
|
278
|
+
<ImageUploader
|
|
279
|
+
images={images}
|
|
280
|
+
setImages={setImages}
|
|
281
|
+
className="max-w-2xl mx-auto"
|
|
282
|
+
/>
|
|
398
283
|
```
|
|
399
284
|
|
|
400
|
-
|
|
285
|
+
### Custom Styling
|
|
401
286
|
|
|
402
|
-
|
|
287
|
+
For complete customization, you can wrap and override styles:
|
|
403
288
|
|
|
404
289
|
```tsx
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
ValidationResult,
|
|
413
|
-
FileValidationOptions,
|
|
414
|
-
} from "ultra-image-uploader";
|
|
290
|
+
<div className="your-custom-wrapper">
|
|
291
|
+
<ImageUploader
|
|
292
|
+
images={images}
|
|
293
|
+
setImages={setImages}
|
|
294
|
+
className="your-custom-class"
|
|
295
|
+
/>
|
|
296
|
+
</div>
|
|
415
297
|
```
|
|
416
298
|
|
|
417
|
-
##
|
|
299
|
+
## Troubleshooting
|
|
418
300
|
|
|
419
|
-
###
|
|
301
|
+
### Auto imports not working
|
|
420
302
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
"https://example.com/product1.jpg",
|
|
426
|
-
]);
|
|
303
|
+
**VS Code:**
|
|
304
|
+
1. Ensure TypeScript is enabled in your project
|
|
305
|
+
2. Restart the TypeScript server: `Cmd/Ctrl + Shift + P` → "TypeScript: Restart TS Server"
|
|
306
|
+
3. Check that `node_modules/ultra-image-uploader` exists
|
|
427
307
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
setImages={setImages}
|
|
432
|
-
mode="update"
|
|
433
|
-
defaultImages={existingImages}
|
|
434
|
-
multiple={true}
|
|
435
|
-
maxSize={5 * 1024 * 1024} // 5MB
|
|
436
|
-
allowedTypes={["image/jpeg", "image/webp"]}
|
|
437
|
-
theme="modern"
|
|
438
|
-
previewWidth={200}
|
|
439
|
-
previewHeight={200}
|
|
440
|
-
/>
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
```
|
|
308
|
+
**WebStorm:**
|
|
309
|
+
1. Invalidate caches: `File` → `Invalidate Caches and Restart`
|
|
310
|
+
2. Ensure TypeScript plugin is enabled
|
|
444
311
|
|
|
445
|
-
###
|
|
312
|
+
### Uploads failing
|
|
446
313
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
314
|
+
1. **Check API keys** - Verify your ImgBB or Cloudinary credentials
|
|
315
|
+
2. **CORS issues** - Ensure your domain is whitelisted
|
|
316
|
+
3. **File size** - Check if file exceeds provider limits
|
|
317
|
+
4. **Network** - Check browser console for network errors
|
|
450
318
|
|
|
451
|
-
|
|
452
|
-
<ImageUploader
|
|
453
|
-
images={avatar}
|
|
454
|
-
setImages={setAvatar}
|
|
455
|
-
multiple={false}
|
|
456
|
-
maxSize={2 * 1024 * 1024} // 2MB
|
|
457
|
-
previewWidth={180}
|
|
458
|
-
previewHeight={180}
|
|
459
|
-
theme="minimal"
|
|
460
|
-
/>
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
```
|
|
319
|
+
### TypeScript errors
|
|
464
320
|
|
|
465
|
-
|
|
321
|
+
```bash
|
|
322
|
+
# Reinstall dependencies
|
|
323
|
+
rm -rf node_modules package-lock.json
|
|
324
|
+
npm install
|
|
466
325
|
|
|
467
|
-
|
|
326
|
+
# Restart TypeScript server in your editor
|
|
327
|
+
```
|
|
468
328
|
|
|
469
|
-
|
|
470
|
-
// Old API still works
|
|
471
|
-
import { uploadImagesToImageBB } from "ultra-image-uploader";
|
|
472
|
-
const { urls } = await uploadImagesToImageBB(images, apiKey);
|
|
329
|
+
### Build issues
|
|
473
330
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
331
|
+
```bash
|
|
332
|
+
# Clean and rebuild
|
|
333
|
+
npm run clean
|
|
334
|
+
npm run build
|
|
478
335
|
```
|
|
479
336
|
|
|
480
337
|
## Browser Support
|
|
@@ -482,17 +339,31 @@ const urls = results.map(r => r.url);
|
|
|
482
339
|
- Chrome/Edge (latest)
|
|
483
340
|
- Firefox (latest)
|
|
484
341
|
- Safari (latest)
|
|
485
|
-
- Mobile browsers
|
|
342
|
+
- Mobile browsers (iOS Safari, Chrome Mobile)
|
|
343
|
+
|
|
344
|
+
## Requirements
|
|
345
|
+
|
|
346
|
+
- React >= 18.0.0
|
|
347
|
+
- TypeScript (optional but recommended)
|
|
486
348
|
|
|
487
349
|
## License
|
|
488
350
|
|
|
489
351
|
MIT © Digontha Das
|
|
490
352
|
|
|
491
|
-
##
|
|
353
|
+
## Links
|
|
354
|
+
|
|
355
|
+
- [GitHub](https://github.com/digontha/ultra-image-uploader)
|
|
356
|
+
- [NPM](https://www.npmjs.com/package/ultra-image-uploader)
|
|
357
|
+
- [Report Issues](https://github.com/digontha/ultra-image-uploader/issues)
|
|
358
|
+
|
|
359
|
+
## Changelog
|
|
492
360
|
|
|
493
|
-
|
|
494
|
-
-
|
|
495
|
-
-
|
|
361
|
+
### v2.0.0
|
|
362
|
+
- 🎨 Modern UI redesign with progress bars
|
|
363
|
+
- ✅ Auto import support for all editors
|
|
364
|
+
- 📦 Simplified package structure
|
|
365
|
+
- 🚀 Improved drag-and-drop experience
|
|
366
|
+
- 🎯 Better TypeScript support
|
|
496
367
|
|
|
497
368
|
---
|
|
498
369
|
|