@react-pdf-kit/viewer 2.8.0-beta.1 → 2.8.0-beta.10

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.
Files changed (175) hide show
  1. package/README.md +44 -30
  2. package/dist/{AnnotationLayer-C6UTOVmc.js → AnnotationLayer-CyOYh0Tw.js} +2 -2
  3. package/dist/CanvasLayer-CJqCJ30J.js +111 -0
  4. package/dist/{LoadingIndicator-Bzzf28Xv.js → LoadingIndicator-0E8WHnSN.js} +7 -7
  5. package/dist/MenuItem-lItnKNd5.js +31 -0
  6. package/dist/Paginate.module-DhE7N8AA.js +9 -0
  7. package/dist/PaginationContext-DIzsZhFd.js +194 -0
  8. package/dist/{PasswordModal-BeLyLUsu.js → PasswordModal-CxHFn0pB.js} +12 -12
  9. package/dist/RPLayout.module-BH5r8dDc.js +14 -0
  10. package/dist/RPPages-U8QNLlIa.js +686 -0
  11. package/dist/{RPTooltip-CXBVXusS.js → RPTooltip-QWwWh4HW.js} +123 -91
  12. package/dist/SearchTool.module-DY8Ucfb_.js +17 -0
  13. package/dist/{SkipLink-CdcjClGB.js → SkipLink-Dj83gZdk.js} +3 -3
  14. package/dist/{TextLayer-DWGFN9SF.js → TextLayer-D-V9kogG.js} +5 -5
  15. package/dist/{Thumbnail-BO3QHzxR.js → Thumbnail-BXMk0OWF.js} +6 -6
  16. package/dist/{Thumbnails-DyeBsQJT.js → Thumbnails-BIuN8LZ8.js} +2 -2
  17. package/dist/assets/AnnotationLayer.css +1 -1
  18. package/dist/assets/CanvasLayer.css +1 -0
  19. package/dist/assets/LoadingIndicator.css +1 -1
  20. package/dist/assets/MenuItem.css +1 -1
  21. package/dist/assets/Paginate.css +1 -1
  22. package/dist/assets/PasswordModal.css +1 -1
  23. package/dist/assets/RPLayout.css +1 -1
  24. package/dist/assets/RPPages.css +1 -1
  25. package/dist/assets/SearchTool.css +1 -1
  26. package/dist/assets/SkipLink.css +1 -1
  27. package/dist/assets/TextLayer.css +1 -1
  28. package/dist/assets/Thumbnail.css +1 -1
  29. package/dist/assets/style.js +1 -1
  30. package/dist/components/RPController.js +39 -39
  31. package/dist/components/RPPages.js +1 -1
  32. package/dist/components/RPProvider.js +1 -1
  33. package/dist/components/layout/LayoutContainer.js +6 -6
  34. package/dist/components/layout/LayoutWrapper.js +5 -5
  35. package/dist/components/layout/RPDefaultLayout.js +56 -55
  36. package/dist/components/layout/RPLayout.js +39 -38
  37. package/dist/components/layout/SkipLink.js +1 -1
  38. package/dist/components/layout/sidebar/RPSidebar.js +2 -2
  39. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  40. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  41. package/dist/components/layout/toolbar/DarkModeTool.js +1 -1
  42. package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
  43. package/dist/components/layout/toolbar/FileDownloadTool.js +6 -6
  44. package/dist/components/layout/toolbar/FileUploadTool.js +6 -6
  45. package/dist/components/layout/toolbar/FullScreenTool.js +9 -8
  46. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  47. package/dist/components/layout/toolbar/MostPageTool.js +23 -29
  48. package/dist/components/layout/toolbar/OtherTool.js +1 -1
  49. package/dist/components/layout/toolbar/Paginate.js +18 -3
  50. package/dist/components/layout/toolbar/PrintTool.js +6 -6
  51. package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
  52. package/dist/components/layout/toolbar/RPMoreOptions.js +1 -1
  53. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  54. package/dist/components/layout/toolbar/RotateTool.js +10 -10
  55. package/dist/components/layout/toolbar/ScrollModeTool.js +17 -17
  56. package/dist/components/layout/toolbar/SearchCloseButton.js +2 -2
  57. package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
  58. package/dist/components/layout/toolbar/SearchTool.js +133 -121
  59. package/dist/components/layout/toolbar/SelectionModeTool.js +10 -10
  60. package/dist/components/layout/toolbar/ThumbnailTool.js +1 -1
  61. package/dist/components/layout/toolbar/ToolbarCustom.js +2 -2
  62. package/dist/components/layout/toolbar/ToolbarDefault.js +2 -2
  63. package/dist/components/layout/toolbar/ViewModeTool.js +16 -16
  64. package/dist/components/layout/toolbar/ZoomTool.js +82 -80
  65. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +1 -1
  66. package/dist/components/layout/toolbar/tools/DualPageTool.js +1 -1
  67. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
  68. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +1 -1
  69. package/dist/components/layout/toolbar/tools/FileUploadTool.js +1 -1
  70. package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
  71. package/dist/components/layout/toolbar/tools/FullScreenTool.js +1 -1
  72. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +3 -3
  73. package/dist/components/layout/toolbar/tools/InputPageTool.js +36 -25
  74. package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
  75. package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
  76. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +1 -1
  77. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +2 -2
  78. package/dist/components/layout/toolbar/tools/PrintTool.js +1 -1
  79. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +1 -1
  80. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +1 -1
  81. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +1 -1
  82. package/dist/components/layout/toolbar/tools/SinglePageTool.js +1 -1
  83. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +1 -1
  84. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  85. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +1 -1
  86. package/dist/components/layout/toolbar/tools/ZoomInTool.js +25 -23
  87. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +1 -1
  88. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
  89. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +25 -23
  90. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
  91. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
  92. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
  93. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
  94. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +3 -3
  95. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
  96. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +2 -2
  97. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +7 -7
  98. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
  99. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
  100. package/dist/components/page/AnnotationLayer.js +1 -1
  101. package/dist/components/page/CanvasLayer.js +2 -48
  102. package/dist/components/page/DualPage.js +2 -2
  103. package/dist/components/page/DualPageWithCover.js +2 -2
  104. package/dist/components/page/RPPage.js +94 -2
  105. package/dist/components/page/SinglePage.js +2 -2
  106. package/dist/components/page/TextHighlightLayer.js +1 -1
  107. package/dist/components/page/TextLayer.js +1 -1
  108. package/dist/components/ui/LoadingIndicator.js +1 -1
  109. package/dist/components/ui/PasswordModal.js +1 -1
  110. package/dist/components/ui/RPTooltip.js +1 -1
  111. package/dist/contexts/DimensionPagesContext.js +38 -22
  112. package/dist/contexts/ElementPageContext.js +46 -39
  113. package/dist/contexts/ElementThumbnailContext.js +1 -1
  114. package/dist/contexts/PaginationContext.js +1 -1
  115. package/dist/contexts/RenderQueueProvider.js +26 -18
  116. package/dist/contexts/RenderedPagesCache.js +32 -13
  117. package/dist/contexts/VirtualScrollContext.js +10 -13
  118. package/dist/contexts/ZoomContext.js +119 -61
  119. package/dist/{de_DE--0LF-SJR.js → de_DE-x4Z-jQrz.js} +54 -6
  120. package/dist/{main-0RC2E65p.js → main-DCzVrq0G.js} +2 -2
  121. package/dist/main.js +4 -4
  122. package/dist/style-CJtyyrJx.js +5 -0
  123. package/dist/types/components/page/CanvasLayer.d.ts +4 -1
  124. package/dist/types/components/ui/RPTooltip.d.ts +3 -2
  125. package/dist/types/contexts/RenderQueueProvider.d.ts +2 -0
  126. package/dist/types/contexts/RenderedPagesCache.d.ts +3 -0
  127. package/dist/types/contexts/VirtualScrollContext.d.ts +0 -3
  128. package/dist/types/locales/de_DE.json.d.ts +11 -2
  129. package/dist/types/locales/en_US.json.d.ts +11 -2
  130. package/dist/types/locales/it_IT.json.d.ts +11 -2
  131. package/dist/types/locales/pt_PT.json.d.ts +11 -2
  132. package/dist/types/locales/th_TH.json.d.ts +11 -2
  133. package/dist/types/locales/zh_CN.json.d.ts +11 -2
  134. package/dist/types/utils/Queue.d.ts +1 -0
  135. package/dist/types/utils/const.d.ts +3 -0
  136. package/dist/types/utils/constants.d.ts +9 -0
  137. package/dist/types/utils/documentLayout.d.ts +60 -0
  138. package/dist/types/utils/hooks/usePinch.d.ts +14 -1
  139. package/dist/types/utils/hooks/usePresentPage.d.ts +2 -2
  140. package/dist/types/utils/hooks/useZoomOrigin.d.ts +4 -0
  141. package/dist/types/utils/types.d.ts +24 -2
  142. package/dist/types/utils/zoom.d.ts +2 -0
  143. package/dist/utils/Queue.js +5 -0
  144. package/dist/utils/const.js +2 -2
  145. package/dist/utils/constants.js +2 -2
  146. package/dist/utils/documentLayout.js +141 -0
  147. package/dist/utils/hooks/useLicense.js +1 -1
  148. package/dist/utils/hooks/useLoadPdf.js +73 -63
  149. package/dist/utils/hooks/useLocalization.js +1 -1
  150. package/dist/utils/hooks/usePaginate.js +1 -1
  151. package/dist/utils/hooks/usePinch.js +109 -56
  152. package/dist/utils/hooks/usePresentPage.js +33 -57
  153. package/dist/utils/hooks/useScrollToPage.js +1 -1
  154. package/dist/utils/hooks/useSearch.js +66 -67
  155. package/dist/utils/hooks/useZoomOrigin.js +37 -0
  156. package/dist/utils/renderPage.js +21 -14
  157. package/dist/utils/types.js +3 -3
  158. package/dist/utils/zoom.js +8 -2
  159. package/package.json +1 -1
  160. package/dist/MenuItem-9kCH_GQ0.js +0 -15
  161. package/dist/Paginate.module-B0GMw-MB.js +0 -8
  162. package/dist/PaginationContext-C5CJiEW-.js +0 -242
  163. package/dist/RPLayout.module-Vc3h4xxS.js +0 -14
  164. package/dist/RPPage-BsDixmqF.js +0 -91
  165. package/dist/RPPages-Cf-FDd0a.js +0 -1007
  166. package/dist/SearchTool.module-DUkVXfOn.js +0 -16
  167. package/dist/assets/RPPage.css +0 -1
  168. package/dist/contexts/VirtualGridContext.js +0 -18
  169. package/dist/style-BPQRJJJ7.js +0 -5
  170. package/dist/types/contexts/VirtualGridContext.d.ts +0 -9
  171. package/dist/types/utils/calculatePage.d.ts +0 -12
  172. package/dist/types/utils/hooks/useVirtualReactWindow.d.ts +0 -17
  173. package/dist/utils/calculatePage.js +0 -30
  174. package/dist/utils/hooks/useVirtualReactWindow.js +0 -86
  175. /package/dist/{TextHighlightLayer-BSVgBxR3.js → TextHighlightLayer-3vIZbRyL.js} +0 -0
