@pdf-viewer/react 1.0.0-rc.1 → 1.0.0-rc.3

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 (58) hide show
  1. package/README.md +203 -2
  2. package/dist/{RPDefaultLayout-e9ef78b9.js → RPDefaultLayout-07939e60.js} +13 -13
  3. package/dist/assets/RPDropFileZone.css +1 -1
  4. package/dist/components/RPConfig.js +340 -318
  5. package/dist/components/RPController.js +1 -1
  6. package/dist/components/RPDropFileZone.js +30 -27
  7. package/dist/components/RPPages.js +1 -1
  8. package/dist/components/RPProvider.js +1 -1
  9. package/dist/components/layout/RPDefaultLayout.js +1 -1
  10. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  11. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  12. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  13. package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
  14. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  15. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  16. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  17. package/dist/components/layout/toolbar/MostPageTool.js +2 -2
  18. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  19. package/dist/components/layout/toolbar/Paginate.js +1 -1
  20. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  21. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  22. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  23. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  24. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  25. package/dist/components/layout/toolbar/SearchTool.js +1 -1
  26. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  27. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  28. package/dist/components/layout/toolbar/ZoomTool.js +2 -2
  29. package/dist/components/page/AnnotationLayer.js +1 -1
  30. package/dist/components/page/CanvasLayer.js +1 -1
  31. package/dist/components/page/DualPage.js +1 -1
  32. package/dist/components/page/RPPage.js +1 -1
  33. package/dist/components/page/SinglePage.js +1 -1
  34. package/dist/components/page/TextLayer.js +1 -1
  35. package/dist/components/ui/Checkbox.js +92 -252
  36. package/dist/components/ui/DropDown.js +1 -1
  37. package/dist/components/ui/LoadingIndicator.js +1 -1
  38. package/dist/components/ui/RPTooltip.js +224 -961
  39. package/dist/contexts/PaginationContext.js +1 -1
  40. package/dist/contexts/PrintContext.js +1 -1
  41. package/dist/contexts/SearchContext.js +1 -1
  42. package/dist/contexts/ThumbnailsContext.js +1 -1
  43. package/dist/index-1db49c1a.js +1664 -0
  44. package/dist/index-3dff3fa8.js +307 -0
  45. package/dist/index-4f17fe4d.js +1657 -0
  46. package/dist/main.js +1 -1
  47. package/dist/utils/hooks/useFileDownload.js +1 -1
  48. package/dist/utils/hooks/useLicense.js +1 -1
  49. package/dist/utils/hooks/usePaginate.js +1 -1
  50. package/dist/utils/hooks/usePrint.js +1 -1
  51. package/dist/utils/hooks/useScrollToPage.js +1 -1
  52. package/dist/utils/hooks/useSearch.js +1 -1
  53. package/dist/utils/hooks/useThumbnail.js +1 -1
  54. package/dist/utils/hooks/useVirtualReactWindow.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/floating-ui.react-dom-e6d5fe8f.js +0 -1327
  57. package/dist/index-316854c1.js +0 -2299
  58. package/dist/index-71898eb9.js +0 -139
package/README.md CHANGED
@@ -1,3 +1,204 @@
1
- # React PDF Viewer
1
+ <div align="center">
2
+ <a href="https://www.react-pdf.dev/" target="_blank">
3
+ <picture>
4
+ <source srcset="https://raw.githubusercontent.com/pdf-viewer-react/react-pdf/2308e7d88cde64bf343f1509150ebf6c91a15664/assets/img/react-pdf_cover.webp" width="100%">
5
+ <img alt="React PDF" src="https://raw.githubusercontent.com/pdf-viewer-react/react-pdf/2308e7d88cde64bf343f1509150ebf6c91a15664/assets/img/react-pdf_cover.webp width="100%">
6
+ </picture>
7
+ </a>
8
+ </div>
2
9
 
