@uploadcare/react-uploader 1.10.2 → 1.11.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.
@@ -31,13 +31,13 @@ declare type EventProps = Partial<TEventsSchema>;
31
31
 
32
32
  export declare const FileUploaderInline: FC<TProps<"Inline">>;
33
33
 
34
- declare type FileUploaderInlineProps = {};
34
+ declare type FileUploaderInlineProps = Record<string, never>;
35
35
 
36
36
  export declare const FileUploaderMinimal: FC<TProps<"Minimal">>;
37
37
 
38
- declare type FileUploaderMinimalProps = {};
38
+ declare type FileUploaderMinimalProps = Record<string, never>;
39
39
 
40
- declare type FileUploaderModes = 'Regular' | 'Minimal' | 'Inline';
40
+ declare type FileUploaderModes = "Regular" | "Minimal" | "Inline";
41
41
 
42
42
  export declare const FileUploaderRegular: FC<TProps<"Regular">>;
43
43
 
@@ -56,7 +56,7 @@ declare type TExtraPrefixOn<S extends string> = `on${Capitalize<S>}`;
56
56
 
57
57
  declare type TPrefixOnAndCamelCase<S extends string> = TExtraPrefixOn<TToCamelCase<S>>;
58
58
 
59
- export declare type TProps<T extends FileUploaderModes> = CommonProps & ConfigProps & EventProps & UploadCtxPropviderProps & Pick<TProps_2, "fallback"> & (T extends "Regular" ? FileUploaderRegularProps : T extends "Minimal" ? FileUploaderMinimalProps : T extends "Inline" ? FileUploaderInlineProps : never);
59
+ export declare type TProps<T extends FileUploaderModes> = CommonProps & ConfigProps & EventProps & UploadCtxProviderProps & Pick<TProps_2, "fallback"> & (T extends "Regular" ? FileUploaderRegularProps : T extends "Minimal" ? FileUploaderMinimalProps : T extends "Inline" ? FileUploaderInlineProps : never);
60
60
 
