@monolith-forensics/monolith-ui 1.2.54 → 1.2.56
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.
|
@@ -98,6 +98,9 @@ const StyledContainer = styled.div.attrs({ className: "FileViewer-container" })
|
|
|
98
98
|
|
|
99
99
|
&:hover {
|
|
100
100
|
background-color: ${(props) => props.theme.palette.primary.main};
|
|
101
|
+
border-radius: 10px;
|
|
102
|
+
border: 4px solid rgba(0, 0, 0, 0);
|
|
103
|
+
background-clip: padding-box;
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
|
|
@@ -164,8 +167,7 @@ export const FileViewer = ({ file, open, isPending, onClose }) => {
|
|
|
164
167
|
return (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsxs(StyledContainer, { className: "mfui-FileViewer", children: [_jsxs(StyledMenu, { className: "FileViewer-menu", children: [_jsx(Button, { variant: "text", onClick: () => {
|
|
165
168
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
166
169
|
setZoomFactor(1);
|
|
167
|
-
}, children: _jsx(XIcon, { size: 18 }) }), _jsx("div", { children: file.name }),
|
|
168
|
-
)] }), file.url ? (_jsxs(StyledInnerContainer, { onClick: handleBackgroundClick, "data-type": viewerType, children: [viewerType === ViewerTypes.PDF && (_jsx(PdfViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Image && (_jsx(ImageViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Video && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Audio && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Office && (_jsx(OfficeViewer, { file: file, isPending: isPending })), viewerType === ViewerTypes.Text && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Code && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending }))] })) : (_jsx(StyledInnerContainer, { children: _jsxs("div", { style: {
|
|
170
|
+
}, children: _jsx(XIcon, { size: 18 }) }), _jsx("div", { children: file.name }), _jsxs(StyledActionsMenu, { children: [ZoomableViewerTypes.includes(viewerType) && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(ZoomInIcon, { size: 18, onClick: () => setZoomFactor((prev) => prev * 1.1) }) }), _jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(ZoomOutIcon, { size: 18, onClick: () => setZoomFactor((prev) => prev * 0.9) }) })] })), _jsx("a", { href: file.url, download: file.name, style: { pointerEvents: !file.url ? "none" : "auto" }, children: _jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(DownloadIcon, { size: 18 }) }) })] })] }), file.url ? (_jsxs(StyledInnerContainer, { onClick: handleBackgroundClick, "data-type": viewerType, children: [viewerType === ViewerTypes.PDF && (_jsx(PdfViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Image && (_jsx(ImageViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Video && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Audio && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Office && (_jsx(OfficeViewer, { file: file, isPending: isPending })), viewerType === ViewerTypes.Text && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Code && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending }))] })) : (_jsx(StyledInnerContainer, { children: _jsxs("div", { style: {
|
|
169
171
|
margin: "auto",
|
|
170
172
|
display: "flex",
|
|
171
173
|
gap: "10px",
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
2
|
import { useState } from "react";
|
|
14
3
|
import { Document, Page, pdfjs } from "react-pdf";
|
|
15
4
|
import "react-pdf/dist/esm/Page/AnnotationLayer.css";
|
|
@@ -17,7 +6,13 @@ import "react-pdf/dist/esm/Page/TextLayer.css";
|
|
|
17
6
|
import styled from "styled-components";
|
|
18
7
|
import Loader from "../../Loader";
|
|
19
8
|
pdfjs.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url).toString();
|
|
20
|
-
const StyledContainer = styled.div
|
|
9
|
+
const StyledContainer = styled.div.attrs({
|
|
10
|
+
className: "PdfViewer-container",
|
|
11
|
+
}) `
|
|
12
|
+
flex: 1 1 auto;
|
|
13
|
+
height: 0px;
|
|
14
|
+
width: 100%;
|
|
15
|
+
`;
|
|
21
16
|
const StyledDocument = styled(Document).attrs({
|
|
22
17
|
className: "PdfViewer-document",
|
|
23
18
|
}) ``;
|
|
@@ -34,18 +29,14 @@ const StyledLoader = styled.div `
|
|
|
34
29
|
align-items: center;
|
|
35
30
|
gap: 10px;
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
left: 50%;
|
|
40
|
-
transform: translate(-50%, -50%);
|
|
32
|
+
height: 100%;
|
|
33
|
+
margin: auto;
|
|
41
34
|
`;
|
|
42
35
|
export const PdfViewer = ({ file, zoomFactor = 1, isPending }) => {
|
|
43
36
|
const [loading, setLoading] = useState(true);
|
|
44
37
|
const [numPages, setNumPages] = useState();
|
|
45
38
|
const [pageNumber, setPageNumber] = useState(1);
|
|
46
|
-
function onDocumentLoadSuccess(
|
|
47
|
-
var { numPages } = _a, rest = __rest(_a, ["numPages"]);
|
|
48
|
-
console.log(rest);
|
|
39
|
+
function onDocumentLoadSuccess({ numPages }) {
|
|
49
40
|
setLoading(false);
|
|
50
41
|
setNumPages(numPages);
|
|
51
42
|
}
|
|
@@ -54,7 +45,7 @@ export const PdfViewer = ({ file, zoomFactor = 1, isPending }) => {
|
|
|
54
45
|
if (isPending) {
|
|
55
46
|
return (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading PDF..." })] }));
|
|
56
47
|
}
|
|
57
|
-
return (
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
return (_jsxs(StyledContainer, { className: "PdfViewer", children: [loading && (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading PDF..." })] })), _jsx(StyledDocument, { file: file.url, onLoadStart: () => setLoading(true), onLoadSuccess: onDocumentLoadSuccess, loading: _jsx(_Fragment, {}), onClick: (e) => {
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
}, children: Array.from(new Array(numPages), (el, index) => (_jsx(StyledPage, { pageNumber: index + 1, scale: zoomFactor, width: vw }, `page_${index + 1}`))) })] }));
|
|
60
51
|
};
|