@siamf/upload 1.0.0 → 1.2.0
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 +691 -0
- package/dist/cjs/components/file/FileUpload.d.ts +3 -0
- package/dist/cjs/components/file/FileUpload.js +120 -0
- package/dist/cjs/components/file/FileUpload.js.map +1 -0
- package/dist/cjs/components/file/MultiFileUpload.d.ts +4 -0
- package/dist/cjs/components/file/MultiFileUpload.js +160 -0
- package/dist/cjs/components/file/MultiFileUpload.js.map +1 -0
- package/dist/cjs/components/file/typings.d.ts +103 -0
- package/dist/cjs/components/file/typings.js +57 -0
- package/dist/cjs/components/file/typings.js.map +1 -0
- package/dist/cjs/components/image/ImageUpload.d.ts +3 -0
- package/dist/cjs/components/image/ImageUpload.js +126 -0
- package/dist/cjs/components/image/ImageUpload.js.map +1 -0
- package/dist/cjs/components/image/MultiImageUpload.d.ts +3 -0
- package/dist/cjs/components/image/MultiImageUpload.js +162 -0
- package/dist/cjs/components/image/MultiImageUpload.js.map +1 -0
- package/dist/cjs/components/image/typings.d.ts +73 -0
- package/dist/cjs/components/image/typings.js +18 -0
- package/dist/cjs/components/image/typings.js.map +1 -0
- package/dist/cjs/components/utils/utils.d.ts +9 -0
- package/dist/cjs/components/utils/utils.js +78 -0
- package/dist/cjs/components/utils/utils.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/components/file/FileUpload.d.ts +3 -0
- package/dist/esm/components/file/FileUpload.js +118 -0
- package/dist/esm/components/file/FileUpload.js.map +1 -0
- package/dist/esm/components/file/MultiFileUpload.d.ts +4 -0
- package/dist/esm/components/file/MultiFileUpload.js +157 -0
- package/dist/esm/components/file/MultiFileUpload.js.map +1 -0
- package/dist/esm/components/file/typings.d.ts +103 -0
- package/dist/esm/components/file/typings.js +54 -0
- package/dist/esm/components/file/typings.js.map +1 -0
- package/dist/esm/components/image/ImageUpload.d.ts +3 -0
- package/dist/esm/components/image/ImageUpload.js +124 -0
- package/dist/esm/components/image/ImageUpload.js.map +1 -0
- package/dist/esm/components/image/MultiImageUpload.d.ts +3 -0
- package/dist/esm/components/image/MultiImageUpload.js +160 -0
- package/dist/esm/components/image/MultiImageUpload.js.map +1 -0
- package/dist/esm/components/image/typings.d.ts +73 -0
- package/dist/esm/components/image/typings.js +15 -0
- package/dist/esm/components/image/typings.js.map +1 -0
- package/dist/esm/components/utils/utils.d.ts +9 -0
- package/dist/esm/components/utils/utils.js +69 -0
- package/dist/esm/components/utils/utils.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +52 -8
package/README.md
ADDED
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
<br/>
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://res.cloudinary.com/dub0dpenl/image/upload/v1731780157/Personal%20Logo/logo-white_e6fujz.png">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://res.cloudinary.com/dub0dpenl/image/upload/v1731780152/Personal%20Logo/logo-dark_qqwrqu.png">
|
|
5
|
+
<img alt="Siam Ahnaf" src="https://res.cloudinary.com/dub0dpenl/image/upload/v1731780152/Personal%20Logo/logo-dark_qqwrqu.png" height="auto" width="240">
|
|
6
|
+
</picture>
|
|
7
|
+
<br/> <br/>
|
|
8
|
+
|
|
9
|
+
# @siamf/upload
|
|
10
|
+
A fully headless React package for handling image and file uploads with complete UI control. It provides four flexible components— `ImageUpload`, `MultiImageUpload`, `FileUpload`, and `MultiFileUpload` —using render props for seamless customization. Perfect for developers who need total control over the upload experience.
|
|
11
|
+
|
|
12
|
+
<a href="https://www.buymeacoffee.com/siamahnaf" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
|
|
13
|
+
|
|
14
|
+
- Easy to use
|
|
15
|
+
- Full UI Control (This package only provide functionality)
|
|
16
|
+
- SSR Support
|
|
17
|
+
- Latest React Support
|
|
18
|
+
|
|
19
|
+
# Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
$ npm i @siamf/upload
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
# Usage
|
|
26
|
+
|
|
27
|
+
### `ImageUpload`
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
"use client"
|
|
31
|
+
import { useState } from "react";
|
|
32
|
+
import { ImageUpload, ImageType } from "@siamf/upload";
|
|
33
|
+
|
|
34
|
+
const Page = () => {
|
|
35
|
+
//State
|
|
36
|
+
const [selectedImage, setSelected] = useState<ImageType>(null);
|
|
37
|
+
|
|
38
|
+
const onHandleFile = (value: ImageType) => {
|
|
39
|
+
setSelected(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div className="px-40 py-40">
|
|
44
|
+
<ImageUpload
|
|
45
|
+
onChange={onHandleFile}
|
|
46
|
+
value={selectedImage}
|
|
47
|
+
>
|
|
48
|
+
{({
|
|
49
|
+
isDragging,
|
|
50
|
+
dragProps,
|
|
51
|
+
onImageUpload,
|
|
52
|
+
imageInfo,
|
|
53
|
+
onImageRemove,
|
|
54
|
+
errors,
|
|
55
|
+
}) => (
|
|
56
|
+
<div>
|
|
57
|
+
<div className={`border border-solid border-red-600 p-8 ${isDragging && "bg-green-600"}`} {...dragProps} onClick={onImageUpload}>
|
|
58
|
+
Upload Now
|
|
59
|
+
</div>
|
|
60
|
+
<div>
|
|
61
|
+
{imageInfo &&
|
|
62
|
+
<div className="my-4 border-4 p-5 border-solid border-black">
|
|
63
|
+
<img src={imageInfo.dataURL} />
|
|
64
|
+
</div>
|
|
65
|
+
}
|
|
66
|
+
<button onClick={onImageRemove}>
|
|
67
|
+
Remove File
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
</ImageUpload>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default Page;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### `MultiImageUpload`
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
"use client"
|
|
85
|
+
import { useState } from "react";
|
|
86
|
+
import { MultiImageUpload, MultiImageType } from "@siamf/upload";
|
|
87
|
+
|
|
88
|
+
const Page = () => {
|
|
89
|
+
//State
|
|
90
|
+
const [imageList, setImageList] = useState<MultiImageType>([]);
|
|
91
|
+
|
|
92
|
+
const onHandleFile = (value: MultiImageType) => {
|
|
93
|
+
setImageList(value);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div className="px-40 py-40">
|
|
98
|
+
<MultiImageUpload
|
|
99
|
+
onChange={onHandleFile}
|
|
100
|
+
value={imageList}
|
|
101
|
+
>
|
|
102
|
+
{({
|
|
103
|
+
isDragging,
|
|
104
|
+
dragProps,
|
|
105
|
+
onImageUpload,
|
|
106
|
+
imageInfo,
|
|
107
|
+
onImageRemove,
|
|
108
|
+
onImageRemoveAll,
|
|
109
|
+
onImageUpdate,
|
|
110
|
+
errors,
|
|
111
|
+
}) => (
|
|
112
|
+
<div>
|
|
113
|
+
<div className={`border border-solid border-red-600 p-8 ${isDragging && "bg-green-600"}`} {...dragProps} onClick={onImageUpload}>
|
|
114
|
+
Upload Now
|
|
115
|
+
</div>
|
|
116
|
+
<div>
|
|
117
|
+
{imageInfo.map((item, i) => (
|
|
118
|
+
<div className="my-4 border-4 p-5 border-solid border-black">
|
|
119
|
+
<img src={item?.dataURL} />
|
|
120
|
+
<button onClick={() => onImageRemove(i)}>Remove File</button>
|
|
121
|
+
<button onClick={() => onImageUpdate(i)}>Update File</button>
|
|
122
|
+
</div>
|
|
123
|
+
))}
|
|
124
|
+
<button onClick={onImageRemoveAll}>
|
|
125
|
+
Remove All
|
|
126
|
+
</button>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
)}
|
|
130
|
+
</MultiImageUpload>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export default Page;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### `FileUpload`
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
"use client"
|
|
142
|
+
import { useState } from "react";
|
|
143
|
+
import { FileUpload, FileType } from "@siamf/upload";
|
|
144
|
+
|
|
145
|
+
const Page = () => {
|
|
146
|
+
//State
|
|
147
|
+
const [selectedFile, setSelected] = useState<FileType>(null);
|
|
148
|
+
|
|
149
|
+
const onHandleFile = (value: FileType) => {
|
|
150
|
+
setSelected(value);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div className="px-40 py-40">
|
|
155
|
+
<FileUpload
|
|
156
|
+
onChange={onHandleFile}
|
|
157
|
+
value={selectedFile}
|
|
158
|
+
>
|
|
159
|
+
{({
|
|
160
|
+
isDragging,
|
|
161
|
+
dragProps,
|
|
162
|
+
onFileUpload,
|
|
163
|
+
fileInfo,
|
|
164
|
+
onFileRemove,
|
|
165
|
+
errors,
|
|
166
|
+
}) => (
|
|
167
|
+
<div>
|
|
168
|
+
<div className={`border border-solid border-red-600 p-8 ${isDragging && "bg-green-600"}`} {...dragProps} onClick={onFileUpload}>
|
|
169
|
+
Upload Now
|
|
170
|
+
</div>
|
|
171
|
+
<div>
|
|
172
|
+
{fileInfo &&
|
|
173
|
+
<div className="my-4 border-4 p-5 border-solid border-black">
|
|
174
|
+
<p>{fileInfo.fileInfo.name}</p>
|
|
175
|
+
</div>
|
|
176
|
+
}
|
|
177
|
+
<button onClick={onFileRemove}>
|
|
178
|
+
Remove File
|
|
179
|
+
</button>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
</FileUpload>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export default Page;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### `MultiFileUpload`
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
"use client"
|
|
195
|
+
import { useState } from "react";
|
|
196
|
+
import { MultiFileUpload, MultiFileType } from "@siamf/upload";
|
|
197
|
+
|
|
198
|
+
const Page = () => {
|
|
199
|
+
//State
|
|
200
|
+
const [fileList, setFileList] = useState<MultiFileType>([]);
|
|
201
|
+
|
|
202
|
+
const onHandleFile = (value: MultiFileType) => {
|
|
203
|
+
setFileList(value);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<div className="px-40 py-40">
|
|
208
|
+
<MultiFileUpload
|
|
209
|
+
onChange={onHandleFile}
|
|
210
|
+
value={fileList}
|
|
211
|
+
>
|
|
212
|
+
{({
|
|
213
|
+
isDragging,
|
|
214
|
+
dragProps,
|
|
215
|
+
onFileUpload,
|
|
216
|
+
fileInfo,
|
|
217
|
+
onFileRemove,
|
|
218
|
+
onFileRemoveAll,
|
|
219
|
+
onFileUpdate,
|
|
220
|
+
errors,
|
|
221
|
+
}) => (
|
|
222
|
+
<div>
|
|
223
|
+
<div className={`border border-solid border-red-600 p-8 ${isDragging && "bg-green-600"}`} {...dragProps} onClick={onFileUpload}>
|
|
224
|
+
Upload Now
|
|
225
|
+
</div>
|
|
226
|
+
<div>
|
|
227
|
+
{fileInfo.map((item, i) => (
|
|
228
|
+
<div className="my-4 border-4 p-5 border-solid border-black">
|
|
229
|
+
<p>{item?.fileInfo.name}</p>
|
|
230
|
+
<button onClick={() => onFileRemove(i)}>Remove File</button>
|
|
231
|
+
<button onClick={() => onFileUpdate(i)}>Update File</button>
|
|
232
|
+
</div>
|
|
233
|
+
))}
|
|
234
|
+
<button onClick={onFileRemoveAll}>
|
|
235
|
+
Remove All
|
|
236
|
+
</button>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
)}
|
|
240
|
+
</MultiFileUpload>
|
|
241
|
+
</div>
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export default Page;
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Example for Validation**
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
...
|
|
252
|
+
{({ imageList, onImageUpload, onImageRemoveAll, errors }) => (
|
|
253
|
+
errors && <div>
|
|
254
|
+
{errors.acceptType && <span>Your selected file type is not allow</span>}
|
|
255
|
+
{errors.maxFileSize && <span>Selected file size exceed maxFileSize</span>}
|
|
256
|
+
</div>
|
|
257
|
+
)}
|
|
258
|
+
...
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
# Available Options
|
|
262
|
+
|
|
263
|
+
## `ImageUpload`
|
|
264
|
+
|
|
265
|
+
### Props
|
|
266
|
+
<table width="100%">
|
|
267
|
+
<tr>
|
|
268
|
+
<th> Name </th>
|
|
269
|
+
<th> Description </th>
|
|
270
|
+
<th> Type </th>
|
|
271
|
+
<th> Default/Required </th>
|
|
272
|
+
</tr>
|
|
273
|
+
<tr>
|
|
274
|
+
<td> inputProps </td>
|
|
275
|
+
<td> Available props for input field </td>
|
|
276
|
+
<td> HTMLProps<HTMLInputElement> </td>
|
|
277
|
+
<td> optional </td>
|
|
278
|
+
</tr>
|
|
279
|
+
<tr>
|
|
280
|
+
<td> acceptType </td>
|
|
281
|
+
<td> Image Accept type </td>
|
|
282
|
+
<td> ImageAcceptType | Exclude<ImageAcceptType, ImageAcceptType.ALL>[] </td>
|
|
283
|
+
<td> ImageAcceptType.ALL </td>
|
|
284
|
+
</tr>
|
|
285
|
+
<tr>
|
|
286
|
+
<td> maxFileSize </td>
|
|
287
|
+
<td> Max file size validation </td>
|
|
288
|
+
<td> number </td>
|
|
289
|
+
<td> optional </td>
|
|
290
|
+
</tr>
|
|
291
|
+
<tr>
|
|
292
|
+
<td> resolutionWidth </td>
|
|
293
|
+
<td> Image resolution width validation </td>
|
|
294
|
+
<td> number </td>
|
|
295
|
+
<td> optional </td>
|
|
296
|
+
</tr>
|
|
297
|
+
<tr>
|
|
298
|
+
<td> resolutionHeight </td>
|
|
299
|
+
<td> Image resolution height validation </td>
|
|
300
|
+
<td> number </td>
|
|
301
|
+
<td> optional </td>
|
|
302
|
+
</tr>
|
|
303
|
+
<tr>
|
|
304
|
+
<td> resolutionType </td>
|
|
305
|
+
<td> Resolution type for validations </td>
|
|
306
|
+
<td> "absolute" | "less" | "more" | "ratio" </td>
|
|
307
|
+
<td> "absolute" </td>
|
|
308
|
+
</tr>
|
|
309
|
+
<tr>
|
|
310
|
+
<td> children </td>
|
|
311
|
+
<td> UI for upload zone or button </td>
|
|
312
|
+
<td> (props: ImageExportTypes) => React.ReactNode </td>
|
|
313
|
+
<td> required </td>
|
|
314
|
+
</tr>
|
|
315
|
+
<tr>
|
|
316
|
+
<td> onChange </td>
|
|
317
|
+
<td> Image upload listener function </td>
|
|
318
|
+
<td> (value: ImageType) => void; </td>
|
|
319
|
+
<td> required </td>
|
|
320
|
+
</tr>
|
|
321
|
+
<tr>
|
|
322
|
+
<td> value </td>
|
|
323
|
+
<td> Default Value </td>
|
|
324
|
+
<td> ImageType </td>
|
|
325
|
+
<td> required </td>
|
|
326
|
+
</tr>
|
|
327
|
+
<tr>
|
|
328
|
+
<td> onError </td>
|
|
329
|
+
<td> Image upload error listener </td>
|
|
330
|
+
<td> (errors: ImageErrorTypes) => void; </td>
|
|
331
|
+
<td> optional </td>
|
|
332
|
+
</tr>
|
|
333
|
+
</table>
|
|
334
|
+
|
|
335
|
+
### ImageExportTypes
|
|
336
|
+
<table width="100%">
|
|
337
|
+
<tr>
|
|
338
|
+
<th> dragProps </th>
|
|
339
|
+
<th> Element for implementing drag and drop features </th>
|
|
340
|
+
<th> Object </th>
|
|
341
|
+
</tr>
|
|
342
|
+
<tr>
|
|
343
|
+
<td> isDragging </td>
|
|
344
|
+
<td> Listen is it dragging or not </td>
|
|
345
|
+
<td> boolean </td>
|
|
346
|
+
</tr>
|
|
347
|
+
<tr>
|
|
348
|
+
<td> onImageUpload </td>
|
|
349
|
+
<td> Handler for triggering image upload </td>
|
|
350
|
+
<td> () => void </td>
|
|
351
|
+
</tr>
|
|
352
|
+
<tr>
|
|
353
|
+
<td> imageInfo </td>
|
|
354
|
+
<td> Selected image information </td>
|
|
355
|
+
<td> ImageType </td>
|
|
356
|
+
</tr>
|
|
357
|
+
<tr>
|
|
358
|
+
<td> errors </td>
|
|
359
|
+
<td> Error listener </td>
|
|
360
|
+
<td> ImageErrorTypes </td>
|
|
361
|
+
</tr>
|
|
362
|
+
<tr>
|
|
363
|
+
<td> onImageRemove </td>
|
|
364
|
+
<td> Handler for removing selected Image </td>
|
|
365
|
+
<td> () => void </td>
|
|
366
|
+
</tr>
|
|
367
|
+
</table>
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
## `MultiImageUpload`
|
|
371
|
+
|
|
372
|
+
### Props
|
|
373
|
+
<table width="100%">
|
|
374
|
+
<tr>
|
|
375
|
+
<th> Name </th>
|
|
376
|
+
<th> Description </th>
|
|
377
|
+
<th> Type </th>
|
|
378
|
+
<th> Default/Required </th>
|
|
379
|
+
</tr>
|
|
380
|
+
<tr>
|
|
381
|
+
<td> inputProps </td>
|
|
382
|
+
<td> Available props for input field </td>
|
|
383
|
+
<td> HTMLProps<HTMLInputElement> </td>
|
|
384
|
+
<td> optional </td>
|
|
385
|
+
</tr>
|
|
386
|
+
<tr>
|
|
387
|
+
<td> acceptType </td>
|
|
388
|
+
<td> Image Accept type </td>
|
|
389
|
+
<td> ImageAcceptType | Exclude<ImageAcceptType, ImageAcceptType.ALL>[] </td>
|
|
390
|
+
<td> ImageAcceptType.ALL </td>
|
|
391
|
+
</tr>
|
|
392
|
+
<tr>
|
|
393
|
+
<td> maxFileSize </td>
|
|
394
|
+
<td> Max file size validation </td>
|
|
395
|
+
<td> number </td>
|
|
396
|
+
<td> optional </td>
|
|
397
|
+
</tr>
|
|
398
|
+
<tr>
|
|
399
|
+
<td> resolutionWidth </td>
|
|
400
|
+
<td> Image resolution width validation </td>
|
|
401
|
+
<td> number </td>
|
|
402
|
+
<td> optional </td>
|
|
403
|
+
</tr>
|
|
404
|
+
<tr>
|
|
405
|
+
<td> resolutionHeight </td>
|
|
406
|
+
<td> Image resolution height validation </td>
|
|
407
|
+
<td> number </td>
|
|
408
|
+
<td> optional </td>
|
|
409
|
+
</tr>
|
|
410
|
+
<tr>
|
|
411
|
+
<td> resolutionType </td>
|
|
412
|
+
<td> Resolution type for validations </td>
|
|
413
|
+
<td> "absolute" | "less" | "more" | "ratio" </td>
|
|
414
|
+
<td> "absolute" </td>
|
|
415
|
+
</tr>
|
|
416
|
+
<tr>
|
|
417
|
+
<td> children </td>
|
|
418
|
+
<td> UI for upload zone or button </td>
|
|
419
|
+
<td> (props: MultiImageExportTypes) => React.ReactNode </td>
|
|
420
|
+
<td> required </td>
|
|
421
|
+
</tr>
|
|
422
|
+
<tr>
|
|
423
|
+
<td> onChange </td>
|
|
424
|
+
<td> Image upload listener function </td>
|
|
425
|
+
<td> (value: MultiImageType) => void </td>
|
|
426
|
+
<td> required </td>
|
|
427
|
+
</tr>
|
|
428
|
+
<tr>
|
|
429
|
+
<td> value </td>
|
|
430
|
+
<td> Default Value </td>
|
|
431
|
+
<td> MultiImageType </td>
|
|
432
|
+
<td> required </td>
|
|
433
|
+
</tr>
|
|
434
|
+
<tr>
|
|
435
|
+
<td> onError </td>
|
|
436
|
+
<td> Image upload error listener </td>
|
|
437
|
+
<td> (errors: MultiImageErrorTypes) => void </td>
|
|
438
|
+
<td> optional </td>
|
|
439
|
+
</tr>
|
|
440
|
+
<tr>
|
|
441
|
+
<td> maxNumber </td>
|
|
442
|
+
<td> Maximum files to be selected </td>
|
|
443
|
+
<td> number </td>
|
|
444
|
+
<td> 10 </td>
|
|
445
|
+
</tr>
|
|
446
|
+
</table>
|
|
447
|
+
|
|
448
|
+
### MultiImageExportTypes
|
|
449
|
+
<table width="100%">
|
|
450
|
+
<tr>
|
|
451
|
+
<th> dragProps </th>
|
|
452
|
+
<th> Element for implementing drag and drop features </th>
|
|
453
|
+
<th> Object </th>
|
|
454
|
+
</tr>
|
|
455
|
+
<tr>
|
|
456
|
+
<td> isDragging </td>
|
|
457
|
+
<td> Listen is it dragging or not </td>
|
|
458
|
+
<td> boolean </td>
|
|
459
|
+
</tr>
|
|
460
|
+
<tr>
|
|
461
|
+
<td> onImageUpload </td>
|
|
462
|
+
<td> Handler for triggering image upload </td>
|
|
463
|
+
<td> () => void </td>
|
|
464
|
+
</tr>
|
|
465
|
+
<tr>
|
|
466
|
+
<td> imageInfo </td>
|
|
467
|
+
<td> Selected image information </td>
|
|
468
|
+
<td> MultiImageType </td>
|
|
469
|
+
</tr>
|
|
470
|
+
<tr>
|
|
471
|
+
<td> errors </td>
|
|
472
|
+
<td> Error listener </td>
|
|
473
|
+
<td> MultiImageErrorTypes </td>
|
|
474
|
+
</tr>
|
|
475
|
+
<tr>
|
|
476
|
+
<td> onImageRemove </td>
|
|
477
|
+
<td> Handler for removing selected Image </td>
|
|
478
|
+
<td> (index: number) => void </td>
|
|
479
|
+
</tr>
|
|
480
|
+
<tr>
|
|
481
|
+
<td> onImageUpdate </td>
|
|
482
|
+
<td> Handler for updating a particular image </td>
|
|
483
|
+
<td> (index: number) => void </td>
|
|
484
|
+
</tr>
|
|
485
|
+
<tr>
|
|
486
|
+
<td> onImageRemoveAll </td>
|
|
487
|
+
<td> Handler for removing all image </td>
|
|
488
|
+
<td> () => void </td>
|
|
489
|
+
</tr>
|
|
490
|
+
</table>
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
## `FileUpload`
|
|
494
|
+
|
|
495
|
+
### Props
|
|
496
|
+
<table width="100%">
|
|
497
|
+
<tr>
|
|
498
|
+
<th> Name </th>
|
|
499
|
+
<th> Description </th>
|
|
500
|
+
<th> Type </th>
|
|
501
|
+
<th> Default/Required </th>
|
|
502
|
+
</tr>
|
|
503
|
+
<tr>
|
|
504
|
+
<td> inputProps </td>
|
|
505
|
+
<td> Available props for input field </td>
|
|
506
|
+
<td> HTMLProps<HTMLInputElement> </td>
|
|
507
|
+
<td> optional </td>
|
|
508
|
+
</tr>
|
|
509
|
+
<tr>
|
|
510
|
+
<td> acceptType </td>
|
|
511
|
+
<td> File Accept type </td>
|
|
512
|
+
<td> FileAcceptType | Exclude<FileAcceptType, FileAcceptType.ALL>[] </td>
|
|
513
|
+
<td> FileAcceptType.ALL </td>
|
|
514
|
+
</tr>
|
|
515
|
+
<tr>
|
|
516
|
+
<td> maxFileSize </td>
|
|
517
|
+
<td> Max file size validation </td>
|
|
518
|
+
<td> number </td>
|
|
519
|
+
<td> optional </td>
|
|
520
|
+
</tr>
|
|
521
|
+
<tr>
|
|
522
|
+
<td> children </td>
|
|
523
|
+
<td> UI for upload zone or button </td>
|
|
524
|
+
<td> (props: FileExportTypes) => React.ReactNode </td>
|
|
525
|
+
<td> required </td>
|
|
526
|
+
</tr>
|
|
527
|
+
<tr>
|
|
528
|
+
<td> onChange </td>
|
|
529
|
+
<td> File upload listener function </td>
|
|
530
|
+
<td> (value: FileType) => void </td>
|
|
531
|
+
<td> required </td>
|
|
532
|
+
</tr>
|
|
533
|
+
<tr>
|
|
534
|
+
<td> value </td>
|
|
535
|
+
<td> Default Value </td>
|
|
536
|
+
<td> FileType </td>
|
|
537
|
+
<td> required </td>
|
|
538
|
+
</tr>
|
|
539
|
+
<tr>
|
|
540
|
+
<td> onError </td>
|
|
541
|
+
<td> File upload error listener </td>
|
|
542
|
+
<td> (errors: FileErrorTypes) => void; </td>
|
|
543
|
+
<td> optional </td>
|
|
544
|
+
</tr>
|
|
545
|
+
</table>
|
|
546
|
+
|
|
547
|
+
### ImageExportTypes
|
|
548
|
+
<table width="100%">
|
|
549
|
+
<tr>
|
|
550
|
+
<th> dragProps </th>
|
|
551
|
+
<th> Element for implementing drag and drop features </th>
|
|
552
|
+
<th> Object </th>
|
|
553
|
+
</tr>
|
|
554
|
+
<tr>
|
|
555
|
+
<td> isDragging </td>
|
|
556
|
+
<td> Listen is it dragging or not </td>
|
|
557
|
+
<td> boolean </td>
|
|
558
|
+
</tr>
|
|
559
|
+
<tr>
|
|
560
|
+
<td> onImageUpload </td>
|
|
561
|
+
<td> Handler for triggering file upload </td>
|
|
562
|
+
<td> () => void </td>
|
|
563
|
+
</tr>
|
|
564
|
+
<tr>
|
|
565
|
+
<td> fileInfo </td>
|
|
566
|
+
<td> Selected file information </td>
|
|
567
|
+
<td> FileType </td>
|
|
568
|
+
</tr>
|
|
569
|
+
<tr>
|
|
570
|
+
<td> errors </td>
|
|
571
|
+
<td> Error listener </td>
|
|
572
|
+
<td> FileErrorTypes </td>
|
|
573
|
+
</tr>
|
|
574
|
+
<tr>
|
|
575
|
+
<td> onFileRemove </td>
|
|
576
|
+
<td> Handler for removing selected File </td>
|
|
577
|
+
<td> () => void </td>
|
|
578
|
+
</tr>
|
|
579
|
+
</table>
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
## `MultiFileUpload`
|
|
583
|
+
|
|
584
|
+
### Props
|
|
585
|
+
<table width="100%">
|
|
586
|
+
<tr>
|
|
587
|
+
<th> Name </th>
|
|
588
|
+
<th> Description </th>
|
|
589
|
+
<th> Type </th>
|
|
590
|
+
<th> Default/Required </th>
|
|
591
|
+
</tr>
|
|
592
|
+
<tr>
|
|
593
|
+
<td> inputProps </td>
|
|
594
|
+
<td> Available props for input field </td>
|
|
595
|
+
<td> HTMLProps<HTMLInputElement> </td>
|
|
596
|
+
<td> optional </td>
|
|
597
|
+
</tr>
|
|
598
|
+
<tr>
|
|
599
|
+
<td> acceptType </td>
|
|
600
|
+
<td> File Accept type </td>
|
|
601
|
+
<td> FileAcceptType | Exclude<FileAcceptType, FileAcceptType.ALL>[] </td>
|
|
602
|
+
<td> FileAcceptType.ALL </td>
|
|
603
|
+
</tr>
|
|
604
|
+
<tr>
|
|
605
|
+
<td> maxFileSize </td>
|
|
606
|
+
<td> Max file size validation </td>
|
|
607
|
+
<td> number </td>
|
|
608
|
+
<td> optional </td>
|
|
609
|
+
</tr>
|
|
610
|
+
<tr>
|
|
611
|
+
<td> children </td>
|
|
612
|
+
<td> UI for upload zone or button </td>
|
|
613
|
+
<td> (props: MultiFileExportTypes) => React.ReactNode </td>
|
|
614
|
+
<td> required </td>
|
|
615
|
+
</tr>
|
|
616
|
+
<tr>
|
|
617
|
+
<td> onChange </td>
|
|
618
|
+
<td> File upload listener function </td>
|
|
619
|
+
<td> (value: MultiFileType) => void </td>
|
|
620
|
+
<td> required </td>
|
|
621
|
+
</tr>
|
|
622
|
+
<tr>
|
|
623
|
+
<td> value </td>
|
|
624
|
+
<td> Default Value </td>
|
|
625
|
+
<td> MultiFileType </td>
|
|
626
|
+
<td> required </td>
|
|
627
|
+
</tr>
|
|
628
|
+
<tr>
|
|
629
|
+
<td> onError </td>
|
|
630
|
+
<td> File upload error listener </td>
|
|
631
|
+
<td> (errors: MultiFileErrorTypes) => void </td>
|
|
632
|
+
<td> optional </td>
|
|
633
|
+
</tr>
|
|
634
|
+
<tr>
|
|
635
|
+
<td> maxNumber </td>
|
|
636
|
+
<td> Maximum files to be selected </td>
|
|
637
|
+
<td> number </td>
|
|
638
|
+
<td> 10 </td>
|
|
639
|
+
</tr>
|
|
640
|
+
</table>
|
|
641
|
+
|
|
642
|
+
### MultiImageExportTypes
|
|
643
|
+
<table width="100%">
|
|
644
|
+
<tr>
|
|
645
|
+
<th> dragProps </th>
|
|
646
|
+
<th> Element for implementing drag and drop features </th>
|
|
647
|
+
<th> Object </th>
|
|
648
|
+
</tr>
|
|
649
|
+
<tr>
|
|
650
|
+
<td> isDragging </td>
|
|
651
|
+
<td> Listen is it dragging or not </td>
|
|
652
|
+
<td> boolean </td>
|
|
653
|
+
</tr>
|
|
654
|
+
<tr>
|
|
655
|
+
<td> onFileUpload </td>
|
|
656
|
+
<td> Handler for triggering file upload </td>
|
|
657
|
+
<td> () => void </td>
|
|
658
|
+
</tr>
|
|
659
|
+
<tr>
|
|
660
|
+
<td> fileInfo </td>
|
|
661
|
+
<td> Selected file information </td>
|
|
662
|
+
<td> MultiFileType </td>
|
|
663
|
+
</tr>
|
|
664
|
+
<tr>
|
|
665
|
+
<td> errors </td>
|
|
666
|
+
<td> Error listener </td>
|
|
667
|
+
<td> MultiFileErrorTypes </td>
|
|
668
|
+
</tr>
|
|
669
|
+
<tr>
|
|
670
|
+
<td> onFileRemove </td>
|
|
671
|
+
<td> Handler for removing particular file </td>
|
|
672
|
+
<td> (index: number) => void </td>
|
|
673
|
+
</tr>
|
|
674
|
+
<tr>
|
|
675
|
+
<td> onFileUpdate </td>
|
|
676
|
+
<td> Handler for updating a particular file </td>
|
|
677
|
+
<td> (index: number) => void </td>
|
|
678
|
+
</tr>
|
|
679
|
+
<tr>
|
|
680
|
+
<td> onFileRemoveAll </td>
|
|
681
|
+
<td> Handler for removing all file </td>
|
|
682
|
+
<td> () => void </td>
|
|
683
|
+
</tr>
|
|
684
|
+
</table>
|
|
685
|
+
|
|
686
|
+
# Stay in touch
|
|
687
|
+
|
|
688
|
+
- Author - [Siam Ahnaf](https://www.siamahnaf.com/)
|
|
689
|
+
- Website - [https://www.siamahnaf.com/](https://www.siamahnaf.com/)
|
|
690
|
+
- LinkedIn - [https://www.linkedin.com/in/siamahnaf/](https://www.linkedin.com/in/siamahnaf/)
|
|
691
|
+
- Github - [https://github.com/siamahnaf](https://github.com/siamahnaf)
|