@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/dist/index.cjs +1 -1
- package/dist/index.esm.js +609 -592
- package/package.json +1 -1
- package/src/components/PdfViewer/PdfViewer.tsx +25 -2
package/package.json
CHANGED
|
@@ -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
|
|
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={
|
|
128
|
+
scale={scale}
|
|
106
129
|
rotate={rotation}
|
|
107
130
|
>
|
|
108
131
|
<Page
|