61
61
  declare type TProps_2 = {
62
62
  fallback?: default_2.ReactNode | default_2.ReactPortal | null;
@@ -66,13 +66,13 @@ declare type TProps_2 = {
66
66
 
67
67
  declare type TToCamelCase<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${Lowercase<Head>}${Capitalize<TToCamelCase<Tail>>}` : Lowercase<S>;
68
68
 
69
- declare type UploadCtxPropviderProps = {
70
- apiRef?: Ref<InstanceType<UploadCtxProvider>>;
71
- };
72
-
73
69
  export { UploadCtxProvider }
74
70
 
71
+ declare type UploadCtxProviderProps = {
72
+ apiRef?: Ref<UploadCtxProvider>;
73
+ };
74
+
75
75
 
76
- export * from "@uploadcare/file-uploader/types/index.js";
76
+ export * from "@uploadcare/file-uploader";
77
77
 
78
78
  export { }
@@ -1,11 +1,11 @@
1
- import { FileUploaderRegular as r } from "./FileUploaderRegular-DOI7Lze6.js";
2
- import { FileUploaderMinimal as i } from "./FileUploaderMinimal-Br6g5xIZ.js";
3
- import { FileUploaderInline as a } from "./FileUploaderInline-vnUbJRWK.js";
4
- import { UploadCtxProvider as f, defineLocale as m } from "@uploadcare/file-uploader";
1
+ import { UploadCtxProvider as r, defineLocale as l } from "@uploadcare/file-uploader";
2
+ import { FileUploaderInline as p } from "./FileUploaderInline-Be5rZcwa.js";
3
+ import { FileUploaderMinimal as d } from "./FileUploaderMinimal-Ba6hvwTt.js";
4
+ import { FileUploaderRegular as m } from "./FileUploaderRegular-BvY0ea1c.js";
5
5
  export {
6
- a as FileUploaderInline,
7
- i as FileUploaderMinimal,
8
- r as FileUploaderRegular,
9
- f as UploadCtxProvider,
10
- m as defineLocale
6
+ p as FileUploaderInline,
7
+ d as FileUploaderMinimal,
8
+ m as FileUploaderRegular,
9
+ r as UploadCtxProvider,
10
+ l as defineLocale
11
11
  };
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": "1.10.2",
4
+ "version": "1.11.0-alpha.0",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "files": [
@@ -22,6 +22,7 @@
22
22
  "./core.css": "./dist/react-uploader.css"
23
23
  },
24
24
  "scripts": {
25
+ "start": "vite",
25
26
  "dev": "tsc && vite build --watch",
26
27
  "build": "tsc && vite build",
27
28
  "preview": "vite preview",
@@ -34,7 +35,7 @@
34
35
  "next": ">= 13.0.0"
35
36
  },
36
37
  "dependencies": {
37
- "@uploadcare/file-uploader": "1.19.5",
38
+ "@uploadcare/file-uploader": "1.24.0-alpha.2",
38
39
  "@uploadcare/react-adapter": "^0.3.1"
39
40
  },
40
41
  "repository": {
@@ -88,5 +89,10 @@
88
89
  "react hook file upload",
89
90
  "front-end"
90
91
  ],
91
- "gitHead": "71a4d5c822ecff28f973664d5036500d5b603f26"
92
+ "devDependencies": {
93
+ "react": "^19",
94
+ "react-dom": "^19",
95
+ "@types/react-dom": "^19",
96
+ "@types/react": "^19"
97
+ }
92
98
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
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.
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),g=require("@uploadcare/file-uploader"),n=require("./useIsBrowser-BfTbCFcA.cjs");function f(e){const o=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(o,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const l=f(g);l.defineComponents(l);const m=n.j({react:t,tag:"uc-file-uploader-inline",elClass:l.FileUploaderMinimal}),C=({ctxName:e,className:o,classNameUploader:r,apiRef:a,fallback:s,...c})=>{const i=t.useMemo(()=>e??l.UID.generate(),[e]),{eventHandlers:u,config:d}=t.useMemo(()=>n.getCalcPropertyOfProps(c),[c]),p=n.useIsBrowser();return t.createElement(n.ConditionalSuspense,{condition:p,fallback:s},t.createElement("div",{className:o},t.createElement(n.AdapterConfig,{userAgentIntegration:n.getUserAgentIntegration(),"ctx-name":i,...d}),t.createElement(n.AdapterUploadCtxProvider,{ref:a,"ctx-name":i,...u}),t.createElement(m,{class:r,"ctx-name":i})))};exports.FileUploaderInline=C;
@@ -1,32 +0,0 @@
1
- import e, { useMemo as o } from "react";
2
- import * as t from "@uploadcare/file-uploader";
3
- import { g, u as f, C, A as u, a as A, b as U, j as E } from "./useIsBrowser-wdFeUbZ-.js";
4
- t.defineComponents(t);
5
- const I = E({
6
- react: e,
7
- tag: "uc-file-uploader-inline",
8
- elClass: t.FileUploaderMinimal
9
- }), F = ({
10
- ctxName: r,
11
- className: s,
12
- classNameUploader: i,
13
- apiRef: l,
14
- fallback: c,
15
- ...a
16
- }) => {
17
- const n = o(() => r ?? t.UID.generate(), [r]), { eventHandlers: m, config: d } = o(
18
- () => g(a),
19
- [a]
20
- ), p = f();
21
- return /* @__PURE__ */ e.createElement(C, { condition: p, fallback: c }, /* @__PURE__ */ e.createElement("div", { className: s }, /* @__PURE__ */ e.createElement(u, { userAgentIntegration: A(), "ctx-name": n, ...d }), /* @__PURE__ */ e.createElement(
22
- U,
23
- {
24
- ref: l,
25
- "ctx-name": n,
26
- ...m
27
- }
28
- ), /* @__PURE__ */ e.createElement(I, { class: i, "ctx-name": n })));
29
- };
30
- export {
31
- F as FileUploaderInline
32
- };
@@ -1,32 +0,0 @@
1
- import e, { useMemo as o } from "react";
2
- import * as t from "@uploadcare/file-uploader";
3
- import { g, u as f, C, A as u, a as A, b as U, j as E } from "./useIsBrowser-wdFeUbZ-.js";
4
- t.defineComponents(t);
5
- const M = E({
6
- react: e,
7
- tag: "uc-file-uploader-minimal",
8
- elClass: t.FileUploaderMinimal
9
- }), v = ({
10
- ctxName: n,
11
- className: s,
12
- classNameUploader: i,
13
- apiRef: l,
14
- fallback: m,
15
- ...r
16
- }) => {
17
- const a = o(() => n ?? t.UID.generate(), [n]), { eventHandlers: c, config: d } = o(
18
- () => g(r),
19
- [r]
20
- ), p = f();
21
- return /* @__PURE__ */ e.createElement(C, { condition: p, fallback: m }, /* @__PURE__ */ e.createElement("div", { className: s }, /* @__PURE__ */ e.createElement(u, { userAgentIntegration: A(), "ctx-name": a, ...d }), /* @__PURE__ */ e.createElement(
22
- U,
23
- {
24
- ref: l,
25
- "ctx-name": a,
26
- ...c
27
- }
28
- ), /* @__PURE__ */ e.createElement(M, { class: i, "ctx-name": a })));
29
- };
30
- export {
31
- v as FileUploaderMinimal
32
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),p=require("@uploadcare/file-uploader"),n=require("./useIsBrowser-BfTbCFcA.cjs");function g(e){const o=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(o,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const i=g(p);i.defineComponents(i);const f=n.j({react:t,tag:"uc-file-uploader-minimal",elClass:i.FileUploaderMinimal}),C=({ctxName:e,className:o,classNameUploader:r,apiRef:a,fallback:s,...c})=>{const l=t.useMemo(()=>e??i.UID.generate(),[e]),{eventHandlers:u,config:d}=t.useMemo(()=>n.getCalcPropertyOfProps(c),[c]),m=n.useIsBrowser();return t.createElement(n.ConditionalSuspense,{condition:m,fallback:s},t.createElement("div",{className:o},t.createElement(n.AdapterConfig,{userAgentIntegration:n.getUserAgentIntegration(),"ctx-name":l,...d}),t.createElement(n.AdapterUploadCtxProvider,{ref:a,"ctx-name":l,...u}),t.createElement(f,{class:r,"ctx-name":l})))};exports.FileUploaderMinimal=C;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),f=require("@uploadcare/file-uploader"),r=require("./useIsBrowser-BfTbCFcA.cjs");function m(e){const o=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(o,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return o.default=e,Object.freeze(o)}const l=m(f);l.defineComponents(l);const C=r.j({react:t,tag:"uc-file-uploader-regular",elClass:l.FileUploaderRegular}),U=({ctxName:e,className:o,classNameUploader:n,apiRef:a,fallback:i,...s})=>{const c=t.useMemo(()=>e??l.UID.generate(),[e]),{eventHandlers:u,config:d,uploader:g}=t.useMemo(()=>r.getCalcPropertyOfProps(s),[s]),p=r.useIsBrowser();return t.createElement(r.ConditionalSuspense,{condition:p,fallback:i},t.createElement("div",{className:o},t.createElement(r.AdapterConfig,{userAgentIntegration:r.getUserAgentIntegration(),"ctx-name":c,...d}),t.createElement(r.AdapterUploadCtxProvider,{ref:a,"ctx-name":c,...u}),t.createElement(C,{class:n,"ctx-name":c,...g})))};exports.FileUploaderRegular=U;
@@ -1,32 +0,0 @@
1
- import e, { useMemo as o } from "react";
2
- import * as r from "@uploadcare/file-uploader";
3
- import { g as u, u as f, C, A, a as U, b as E, j as x } from "./useIsBrowser-wdFeUbZ-.js";
4
- r.defineComponents(r);
5
- const I = x({
6
- react: e,
7
- tag: "uc-file-uploader-regular",
8
- elClass: r.FileUploaderRegular
9
- }), F = ({
10
- ctxName: a,
11
- className: s,
12
- classNameUploader: l,
13
- apiRef: c,
14
- fallback: i,
15
- ...n
16
- }) => {
17
- const t = o(() => a ?? r.UID.generate(), [a]), { eventHandlers: d, config: g, uploader: m } = o(
18
- () => u(n),
19
- [n]
20
- ), p = f();
21
- return /* @__PURE__ */ e.createElement(C, { condition: p, fallback: i }, /* @__PURE__ */ e.createElement("div", { className: s }, /* @__PURE__ */ e.createElement(A, { userAgentIntegration: U(), "ctx-name": t, ...g }), /* @__PURE__ */ e.createElement(
22
- E,
23
- {
24
- ref: c,
25
- "ctx-name": t,
26
- ...d
27
- }
28
- ), /* @__PURE__ */ e.createElement(I, { class: l, "ctx-name": t, ...m })));
29
- };
30
- export {
31
- F as FileUploaderRegular
32
- };
@@ -1 +0,0 @@
1
- "use strict";const f=require("react"),y=require("@uploadcare/file-uploader");function b(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const v=b(y),h=new Set(["children","ref","style","className"]),O=(e={})=>Object==null?void 0:Object.keys(e).reduce((t,r)=>{var s,n;const o=e==null?void 0:e[r],a=`on${(n=(s=o==null?void 0:o.split("-"))==null?void 0:s.map(c=>c.charAt(0).toUpperCase()+c.slice(1)))==null?void 0:n.join("")}`;return t[a]=o,t},{}),m=new WeakMap,j=e=>{let t=m.get(e);return t===void 0&&(t=new Map,m.set(e,t)),t},E=({node:e,nameProp:t,valueProp:r,prevValueProp:s,event:n})=>{if(n!==void 0){if(r!==s){const o=j(e),a=o.has(n);let c=o.get(n);r!==void 0?a?c.handleEvent=r:(c={handleEvent:r},o.set(n,c),e.addEventListener(n,l=>c.handleEvent(l.detail))):a&&(o.delete(n),e.removeEventListener(n,c))}return}e[t]=r,r==null&&t in HTMLElement.prototype&&e.removeAttribute(t)},U=(e,t,r)=>{const s={},n={};return Object.entries(e).forEach(([o,a])=>{h.has(o)?s[o==="className"?"class":o]=a:t.has(o)||o in r.prototype?n[o]=a:s[o]=a}),{reactProps:s,customElProps:n}},g=({react:e,tag:t,elClass:r,schemaEvents:s})=>{const n=O(s),o=new Set(Object.keys(n??{})),a=e.forwardRef((c,l)=>{const d=e.useRef(new Map),p=e.useRef(null),{reactProps:C,customElProps:P}=U(c,o,r);return e.useLayoutEffect(()=>{if(p.current===null)return;const i=new Map;for(const u in P)E({node:p.current,nameProp:u,valueProp:P[u],prevValueProp:d.current.get(u),event:n[u]}),d.current.delete(u),i.set(u,c[u]);for(const[u,w]of d.current)E({node:p.current,nameProp:u,valueProp:void 0,prevValueProp:w,event:n[u]});d.current=i}),e.createElement(t??r.__tag,{...C,ref:e.useCallback(i=>{p.current=i,typeof l=="function"?l(i):l!==null&&(l.current=i)},[l])})});return a.displayName=r.name,a},A=g({react:f,tag:"uc-config",elClass:v.Config}),M=g({react:f,tag:"uc-upload-ctx-provider",elClass:v.UploadCtxProvider,schemaEvents:v.UploadCtxProvider.EventType}),N=e=>{const t={},r={},s={};for(const[n,o]of Object.entries(e)){if(n.startsWith("on")){t[n]=o;continue}if(n==="headless"){s[n]=o;continue}r[n]=o}return{eventHandlers:t,uploader:s,config:r}},S="1.10.1",I="React-Uploader",_=()=>`${I}/${S}`,k=({children:e})=>e,x=()=>{const[e,t]=f.useState(!1);return f.useEffect(()=>{typeof window<"u"&&t(!0)},[]),e};exports.AdapterConfig=A;exports.AdapterUploadCtxProvider=M;exports.ConditionalSuspense=k;exports.getCalcPropertyOfProps=N;exports.getUserAgentIntegration=_;exports.j=g;exports.useIsBrowser=x;
@@ -1,123 +0,0 @@
1
- import P, { useState as w, useEffect as y } from "react";
2
- import * as f from "@uploadcare/file-uploader";
3
- const b = /* @__PURE__ */ new Set([
4
- "children",
5
- "ref",
6
- "style",
7
- "className"
8
- ]), j = (e = {}) => Object == null ? void 0 : Object.keys(e).reduce((r, o) => {
9
- var s, t;
10
- const n = e == null ? void 0 : e[o], a = `on${(t = (s = n == null ? void 0 : n.split("-")) == null ? void 0 : s.map((c) => c.charAt(0).toUpperCase() + c.slice(1))) == null ? void 0 : t.join("")}`;
11
- return r[a] = n, r;
12
- }, {}), m = /* @__PURE__ */ new WeakMap(), A = (e) => {
13
- let r = m.get(e);
14
- return r === void 0 && (r = /* @__PURE__ */ new Map(), m.set(e, r)), r;
15
- }, E = ({
16
- node: e,
17
- nameProp: r,
18
- valueProp: o,
19
- prevValueProp: s,
20
- event: t
21
- }) => {
22
- if (t !== void 0) {
23
- if (o !== s) {
24
- const n = A(e), a = n.has(t);
25
- let c = n.get(t);
26
- o !== void 0 ? a ? c.handleEvent = o : (c = { handleEvent: o }, n.set(t, c), e.addEventListener(
27
- t,
28
- (l) => c.handleEvent(l.detail)
29
- )) : a && (n.delete(t), e.removeEventListener(t, c));
30
- }
31
- return;
32
- }
33
- e[r] = o, o == null && r in HTMLElement.prototype && e.removeAttribute(r);
34
- }, M = (e, r, o) => {
35
- const s = {}, t = {};
36
- return Object.entries(e).forEach(([n, a]) => {
37
- b.has(n) ? s[n === "className" ? "class" : n] = a : r.has(n) || n in o.prototype ? t[n] = a : s[n] = a;
38
- }), { reactProps: s, customElProps: t };
39
- }, g = ({
40
- react: e,
41
- // https://react.dev/warnings/invalid-hook-call-warning
42
- tag: r,
43
- elClass: o,
44
- schemaEvents: s
45
- }) => {
46
- const t = j(s), n = new Set(Object.keys(t ?? {})), a = e.forwardRef(
47
- (c, l) => {
48
- const i = e.useRef(/* @__PURE__ */ new Map()), p = e.useRef(null), { reactProps: h, customElProps: v } = M(c, n, o);
49
- return e.useLayoutEffect(() => {
50
- if (p.current === null)
51
- return;
52
- const d = /* @__PURE__ */ new Map();
53
- for (const u in v)
54
- E({
55
- node: p.current,
56
- nameProp: u,
57
- valueProp: v[u],
58
- prevValueProp: i.current.get(u),
59
- event: t[u]
60
- }), i.current.delete(u), d.set(u, c[u]);
61
- for (const [u, C] of i.current)
62
- E({
63
- node: p.current,
64
- nameProp: u,
65
- valueProp: void 0,
66
- prevValueProp: C,
67
- event: t[u]
68
- });
69
- i.current = d;
70
- }), e.createElement(r ?? o.__tag, {
71
- ...h,
72
- ref: e.useCallback(
73
- (d) => {
74
- p.current = d, typeof l == "function" ? l(d) : l !== null && (l.current = d);
75
- },
76
- [l]
77
- )
78
- });
79
- }
80
- );
81
- return a.displayName = o.name, a;
82
- }, x = g({
83
- react: P,
84
- tag: "uc-config",
85
- elClass: f.Config
86
- }), R = g({
87
- react: P,
88
- tag: "uc-upload-ctx-provider",
89
- elClass: f.UploadCtxProvider,
90
- schemaEvents: f.UploadCtxProvider.EventType
91
- }), k = (e) => {
92
- const r = {}, o = {}, s = {};
93
- for (const [t, n] of Object.entries(e)) {
94
- if (t.startsWith("on")) {
95
- r[t] = n;
96
- continue;
97
- }
98
- if (t === "headless") {
99
- s[t] = n;
100
- continue;
101
- }
102
- o[t] = n;
103
- }
104
- return {
105
- eventHandlers: r,
106
- uploader: s,
107
- config: o
108
- };
109
- }, O = "1.10.1", U = "React-Uploader", I = () => `${U}/${O}`, L = ({ children: e }) => e, S = () => {
110
- const [e, r] = w(!1);
111
- return y(() => {
112
- typeof window < "u" && r(!0);
113
- }, []), e;
114
- };
115
- export {
116
- x as A,
117
- L as C,
118
- I as a,
119
- R as b,
120
- k as g,
121
- g as j,
122
- S as u
123
- };