@lateralus-ai/shipping-ui 1.4.12 → 1.4.13

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.4.12",
3
+ "version": "1.4.13",
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",
@@ -11,6 +11,8 @@ import {
11
11
  ChangeEvent,
12
12
  useMemo,
13
13
  MouseEvent as ReactMouseEvent,
14
+ useRef,
15
+ useEffect,
14
16
  } from "react"
15
17
  import { useZoom } from "./useZoom"
16
18
  import { useRotation } from "./useRotation"
@@ -37,6 +39,24 @@ export const PdfViewer = ({
37
39
  const [rotation, rotationActions] = useRotation()
38
40
  const [{ currentPage, totalPages }, pageActions] = usePageManagement()
39
41
  const [{ pan, isDragging }, panActions] = usePanning()
42
+ const [scale, setScale] = useState(1)
43
+ const containerRef = useRef<HTMLDivElement>(null)
44
+
45
+ useEffect(() => {
46
+ const calculateScale = () => {
47
+ if (containerRef.current) {
48
+ const containerWidth = containerRef.current.offsetWidth
49
+
50
+ // Assuming standard PDF page width is ~612 points (8.5 inches)
51
+ const baseScale = containerWidth / 612
52
+ setScale(baseScale * (zoom / 100))
53
+ }
54
+ }
55
+
56
+ calculateScale()
57
+ window.addEventListener("resize", calculateScale)
58
+ return () => window.removeEventListener("resize", calculateScale)
59
+ }, [zoom])
40
60
 
41
61
  const handleOpen = (event: ReactMouseEvent<HTMLButtonElement>) => {
42
62
  if (onOpen) {
@@ -68,7 +88,10 @@ export const PdfViewer = ({
68
88
  )
69
89
 
70
90
  return (
71
- <div className={cn("shadow rounded-t-lg flex flex-col h-full", className)}>
91
+ <div
92
+ className={cn("shadow rounded-t-lg flex flex-col h-full", className)}
93
+ ref={containerRef}
94
+ >
72
95
  <ModalPanel.Header onClose={onClose} right={rightButtons}>
73
96
  {title}
74
97
  </ModalPanel.Header>
@@ -102,7 +125,7 @@ export const PdfViewer = ({
102
125
  onLoadSuccess={({ numPages }) => {
103
126
  pageActions.setTotalPages(numPages)
104
127
  }}
105
- scale={zoom / 100}
128
+ scale={scale}
106
129
  rotate={rotation}
107
130
  >
108
131
  <Page