@pdf-viewer/react 0.9.0-beta.4 → 0.9.0-beta.6

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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { useState as e } from "react";
3
- import { P as u, S as M, T as C, a as R } from "../RPDefaultLayout-1a423868.js";
2
+ import { useState as o } from "react";
3
+ import { P as u, S as M, T as R, a as C } from "../RPDefaultLayout-1a423868.js";
4
4
  import { DarkModeProvider as L } from "../contexts/DarkModeContext.js";
5
5
  import { ScrollMode as T, SelectionMode as V } from "../utils/types.js";
6
6
  import { RotateProvider as b } from "../contexts/RotationContext.js";
@@ -18,42 +18,42 @@ import { FullScreenProvider as Z } from "../contexts/FullScreenContext.js";
18
18
  import { FileInputProvider as j } from "../contexts/FileInputContext.js";
19
19
  import { DropFileZoneProvider as A } from "../contexts/DropFileZoneContext.js";
20
20
  import { LayoutContainerContext as N } from "../contexts/LayoutContainerContext.js";
21
- const nr = (o) => {
21
+ const nr = (t) => {
22
22
  const {
23
- children: t,
24
- darkMode: l = !1,
25
- onDarkModeChange: n,
26
- initialRotate: d = 0,
27
- textLayer: m = !0,
28
- initialPage: a = 1,
23
+ children: l,
24
+ darkMode: n = !1,
25
+ onDarkModeChange: d,
26
+ initialRotate: m = 0,
27
+ textLayer: a = !0,
28
+ initialPage: c = 1,
29
29
  // initialViewMode = ViewMode.SINGLE_PAGE,
30
- initialThumbnailsVisible: c = !1,
30
+ initialThumbnailsVisible: f = !1,
31
31
  initialSearch: h,
32
- initialScale: f,
33
- initialScrollMode: P = T.VERTICAL_SCROLLING,
34
- mobileWidth: p
35
- } = o, [v, S] = e(null), [i, s] = e(null);
32
+ initialScale: P,
33
+ initialScrollMode: p = T.VERTICAL_SCROLLING,
34
+ mobileWidth: v
35
+ } = t, [i, S] = o(null), [e, s] = o(null);
36
36
  return /* @__PURE__ */ r(
37
37
  G,
38
38
  {
39
- initialScale: f,
40
- initialPage: a,
41
- initialScrollMode: P,
42
- initialRotate: d,
43
- children: /* @__PURE__ */ r(w, { mobileWidth: p, children: /* @__PURE__ */ r(D, { children: /* @__PURE__ */ r(y, { children: /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(k, { children: /* @__PURE__ */ r(E, { initialSelectionMode: V.TEXT, children: /* @__PURE__ */ r(F, { children: /* @__PURE__ */ r(u, { children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(x, { textLayer: m, children: /* @__PURE__ */ r(I, { children: /* @__PURE__ */ r(
39
+ initialScale: P,
40
+ initialPage: c,
41
+ initialScrollMode: p,
42
+ initialRotate: m,
43
+ children: /* @__PURE__ */ r(w, { mobileWidth: v, containerRef: i, children: /* @__PURE__ */ r(D, { children: /* @__PURE__ */ r(y, { children: /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(k, { children: /* @__PURE__ */ r(E, { initialSelectionMode: V.TEXT, children: /* @__PURE__ */ r(F, { children: /* @__PURE__ */ r(u, { children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(x, { textLayer: a, children: /* @__PURE__ */ r(I, { children: /* @__PURE__ */ r(
44
44
  L,
45
45
  {
46
- darkMode: l,
47
- onDarkModeChange: n,
46
+ darkMode: n,
47
+ onDarkModeChange: d,
48
48
  children: /* @__PURE__ */ r(
49
49
  N.Provider,
50
50
  {
51
- value: { container: v, contentRef: i, setContainer: S, setContentRef: s },
51
+ value: { container: i, contentRef: e, setContainer: S, setContentRef: s },
52
52
  children: /* @__PURE__ */ r(M, { initialSearch: h, children: /* @__PURE__ */ r(
53
- C,
53
+ R,
54
54
  {
55
- initialThumbnailsVisible: c,
56
- children: /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(Z, { elementRef: i, children: /* @__PURE__ */ r(R, { children: /* @__PURE__ */ r(j, { children: t }) }) }) })
55
+ initialThumbnailsVisible: f,
56
+ children: /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(Z, { elementRef: e, children: /* @__PURE__ */ r(C, { children: /* @__PURE__ */ r(j, { children: l }) }) }) })
57
57
  }
58
58
  ) })
59
59
  }
@@ -1,62 +1,72 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { createContext as h, useState as m, useEffect as b, useContext as x } from "react";
3
- const v = {
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { createContext as b, useState as v, useEffect as x, useContext as g } from "react";
3
+ const k = {
4
4
  xs: 320,
5
5
  sm: 640,
6
6
  md: 768,
7
7
  lg: 1024,
8
8
  xl: 1280,
9
9
  "2xl": 1536
10
- }, s = h(void 0), E = ({ children: n, mobileWidth: a = 768 }) => {
11
- const [o, d] = m({
12
- width: window.innerWidth,
13
- height: window.innerHeight,
10
+ }, p = b(void 0), S = ({
11
+ children: s,
12
+ containerRef: t,
13
+ mobileWidth: l = 768
14
+ }) => {
15
+ const [o, c] = v({
16
+ width: (t == null ? void 0 : t.clientWidth) || window.innerWidth,
17
+ height: (t == null ? void 0 : t.clientHeight) || window.innerHeight,
14
18
  isMobile: !1,
15
19
  currentBreakpoint: "xs",
16
20
  orientation: "portrait"
17
- }), r = {
18
- ...v,
19
- md: a
20
- }, c = () => o.width < r.md, w = (e) => {
21
- const i = Object.entries(r);
22
- for (let t = i.length - 1; t >= 0; t--)
23
- if (e >= i[t][1])
24
- return i[t][0];
21
+ }), n = {
22
+ ...k,
23
+ md: l
24
+ }, w = () => o.width < n.md, u = (e) => {
25
+ const r = Object.entries(n);
26
+ for (let i = r.length - 1; i >= 0; i--)
27
+ if (e >= r[i][1])
28
+ return r[i][0];
25
29
  return "xs";
26
- }, p = () => {
30
+ }, a = () => {
27
31
  const e = navigator.userAgent.toLowerCase();
28
- return ["iphone", "ipod", "ipad", "android", "mobile", "phone", "tablet"].some((t) => e.includes(t));
32
+ return ["iphone", "ipod", "ipad", "android", "mobile", "phone", "tablet"].some((i) => e.includes(i));
29
33
  };
30
- b(() => {
34
+ x(() => {
35
+ if (!t)
36
+ return;
31
37
  const e = () => {
32
- const i = window.innerWidth, t = window.innerHeight;
33
- d({
38
+ const i = t.clientWidth, d = t.clientHeight;
39
+ c({
34
40
  width: i,
35
- height: t,
36
- isMobile: p(),
37
- currentBreakpoint: w(i),
38
- orientation: t > i ? "portrait" : "landscape"
41
+ height: d,
42
+ isMobile: a(),
43
+ currentBreakpoint: u(i),
44
+ orientation: d > i ? "portrait" : "landscape"
39
45
  });
40
46
  };
41
- return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
42
- }, []);
43
- const l = {
47
+ e();
48
+ const r = new ResizeObserver(e);
49
+ return r.observe(t), window.addEventListener("resize", e), () => {
50
+ r.disconnect(), window.removeEventListener("resize", e);
51
+ };
52
+ }, [t]);
53
+ const h = {
44
54
  ...o,
45
- breakpoints: r,
46
- isBreakpoint: (e) => o.width >= r[e],
55
+ breakpoints: n,
56
+ isBreakpoint: (e) => o.width >= n[e],
47
57
  isMobileDevice: o.isMobile,
48
58
  isPortrait: o.orientation === "portrait",
49
59
  isLandscape: o.orientation === "landscape",
50
- isSmallScreen: c()
60
+ isSmallScreen: w()
51
61
  };
52
- return /* @__PURE__ */ u(s.Provider, { value: l, children: n });
53
- }, B = () => {
54
- const n = x(s);
55
- if (n === void 0)
62
+ return /* @__PURE__ */ m(p.Provider, { value: h, children: s });
63
+ }, P = () => {
64
+ const s = g(p);
65
+ if (s === void 0)
56
66
  throw new Error("useViewportContext must be used within a ViewportProvider");
57
- return n;
67
+ return s;
58
68
  };
59
69
  export {
60
- E as ViewportProvider,
61
- B as useViewportContext
70
+ S as ViewportProvider,
71
+ P as useViewportContext
62
72
  };
package/dist/main.js CHANGED
@@ -1,40 +1,41 @@
1
1
  import { RPProvider as t } from "./components/RPProvider.js";
2
- import { b as x, R as n, c as s, u as p, d as f, e as m } from "./RPDefaultLayout-1a423868.js";
2
+ import { b as x, R as n, c as s, u as m, d as p, e as f } from "./RPDefaultLayout-1a423868.js";
3
3
  import { RPConfig as a } from "./components/RPConfig.js";
4
- import { RPController as C } from "./components/RPController.js";
5
- import { RPTheme as l } from "./components/RPTheme.js";
4
+ import { RPController as l } from "./components/RPController.js";
5
+ import { RPTheme as P } from "./components/RPTheme.js";
6
6
  import { RPDropFileZone as d } from "./components/RPDropFileZone.js";
7
7
  import { useDarkModeContext as c } from "./contexts/DarkModeContext.js";
8
8
  import { useDocumentContext as M } from "./contexts/RPDocumentContext.js";
9
- import { useRotationContext as w } from "./contexts/RotationContext.js";
10
- import { useViewModeContext as Z } from "./contexts/ViewModeContext.js";
11
- import { useDropFileZoneContext as V } from "./contexts/DropFileZoneContext.js";
12
- import { useOpenFileContext as k } from "./contexts/FileInputContext.js";
13
- import { useZoomContext as y } from "./contexts/ZoomContext.js";
9
+ import { useRotationContext as g } from "./contexts/RotationContext.js";
10
+ import { useViewModeContext as S } from "./contexts/ViewModeContext.js";
11
+ import { useDropFileZoneContext as v } from "./contexts/DropFileZoneContext.js";
12
+ import { useOpenFileContext as V } from "./contexts/FileInputContext.js";
13
+ import { useZoomContext as k } from "./contexts/ZoomContext.js";
14
14
  import { usePdfProperties as O } from "./utils/hooks/usePdfProperties.js";
15
15
  import { useFullScreenContext as j } from "./contexts/FullScreenContext.js";
16
- import { ScrollMode as z, ViewMode as A } from "./utils/types.js";
16
+ import { ScrollMode as z, ViewMode as A, ZoomLevel as B } from "./utils/types.js";
17
17
  export {
18
18
  a as RPConfig,
19
- C as RPController,
19
+ l as RPController,
20
20
  x as RPDefaultLayout,
21
21
  d as RPDropFileZone,
22
22
  n as RPPages,
23
23
  t as RPProvider,
24
- l as RPTheme,
24
+ P as RPTheme,
25
25
  z as ScrollMode,
26
26
  A as ViewMode,
27
+ B as ZoomLevel,
27
28
  c as useDarkModeContext,
28
29
  M as useDocumentContext,
29
- V as useDropFileZoneContext,
30
+ v as useDropFileZoneContext,
30
31
  s as useFileDownload,
31
32
  j as useFullScreenContext,
32
- k as useOpenFileContext,
33
- p as usePaginationContext,
33
+ V as useOpenFileContext,
34
+ m as usePaginationContext,
34
35
  O as usePdfProperties,
35
- f as usePrintContext,
36
- w as useRotationContext,
37
- m as useSearchContext,
38
- Z as useViewModeContext,
39
- y as useZoomContext
36
+ p as usePrintContext,
37
+ g as useRotationContext,
38
+ f as useSearchContext,
39
+ S as useViewModeContext,
40
+ k as useZoomContext
40
41
  };
@@ -22,6 +22,7 @@ interface ViewportContextType extends ViewportState {
22
22
  interface ViewportProviderProps {
23
23
  children: React.ReactNode;
24
24
  mobileWidth?: number;
25
+ containerRef: HTMLElement | null;
25
26
  }
26
27
  export declare const ViewportProvider: React.FC<ViewportProviderProps>;
27
28
  export declare const useViewportContext: () => ViewportContextType;
@@ -20,4 +20,4 @@ export { usePdfProperties } from './utils/hooks/usePdfProperties';
20
20
  export { useFullScreenContext } from './contexts/FullScreenContext';
21
21
  export { type PDFDocumentProxy } from 'pdfjs-dist';
22
22
  export type { RPConfigProps, RPThemeProps, RPProviderProps, RPLayoutProps, RPIcons, RPSlots, DarkModeProps, ZoomProps, ViewModeProps, DownloadToolProps, OpenFileToolProps, ScrollModeProps, PageNavigationToolProps, PrintToolProps, Localization, MatchValue } from './utils/types';
23
- export { ViewMode, ScrollMode } from './utils/types';
23
+ export { ViewMode, ScrollMode, ZoomLevel } from './utils/types';
@@ -1,6 +1,6 @@
1
1
  import { useState as g, useCallback as E, useEffect as h } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const A = /* @__PURE__ */ new Date("2025-02-26T10:08:29.736Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
3
+ const A = /* @__PURE__ */ new Date("2025-02-27T08:25:37.384Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
4
4
  invalidLicense: `You are currently using without a valid license. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
- "version": "0.9.0-beta.4",
4
+ "version": "0.9.0-beta.6",
5
5
  "keywords": [
6
6
  "component",
7
7
  "frontend",