@monolith-forensics/monolith-ui 1.2.56 → 1.2.58

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.
@@ -6,8 +6,8 @@ export type File = {
6
6
  url?: string;
7
7
  };
8
8
  export declare const FileViewer: React.FC<{
9
- file: File;
10
- open: boolean;
9
+ file?: File;
10
+ open?: boolean;
11
11
  isPending?: boolean;
12
12
  onClose: () => void;
13
13
  }>;
@@ -125,9 +125,10 @@ const StyledInnerContainer = styled.div.attrs({
125
125
  }
126
126
  `;
127
127
  const resolveViewerType = (file) => {
128
- let ext = file.ext;
128
+ var _a, _b;
129
+ let ext = (_a = file === null || file === void 0 ? void 0 : file.ext) === null || _a === void 0 ? void 0 : _a.toLowerCase();
129
130
  if (!ext) {
130
- ext = file.name.split(".").pop();
131
+ ext = (_b = file.name.split(".").pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase();
131
132
  }
132
133
  if (!ext) {
133
134
  return ViewerTypes.Code;
@@ -159,6 +160,8 @@ export const FileViewer = ({ file, open, isPending, onClose }) => {
159
160
  const [zoomFactor, setZoomFactor] = useState(1);
160
161
  if (!open)
161
162
  return null;
163
+ if (!file)
164
+ return null;
162
165
  const viewerType = resolveViewerType(file);
163
166
  const handleBackgroundClick = (e) => {
164
167
  onClose === null || onClose === void 0 ? void 0 : onClose();
@@ -43,9 +43,9 @@ export const PdfViewer = ({ file, zoomFactor = 1, isPending }) => {
43
43
  // viewport width
44
44
  const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0) / 1.15;
45
45
  if (isPending) {
46
- return (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading PDF..." })] }));
46
+ return (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading File..." })] }));
47
47
  }
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) => {
48
+ return (_jsxs(StyledContainer, { className: "PdfViewer", children: [loading && (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading File..." })] })), _jsx(StyledDocument, { file: file.url, onLoadStart: () => setLoading(true), onLoadSuccess: onDocumentLoadSuccess, loading: _jsx(_Fragment, {}), onClick: (e) => {
49
49
  e.stopPropagation();
50
50
  }, children: Array.from(new Array(numPages), (el, index) => (_jsx(StyledPage, { pageNumber: index + 1, scale: zoomFactor, width: vw }, `page_${index + 1}`))) })] }));
51
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.56",
3
+ "version": "1.2.58",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",