@pdf-viewer/react 1.6.0-beta.1 → 1.6.0-beta.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 (76) hide show
  1. package/dist/RPDefaultLayout-f579f051.js +3039 -0
  2. package/dist/{SearchCloseButton-d6135e7c.js → SearchCloseButton-959cc1ed.js} +11 -11
  3. package/dist/assets/Container.css +1 -1
  4. package/dist/assets/RPDefaultLayout.css +1 -1
  5. package/dist/assets/SearchCloseButton.css +1 -1
  6. package/dist/components/RPController.js +52 -51
  7. package/dist/components/RPPages.js +1 -1
  8. package/dist/components/RPProvider.js +1 -1
  9. package/dist/components/layout/Container.js +7 -6
  10. package/dist/components/layout/LayoutContainer.js +1 -1
  11. package/dist/components/layout/RPDefaultLayout.js +1 -1
  12. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  13. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  14. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  15. package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
  16. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  17. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  18. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  19. package/dist/components/layout/toolbar/MostPageTool.js +2 -2
  20. package/dist/components/layout/toolbar/OtherTool.js +4 -3
  21. package/dist/components/layout/toolbar/Paginate.js +1 -1
  22. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  23. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  24. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  25. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  26. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  27. package/dist/components/layout/toolbar/SearchCloseButton.js +1 -1
  28. package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
  29. package/dist/components/layout/toolbar/SearchTool.js +2 -2
  30. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  31. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  32. package/dist/components/layout/toolbar/ZoomTool.js +8 -27
  33. package/dist/components/page/AnnotationLayer.js +1 -1
  34. package/dist/components/page/CanvasLayer.js +1 -1
  35. package/dist/components/page/DualPage.js +1 -1
  36. package/dist/components/page/RPPage.js +1 -1
  37. package/dist/components/page/SinglePage.js +1 -1
  38. package/dist/components/page/TextHighlightLayer.js +1 -1
  39. package/dist/components/page/TextLayer.js +1 -1
  40. package/dist/components/ui/Checkbox.js +13 -14
  41. package/dist/components/ui/DropDown.js +1 -1
  42. package/dist/components/ui/LoadingIndicator.js +1 -1
  43. package/dist/components/ui/RPTooltip.js +331 -689
  44. package/dist/contexts/PaginationContext.js +1 -1
  45. package/dist/contexts/PrintContext.js +1 -1
  46. package/dist/contexts/SearchContext.js +1 -1
  47. package/dist/contexts/SmoothScrollContext.js +8 -9
  48. package/dist/contexts/ThumbnailsContext.js +1 -1
  49. package/dist/contexts/ZoomContext.js +17 -16
  50. package/dist/index-1cb41342.js +307 -0
  51. package/dist/index-7279fb4e.js +1557 -0
  52. package/dist/index-aa2d3884.js +140 -0
  53. package/dist/main.js +1 -1
  54. package/dist/types/contexts/SmoothScrollContext.d.ts +1 -3
  55. package/dist/types/utils/constants.d.ts +1 -0
  56. package/dist/types/utils/getZoomLevel.d.ts +2 -2
  57. package/dist/types/utils/types.d.ts +5 -2
  58. package/dist/utils/constants.js +3 -2
  59. package/dist/utils/getZoomLevel.js +13 -9
  60. package/dist/utils/hooks/useFileDownload.js +1 -1
  61. package/dist/utils/hooks/useLicense.js +18 -18
  62. package/dist/utils/hooks/usePaginate.js +1 -1
  63. package/dist/utils/hooks/usePinch.js +68 -17
  64. package/dist/utils/hooks/usePresentPage.js +1 -1
  65. package/dist/utils/hooks/usePrint.js +1 -1
  66. package/dist/utils/hooks/useScrollToPage.js +1 -1
  67. package/dist/utils/hooks/useSearch.js +1 -1
  68. package/dist/utils/hooks/useThumbnail.js +1 -1
  69. package/dist/utils/hooks/useVirtualReactWindow.js +1 -1
  70. package/dist/utils/types.js +9 -9
  71. package/package.json +1 -1
  72. package/dist/RPDefaultLayout-3a892bb5.js +0 -3041
  73. package/dist/index-2e540713.js +0 -23
  74. package/dist/index-353ec0a6.js +0 -172
  75. package/dist/index-5ff5dbd0.js +0 -1675
  76. package/dist/index-71898eb9.js +0 -139
