@lateralus-ai/shipping-ui 1.3.0 → 1.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lateralus-ai/shipping-ui",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Shared UI theme and components for Lateralus shipping applications",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.esm.js",
@@ -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<HTMLAnchorElement>) => void;
21
22
  }
22
23
 
23
24
  export const PdfViewer = ({
@@ -25,16 +26,33 @@ 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<HTMLAnchorElement>) => {
37
+ onOpen?.(event);
38
+ if (event.defaultPrevented) {
39
+ return;
40
+ }
41
+
42
+ // Allow default anchor behavior when event isn't prevented
43
+ if (!src) {
44
+ event.preventDefault();
45
+ }
46
+ };
34
47
 
35
48
  const rightButtons = (
36
49
  <IconButton variant="text" color="gray">
37
- <a href={src} target="_blank" rel="noopener noreferrer">
50
+ <a
51
+ href={src}
52
+ target="_blank"
53
+ rel="noopener noreferrer"
54
+ onClick={handleOpen}
55
+ >
38
56
  <ExpandIcon className="size-4" />
39
57
  </a>
40
58
  </IconButton>