@@ -1,66 +1,119 @@
1
- import { useDebounce as e } from "./useDebounce.js";
1
+ import { MAX_ZOOM_SCALE as e } from "../constants.js";
2
2
  import { useZoomContext as t } from "../../contexts/ZoomContext.js";
3
- import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
3
+ import { getZoomOriginFromClientPoint as n } from "./useZoomOrigin.js";
4
+ import { useCallback as r, useEffect as i, useRef as a } from "react";
4
5
  //#region lib/utils/hooks/usePinch.ts
5
- var o = (o) => {
6
- let { currentZoom: s, setZoomLevel: c } = t(), [l, u] = a(0), d = e(l, 100), [f, p] = a(!1), m = i(null), h = n((e) => {
7
- u(e ? (e) => e + 3 : (e) => e - 3);
8
- }, []), g = n((e) => {
9
- e.ctrlKey && (e.preventDefault(), h(e.deltaY < 0));
10
- }, [h]);
11
- r(() => {
12
- if (d) {
13
- let e = Math.round(s * 100 + d);
14
- u(0), c(e > 25 ? e : 25);
6
+ var o = () => 35 / (window.devicePixelRatio || 1), s = (s, c = {}) => {
7
+ let { targetZoom: l, zoomTo: u } = t(), { onBeforeZoom: d, onPinchEnd: f } = c, p = a(null), m = a(!1), h = a(!1), g = a(!1), _ = a(1), v = a(1), y = a(!1), b = a(!1), x = a(), S = a(l), C = a(null);
8
+ i(() => {
9
+ S.current = l;
10
+ }, [l]);
11
+ let w = r((e, t, n) => {
12
+ if (t === 1) return 1;
13
+ let r = n.current;
14
+ (r > 1 && t < 1 || r < 1 && t > 1) && (n.current = 1);
15
+ let i = Math.floor(e * t * n.current * 100) / (100 * e);
16
+ return n.current = t / i, i;
17
+ }, []), T = r((t, n, r) => {
18
+ let i = S.current || 1, a = 25 / 100, o = e / 100;
19
+ if (i >= o && t > 1 || i <= a && t < 1) return;
20
+ let s = Math.max(a, Math.min(o, Math.round(i * t * 100) / 100));
21
+ Math.abs(s - i) < 1e-10 || (d?.({
22
+ gesture: r,
23
+ previousScale: i,
24
+ nextScale: s,
25
+ origin: n
26
+ }), S.current = s, u(s * 100, {
27
+ origin: n,
28
+ gesture: r,
29
+ previousTargetZoom: i
30
+ }));
31
+ }, [d, u]), E = r((e, t) => n(s, e, t) ?? void 0, [s]), D = r(() => {
32
+ b.current || (y.current = !0, clearTimeout(x.current), x.current = setTimeout(() => {
33
+ y.current = !1;
34
+ }, 100));
35
+ }, []), O = r((e) => {
36
+ if (!e.ctrlKey) {
37
+ b.current = !1, g.current = !1;
38
+ return;
15
39
  }
16
- }, [d]);
17
- let _ = (e, t) => {
18
- let n = e.clientX - t.clientX, r = e.clientY - t.clientY;
19
- return Math.sqrt(n * n + r * r);
20
- }, v = n((e) => {
21
- !f || e.touches.length !== 2 || (m.current = _(e.touches[0], e.touches[1]), e.preventDefault());
22
- }, [f]), y = n(() => {
23
- m.current = null;
24
- }, []), b = n((e) => {
25
- if (!f || e.touches.length !== 2 || m.current === null) return;
26
- let t = _(e.touches[0], e.touches[1]), n = t - m.current;
27
- Math.abs(n) > 5 && (h(n > 0), m.current = t, e.preventDefault());
28
- }, [h, f]), x = () => {
29
- document.activeElement instanceof HTMLElement && document.activeElement.blur();
30
- };
31
- r(() => {
32
- if (f) {
33
- document.body.style.touchAction = "pan-x pan-y";
40
+ g.current || (v.current = 1), g.current = !0, b.current = !0, y.current = !1, clearTimeout(x.current), e.preventDefault();
41
+ let t = Math.exp(-e.deltaY / 100);
42
+ T(w(S.current || 1, t, v), E(e.clientX, e.clientY), "wheel");
43
+ }, [
44
+ w,
45
+ E,
46
+ T
47
+ ]), k = (e) => Array.from(e.touches).sort((e, t) => e.identifier - t.identifier), A = r(() => {
48
+ !s || C.current || (C.current = {
49
+ touchAction: s.style.touchAction,
50
+ webkitUserSelect: s.style.webkitUserSelect,
51
+ overscrollBehavior: s.style.overscrollBehavior,
52
+ webkitOverflowScrolling: s.style.getPropertyValue("-webkit-overflow-scrolling")
53
+ }, s.style.touchAction = "none", s.style.webkitUserSelect = "none", s.style.overscrollBehavior = "contain", s.style.setProperty("-webkit-overflow-scrolling", "auto"));
54
+ }, [s]), j = r(() => {
55
+ !s || !C.current || (s.style.touchAction = C.current.touchAction, s.style.webkitUserSelect = C.current.webkitUserSelect, s.style.overscrollBehavior = C.current.overscrollBehavior, C.current.webkitOverflowScrolling ? s.style.setProperty("-webkit-overflow-scrolling", C.current.webkitOverflowScrolling) : s.style.removeProperty("-webkit-overflow-scrolling"), C.current = null);
56
+ }, [s]), M = r(() => {
57
+ if (!(m.current || p.current || h.current)) {
58
+ j();
34
59
  return;
35
60
  }
36
- document.body.style.touchAction = "";
37
- }, [f]), r(() => {
38
- let e = () => {
39
- let e = document.activeElement;
40
- p(!!e?.closest("[data-rp=\"container\"]"));
41
- };
42
- return window.addEventListener("focusin", e), window.addEventListener("focusout", e), e(), () => {
43
- window.removeEventListener("focusin", e), window.removeEventListener("focusout", e);
44
- };
45
- }, []), r(() => {
46
- if (!o) return;
47
- let e = (e) => {
48
- o.contains(e.target) || x();
49
- };
50
- return document.addEventListener("scroll", e), () => {
51
- document.removeEventListener("scroll", e);
52
- };
53
- }, [o]), r(() => {
54
- if (o) return o.addEventListener("wheel", g, { passive: !1 }), o.addEventListener("touchstart", v, { passive: !1 }), o.addEventListener("touchmove", b, { passive: !1 }), o.addEventListener("touchend", y, { passive: !1 }), () => {
55
- o.removeEventListener("wheel", g), o.removeEventListener("touchstart", v), o.removeEventListener("touchmove", b), o.removeEventListener("touchend", y);
61
+ p.current = null, m.current = !1, h.current = !1, _.current = 1, j(), f?.();
62
+ }, [f, j]), N = r((e) => {
63
+ if (e.touches.length !== 2) {
64
+ M();
65
+ return;
66
+ }
67
+ A(), e.preventDefault(), e.stopPropagation();
68
+ let [t, n] = k(e);
69
+ m.current = !0, _.current = 1, p.current = {
70
+ touch0ScreenX: t.screenX,
71
+ touch0ScreenY: t.screenY,
72
+ touch1ScreenX: n.screenX,
73
+ touch1ScreenY: n.screenY
74
+ }, h.current = !1;
75
+ }, [A, M]), P = r((e) => {
76
+ let t = p.current;
77
+ if (!t || e.touches.length !== 2) {
78
+ M();
79
+ return;
80
+ }
81
+ e.preventDefault(), e.stopPropagation();
82
+ let [n, r] = k(e), i = t.touch1ScreenX - t.touch0ScreenX, a = t.touch1ScreenY - t.touch0ScreenY, s = r.screenX - n.screenX, c = r.screenY - n.screenY, l = Math.hypot(i, a) || 1, u = Math.hypot(s, c) || 1;
83
+ if (!h.current && Math.abs(l - u) <= o()) return;
84
+ if (t.touch0ScreenX = n.screenX, t.touch0ScreenY = n.screenY, t.touch1ScreenX = r.screenX, t.touch1ScreenY = r.screenY, !h.current) {
85
+ h.current = !0;
86
+ return;
87
+ }
88
+ let d = u / l;
89
+ T(w(S.current || 1, d, _), E((n.clientX + r.clientX) / 2, (n.clientY + r.clientY) / 2), "touch");
90
+ }, [
91
+ w,
92
+ E,
93
+ M,
94
+ T
95
+ ]), F = r((e) => {
96
+ e.touches.length >= 2 || (M(), v.current = 1);
97
+ }, [M]), I = r(() => {
98
+ M(), v.current = 1;
99
+ }, [M]), L = r(() => {
100
+ b.current = !1, g.current = !1, v.current = 1, y.current = !1, clearTimeout(x.current), M();
101
+ }, [M]);
102
+ i(() => {
103
+ if (s) return s.addEventListener("wheel", O, { passive: !1 }), s.addEventListener("scroll", D, { passive: !0 }), s.addEventListener("touchstart", N, { passive: !1 }), s.addEventListener("touchmove", P, { passive: !1 }), s.addEventListener("touchend", F, { passive: !1 }), s.addEventListener("touchcancel", I, { passive: !1 }), window.addEventListener("touchend", F, { passive: !1 }), window.addEventListener("touchcancel", I, { passive: !1 }), window.addEventListener("blur", L), () => {
104
+ j(), s.removeEventListener("wheel", O), s.removeEventListener("scroll", D), s.removeEventListener("touchstart", N), s.removeEventListener("touchmove", P), s.removeEventListener("touchend", F), s.removeEventListener("touchcancel", I), window.removeEventListener("touchend", F), window.removeEventListener("touchcancel", I), window.removeEventListener("blur", L), clearTimeout(x.current);
56
105
  };
57
106
  }, [
58
- o,
59
- g,
60
- v,
61
- b,
62
- y
107
+ s,
108
+ D,
109
+ I,
110
+ F,
111
+ P,
112
+ N,
113
+ O,
114
+ L,
115
+ j
63
116
  ]);
64
117
  };
65
118
  //#endregion
66
- export { o as usePinch };
119
+ export { s as usePinch };
@@ -1,70 +1,46 @@
1
- import { ViewMode as e } from "../types.js";
2
- import { useLayoutContainer as t } from "../../contexts/LayoutContainerContext.js";
3
- import { useDebounce as n } from "./useDebounce.js";
4
- import { useDimensionPagesContext as r } from "../../contexts/DimensionPagesContext.js";
5
- import { useSmoothScrollContext as i } from "../../contexts/SmoothScrollContext.js";
6
- import { getGridDimension as a, getPositionFromPage as o } from "../calculatePage.js";
7
- import { r as s } from "../../PaginationContext-C5CJiEW-.js";
8
- import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
1
+ import { useDebounce as e } from "./useDebounce.js";
2
+ import { useSmoothScrollContext as t } from "../../contexts/SmoothScrollContext.js";
3
+ import { r as n } from "../../PaginationContext-DIzsZhFd.js";
4
+ import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
9
5
  //#region lib/utils/hooks/usePresentPage.ts
10
- var p = (p, m, h, g) => {
11
- let _ = d(), { contentRef: v } = t(), { heights: y, widths: b } = r(), { setFocusedPage: x } = s(), S = d(x);
12
- S.current = x;
13
- let [C, w] = f([]), { targetScrollPage: T } = i(), E = n(C, 0, 500), D = u(() => {
14
- let t = g === e.DUAL_PAGE_WITH_COVER, { rowsHeight: n, columnsWidth: r } = a({
15
- heights: y,
16
- widths: b
17
- }, p, t);
18
- return y.map((e, i) => {
19
- let a = b[i], s = o(i + 1, p, t), c = r.slice(0, s.columnIndex).reduce((e, t) => e + t, 0), l = n.slice(0, s.rowIndex).reduce((e, t) => e + t, 0), u = c + a, d = l + e;
20
- return {
21
- pageNumber: i + 1,
22
- ...s,
23
- width: a,
24
- height: e,
25
- startX: c,
26
- startY: l,
27
- endX: u,
28
- endY: d
29
- };
30
- });
31
- }, [
32
- y,
33
- b,
34
- p,
35
- m,
36
- g
37
- ]);
38
- l(() => {
39
- E.length > 0 && !T.current && S.current(E[0].pageNumber), E[0]?.ratio && E.some((e) => e.pageNumber === T.current) && setTimeout(() => {
40
- T.current = void 0;
41
- }, 500);
42
- }, [E]);
43
- let O = c((e) => {
44
- _.current && cancelAnimationFrame(_.current), _.current = requestAnimationFrame(() => {
6
+ var s = (s, c) => {
7
+ let l = a(), u = a(), { setFocusedPage: d } = n(), f = a(d);
8
+ f.current = d;
9
+ let [p, m] = o([]), { targetScrollPage: h } = t(), g = e(p, 0, 500);
10
+ i(() => {
11
+ g.length > 0 && !h.current && f.current(g[0].pageNumber);
12
+ let e = g[0]?.ratio, t = h.current;
13
+ e && g.some((e) => e.pageNumber === t) && (clearTimeout(u.current), u.current = setTimeout(() => {
14
+ h.current === t && (h.current = void 0);
15
+ }, 500));
16
+ }, [g, h]), i(() => () => {
17
+ clearTimeout(u.current), l.current && cancelAnimationFrame(l.current);
18
+ }, []);
19
+ let _ = r((e) => {
20
+ c && (l.current && cancelAnimationFrame(l.current), l.current = requestAnimationFrame(() => {
45
21
  let t = e.target, n = {
46
- startTop: t.scrollTop,
47
- startLeft: t.scrollLeft,
48
- endTop: t.scrollTop + t.clientHeight,
49
- endLeft: t.scrollLeft + t.clientWidth
22
+ startTop: t.scrollTop - c.offsetTop,
23
+ startLeft: t.scrollLeft - c.offsetLeft,
24
+ endTop: t.scrollTop - c.offsetTop + t.clientHeight,
25
+ endLeft: t.scrollLeft - c.offsetLeft + t.clientWidth
50
26
  };
51
- w(D.filter((e) => {
52
- let t = e.endX >= n.startLeft && e.endY >= n.startTop, r = e.startX <= n.endLeft && e.startY <= n.endTop;
27
+ m(c.pages.filter((e) => {
28
+ let t = e.left + e.width >= n.startLeft && e.top + e.height >= n.startTop, r = e.left <= n.endLeft && e.top <= n.endTop;
53
29
  return t && r;
54
30
  }).map((e) => {
55
- let t = n.startLeft > e.startX ? n.startLeft : e.startX, r = n.startTop > e.startY ? n.startTop : e.startY, i = n.endLeft < e.endX ? n.endLeft : e.endX, a = n.endTop < e.endY ? n.endTop : e.endY, o = +((i - t) * (a - r) / (e.width * e.height) * 100).toFixed(2);
31
+ let t = Math.max(n.startLeft, e.left), r = Math.max(n.startTop, e.top), i = Math.min(n.endLeft, e.left + e.width), a = Math.min(n.endTop, e.top + e.height), o = +(Math.max(0, i - t) * Math.max(0, a - r) / (e.width * e.height || 1) * 100).toFixed(2);
56
32
  return {
57
33
  pageNumber: e.pageNumber,
58
34
  ratio: o
59
35
  };
60
36
  }).sort((e, t) => t.ratio - e.ratio));
61
- });
62
- }, [v, D]);
63
- l(() => {
64
- if (h) return h?.addEventListener("scroll", O), () => {
65
- h?.removeEventListener("scroll", O);
37
+ }));
38
+ }, [c]);
39
+ i(() => {
40
+ if (s) return s?.addEventListener("scroll", _), _({ target: s }), () => {
41
+ s?.removeEventListener("scroll", _);
66
42
  };
67
- }, [h, O]);
43
+ }, [s, _]);
68
44
  };
69
45
  //#endregion
70
- export { p as usePresentPage };
46
+ export { s as usePresentPage };
@@ -1,2 +1,2 @@
1
- import { a as e } from "../../PaginationContext-C5CJiEW-.js";
1
+ import { a as e } from "../../PaginationContext-DIzsZhFd.js";
2
2
  export { e as useScrollToPage };
@@ -1,81 +1,80 @@
1
- import { ScrollMode as e, ViewMode as t } from "../types.js";
2
- import { useDocumentContext as n } from "../../contexts/RPDocumentContext.js";
3
- import { useScrollModeContext as r } from "../../contexts/ScrollModeContext.js";
4
- import { useViewModeContext as i } from "../../contexts/ViewModeContext.js";
5
- import { useVirtualScrollContext as a } from "../../contexts/VirtualScrollContext.js";
6
- import { useLayoutContainer as o } from "../../contexts/LayoutContainerContext.js";
7
- import { useZoomContext as s } from "../../contexts/ZoomContext.js";
8
- import { usePagesRotateContext as c } from "../../contexts/PagesRotateContext.js";
9
- import { useDimensionPagesContext as l } from "../../contexts/DimensionPagesContext.js";
10
- import { useSmoothScrollContext as u } from "../../contexts/SmoothScrollContext.js";
11
- import { getScrollDistance as d } from "../getScrollDistance.js";
12
- import { r as f } from "../../PaginationContext-C5CJiEW-.js";
1
+ import { ScrollMode as e } from "../types.js";
2
+ import { useDocumentContext as t } from "../../contexts/RPDocumentContext.js";
3
+ import { useScrollModeContext as n } from "../../contexts/ScrollModeContext.js";
4
+ import { useViewModeContext as r } from "../../contexts/ViewModeContext.js";
5
+ import { useVirtualScrollContext as i } from "../../contexts/VirtualScrollContext.js";
6
+ import { useLayoutContainer as a } from "../../contexts/LayoutContainerContext.js";
7
+ import { useZoomContext as o } from "../../contexts/ZoomContext.js";
8
+ import { usePagesRotateContext as s } from "../../contexts/PagesRotateContext.js";
9
+ import { useDimensionPagesContext as c } from "../../contexts/DimensionPagesContext.js";
10
+ import { useSmoothScrollContext as l } from "../../contexts/SmoothScrollContext.js";
11
+ import { buildDocumentLayout as u, getPagePlacement as d } from "../documentLayout.js";
12
+ import { r as f } from "../../PaginationContext-DIzsZhFd.js";
13
13
  import { findMatches as p } from "../highlight.js";
14
14
  import { getWordPositionInPage as m } from "../getWordPositionInPage.js";
15
15
  import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
16
16
  //#region lib/utils/hooks/useSearch.ts
17
17
  var b = (b = {}, x = "") => {
18
- let [S, C] = y(x), [w, T] = y(!1), { pdf: E, pages: D } = n(), { widths: O, heights: k } = l(), A = v(!S), { currentZoom: j } = s(), [M, N] = y([]), { setFocusedPage: P } = f(), { columnCount: F, viewMode: I } = i(), { pageRotate: L } = c(), [R, z] = y(0), { pageScrollElementRef: B, virtualScrollableElementRef: V } = a(), { scrollMode: H } = r(), { pagesRef: U } = o(), { scrollBehavior: W } = u(), G = v({}), K = v(0), q = _(() => R === 0 ? null : M[R - 1], [R, M]), J = _(() => M.length, [M]), Y = h((n) => {
19
- if (n === 0) return;
20
- let r = M[n - 1];
21
- if (!r || !D) return;
22
- let i = V || B;
23
- if (!i || !U) return;
24
- let a = D.get(r.page);
25
- if (H === e.PAGE_SCROLLING && P(r.page), !a) return;
26
- let o = 0, s = 0;
27
- if (H === e.VERTICAL_SCROLLING) {
28
- let e = r.page - 1, n = F, i, a;
29
- if (I === t.DUAL_PAGE_WITH_COVER) if (r.page === 1) i = 0, a = 0;
30
- else {
31
- let e = r.page - 2;
32
- i = e % 2, a = Math.floor(e / 2) + 1;
33
- }
34
- else i = e % n, a = Math.floor(e / n);
35
- o = d(k, a), s = d(O, i);
36
- }
37
- H === e.HORIZONTAL_SCROLLING && (s = O.slice(0, r.page - 1).reduce((e, t) => e + t, 0));
38
- let c = {
39
- height: k[r.page - 1],
40
- width: O[r.page - 1]
41
- }, l = L[r.page], { leftInPage: u, topInPage: f } = m(c, U, r.rect, j, l), p = s + u, h = o + f, g = {
18
+ let [S, C] = y(x), [w, T] = y(!1), { pdf: E, pages: D } = t(), { widths: O, heights: k } = c(), A = v(!S), { currentZoom: j } = o(), [M, N] = y([]), { setFocusedPage: P } = f(), { viewMode: F } = r(), { pageRotate: I } = s(), [L, R] = y(0), { pageScrollElementRef: z, virtualScrollableElementRef: B } = i(), { scrollMode: V } = n(), { pagesRef: H } = a(), { scrollBehavior: U } = l(), W = v({}), G = v(0), K = _(() => L === 0 ? null : M[L - 1], [L, M]), q = _(() => M.length, [M]), J = h((t) => {
19
+ if (t === 0) return;
20
+ let n = M[t - 1];
21
+ if (!n || !D) return;
22
+ let r = B || z;
23
+ if (!r || !H) return;
24
+ let i = D.get(n.page);
25
+ if (V === e.PAGE_SCROLLING && P(n.page), !i) return;
26
+ let a = u({
27
+ pageDimensions: {
28
+ widths: O,
29
+ heights: k
30
+ },
31
+ viewportWidth: r.clientWidth,
32
+ viewportHeight: r.clientHeight,
33
+ scrollMode: V,
34
+ viewMode: F,
35
+ focusedPage: n.page
36
+ }), o = d(a, n.page);
37
+ if (!o) return;
38
+ let s = {
39
+ height: k[n.page - 1],
40
+ width: O[n.page - 1]
41
+ }, c = I[n.page], { leftInPage: l, topInPage: f } = m(s, H, n.rect, j, c), p = a.offsetLeft + o.left + l, h = a.offsetTop + o.top + f, g = {
42
42
  left: Math.max(p, 0),
43
43
  top: Math.max(h, 0)
44
44
  };
45
- i.scrollTo({
45
+ r.scrollTo({
46
46
  ...g,
47
- behavior: W
47
+ behavior: U
48
48
  });
49
49
  }, [
50
50
  D,
51
51
  P,
52
52
  O,
53
53
  k,
54
- H,
55
- I,
56
- F,
57
54
  V,
55
+ F,
58
56
  B,
59
- U,
57
+ z,
58
+ H,
60
59
  M,
61
60
  j,
62
- L,
63
- W
61
+ I,
62
+ U
64
63
  ]);
65
64
  g(() => {
66
- R && Y(R);
67
- }, [R]);
68
- let X = h(() => {
69
- z((e) => {
65
+ L && J(L);
66
+ }, [L]);
67
+ let Y = h(() => {
68
+ R((e) => {
70
69
  let t;
71
- return t = J ? e + 1 > J ? 1 : e + 1 : 0, K.current = t, t;
72
- }), K.current === 1 && Y(K.current);
73
- }, [J, Y]), Z = h(() => {
74
- z((e) => {
70
+ return t = q ? e + 1 > q ? 1 : e + 1 : 0, G.current = t, t;
71
+ }), G.current === 1 && J(G.current);
72
+ }, [q, J]), X = h(() => {
73
+ R((e) => {
75
74
  let t;
76
- return t = J ? e - 1 <= 0 ? J : e - 1 : 0, K.current = t, t;
77
- }), K.current === 1 && Y(K.current);
78
- }, [J, Y]), Q = h(async (e) => {
75
+ return t = q ? e - 1 <= 0 ? q : e - 1 : 0, G.current = t, t;
76
+ }), G.current === 1 && J(G.current);
77
+ }, [q, J]), Z = h(async (e) => {
79
78
  if (!e) return {};
80
79
  let t = e.numPages, n = {};
81
80
  for (let r = 1; r <= t; r++) {
@@ -87,11 +86,11 @@ var b = (b = {}, x = "") => {
87
86
  }, []);
88
87
  return g(() => {
89
88
  if (!S) {
90
- A.current = !0, N([]), z(0);
89
+ A.current = !0, N([]), R(0);
91
90
  return;
92
91
  }
93
- A.current = !1, T(!0), N([]), z(0), Q(E).then((e) => {
94
- G.current = e;
92
+ A.current = !1, T(!0), N([]), R(0), Z(E).then((e) => {
93
+ W.current = e;
95
94
  let t = Object.keys(e).reduce((t, n) => {
96
95
  let r = p([S], e[n], Number(n) - 1, b).map((e, t) => ({
97
96
  ...e,
@@ -100,13 +99,13 @@ var b = (b = {}, x = "") => {
100
99
  }));
101
100
  return [...t, ...r];
102
101
  }, []);
103
- N(t), z(+!!t.length);
102
+ N(t), R(+!!t.length);
104
103
  }).catch(() => {
105
- N([]), z(0);
104
+ N([]), R(0);
106
105
  }).finally(() => T(!1));
107
106
  }, [
108
107
  S,
109
- Q,
108
+ Z,
110
109
  E,
111
110
  b
112
111
  ]), {
@@ -114,12 +113,12 @@ var b = (b = {}, x = "") => {
114
113
  setSearch: C,
115
114
  loading: w,
116
115
  matches: M,
117
- totalMatches: J,
118
- currentMatchPosition: R,
119
- currentMatch: q,
120
- nextMatch: X,
121
- prevMatch: Z,
122
- setCurrentMatchPosition: z
116
+ totalMatches: q,
117
+ currentMatchPosition: L,
118
+ currentMatch: K,
119
+ nextMatch: Y,
120
+ prevMatch: X,
121
+ setCurrentMatchPosition: R
123
122
  };
124
123
  };
125
124
  //#endregion
@@ -0,0 +1,37 @@
1
+ import { useCallback as e, useEffect as t, useRef as n } from "react";
2
+ //#region lib/utils/hooks/useZoomOrigin.ts
3
+ var r = (e, t, n) => Math.max(t, Math.min(e, n)), i = (e) => Number.isFinite(e.left) && Number.isFinite(e.top) && Number.isFinite(e.width) && Number.isFinite(e.height) && e.width > 0 && e.height > 0, a = (e, t, n) => {
4
+ if (!e || !Number.isFinite(t) || !Number.isFinite(n)) return null;
5
+ let a = e.getBoundingClientRect();
6
+ return i(a) ? [r(t - a.left, 0, a.width), r(n - a.top, 0, a.height)] : null;
7
+ }, o = (e) => {
8
+ if (!e) return;
9
+ let t = e.getBoundingClientRect();
10
+ if (!i(t)) return;
11
+ let { width: n, height: r } = t;
12
+ return [n / 2, r / 2];
13
+ }, s = (s) => {
14
+ let c = n(null), l = e((e, t) => a(s, e, t), [s]);
15
+ return t(() => {
16
+ if (!s) {
17
+ c.current = null;
18
+ return;
19
+ }
20
+ let e = (e) => {
21
+ c.current = l(e.clientX, e.clientY);
22
+ }, t = (e) => {
23
+ c.current = l(e.clientX, e.clientY);
24
+ };
25
+ return s.addEventListener("pointermove", e, { passive: !0 }), s.addEventListener("mousemove", t, { passive: !0 }), () => {
26
+ s.removeEventListener("pointermove", e), s.removeEventListener("mousemove", t);
27
+ };
28
+ }, [s, l]), e(() => {
29
+ if (!s) return;
30
+ let e = s.getBoundingClientRect();
31
+ if (!i(e)) return;
32
+ let { width: t, height: n } = e, a = c.current;
33
+ return a ? [r(a[0], 0, t), r(a[1], 0, n)] : o(s);
34
+ }, [s]);
35
+ };
36
+ //#endregion
37
+ export { o as getZoomCenterOrigin, a as getZoomOriginFromClientPoint, s as useZoomOrigin };
@@ -1,21 +1,28 @@
1
- import { AnnotationMode as e } from "pdfjs-dist";
1
+ import { IOS_MAX_CANVAS_PIXELS as e, MAX_CANVAS_DIM as t, MAX_CANVAS_PIXELS as n, SAFARI_MAX_CANVAS_PIXELS as r } from "./constants.js";
2
+ import { AnnotationMode as i } from "pdfjs-dist";
2
3
  //#region lib/utils/renderPage.ts
3
- var t = (t, n, r = {}) => {
4
- let { scale: i = 1, rotate: a = 0, renderForms: o = !1, interactiveForm: s = !0 } = r, c = n.getContext("2d", { desynchronized: !1 }), l = window.devicePixelRatio, u = t.getViewport({
5
- scale: i,
4
+ var a = () => {
5
+ let t = navigator.userAgent, i = /iPad|iPhone|iPod/.test(t) && !window.MSStream, a = /^((?!chrome|android).)*safari/i.test(t);
6
+ return i ? e : a ? r : n;
7
+ }, o = (e, n) => {
8
+ let r = window.devicePixelRatio || 1, i = Math.max(e * n, 1), o = Math.min(a(), i * 200), s = Math.sqrt(o / i), c = t / Math.max(e, 1), l = t / Math.max(n, 1), u = Math.min(r, s, c, l);
9
+ return Number.isFinite(u) && u > 0 ? u : 1;
10
+ }, s = (e, t, n = {}) => {
11
+ let { scale: r = 1, rotate: a = 0, renderForms: s = !1, interactiveForm: c = !0 } = n, l = t.getContext("2d", { desynchronized: !1 }), u = e.getViewport({
12
+ scale: r,
6
13
  rotation: a
7
- }), d = t.getViewport({
8
- scale: i * l,
14
+ }), d = o(u.width, u.height), f = e.getViewport({
15
+ scale: r * d,
9
16
  rotation: a
10
17
  });
11
- n.width = d.width, n.height = d.height, n.style.width = `${Math.floor(u.width)}px`, n.style.height = `${Math.floor(u.height)}px`;
12
- let f = o ? e.ENABLE_FORMS : void 0;
13
- return s || (f = e.ENABLE), t.render({
14
- canvas: n,
15
- canvasContext: c,
16
- viewport: d,
17
- annotationMode: f
18
+ t.width = Math.floor(f.width), t.height = Math.floor(f.height), t.style.width = `${Math.floor(u.width)}px`, t.style.height = `${Math.floor(u.height)}px`;
19
+ let p = s ? i.ENABLE_FORMS : void 0;
20
+ return c || (p = i.ENABLE), e.render({
21
+ canvas: t,
22
+ canvasContext: l,
23
+ viewport: f,
24
+ annotationMode: p
18
25
  });
19
26
  };
20
27
  //#endregion
21
- export { t as renderPage };
28
+ export { s as renderPage };
@@ -1,11 +1,11 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "../de_DE--0LF-SJR.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "../de_DE-x4Z-jQrz.js";
2
2
  //#region lib/utils/types.ts
3
3
  var o = /* @__PURE__ */ function(e) {
4
4
  return e[e.Text = 1] = "Text", e[e.Link = 2] = "Link", e[e.FreeText = 3] = "FreeText", e[e.Line = 4] = "Line", e[e.Square = 5] = "Square", e[e.Circle = 6] = "Circle", e[e.Polygon = 7] = "Polygon", e[e.Polyline = 8] = "Polyline", e[e.Highlight = 9] = "Highlight", e[e.Underline = 10] = "Underline", e[e.Squiggly = 11] = "Squiggly", e[e.StrikeOut = 12] = "StrikeOut", e[e.Stamp = 13] = "Stamp", e[e.Caret = 14] = "Caret", e[e.Ink = 15] = "Ink", e[e.Popup = 16] = "Popup", e[e.FileAttachment = 17] = "FileAttachment", e[e.Widget = 20] = "Widget", e;
5
5
  }({}), s = /* @__PURE__ */ function(e) {
6
6
  return e.INTERNAL_LINK = "internal-link", e.LINK = "link", e.FILE_ATTACHMENT = "file-attachment", e.FORM_TEXT = "form-text", e.FORM_SELECT = "form-select", e.FORM_CHECKBOX = "form-checkbox", e.FORM_RADIO = "form-radio", e.FORM_BUTTON = "form-button", e.BUTTON = "button", e;
7
7
  }({}), c = /* @__PURE__ */ function(e) {
8
- return e.NOT_SUPPORTED = "not-supported", e.INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf", e;
8
+ return e.NOT_SUPPORTED = "not-supported", e.INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf", e.WASM_URL_REQUIRED = "wasm-url-required", e;
9
9
  }({}), l = /* @__PURE__ */ function(e) {
10
10
  return e.ACTUAL = "Actual Size", e.PAGE_FIT = "Page Fit", e.PAGE_WIDTH = "Page Width", e;
11
11
  }({}), u = /* @__PURE__ */ function(e) {
@@ -13,7 +13,7 @@ var o = /* @__PURE__ */ function(e) {
13
13
  }({}), d = /* @__PURE__ */ function(e) {
14
14
  return e.SINGLE_PAGE = "Single", e.DUAL_PAGE = "Dual", e.DUAL_PAGE_WITH_COVER = "DualWithCover", e;
15
15
  }({}), f = /* @__PURE__ */ function(e) {
16
- return e.FONT_FAMILY = "--rp-font-family", e.PRIMARY_COLOR = "--rp-primary-color", e.BORDER_RADIUS = "--rp-border-radius", e.TEXT_COLOR = "--rp-text-color", e.OUTLINE_COLOR = "--rp-outline-color", e.FONT_SIZE = "--rp-font-size", e.DROP_MASK_BACKGROUND_COLOR = "--rp-drop-mask-background-color", e.LOADER_BACKDROP_COLOR = "--rp-loader-backdrop-color", e.ICON_DISABLED = "--rp-icon-disabled", e.ICON_FONT_SIZE = "--rp-icon-font-size", e.TOOLBAR_BACKGROUND = "--rp-toolbar-background", e.TOOLBAR_BORDER_COLOR = "--rp-toolbar-border-color", e.TOOLBAR_PADDING = "--rp-toolbar-padding", e.TOOLBAR_GAP = "--rp-toolbar-gap", e.TOOLBAR_SIZE = "--rp-toolbar-size", e.SIDEBAR_WIDTH = "--rp-sidebar-width", e.THUMBNAIL_BORDER_COLOR = "--rp-thumbnail-border-color", e.THUMBNAIL_BACKGROUND_COLOR = "--rp-thumbnail-background-color", e.THUMBNAIL_ACTIVE_COLOR = "--rp-thumbnail-active-color", e.THUMBNAIL_PADDING_Y = "--rp-thumbnail-padding-y", e.BUTTON_HOVER_BACKGROUND = "--rp-button-hover-background", e.BUTTON_PADDING = "--rp-button-padding", e.INPUT_PADDING = "--rp-input-padding", e.INPUT_BORDER_RADIUS = "--rp-input-border-radius", e.INPUT_BACKGROUND_COLOR = "--rp-input-background-color", e.INPUT_PLACEHOLDER_COLOR = "--rp-input-placeholder-color", e.PAGES_BACKGROUND_COLOR = "--rp-pages-background-color", e.PAGE_SHADOW = "--rp-page-shadow", e.PAGE_OUTLINE = "--rp-page-outline", e.PAGE_OUTLINE_OFFSET = "--rp-page-outline-offset", e.ANNOTATION_LAYER_LINK_HOVER_BACKGROUND = "--rp-annotation-layer__link-hover-background", e.DROPDOWN_BACKGROUND_COLOR = "--rp-dropdown-background-color", e.DROPDOWN_PADDING = "--rp-dropdown-padding", e.DROPDOWN_HOVER_BACKGROUND_COLOR = "--rp-dropdown-hover-background-color", e.DROPDOWN_SEPARATOR_COLOR = "--rp-dropdown-separator-color", e.DROPDOWN_SEPARATOR_MARGIN = "--rp-dropdown-separator-margin", e.DROPDOWN_PADDING_MENU_ITEM = "--rp-dropdown-padding-menu-item", e.DROPDOWN_FONT_SIZE = "--rp-dropdown-font-size", e.DROPDOWN_BORDER_RADIUS = "--rp-dropdown-border-radius", e.SEARCH_TOOL_DROPDOWN_PADDING = "--rp-search-tool-dropdown-padding", e.POPOVER_FONT_SIZE = "--rp-popover-font-size", e.POPOVER_BACKGROUND_COLOR = "--rp-popover-background-color", e.POPOVER_COLOR = "--rp-popover-color", e.POPOVER_BORDER_COLOR = "--rp-popover-border-color", e.POPOVER_BORDER_RADIUS = "--rp-popover-border-radius", e.OVERLAY_BACKGROUND_COLOR = "--rp-overlay-background-color", e.DIALOG_BACKGROUND_COLOR = "--rp-dialog-background-color", e.PROPERTIES_DIVIDER_COLOR = "--rp-properties-divider-color", e.PROPERTIES_DIVIDER_MARGIN = "--rp-properties-divider-margin", e.PROPERTY_ITEM_GAP = "--rp-property-item-gap", e.DIALOG_TITLE_COLOR = "--rp-dialog-title-color", e.PROPERTY_ITEM_LABEL_COLOR = "--rp-property-item-label-color", e.PROPERTY_CLOSE_ICON_SIZE = "--rp-property-close-icon-size", e.PROPERTY_ITEM_FONT_SIZE = "--rp-property-item-font-size", e.PROPERTY_ITEM_FONT_WEIGHT = "--rp-property-item-font-weight", e.DIALOG_TITLE_FONT_SIZE = "--rp-dialog-title-font-size", e.DIALOG_TITLE_FONT_WEIGHT = "--rp-dialog-title-font-weight", e.MENU_ITEM_ICON_SIZE = "--rp-menu-item-icon-size", e.PRINT_PROGRESS_BACKGROUND = "--rp-print-progress-background", e.PRINT_PROGRESS_COLOR = "--rp-print-progress-color", e.DROP_ZONE_BORDER = "--rp-drop-zone-border", e.DROP_ZONE_FONT_COLOR = "--rp-drop-zone-font-color", e.DROP_ZONE_FONT_SIZE = "--rp-drop-zone-font-size", e.DROP_ZONE_BACKGROUND_COLOR = "--rp-drop-zone-background-color", e.CHECKBOX_BORDER_RADIUS = "--rp-checkbox-border-radius", e.CHECKBOX_BORDER_COLOR = "--rp-checkbox-border-color", e.CHECKBOX_INDICATOR_COLOR = "--rp-checkbox-indicator-color", e.HIGHLIGHT_BACKGROUND_COLOR = "--rp-highlight-background-color", e.TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius", e.CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color", e.TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color", e.TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius", e.TOOLTIP_FONT_COLOR = "--rp-tooltip-font-color", e.TOOLTIP_FONT_SIZE = "--rp-tooltip-font-size", e.TOOLTIP_PADDING = "--rp-tooltip-padding", e.PASSWORD_MODAL_BACKGROUND_COLOR = "--rp-password-background-color", e.PASSWORD_MODAL_TITLE_FONT_COLOR = "--rp-password-title-font-color", e.PASSWORD_MODAL_CONTENT_FONT_COLOR = "--rp-password-content-font-color", e.PASSWORD_MODAL_INPUT_PLACEHOLDER_COLOR = "--rp-password-input-placeholder-color", e.PASSWORD_MODAL_INPUT_BORDER_COLOR = "--rp-password-input-border-color", e.PASSWORD_MODAL_INPUT_FONT_COLOR = "--rp-password-input-font-color", e.PASSWORD_MODAL_BUTTON_FONT_COLOR = "--rp-password-button-font-color", e.PASSWORD_MODAL_BUTTON_BACKGROUND_COLOR = "--rp-password-button-background-color", e.PASSWORD_MODAL_BUTTON_BORDER_COLOR = "--rp-password-button-border-color", e.PASSWORD_MODAL_BORDER_COLOR = "--rp-password-border-color", e.CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width", e.CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color", e.CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset", e.BUTTON_BORDER_RADIUS = "--rp-button-border-radius", e.SKIP_LINK_FONT_SIZE = "--rp-skip-link-font-size", e.SKIP_LINK_COLOR = "--rp-skip-link-color", e.SKIP_LINK_BACKGROUND_COLOR = "--rp-skip-link-background-color", e.SKIP_LINK_BORDER_COLOR = "--rp-skip-link-border-color", e;
16
+ return e.FONT_FAMILY = "--rp-font-family", e.PRIMARY_COLOR = "--rp-primary-color", e.BORDER_RADIUS = "--rp-border-radius", e.TEXT_COLOR = "--rp-text-color", e.OUTLINE_COLOR = "--rp-outline-color", e.FONT_SIZE = "--rp-font-size", e.DROP_MASK_BACKGROUND_COLOR = "--rp-drop-mask-background-color", e.LOADER_BACKDROP_COLOR = "--rp-loader-backdrop-color", e.ICON_DISABLED = "--rp-icon-disabled", e.ICON_FONT_SIZE = "--rp-icon-font-size", e.TOOLBAR_BACKGROUND = "--rp-toolbar-background", e.TOOLBAR_BORDER_COLOR = "--rp-toolbar-border-color", e.TOOLBAR_PADDING = "--rp-toolbar-padding", e.TOOLBAR_GAP = "--rp-toolbar-gap", e.TOOLBAR_SIZE = "--rp-toolbar-size", e.SIDEBAR_WIDTH = "--rp-sidebar-width", e.THUMBNAIL_BORDER_COLOR = "--rp-thumbnail-border-color", e.THUMBNAIL_BACKGROUND_COLOR = "--rp-thumbnail-background-color", e.THUMBNAIL_ACTIVE_COLOR = "--rp-thumbnail-active-color", e.THUMBNAIL_PADDING_Y = "--rp-thumbnail-padding-y", e.BUTTON_HOVER_BACKGROUND = "--rp-button-hover-background", e.BUTTON_PADDING = "--rp-button-padding", e.INPUT_PADDING = "--rp-input-padding", e.INPUT_BORDER_RADIUS = "--rp-input-border-radius", e.INPUT_BACKGROUND_COLOR = "--rp-input-background-color", e.INPUT_PLACEHOLDER_COLOR = "--rp-input-placeholder-color", e.SEARCH_INPUT_BORDER_COLOR = "--rp-search-input-border-color", e.PAGES_BACKGROUND_COLOR = "--rp-pages-background-color", e.PAGE_SHADOW = "--rp-page-shadow", e.PAGE_OUTLINE = "--rp-page-outline", e.PAGE_OUTLINE_OFFSET = "--rp-page-outline-offset", e.ANNOTATION_LAYER_LINK_HOVER_BACKGROUND = "--rp-annotation-layer__link-hover-background", e.DROPDOWN_BACKGROUND_COLOR = "--rp-dropdown-background-color", e.DROPDOWN_PADDING = "--rp-dropdown-padding", e.DROPDOWN_HOVER_BACKGROUND_COLOR = "--rp-dropdown-hover-background-color", e.DROPDOWN_SEPARATOR_COLOR = "--rp-dropdown-separator-color", e.DROPDOWN_SEPARATOR_MARGIN = "--rp-dropdown-separator-margin", e.DROPDOWN_PADDING_MENU_ITEM = "--rp-dropdown-padding-menu-item", e.DROPDOWN_FONT_SIZE = "--rp-dropdown-font-size", e.DROPDOWN_BORDER_RADIUS = "--rp-dropdown-border-radius", e.SEARCH_TOOL_DROPDOWN_PADDING = "--rp-search-tool-dropdown-padding", e.POPOVER_FONT_SIZE = "--rp-popover-font-size", e.POPOVER_BACKGROUND_COLOR = "--rp-popover-background-color", e.POPOVER_COLOR = "--rp-popover-color", e.POPOVER_BORDER_COLOR = "--rp-popover-border-color", e.POPOVER_BORDER_RADIUS = "--rp-popover-border-radius", e.OVERLAY_BACKGROUND_COLOR = "--rp-overlay-background-color", e.DIALOG_BACKGROUND_COLOR = "--rp-dialog-background-color", e.PROPERTIES_DIVIDER_COLOR = "--rp-properties-divider-color", e.PROPERTIES_DIVIDER_MARGIN = "--rp-properties-divider-margin", e.PROPERTY_ITEM_GAP = "--rp-property-item-gap", e.DIALOG_TITLE_COLOR = "--rp-dialog-title-color", e.PROPERTY_ITEM_LABEL_COLOR = "--rp-property-item-label-color", e.PROPERTY_CLOSE_ICON_SIZE = "--rp-property-close-icon-size", e.PROPERTY_ITEM_FONT_SIZE = "--rp-property-item-font-size", e.PROPERTY_ITEM_FONT_WEIGHT = "--rp-property-item-font-weight", e.DIALOG_TITLE_FONT_SIZE = "--rp-dialog-title-font-size", e.DIALOG_TITLE_FONT_WEIGHT = "--rp-dialog-title-font-weight", e.MENU_ITEM_ICON_SIZE = "--rp-menu-item-icon-size", e.PRINT_PROGRESS_BACKGROUND = "--rp-print-progress-background", e.PRINT_PROGRESS_COLOR = "--rp-print-progress-color", e.PRINT_PROGRESS_CANCEL_BUTTON_BORDER_COLOR = "--rp-print-progress-cancel-button-border-color", e.DROP_ZONE_BORDER = "--rp-drop-zone-border", e.DROP_ZONE_FONT_COLOR = "--rp-drop-zone-font-color", e.DROP_ZONE_FONT_SIZE = "--rp-drop-zone-font-size", e.DROP_ZONE_BACKGROUND_COLOR = "--rp-drop-zone-background-color", e.CHECKBOX_BORDER_RADIUS = "--rp-checkbox-border-radius", e.CHECKBOX_BORDER_COLOR = "--rp-checkbox-border-color", e.CHECKBOX_INDICATOR_COLOR = "--rp-checkbox-indicator-color", e.HIGHLIGHT_BACKGROUND_COLOR = "--rp-highlight-background-color", e.TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius", e.CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color", e.TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color", e.TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius", e.TOOLTIP_FONT_COLOR = "--rp-tooltip-font-color", e.TOOLTIP_FONT_SIZE = "--rp-tooltip-font-size", e.TOOLTIP_PADDING = "--rp-tooltip-padding", e.PASSWORD_MODAL_BACKGROUND_COLOR = "--rp-password-background-color", e.PASSWORD_MODAL_TITLE_FONT_COLOR = "--rp-password-title-font-color", e.PASSWORD_MODAL_CONTENT_FONT_COLOR = "--rp-password-content-font-color", e.PASSWORD_MODAL_INPUT_PLACEHOLDER_COLOR = "--rp-password-input-placeholder-color", e.PASSWORD_MODAL_INPUT_BORDER_COLOR = "--rp-password-input-border-color", e.PASSWORD_MODAL_INPUT_FONT_COLOR = "--rp-password-input-font-color", e.PASSWORD_MODAL_BUTTON_FONT_COLOR = "--rp-password-button-font-color", e.PASSWORD_MODAL_BUTTON_BACKGROUND_COLOR = "--rp-password-button-background-color", e.PASSWORD_MODAL_BUTTON_BORDER_COLOR = "--rp-password-button-border-color", e.PASSWORD_MODAL_BORDER_COLOR = "--rp-password-border-color", e.CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width", e.CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color", e.CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset", e.BUTTON_BORDER_RADIUS = "--rp-button-border-radius", e.SKIP_LINK_FONT_SIZE = "--rp-skip-link-font-size", e.SKIP_LINK_COLOR = "--rp-skip-link-color", e.SKIP_LINK_BACKGROUND_COLOR = "--rp-skip-link-background-color", e.SKIP_LINK_BORDER_COLOR = "--rp-skip-link-border-color", e;
17
17
  }({}), p = /* @__PURE__ */ function(e) {
18
18
  return e.PAGE_SCROLLING = "PAGE", e.VERTICAL_SCROLLING = "VERTICAL", e.HORIZONTAL_SCROLLING = "HORIZONTAL", e;
19
19
  }({}), m = /* @__PURE__ */ function(e) {
@@ -1,5 +1,11 @@
1
1
  import { MAX_ZOOM_SCALE as e } from "./constants.js";
2
2
  //#region lib/utils/zoom.ts
3
- var t = (e) => e * 100 <= 25, n = (t) => t * 100 >= e;
3
+ var t = (e) => e * 100 <= 25, n = (t) => t * 100 >= e, r = (t) => {
4
+ let n = Math.floor(t / 25) * 25;
5
+ return Math.min(n + 25, e);
6
+ }, i = (e) => {
7
+ let t = Math.ceil(e / 25) * 25;
8
+ return Math.max(t - 25, 25);
9
+ };
4
10
  //#endregion
5
- export { n as isZoomInDisabled, t as isZoomOutDisabled };
11
+ export { r as getNextZoomInLevel, i as getNextZoomOutLevel, n as isZoomInDisabled, t as isZoomOutDisabled };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.8.0-beta.1",
3
+ "version": "2.8.0-beta.10",
4
4
  "private": false,
5
5
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
6
6
  "keywords": [