@@ -0,0 +1,140 @@
1
+ import * as i from "react";
2
+ import { u as p, a as R, P as w, c as h, d as _, b as U } from "./index-1cb41342.js";
3
+ import { jsx as T } from "react/jsx-runtime";
4
+ function z(t, e = globalThis == null ? void 0 : globalThis.document) {
5
+ const s = p(t);
6
+ i.useEffect(() => {
7
+ const n = (r) => {
8
+ r.key === "Escape" && s(r);
9
+ };
10
+ return e.addEventListener("keydown", n, { capture: !0 }), () => e.removeEventListener("keydown", n, { capture: !0 });
11
+ }, [s, e]);
12
+ }
13
+ var H = "DismissableLayer", b = "dismissableLayer.update", M = "dismissableLayer.pointerDownOutside", K = "dismissableLayer.focusOutside", O, S = i.createContext({
14
+ layers: /* @__PURE__ */ new Set(),
15
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
16
+ branches: /* @__PURE__ */ new Set()
17
+ }), j = i.forwardRef(
18
+ (t, e) => {
19
+ const {
20
+ disableOutsidePointerEvents: s = !1,
21
+ onEscapeKeyDown: n,
22
+ onPointerDownOutside: r,
23
+ onFocusOutside: o,
24
+ onInteractOutside: l,
25
+ onDismiss: d,
26
+ ...v
27
+ } = t, u = i.useContext(S), [c, B] = i.useState(null), f = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = i.useState({}), I = R(e, (a) => B(a)), m = Array.from(u.layers), [W] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), k = m.indexOf(W), P = c ? m.indexOf(c) : -1, A = u.layersWithOutsidePointerEventsDisabled.size > 0, D = P >= k, N = $((a) => {
28
+ const E = a.target, C = [...u.branches].some((y) => y.contains(E));
29
+ !D || C || (r == null || r(a), l == null || l(a), a.defaultPrevented || d == null || d());
30
+ }, f), L = q((a) => {
31
+ const E = a.target;
32
+ [...u.branches].some((y) => y.contains(E)) || (o == null || o(a), l == null || l(a), a.defaultPrevented || d == null || d());
33
+ }, f);
34
+ return z((a) => {
35
+ P === u.layers.size - 1 && (n == null || n(a), !a.defaultPrevented && d && (a.preventDefault(), d()));
36
+ }, f), i.useEffect(() => {
37
+ if (c)
38
+ return s && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (O = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(c)), u.layers.add(c), g(), () => {
39
+ s && u.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = O);
40
+ };
41
+ }, [c, f, s, u]), i.useEffect(() => () => {
42
+ c && (u.layers.delete(c), u.layersWithOutsidePointerEventsDisabled.delete(c), g());
43
+ }, [c, u]), i.useEffect(() => {
44
+ const a = () => F({});
45
+ return document.addEventListener(b, a), () => document.removeEventListener(b, a);
46
+ }, []), /* @__PURE__ */ T(
47
+ w.div,
48
+ {
49
+ ...v,
50
+ ref: I,
51
+ style: {
52
+ pointerEvents: A ? D ? "auto" : "none" : void 0,
53
+ ...t.style
54
+ },
55
+ onFocusCapture: h(t.onFocusCapture, L.onFocusCapture),
56
+ onBlurCapture: h(t.onBlurCapture, L.onBlurCapture),
57
+ onPointerDownCapture: h(
58
+ t.onPointerDownCapture,
59
+ N.onPointerDownCapture
60
+ )
61
+ }
62
+ );
63
+ }
64
+ );
65
+ j.displayName = H;
66
+ var X = "DismissableLayerBranch", Y = i.forwardRef((t, e) => {
67
+ const s = i.useContext(S), n = i.useRef(null), r = R(e, n);
68
+ return i.useEffect(() => {
69
+ const o = n.current;
70
+ if (o)
71
+ return s.branches.add(o), () => {
72
+ s.branches.delete(o);
73
+ };
74
+ }, [s.branches]), /* @__PURE__ */ T(w.div, { ...t, ref: r });
75
+ });
76
+ Y.displayName = X;
77
+ function $(t, e = globalThis == null ? void 0 : globalThis.document) {
78
+ const s = p(t), n = i.useRef(!1), r = i.useRef(() => {
79
+ });
80
+ return i.useEffect(() => {
81
+ const o = (d) => {
82
+ if (d.target && !n.current) {
83
+ let v = function() {
84
+ x(
85
+ M,
86
+ s,
87
+ u,
88
+ { discrete: !0 }
89
+ );
90
+ };
91
+ const u = { originalEvent: d };
92
+ d.pointerType === "touch" ? (e.removeEventListener("click", r.current), r.current = v, e.addEventListener("click", r.current, { once: !0 })) : v();
93
+ } else
94
+ e.removeEventListener("click", r.current);
95
+ n.current = !1;
96
+ }, l = window.setTimeout(() => {
97
+ e.addEventListener("pointerdown", o);
98
+ }, 0);
99
+ return () => {
100
+ window.clearTimeout(l), e.removeEventListener("pointerdown", o), e.removeEventListener("click", r.current);
101
+ };
102
+ }, [e, s]), {
103
+ // ensures we check React component tree (not just DOM tree)
104
+ onPointerDownCapture: () => n.current = !0
105
+ };
106
+ }
107
+ function q(t, e = globalThis == null ? void 0 : globalThis.document) {
108
+ const s = p(t), n = i.useRef(!1);
109
+ return i.useEffect(() => {
110
+ const r = (o) => {
111
+ o.target && !n.current && x(K, s, { originalEvent: o }, {
112
+ discrete: !1
113
+ });
114
+ };
115
+ return e.addEventListener("focusin", r), () => e.removeEventListener("focusin", r);
116
+ }, [e, s]), {
117
+ onFocusCapture: () => n.current = !0,
118
+ onBlurCapture: () => n.current = !1
119
+ };
120
+ }
121
+ function g() {
122
+ const t = new CustomEvent(b);
123
+ document.dispatchEvent(t);
124
+ }
125
+ function x(t, e, s, { discrete: n }) {
126
+ const r = s.originalEvent.target, o = new CustomEvent(t, { bubbles: !1, cancelable: !0, detail: s });
127
+ e && r.addEventListener(t, e, { once: !0 }), n ? _(r, o) : r.dispatchEvent(o);
128
+ }
129
+ var G = i["useId".toString()] || (() => {
130
+ }), J = 0;
131
+ function Z(t) {
132
+ const [e, s] = i.useState(G());
133
+ return U(() => {
134
+ t || s((n) => n ?? String(J++));
135
+ }, [t]), t || (e ? `radix-${e}` : "");
136
+ }
137
+ export {
138
+ j as D,
139
+ Z as u
140
+ };
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RPProvider as t } from "./components/RPProvider.js";
2
- import { b as x, R as n, c as s, u as m, d as p, e as f } from "./RPDefaultLayout-3a892bb5.js";
2
+ import { b as x, R as n, c as s, u as m, d as p, e as f } from "./RPDefaultLayout-f579f051.js";
3
3
  import { RPConfig as a } from "./components/RPConfig.js";
