@osmandvc/react-upload-control 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
package/README.md
CHANGED
@@ -1,14 +1,37 @@
|
|
1
1
|
# React Upload Control
|
2
2
|
|
3
|
-
|
3
|
+
[![npm version](https://img.shields.io/npm/v/@osmandvc/react-upload-control.svg)](https://www.npmjs.com/package/@osmandvc/react-upload-control)
|
4
|
+
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
|
5
|
+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
4
6
|
|
5
|
-
|
7
|
+
A modern, flexible file upload control for React applications.
|
6
8
|
|
7
9
|
React Upload Control is a free, lightweight and open-source file uploader library designed for modern React applications. This library is crafted to provide a high-quality developer experience (DX), making it easy to use for simple file uploads while offering extensive customization options for advanced use cases.
|
8
10
|
|
11
|
+
## Demo
|
12
|
+
|
13
|
+
Check out our interactive demo cases here:
|
14
|
+
[React Upload Control Demo](https://675c9582166050575d7b72e2-bzirycxazq.chromatic.com)
|
15
|
+
|
16
|
+
## Why React Upload Control? 🤷♂️
|
17
|
+
|
18
|
+
Born from real-world needs in a production environment, React Upload Control addresses common limitations found in existing file upload solutions. While there are many file upload libraries available, we found that most of them fell short in crucial areas:
|
19
|
+
|
20
|
+
- 🔄 **No Drag-to-Reorder:** Most solutions lack built-in file ordering capabilities, a crucial feature for many applications
|
21
|
+
- 📚 **Documentation Gaps:** Many libraries either have excessive boilerplate, insufficient documentation or lacking DX
|
22
|
+
- 🔧 **Maintenance Issues:** Several options are outdated or no longer actively maintained
|
23
|
+
- 🎨 **Poor UI/UX:** Many unstyled options result in subpar user interfaces
|
24
|
+
- 🔒 **Vendor Lock-in:** Some solutions tie you to specific cloud services or platforms
|
25
|
+
- 📦 **Bloated Dependencies:** Often file uploaders come bundled within larger UI libraries, increasing your bundle size
|
26
|
+
|
27
|
+
React Upload Control was created to solve these problems, offering a standalone, modern file uploader that's both powerful and flexible. Whether you need a simple file upload control or a feature-rich solution with file processing capabilities, you can customize it to your specific needs without compromising on quality or developer experience.
|
28
|
+
|
29
|
+
## Features summary 🔥
|
30
|
+
|
9
31
|
- 🚀 **Modern Stack:** Built with React 18+ and TypeScript for type-safe development
|
10
32
|
- 📁 **Drag & Drop:** Intuitive file uploading with visual feedback and validation
|
11
33
|
- 📋 **File Management:** Drag-to-reorder capability for organizing user uploads
|
34
|
+
- 🔄 **File Processing:** Optional pre/post-processing capabilities with [@osmandvc/react-upload-control-processors](https://www.npmjs.com/package/@osmandvc/react-upload-control-processors) or custom integrations
|
12
35
|
- 📷 **Camera Integration:** Camera integration for capturing photos directly
|
13
36
|
- 💻 **Developer Experience:** Simple API with comprehensive TypeScript support and documentation
|
14
37
|
- 🌐 **Internationalization:** Built-in i18n support for multiple languages (currently English and German)
|
@@ -19,11 +42,6 @@ React Upload Control is a free, lightweight and open-source file uploader librar
|
|
19
42
|
- ⚙️ **Unopinionated:** You decide how and where files are uploaded, no vendor lock-in
|
20
43
|
- 🔓 **Open Source:** Free to use and modify under the MIT license
|
21
44
|
|
22
|
-
## Demo
|
23
|
-
|
24
|
-
Check out our interactive demo cases here:
|
25
|
-
[React Upload Control Demo](https://675c9582166050575d7b72e2-kpevajcgoj.chromatic.com/)
|
26
|
-
|
27
45
|
## Installation
|
28
46
|
|
29
47
|
To install React Upload Control, use npm or yarn:
|
@@ -386,6 +404,50 @@ interface UploadedFile {
|
|
386
404
|
}
|
387
405
|
```
|
388
406
|
|
407
|
+
## File Processing
|
408
|
+
|
409
|
+
React Upload Control supports file processing through the optional [@osmandvc/react-upload-control-processors](https://www.npmjs.com/package/@osmandvc/react-upload-control-processors) package. This enables you to process files before or after upload, with built-in support for PDF manipulation and extensible architecture for custom processors.
|
410
|
+
|
411
|
+
```bash
|
412
|
+
npm install @osmandvc/react-upload-control-processors
|
413
|
+
```
|
414
|
+
|
415
|
+
### Example: PDF to JPEG Conversion
|
416
|
+
|
417
|
+
```tsx
|
418
|
+
import {
|
419
|
+
FileUploadControl,
|
420
|
+
UploadedFile,
|
421
|
+
UploadedFilesProvider,
|
422
|
+
UploadFileResult,
|
423
|
+
} from "@osmandvc/react-upload-control";
|
424
|
+
import { processPdfToJpeg } from "@osmandvc/react-upload-control-processors";
|
425
|
+
|
426
|
+
function FileUploadTest() {
|
427
|
+
return (
|
428
|
+
<div className="max-w-lg">
|
429
|
+
<UploadedFilesProvider
|
430
|
+
config={{
|
431
|
+
mimeTypes: ["image/png", "image/jpeg", "application/pdf"],
|
432
|
+
disableSorting: true,
|
433
|
+
}}
|
434
|
+
handlers={{
|
435
|
+
onUpload: handleUpload,
|
436
|
+
onFinish: handleFinish,
|
437
|
+
preProcessFiles: {
|
438
|
+
"application/pdf": processPdfToJpeg,
|
439
|
+
},
|
440
|
+
}}
|
441
|
+
>
|
442
|
+
<FileUploadControl />
|
443
|
+
</UploadedFilesProvider>
|
444
|
+
</div>
|
445
|
+
);
|
446
|
+
}
|
447
|
+
```
|
448
|
+
|
449
|
+
You can see a demo of this in action [here](https://675c9582166050575d7b72e2-bzirycxazq.chromatic.com/?path=/story/examples-upload-control-with-pdf-pre-processing--default).
|
450
|
+
|
389
451
|
## Creating Custom Upload Sources and Destinations
|
390
452
|
|
391
453
|
The `useUploadFilesProvider` hook allows you to create your own file sources (like drop areas) and file destinations (like file lists) with ease. The provider handles all the complex validation and state management for you.
|