@uploadcare/react-uploader 0.5.2 → 0.5.4
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 +1 -1
- package/dist/react-uploader.cjs +1 -1
- package/dist/react-uploader.d.ts +1 -1
- package/dist/react-uploader.js +83 -83
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ import "@uploadcare/react-uploader/core.css";
|
|
|
86
86
|
|
|
87
87
|
An easy way to connect React-Uploader to your project and utilize the available API props.
|
|
88
88
|
We provide a full set of props that are used in blocks. For review we suggest you to look at
|
|
89
|
-
the [documentation]
|
|
89
|
+
the [documentation][uc-docs-file-uploader-options].
|
|
90
90
|
|
|
91
91
|
## Styles
|
|
92
92
|
|
package/dist/react-uploader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),v=require("@uploadcare/blocks");function j(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const i=j(v),I=new Set(["children","ref","style","className"]),x=(e={})=>Object==null?void 0:Object.keys(e).reduce((t,r)=>{var a,l;const o=e==null?void 0:e[r],c=`on${(l=(a=o==null?void 0:o.split("-"))==null?void 0:a.map(s=>s.charAt(0).toUpperCase()+s.slice(1)))==null?void 0:l.join("")}`;return t[c]=o,t},{}),y=new WeakMap,F=e=>{let t=y.get(e);return t===void 0&&(t=new Map,y.set(e,t)),t},A=({node:e,nameProp:t,valueProp:r,prevValueProp:a,event:l})=>{if(l!==void 0){if(r!==a){const o=F(e),c=o.has(l);let s=o.get(l);r!==void 0?c?s.handleEvent=r:(s={handleEvent:r},o.set(l,s),e.addEventListener(l,u=>s.handleEvent(u.detail))):c&&(o.delete(l),e.removeEventListener(l,s))}return}e[t]=r,r==null&&t in HTMLElement.prototype&&e.removeAttribute(t)},R=(e,t,r)=>{const a={},l={};return Object.entries(e).forEach(([o,c])=>{I.has(o)?a[o==="className"?"class":o]=c:t.has(o)||o in r.prototype?l[o]=c:a[o]=c}),{reactProps:a,customElProps:l}},f=({react:e,tag:t,elClass:r,schemaEvents:a})=>{const l=x(a),o=new Set(Object.keys(l??{})),c=e.forwardRef((s,u)=>{const d=e.useRef(new Map),g=e.useRef(null),{reactProps:O,customElProps:w}=R(s,o,r);return e.useLayoutEffect(()=>{if(g.current===null)return;const m=new Map;for(const p in w)A({node:g.current,nameProp:p,valueProp:w[p],prevValueProp:d.current.get(p),event:l[p]}),d.current.delete(p),m.set(p,s[p]);for(const[p,h]of d.current)A({node:g.current,nameProp:p,valueProp:void 0,prevValueProp:h,event:l[p]});d.current=m}),e.createElement(t??r.__tag,{...O,ref:e.useCallback(m=>{g.current=m,typeof u=="function"?u(m):u!==null&&(u.current=m)},[u])})});return c.displayName=r.name,c},E=f({react:n,tag:"lr-config",elClass:i.Config}),P=f({react:n,tag:"lr-upload-ctx-provider",elClass:i.UploadCtxProvider,schemaEvents:i.UploadCtxProvider.EventType}),M=e=>{const t={},r={};return Object.entries(e).forEach(([a,l])=>{a.startsWith("on")?t[a]=l:r[a]=l}),{eventHandlers:t,config:r}},B="0.5.3",T="React-Uploader",U=()=>`${T}/${B}`,b=({children:e})=>e,C=()=>{const[e,t]=n.useState(!1);return n.useEffect(()=>{typeof window<"u"&&t(!0)},[]),e};i.registerBlocks(i);const _=f({react:n,tag:"lr-file-uploader-regular",elClass:i.FileUploaderRegular}),L=({ctxName:e,className:t,classNameUploader:r,apiRef:a,fallback:l,...o})=>{const c=n.useMemo(()=>e??i.UID.generate(),[e]),{eventHandlers:s,config:u}=n.useMemo(()=>M(o),[o]),d=C();return n.createElement(b,{condition:d,fallback:l},n.createElement("div",{className:t},n.createElement(E,{userAgentIntegration:U(),"ctx-name":c,...u}),n.createElement(P,{ref:a,"ctx-name":c,...s}),n.createElement(_,{class:r,"ctx-name":c})))};i.registerBlocks(i);const S=f({react:n,tag:"lr-file-uploader-minimal",elClass:i.FileUploaderMinimal}),N=({ctxName:e,className:t,classNameUploader:r,apiRef:a,fallback:l,...o})=>{const c=n.useMemo(()=>e??i.UID.generate(),[e]),{eventHandlers:s,config:u}=n.useMemo(()=>M(o),[o]),d=C();return n.createElement(b,{condition:d,fallback:l},n.createElement("div",{className:t},n.createElement(E,{userAgentIntegration:U(),"ctx-name":c,...u}),n.createElement(P,{ref:a,"ctx-name":c,...s}),n.createElement(S,{class:r,"ctx-name":c})))};i.registerBlocks(i);const k=f({react:n,tag:"lr-file-uploader-inline",elClass:i.FileUploaderMinimal}),D=({ctxName:e,className:t,classNameUploader:r,apiRef:a,fallback:l,...o})=>{const c=n.useMemo(()=>e??i.UID.generate(),[e]),{eventHandlers:s,config:u}=n.useMemo(()=>M(o),[o]),d=C();return n.createElement(b,{condition:d,fallback:l},n.createElement("div",{className:t},n.createElement(E,{userAgentIntegration:U(),"ctx-name":c,...u}),n.createElement(P,{ref:a,"ctx-name":c,...s}),n.createElement(k,{class:r,"ctx-name":c})))};Object.defineProperty(exports,"UploadCtxProvider",{enumerable:!0,get:()=>v.UploadCtxProvider});Object.defineProperty(exports,"defineLocale",{enumerable:!0,get:()=>v.defineLocale});exports.FileUploaderInline=D;exports.FileUploaderMinimal=N;exports.FileUploaderRegular=L;
|
package/dist/react-uploader.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare type TProps = TDefaultProps & TRefUploadCtxProvider & TPropsWithE
|
|
|
32
32
|
|
|
33
33
|
declare type TProps_2 = {
|
|
34
34
|
fallback?: React_2.ReactChild | React_2.ReactFragment | React_2.ReactPortal | null;
|
|
35
|
-
condition
|
|
35
|
+
condition?: boolean;
|
|
36
36
|
children: React_2.ReactNode;
|
|
37
37
|
};
|
|
38
38
|
|
package/dist/react-uploader.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import
|
|
1
|
+
import s, { useState as B, useEffect as F, useMemo as f } from "react";
|
|
2
2
|
import * as i from "@uploadcare/blocks";
|
|
3
|
-
import { UploadCtxProvider as
|
|
4
|
-
const
|
|
3
|
+
import { UploadCtxProvider as W, defineLocale as q } from "@uploadcare/blocks";
|
|
4
|
+
const R = /* @__PURE__ */ new Set([
|
|
5
5
|
"children",
|
|
6
6
|
"ref",
|
|
7
7
|
"style",
|
|
8
8
|
"className"
|
|
9
|
-
]),
|
|
10
|
-
var
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
}, {}), h = /* @__PURE__ */ new WeakMap(),
|
|
14
|
-
let
|
|
15
|
-
return
|
|
9
|
+
]), b = (e = {}) => Object == null ? void 0 : Object.keys(e).reduce((r, o) => {
|
|
10
|
+
var a, n;
|
|
11
|
+
const t = e == null ? void 0 : e[o], l = `on${(n = (a = t == null ? void 0 : t.split("-")) == null ? void 0 : a.map((c) => c.charAt(0).toUpperCase() + c.slice(1))) == null ? void 0 : n.join("")}`;
|
|
12
|
+
return r[l] = t, r;
|
|
13
|
+
}, {}), h = /* @__PURE__ */ new WeakMap(), O = (e) => {
|
|
14
|
+
let r = h.get(e);
|
|
15
|
+
return r === void 0 && (r = /* @__PURE__ */ new Map(), h.set(e, r)), r;
|
|
16
16
|
}, x = ({
|
|
17
17
|
node: e,
|
|
18
|
-
nameProp:
|
|
18
|
+
nameProp: r,
|
|
19
19
|
valueProp: o,
|
|
20
|
-
prevValueProp:
|
|
20
|
+
prevValueProp: a,
|
|
21
21
|
event: n
|
|
22
22
|
}) => {
|
|
23
23
|
if (n !== void 0) {
|
|
24
|
-
if (o !==
|
|
25
|
-
const
|
|
26
|
-
let c =
|
|
27
|
-
o !== void 0 ? l ? c.handleEvent = o : (c = { handleEvent: o },
|
|
24
|
+
if (o !== a) {
|
|
25
|
+
const t = O(e), l = t.has(n);
|
|
26
|
+
let c = t.get(n);
|
|
27
|
+
o !== void 0 ? l ? c.handleEvent = o : (c = { handleEvent: o }, t.set(n, c), e.addEventListener(
|
|
28
28
|
n,
|
|
29
29
|
(d) => c.handleEvent(d.detail)
|
|
30
|
-
)) : l && (
|
|
30
|
+
)) : l && (t.delete(n), e.removeEventListener(n, c));
|
|
31
31
|
}
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
e[
|
|
35
|
-
},
|
|
36
|
-
const
|
|
37
|
-
return Object.entries(e).forEach(([
|
|
38
|
-
|
|
39
|
-
}), { reactProps:
|
|
34
|
+
e[r] = o, o == null && r in HTMLElement.prototype && e.removeAttribute(r);
|
|
35
|
+
}, T = (e, r, o) => {
|
|
36
|
+
const a = {}, n = {};
|
|
37
|
+
return Object.entries(e).forEach(([t, l]) => {
|
|
38
|
+
R.has(t) ? a[t === "className" ? "class" : t] = l : r.has(t) || t in o.prototype ? n[t] = l : a[t] = l;
|
|
39
|
+
}), { reactProps: a, customElProps: n };
|
|
40
40
|
}, v = ({
|
|
41
41
|
react: e,
|
|
42
42
|
// https://react.dev/warnings/invalid-hook-call-warning
|
|
43
|
-
tag:
|
|
43
|
+
tag: r,
|
|
44
44
|
elClass: o,
|
|
45
|
-
schemaEvents:
|
|
45
|
+
schemaEvents: a
|
|
46
46
|
}) => {
|
|
47
|
-
const n =
|
|
47
|
+
const n = b(a), t = new Set(Object.keys(n ?? {})), l = e.forwardRef(
|
|
48
48
|
(c, d) => {
|
|
49
|
-
const u = e.useRef(/* @__PURE__ */ new Map()),
|
|
49
|
+
const u = e.useRef(/* @__PURE__ */ new Map()), g = e.useRef(null), { reactProps: I, customElProps: M } = T(c, t, o);
|
|
50
50
|
return e.useLayoutEffect(() => {
|
|
51
|
-
if (
|
|
51
|
+
if (g.current === null)
|
|
52
52
|
return;
|
|
53
53
|
const m = /* @__PURE__ */ new Map();
|
|
54
54
|
for (const p in M)
|
|
55
55
|
x({
|
|
56
|
-
node:
|
|
56
|
+
node: g.current,
|
|
57
57
|
nameProp: p,
|
|
58
58
|
valueProp: M[p],
|
|
59
59
|
prevValueProp: u.current.get(p),
|
|
60
60
|
event: n[p]
|
|
61
61
|
}), u.current.delete(p), m.set(p, c[p]);
|
|
62
|
-
for (const [p,
|
|
62
|
+
for (const [p, y] of u.current)
|
|
63
63
|
x({
|
|
64
|
-
node:
|
|
64
|
+
node: g.current,
|
|
65
65
|
nameProp: p,
|
|
66
66
|
valueProp: void 0,
|
|
67
|
-
prevValueProp:
|
|
67
|
+
prevValueProp: y,
|
|
68
68
|
event: n[p]
|
|
69
69
|
});
|
|
70
70
|
u.current = m;
|
|
71
|
-
}), e.createElement(
|
|
71
|
+
}), e.createElement(r ?? o.__tag, {
|
|
72
72
|
...I,
|
|
73
73
|
ref: e.useCallback(
|
|
74
74
|
(m) => {
|
|
75
|
-
|
|
75
|
+
g.current = m, typeof d == "function" ? d(m) : d !== null && (d.current = m);
|
|
76
76
|
},
|
|
77
77
|
[d]
|
|
78
78
|
)
|
|
@@ -80,111 +80,111 @@ const b = /* @__PURE__ */ new Set([
|
|
|
80
80
|
}
|
|
81
81
|
);
|
|
82
82
|
return l.displayName = o.name, l;
|
|
83
|
-
},
|
|
84
|
-
react:
|
|
83
|
+
}, E = v({
|
|
84
|
+
react: s,
|
|
85
85
|
tag: "lr-config",
|
|
86
86
|
elClass: i.Config
|
|
87
87
|
}), P = v({
|
|
88
|
-
react:
|
|
88
|
+
react: s,
|
|
89
89
|
tag: "lr-upload-ctx-provider",
|
|
90
90
|
elClass: i.UploadCtxProvider,
|
|
91
91
|
schemaEvents: i.UploadCtxProvider.EventType
|
|
92
92
|
}), C = (e) => {
|
|
93
|
-
const
|
|
94
|
-
return Object.entries(e).forEach(([
|
|
95
|
-
|
|
93
|
+
const r = {}, o = {};
|
|
94
|
+
return Object.entries(e).forEach(([a, n]) => {
|
|
95
|
+
a.startsWith("on") ? r[a] = n : o[a] = n;
|
|
96
96
|
}), {
|
|
97
|
-
eventHandlers:
|
|
97
|
+
eventHandlers: r,
|
|
98
98
|
config: o
|
|
99
99
|
};
|
|
100
|
-
},
|
|
101
|
-
const [e,
|
|
102
|
-
return
|
|
103
|
-
typeof window < "u" &&
|
|
100
|
+
}, j = "0.5.3", L = "React-Uploader", U = () => `${L}/${j}`, w = ({ children: e }) => e, A = () => {
|
|
101
|
+
const [e, r] = B(!1);
|
|
102
|
+
return F(() => {
|
|
103
|
+
typeof window < "u" && r(!0);
|
|
104
104
|
}, []), e;
|
|
105
105
|
};
|
|
106
106
|
i.registerBlocks(i);
|
|
107
|
-
const
|
|
108
|
-
react:
|
|
107
|
+
const N = v({
|
|
108
|
+
react: s,
|
|
109
109
|
tag: "lr-file-uploader-regular",
|
|
110
110
|
elClass: i.FileUploaderRegular
|
|
111
|
-
}),
|
|
111
|
+
}), S = ({
|
|
112
112
|
ctxName: e,
|
|
113
|
-
className:
|
|
113
|
+
className: r,
|
|
114
114
|
classNameUploader: o,
|
|
115
|
-
apiRef:
|
|
115
|
+
apiRef: a,
|
|
116
116
|
fallback: n,
|
|
117
|
-
...
|
|
117
|
+
...t
|
|
118
118
|
}) => {
|
|
119
119
|
const l = f(() => e ?? i.UID.generate(), [e]), { eventHandlers: c, config: d } = f(
|
|
120
|
-
() => C(
|
|
121
|
-
[
|
|
120
|
+
() => C(t),
|
|
121
|
+
[t]
|
|
122
122
|
), u = A();
|
|
123
|
-
return /* @__PURE__ */
|
|
123
|
+
return /* @__PURE__ */ s.createElement(w, { condition: u, fallback: n }, /* @__PURE__ */ s.createElement("div", { className: r }, /* @__PURE__ */ s.createElement(E, { userAgentIntegration: U(), "ctx-name": l, ...d }), /* @__PURE__ */ s.createElement(
|
|
124
124
|
P,
|
|
125
125
|
{
|
|
126
|
-
ref:
|
|
126
|
+
ref: a,
|
|
127
127
|
"ctx-name": l,
|
|
128
128
|
...c
|
|
129
129
|
}
|
|
130
|
-
), /* @__PURE__ */
|
|
130
|
+
), /* @__PURE__ */ s.createElement(N, { class: o, "ctx-name": l })));
|
|
131
131
|
};
|
|
132
132
|
i.registerBlocks(i);
|
|
133
|
-
const
|
|
134
|
-
react:
|
|
133
|
+
const _ = v({
|
|
134
|
+
react: s,
|
|
135
135
|
tag: "lr-file-uploader-minimal",
|
|
136
136
|
elClass: i.FileUploaderMinimal
|
|
137
|
-
}),
|
|
137
|
+
}), X = ({
|
|
138
138
|
ctxName: e,
|
|
139
|
-
className:
|
|
139
|
+
className: r,
|
|
140
140
|
classNameUploader: o,
|
|
141
|
-
apiRef:
|
|
141
|
+
apiRef: a,
|
|
142
142
|
fallback: n,
|
|
143
|
-
...
|
|
143
|
+
...t
|
|
144
144
|
}) => {
|
|
145
145
|
const l = f(() => e ?? i.UID.generate(), [e]), { eventHandlers: c, config: d } = f(
|
|
146
|
-
() => C(
|
|
147
|
-
[
|
|
146
|
+
() => C(t),
|
|
147
|
+
[t]
|
|
148
148
|
), u = A();
|
|
149
|
-
return /* @__PURE__ */
|
|
149
|
+
return /* @__PURE__ */ s.createElement(w, { condition: u, fallback: n }, /* @__PURE__ */ s.createElement("div", { className: r }, /* @__PURE__ */ s.createElement(E, { userAgentIntegration: U(), "ctx-name": l, ...d }), /* @__PURE__ */ s.createElement(
|
|
150
150
|
P,
|
|
151
151
|
{
|
|
152
|
-
ref:
|
|
152
|
+
ref: a,
|
|
153
153
|
"ctx-name": l,
|
|
154
154
|
...c
|
|
155
155
|
}
|
|
156
|
-
), /* @__PURE__ */
|
|
156
|
+
), /* @__PURE__ */ s.createElement(_, { class: o, "ctx-name": l })));
|
|
157
157
|
};
|
|
158
158
|
i.registerBlocks(i);
|
|
159
|
-
const
|
|
160
|
-
react:
|
|
159
|
+
const k = v({
|
|
160
|
+
react: s,
|
|
161
161
|
tag: "lr-file-uploader-inline",
|
|
162
162
|
elClass: i.FileUploaderMinimal
|
|
163
|
-
}),
|
|
163
|
+
}), D = ({
|
|
164
164
|
ctxName: e,
|
|
165
|
-
className:
|
|
165
|
+
className: r,
|
|
166
166
|
classNameUploader: o,
|
|
167
|
-
apiRef:
|
|
167
|
+
apiRef: a,
|
|
168
168
|
fallback: n,
|
|
169
|
-
...
|
|
169
|
+
...t
|
|
170
170
|
}) => {
|
|
171
171
|
const l = f(() => e ?? i.UID.generate(), [e]), { eventHandlers: c, config: d } = f(
|
|
172
|
-
() => C(
|
|
173
|
-
[
|
|
172
|
+
() => C(t),
|
|
173
|
+
[t]
|
|
174
174
|
), u = A();
|
|
175
|
-
return /* @__PURE__ */
|
|
175
|
+
return /* @__PURE__ */ s.createElement(w, { condition: u, fallback: n }, /* @__PURE__ */ s.createElement("div", { className: r }, /* @__PURE__ */ s.createElement(E, { userAgentIntegration: U(), "ctx-name": l, ...d }), /* @__PURE__ */ s.createElement(
|
|
176
176
|
P,
|
|
177
177
|
{
|
|
178
|
-
ref:
|
|
178
|
+
ref: a,
|
|
179
179
|
"ctx-name": l,
|
|
180
180
|
...c
|
|
181
181
|
}
|
|
182
|
-
), /* @__PURE__ */
|
|
182
|
+
), /* @__PURE__ */ s.createElement(k, { class: o, "ctx-name": l })));
|
|
183
183
|
};
|
|
184
184
|
export {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
D as FileUploaderInline,
|
|
186
|
+
X as FileUploaderMinimal,
|
|
187
|
+
S as FileUploaderRegular,
|
|
188
|
+
W as UploadCtxProvider,
|
|
189
|
+
q as defineLocale
|
|
190
190
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadcare/react-uploader",
|
|
3
3
|
"description": "React component for file uploads using Uploadcare",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"react hook file upload",
|
|
82
82
|
"front-end"
|
|
83
83
|
],
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "4e93391fad463da99edc41a4a2ae8e84d61b9c9c"
|
|
85
85
|
}
|