react-files-preview
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -84,2 +84,6 @@ import { ChangeEventHandler } from "react"; | ||
/** | ||
* Callback function invoked when a file is dropped. | ||
*/ | ||
onDrop?: (event: React.DragEvent<HTMLDivElement>) => void; | ||
/** | ||
* Callback function invoked when a file is clicked. | ||
@@ -86,0 +90,0 @@ * @param file - The clicked file. |
@@ -1,2 +0,2 @@ | ||
import Re, { createContext as h0, useReducer as v0, useState as He, useEffect as B, useContext as S, Suspense as m0 } from "react"; | ||
import Re, { createContext as h0, useReducer as v0, useState as He, useEffect as G, useContext as S, Suspense as m0 } from "react"; | ||
var _e = { exports: {} }, Q = {}; | ||
@@ -18,5 +18,5 @@ /** | ||
var a = Re, o = Symbol.for("react.element"), p = Symbol.for("react.fragment"), w = Object.prototype.hasOwnProperty, b = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 }; | ||
function m(x, d, O) { | ||
function m(x, d, N) { | ||
var g, T = {}, k = null, V = null; | ||
O !== void 0 && (k = "" + O), d.key !== void 0 && (k = "" + d.key), d.ref !== void 0 && (V = d.ref); | ||
N !== void 0 && (k = "" + N), d.key !== void 0 && (k = "" + d.key), d.ref !== void 0 && (V = d.ref); | ||
for (g in d) | ||
@@ -44,7 +44,7 @@ w.call(d, g) && !s.hasOwnProperty(g) && (T[g] = d[g]); | ||
return $e || ($e = 1, process.env.NODE_ENV !== "production" && function() { | ||
var a = Re, o = Symbol.for("react.element"), p = Symbol.for("react.portal"), w = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), m = Symbol.for("react.provider"), x = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), V = Symbol.for("react.offscreen"), Y = Symbol.iterator, te = "@@iterator"; | ||
function z(e) { | ||
var a = Re, o = Symbol.for("react.element"), p = Symbol.for("react.portal"), w = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), m = Symbol.for("react.provider"), x = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), N = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), V = Symbol.for("react.offscreen"), q = Symbol.iterator, te = "@@iterator"; | ||
function I(e) { | ||
if (e === null || typeof e != "object") | ||
return null; | ||
var r = Y && e[Y] || e[te]; | ||
var r = q && e[q] || e[te]; | ||
return typeof r == "function" ? r : null; | ||
@@ -57,11 +57,11 @@ } | ||
n[i - 1] = arguments[i]; | ||
M("error", e, n); | ||
z("error", e, n); | ||
} | ||
} | ||
function M(e, r, n) { | ||
function z(e, r, n) { | ||
{ | ||
var i = F.ReactDebugCurrentFrame, f = i.getStackAddendum(); | ||
f !== "" && (r += "%s", n = n.concat([f])); | ||
var h = n.map(function(c) { | ||
return String(c); | ||
var h = n.map(function(u) { | ||
return String(u); | ||
}); | ||
@@ -71,12 +71,12 @@ h.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, h); | ||
} | ||
var re = !1, ae = !1, N = !1, me = !1, pe = !1, P; | ||
P = Symbol.for("react.module.reference"); | ||
function D(e) { | ||
return !!(typeof e == "string" || typeof e == "function" || e === w || e === s || pe || e === b || e === O || e === g || me || e === V || re || ae || N || typeof e == "object" && e !== null && (e.$$typeof === k || e.$$typeof === T || e.$$typeof === m || e.$$typeof === x || e.$$typeof === d || // This needs to include all possible module reference object | ||
var re = !1, ae = !1, ne = !1, A = !1, pe = !1, ie; | ||
ie = Symbol.for("react.module.reference"); | ||
function M(e) { | ||
return !!(typeof e == "string" || typeof e == "function" || e === w || e === s || pe || e === b || e === N || e === g || A || e === V || re || ae || ne || typeof e == "object" && e !== null && (e.$$typeof === k || e.$$typeof === T || e.$$typeof === m || e.$$typeof === x || e.$$typeof === d || // This needs to include all possible module reference object | ||
// types supported by any Flight configuration anywhere since | ||
// we don't know which Flight build this will end up being used | ||
// with. | ||
e.$$typeof === P || e.getModuleId !== void 0)); | ||
e.$$typeof === ie || e.getModuleId !== void 0)); | ||
} | ||
function G(e, r, n) { | ||
function P(e, r, n) { | ||
var i = e.displayName; | ||
@@ -88,6 +88,6 @@ if (i) | ||
} | ||
function q(e) { | ||
function U(e) { | ||
return e.displayName || "Context"; | ||
} | ||
function A(e) { | ||
function C(e) { | ||
if (e == null) | ||
@@ -108,3 +108,3 @@ return null; | ||
return "StrictMode"; | ||
case O: | ||
case N: | ||
return "Suspense"; | ||
@@ -118,15 +118,15 @@ case g: | ||
var r = e; | ||
return q(r) + ".Consumer"; | ||
return U(r) + ".Consumer"; | ||
case m: | ||
var n = e; | ||
return q(n._context) + ".Provider"; | ||
return U(n._context) + ".Provider"; | ||
case d: | ||
return G(e, e.render, "ForwardRef"); | ||
return P(e, e.render, "ForwardRef"); | ||
case T: | ||
var i = e.displayName || null; | ||
return i !== null ? i : A(e.type) || "Memo"; | ||
return i !== null ? i : C(e.type) || "Memo"; | ||
case k: { | ||
var f = e, h = f._payload, c = f._init; | ||
var f = e, h = f._payload, u = f._init; | ||
try { | ||
return A(c(h)); | ||
return C(u(h)); | ||
} catch { | ||
@@ -139,14 +139,14 @@ return null; | ||
} | ||
var L = Object.assign, $ = 0, ne, ie, le, oe, u, v, H; | ||
function U() { | ||
var D = Object.assign, $ = 0, le, oe, se, ce, ue, c, v; | ||
function H() { | ||
} | ||
U.__reactDisabledLog = !0; | ||
function se() { | ||
H.__reactDisabledLog = !0; | ||
function J() { | ||
{ | ||
if ($ === 0) { | ||
ne = console.log, ie = console.info, le = console.warn, oe = console.error, u = console.group, v = console.groupCollapsed, H = console.groupEnd; | ||
le = console.log, oe = console.info, se = console.warn, ce = console.error, ue = console.group, c = console.groupCollapsed, v = console.groupEnd; | ||
var e = { | ||
configurable: !0, | ||
enumerable: !0, | ||
value: U, | ||
value: H, | ||
writable: !0 | ||
@@ -167,3 +167,3 @@ }; | ||
} | ||
function ce() { | ||
function fe() { | ||
{ | ||
@@ -177,22 +177,22 @@ if ($--, $ === 0) { | ||
Object.defineProperties(console, { | ||
log: L({}, e, { | ||
value: ne | ||
}), | ||
info: L({}, e, { | ||
value: ie | ||
}), | ||
warn: L({}, e, { | ||
log: D({}, e, { | ||
value: le | ||
}), | ||
error: L({}, e, { | ||
info: D({}, e, { | ||
value: oe | ||
}), | ||
group: L({}, e, { | ||
value: u | ||
warn: D({}, e, { | ||
value: se | ||
}), | ||
groupCollapsed: L({}, e, { | ||
error: D({}, e, { | ||
value: ce | ||
}), | ||
group: D({}, e, { | ||
value: ue | ||
}), | ||
groupCollapsed: D({}, e, { | ||
value: c | ||
}), | ||
groupEnd: D({}, e, { | ||
value: v | ||
}), | ||
groupEnd: L({}, e, { | ||
value: H | ||
}) | ||
@@ -204,4 +204,4 @@ }); | ||
} | ||
var J = F.ReactCurrentDispatcher, K; | ||
function ue(e, r, n) { | ||
var W = F.ReactCurrentDispatcher, K; | ||
function Z(e, r, n) { | ||
{ | ||
@@ -219,6 +219,6 @@ if (K === void 0) | ||
} | ||
var ge = !1, fe; | ||
var ge = !1, de; | ||
{ | ||
var We = typeof WeakMap == "function" ? WeakMap : Map; | ||
fe = new We(); | ||
de = new We(); | ||
} | ||
@@ -229,3 +229,3 @@ function Se(e, r) { | ||
{ | ||
var n = fe.get(e); | ||
var n = de.get(e); | ||
if (n !== void 0) | ||
@@ -239,9 +239,9 @@ return n; | ||
var h; | ||
h = J.current, J.current = null, se(); | ||
h = W.current, W.current = null, J(); | ||
try { | ||
if (r) { | ||
var c = function() { | ||
var u = function() { | ||
throw Error(); | ||
}; | ||
if (Object.defineProperty(c.prototype, "props", { | ||
if (Object.defineProperty(u.prototype, "props", { | ||
set: function() { | ||
@@ -252,14 +252,14 @@ throw Error(); | ||
try { | ||
Reflect.construct(c, []); | ||
} catch (I) { | ||
i = I; | ||
Reflect.construct(u, []); | ||
} catch (L) { | ||
i = L; | ||
} | ||
Reflect.construct(e, [], c); | ||
Reflect.construct(e, [], u); | ||
} else { | ||
try { | ||
c.call(); | ||
} catch (I) { | ||
i = I; | ||
u.call(); | ||
} catch (L) { | ||
i = L; | ||
} | ||
e.call(c.prototype); | ||
e.call(u.prototype); | ||
} | ||
@@ -269,10 +269,10 @@ } else { | ||
throw Error(); | ||
} catch (I) { | ||
i = I; | ||
} catch (L) { | ||
i = L; | ||
} | ||
e(); | ||
} | ||
} catch (I) { | ||
if (I && i && typeof I.stack == "string") { | ||
for (var l = I.stack.split(` | ||
} catch (L) { | ||
if (L && i && typeof L.stack == "string") { | ||
for (var l = L.stack.split(` | ||
`), _ = i.stack.split(` | ||
@@ -286,5 +286,5 @@ `), y = l.length - 1, E = _.length - 1; y >= 1 && E >= 0 && l[y] !== _[E]; ) | ||
if (y--, E--, E < 0 || l[y] !== _[E]) { | ||
var C = ` | ||
var O = ` | ||
` + l[y].replace(" at new ", " at "); | ||
return e.displayName && C.includes("<anonymous>") && (C = C.replace("<anonymous>", e.displayName)), typeof e == "function" && fe.set(e, C), C; | ||
return e.displayName && O.includes("<anonymous>") && (O = O.replace("<anonymous>", e.displayName)), typeof e == "function" && de.set(e, O), O; | ||
} | ||
@@ -296,6 +296,6 @@ while (y >= 1 && E >= 0); | ||
} finally { | ||
ge = !1, J.current = h, ce(), Error.prepareStackTrace = f; | ||
ge = !1, W.current = h, fe(), Error.prepareStackTrace = f; | ||
} | ||
var Z = e ? e.displayName || e.name : "", Me = Z ? ue(Z) : ""; | ||
return typeof e == "function" && fe.set(e, Me), Me; | ||
var Y = e ? e.displayName || e.name : "", Me = Y ? Z(Y) : ""; | ||
return typeof e == "function" && de.set(e, Me), Me; | ||
} | ||
@@ -309,3 +309,3 @@ function Ze(e, r, n) { | ||
} | ||
function de(e, r, n) { | ||
function he(e, r, n) { | ||
if (e == null) | ||
@@ -316,8 +316,8 @@ return ""; | ||
if (typeof e == "string") | ||
return ue(e); | ||
return Z(e); | ||
switch (e) { | ||
case O: | ||
return ue("Suspense"); | ||
case N: | ||
return Z("Suspense"); | ||
case g: | ||
return ue("SuspenseList"); | ||
return Z("SuspenseList"); | ||
} | ||
@@ -329,7 +329,7 @@ if (typeof e == "object") | ||
case T: | ||
return de(e.type, r, n); | ||
return he(e.type, r, n); | ||
case k: { | ||
var i = e, f = i._payload, h = i._init; | ||
try { | ||
return de(h(f), r, n); | ||
return he(h(f), r, n); | ||
} catch { | ||
@@ -341,6 +341,6 @@ } | ||
} | ||
var he = Object.prototype.hasOwnProperty, Te = {}, ke = F.ReactDebugCurrentFrame; | ||
function ve(e) { | ||
var ve = Object.prototype.hasOwnProperty, Te = {}, ke = F.ReactDebugCurrentFrame; | ||
function me(e) { | ||
if (e) { | ||
var r = e._owner, n = de(e.type, e._source, r ? r.type : null); | ||
var r = e._owner, n = he(e.type, e._source, r ? r.type : null); | ||
ke.setExtraStackFrame(n); | ||
@@ -352,16 +352,16 @@ } else | ||
{ | ||
var h = Function.call.bind(he); | ||
for (var c in e) | ||
if (h(e, c)) { | ||
var h = Function.call.bind(ve); | ||
for (var u in e) | ||
if (h(e, u)) { | ||
var l = void 0; | ||
try { | ||
if (typeof e[c] != "function") { | ||
var _ = Error((i || "React class") + ": " + n + " type `" + c + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[c] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); | ||
if (typeof e[u] != "function") { | ||
var _ = Error((i || "React class") + ": " + n + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); | ||
throw _.name = "Invariant Violation", _; | ||
} | ||
l = e[c](r, c, i, n, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
l = e[u](r, u, i, n, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
} catch (y) { | ||
l = y; | ||
} | ||
l && !(l instanceof Error) && (ve(f), j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", i || "React class", n, c, typeof l), ve(null)), l instanceof Error && !(l.message in Te) && (Te[l.message] = !0, ve(f), j("Failed %s type: %s", n, l.message), ve(null)); | ||
l && !(l instanceof Error) && (me(f), j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", i || "React class", n, u, typeof l), me(null)), l instanceof Error && !(l.message in Te) && (Te[l.message] = !0, me(f), j("Failed %s type: %s", n, l.message), me(null)); | ||
} | ||
@@ -402,3 +402,3 @@ } | ||
function Xe(e) { | ||
if (he.call(e, "ref")) { | ||
if (ve.call(e, "ref")) { | ||
var r = Object.getOwnPropertyDescriptor(e, "ref").get; | ||
@@ -411,3 +411,3 @@ if (r && r.isReactWarning) | ||
function Qe(e) { | ||
if (he.call(e, "key")) { | ||
if (ve.call(e, "key")) { | ||
var r = Object.getOwnPropertyDescriptor(e, "key").get; | ||
@@ -421,4 +421,4 @@ if (r && r.isReactWarning) | ||
if (typeof e.ref == "string" && X.current && r && X.current.stateNode !== r) { | ||
var n = A(X.current.type); | ||
we[n] || (j('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', A(X.current.type), e.ref), we[n] = !0); | ||
var n = C(X.current.type); | ||
we[n] || (j('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', C(X.current.type), e.ref), we[n] = !0); | ||
} | ||
@@ -448,3 +448,3 @@ } | ||
} | ||
var a0 = function(e, r, n, i, f, h, c) { | ||
var a0 = function(e, r, n, i, f, h, u) { | ||
var l = { | ||
@@ -457,3 +457,3 @@ // This tag allows us to uniquely identify this as a React Element | ||
ref: n, | ||
props: c, | ||
props: u, | ||
// Record the component responsible for creating this element. | ||
@@ -481,22 +481,22 @@ _owner: h | ||
{ | ||
var h, c = {}, l = null, _ = null; | ||
var h, u = {}, l = null, _ = null; | ||
n !== void 0 && (Oe(n), l = "" + n), Qe(r) && (Oe(r.key), l = "" + r.key), Xe(r) && (_ = r.ref, e0(r, f)); | ||
for (h in r) | ||
he.call(r, h) && !Ke.hasOwnProperty(h) && (c[h] = r[h]); | ||
ve.call(r, h) && !Ke.hasOwnProperty(h) && (u[h] = r[h]); | ||
if (e && e.defaultProps) { | ||
var y = e.defaultProps; | ||
for (h in y) | ||
c[h] === void 0 && (c[h] = y[h]); | ||
u[h] === void 0 && (u[h] = y[h]); | ||
} | ||
if (l || _) { | ||
var E = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; | ||
l && t0(c, E), _ && r0(c, E); | ||
l && t0(u, E), _ && r0(u, E); | ||
} | ||
return a0(e, l, _, f, i, X.current, c); | ||
return a0(e, l, _, f, i, X.current, u); | ||
} | ||
} | ||
var ye = F.ReactCurrentOwner, Fe = F.ReactDebugCurrentFrame; | ||
function W(e) { | ||
function B(e) { | ||
if (e) { | ||
var r = e._owner, n = de(e.type, e._source, r ? r.type : null); | ||
var r = e._owner, n = he(e.type, e._source, r ? r.type : null); | ||
Fe.setExtraStackFrame(n); | ||
@@ -511,6 +511,6 @@ } else | ||
} | ||
function De() { | ||
function Pe() { | ||
{ | ||
if (ye.current) { | ||
var e = A(ye.current.type); | ||
var e = C(ye.current.type); | ||
if (e) | ||
@@ -535,6 +535,6 @@ return ` | ||
} | ||
var Pe = {}; | ||
var De = {}; | ||
function l0(e) { | ||
{ | ||
var r = De(); | ||
var r = Pe(); | ||
if (!r) { | ||
@@ -555,7 +555,7 @@ var n = typeof e == "string" ? e : e.displayName || e.name; | ||
var n = l0(r); | ||
if (Pe[n]) | ||
if (De[n]) | ||
return; | ||
Pe[n] = !0; | ||
De[n] = !0; | ||
var i = ""; | ||
e && e._owner && e._owner !== ye.current && (i = " It was passed a child from " + A(e._owner.type) + "."), W(e), j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', n, i), W(null); | ||
e && e._owner && e._owner !== ye.current && (i = " It was passed a child from " + C(e._owner.type) + "."), B(e), j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', n, i), B(null); | ||
} | ||
@@ -575,6 +575,6 @@ } | ||
else if (e) { | ||
var f = z(e); | ||
var f = I(e); | ||
if (typeof f == "function" && f !== e.entries) | ||
for (var h = f.call(e), c; !(c = h.next()).done; ) | ||
Ee(c.value) && Le(c.value, r); | ||
for (var h = f.call(e), u; !(u = h.next()).done; ) | ||
Ee(u.value) && Le(u.value, r); | ||
} | ||
@@ -598,7 +598,7 @@ } | ||
if (n) { | ||
var i = A(r); | ||
var i = C(r); | ||
Ye(n, e.props, "prop", i, e); | ||
} else if (r.PropTypes !== void 0 && !be) { | ||
be = !0; | ||
var f = A(r); | ||
var f = C(r); | ||
j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", f || "Unknown"); | ||
@@ -614,7 +614,7 @@ } | ||
if (i !== "children" && i !== "key") { | ||
W(e), j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", i), W(null); | ||
B(e), j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", i), B(null); | ||
break; | ||
} | ||
} | ||
e.ref !== null && (W(e), j("Invalid attribute `ref` supplied to `React.Fragment`."), W(null)); | ||
e.ref !== null && (B(e), j("Invalid attribute `ref` supplied to `React.Fragment`."), B(null)); | ||
} | ||
@@ -624,10 +624,10 @@ } | ||
{ | ||
var c = D(e); | ||
if (!c) { | ||
var u = M(e); | ||
if (!u) { | ||
var l = ""; | ||
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (l += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); | ||
var _ = i0(f); | ||
_ ? l += _ : l += De(); | ||
_ ? l += _ : l += Pe(); | ||
var y; | ||
e === null ? y = "null" : xe(e) ? y = "array" : e !== void 0 && e.$$typeof === o ? (y = "<" + (A(e.type) || "Unknown") + " />", l = " Did you accidentally export a JSX literal instead of a component?") : y = typeof e, j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", y, l); | ||
e === null ? y = "null" : xe(e) ? y = "array" : e !== void 0 && e.$$typeof === o ? (y = "<" + (C(e.type) || "Unknown") + " />", l = " Did you accidentally export a JSX literal instead of a component?") : y = typeof e, j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", y, l); | ||
} | ||
@@ -637,14 +637,14 @@ var E = n0(e, r, n, f, h); | ||
return E; | ||
if (c) { | ||
var C = r.children; | ||
if (C !== void 0) | ||
if (u) { | ||
var O = r.children; | ||
if (O !== void 0) | ||
if (i) | ||
if (xe(C)) { | ||
for (var Z = 0; Z < C.length; Z++) | ||
Ie(C[Z], e); | ||
Object.freeze && Object.freeze(C); | ||
if (xe(O)) { | ||
for (var Y = 0; Y < O.length; Y++) | ||
Ie(O[Y], e); | ||
Object.freeze && Object.freeze(O); | ||
} else | ||
j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); | ||
else | ||
Ie(C, e); | ||
Ie(O, e); | ||
} | ||
@@ -781,3 +781,3 @@ return e === w ? s0(E) : o0(E), E; | ||
const [b, s] = He(null); | ||
B(() => { | ||
G(() => { | ||
a.size < 1e6 ? s(Math.floor(a.size / 1e3) + " KB") : s(Math.floor(a.size / 1e6) + " MB"); | ||
@@ -789,3 +789,3 @@ }, [a]); | ||
x.length > 20 && (x = x.substring(0, 5) + ".." + x.substring(x.length - 3, x.length)); | ||
const O = x + "." + d, g = S(R).state.componentState, { dispatch: T } = S(R), k = () => { | ||
const N = x + "." + d, g = S(R).state.componentState, { dispatch: T } = S(R), k = () => { | ||
T({ | ||
@@ -801,3 +801,3 @@ type: "SET_IMAGE_EDITOR_DATA", | ||
return /* @__PURE__ */ t.jsxs("div", { className: "relative ", children: [ | ||
/* @__PURE__ */ t.jsx("h5", { className: "text-[12px] mt-1 font-normal break-words text-black dark:text-slate-100", children: O }), | ||
/* @__PURE__ */ t.jsx("h5", { className: "text-[12px] mt-1 font-normal break-words text-black dark:text-slate-100", children: N }), | ||
g.showFileSize && /* @__PURE__ */ t.jsx("span", { "data-testid": "file-size", className: "text-[10px] text-black dark:text-slate-100", children: b }), | ||
@@ -874,3 +874,3 @@ g.downloadFile && o && /* @__PURE__ */ t.jsx( | ||
const [p, w] = He(null); | ||
B(() => { | ||
G(() => { | ||
if (a) { | ||
@@ -1177,3 +1177,3 @@ const d = URL.createObjectURL(a); | ||
accept: d, | ||
maxFileSize: O, | ||
maxFileSize: N, | ||
maxFiles: g, | ||
@@ -1183,22 +1183,23 @@ width: T, | ||
height: V, | ||
fileHeight: Y, | ||
fileHeight: q, | ||
fileWidth: te, | ||
disabled: z, | ||
disabled: I, | ||
onChange: F, | ||
onRemove: j, | ||
onError: M, | ||
onError: z, | ||
getFiles: re, | ||
onClick: ae | ||
onClick: ae, | ||
onDrop: ne | ||
}) => { | ||
const N = S(R).state.fileData, me = S(R).state.fileState, pe = S(R).state.componentState, P = S(R).state.imageEditorState, { dispatch: D } = S(R), G = (u) => { | ||
const A = S(R).state.fileData, pe = S(R).state.fileState, ie = S(R).state.componentState, M = S(R).state.imageEditorState, { dispatch: P } = S(R), U = (c) => { | ||
let v = !1; | ||
if (g && (N.length + u.length > g || u.length > g)) | ||
throw v = !0, M && M(new Error(`Max ${g} files are allowed to be selected`)), new Error(`Max ${g} files are allowed to be selected`); | ||
return O && u.forEach((H) => { | ||
if (H.size > O) | ||
throw v = !0, M && M(new Error(`File size limit exceeded: ${H.name}`)), new Error(`File size limit exceeded: ${H.name}`); | ||
if (g && (A.length + c.length > g || c.length > g)) | ||
throw v = !0, z && z(new Error(`Max ${g} files are allowed to be selected`)), new Error(`Max ${g} files are allowed to be selected`); | ||
return N && c.forEach((H) => { | ||
if (H.size > N) | ||
throw v = !0, z && z(new Error(`File size limit exceeded: ${H.name}`)), new Error(`File size limit exceeded: ${H.name}`); | ||
}), v; | ||
}; | ||
B(() => { | ||
async function u() { | ||
G(() => { | ||
async function c() { | ||
try { | ||
@@ -1212,21 +1213,21 @@ if (o) { | ||
{ type: "image/tiff", ext: ".tiff" } | ||
], U = await (await fetch(o)).blob(); | ||
let se = null; | ||
const ce = v.filter((K) => K.type === U.type); | ||
ce.length > 0 && (se = ce[0].ext); | ||
const J = new File([U], "file" + se, { | ||
type: U.type | ||
], J = await (await fetch(o)).blob(); | ||
let fe = null; | ||
const W = v.filter((Z) => Z.type === J.type); | ||
W.length > 0 && (fe = W[0].ext); | ||
const K = new File([J], "file" + fe, { | ||
type: J.type | ||
}); | ||
D({ type: "STORE_FILE_DATA", payload: { files: [J] } }); | ||
P({ type: "STORE_FILE_DATA", payload: { files: [K] } }); | ||
} | ||
} catch (v) { | ||
if (v instanceof Error) | ||
throw M && M(v), v; | ||
throw z && z(v), v; | ||
} | ||
} | ||
u(); | ||
}, []), B(() => { | ||
a && a.length > 0 && (G(a) || D({ type: "STORE_FILE_DATA", payload: { files: a } })); | ||
}, [a]), B(() => { | ||
D({ | ||
c(); | ||
}, []), G(() => { | ||
a && a.length > 0 && (U(a) || P({ type: "STORE_FILE_DATA", payload: { files: a } })); | ||
}, [a]), G(() => { | ||
P({ | ||
type: "SET_COMPONENT_STATE", | ||
@@ -1239,5 +1240,5 @@ payload: { | ||
rounded: k ?? !0, | ||
fileHeight: Y ?? "h-32", | ||
fileHeight: q ?? "h-32", | ||
fileWidth: te ?? "w-44", | ||
disabled: z ?? !1, | ||
disabled: I ?? !1, | ||
allowEditing: m ?? !1 | ||
@@ -1251,31 +1252,31 @@ } | ||
s, | ||
Y, | ||
q, | ||
te, | ||
k, | ||
z, | ||
I, | ||
m | ||
]); | ||
const q = (u) => { | ||
const v = Array.from(u.target.files || []); | ||
G(v) || D({ type: "APPEND_FILE_DATA", payload: { files: v } }); | ||
}, A = (u) => { | ||
D({ type: "REMOVE_FILE_DATA", payload: u }), j && j(u); | ||
}, L = (u) => { | ||
ae && ae(u); | ||
const C = (c) => { | ||
const v = Array.from(c.target.files || []); | ||
U(v) || P({ type: "APPEND_FILE_DATA", payload: { files: v } }); | ||
}, D = (c) => { | ||
P({ type: "REMOVE_FILE_DATA", payload: c }), j && j(c); | ||
}, $ = (c) => { | ||
ae && ae(c); | ||
}; | ||
B(() => { | ||
re && re(N); | ||
}, [N]); | ||
const $ = (u) => { | ||
u.preventDefault(), u.dataTransfer.dropEffect = "copy"; | ||
}, ne = (u) => { | ||
u.preventDefault(); | ||
}, ie = (u) => { | ||
u.preventDefault(); | ||
const v = Array.from(u.dataTransfer.files); | ||
v && v.length > 0 && (G(v) || D({ type: "APPEND_FILE_DATA", payload: { files: v } })); | ||
}, le = (u) => { | ||
if (u && P.index != null) { | ||
const v = Array.from(N); | ||
v[P.index] = u, D({ | ||
G(() => { | ||
re && re(A); | ||
}, [A]); | ||
const le = (c) => { | ||
c.preventDefault(), c.dataTransfer.dropEffect = "copy"; | ||
}, oe = (c) => { | ||
c.preventDefault(); | ||
}, se = (c) => { | ||
c.preventDefault(); | ||
const v = Array.from(c.dataTransfer.files); | ||
v && v.length > 0 && (U(v) || (P({ type: "APPEND_FILE_DATA", payload: { files: v } }), ne && ne(c))); | ||
}, ce = (c) => { | ||
if (c && M.index != null) { | ||
const v = Array.from(A); | ||
v[M.index] = c, P({ | ||
type: "STORE_FILE_DATA", | ||
@@ -1287,4 +1288,4 @@ payload: { | ||
} | ||
}, oe = () => { | ||
D({ | ||
}, ue = () => { | ||
P({ | ||
type: "SET_IMAGE_EDITOR_DATA", | ||
@@ -1298,21 +1299,21 @@ payload: { | ||
}; | ||
return me.zoom ? /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(_0, {}) }) : P.isEditing && P.file ? /* @__PURE__ */ t.jsx(m0, { fallback: /* @__PURE__ */ t.jsx(t.Fragment, {}), children: /* @__PURE__ */ t.jsx( | ||
return pe.zoom ? /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(_0, {}) }) : M.isEditing && M.file ? /* @__PURE__ */ t.jsx(m0, { fallback: /* @__PURE__ */ t.jsx(t.Fragment, {}), children: /* @__PURE__ */ t.jsx( | ||
S0, | ||
{ | ||
open: P.isEditing, | ||
file: P.file, | ||
onSaveImage: le, | ||
onClose: oe, | ||
open: M.isEditing, | ||
file: M.file, | ||
onSaveImage: ce, | ||
onClose: ue, | ||
downloadOnSave: !1 | ||
} | ||
) }) : /* @__PURE__ */ t.jsx("div", { className: "w-full", children: /* @__PURE__ */ t.jsx("div", { className: "flex flex-row max-h-2", children: /* @__PURE__ */ t.jsxs("div", { className: `${T ?? "basis-11/12"} mx-auto`, children: [ | ||
N.length > 0 && /* @__PURE__ */ t.jsx( | ||
A.length > 0 && /* @__PURE__ */ t.jsx( | ||
R0, | ||
{ | ||
fileData: N, | ||
fileData: A, | ||
multiple: x, | ||
disabled: z, | ||
disabled: I, | ||
accept: d, | ||
onChange: F, | ||
handleImage: q | ||
handleImage: C | ||
} | ||
@@ -1323,9 +1324,9 @@ ), | ||
{ | ||
className: `${V && `overflow-auto ${V}`} ${N.length == 0 && `border-2 border-dashed border-gray-300 ${z ? "" : "hover:bg-stone-200"} `} flex flex-row flex-wrap gap-4 p-6 bg-stone-100 shadow dark:bg-gray-800 `, | ||
onDragOver: $, | ||
onDragLeave: ne, | ||
onDrop: ie, | ||
className: `${V && `overflow-auto ${V}`} ${A.length == 0 && `border-2 border-dashed border-gray-300 ${I ? "" : "hover:bg-stone-200"} `} flex flex-row flex-wrap gap-4 p-6 bg-stone-100 shadow dark:bg-gray-800 `, | ||
onDragOver: le, | ||
onDragLeave: oe, | ||
onDrop: se, | ||
"data-testid": "dropzone", | ||
children: N.length > 0 ? N.map((u, v) => /* @__PURE__ */ t.jsxs("div", { className: "relative pb-5 group", onClick: () => L(u), children: [ | ||
/* @__PURE__ */ t.jsx("div", { className: "ml-9", children: pe.removeFile ? /* @__PURE__ */ t.jsx( | ||
children: A.length > 0 ? A.map((c, v) => /* @__PURE__ */ t.jsxs("div", { className: "relative pb-5 group", onClick: () => $(c), children: [ | ||
/* @__PURE__ */ t.jsx("div", { className: "ml-9", children: ie.removeFile ? /* @__PURE__ */ t.jsx( | ||
"svg", | ||
@@ -1335,3 +1336,3 @@ { | ||
"data-testid": "remove-file-button", | ||
onClick: () => A(u), | ||
onClick: () => D(c), | ||
className: "absolute -top-2 right-0 z-10 text-black opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer h-5 w-5", | ||
@@ -1343,3 +1344,3 @@ fill: "currentColor", | ||
) : /* @__PURE__ */ t.jsx(t.Fragment, {}) }), | ||
/* @__PURE__ */ t.jsx("div", { className: "clear-right", children: /* @__PURE__ */ t.jsx(E0, { file: u, index: v }) }) | ||
/* @__PURE__ */ t.jsx("div", { className: "clear-right", children: /* @__PURE__ */ t.jsx(E0, { file: c, index: v }) }) | ||
] }, v)) : /* @__PURE__ */ t.jsxs( | ||
@@ -1349,3 +1350,3 @@ "label", | ||
htmlFor: "fileInput", | ||
className: `text-black dark:text-slate-100 ${z ? "mx-auto cursor-not-allowed flex items-center" : "mx-auto cursor-pointer flex items-center"}`, | ||
className: `text-black dark:text-slate-100 ${I ? "mx-auto cursor-not-allowed flex items-center" : "mx-auto cursor-pointer flex items-center"}`, | ||
children: [ | ||
@@ -1357,6 +1358,6 @@ "Drop files here, or click to browse files", | ||
id: "fileInput", | ||
disabled: z, | ||
disabled: I, | ||
type: "file", | ||
onChange: (u) => { | ||
q(u), F && F(u); | ||
onChange: (c) => { | ||
C(c), F && F(c); | ||
}, | ||
@@ -1363,0 +1364,0 @@ multiple: x ?? !0, |
@@ -5,3 +5,3 @@ { | ||
"private": false, | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"author": "Usama Chouhan (musama619)", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133275
2595