@lateralus-ai/shipping-ui 1.3.0 → 1.3.2
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.
- package/dist/components/PdfViewer/PdfViewer.d.ts +3 -1
- package/dist/index.cjs +28 -28
- package/dist/index.esm.js +1176 -1167
- package/package.json +1 -1
- package/src/components/PdfViewer/PdfViewer.tsx +18 -5
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { Icon } from "@iconify/react";
|
|
|
6
6
|
import { cn } from "../../utils/cn";
|
|
7
7
|
import "react-pdf/dist/Page/AnnotationLayer.css";
|
|
8
8
|
import "react-pdf/dist/Page/TextLayer.css";
|
|
9
|
-
import { useState, ChangeEvent, useMemo } from "react";
|
|
9
|
+
import { useState, ChangeEvent, useMemo, MouseEvent as ReactMouseEvent } from "react";
|
|
10
10
|
import { useZoom } from "./useZoom";
|
|
11
11
|
import { useRotation } from "./useRotation";
|
|
12
12
|
import { usePageManagement } from "./usePageManagement";
|
|
@@ -18,6 +18,7 @@ interface PdfViewerProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
18
18
|
onClose: () => void;
|
|
19
19
|
src: string;
|
|
20
20
|
title?: string;
|
|
21
|
+
onOpen?: (event: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export const PdfViewer = ({
|
|
@@ -25,18 +26,30 @@ export const PdfViewer = ({
|
|
|
25
26
|
src,
|
|
26
27
|
title = "PDF Viewer",
|
|
27
28
|
className,
|
|
29
|
+
onOpen,
|
|
28
30
|
}: PdfViewerProps) => {
|
|
29
31
|
const [zoom, zoomActions] = useZoom();
|
|
30
32
|
const [rotation, rotationActions] = useRotation();
|
|
31
33
|
const [{ currentPage, totalPages }, pageActions] = usePageManagement();
|
|
32
34
|
const [{ pan, isDragging }, panActions] = usePanning();
|
|
33
35
|
|
|
36
|
+
const handleOpen = (event: ReactMouseEvent<HTMLButtonElement>) => {
|
|
37
|
+
onOpen?.(event);
|
|
38
|
+
if (event.defaultPrevented) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!src) {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
window.open(src, "_blank", "noopener,noreferrer");
|
|
48
|
+
};
|
|
34
49
|
|
|
35
50
|
const rightButtons = (
|
|
36
|
-
<IconButton variant="text" color="gray">
|
|
37
|
-
<
|
|
38
|
-
<ExpandIcon className="size-4" />
|
|
39
|
-
</a>
|
|
51
|
+
<IconButton variant="text" color="gray" onClick={handleOpen}>
|
|
52
|
+
<ExpandIcon className="size-4" />
|
|
40
53
|
</IconButton>
|
|
41
54
|
);
|
|
42
55
|
|