@uploadcare/react-uploader 0.0.1-alpha.4 → 0.2.0-alpha.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/LICENSE +21 -0
- package/README.md +75 -11
- package/dist/react-uploader.cjs +30 -30
- package/dist/react-uploader.d.ts +10 -5
- package/dist/react-uploader.js +621 -606
- package/package.json +52 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Uploadcare Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -6,9 +6,14 @@
|
|
|
6
6
|
alt="">
|
|
7
7
|
</a>
|
|
8
8
|
|
|
9
|
-
Uploadcare React Uploader.
|
|
9
|
+
Uploadcare React Uploader. Allows you to use Uploader in React applications according to React canons.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
[![Build Status][badge-build]][build-url]
|
|
13
|
+
[![NPM version][npm-img]][npm-url]
|
|
14
|
+
[![GitHub release][badge-release-img]][badge-release-url]
|
|
15
|
+
[![Uploadcare stack on StackShare][badge-stack-img]][badge-stack-url]
|
|
10
16
|
|
|
11
|
-
### (@TODO: Add a link to the documentation)
|
|
12
17
|
|
|
13
18
|
## Install
|
|
14
19
|
|
|
@@ -16,19 +21,74 @@ Uploadcare React Uploader.
|
|
|
16
21
|
npm i @uploadcare/react-uploader
|
|
17
22
|
```
|
|
18
23
|
|
|
19
|
-
|
|
20
24
|
## Usage
|
|
21
25
|
|
|
22
26
|
```jsx
|
|
23
|
-
import { FileUploaderRegular
|
|
27
|
+
import { FileUploaderRegular } from "@uploadcare/react-uploader";
|
|
28
|
+
|
|
29
|
+
<FileUploaderRegular pubkey="YOUR_PUBLIC_KEY"/>;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## File Uploader API
|
|
33
|
+
|
|
34
|
+
It is possible to get ref on UploadCtxProvider via `ref`. In this way it is possible to additional uploader management
|
|
35
|
+
methods.
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import React, { useRef } from "react";
|
|
39
|
+
import {
|
|
40
|
+
FileUploaderRegular,
|
|
41
|
+
UploadCtxProvider
|
|
42
|
+
} from "@uploadcare/react-uploader";
|
|
24
43
|
|
|
25
|
-
|
|
44
|
+
const uploaderRef = useRef<InstanceType<UploadCtxProvider> | null>(null);
|
|
26
45
|
|
|
27
|
-
<
|
|
46
|
+
<FileUploaderRegular refUploadCtxProvider={uploaderRef} pubkey="YOUR_PUBLIC_KEY"/>;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Events
|
|
50
|
+
|
|
51
|
+
Events in React Uploader are the same as in blocks, see the [documentation][uc-docs-events].
|
|
52
|
+
The principle of converting events from blocks to React Uploader:
|
|
53
|
+
|
|
54
|
+
1. All events in React Uploader start with `on`.
|
|
55
|
+
2. All events in React Uploader in `camelCase`.
|
|
56
|
+
|
|
57
|
+
Example:
|
|
28
58
|
|
|
29
|
-
|
|
59
|
+
```jsx
|
|
60
|
+
import { FileUploaderRegular } from "@uploadcare/react-uploader";
|
|
61
|
+
|
|
62
|
+
<FileUploaderRegular
|
|
63
|
+
pubkey="YOUR_PUBLIC_KEY"
|
|
64
|
+
onModalOpen={() => {
|
|
65
|
+
console.log('modal-open')
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
30
68
|
```
|
|
31
69
|
|
|
70
|
+
### Table of events
|
|
71
|
+
|
|
72
|
+
| Events blocks | Events React Uploader |
|
|
73
|
+
|------------------------|------------------------|
|
|
74
|
+
| file-added | onFileAdded |
|
|
75
|
+
| file-removed | onFileRemoved |
|
|
76
|
+
| file-upload-start | onFileUploadStart |
|
|
77
|
+
| file-upload-progress | onFileUploadProgress |
|
|
78
|
+
| file-upload-success | onFileUploadSuccess |
|
|
79
|
+
| file-upload-failed | onFileUploadFailed |
|
|
80
|
+
| file-url-changed | onFileUrlChanged |
|
|
81
|
+
| modal-open | onModalOpen |
|
|
82
|
+
| modal-close | onModalClose |
|
|
83
|
+
| done-click | onDoneClick |
|
|
84
|
+
| upload-click | onUploadClick |
|
|
85
|
+
| activity-change | onActivityChange |
|
|
86
|
+
| common-upload-start | onCommonUploadStart |
|
|
87
|
+
| common-upload-progress | onCommonUploadProgress |
|
|
88
|
+
| common-upload-success | onCommonUploadSuccess |
|
|
89
|
+
| common-upload-failed | onCommonUploadFailed |
|
|
90
|
+
| change | onChange |
|
|
91
|
+
| group-created | onGroupCreated |
|
|
32
92
|
|
|
33
93
|
## Security issues
|
|
34
94
|
|
|
@@ -49,8 +109,12 @@ request at [hello@uploadcare.com][uc-email-hello].
|
|
|
49
109
|
[uc-email-hello]: mailto:hello@uploadcare.com
|
|
50
110
|
|
|
51
111
|
[badge-stack-img]: https://img.shields.io/badge/tech-stack-0690fa.svg?style=flat
|
|
52
|
-
|
|
53
112
|
[badge-stack-url]: https://stackshare.io/uploadcare/stacks/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[
|
|
113
|
+
[badge-release-img]: https://img.shields.io/github/release/uploadcare/react-components.svg
|
|
114
|
+
[badge-release-url]: https://github.com/uploadcare/react-components/releases
|
|
115
|
+
[npm-img]: http://img.shields.io/npm/v/@uploadcare/react-uploader.svg
|
|
116
|
+
[npm-url]: https://www.npmjs.com/package/@uploadcare/react-uploader
|
|
117
|
+
[badge-build]: https://github.com/uploadcare/react-components/actions/workflows/checks.yml/badge.svg
|
|
118
|
+
[build-url]: https://github.com/uploadcare/react-components/actions/workflows/checks.yml
|
|
119
|
+
|
|
120
|
+
[uc-docs-events]: https://uploadcare.com/docs/file-uploader/events/
|