@uploadcare/react-uploader 0.0.1-alpha.4 → 0.0.1-alpha.5

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 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, FileUploaderMinimal, FileUploaderInline } from "@uploadcare/react-uploader";
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
- <FileUploaderRegular pubkey="YOUR_PUBLIC_KEY" />;
44
+ const uploaderRef = useRef<InstanceType<UploadCtxProvider> | null>(null);
26
45
 
27
- <FileUploaderMinimal pubkey="YOUR_PUBLIC_KEY" />;
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
- <FileUploaderInline pubkey="YOUR_PUBLIC_KEY" />;
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
- [uc-docs-metadata]: https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File-Metadata
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/