@react-pdf-kit/viewer 2.8.0-beta.6 → 2.8.0-beta.8

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 (172) hide show
  1. package/README.md +44 -30
  2. package/dist/{AnnotationLayer-CAIvKf_O.js → AnnotationLayer-CyOYh0Tw.js} +2 -2
  3. package/dist/CanvasLayer-CJqCJ30J.js +111 -0
  4. package/dist/{LoadingIndicator-DiWoWs4Y.js → LoadingIndicator-B_Jsf8No.js} +7 -7
  5. package/dist/MenuItem-D-GflAAo.js +31 -0
  6. package/dist/PaginationContext-DIzsZhFd.js +194 -0
  7. package/dist/{PasswordModal-CB9Rd2zJ.js → PasswordModal-S0leMhEd.js} +11 -11
  8. package/dist/RPLayout.module-BH5r8dDc.js +14 -0
  9. package/dist/RPPages-BQw330_L.js +655 -0
  10. package/dist/{RPTooltip-ZZoFqP7C.js → RPTooltip-COLVx-C_.js} +123 -91
  11. package/dist/SearchTool.module-DY8Ucfb_.js +17 -0
  12. package/dist/{SkipLink-CdcjClGB.js → SkipLink-Dj83gZdk.js} +3 -3
  13. package/dist/{TextLayer-DWGFN9SF.js → TextLayer-D-V9kogG.js} +5 -5
  14. package/dist/{Thumbnail-CzclS3h_.js → Thumbnail-C6zkvwcs.js} +6 -6
  15. package/dist/{Thumbnails-DnAsrttK.js → Thumbnails-DKG6I7pb.js} +2 -2
  16. package/dist/assets/AnnotationLayer.css +1 -1
  17. package/dist/assets/CanvasLayer.css +1 -0
  18. package/dist/assets/LoadingIndicator.css +1 -1
  19. package/dist/assets/MenuItem.css +1 -1
  20. package/dist/assets/PasswordModal.css +1 -1
  21. package/dist/assets/RPLayout.css +1 -1
  22. package/dist/assets/RPPages.css +1 -1
  23. package/dist/assets/SearchTool.css +1 -1
  24. package/dist/assets/SkipLink.css +1 -1
  25. package/dist/assets/TextLayer.css +1 -1
  26. package/dist/assets/Thumbnail.css +1 -1
  27. package/dist/assets/style.js +1 -1
  28. package/dist/components/RPController.js +39 -39
  29. package/dist/components/RPPages.js +1 -1
  30. package/dist/components/RPProvider.js +1 -1
  31. package/dist/components/layout/LayoutContainer.js +6 -6
  32. package/dist/components/layout/LayoutWrapper.js +5 -5
  33. package/dist/components/layout/RPDefaultLayout.js +2 -2
  34. package/dist/components/layout/RPLayout.js +2 -2
  35. package/dist/components/layout/SkipLink.js +1 -1
  36. package/dist/components/layout/sidebar/RPSidebar.js +2 -2
  37. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  38. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  39. package/dist/components/layout/toolbar/DarkModeTool.js +1 -1
  40. package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
  41. package/dist/components/layout/toolbar/FileDownloadTool.js +6 -6
  42. package/dist/components/layout/toolbar/FileUploadTool.js +6 -6
  43. package/dist/components/layout/toolbar/FullScreenTool.js +9 -8
  44. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  45. package/dist/components/layout/toolbar/MostPageTool.js +23 -29
  46. package/dist/components/layout/toolbar/OtherTool.js +1 -1
  47. package/dist/components/layout/toolbar/Paginate.js +2 -2
  48. package/dist/components/layout/toolbar/PrintTool.js +6 -6
  49. package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
  50. package/dist/components/layout/toolbar/RPMoreOptions.js +1 -1
  51. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  52. package/dist/components/layout/toolbar/RotateTool.js +10 -10
  53. package/dist/components/layout/toolbar/ScrollModeTool.js +17 -17
  54. package/dist/components/layout/toolbar/SearchCloseButton.js +2 -2
  55. package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
  56. package/dist/components/layout/toolbar/SearchTool.js +133 -121
  57. package/dist/components/layout/toolbar/SelectionModeTool.js +10 -10
  58. package/dist/components/layout/toolbar/ThumbnailTool.js +1 -1
  59. package/dist/components/layout/toolbar/ToolbarCustom.js +2 -2
  60. package/dist/components/layout/toolbar/ToolbarDefault.js +2 -2
  61. package/dist/components/layout/toolbar/ViewModeTool.js +16 -16
  62. package/dist/components/layout/toolbar/ZoomTool.js +82 -80
  63. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +1 -1
  64. package/dist/components/layout/toolbar/tools/DualPageTool.js +1 -1
  65. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
  66. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +1 -1
  67. package/dist/components/layout/toolbar/tools/FileUploadTool.js +1 -1
  68. package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
  69. package/dist/components/layout/toolbar/tools/FullScreenTool.js +1 -1
  70. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +3 -3
  71. package/dist/components/layout/toolbar/tools/InputPageTool.js +2 -2
  72. package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
  73. package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
  74. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +1 -1
  75. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +2 -2
  76. package/dist/components/layout/toolbar/tools/PrintTool.js +1 -1
  77. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +1 -1
  78. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +1 -1
  79. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +1 -1
  80. package/dist/components/layout/toolbar/tools/SinglePageTool.js +1 -1
  81. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +1 -1
  82. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  83. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +1 -1
  84. package/dist/components/layout/toolbar/tools/ZoomInTool.js +25 -23
  85. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +1 -1
  86. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
  87. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +25 -23
  88. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
  89. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
  90. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
  91. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
  92. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +3 -3
  93. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
  94. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +2 -2
  95. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +7 -7
  96. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
  97. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
  98. package/dist/components/page/AnnotationLayer.js +1 -1
  99. package/dist/components/page/CanvasLayer.js +2 -48
  100. package/dist/components/page/DualPage.js +2 -2
  101. package/dist/components/page/DualPageWithCover.js +2 -2
  102. package/dist/components/page/RPPage.js +94 -2
  103. package/dist/components/page/SinglePage.js +2 -2
  104. package/dist/components/page/TextHighlightLayer.js +1 -1
  105. package/dist/components/page/TextLayer.js +1 -1
  106. package/dist/components/ui/LoadingIndicator.js +1 -1
  107. package/dist/components/ui/PasswordModal.js +1 -1
  108. package/dist/components/ui/RPTooltip.js +1 -1
  109. package/dist/contexts/DimensionPagesContext.js +38 -22
  110. package/dist/contexts/ElementPageContext.js +46 -39
  111. package/dist/contexts/ElementThumbnailContext.js +1 -1
  112. package/dist/contexts/PaginationContext.js +1 -1
  113. package/dist/contexts/RenderQueueProvider.js +24 -18
  114. package/dist/contexts/RenderedPagesCache.js +32 -13
  115. package/dist/contexts/VirtualScrollContext.js +10 -13
  116. package/dist/contexts/ZoomContext.js +119 -61
  117. package/dist/{de_DE-DwUvXUWH.js → de_DE-x4Z-jQrz.js} +30 -0
  118. package/dist/{main-CKr9unOk.js → main-7sMXtgRg.js} +2 -2
  119. package/dist/main.js +4 -4
  120. package/dist/style-CJtyyrJx.js +5 -0
  121. package/dist/types/components/page/CanvasLayer.d.ts +4 -1
  122. package/dist/types/components/ui/RPTooltip.d.ts +3 -2
  123. package/dist/types/contexts/RenderQueueProvider.d.ts +2 -0
  124. package/dist/types/contexts/RenderedPagesCache.d.ts +3 -0
  125. package/dist/types/contexts/VirtualScrollContext.d.ts +0 -3
  126. package/dist/types/locales/de_DE.json.d.ts +5 -0
  127. package/dist/types/locales/en_US.json.d.ts +5 -0
  128. package/dist/types/locales/it_IT.json.d.ts +5 -0
  129. package/dist/types/locales/pt_PT.json.d.ts +5 -0
  130. package/dist/types/locales/th_TH.json.d.ts +5 -0
  131. package/dist/types/locales/zh_CN.json.d.ts +5 -0
  132. package/dist/types/utils/Queue.d.ts +1 -0
  133. package/dist/types/utils/const.d.ts +3 -0
  134. package/dist/types/utils/constants.d.ts +9 -0
  135. package/dist/types/utils/documentLayout.d.ts +60 -0
  136. package/dist/types/utils/hooks/usePinch.d.ts +14 -1
  137. package/dist/types/utils/hooks/usePresentPage.d.ts +2 -2
  138. package/dist/types/utils/hooks/useZoomOrigin.d.ts +4 -0
  139. package/dist/types/utils/types.d.ts +21 -2
  140. package/dist/types/utils/zoom.d.ts +2 -0
  141. package/dist/utils/Queue.js +5 -0
  142. package/dist/utils/const.js +2 -2
  143. package/dist/utils/constants.js +2 -2
  144. package/dist/utils/documentLayout.js +141 -0
  145. package/dist/utils/hooks/useLicense.js +1 -1
  146. package/dist/utils/hooks/useLoadPdf.js +73 -63
  147. package/dist/utils/hooks/useLocalization.js +1 -1
  148. package/dist/utils/hooks/usePaginate.js +1 -1
  149. package/dist/utils/hooks/usePinch.js +109 -56
  150. package/dist/utils/hooks/usePresentPage.js +33 -57
  151. package/dist/utils/hooks/useScrollToPage.js +1 -1
  152. package/dist/utils/hooks/useSearch.js +66 -67
  153. package/dist/utils/hooks/useZoomOrigin.js +37 -0
  154. package/dist/utils/renderPage.js +21 -14
  155. package/dist/utils/types.js +3 -3
  156. package/dist/utils/zoom.js +8 -2
  157. package/package.json +1 -1
  158. package/dist/MenuItem-BJDWfzAw.js +0 -15
  159. package/dist/PaginationContext-Cwf8sCpK.js +0 -242
  160. package/dist/RPLayout.module-Vc3h4xxS.js +0 -14
  161. package/dist/RPPage-C_r8aeTc.js +0 -91
  162. package/dist/RPPages-CmXHTAqF.js +0 -1007
  163. package/dist/SearchTool.module-DUkVXfOn.js +0 -16
  164. package/dist/assets/RPPage.css +0 -1
  165. package/dist/contexts/VirtualGridContext.js +0 -18
  166. package/dist/style-C8T5x1fE.js +0 -5
  167. package/dist/types/contexts/VirtualGridContext.d.ts +0 -9
  168. package/dist/types/utils/calculatePage.d.ts +0 -12
  169. package/dist/types/utils/hooks/useVirtualReactWindow.d.ts +0 -17
  170. package/dist/utils/calculatePage.js +0 -30
  171. package/dist/utils/hooks/useVirtualReactWindow.js +0 -86
  172. /package/dist/{TextHighlightLayer-BSVgBxR3.js → TextHighlightLayer-3vIZbRyL.js} +0 -0