3
- render pdf on client side using pdfjs
10
+ <br/>
11
+ <div align="center">
12
+ Works seamlessly on your React.js websites. Fast, Customizable and Web Responsive PDF viewer. Save you weeks of development time.
13
+ </div>
14
+ <br/>
15
+
16
+ <div align="center">
17
+
18
+ [React PDF Home][reactpdf] - [License](#page_facing_up-license) - [Documentation][reactpdf-docs]
19
+
20
+ [![NPM Version](https://img.shields.io/npm/v/%40pdf-viewer%2Freact)][npm]
21
+ [![Twitter](https://img.shields.io/twitter/follow/ReactPDF?label=ReactPDF&style=social)][twitter]
22
+
23
+ </div>
24
+
25
+ # :star: Why React PDF
26
+
27
+ - **Save Weeks of Development Time**: React PDF simplifies PDF integration with ready-to-use tools, minimizing the need for custom development and saving you valuable time.
28
+ - **Tailored for React.js**: React PDF is native to React.js, ensuring smooth integration into your projects.
29
+ - **Customizability at Its Core**: Built with flexibility in mind, allowing you to match your application’s unique style and functionality.
30
+ - **High-Performance & Rapid Rendering**: Optimized for rendering large PDFs efficiently, React PDF delivers lightning-fast load times with features like virtual scrolling.
31
+ - **Accessibility**: Designed with inclusivity in mind, React PDF supports ARIA attributes, catering to diverse user bases.
32
+ - **Modern Browser Compatibility**: Works seamlessly across modern browsers, eliminating compatibility headaches.
33
+ - **Active Development & Support**: With regular updates and a responsive support team, React PDF evolves to meet developer needs.
34
+
35
+ # 📜 Background
36
+
37
+ 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!
38
+
39
+ # :sparkles: Features
40
+
41
+ - 🎯 **Interactive & Immersive Viewing Experience** with features like rotation, zoom, and keyboard navigation.
42
+ - 📱 **Responsive Across All Devices** for a consistent experience on desktops, tablets and mobile devices.
43
+ - 🎨 **Customizable UI and Styling** to tailor the viewer’s appearance to match your website’s theme.
44
+ - 🧭 **Advanced Navigation Options** to browse documents easily with table of contents, hyperlinks, and a powerful search tool.
45
+ - ⚡ **High-Performance Rendering** to load large PDF documents quickly and handle complex elements like vector graphics with ease.
46
+ - 🔧 **Programmatic Control with Hooks and Props**, allowing you to interact with the viewer programmatically.
47
+ - 📂 **Document Management Tools**, including features like downloading and printing.
48
+ - 👁️ **Accessibility Support** to built-in support for ARIA attributes and tooltips, catering to diverse user bases.
49
+
50
+ For the full feature set, visit [React PDF Features](https://www.react-pdf.dev/features?utm_source=github).
51
+
52
+ # :zap: Quick Start Guide
53
+
54
+ Here’s how to get started with React PDF in your React.js project:
55
+
56
+ ## 1. Check Prerequsities
57
+
58
+ Here are the basic system requirements to run the React PDF component:
59
+
60
+ - React version: >= 18.0
61
+
62
+ If you are working with a React framework such as Next and Gatsby, React PDF can run smoothly as long as you are using React 18 and above.
63
+
64
+ React PDF viewer also works well with other React.js UI libraries such as MUI, Ant Design and Chakra UI.
65
+
66
+ Although React PDF can run on most JavaScript module bundlers, it is more vigorously tested on Vite and Webpack.
67
+
68
+ _Remark: <br/>- If using TypeScript, it requires >= TypeScript 4.6._
69
+
70
+ ### Browser support
71
+
72
+ | Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
73
+ | ------ | ------- | ---- | ------ | ---------- | -------------- |
74
+ | 115+ | 115+ | 115+ | 16.5+ | 16.5+ | 126+ |
75
+
76
+ ## 2. Install the Package
77
+
78
+ There are a few ways you can install React PDF, namely `bun`, `npm`, `pnpm` or `yarn`.
79
+
80
+ ### Using bun:
81
+
82
+ ```bash
83
+ bun add @pdf-viewer/react
84
+ ```
85
+
86
+ ##### Caching of previous Worker version with `bun`
87
+
88
+ To clear cache, try running `bun pm cache rm` to remove cache in the global cache directory. If the error remains, try executing the following steps:
89
+
90
+ ```shell
91
+ rm bun.lockb
92
+ rm -R node_modules
93
+ ```
94
+
95
+ ### Using npm:
96
+
97
+ ```bash
98
+ npm install @pdf-viewer/react
99
+ ```
100
+
101
+ ### Using yarn:
102
+
103
+ ```bash
104
+ yarn add @pdf-viewer/react
105
+ ```
106
+
107
+ ### Using pnpm:
108
+
109
+ ```bash
110
+ pnpm add @pdf-viewer/react
111
+ ```
112
+
113
+ For more information on how to use different package managers, please visit our [installation guide](https://docs.react-pdf.dev/introduction/getting-started.html#installation?utm_source=github).
114
+
115
+ ## 3. Import and Use the Component
116
+
117
+ 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.
118
+
119
+ ```tsx
120
+ <RPConfig>
121
+ {' '}
122
+ {/* Configuration license and pdfjs-dist worker */}
123
+ <RPProvider>
124
+ {' '}
125
+ {/* Viewer context provider */}
126
+ <RPTheme>
127
+ {' '}
128
+ {/* Theme customization (optional) */}
129
+ <RPDefaultLayout>
130
+ {' '}
131
+ {/* Default layout container */}
132
+ <RPPages /> {/* PDF pages renderer */}
133
+ </RPDefaultLayout>
134
+ </RPTheme>
135
+ </RPProvider>
136
+ </RPConfig>
137
+ ```
138
+
139
+ _Remark: For more information on each component, please refer to [Component](https://docs.react-pdf.dev/components/overview?utm_source=github)._
140
+
141
+ ### Basic Usage
142
+
143
+ The most basic usage of React PDF viewer needs four components, namely: `RPConfig`, `RPProvider`, `RPDefaultLayout`, and `RPPages`.
144
+
145
+ Here's how to implement a basic PDF viewer in a React application:
146
+
147
+ ```jsx
148
+ import { RPProvider, RPDefaultLayout, RPPages, RPConfig } from '@pdf-viewer/react'
149
+
150
+ const App = () => {
151
+ return (
152
+ <RPConfig>
153
+ <RPProvider src="https://cdn.codewithmosh.com/image/upload/v1721763853/guides/web-roadmap.pdf">
154
+ <RPDefaultLayout style={{ height: '660px' }}>
155
+ <RPPages />
156
+ </RPDefaultLayout>
157
+ </RPProvider>
158
+ </RPConfig>
159
+ )
160
+ }
161
+ export default App
162
+ ```
163
+
164
+ The PDF viewer will automatically adjust to fit its container's dimensions. You can control the size by setting the `style` prop on `RPDefaultLayout`. For more information on using React PDF, visit our [basic usage guide](https://docs.react-pdf.dev/introduction/basic-usage?utm_source=github)
165
+
166
+ You may also check out our [Starter Toolkit](#pushpin-starter-toolkit) for examples to get you started.
167
+
168
+ ### 4. Customize with Hooks and Props
169
+
170
+ To enhance React PDF further, we offer built-in hooks and props that let you fine-tune functionality, adjust appearance, and integrate custom behaviors into your application.
171
+
172
+ For detailed usage, refer to our [Documentation][reactpdf-docs].
173
+
174
+ # :pushpin: Starter Toolkit
175
+
176
+ Here are some sample projects to get started on React PDF quickly:
177
+
178
+ 1. [React (webpack) - JavaScript](https://github.com/pdf-viewer-react/starter-rp-react-js-webpack)
179
+ 2. [React (webpack) - TypeScript](https://github.com/reactpdf/pdf-viewer-react/starter-rp-react-ts-webpack)
180
+ 3. [React (vite) - JavaScript](https://github.com/pdf-viewer-react/starter-rp-react-js-vite)
181
+ 4. [React (vite) - TypeScript](https://github.com/pdf-viewer-react/starter-rp-react-ts-vite)
182
+ 5. [Next - JavaScript](https://github.com/pdf-viewer-react/starter-rp-next-js)
183
+ 6. [Next - TypeScript](https://github.com/pdf-viewer-react/starter-rp-next-ts)
184
+
185
+ # :raising_hand: Need Help?
186
+
187
+ We are more than happy to help you. If you have any questions, run into any errors or face any problems, please feel free to create an issue in [Issues](../../issues) or PM us directly in [Twitter][twitter]. Anything related to React PDF is on the table!
188
+
189
+ # :page_facing_up: License
190
+
191
+ React PDF is distributed under our proprietary license. Please refer to our [License page](https://www.react-pdf.dev/license-agreement?utm_source=github) file for more details.
192
+
193
+ If you would like to use React PDF commercially, please purchase a license from [our website][reactpdf] or reach out to us directly at [david@react-pdf.dev](mailto:david@react-pdf.dev).
194
+
195
+ # Acknowledgement
196
+
197
+ - [pdf.js](https://github.com/mozilla/pdf.js)
198
+ - [Img Shields](https://shields.io)
199
+ - [React.js](https://reactjs.org/)
200
+
201
+ [reactpdf]: https://www.react-pdf.dev
202
+ [reactpdf-docs]: https://docs.react-pdf.dev
203
+ [npm]: https://www.npmjs.com/package/@pdf-viewer/react
204
+ [twitter]: https://www.x.com/ReactPDF
@@ -54,9 +54,9 @@ import { FileUploadTool as Yt } from "./components/layout/toolbar/FileUploadTool
54
54
  import { DarkModeTool as mr } from "./components/layout/toolbar/DarkModeTool.js";
55
55
  import { ThreeDotIcon as fr } from "./components/icons/ThreeDotIcon.js";
56
56
  import { UIDropDown as ft } from "./components/ui/DropDown.js";
57
- import { u as gt, a as Ne, c as xe, b as vt, d as gr, e as vr, h as _r, f as wr, F as br, D as Cr, g as Pr, G as Fe } from "./index-316854c1.js";
58
- import { c as Tr, e as Sr, b as yr } from "./index-71898eb9.js";
59
- import { e as Ke } from "./floating-ui.react-dom-e6d5fe8f.js";
57
+ import { c as gr, a as gt, P as Ne, b as xe, d as vt, i as vr, k as _r, u as wr } from "./index-3dff3fa8.js";
58
+ import { D as br, u as Ke } from "./index-4f17fe4d.js";
59
+ import { a as Cr, h as Pr, u as Tr, F as Sr, b as yr, G as Fe } from "./index-1db49c1a.js";
60
60
  import { CloseIcon as Qt } from "./components/icons/CloseIcon.js";
61
61
  import { PropertyItem as Ir } from "./components/layout/toolbar/PropertyItem.js";
62
62
  import { useOtherToolContext as xr, OtherToolProvider as Rr } from "./contexts/OtherToolContext.js";
@@ -1042,7 +1042,7 @@ function Ot(e, t) {
1042
1042
  var n = {};
1043
1043
  for (var r in e)
1044
1044
  if ({}.hasOwnProperty.call(e, r)) {
1045
- if (t.includes(r))
1045
+ if (t.indexOf(r) !== -1)
1046
1046
  continue;
1047
1047
  n[r] = e[r];
1048
1048
  }
@@ -1922,7 +1922,7 @@ const bo = ({ widths: e, heights: t }) => {
1922
1922
  !p && /* @__PURE__ */ s(ee, { content: "Next page", children: /* @__PURE__ */ s(X, { onClick: r, disabled: e === t, children: /* @__PURE__ */ s(So, {}) }) })
1923
1923
  ] }) : null;
1924
1924
  };
1925
- var Ct = "Dialog", [gn, Zs] = Tr(Ct), [Io, ae] = gn(Ct), vn = (e) => {
1925
+ var Ct = "Dialog", [gn, Zs] = gr(Ct), [Io, ae] = gn(Ct), vn = (e) => {
1926
1926
  const {
1927
1927
  __scopeDialog: t,
1928
1928
  children: n,
@@ -1930,7 +1930,7 @@ var Ct = "Dialog", [gn, Zs] = Tr(Ct), [Io, ae] = gn(Ct), vn = (e) => {
1930
1930
  defaultOpen: o,
1931
1931
  onOpenChange: a,
1932
1932
  modal: c = !0
1933
- } = e, i = V.useRef(null), l = V.useRef(null), [p = !1, h] = yr({
1933
+ } = e, i = V.useRef(null), l = V.useRef(null), [p = !1, h] = wr({
1934
1934
  prop: r,
1935
1935
  defaultProp: o,
1936
1936
  onChange: a
@@ -1976,7 +1976,7 @@ var Pt = "DialogPortal", [Ro, wn] = gn(Pt, {
1976
1976
  forceMount: void 0
1977
1977
  }), bn = (e) => {
1978
1978
  const { __scopeDialog: t, forceMount: n, children: r, container: o } = e, a = ae(Pt, t);
1979
- return /* @__PURE__ */ s(Ro, { scope: t, forceMount: n, children: V.Children.map(r, (c) => /* @__PURE__ */ s(vt, { present: n || a.open, children: /* @__PURE__ */ s(Pr, { asChild: !0, container: o, children: c }) })) });
1979
+ return /* @__PURE__ */ s(Ro, { scope: t, forceMount: n, children: V.Children.map(r, (c) => /* @__PURE__ */ s(vt, { present: n || a.open, children: /* @__PURE__ */ s(yr, { asChild: !0, container: o, children: c }) })) });
1980
1980
  };
1981
1981
  bn.displayName = Pt;
1982
1982
  var ke = "DialogOverlay", Cn = V.forwardRef(
@@ -1992,7 +1992,7 @@ var Lo = V.forwardRef(
1992
1992
  return (
1993
1993
  // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
1994
1994
  // ie. when `Overlay` and `Content` are siblings
1995
- /* @__PURE__ */ s(gr, { as: vr, allowPinchZoom: !0, shards: [o.contentRef], children: /* @__PURE__ */ s(
1995
+ /* @__PURE__ */ s(Cr, { as: vr, allowPinchZoom: !0, shards: [o.contentRef], children: /* @__PURE__ */ s(
1996
1996
  Ne.div,
1997
1997
  {
1998
1998
  "data-state": St(o.open),
@@ -2016,7 +2016,7 @@ var No = V.forwardRef(
2016
2016
  return V.useEffect(() => {
2017
2017
  const a = r.current;
2018
2018
  if (a)
2019
- return _r(a);
2019
+ return Pr(a);
2020
2020
  }, []), /* @__PURE__ */ s(
2021
2021
  Tn,
2022
2022
  {
@@ -2065,9 +2065,9 @@ var No = V.forwardRef(
2065
2065
  ), Tn = V.forwardRef(
2066
2066
  (e, t) => {
2067
2067
  const { __scopeDialog: n, trapFocus: r, onOpenAutoFocus: o, onCloseAutoFocus: a, ...c } = e, i = ae(ve, n), l = V.useRef(null), p = gt(t, l);
2068
- return wr(), /* @__PURE__ */ O(Ae, { children: [
2068
+ return Tr(), /* @__PURE__ */ O(Ae, { children: [
2069
2069
  /* @__PURE__ */ s(
2070
- br,
2070
+ Sr,
2071
2071
  {
2072
2072
  asChild: !0,
2073
2073
  loop: !0,
@@ -2075,7 +2075,7 @@ var No = V.forwardRef(
2075
2075
  onMountAutoFocus: o,
2076
2076
  onUnmountAutoFocus: a,
2077
2077
  children: /* @__PURE__ */ s(
2078
- Cr,
2078
+ br,
2079
2079
  {
2080
2080
  role: "dialog",
2081
2081
  id: i.contentId,
@@ -2127,7 +2127,7 @@ xn.displayName = In;
2127
2127
  function St(e) {
2128
2128
  return e ? "open" : "closed";
2129
2129
  }
2130
- var Rn = "DialogTitleWarning", [js, Ln] = Sr(Rn, {
2130
+ var Rn = "DialogTitleWarning", [js, Ln] = _r(Rn, {
2131
2131
  contentName: ve,
2132
2132
  titleName: Tt,
2133
2133
  docsSlug: "dialog"