@uploadcare/react-uploader 0.4.0-alpha.2 → 0.5.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/dist/react-uploader.cjs +1 -1
- package/dist/react-uploader.js +10 -10
- package/package.json +4 -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/dist/react-uploader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),v=require("@uploadcare/blocks");function j(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const i=j(v),F=new Set(["children","ref","style","className"]),I=(e={})=>Object==null?void 0:Object.keys(e).reduce((t,n)=>{var a,l;const o=e==null?void 0:e[n],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,x=e=>{let t=y.get(e);return t===void 0&&(t=new Map,y.set(e,t)),t},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),v=require("@uploadcare/blocks");function j(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const i=j(v),F=new Set(["children","ref","style","className"]),I=(e={})=>Object==null?void 0:Object.keys(e).reduce((t,n)=>{var a,l;const o=e==null?void 0:e[n],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,x=e=>{let t=y.get(e);return t===void 0&&(t=new Map,y.set(e,t)),t},A=({node:e,nameProp:t,valueProp:n,prevValueProp:a,event:l})=>{if(l!==void 0){if(n!==a){const o=x(e),c=o.has(l);let s=o.get(l);n!==void 0?c?s.handleEvent=n:(s={handleEvent:n},o.set(l,s),e.addEventListener(l,u=>s.handleEvent(u.detail))):c&&(o.delete(l),e.removeEventListener(l,s))}return}e[t]=n,n==null&&t in HTMLElement.prototype&&e.removeAttribute(t)},R=(e,t,n)=>{const a={},l={};return Object.entries(e).forEach(([o,c])=>{F.has(o)?a[o==="className"?"class":o]=c:t.has(o)||o in n.prototype?l[o]=c:a[o]=c}),{reactProps:a,customElProps:l}},f=({react:e,tag:t,elClass:n,schemaEvents:a})=>{const l=I(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,n);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??n.__tag,{...O,ref:e.useCallback(m=>{g.current=m,typeof u=="function"?u(m):u!==null&&(u.current=m)},[u])})});return c.displayName=n.name,c},E=f({react:r,tag:"lr-config",elClass:i.Config}),P=f({react:r,tag:"lr-upload-ctx-provider",elClass:i.UploadCtxProvider,schemaEvents:i.UploadCtxProvider.EventType}),M=e=>{const t={},n={};return Object.entries(e).forEach(([a,l])=>{a.startsWith("on")?t[a]=l:n[a]=l}),{eventHandlers:t,config:n}},B="0.4.0",S="React-Uploader",U=()=>`${S}/${B}`,C=({condition:e,fallback:t,children:n,...a})=>e?r.createElement(r.Suspense,{fallback:t,...a},n):r.createElement(r.Fragment,null,t),b=()=>{const[e,t]=r.useState(!1);return r.useEffect(()=>{typeof window<"u"&&t(!0)},[]),e};i.registerBlocks(i);const T=f({react:r,tag:"lr-file-uploader-regular",elClass:i.FileUploaderRegular}),_=({ctxName:e,className:t,classNameUploader:n,apiRef:a,fallback:l,...o})=>{const c=r.useMemo(()=>e??i.UID.generate(),[e]),{eventHandlers:s,config:u}=r.useMemo(()=>M(o),[o]),d=b();return r.createElement(C,{condition:d,fallback:l},r.createElement("div",{className:t},r.createElement(E,{userAgentIntegration:U(),"ctx-name":c,...u}),r.createElement(P,{ref:a,"ctx-name":c,...s}),r.createElement(T,{class:n,"ctx-name":c})))};i.registerBlocks(i);const L=f({react:r,tag:"lr-file-uploader-minimal",elClass:i.FileUploaderMinimal}),N=({ctxName:e,className:t,classNameUploader:n,apiRef:a,fallback:l,...o})=>{const c=r.useMemo(()=>e??i.UID.generate(),[e]),{eventHandlers:s,config:u}=r.useMemo(()=>M(o),[o]),d=b();return r.createElement(C,{condition:d,fallback:l},r.createElement("div",{className:t},r.createElement(E,{userAgentIntegration:U(),"ctx-name":c,...u}),r.createElement(P,{ref:a,"ctx-name":c,...s}),r.createElement(L,{class:n,"ctx-name":c})))};i.registerBlocks(i);const k=f({react:r,tag:"lr-file-uploader-inline",elClass:i.FileUploaderMinimal}),D=({ctxName:e,className:t,classNameUploader:n,apiRef:a,fallback:l,...o})=>{const c=r.useMemo(()=>e??i.UID.generate(),[e]),{eventHandlers:s,config:u}=r.useMemo(()=>M(o),[o]),d=b();return r.createElement(C,{condition:d,fallback:l},r.createElement("div",{className:t},r.createElement(E,{userAgentIntegration:U(),"ctx-name":c,...u}),r.createElement(P,{ref:a,"ctx-name":c,...s}),r.createElement(k,{class:n,"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=_;
|
package/dist/react-uploader.js
CHANGED
|
@@ -10,9 +10,9 @@ const b = /* @__PURE__ */ new Set([
|
|
|
10
10
|
var s, n;
|
|
11
11
|
const r = e == null ? void 0 : e[o], l = `on${(n = (s = r == null ? void 0 : r.split("-")) == null ? void 0 : s.map((c) => c.charAt(0).toUpperCase() + c.slice(1))) == null ? void 0 : n.join("")}`;
|
|
12
12
|
return t[l] = r, t;
|
|
13
|
-
}, {}),
|
|
14
|
-
let t =
|
|
15
|
-
return t === void 0 && (t = /* @__PURE__ */ new Map(),
|
|
13
|
+
}, {}), h = /* @__PURE__ */ new WeakMap(), T = (e) => {
|
|
14
|
+
let t = h.get(e);
|
|
15
|
+
return t === void 0 && (t = /* @__PURE__ */ new Map(), h.set(e, t)), t;
|
|
16
16
|
}, x = ({
|
|
17
17
|
node: e,
|
|
18
18
|
nameProp: t,
|
|
@@ -46,16 +46,16 @@ const b = /* @__PURE__ */ new Set([
|
|
|
46
46
|
}) => {
|
|
47
47
|
const n = O(s), r = new Set(Object.keys(n ?? {})), l = e.forwardRef(
|
|
48
48
|
(c, d) => {
|
|
49
|
-
const u = e.useRef(/* @__PURE__ */ new Map()), E = e.useRef(null), { reactProps: I, customElProps:
|
|
49
|
+
const u = e.useRef(/* @__PURE__ */ new Map()), E = e.useRef(null), { reactProps: I, customElProps: M } = j(c, r, o);
|
|
50
50
|
return e.useLayoutEffect(() => {
|
|
51
51
|
if (E.current === null)
|
|
52
52
|
return;
|
|
53
53
|
const m = /* @__PURE__ */ new Map();
|
|
54
|
-
for (const p in
|
|
54
|
+
for (const p in M)
|
|
55
55
|
x({
|
|
56
56
|
node: E.current,
|
|
57
57
|
nameProp: p,
|
|
58
|
-
valueProp:
|
|
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]);
|
|
@@ -97,7 +97,7 @@ const b = /* @__PURE__ */ new Set([
|
|
|
97
97
|
eventHandlers: t,
|
|
98
98
|
config: o
|
|
99
99
|
};
|
|
100
|
-
}, L = "0.4.0
|
|
100
|
+
}, L = "0.4.0", N = "React-Uploader", U = () => `${N}/${L}`, w = ({ condition: e, fallback: t, children: o, ...s }) => e ? /* @__PURE__ */ a.createElement(y, { fallback: t, ...s }, o) : /* @__PURE__ */ a.createElement(a.Fragment, null, t), A = () => {
|
|
101
101
|
const [e, t] = B(!1);
|
|
102
102
|
return R(() => {
|
|
103
103
|
typeof window < "u" && t(!0);
|
|
@@ -119,7 +119,7 @@ const _ = v({
|
|
|
119
119
|
const l = f(() => e ?? i.UID.generate(), [e]), { eventHandlers: c, config: d } = f(
|
|
120
120
|
() => C(r),
|
|
121
121
|
[r]
|
|
122
|
-
), u =
|
|
122
|
+
), u = A();
|
|
123
123
|
return /* @__PURE__ */ a.createElement(w, { condition: u, fallback: n }, /* @__PURE__ */ a.createElement("div", { className: t }, /* @__PURE__ */ a.createElement(g, { userAgentIntegration: U(), "ctx-name": l, ...d }), /* @__PURE__ */ a.createElement(
|
|
124
124
|
P,
|
|
125
125
|
{
|
|
@@ -145,7 +145,7 @@ const H = v({
|
|
|
145
145
|
const l = f(() => e ?? i.UID.generate(), [e]), { eventHandlers: c, config: d } = f(
|
|
146
146
|
() => C(r),
|
|
147
147
|
[r]
|
|
148
|
-
), u =
|
|
148
|
+
), u = A();
|
|
149
149
|
return /* @__PURE__ */ a.createElement(w, { condition: u, fallback: n }, /* @__PURE__ */ a.createElement("div", { className: t }, /* @__PURE__ */ a.createElement(g, { userAgentIntegration: U(), "ctx-name": l, ...d }), /* @__PURE__ */ a.createElement(
|
|
150
150
|
P,
|
|
151
151
|
{
|
|
@@ -171,7 +171,7 @@ const S = v({
|
|
|
171
171
|
const l = f(() => e ?? i.UID.generate(), [e]), { eventHandlers: c, config: d } = f(
|
|
172
172
|
() => C(r),
|
|
173
173
|
[r]
|
|
174
|
-
), u =
|
|
174
|
+
), u = A();
|
|
175
175
|
return /* @__PURE__ */ a.createElement(w, { condition: u, fallback: n }, /* @__PURE__ */ a.createElement("div", { className: t }, /* @__PURE__ */ a.createElement(g, { userAgentIntegration: U(), "ctx-name": l, ...d }), /* @__PURE__ */ a.createElement(
|
|
176
176
|
P,
|
|
177
177
|
{
|
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.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -80,5 +80,6 @@
|
|
|
80
80
|
"react file upload",
|
|
81
81
|
"react hook file upload",
|
|
82
82
|
"front-end"
|
|
83
|
-
]
|
|
84
|
-
|
|
83
|
+
],
|
|
84
|
+
"gitHead": "1edddd9395d2d73bf92a8b9508c8df2e2aa6a89f"
|
|
85
|
+
}
|