@rws-aoa/react-library
Version:
RWS AOA Design System
99 lines (98 loc) • 3.51 kB
JavaScript
import { jsx as v, jsxs as k } from "react/jsx-runtime";
import { c as P } from "../../../chunks/compiler-runtime.hDcrsMwn.js";
import { Box as w } from "@mui/material";
import { useDropzone as A } from "react-dropzone";
import { toast as E } from "react-toastify";
import { isExtensionAllowed as I } from "../../../_constants.js";
function G(i) {
const e = P.c(30);
let d;
e[0] !== i.maxUploadFiles || e[1] !== i.maxUploadSizeExceededWarning ? (d = function() {
E(i.maxUploadSizeExceededWarning ?? `U heeft meer dan ${i.maxUploadFiles} bestand(en) geselecteerd. Dit is niet toegestaan.`, {
type: "warning"
});
}, e[0] = i.maxUploadFiles, e[1] = i.maxUploadSizeExceededWarning, e[2] = d) : d = e[2];
const s = d;
let f;
e[3] !== i || e[4] !== s ? (f = function(F, C) {
C.length > 0 && (C.every(V) ? s() : E(i.extensionWarning, {
type: "warning"
}));
const o = [...i.currentFiles];
for (const r of F) {
const S = o.findIndex((_) => _.file.name === r.name);
S === -1 ? o.push({
file: r,
...i.perFileProperties?.(r)
}) : o.splice(S, 1, {
file: r,
...i.perFileProperties?.(r)
});
}
i.maxUploadFiles && o.length > i.maxUploadFiles ? s() : i.storeFiles(o);
}, e[3] = i, e[4] = s, e[5] = f) : f = e[5];
const h = f;
let c;
e[6] !== i ? (c = function(F) {
return i.customFileValidator?.(F) ? {
code: "custom-validator",
message: i.extensionWarning
} : I(i.extensionRegex, F.name) ? null : {
code: "name-not-ok",
message: i.extensionWarning
};
}, e[6] = i, e[7] = c) : c = e[7];
const U = c;
let m;
e[8] !== U || e[9] !== h || e[10] !== i.extensions || e[11] !== i.isDisabled || e[12] !== i.maxUploadFiles ? (m = {
onDrop: h,
disabled: i.isDisabled,
accept: i.extensions,
maxFiles: i.maxUploadFiles,
validator: U
}, e[8] = U, e[9] = h, e[10] = i.extensions, e[11] = i.isDisabled, e[12] = i.maxUploadFiles, e[13] = m) : m = e[13];
const {
getRootProps: b,
getInputProps: D
} = A(m);
let t;
e[14] !== b ? (t = b(), e[14] = b, e[15] = t) : t = e[15];
const y = i.dataQas?.root ?? "file-dropzone-root";
let x;
e[16] === Symbol.for("react.memo_cache_sentinel") ? (x = {
"&:focus": {
outline: "none"
}
}, e[16] = x) : x = e[16];
let n;
e[17] !== D ? (n = D(), e[17] = D, e[18] = n) : n = e[18];
const W = i.dataQas?.input ?? "file-drop-input";
let l;
e[19] !== n || e[20] !== W ? (l = /* @__PURE__ */ v("input", { ...n, "aria-label": "File drop", "data-qa": W, "data-testid": "file-drop-input" }), e[19] = n, e[20] = W, e[21] = l) : l = e[21];
let u;
e[22] === Symbol.for("react.memo_cache_sentinel") ? (u = {
backgroundColor: "var(--color-rijks-grey-2)",
borderWidth: 1,
borderStyle: "dashed",
borderColor: "black",
marginBottom: 0.5,
textAlign: "center"
}, e[22] = u) : u = e[22];
let a;
e[23] !== i.fileDropChildren ? (a = /* @__PURE__ */ v(w, { sx: u, children: i.fileDropChildren }), e[23] = i.fileDropChildren, e[24] = a) : a = e[24];
let g;
return e[25] !== a || e[26] !== t || e[27] !== y || e[28] !== l ? (g = /* @__PURE__ */ k(w, { ...t, "data-qa": y, sx: x, children: [
l,
a
] }), e[25] = a, e[26] = t, e[27] = y, e[28] = l, e[29] = g) : g = e[29], g;
}
function V(i) {
return i.errors.every(j);
}
function j(i) {
return i.code === "too-many-files";
}
export {
G as AoaFileDropzone
};
//# sourceMappingURL=FileDropzone.js.map