4
4
  import { RPController as l } from "./components/RPController.js";
5
5
  import { RPTheme as P } from "./components/RPTheme.js";
@@ -1,7 +1,5 @@
1
- import { ScrollPosition } from '../utils/types';
2
1
  interface SmoothScrollContextType {
3
- smoothScrolling: React.MutableRefObject<boolean>;
4
- targetScrollPosition: React.MutableRefObject<ScrollPosition>;
2
+ targetScrollPage: React.MutableRefObject<number | undefined>;
5
3
  }
6
4
  export declare const SmoothScrollProvider: ({ children }: {
7
5
  children: React.ReactNode;
@@ -1,2 +1,3 @@
1
1
  export declare const PAGE_PADDING = 4;
2
2
  export declare const THUMBNAIL_MIN_WIDTH = 200;
3
+ export declare const SCROLL_BAR_WIDTH = 20;
@@ -1,2 +1,2 @@
1
- import { ZoomLevel } from './types';
2
- export declare const getZoomLevel: (zoomLevel: number | ZoomLevel, clientWidth: number, clientHeight: number, pageWidth: number, pageHeight: number) => number;
1
+ import { ZoomLevel, ViewMode } from './types';
2
+ export declare const getZoomLevel: (zoomLevel: number | ZoomLevel, clientWidth: number, clientHeight: number, pageWidth: number, pageHeight: number, viewMode: ViewMode) => number;
@@ -446,7 +446,10 @@ export declare enum ThemeVariables {
446
446
  TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius",
447
447
  CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color",
448
448
  TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color",
449
- TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius"
449
+ TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius",
450
+ CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width",
451
+ CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color",
452
+ CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset"
450
453
  }
451
454
  export interface DarkModeProviderProps extends PropsWithChildren, Partial<Omit<DarkMode, 'setDarkMode'>> {
452
455
  }
@@ -467,7 +470,7 @@ export interface RPProviderProps extends PropsWithChildren, LoadPDFOptions, RPCo
467
470
  characterMap?: CharacterMap;
468
471
  }
469
472
  export type LocalizationMap = Record<string, Localization>;
470
- export interface RPControllerProps extends PropsWithChildren, DarkModeProviderProps, RotateProviderProps, LayerProviderProps, ZoomProviderProps, PageProviderProps, ScrollModeProps {
473
+ export interface RPControllerProps extends PropsWithChildren, DarkModeProviderProps, RotateProviderProps, LayerProviderProps, ZoomProviderProps, PageProviderProps, ViewModeProps, ScrollModeProps {
471
474
  initialSearch?: string;
472
475
  initialThumbnailsVisible?: boolean;
473
476
  locale?: string;
@@ -1,5 +1,6 @@
1
- const I = 4, o = 200;
1
+ const I = 4, _ = 200, o = 20;
2
2
  export {
3
3
  I as PAGE_PADDING,
4
- o as THUMBNAIL_MIN_WIDTH
4
+ o as SCROLL_BAR_WIDTH,
5
+ _ as THUMBNAIL_MIN_WIDTH
5
6
  };
@@ -1,20 +1,24 @@
1
- import { ZoomLevel as t } from "./types.js";
2
- const c = (o, r, m, e, s) => {
1
+ import { SCROLL_BAR_WIDTH as s } from "./constants.js";
2
+ import { ZoomLevel as e, ViewMode as c } from "./types.js";
3
+ const Z = (o, t, m, r, a, u) => {
3
4
  if (typeof o == "number")
4
5
  return o;
5
6
  switch (o) {
6
- case t.ACTUAL:
7
+ case e.ACTUAL:
7
8
  return 100;
8
- case t.PAGE_FIT:
9
+ case e.PAGE_FIT:
9
10
  let n = 0;
10
- const f = r > m;
11
- return s > e && f ? n = m / s : n = r / e, Math.floor(n * 100);
12
- case t.PAGE_WIDTH:
13
- return Math.floor(r / e * 100);
11
+ const l = u === c.DUAL_PAGE ? 2 * r : r;
12
+ return n = Math.min(
13
+ (t - s) / l,
14
+ m / a
15
+ ), Math.floor(n * 100);
16
+ case e.PAGE_WIDTH:
17
+ return Math.floor(t / r * 100);
14
18
  default:
15
19
  return 100;
16
20
  }
17
21
  };
18
22
  export {
19
- c as getZoomLevel
23
+ Z as getZoomLevel
20
24
  };
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../contexts/RPDocumentContext.js";
4
- import { c as C } from "../../RPDefaultLayout-3a892bb5.js";
4
+ import { c as C } from "../../RPDefaultLayout-f579f051.js";
5
5
  import "../../contexts/DarkModeContext.js";
6
6
  import "../../contexts/RotationContext.js";
7
7
  import "../../contexts/LayerContext.js";
@@ -1,6 +1,6 @@
1
- import { useState as E, useCallback as h, useEffect as A } from "react";
1
+ import { useState as g, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as c } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2025-05-15T03:02:24.859Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
3
+ const b = /* @__PURE__ */ new Date("2025-05-16T04:25:03.248Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${l}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
6
6
  expired: `Your license key has expired. ${l}`,
@@ -44,20 +44,20 @@ kwIDAQAB
44
44
  // Convert signature to ArrayBuffer
45
45
  new TextEncoder().encode(atob(e))
46
46
  ))
47
- throw new Error(o.invalidSignature);
47
+ throw new Error(s.invalidSignature);
48
48
  return JSON.parse(atob(e));
49
49
  } catch {
50
- throw new Error(o.invalidLicense);
50
+ throw new Error(s.invalidLicense);
51
51
  }
52
52
  }
53
53
  const y = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), d = {
54
54
  isValid: !0,
55
- invalidatedMessage: o.invalidLicense,
55
+ invalidatedMessage: s.invalidLicense,
56
56
  type: void 0
57
57
  }, x = (r) => {
58
- const [t, e] = E(d), n = h(async () => {
58
+ const [t, e] = g(d), n = h(async () => {
59
59
  if (!r)
60
- throw e(d), new Error("License is missing");
60
+ throw e(d), new Error(s.invalidLicense);
61
61
  let i;
62
62
  try {
63
63
  i = await I(r);
@@ -65,35 +65,35 @@ const y = (r, t) => r === "specific" ? t === window.location.host : window.locat
65
65
  throw c.warn(m.message), new Error(m.message);
66
66
  }
67
67
  c.debug(">>> validatedLicense", i);
68
- const { avu: a, exp: s, dmt: w, dm: p, t: f } = i;
69
- if (!s)
68
+ const { avu: a, exp: o, dmt: w, dm: p, t: v } = i;
69
+ if (!o)
70
70
  throw new Error("License is missing expiration timestamp");
71
- if (s > Number.MAX_SAFE_INTEGER / 1e3)
71
+ if (o > Number.MAX_SAFE_INTEGER / 1e3)
72
72
  throw new Error("Invalid expiration timestamp: value too large");
73
- const v = new Date(s * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
74
- if (v.getTime() < g)
75
- throw new Error(o.expired);
73
+ const f = new Date(o * 1e3), E = (/* @__PURE__ */ new Date()).getTime();
74
+ if (f.getTime() < E)
75
+ throw new Error(s.expired);
76
76
  if (!a)
77
77
  throw new Error("License is missing available until version timestamp");
78
78
  if (a > Number.MAX_SAFE_INTEGER / 1e3)
79
79
  throw new Error("Invalid available until version timestamp: value too large");
80
80
  const u = new Date(a * 1e3);
81
81
  if (c.debug("availableUntilTimestamp", u), u.getTime() < b.getTime())
82
- throw new Error(o.exceededVersion);
82
+ throw new Error(s.exceededVersion);
83
83
  if (!y(w, p))
84
- throw new Error(o.mismatchedDomain);
84
+ throw new Error(s.mismatchedDomain);
85
85
  return {
86
86
  isValid: !0,
87
- type: f,
87
+ type: v,
88
88
  invalidatedMessage: void 0
89
89
  };
90
90
  }, [r]);
91
91
  return A(() => {
92
- n().then(({ isValid: i, type: a, invalidatedMessage: s }) => {
92
+ n().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
93
93
  e({
94
94
  isValid: i,
95
95
  type: a,
96
- invalidatedMessage: s
96
+ invalidatedMessage: o
97
97
  });
98
98
  }).catch((i) => {
99
99
  e({
@@ -1,5 +1,5 @@
1
1
  import "react";
2
- import { g as E } from "../../RPDefaultLayout-3a892bb5.js";
2
+ import { g as E } from "../../RPDefaultLayout-f579f051.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
5
  import "../../contexts/DarkModeContext.js";
@@ -1,28 +1,79 @@
1
- import { useState as d, useCallback as m, useEffect as f } from "react";
2
- import { useDebounce as h } from "./useDebounce.js";
3
- import { useZoomContext as i } from "../../contexts/ZoomContext.js";
4
- const b = (o) => {
5
- const { currentZoom: l, setZoomLevel: a } = i(), [n, s] = d(l || 100), r = h(n, 100), u = m((e) => {
6
- s(e ? (t) => t + 3 : (t) => t - 3);
7
- }, []), c = m(
1
+ import { useState as w, useRef as T, useCallback as r, useEffect as u } from "react";
2
+ import { useDebounce as g } from "./useDebounce.js";
3
+ import { useZoomContext as A } from "../../contexts/ZoomContext.js";
4
+ const I = (n) => {
5
+ const { currentZoom: m, setZoomLevel: b } = A(), [E, d] = w(m || 100), L = g(E, 100), [o, y] = w(!1), c = T(null), i = r((e) => {
6
+ d(e ? (t) => t + 3 : (t) => t - 3);
7
+ }, []), a = r(
8
8
  (e) => {
9
9
  if (!e.ctrlKey)
10
10
  return;
11
11
  e.preventDefault();
12
12
  const t = e.deltaY < 0;
13
- u(t);
13
+ i(t);
14
14
  },
15
- [u]
15
+ [i]
16
16
  );
17
- f(() => {
18
- if (r) {
19
- const e = Math.round(l * 100 + n);
20
- s(0), a(e > 25 ? e : 25);
17
+ u(() => {
18
+ if (L) {
19
+ const e = Math.round(m * 100 + E);
20
+ d(0), b(e > 25 ? e : 25);
21
21
  }
22
- }, [r]), f(() => (o && o.addEventListener("wheel", c), () => {
23
- o && o.removeEventListener("wheel", c);
24
- }), [o, c]);
22
+ }, [L]);
23
+ const p = (e, t) => {
24
+ const s = e.clientX - t.clientX, l = e.clientY - t.clientY;
25
+ return Math.sqrt(s * s + l * l);
26
+ }, h = r(
27
+ (e) => {
28
+ if (!o || e.touches.length !== 2)
29
+ return;
30
+ const t = p(e.touches[0], e.touches[1]);
31
+ c.current = t, e.preventDefault();
32
+ },
33
+ [o]
34
+ ), v = r(() => {
35
+ c.current = null;
36
+ }, []), f = r(
37
+ (e) => {
38
+ if (!o || e.touches.length !== 2 || c.current === null)
39
+ return;
40
+ const t = p(e.touches[0], e.touches[1]), s = t - c.current, l = Math.abs(s) > 5, S = s > 0;
41
+ l && (i(S), c.current = t, e.preventDefault());
42
+ },
43
+ [i, o]
44
+ ), D = () => {
45
+ document.activeElement instanceof HTMLElement && document.activeElement.blur();
46
+ };
47
+ u(() => {
48
+ if (o) {
49
+ document.body.style.touchAction = "pan-x pan-y";
50
+ return;
51
+ }
52
+ document.body.style.touchAction = "";
53
+ }, [o]), u(() => {
54
+ const e = () => {
55
+ const t = document.activeElement, s = !!(t != null && t.closest('[data-rp="container"]'));
56
+ y(s);
57
+ };
58
+ return window.addEventListener("focusin", e), window.addEventListener("focusout", e), e(), () => {
59
+ window.removeEventListener("focusin", e), window.removeEventListener("focusout", e);
60
+ };
61
+ }, []), u(() => {
62
+ if (!n)
63
+ return;
64
+ const e = (t) => {
65
+ n.contains(t.target) || D();
66
+ };
67
+ return document.addEventListener("scroll", e), () => {
68
+ document.removeEventListener("scroll", e);
69
+ };
70
+ }, [n]), u(() => {
71
+ if (n)
72
+ return n.addEventListener("wheel", a, { passive: !1 }), n.addEventListener("touchstart", h, { passive: !1 }), n.addEventListener("touchmove", f, { passive: !1 }), n.addEventListener("touchend", v, { passive: !1 }), () => {
73
+ n.removeEventListener("wheel", a), n.removeEventListener("touchstart", h), n.removeEventListener("touchmove", f), n.removeEventListener("touchend", v);
74
+ };
75
+ }, [n, a, h, f, v]);
25
76
  };
26
77
  export {
27
- b as usePinch
78
+ I as usePinch
28
79
  };
@@ -4,7 +4,7 @@ import "../../contexts/DimensionPagesContext.js";
4
4
  import "../calculatePage.js";
5
5
  import "react/jsx-runtime";
6
6
  import "../../contexts/RPDocumentContext.js";
7
- import { v as F } from "../../RPDefaultLayout-3a892bb5.js";
7
+ import { v as F } from "../../RPDefaultLayout-f579f051.js";
8
8
  import "../../contexts/DarkModeContext.js";
9
9
  import "../../contexts/RotationContext.js";
10
10
  import "../../contexts/LayerContext.js";
@@ -1,7 +1,7 @@
1
1
  import "react";
2
2
  import "react/jsx-runtime";
3
3
  import "../../contexts/RPDocumentContext.js";
4
- import { i as E } from "../../RPDefaultLayout-3a892bb5.js";
4
+ import { i as E } from "../../RPDefaultLayout-f579f051.js";
5
5
  import "../../contexts/DarkModeContext.js";
6
6
  import "../../contexts/RotationContext.js";
7
7
  import "../../contexts/LayerContext.js";
@@ -2,7 +2,7 @@ import "react";
2
2
  import "../../contexts/ScrollModeContext.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
- import { f as D } from "../../RPDefaultLayout-3a892bb5.js";
5
+ import { f as D } from "../../RPDefaultLayout-f579f051.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../types.js";
8
8
  import "../../contexts/RotationContext.js";
@@ -7,7 +7,7 @@ import "pdfjs-dist";
7
7
  import "../../contexts/RPDocumentContext.js";
8
8
  import "../../contexts/ZoomContext.js";
9
9
  import "react/jsx-runtime";
10
- import { n as G } from "../../RPDefaultLayout-3a892bb5.js";
10
+ import { n as G } from "../../RPDefaultLayout-f579f051.js";
11
11
  import "../../contexts/DarkModeContext.js";
12
12
  import "../../contexts/RotationContext.js";
13
13
  import "../../contexts/LayerContext.js";
@@ -2,7 +2,7 @@ import "react";
2
2
  import "../renderPage.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
- import { k as F } from "../../RPDefaultLayout-3a892bb5.js";
5
+ import { k as F } from "../../RPDefaultLayout-f579f051.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../../contexts/RotationContext.js";
8
8
  import "../../contexts/LayerContext.js";
@@ -3,7 +3,7 @@ import "../types.js";
3
3
  import "../../contexts/ScrollModeContext.js";
4
4
  import "react/jsx-runtime";
5
5
  import "../../contexts/RPDocumentContext.js";
6
- import { s as C } from "../../RPDefaultLayout-3a892bb5.js";
6
+ import { s as C } from "../../RPDefaultLayout-f579f051.js";
7
7
  import "../../contexts/DarkModeContext.js";
8
8
  import "../../contexts/RotationContext.js";
9
9
  import "../../contexts/LayerContext.js";
@@ -1,20 +1,20 @@
1
- import { e as r, z as _, i as R, p as o, t as p } from "../th_TH-2c4015a5.js";
2
- var E = /* @__PURE__ */ ((O) => (O[O.Text = 1] = "Text", O[O.Link = 2] = "Link", O[O.FreeText = 3] = "FreeText", O[O.Line = 4] = "Line", O[O.Square = 5] = "Square", O[O.Circle = 6] = "Circle", O[O.Polygon = 7] = "Polygon", O[O.Polyline = 8] = "Polyline", O[O.Highlight = 9] = "Highlight", O[O.Underline = 10] = "Underline", O[O.Squiggly = 11] = "Squiggly", O[O.StrikeOut = 12] = "StrikeOut", O[O.Stamp = 13] = "Stamp", O[O.Caret = 14] = "Caret", O[O.Ink = 15] = "Ink", O[O.Popup = 16] = "Popup", O[O.FileAttachment = 17] = "FileAttachment", O[O.Widget = 20] = "Widget", O))(E || {}), I = /* @__PURE__ */ ((O) => (O.INTERNAL_LINK = "internal-link", O.LINK = "link", O.FILE_ATTACHMENT = "file-attachment", O.FORM_TEXT = "form-text", O.FORM_SELECT = "form-select", O.FORM_CHECKBOX = "form-checkbox", O.FORM_RADIO = "form-radio", O.FORM_BUTTON = "form-button", O.BUTTON = "button", O))(I || {}), D = /* @__PURE__ */ ((O) => (O.ACTUAL = "Actual", O.PAGE_FIT = "Fit", O.PAGE_WIDTH = "Width", O))(D || {}), d = /* @__PURE__ */ ((O) => (O.Organization = "organization", O.Developer = "developer", O))(d || {}), N = /* @__PURE__ */ ((O) => (O.SINGLE_PAGE = "Single", O.DUAL_PAGE = "Dual", O))(N || {}), L = /* @__PURE__ */ ((O) => (O.FONT_FAMILY = "--rp-font-family", O.PRIMARY_COLOR = "--rp-primary-color", O.BORDER_RADIUS = "--rp-border-radius", O.TEXT_COLOR = "--rp-text-color", O.OUTLINE_COLOR = "--rp-outline-color", O.FONT_SIZE = "--rp-font-size", O.DROP_MASK_BACKGROUND_COLOR = "--rp-drop-mask-background-color", O.LOADER_BACKDROP_COLOR = "--rp-loader-backdrop-color", O.ICON_DISABLED = "--rp-icon-disabled", O.ICON_FONT_SIZE = "--rp-icon-font-size", O.TOOLBAR_BACKGROUND = "--rp-toolbar-background", O.TOOLBAR_BORDER_COLOR = "--rp-toolbar-border-color", O.TOOLBAR_PADDING = "--rp-toolbar-padding", O.TOOLBAR_GAP = "--rp-toolbar-gap", O.TOOLBAR_SIZE = "--rp-toolbar-size", O.SIDEBAR_WIDTH = "--rp-sidebar-width", O.THUMBNAIL_BORDER_COLOR = "--rp-thumbnail-border-color", O.THUMBNAIL_BACKGROUND_COLOR = "--rp-thumbnail-background-color", O.THUMBNAIL_ACTIVE_COLOR = "--rp-thumbnail-active-color", O.THUMBNAIL_PADDING_Y = "--rp-thumbnail-padding-y", O.BUTTON_HOVER_BACKGROUND = "--rp-button-hover-background", O.BUTTON_PADDING = "--rp-button-padding", O.INPUT_PADDING = "--rp-input-padding", O.INPUT_BORDER_RADIUS = "--rp-input-border-radius", O.INPUT_BACKGROUND_COLOR = "--rp-input-background-color", O.INPUT_PLACEHOLDER_COLOR = "--rp-input-placeholder-color", O.PAGES_BACKGROUND_COLOR = "--rp-pages-background-color", O.ANNOTATION_LAYER_LINK_HOVER_BACKGROUND = "--rp-annotation-layer__link-hover-background", O.DROPDOWN_BACKGROUND_COLOR = "--rp-dropdown-background-color", O.DROPDOWN_PADDING = "--rp-dropdown-padding", O.DROPDOWN_HOVER_BACKGROUND_COLOR = "--rp-dropdown-hover-background-color", O.DROPDOWN_SEPARATOR_COLOR = "--rp-dropdown-separator-color", O.DROPDOWN_SEPARATOR_MARGIN = "--rp-dropdown-separator-margin", O.DROPDOWN_PADDING_MENU_ITEM = "--rp-dropdown-padding-menu-item", O.DROPDOWN_FONT_SIZE = "--rp-dropdown-font-size", O.DROPDOWN_BORDER_RADIUS = "--rp-dropdown-border-radius", O.SEARCH_TOOL_DROPDOWN_PADDING = "--rp-search-tool-dropdown-padding", O.POPOVER_FONT_SIZE = "--rp-popover-font-size", O.POPOVER_BACKGROUND_COLOR = "--rp-popover-background-color", O.POPOVER_COLOR = "--rp-popover-color", O.POPOVER_BORDER_COLOR = "--rp-popover-border-color", O.POPOVER_BORDER_RADIUS = "--rp-popover-border-radius", O.OVERLAY_BACKGROUND_COLOR = "--rp-overlay-background-color", O.DIALOG_BACKGROUND_COLOR = "--rp-dialog-background-color", O.PROPERTIES_DIVIDER_COLOR = "--rp-properties-divider-color", O.PROPERTIES_DIVIDER_MARGIN = "--rp-properties-divider-margin", O.PROPERTY_ITEM_GAP = "--rp-property-item-gap", O.DIALOG_TITLE_COLOR = "--rp-dialog-title-color", O.PROPERTY_ITEM_LABEL_COLOR = "--rp-property-item-label-color", O.PROPERTY_CLOSE_ICON_SIZE = "--rp-property-close-icon-size", O.PROPERTY_ITEM_FONT_SIZE = "--rp-property-item-font-size", O.PROPERTY_ITEM_FONT_WEIGHT = "--rp-property-item-font-weight", O.DIALOG_TITLE_FONT_SIZE = "--rp-dialog-title-font-size", O.DIALOG_TITLE_FONT_WEIGHT = "--rp-dialog-title-font-weight", O.MENU_ITEM_ICON_SIZE = "--rp-menu-item-icon-size", O.PRINT_PROGRESS_BACKGROUND = "--rp-print-progress-background", O.PRINT_PROGRESS_COLOR = "--rp-print-progress-color", O.DROP_ZONE_BORDER = "--rp-drop-zone-border", O.DROP_ZONE_FONT_COLOR = "--rp-drop-zone-font-color", O.DROP_ZONE_FONT_SIZE = "--rp-drop-zone-font-size", O.DROP_ZONE_BACKGROUND_COLOR = "--rp-drop-zone-background-color", O.CHECKBOX_BORDER_RADIUS = "--rp-checkbox-border-radius", O.CHECKBOX_BORDER_COLOR = "--rp-checkbox-border-color", O.CHECKBOX_INDICATOR_COLOR = "--rp-checkbox-indicator-color", O.HIGHLIGHT_BACKGROUND_COLOR = "--rp-highlight-background-color", O.TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius", O.CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color", O.TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color", O.TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius", O))(L || {}), C = /* @__PURE__ */ ((O) => (O.PAGE_SCROLLING = "PAGE", O.VERTICAL_SCROLLING = "VERTICAL", O.HORIZONTAL_SCROLLING = "HORIZONTAL", O))(C || {}), P = /* @__PURE__ */ ((O) => (O.TEXT = "TEXT", O.HAND = "HAND", O))(P || {});
1
+ import { e as r, z as _, i as R, p as o, t as E } from "../th_TH-2c4015a5.js";
2
+ var I = /* @__PURE__ */ ((O) => (O[O.Text = 1] = "Text", O[O.Link = 2] = "Link", O[O.FreeText = 3] = "FreeText", O[O.Line = 4] = "Line", O[O.Square = 5] = "Square", O[O.Circle = 6] = "Circle", O[O.Polygon = 7] = "Polygon", O[O.Polyline = 8] = "Polyline", O[O.Highlight = 9] = "Highlight", O[O.Underline = 10] = "Underline", O[O.Squiggly = 11] = "Squiggly", O[O.StrikeOut = 12] = "StrikeOut", O[O.Stamp = 13] = "Stamp", O[O.Caret = 14] = "Caret", O[O.Ink = 15] = "Ink", O[O.Popup = 16] = "Popup", O[O.FileAttachment = 17] = "FileAttachment", O[O.Widget = 20] = "Widget", O))(I || {}), p = /* @__PURE__ */ ((O) => (O.INTERNAL_LINK = "internal-link", O.LINK = "link", O.FILE_ATTACHMENT = "file-attachment", O.FORM_TEXT = "form-text", O.FORM_SELECT = "form-select", O.FORM_CHECKBOX = "form-checkbox", O.FORM_RADIO = "form-radio", O.FORM_BUTTON = "form-button", O.BUTTON = "button", O))(p || {}), N = /* @__PURE__ */ ((O) => (O.ACTUAL = "Actual", O.PAGE_FIT = "Fit", O.PAGE_WIDTH = "Width", O))(N || {}), D = /* @__PURE__ */ ((O) => (O.Organization = "organization", O.Developer = "developer", O))(D || {}), d = /* @__PURE__ */ ((O) => (O.SINGLE_PAGE = "Single", O.DUAL_PAGE = "Dual", O))(d || {}), L = /* @__PURE__ */ ((O) => (O.FONT_FAMILY = "--rp-font-family", O.PRIMARY_COLOR = "--rp-primary-color", O.BORDER_RADIUS = "--rp-border-radius", O.TEXT_COLOR = "--rp-text-color", O.OUTLINE_COLOR = "--rp-outline-color", O.FONT_SIZE = "--rp-font-size", O.DROP_MASK_BACKGROUND_COLOR = "--rp-drop-mask-background-color", O.LOADER_BACKDROP_COLOR = "--rp-loader-backdrop-color", O.ICON_DISABLED = "--rp-icon-disabled", O.ICON_FONT_SIZE = "--rp-icon-font-size", O.TOOLBAR_BACKGROUND = "--rp-toolbar-background", O.TOOLBAR_BORDER_COLOR = "--rp-toolbar-border-color", O.TOOLBAR_PADDING = "--rp-toolbar-padding", O.TOOLBAR_GAP = "--rp-toolbar-gap", O.TOOLBAR_SIZE = "--rp-toolbar-size", O.SIDEBAR_WIDTH = "--rp-sidebar-width", O.THUMBNAIL_BORDER_COLOR = "--rp-thumbnail-border-color", O.THUMBNAIL_BACKGROUND_COLOR = "--rp-thumbnail-background-color", O.THUMBNAIL_ACTIVE_COLOR = "--rp-thumbnail-active-color", O.THUMBNAIL_PADDING_Y = "--rp-thumbnail-padding-y", O.BUTTON_HOVER_BACKGROUND = "--rp-button-hover-background", O.BUTTON_PADDING = "--rp-button-padding", O.INPUT_PADDING = "--rp-input-padding", O.INPUT_BORDER_RADIUS = "--rp-input-border-radius", O.INPUT_BACKGROUND_COLOR = "--rp-input-background-color", O.INPUT_PLACEHOLDER_COLOR = "--rp-input-placeholder-color", O.PAGES_BACKGROUND_COLOR = "--rp-pages-background-color", O.ANNOTATION_LAYER_LINK_HOVER_BACKGROUND = "--rp-annotation-layer__link-hover-background", O.DROPDOWN_BACKGROUND_COLOR = "--rp-dropdown-background-color", O.DROPDOWN_PADDING = "--rp-dropdown-padding", O.DROPDOWN_HOVER_BACKGROUND_COLOR = "--rp-dropdown-hover-background-color", O.DROPDOWN_SEPARATOR_COLOR = "--rp-dropdown-separator-color", O.DROPDOWN_SEPARATOR_MARGIN = "--rp-dropdown-separator-margin", O.DROPDOWN_PADDING_MENU_ITEM = "--rp-dropdown-padding-menu-item", O.DROPDOWN_FONT_SIZE = "--rp-dropdown-font-size", O.DROPDOWN_BORDER_RADIUS = "--rp-dropdown-border-radius", O.SEARCH_TOOL_DROPDOWN_PADDING = "--rp-search-tool-dropdown-padding", O.POPOVER_FONT_SIZE = "--rp-popover-font-size", O.POPOVER_BACKGROUND_COLOR = "--rp-popover-background-color", O.POPOVER_COLOR = "--rp-popover-color", O.POPOVER_BORDER_COLOR = "--rp-popover-border-color", O.POPOVER_BORDER_RADIUS = "--rp-popover-border-radius", O.OVERLAY_BACKGROUND_COLOR = "--rp-overlay-background-color", O.DIALOG_BACKGROUND_COLOR = "--rp-dialog-background-color", O.PROPERTIES_DIVIDER_COLOR = "--rp-properties-divider-color", O.PROPERTIES_DIVIDER_MARGIN = "--rp-properties-divider-margin", O.PROPERTY_ITEM_GAP = "--rp-property-item-gap", O.DIALOG_TITLE_COLOR = "--rp-dialog-title-color", O.PROPERTY_ITEM_LABEL_COLOR = "--rp-property-item-label-color", O.PROPERTY_CLOSE_ICON_SIZE = "--rp-property-close-icon-size", O.PROPERTY_ITEM_FONT_SIZE = "--rp-property-item-font-size", O.PROPERTY_ITEM_FONT_WEIGHT = "--rp-property-item-font-weight", O.DIALOG_TITLE_FONT_SIZE = "--rp-dialog-title-font-size", O.DIALOG_TITLE_FONT_WEIGHT = "--rp-dialog-title-font-weight", O.MENU_ITEM_ICON_SIZE = "--rp-menu-item-icon-size", O.PRINT_PROGRESS_BACKGROUND = "--rp-print-progress-background", O.PRINT_PROGRESS_COLOR = "--rp-print-progress-color", O.DROP_ZONE_BORDER = "--rp-drop-zone-border", O.DROP_ZONE_FONT_COLOR = "--rp-drop-zone-font-color", O.DROP_ZONE_FONT_SIZE = "--rp-drop-zone-font-size", O.DROP_ZONE_BACKGROUND_COLOR = "--rp-drop-zone-background-color", O.CHECKBOX_BORDER_RADIUS = "--rp-checkbox-border-radius", O.CHECKBOX_BORDER_COLOR = "--rp-checkbox-border-color", O.CHECKBOX_INDICATOR_COLOR = "--rp-checkbox-indicator-color", O.HIGHLIGHT_BACKGROUND_COLOR = "--rp-highlight-background-color", O.TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius", O.CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color", O.TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color", O.TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius", O.CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width", O.CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color", O.CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset", O))(L || {}), C = /* @__PURE__ */ ((O) => (O.PAGE_SCROLLING = "PAGE", O.VERTICAL_SCROLLING = "VERTICAL", O.HORIZONTAL_SCROLLING = "HORIZONTAL", O))(C || {}), c = /* @__PURE__ */ ((O) => (O.TEXT = "TEXT", O.HAND = "HAND", O))(c || {});
3
3
  const g = {
4
4
  en_US: r,
5
5
  zh_CN: _,
6
6
  it_IT: R,
7
7
  pt_PT: o,
8
- th_TH: p
8
+ th_TH: E
9
9
  };
10
10
  export {
11
- E as AnnotationSubType,
12
- I as AnnotationType,
13
- d as LicenseType,
11
+ I as AnnotationSubType,
12
+ p as AnnotationType,
13
+ D as LicenseType,
14
14
  g as Locales,
15
15
  C as ScrollMode,
16
- P as SelectionMode,
16
+ c as SelectionMode,
17
17
  L as ThemeVariables,
18
- N as ViewMode,
19
- D as ZoomLevel
18
+ d as ViewMode,
19
+ N as ZoomLevel
20
20
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "The PDF Viewer component for React and Next.js",
5
- "version": "1.6.0-beta.1",
5
+ "version": "1.6.0-beta.3",
6
6
  "keywords": [
7
7
  "component",
8
8
  "frontend",