react-files-preview
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -17,3 +17,3 @@ import Re, { createContext as h0, useReducer as v0, useState as He, useEffect as G, useContext as S, Suspense as m0 } from "react"; | ||
Ve = 1; | ||
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 }; | ||
var a = Re, l = 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, N) { | ||
@@ -27,3 +27,3 @@ var g, T = {}, k = null, V = null; | ||
T[g] === void 0 && (T[g] = d[g]); | ||
return { $$typeof: o, type: x, key: k, ref: V, props: T, _owner: b.current }; | ||
return { $$typeof: l, type: x, key: k, ref: V, props: T, _owner: b.current }; | ||
} | ||
@@ -45,4 +45,4 @@ return Q.Fragment = p, Q.jsx = m, Q.jsxs = m, Q; | ||
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"), 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) { | ||
var a = Re, l = 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 A(e) { | ||
if (e === null || typeof e != "object") | ||
@@ -53,3 +53,3 @@ return null; | ||
} | ||
var F = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
var P = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
function j(e) { | ||
@@ -64,3 +64,3 @@ { | ||
{ | ||
var i = F.ReactDebugCurrentFrame, f = i.getStackAddendum(); | ||
var i = P.ReactDebugCurrentFrame, f = i.getStackAddendum(); | ||
f !== "" && (r += "%s", n = n.concat([f])); | ||
@@ -73,6 +73,6 @@ var h = n.map(function(u) { | ||
} | ||
var re = !1, ae = !1, ne = !1, A = !1, pe = !1, ie; | ||
var re = !1, ae = !1, ne = !1, F = !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 | ||
return !!(typeof e == "string" || typeof e == "function" || e === w || e === s || pe || e === b || e === N || e === g || F || 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 | ||
@@ -83,3 +83,3 @@ // we don't know which Flight build this will end up being used | ||
} | ||
function P(e, r, n) { | ||
function D(e, r, n) { | ||
var i = e.displayName; | ||
@@ -124,3 +124,3 @@ if (i) | ||
case d: | ||
return P(e, e.render, "ForwardRef"); | ||
return D(e, e.render, "ForwardRef"); | ||
case T: | ||
@@ -140,3 +140,3 @@ var i = e.displayName || null; | ||
} | ||
var D = Object.assign, $ = 0, le, oe, se, ce, ue, c, v; | ||
var L = Object.assign, $ = 0, le, oe, se, ce, ue, c, v; | ||
function H() { | ||
@@ -177,21 +177,21 @@ } | ||
Object.defineProperties(console, { | ||
log: D({}, e, { | ||
log: L({}, e, { | ||
value: le | ||
}), | ||
info: D({}, e, { | ||
info: L({}, e, { | ||
value: oe | ||
}), | ||
warn: D({}, e, { | ||
warn: L({}, e, { | ||
value: se | ||
}), | ||
error: D({}, e, { | ||
error: L({}, e, { | ||
value: ce | ||
}), | ||
group: D({}, e, { | ||
group: L({}, e, { | ||
value: ue | ||
}), | ||
groupCollapsed: D({}, e, { | ||
groupCollapsed: L({}, e, { | ||
value: c | ||
}), | ||
groupEnd: D({}, e, { | ||
groupEnd: L({}, e, { | ||
value: v | ||
@@ -204,3 +204,3 @@ }) | ||
} | ||
var W = F.ReactCurrentDispatcher, K; | ||
var W = P.ReactCurrentDispatcher, K; | ||
function Z(e, r, n) { | ||
@@ -250,4 +250,4 @@ { | ||
Reflect.construct(u, []); | ||
} catch (L) { | ||
i = L; | ||
} catch (I) { | ||
i = I; | ||
} | ||
@@ -258,4 +258,4 @@ Reflect.construct(e, [], u); | ||
u.call(); | ||
} catch (L) { | ||
i = L; | ||
} catch (I) { | ||
i = I; | ||
} | ||
@@ -267,20 +267,20 @@ e.call(u.prototype); | ||
throw Error(); | ||
} catch (L) { | ||
i = L; | ||
} catch (I) { | ||
i = I; | ||
} | ||
e(); | ||
} | ||
} catch (L) { | ||
if (L && i && typeof L.stack == "string") { | ||
for (var l = L.stack.split(` | ||
} catch (I) { | ||
if (I && i && typeof I.stack == "string") { | ||
for (var o = I.stack.split(` | ||
`), _ = i.stack.split(` | ||
`), y = l.length - 1, E = _.length - 1; y >= 1 && E >= 0 && l[y] !== _[E]; ) | ||
`), y = o.length - 1, E = _.length - 1; y >= 1 && E >= 0 && o[y] !== _[E]; ) | ||
E--; | ||
for (; y >= 1 && E >= 0; y--, E--) | ||
if (l[y] !== _[E]) { | ||
if (o[y] !== _[E]) { | ||
if (y !== 1 || E !== 1) | ||
do | ||
if (y--, E--, E < 0 || l[y] !== _[E]) { | ||
if (y--, E--, E < 0 || o[y] !== _[E]) { | ||
var O = ` | ||
` + l[y].replace(" at new ", " at "); | ||
` + o[y].replace(" at new ", " at "); | ||
return e.displayName && O.includes("<anonymous>") && (O = O.replace("<anonymous>", e.displayName)), typeof e == "function" && de.set(e, O), O; | ||
@@ -334,3 +334,3 @@ } | ||
} | ||
var ve = Object.prototype.hasOwnProperty, Te = {}, ke = F.ReactDebugCurrentFrame; | ||
var ve = Object.prototype.hasOwnProperty, Te = {}, ke = P.ReactDebugCurrentFrame; | ||
function me(e) { | ||
@@ -348,3 +348,3 @@ if (e) { | ||
if (h(e, u)) { | ||
var l = void 0; | ||
var o = void 0; | ||
try { | ||
@@ -355,7 +355,7 @@ if (typeof e[u] != "function") { | ||
} | ||
l = e[u](r, u, i, n, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
o = e[u](r, u, i, n, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
} catch (y) { | ||
l = y; | ||
o = y; | ||
} | ||
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)); | ||
o && !(o 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 o), me(null)), o instanceof Error && !(o.message in Te) && (Te[o.message] = !0, me(f), j("Failed %s type: %s", n, o.message), me(null)); | ||
} | ||
@@ -388,3 +388,3 @@ } | ||
} | ||
var X = F.ReactCurrentOwner, Ke = { | ||
var X = P.ReactCurrentOwner, Ke = { | ||
key: !0, | ||
@@ -441,5 +441,5 @@ ref: !0, | ||
var a0 = function(e, r, n, i, f, h, u) { | ||
var l = { | ||
var o = { | ||
// This tag allows us to uniquely identify this as a React Element | ||
$$typeof: o, | ||
$$typeof: l, | ||
// Built-in properties that belong on the element | ||
@@ -453,3 +453,3 @@ type: e, | ||
}; | ||
return l._store = {}, Object.defineProperty(l._store, "validated", { | ||
return o._store = {}, Object.defineProperty(o._store, "validated", { | ||
configurable: !1, | ||
@@ -459,3 +459,3 @@ enumerable: !1, | ||
value: !1 | ||
}), Object.defineProperty(l, "_self", { | ||
}), Object.defineProperty(o, "_self", { | ||
configurable: !1, | ||
@@ -465,3 +465,3 @@ enumerable: !1, | ||
value: i | ||
}), Object.defineProperty(l, "_source", { | ||
}), Object.defineProperty(o, "_source", { | ||
configurable: !1, | ||
@@ -471,8 +471,8 @@ enumerable: !1, | ||
value: f | ||
}), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l; | ||
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o; | ||
}; | ||
function n0(e, r, n, i, f) { | ||
{ | ||
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)); | ||
var h, u = {}, o = null, _ = null; | ||
n !== void 0 && (Oe(n), o = "" + n), Qe(r) && (Oe(r.key), o = "" + r.key), Xe(r) && (_ = r.ref, e0(r, f)); | ||
for (h in r) | ||
@@ -485,10 +485,10 @@ ve.call(r, h) && !Ke.hasOwnProperty(h) && (u[h] = r[h]); | ||
} | ||
if (l || _) { | ||
if (o || _) { | ||
var E = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; | ||
l && t0(u, E), _ && r0(u, E); | ||
o && t0(u, E), _ && r0(u, E); | ||
} | ||
return a0(e, l, _, f, i, X.current, u); | ||
return a0(e, o, _, f, i, X.current, u); | ||
} | ||
} | ||
var ye = F.ReactCurrentOwner, Fe = F.ReactDebugCurrentFrame; | ||
var ye = P.ReactCurrentOwner, Fe = P.ReactDebugCurrentFrame; | ||
function B(e) { | ||
@@ -504,3 +504,3 @@ if (e) { | ||
function Ee(e) { | ||
return typeof e == "object" && e !== null && e.$$typeof === o; | ||
return typeof e == "object" && e !== null && e.$$typeof === l; | ||
} | ||
@@ -568,3 +568,3 @@ function Pe() { | ||
else if (e) { | ||
var f = I(e); | ||
var f = A(e); | ||
if (typeof f == "function" && f !== e.entries) | ||
@@ -617,8 +617,8 @@ for (var h = f.call(e), u; !(u = h.next()).done; ) | ||
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 o = ""; | ||
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (o += " 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 += Pe(); | ||
_ ? o += _ : o += Pe(); | ||
var y; | ||
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); | ||
e === null ? y = "null" : xe(e) ? y = "array" : e !== void 0 && e.$$typeof === l ? (y = "<" + (C(e.type) || "Unknown") + " />", o = " 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, o); | ||
} | ||
@@ -662,3 +662,3 @@ var E = n0(e, r, n, f, h); | ||
"image/tiff" | ||
], w0 = (a, o) => { | ||
], w0 = (a, l) => { | ||
const p = a.fileData.length - 1, w = (s) => { | ||
@@ -678,17 +678,17 @@ const m = a.fileData[s]; | ||
}; | ||
switch (o.type) { | ||
switch (l.type) { | ||
case "STORE_FILE_DATA": | ||
return { ...a, fileData: o.payload.files }; | ||
return { ...a, fileData: l.payload.files }; | ||
case "SET_COMPONENT_STATE": | ||
return { ...a, componentState: o.payload }; | ||
return { ...a, componentState: l.payload }; | ||
case "APPEND_FILE_DATA": | ||
return { ...a, fileData: [...a.fileData, ...o.payload.files] }; | ||
return { ...a, fileData: [...a.fileData, ...l.payload.files] }; | ||
case "STORE_FILE_STATE": | ||
return { ...a, fileState: o.payload }; | ||
return { ...a, fileState: l.payload }; | ||
case "SET_IMAGE_EDITOR_DATA": | ||
return { ...a, imageEditorState: o.payload }; | ||
return { ...a, imageEditorState: l.payload }; | ||
case "REMOVE_FILE_DATA": | ||
return { | ||
...a, | ||
fileData: a.fileData.filter((s) => s.name !== o.payload.name) | ||
fileData: a.fileData.filter((s) => s.name !== l.payload.name) | ||
}; | ||
@@ -744,3 +744,3 @@ case "GET_NEXT_FILE": { | ||
}), y0 = ({ children: a }) => { | ||
const [o, p] = v0(w0, { | ||
const [l, p] = v0(w0, { | ||
fileData: [], | ||
@@ -771,4 +771,4 @@ fileState: { | ||
}); | ||
return /* @__PURE__ */ t.jsx(R.Provider, { value: { state: o, dispatch: p }, children: a }); | ||
}, b0 = ({ file: a, fileSrc: o, index: p, isImage: w }) => { | ||
return /* @__PURE__ */ t.jsx(R.Provider, { value: { state: l, dispatch: p }, children: a }); | ||
}, b0 = ({ file: a, fileSrc: l, index: p, isImage: w }) => { | ||
const [b, s] = He(null); | ||
@@ -795,7 +795,7 @@ G(() => { | ||
g.showFileSize && /* @__PURE__ */ t.jsx("span", { "data-testid": "file-size", className: "text-[10px] text-black dark:text-slate-100", children: b }), | ||
g.downloadFile && o && /* @__PURE__ */ t.jsx( | ||
g.downloadFile && l && /* @__PURE__ */ t.jsx( | ||
"a", | ||
{ | ||
className: "float-right absolute top-1 right-0 text-gray-500 dark:text-white", | ||
href: o, | ||
href: l, | ||
target: "_blank", | ||
@@ -864,3 +864,3 @@ download: a == null ? void 0 : a.name, | ||
} | ||
], je = ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/tiff"], E0 = ({ file: a, index: o }) => { | ||
], je = ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/tiff"], E0 = ({ file: a, index: l }) => { | ||
const [p, w] = He(null); | ||
@@ -879,3 +879,3 @@ G(() => { | ||
fileSrc: URL.createObjectURL(a), | ||
index: o, | ||
index: l, | ||
isImage: je.includes(a.type), | ||
@@ -931,9 +931,9 @@ fileName: a.name, | ||
), | ||
/* @__PURE__ */ t.jsx("div", { className: "h-5 w-44", children: p && /* @__PURE__ */ t.jsx(b0, { file: a, fileSrc: p, index: o, isImage: je.includes(a.type) }) }) | ||
/* @__PURE__ */ t.jsx("div", { className: "h-5 w-44", children: p && /* @__PURE__ */ t.jsx(b0, { file: a, fileSrc: p, index: l, isImage: je.includes(a.type) }) }) | ||
] }); | ||
}, j0 = () => { | ||
const a = S(R).state.fileData, o = S(R).state.fileState; | ||
return /* @__PURE__ */ t.jsx("div", { id: "slider-count", className: "absolute bottom-5 right-0 left-0 flex items-center justify-center z-50", children: (o == null ? void 0 : o.index) !== null && /* @__PURE__ */ t.jsx("div", { className: "text-white text-1xl", children: `${o.index + 1} of ${a == null ? void 0 : a.length}` }) }); | ||
const a = S(R).state.fileData, l = S(R).state.fileState; | ||
return /* @__PURE__ */ t.jsx("div", { id: "slider-count", className: "absolute bottom-5 right-0 left-0 flex items-center justify-center z-50", children: (l == null ? void 0 : l.index) !== null && /* @__PURE__ */ t.jsx("div", { className: "text-white text-1xl", children: `${l.index + 1} of ${a == null ? void 0 : a.length}` }) }); | ||
}, _0 = () => { | ||
const a = S(R).state.fileState, o = S(R).state.componentState, p = Ue.filter((d) => d.type === a.type), { dispatch: w } = S(R), b = () => { | ||
const a = S(R).state.fileState, l = S(R).state.componentState, p = Ue.filter((d) => d.type === a.type), { dispatch: w } = S(R), b = () => { | ||
a.fileSrc && URL.revokeObjectURL(a.fileSrc), w({ | ||
@@ -990,3 +990,3 @@ type: "STORE_FILE_STATE", | ||
), | ||
a.fileSrc && /* @__PURE__ */ t.jsxs( | ||
a.fileSrc && l.downloadFile && /* @__PURE__ */ t.jsxs( | ||
"a", | ||
@@ -1080,3 +1080,3 @@ { | ||
"data-testid": "image-slider", | ||
className: `${o.rounded && "rounded-lg"} relative w-[130vh] max-sm:w-96 max-md:w-[75vh] h-[78vh] max-sm:h-52 max-md:h-80 bg-slate-400 overflow-hidden transition-all delay-750 ease-in`, | ||
className: `${l.rounded && "rounded-lg"} relative w-[130vh] max-sm:w-96 max-md:w-[75vh] h-[78vh] max-sm:h-52 max-md:h-80 bg-slate-400 overflow-hidden transition-all delay-750 ease-in`, | ||
children: a.isImage ? a.fileSrc && /* @__PURE__ */ t.jsx("img", { className: "object-fit w-full h-full ", src: a.fileSrc, alt: "Zoomed Image" }) : /* @__PURE__ */ t.jsx("span", { className: "flex w-full h-full items-center justify-center text-4xl", children: /* @__PURE__ */ t.jsx( | ||
@@ -1130,3 +1130,3 @@ "span", | ||
), | ||
o.showSliderCount ? /* @__PURE__ */ t.jsx(j0, {}) : /* @__PURE__ */ t.jsx(t.Fragment, {}) | ||
l.showSliderCount ? /* @__PURE__ */ t.jsx(j0, {}) : /* @__PURE__ */ t.jsx(t.Fragment, {}) | ||
] | ||
@@ -1150,4 +1150,4 @@ } | ||
type: "file", | ||
onChange: (o) => { | ||
a.handleImage(o), a.onChange && a.onChange(o); | ||
onChange: (l) => { | ||
a.handleImage(l), a.onChange && a.onChange(l); | ||
}, | ||
@@ -1167,3 +1167,3 @@ style: { display: "none" }, | ||
files: a, | ||
url: o, | ||
url: l, | ||
downloadFile: p, | ||
@@ -1183,4 +1183,4 @@ removeFile: w, | ||
fileWidth: te, | ||
disabled: I, | ||
onChange: F, | ||
disabled: A, | ||
onChange: P, | ||
onRemove: j, | ||
@@ -1192,5 +1192,5 @@ onError: z, | ||
}) => { | ||
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) => { | ||
const F = S(R).state.fileData, pe = S(R).state.fileState, ie = S(R).state.componentState, M = S(R).state.imageEditorState, { dispatch: D } = S(R), U = (c) => { | ||
let v = !1; | ||
if (g && (A.length + c.length > g || c.length > g)) | ||
if (g && (F.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`); | ||
@@ -1205,3 +1205,3 @@ return N && c.forEach((H) => { | ||
try { | ||
if (o) { | ||
if (l) { | ||
const v = [ | ||
@@ -1213,3 +1213,3 @@ { type: "image/jpeg", ext: ".jpg" }, | ||
{ type: "image/tiff", ext: ".tiff" } | ||
], J = await (await fetch(o)).blob(); | ||
], J = await (await fetch(l)).blob(); | ||
let fe = null; | ||
@@ -1221,3 +1221,3 @@ const W = v.filter((Z) => Z.type === J.type); | ||
}); | ||
P({ type: "STORE_FILE_DATA", payload: { files: [K] } }); | ||
D({ type: "STORE_FILE_DATA", payload: { files: [K] } }); | ||
} | ||
@@ -1231,5 +1231,5 @@ } catch (v) { | ||
}, []), G(() => { | ||
a && a.length > 0 && (U(a) || P({ type: "STORE_FILE_DATA", payload: { files: a } })); | ||
a && a.length > 0 && (U(a) || D({ type: "STORE_FILE_DATA", payload: { files: a } })); | ||
}, [a]), G(() => { | ||
P({ | ||
D({ | ||
type: "SET_COMPONENT_STATE", | ||
@@ -1244,3 +1244,3 @@ payload: { | ||
fileWidth: te ?? "w-44", | ||
disabled: I ?? !1, | ||
disabled: A ?? !1, | ||
allowEditing: m ?? !1 | ||
@@ -1257,3 +1257,3 @@ } | ||
k, | ||
I, | ||
A, | ||
m | ||
@@ -1263,5 +1263,5 @@ ]); | ||
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); | ||
U(v) || D({ type: "APPEND_FILE_DATA", payload: { files: v } }); | ||
}, L = (c) => { | ||
D({ type: "REMOVE_FILE_DATA", payload: c }), j && j(c); | ||
}, $ = (c) => { | ||
@@ -1271,4 +1271,4 @@ ae && ae(c); | ||
G(() => { | ||
re && re(A); | ||
}, [A]); | ||
re && re(F); | ||
}, [F]); | ||
const le = (c) => { | ||
@@ -1281,7 +1281,7 @@ c.preventDefault(), c.dataTransfer.dropEffect = "copy"; | ||
const v = Array.from(c.dataTransfer.files); | ||
v && v.length > 0 && (U(v) || (P({ type: "APPEND_FILE_DATA", payload: { files: v } }), ne && ne(c))); | ||
v && v.length > 0 && (U(v) || (D({ 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({ | ||
const v = Array.from(F); | ||
v[M.index] = c, D({ | ||
type: "STORE_FILE_DATA", | ||
@@ -1294,3 +1294,3 @@ payload: { | ||
}, ue = () => { | ||
P({ | ||
D({ | ||
type: "SET_IMAGE_EDITOR_DATA", | ||
@@ -1314,10 +1314,10 @@ payload: { | ||
) }) : /* @__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: [ | ||
A.length > 0 && /* @__PURE__ */ t.jsx( | ||
F.length > 0 && /* @__PURE__ */ t.jsx( | ||
R0, | ||
{ | ||
fileData: A, | ||
fileData: F, | ||
multiple: x, | ||
disabled: I, | ||
disabled: A, | ||
accept: d, | ||
onChange: F, | ||
onChange: P, | ||
handleImage: C | ||
@@ -1329,8 +1329,8 @@ } | ||
{ | ||
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, | ||
className: `${V && `overflow-auto ${V}`} ${F.length == 0 && `border-2 border-dashed border-gray-300 ${A ? "" : "hover:bg-stone-200"} `} flex flex-row flex-wrap gap-4 p-6 bg-stone-100 shadow dark:bg-gray-800 `, | ||
onDragOver: A ? void 0 : le, | ||
onDragLeave: A ? void 0 : oe, | ||
onDrop: A ? void 0 : se, | ||
"data-testid": "dropzone", | ||
children: A.length > 0 ? A.map((c, v) => /* @__PURE__ */ t.jsxs("div", { className: "relative pb-5 group", onClick: () => $(c), children: [ | ||
children: F.length > 0 ? F.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( | ||
@@ -1341,3 +1341,3 @@ "svg", | ||
"data-testid": "remove-file-button", | ||
onClick: () => D(c), | ||
onClick: () => L(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", | ||
@@ -1354,3 +1354,3 @@ fill: "currentColor", | ||
htmlFor: "fileInput", | ||
className: `text-black dark:text-slate-100 ${I ? "mx-auto cursor-not-allowed flex items-center" : "mx-auto cursor-pointer flex items-center"}`, | ||
className: `text-black dark:text-slate-100 ${A ? "mx-auto cursor-not-allowed flex items-center" : "mx-auto cursor-pointer flex items-center"}`, | ||
children: [ | ||
@@ -1362,6 +1362,6 @@ "Drop files here, or click to browse files", | ||
id: "fileInput", | ||
disabled: I, | ||
disabled: A, | ||
type: "file", | ||
onChange: (c) => { | ||
C(c), F && F(c); | ||
C(c), P && P(c); | ||
}, | ||
@@ -1368,0 +1368,0 @@ multiple: x ?? !0, |
@@ -5,3 +5,3 @@ { | ||
"private": false, | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"author": "Usama Chouhan (musama619)", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
@@ -20,4 +20,3 @@ ![react-files-preview](https://github.com/musama619/react-files-preview/blob/main/react-files-preview.png?raw=true) | ||
``` | ||
## 🚀 Demo | ||
https://react-files-preview.netlify.app/ | ||
## [Stackblitz - Check It Live](https://stackblitz.com/edit/vitejs-vite-xjck27?file=src%2FApp.tsx) | ||
@@ -24,0 +23,0 @@ ## Usage |
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
136483
62