package/README.md CHANGED
@@ -32,6 +32,10 @@
32
32
  - **Modern Browser Compatibility**: The React PDF Viewer components seamlessly across modern browsers, eliminating compatibility headaches.
33
33
  - **Active Development & Support**: With regular updates and a responsive support team, React PDF Kit evolves to meet developer needs.
34
34
 
35
+ <p align="center">
36
+ <img src="https://github.com/user-attachments/assets/8803229a-2f59-48d1-aecc-628ae759862f" alt="React PDF Kit demo">
37
+ </p>
38
+
35
39
  # 📜 Background
36
40
 
37
41
  As developers ourselves, we faced many issues such as browser incompatibility and customizability while trying to render a PDF document or working with PDF libraries. Having faced issues using PDF libraries, we want the solution to be flexible for React.js developers and teams. More importantly, the technical document must be easy to use!
@@ -47,7 +51,7 @@ As developers ourselves, we faced many issues such as browser incompatibility an
47
51
  - 📂 **Document Management Tools**, including features like downloading and printing.
48
52
  - 👁️ **Accessibility Support** to built-in support for ARIA attributes and tooltips, catering to diverse user bases.
49
53
 
50
- For the full feature set, visit [React PDF Kit Features](https://www.react-pdf-kit.dev/features?utm_source=github&utm_medium=referral).
54
+ For the full feature set, visit [React PDF Kit Features](https://www.react-pdf-kit.dev/features).
51
55
 
52
56
  # :zap: Quick Start Guide
53
57
 
@@ -78,23 +82,13 @@ As newer PDF.js versions rely on more modern browser APIs, minimum supported bro
78
82
 
79
83
  React PDF Kit v2.0.0 defaults to PDF.js `5.4.530`.
80
84
 
81
- | Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
82
- | ------ | ------- | ---- | ------ | ---------- | -------------- |
83
- | 126+ | 126+ | 126+ | 18.4+ | 18.4+ | 126+ |
84
-
85
- <Aside>
86
- It's currently not recommended to use a PDF.js worker version beyond `5.4.530` because it will support fewer browser versions.
87
- </Aside>
88
-
89
- #### Using PDF.js 4.10.38
85
+ | Configuration | Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
86
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------- | ---- | ------ | ---------- | -------------- |
87
+ | React PDF Kit v2 | 126+ | 126+ | 126+ | 18.4+ | 18.4+ | 126+ |
88
+ | [React PDF Kit v2 + Polyfills](https://www.react-pdf-kit.dev/docs/usage-guide/legacy-browser-support.html#polyfills-library) | 119+ | 121+ | 119+ | 18.3+ | 18.3+ | 119+ |
89
+ | [React PDF Kit v2 + Polyfills + Legacy PDF.js Worker](https://www.react-pdf-kit.dev/docs/usage-guide/legacy-browser-support.html#override-the-pdfjs-worker) | 101+ | 101+ | 101+ | 16.5+ | 16.5+ | 101+ |
90
90
 
91
- If you need broader browser compatibility, you can continue using PDF.js `4.10.38`, which supports:
92
-
93
- | Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
94
- | ------ | ------- | ---- | ------ | ---------- | -------------- |
95
- | 119+ | 115+ | 115+ | 17.4+ | 17.4+ | 126+ |
96
-
97
- To change the version of PDF.js used, refer to [Dependency Override](https://docs.react-pdf-kit.dev/usage-guide/overriding-dependency?utm_source=github&utm_medium=referral) guide.
91
+ To change the version of PDF.js used, refer to [Dependency Override](https://www.react-pdf-kit.dev/docs/usage-guide/overriding-dependency) guide.
98
92
 
99
93
  ## 2. Install the Package
100
94
 
@@ -133,25 +127,33 @@ yarn add @react-pdf-kit/viewer
133
127
  pnpm add @react-pdf-kit/viewer
134
128
  ```
135
129
 
136
- For more information on how to use different package managers, please visit our [installation guide](https://docs.react-pdf-kit.dev/introduction/getting-started/#installation?utm_source=github&utm_medium=referral).
130
+ For more information on how to use different package managers, please visit our [installation guide](https://www.react-pdf-kit.dev/docs/introduction/getting-started/#installation).
137
131
 
138
132
  ## 3. Import and Use the Component
139
133
 
140
134
  The following structure demonstrates how to build a React PDF viewer by importing and assembling components. This modular approach gives you the flexibility to customize the viewer as needed.
141
135
 
142
136
  ```tsx
143
- <RPConfig> {/* Configuration license and pdfjs-dist worker */}
144
- <RPTheme> {/* Theme customization (optional) */}
145
- <RPProvider> {/* Viewer context provider */}
146
- <RPLayout toolbar> {/* Provide the default toolbar structure */}
147
- <RPPages /> {/* Render the actual PDF content */}
137
+ <RPConfig>
138
+ {' '}
139
+ {/* Configuration license and pdfjs-dist worker */}
140
+ <RPTheme>
141
+ {' '}
142
+ {/* Theme customization (optional) */}
143
+ <RPProvider>
144
+ {' '}
145
+ {/* Viewer context provider */}
146
+ <RPLayout toolbar>
147
+ {' '}
148
+ {/* Provide the default toolbar structure */}
149
+ <RPPages /> {/* Render the actual PDF content */}
148
150
  </RPLayout>
149
151
  </RPProvider>
150
152
  </RPTheme>
151
153
  </RPConfig>
152
154
  ```
153
155
 
154
- _Remark: For more information on each component, please refer to [Component](https://docs.react-pdf-kit.dev/components/overview?utm_source=github&utm_medium=referral)._
156
+ _Remark: For more information on each component, please refer to [Component](https://www.react-pdf-kit.dev/docs/components/overview)._
155
157
 
156
158
  ### Basic Usage
157
159
 
@@ -176,7 +178,7 @@ const App = () => {
176
178
  export default App
177
179
  ```
178
180
 
179
- The PDF viewer will automatically adjust to fit its container's dimensions. You can control the size by setting the `style` prop on `RPLayout`. For more information on using React PDF, visit our [basic usage guide](https://docs.react-pdf-kit.dev/introduction/basic-usage?utm_source=github&utm_medium=referral)
181
+ The PDF viewer will automatically adjust to fit its container's dimensions. You can control the size by setting the `style` prop on `RPLayout`. For more information on using React PDF, visit our [basic usage guide](https://www.react-pdf-kit.dev/docs/introduction/basic-usage)
180
182
 
181
183
  You may also check out our [Starter Toolkit](#pushpin-starter-toolkit) for examples to get you started.
182
184
 
@@ -186,6 +188,17 @@ To enhance React PDF Kit further, we offer built-in hooks and props that let you
186
188
 
187
189
  For detailed usage, refer to our [Documentation][reactpdf-docs].
188
190
 
191
+ ### 5. Localization
192
+
193
+ React PDF Kit supports multiple languages out of the box. Pass a locale JSON file to `RPConfig` to translate all viewer text:
194
+
195
+ ```jsx
196
+ import zhCN from './localization/zh_CN.json'
197
+ ;<RPConfig localization={zhCN}>{/* ... */}</RPConfig>
198
+ ```
199
+
200
+ We ship locale files for English, Italian, Portuguese, Thai, and Chinese (Simplified). You can also create your own -- see the [Localization Guide](./localization/README.md) for the full list of translation keys and instructions on adding a new language. If you've created a locale we don't support yet, feel free to open a PR to share it with the community!
201
+
189
202
  # :pushpin: Starter Toolkit
190
203
 
191
204
  Here are some sample projects to get started on React PDF quickly:
@@ -215,7 +228,7 @@ Here are some sample projects to get started on React PDF quickly:
215
228
 
216
229
  # 📝 Changelog
217
230
 
218
- Check out our latest release [v2.0.0 (20 February 2026)](https://docs.react-pdf-kit.dev/introduction/changelog/#v200-20-february-2026?utm_source=github&utm_medium=referral)
231
+ Check out our latest release [v2.7.3 (9 July 2026)](https://www.react-pdf-kit.dev/docs/introduction/changelog/#v273-9-July-2026)
219
232
 
220
233
  # :raising_hand: Need Help?
221
234
 
@@ -223,17 +236,18 @@ We are more than happy to help you. If you have any questions, run into any erro
223
236
 
224
237
  # :page_facing_up: License
225
238
 
226
- React PDF Kit is distributed under our proprietary license. Please refer to our [License page](https://www.react-pdf-kit.dev/license-agreement?utm_source=github&utm_medium=referral) file for more details.
239
+ React PDF Kit is distributed under our proprietary license. Please refer to our [License page](https://www.react-pdf-kit.dev/license-agreement) file for more details.
227
240
 
228
- If you would like to use React PDF commercially, please purchase a license from [our website][reactpdf] or reach out to us directly at [https://www.react-pdf-kit.dev/contact-us](https://www.react-pdf-kit.dev/contact-us?utm_source=github&utm_medium=referral).
241
+ If you would like to use React PDF commercially, please purchase a license from [our website][reactpdf] or reach out to us directly at [https://www.react-pdf-kit.dev/contact-us](https://www.react-pdf-kit.dev/contact-us).
229
242
 
230
243
  # Acknowledgement
231
244
 
232
245
  - [pdf.js](https://github.com/mozilla/pdf.js)
246
+ - [node-forge](https://github.com/digitalbazaar/forge)
233
247
  - [Img Shields](https://shields.io)
234
248
  - [React.js](https://reactjs.org/)
235
249
 
236
- [reactpdf]: https://www.react-pdf-kit.dev/?utm_source=github&utm_medium=referral
237
- [reactpdf-docs]: https://docs.react-pdf-kit.dev/?utm_source=github&utm_medium=referral
250
+ [reactpdf]: https://www.react-pdf-kit.dev/
251
+ [reactpdf-docs]: https://www.react-pdf-kit.dev/docs/
238
252
  [npm]: https://www.npmjs.com/package/@react-pdf-kit/viewer
239
253
  [twitter]: https://www.x.com/ReactPDF
@@ -2,7 +2,7 @@ import { AnnotationSubType as e } from "./utils/types.js";
2
2
  import { useDocumentContext as t } from "./contexts/RPDocumentContext.js";
3
3
  import { useInitialStateContext as n } from "./contexts/InitialStateContext.js";
4
4
  import { useScrollModeContext as r } from "./contexts/ScrollModeContext.js";
5
- import { r as i } from "./PaginationContext-Cwf8sCpK.js";
5
+ import { r as i } from "./PaginationContext-DIzsZhFd.js";
6
6
  import { usePrintContext as a } from "./contexts/PrintContext.js";
7
7
  import { SimpleLinkService as o } from "./utils/link_service.js";
8
8
  import { annotationEventsHandler as s, bindLayerEvents as c, enhanceLinkAccessibility as l, fixTabIndexAccessibility as u, handleAnnotationWidget as d, insertDateText as f, unbindLayerEvents as p } from "./utils/annotations.js";
@@ -11,7 +11,7 @@ import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState a
11
11
  import { AnnotationLayer as b } from "pdfjs-dist";
12
12
  import { jsx as x } from "react/jsx-runtime";
13
13
  import './assets/AnnotationLayer.css';//#region lib/components/page/AnnotationLayer.module.css
14
- var S = { "rp-annotation-layer": "_rp-annotation-layer_rwxfx_1" }, C = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/", w = (w) => {
14
+ var S = { "rp-annotation-layer": "_rp-annotation-layer_foiun_1" }, C = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/", w = (w) => {
15
15
  let { pageNumber: T } = w, E = v(null), { pages: D, pdf: O } = t(), { interactiveForm: k } = n(), A = v(), [j, M] = y(), { goToPage: N } = i(), { scrollMode: P } = r(), { print: F } = a(), { download: I } = m(), L = v(null), R = _(() => D.get(T), [D, T]), z = _(() => R?.page.getViewport(), [R]);
16
16
  g(() => {
17
17
  A.current &&= (A.current.div.replaceChildren(), void 0);
@@ -0,0 +1,111 @@
1
+ import { useDocumentContext as e } from "./contexts/RPDocumentContext.js";
2
+ import { useInitialStateContext as t } from "./contexts/InitialStateContext.js";
3
+ import { useZoomContext as n } from "./contexts/ZoomContext.js";
4
+ import { usePagesRotateContext as r } from "./contexts/PagesRotateContext.js";
5
+ import { useRenderQueue as i } from "./contexts/RenderQueueProvider.js";
6
+ import { useRenderedPagesCache as a } from "./contexts/RenderedPagesCache.js";
7
+ import { useCallback as o, useEffect as s, useRef as c } from "react";
8
+ import { jsx as l } from "react/jsx-runtime";
9
+ import './assets/CanvasLayer.css';//#region lib/components/page/RPPage.module.css
10
+ var u = {
11
+ "rp-page-wrapper": "_rp-page-wrapper_1iuev_1",
12
+ "rp-page": "_rp-page_1iuev_1",
13
+ "rp-canvas-layer": "_rp-canvas-layer_1iuev_17",
14
+ "rp-loader-wrapper": "_rp-loader-wrapper_1iuev_40"
15
+ }, d = (d) => {
16
+ let { pageNumber: f, onLoaded: p, onLoading: m } = d, h = c(null), g = c(null), _ = c(null), { pages: v } = e(), { pageRotate: y } = r(), { currentZoom: b, targetZoom: x, isZooming: S } = n(), { interactiveForm: C } = t(), { hasRenderedPage: w, markRenderedPage: T } = a(), E = i(), D = c(`page-${f}`), O = c(0), k = c(""), A = c(null), j = c(0), M = c(!1), N = o((e, t = !1) => {
17
+ e && (e.width = 0, e.height = 0, t && e.parentNode && e.parentNode.removeChild(e));
18
+ }, []), P = o((e = g.current) => {
19
+ if (!e) return;
20
+ let t = j.current, n = t ? (x || b || t || 1) / t : 1;
21
+ e.style.setProperty("--rp-canvas-scale-ratio", String(n));
22
+ }, [b, x]), F = o(() => {
23
+ let e = document.createElement("canvas");
24
+ return e.dataset.rp = `page-${f}-canvas`, e.style.opacity = "0", e.style.position = "absolute", e.style.inset = "0", P(e), e;
25
+ }, [f, P]), I = o(() => {
26
+ E.removeQueue(D.current), A.current &&= (A.current.cancel(), null);
27
+ }, [E]), L = o(() => {
28
+ _.current && !_.current.parentNode && (N(_.current), _.current = null);
29
+ }, [N]), R = o((e) => {
30
+ if (!M.current) return N(e), !1;
31
+ let t = h.current;
32
+ if (!t) return N(e), !1;
33
+ let n = g.current;
34
+ return n?.parentNode ? n.replaceWith(e) : t.appendChild(e), e.style.opacity = "1", g.current = e, N(n), !0;
35
+ }, [N]);
36
+ return s(() => (M.current = !0, () => {
37
+ M.current = !1, I(), N(_.current), N(g.current), _.current = null, g.current = null;
38
+ }), [I, N]), s(() => {
39
+ P();
40
+ }, [P]), s(() => {
41
+ D.current = `page-${f}`, k.current = "", j.current = 0, N(_.current, !0), N(g.current, !0), _.current = null, g.current = null;
42
+ }, [N, f]), s(() => {
43
+ S && (I(), L());
44
+ }, [
45
+ I,
46
+ L,
47
+ S
48
+ ]), s(() => {
49
+ if (!v || b === 0 || S) return;
50
+ let e = v.get(f), t = h.current;
51
+ if (!e || !t) return;
52
+ let n = y[f] ?? e.defaultRotation ?? 0, r = `${f}:${b}:${n}:${C ? "forms" : "static"}`;
53
+ if (k.current === r) return;
54
+ let i = g.current, a = !!i && i.width > 0 && i.height > 0, o = O.current + 1;
55
+ O.current = o, I(), L(), m && !a && m({
56
+ renderKey: r,
57
+ hasRenderedBefore: w(r)
58
+ });
59
+ let s = F();
60
+ return _.current = s, E.enqueue(D.current, {
61
+ page: e.page,
62
+ canvasElem: s,
63
+ options: {
64
+ scale: b,
65
+ rotate: n,
66
+ renderForms: !0,
67
+ interactiveForm: C
68
+ },
69
+ onLoaded: () => {
70
+ if (O.current !== o || _.current !== s) {
71
+ N(s);
72
+ return;
73
+ }
74
+ if (j.current = b, P(s), !R(s)) {
75
+ _.current = null;
76
+ return;
77
+ }
78
+ _.current = null, k.current = r, T(r), A.current = null, p?.();
79
+ },
80
+ onRenderTask: (e) => {
81
+ O.current === o && (A.current = e);
82
+ }
83
+ }, 3), () => {
84
+ I(), _.current === s && (N(s), _.current = null);
85
+ };
86
+ }, [
87
+ I,
88
+ N,
89
+ L,
90
+ F,
91
+ b,
92
+ w,
93
+ C,
94
+ S,
95
+ T,
96
+ p,
97
+ m,
98
+ f,
99
+ y,
100
+ v,
101
+ E,
102
+ R,
103
+ P
104
+ ]), /* @__PURE__ */ l("div", {
105
+ className: u["rp-canvas-layer"],
106
+ "data-rp": `page-${f}-canvasLayer`,
107
+ ref: h
108
+ });
109
+ };
110
+ //#endregion
111
+ export { u as n, d as t };
@@ -3,13 +3,13 @@ import { usePrintContext as t } from "./contexts/PrintContext.js";
3
3
  import { t as n } from "./clsx-B7LyVm5O.js";
4
4
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
5
  import './assets/LoadingIndicator.css';var a = {
6
- "rp-loading-overlay": "_rp-loading-overlay_wazy2_1",
7
- "rp-loading-modal": "_rp-loading-modal_wazy2_14",
8
- "rp-loading-title": "_rp-loading-title_wazy2_27",
9
- "rp-loading-progress-bar": "_rp-loading-progress-bar_wazy2_35",
10
- "rp-loading-progress": "_rp-loading-progress_wazy2_35",
11
- "rp-loading-cancel-button": "_rp-loading-cancel-button_wazy2_55",
12
- loading: "_loading_wazy2_1"
6
+ "rp-loading-overlay": "_rp-loading-overlay_8gxoj_1",
7
+ "rp-loading-modal": "_rp-loading-modal_8gxoj_14",
8
+ "rp-loading-title": "_rp-loading-title_8gxoj_27",
9
+ "rp-loading-progress-bar": "_rp-loading-progress-bar_8gxoj_35",
10
+ "rp-loading-progress": "_rp-loading-progress_8gxoj_35",
11
+ "rp-loading-cancel-button": "_rp-loading-cancel-button_8gxoj_55",
12
+ loading: "_loading_8gxoj_1"
13
13
  }, o = ({ percentage: o }) => {
14
14
  let { cancel: s } = t(), { localeMessages: c } = e();
15
15
  return o < 1 ? null : /* @__PURE__ */ r("div", {
@@ -0,0 +1,31 @@
1
+ import { t as e } from "./clsx-B7LyVm5O.js";
2
+ import { r as t } from "./dist-CKteKPPA.js";
3
+ import { jsx as n } from "react/jsx-runtime";
4
+ import './assets/MenuItem.css';//#region lib/components/layout/toolbar/MenuItem.module.css
5
+ var r = { "rp-menu-item": "_rp-menu-item_1q6of_1" }, i = (i) => {
6
+ let { children: a, className: o, disabled: s = !1, onClick: c, onSelect: l, ...u } = i, d = (e) => {
7
+ if (s) {
8
+ e?.preventDefault(), e?.stopPropagation();
9
+ return;
10
+ }
11
+ c?.(e);
12
+ }, f = (e) => {
13
+ if (s) {
14
+ e?.preventDefault(), e?.stopPropagation();
15
+ return;
16
+ }
17
+ l?.(e);
18
+ };
19
+ return /* @__PURE__ */ n(t, {
20
+ ...u,
21
+ tabIndex: 0,
22
+ className: e(r["rp-menu-item"], o),
23
+ disabled: s,
24
+ "aria-disabled": s,
25
+ onClick: d,
26
+ onSelect: f,
27
+ children: a
28
+ });
29
+ };
30
+ //#endregion
31
+ export { i as t };
@@ -0,0 +1,194 @@
1
+ import { ScrollMode as e, ViewMode as t } from "./utils/types.js";
2
+ import { appConsole as n } from "./utils/appConsole.js";
3
+ import { useDocumentContext as r } from "./contexts/RPDocumentContext.js";
4
+ import { useInitialStateContext as i } from "./contexts/InitialStateContext.js";
5
+ import { useScrollModeContext as a } from "./contexts/ScrollModeContext.js";
6
+ import { useViewModeContext as o } from "./contexts/ViewModeContext.js";
7
+ import { useVirtualScrollContext as s } from "./contexts/VirtualScrollContext.js";
8
+ import { useLayoutContainer as c } from "./contexts/LayoutContainerContext.js";
9
+ import { useGlobalCurrentPage as l } from "./contexts/GlobalCurrentPage.js";
10
+ import { useDebounce as u } from "./utils/hooks/useDebounce.js";
11
+ import { useDimensionPagesContext as d } from "./contexts/DimensionPagesContext.js";
12
+ import { useSmoothScrollContext as f } from "./contexts/SmoothScrollContext.js";
13
+ import { buildDocumentLayout as p, getScrollTargetForPage as m } from "./utils/documentLayout.js";
14
+ import { createContext as h, useCallback as g, useContext as _, useEffect as v, useRef as y, useState as b } from "react";
15
+ import { jsx as x } from "react/jsx-runtime";
16
+ //#region lib/utils/hooks/useScrollToPage.ts
17
+ var S = () => {
18
+ let { viewMode: t } = o(), { scrollMode: n } = a(), { virtualScrollableElementRef: r, pageScrollElementRef: i } = s(), { setFocusedPage: c } = T(), { widths: l, heights: u } = d(), h = y(n), _ = y(t), b = y({
19
+ widths: l,
20
+ heights: u
21
+ }), { targetScrollPage: x, scrollBehavior: S } = f(), C = y(null), w = y();
22
+ h.current = n, _.current = t, b.current = {
23
+ widths: l,
24
+ heights: u
25
+ };
26
+ let E = g(() => {
27
+ let t = h.current === e.PAGE_SCROLLING;
28
+ return (t ? i : r) ?? (t ? r : i);
29
+ }, [i, r]), D = g((t, n = S) => {
30
+ c(t), x.current = t, clearTimeout(w.current), w.current = setTimeout(() => {
31
+ x.current === t && (x.current = void 0);
32
+ }, 3e3);
33
+ let r = E();
34
+ if (!r) {
35
+ C.current = {
36
+ page: t,
37
+ behavior: n
38
+ };
39
+ return;
40
+ }
41
+ let { widths: i, heights: a } = b.current, o = m(p({
42
+ pageDimensions: {
43
+ widths: i,
44
+ heights: a
45
+ },
46
+ viewportWidth: r.clientWidth,
47
+ viewportHeight: r.clientHeight,
48
+ scrollMode: h.current,
49
+ viewMode: _.current,
50
+ focusedPage: t
51
+ }), t);
52
+ if (!o) {
53
+ C.current = {
54
+ page: t,
55
+ behavior: n
56
+ };
57
+ return;
58
+ }
59
+ C.current = null;
60
+ let s = () => {
61
+ r.scrollTo({
62
+ left: Math.floor(o.left),
63
+ top: Math.floor(o.top),
64
+ behavior: n
65
+ });
66
+ };
67
+ if (h.current === e.PAGE_SCROLLING) {
68
+ requestAnimationFrame(s);
69
+ return;
70
+ }
71
+ s();
72
+ }, [
73
+ E,
74
+ S,
75
+ c,
76
+ x
77
+ ]);
78
+ return v(() => () => {
79
+ clearTimeout(w.current);
80
+ }, []), v(() => {
81
+ if (!E() || !C.current) return;
82
+ let { page: e, behavior: t } = C.current;
83
+ C.current = null, D(e, t);
84
+ }, [E, D]), { scrollToPage: D };
85
+ }, C = (n = 1) => {
86
+ let [r, i] = b(n), [s, l] = b(0), { scrollToPage: f } = S(), p = y(n), { viewMode: m } = o(), { scrollMode: h } = a(), { widths: _ } = d(), { pagesRef: v } = c(), x = u(r, 100), C = g((e) => {
87
+ if (!/^[0-9]*$/g.test(e.toString()) || !e) return {
88
+ success: !1,
89
+ currentPage: p.current
90
+ };
91
+ let t = +e;
92
+ return t <= 0 || t > s ? {
93
+ success: !1,
94
+ currentPage: p.current
95
+ } : (i(t), p.current = t, {
96
+ success: !0,
97
+ currentPage: +e
98
+ });
99
+ }, [s]), w = g(C, [C]), T = g((e) => {
100
+ i(e), p.current = e;
101
+ }, []), E = g((e, t) => {
102
+ let n = C(e);
103
+ return n.success && f(n.currentPage, t), n;
104
+ }, [C, f]), D = g((e) => {
105
+ let n = e % 2 == 1;
106
+ if (!v || n) return !1;
107
+ let r = n ? _[e] : _[e - 1], i = n ? _[e + 1] : _[e];
108
+ return m === t.DUAL_PAGE && r + i < v.clientWidth;
109
+ }, [
110
+ m,
111
+ _,
112
+ v,
113
+ s
114
+ ]), O = g((n) => m === t.DUAL_PAGE && h === e.PAGE_SCROLLING ? n >= s - 1 : n >= s, [
115
+ s,
116
+ m,
117
+ h
118
+ ]), k = g(() => {
119
+ let e = p.current, t = e - 1;
120
+ D(t) && (t = e - 2), E(t);
121
+ }, [E, D]);
122
+ return {
123
+ focusedPage: x,
124
+ totalPages: s,
125
+ setFocusedPage: w,
126
+ resetPage: T,
127
+ setTotalPages: l,
128
+ nextPage: g(() => {
129
+ let e = p.current;
130
+ if (O(e)) return;
131
+ let t = e + 1;
132
+ D(t) && (t = e + 2), E(t);
133
+ }, [
134
+ E,
135
+ D,
136
+ O
137
+ ]),
138
+ prevPage: k,
139
+ goToPage: E
140
+ };
141
+ }, w = h({
142
+ focusedPage: 0,
143
+ setFocusedPage: (e) => {},
144
+ goToPage: (e, t) => ({
145
+ success: !!e,
146
+ currentPage: +e
147
+ }),
148
+ totalPages: 0,
149
+ setTotalPages: (e) => {},
150
+ prevPage: () => {},
151
+ nextPage: () => {}
152
+ }), T = () => {
153
+ let e = _(w);
154
+ return e?.focusedPage === void 0 && n.error("Please use this hooks inside children component of RPProvider"), e;
155
+ }, E = ({ children: e }) => {
156
+ let { pdf: t, pages: n } = r(), { setCurrentPage: a } = l(), { initialPage: o = 1 } = i(), { focusedPage: s, totalPages: c, setFocusedPage: u, resetPage: d, setTotalPages: f, goToPage: p, nextPage: m, prevPage: h } = C(o), g = y(!0);
157
+ return v(() => {
158
+ if (!t) {
159
+ g.current || (f(0), d(1));
160
+ return;
161
+ }
162
+ if (!t.numPages) return;
163
+ f(t.numPages);
164
+ let e = g.current ? o : 1;
165
+ d(Math.min(Math.max(e, 1), t.numPages)), g.current = !1;
166
+ }, [
167
+ t,
168
+ f,
169
+ d
170
+ ]), v(() => {
171
+ !t || !n.size || (f(n.size), s > n.size && d(n.size));
172
+ }, [
173
+ t,
174
+ n,
175
+ s,
176
+ f,
177
+ d
178
+ ]), v(() => {
179
+ a(s);
180
+ }, [s, a]), /* @__PURE__ */ x(w.Provider, {
181
+ value: {
182
+ focusedPage: s,
183
+ totalPages: c,
184
+ setFocusedPage: u,
185
+ setTotalPages: f,
186
+ nextPage: m,
187
+ prevPage: h,
188
+ goToPage: p
189
+ },
190
+ children: e
191
+ });
192
+ };
193
+ //#endregion
194
+ export { S as a, C as i, E as n, T as r, w as t };
@@ -3,18 +3,18 @@ import { useLocalizationContext as t } from "./contexts/LocalizationContext.js";
3
3
  import { t as n } from "./clsx-B7LyVm5O.js";
4
4
  import { useState as r } from "react";
5
5
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
- import './assets/PasswordModal.css';//#region lib/components/ui/PasswordModal.module.css
6
+ import './assets/PasswordModal.css';//#region lib/components/ui/passwordModal.module.css
7
7
  var o = {
8
- "rp-password-overlay": "_rp-password-overlay_9cdbk_1",
9
- "rp-password-modal": "_rp-password-modal_9cdbk_13",
10
- "rp-password-title": "_rp-password-title_9cdbk_27",
11
- "rp-password-content": "_rp-password-content_9cdbk_35",
12
- "rp-password-form": "_rp-password-form_9cdbk_41",
13
- "rp-password-label": "_rp-password-label_9cdbk_45",
14
- "rp-password-input": "_rp-password-input_9cdbk_57",
15
- "rp-password-input-invalid": "_rp-password-input-invalid_9cdbk_74",
16
- "rp-password-message-invalid": "_rp-password-message-invalid_9cdbk_78",
17
- "rp-password-submit-button": "_rp-password-submit-button_9cdbk_84"
8
+ "rp-password-overlay": "_rp-password-overlay_1xibg_1",
9
+ "rp-password-modal": "_rp-password-modal_1xibg_13",
10
+ "rp-password-title": "_rp-password-title_1xibg_27",
11
+ "rp-password-content": "_rp-password-content_1xibg_35",
12
+ "rp-password-form": "_rp-password-form_1xibg_41",
13
+ "rp-password-label": "_rp-password-label_1xibg_45",
14
+ "rp-password-input": "_rp-password-input_1xibg_57",
15
+ "rp-password-input-invalid": "_rp-password-input-invalid_1xibg_74",
16
+ "rp-password-message-invalid": "_rp-password-message-invalid_1xibg_78",
17
+ "rp-password-submit-button": "_rp-password-submit-button_1xibg_84"
18
18
  }, s = () => {
19
19
  let [s, c] = r(""), { localeMessages: l } = t(), { setPassword: u, setPasswordError: d, invalidPassword: f } = e(), p = (e) => {
20
20
  c(e.target.value), f && d(void 0);
@@ -0,0 +1,14 @@
1
+ import './assets/RPLayout.css';//#region lib/components/layout/RPLayout.module.css
2
+ var e = {
3
+ "rp-layout": "_rp-layout_1h20a_1",
4
+ "rp-layout-wrapper": "_rp-layout-wrapper_1h20a_5",
5
+ "rp-content": "_rp-content_1h20a_11",
6
+ "rp-sidebar": "_rp-sidebar_1h20a_18",
7
+ "rp-pages": "_rp-pages_1h20a_23",
8
+ "rp-container": "_rp-container_1h20a_29",
9
+ "rp-loader": "_rp-loader_1h20a_33",
10
+ "rp-theme-variables": "_rp-theme-variables_1h20a_37",
11
+ "rp-dark-mode": "_rp-dark-mode_1h20a_158"
12
+ };
13
+ //#endregion
14
+ export { e as t };