synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
105 lines (104 loc) • 2.97 kB
JavaScript
import { jsxs as s, jsx as e } from "react/jsx-runtime";
import { useGetFileBatch as F } from "../../../synapse-queries/file/useFiles.js";
import { Box as c, Button as f } from "@mui/material";
import { useState as b } from "react";
import v from "../../DirectDownloadButton.js";
import { FileUpload as B } from "../../FileUpload/FileUpload.js";
import a from "../../IconSvg/IconSvg.js";
function $(p) {
const {
fileHandleAssociations: n = [],
uploadCallback: m,
id: o,
documentName: u,
isMultiFileUpload: i = !1,
onClearAttachment: t,
isLoading: x = !1,
uploadBtnVariant: g = "outlined"
} = p, [I, d] = b(!1), { data: U } = F(
{
includeFileHandles: !0,
includePreSignedURLs: !1,
includePreviewPreSignedURLs: !1,
requestedFiles: n
},
{ enabled: n.length > 0 }
);
return /* @__PURE__ */ s(
c,
{
id: o,
sx: {
display: "flex",
flexDirection: i ? "column" : "row",
alignItems: i ? "flex-start" : "center",
justifyContent: "flex-start",
gap: 2,
my: 2
},
children: [
/* @__PURE__ */ e(
B,
{
id: `${o}-upload`,
onUploadStart: () => d(!0),
onComplete: (l) => {
d(!1), m(l);
},
label: `Upload ${u}`,
buttonProps: {
disabled: x,
variant: g,
endIcon: /* @__PURE__ */ e(a, { icon: "upload", wrap: !1 })
}
}
),
n.map((l, r) => {
const w = U?.requestedFiles.find(
(H) => H.fileHandleId === l.fileHandleId
)?.fileHandle;
return /* @__PURE__ */ s(c, { children: [
/* @__PURE__ */ e(
v,
{
id: `${o}-download-${r}`,
variant: "text",
endIcon: /* @__PURE__ */ e(a, { icon: "download", wrap: !1 }),
color: "primary",
fileHandleAssociation: l,
fileName: w?.fileName,
sx: {
/* Do not apply text-transform because the text is a raw filename */
textTransform: "none"
}
},
r
),
t && /* @__PURE__ */ e(
f,
{
className: "clear-x",
variant: "text",
onClick: () => t(l.fileHandleId),
children: /* @__PURE__ */ e(a, { icon: "clear" })
}
)
] }, l.fileHandleId);
}),
I && /* @__PURE__ */ e(
f,
{
disabled: !0,
variant: "text",
endIcon: /* @__PURE__ */ e(a, { icon: "download", wrap: !1 }),
children: "Uploading..."
}
)
]
}
);
}
export {
$ as UploadDocumentField
};
//# sourceMappingURL=UploadDocumentField.js.map