@pdf-viewer/react 1.8.0-rc.1 → 1.8.0

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 (64) hide show
  1. package/dist/{Popover-1faa77f6.js → Popover-48c8394c.js} +2 -2
  2. package/dist/{RPDefaultLayout-2cca5d34.js → RPDefaultLayout-4b330ca1.js} +571 -565
  3. package/dist/{component-1da194e8.js → component-2aa6e53b.js} +1 -1
  4. package/dist/components/RPConfig.js +691 -673
  5. package/dist/components/RPController.js +1 -1
  6. package/dist/components/RPPages.js +1 -1
  7. package/dist/components/layout/LayoutContainer.js +1 -1
  8. package/dist/components/layout/RPDefaultLayout.js +1 -1
  9. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  10. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  11. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  12. package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
  13. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  14. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  15. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  16. package/dist/components/layout/toolbar/MostPageTool.js +2 -2
  17. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  18. package/dist/components/layout/toolbar/Paginate.js +1 -1
  19. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  20. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  21. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  22. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  23. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  24. package/dist/components/layout/toolbar/SearchResultNavigator.js +1 -1
  25. package/dist/components/layout/toolbar/SearchTool.js +2 -2
  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/TextHighlightLayer.js +1 -1
  35. package/dist/components/page/TextLayer.js +1 -1
  36. package/dist/components/ui/Checkbox.js +228 -116
  37. package/dist/components/ui/DropDown.js +1 -1
  38. package/dist/components/ui/LoadingIndicator.js +1 -1
  39. package/dist/components/ui/Popover.js +1 -1
  40. package/dist/components/ui/RPTooltip.js +207 -207
  41. package/dist/contexts/ElementPageContext.js +57 -46
  42. package/dist/contexts/PaginationContext.js +1 -1
  43. package/dist/contexts/PrintContext.js +1 -1
  44. package/dist/contexts/SearchContext.js +1 -1
  45. package/dist/contexts/ThumbnailsContext.js +1 -1
  46. package/dist/{floating-ui.react-dom-15b9b819.js → floating-ui.react-dom-4b1e2e46.js} +394 -380
  47. package/dist/index-6e0e48fa.js +332 -0
  48. package/dist/{index-7279fb4e.js → index-951f0f1f.js} +464 -456
  49. package/dist/index-e3a67935.js +150 -0
  50. package/dist/main.js +1 -1
  51. package/dist/types/utils/types.d.ts +1 -0
  52. package/dist/utils/hooks/useFileDownload.js +1 -1
  53. package/dist/utils/hooks/useLicense.js +26 -24
  54. package/dist/utils/hooks/usePageRotateContext.js +17 -14
  55. package/dist/utils/hooks/usePaginate.js +1 -1
  56. package/dist/utils/hooks/usePresentPage.js +1 -1
  57. package/dist/utils/hooks/usePrint.js +1 -1
  58. package/dist/utils/hooks/useScrollToPage.js +1 -1
  59. package/dist/utils/hooks/useSearch.js +1 -1
  60. package/dist/utils/hooks/useThumbnail.js +1 -1
  61. package/dist/utils/hooks/useVirtualReactWindow.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/index-1cb41342.js +0 -307
  64. package/dist/index-aa2d3884.js +0 -140
@@ -0,0 +1,150 @@
1
+ import * as r from "react";
2
+ import { u as R, P as w, a as h, f as _, g as U } from "./index-6e0e48fa.js";
3
+ import { jsx as T } from "react/jsx-runtime";
4
+ function b(t) {
5
+ const e = r.useRef(t);
6
+ return r.useEffect(() => {
7
+ e.current = t;
8
+ }), r.useMemo(() => (...n) => {
9
+ var s;
10
+ return (s = e.current) == null ? void 0 : s.call(e, ...n);
11
+ }, []);
12
+ }
13
+ function z(t, e = globalThis == null ? void 0 : globalThis.document) {
14
+ const n = b(t);
15
+ r.useEffect(() => {
16
+ const s = (i) => {
17
+ i.key === "Escape" && n(i);
18
+ };
19
+ return e.addEventListener("keydown", s, { capture: !0 }), () => e.removeEventListener("keydown", s, { capture: !0 });
20
+ }, [n, e]);
21
+ }
22
+ var H = "DismissableLayer", p = "dismissableLayer.update", M = "dismissableLayer.pointerDownOutside", K = "dismissableLayer.focusOutside", g, S = r.createContext({
23
+ layers: /* @__PURE__ */ new Set(),
24
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
25
+ branches: /* @__PURE__ */ new Set()
26
+ }), j = r.forwardRef(
27
+ (t, e) => {
28
+ const {
29
+ disableOutsidePointerEvents: n = !1,
30
+ onEscapeKeyDown: s,
31
+ onPointerDownOutside: i,
32
+ onFocusOutside: a,
33
+ onInteractOutside: l,
34
+ onDismiss: d,
35
+ ...E
36
+ } = t, u = r.useContext(S), [c, B] = r.useState(null), f = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = r.useState({}), I = R(e, (o) => B(o)), m = Array.from(u.layers), [W] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), A = m.indexOf(W), P = c ? m.indexOf(c) : -1, N = u.layersWithOutsidePointerEventsDisabled.size > 0, D = P >= A, k = $((o) => {
37
+ const v = o.target, C = [...u.branches].some((y) => y.contains(v));
38
+ !D || C || (i == null || i(o), l == null || l(o), o.defaultPrevented || d == null || d());
39
+ }, f), L = q((o) => {
40
+ const v = o.target;
41
+ [...u.branches].some((y) => y.contains(v)) || (a == null || a(o), l == null || l(o), o.defaultPrevented || d == null || d());
42
+ }, f);
43
+ return z((o) => {
44
+ P === u.layers.size - 1 && (s == null || s(o), !o.defaultPrevented && d && (o.preventDefault(), d()));
45
+ }, f), r.useEffect(() => {
46
+ if (c)
47
+ return n && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (g = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(c)), u.layers.add(c), O(), () => {
48
+ n && u.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = g);
49
+ };
50
+ }, [c, f, n, u]), r.useEffect(() => () => {
51
+ c && (u.layers.delete(c), u.layersWithOutsidePointerEventsDisabled.delete(c), O());
52
+ }, [c, u]), r.useEffect(() => {
53
+ const o = () => F({});
54
+ return document.addEventListener(p, o), () => document.removeEventListener(p, o);
55
+ }, []), /* @__PURE__ */ T(
56
+ w.div,
57
+ {
58
+ ...E,
59
+ ref: I,
60
+ style: {
61
+ pointerEvents: N ? D ? "auto" : "none" : void 0,
62
+ ...t.style
63
+ },
64
+ onFocusCapture: h(t.onFocusCapture, L.onFocusCapture),
65
+ onBlurCapture: h(t.onBlurCapture, L.onBlurCapture),
66
+ onPointerDownCapture: h(
67
+ t.onPointerDownCapture,
68
+ k.onPointerDownCapture
69
+ )
70
+ }
71
+ );
72
+ }
73
+ );
74
+ j.displayName = H;
75
+ var X = "DismissableLayerBranch", Y = r.forwardRef((t, e) => {
76
+ const n = r.useContext(S), s = r.useRef(null), i = R(e, s);
77
+ return r.useEffect(() => {
78
+ const a = s.current;
79
+ if (a)
80
+ return n.branches.add(a), () => {
81
+ n.branches.delete(a);
82
+ };
83
+ }, [n.branches]), /* @__PURE__ */ T(w.div, { ...t, ref: i });
84
+ });
85
+ Y.displayName = X;
86
+ function $(t, e = globalThis == null ? void 0 : globalThis.document) {
87
+ const n = b(t), s = r.useRef(!1), i = r.useRef(() => {
88
+ });
89
+ return r.useEffect(() => {
90
+ const a = (d) => {
91
+ if (d.target && !s.current) {
92
+ let E = function() {
93
+ x(
94
+ M,
95
+ n,
96
+ u,
97
+ { discrete: !0 }
98
+ );
99
+ };
100
+ const u = { originalEvent: d };
101
+ d.pointerType === "touch" ? (e.removeEventListener("click", i.current), i.current = E, e.addEventListener("click", i.current, { once: !0 })) : E();
102
+ } else
103
+ e.removeEventListener("click", i.current);
104
+ s.current = !1;
105
+ }, l = window.setTimeout(() => {
106
+ e.addEventListener("pointerdown", a);
107
+ }, 0);
108
+ return () => {
109
+ window.clearTimeout(l), e.removeEventListener("pointerdown", a), e.removeEventListener("click", i.current);
110
+ };
111
+ }, [e, n]), {
112
+ // ensures we check React component tree (not just DOM tree)
113
+ onPointerDownCapture: () => s.current = !0
114
+ };
115
+ }
116
+ function q(t, e = globalThis == null ? void 0 : globalThis.document) {
117
+ const n = b(t), s = r.useRef(!1);
118
+ return r.useEffect(() => {
119
+ const i = (a) => {
120
+ a.target && !s.current && x(K, n, { originalEvent: a }, {
121
+ discrete: !1
122
+ });
123
+ };
124
+ return e.addEventListener("focusin", i), () => e.removeEventListener("focusin", i);
125
+ }, [e, n]), {
126
+ onFocusCapture: () => s.current = !0,
127
+ onBlurCapture: () => s.current = !1
128
+ };
129
+ }
130
+ function O() {
131
+ const t = new CustomEvent(p);
132
+ document.dispatchEvent(t);
133
+ }
134
+ function x(t, e, n, { discrete: s }) {
135
+ const i = n.originalEvent.target, a = new CustomEvent(t, { bubbles: !1, cancelable: !0, detail: n });
136
+ e && i.addEventListener(t, e, { once: !0 }), s ? _(i, a) : i.dispatchEvent(a);
137
+ }
138
+ var G = r[" useId ".trim().toString()] || (() => {
139
+ }), J = 0;
140
+ function Z(t) {
141
+ const [e, n] = r.useState(G());
142
+ return U(() => {
143
+ t || n((s) => s ?? String(J++));
144
+ }, [t]), t || (e ? `radix-${e}` : "");
145
+ }
146
+ export {
147
+ j as D,
148
+ Z as a,
149
+ b as u
150
+ };
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RPProvider as t } from "./components/RPProvider.js";
2
- import { a as x, R as n, b as s, u as m, c as p, d as a } from "./RPDefaultLayout-2cca5d34.js";
2
+ import { a as x, R as n, b as s, u as m, c as p, d as a } from "./RPDefaultLayout-4b330ca1.js";
3
3
  import { RPConfig as u } from "./components/RPConfig.js";
4
4
  import { RPController as i } from "./components/RPController.js";
5
5
  import { RPTheme as P } from "./components/RPTheme.js";
@@ -221,6 +221,7 @@ export interface DarkMode extends DarkModeProps {
221
221
  onDarkModeChange: (value: boolean) => void;
222
222
  }
223
223
  export interface License {
224
+ validating?: boolean;
224
225
  isValid: boolean;
225
226
  invalidatedMessage?: string;
226
227
  type?: LicenseType;
@@ -2,7 +2,7 @@ import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../contexts/RPDocumentContext.js";
4
4
  import "../../contexts/DocumentPasswordContext.js";
5
- import { b as H } from "../../RPDefaultLayout-2cca5d34.js";
5
+ import { b as H } from "../../RPDefaultLayout-4b330ca1.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../../contexts/RotationContext.js";
8
8
  import "../../contexts/LayerContext.js";
@@ -1,9 +1,9 @@
1
- import { useState as g, useCallback as h, useEffect as A } from "react";
2
- import { appConsole as c } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2025-07-22T05:14:01.643Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
- invalidLicense: `You are currently using without a valid license. ${l}`,
5
- mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
6
- expired: `Your license key has expired. ${l}`,
1
+ import { useState as E, useCallback as h, useEffect as A } from "react";
2
+ import { appConsole as l } from "../appConsole.js";
3
+ const b = /* @__PURE__ */ new Date("2025-07-29T08:30:55.704Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
+ invalidLicense: `You are currently using without a valid license. ${d}`,
5
+ mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
+ expired: `Your license key has expired. ${d}`,
7
7
  exceededVersion: "Your license does not support the current version of React PDF. The library version you are using exceeds the supported range of your license.",
8
8
  invalidSignature: "Invalid license key: Signature mismatch"
9
9
  };
@@ -50,41 +50,41 @@ kwIDAQAB
50
50
  throw new Error(s.invalidLicense);
51
51
  }
52
52
  }
53
- const y = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), d = {
53
+ const y = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), u = {
54
54
  isValid: !0,
55
55
  invalidatedMessage: s.invalidLicense,
56
56
  type: void 0
57
57
  }, x = (r) => {
58
- const [t, e] = g(d), n = h(async () => {
59
- if (!r)
60
- throw e(d), new Error(s.invalidLicense);
58
+ const [t, e] = E(u), n = h(async () => {
59
+ if (e((c) => ({ ...c, validating: !0 })), !r)
60
+ throw e({ ...u, validating: !1 }), new Error(s.invalidLicense);
61
61
  let i;
62
62
  try {
63
63
  i = await I(r);
64
- } catch (m) {
65
- throw c.warn(m.message), new Error(m.message);
64
+ } catch (c) {
65
+ throw l.warn(c.message), new Error(c.message);
66
66
  }
67
- c.debug(">>> validatedLicense", i);
68
- const { avu: a, exp: o, dmt: w, dm: p, t: v } = i;
67
+ l.debug(">>> validatedLicense", i);
68
+ const { avu: a, exp: o, dmt: m, dm: w, t: f } = i;
69
69
  if (!o)
70
70
  throw new Error("License is missing expiration timestamp");
71
71
  if (o > Number.MAX_SAFE_INTEGER / 1e3)
72
72
  throw new Error("Invalid expiration timestamp: value too large");
73
- const f = new Date(o * 1e3), E = (/* @__PURE__ */ new Date()).getTime();
74
- if (f.getTime() < E)
73
+ const p = new Date(o * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
74
+ if (p.getTime() < g)
75
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
- const u = new Date(a * 1e3);
81
- if (c.debug("availableUntilTimestamp", u), u.getTime() < b.getTime())
80
+ const v = new Date(a * 1e3);
81
+ if (l.debug("availableUntilTimestamp", v), v.getTime() < b.getTime())
82
82
  throw new Error(s.exceededVersion);
83
- if (!y(w, p))
83
+ if (!y(m, w))
84
84
  throw new Error(s.mismatchedDomain);
85
85
  return {
86
86
  isValid: !0,
87
- type: v,
87
+ type: f,
88
88
  invalidatedMessage: void 0
89
89
  };
90
90
  }, [r]);
@@ -93,13 +93,15 @@ const y = (r, t) => r === "specific" ? t === window.location.host : window.locat
93
93
  e({
94
94
  isValid: i,
95
95
  type: a,
96
- invalidatedMessage: o
96
+ invalidatedMessage: o,
97
+ validating: !1
97
98
  });
98
99
  }).catch((i) => {
99
100
  e({
100
- ...d,
101
- isValid: !1
102
- }), c.warn(i.message);
101
+ ...u,
102
+ isValid: !1,
103
+ validating: !1
104
+ }), l.warn(i.message);
103
105
  });
104
106
  }, [n]), t;
105
107
  };
@@ -1,27 +1,30 @@
1
- import { useCallback as a } from "react";
2
- import { usePagesRotateContext as c } from "../../contexts/PagesRotateContext.js";
3
- import { useLicenseContext as m } from "../../contexts/LicenseContext.js";
4
- import { LicenseType as f } from "../types.js";
5
- import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as u } from "../const.js";
6
- const E = () => {
7
- const { setSinglePageRotate: n } = c(), { type: s } = m(), i = a(
8
- (r, t) => {
1
+ import { useRef as u, useCallback as f } from "react";
2
+ import { usePagesRotateContext as m } from "../../contexts/PagesRotateContext.js";
3
+ import { useLicenseContext as l } from "../../contexts/LicenseContext.js";
4
+ import { LicenseType as p } from "../types.js";
5
+ import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as R } from "../const.js";
6
+ const C = () => {
7
+ const { setSinglePageRotate: n } = m(), { type: i, validating: a } = l(), r = u(0), c = f(
8
+ (s, t) => {
9
9
  n((e) => {
10
- const o = typeof t == "function" ? t(e[r] || 0) : t;
10
+ const o = typeof t == "function" ? t(e[s] || 0) : t;
11
11
  return o % 90 !== 0 ? (console.warn("rotationDegree must be a multiple of 90 got", o), e) : {
12
12
  ...e,
13
- [r]: o
13
+ [s]: o
14
14
  };
15
15
  });
16
16
  },
17
17
  [n]
18
18
  );
19
- return s !== f.Organization ? {
19
+ return a !== !1 ? {
20
20
  rotate: () => {
21
- console.error(u);
22
21
  }
23
- } : { rotate: i };
22
+ } : i !== p.Organization ? {
23
+ rotate: () => {
24
+ r.current === 0 && (console.error(R), r.current++);
25
+ }
26
+ } : { rotate: c };
24
27
  };
25
28
  export {
26
- E as usePageRotateContext
29
+ C as usePageRotateContext
27
30
  };
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../types.js";
3
- import { g as I } from "../../RPDefaultLayout-2cca5d34.js";
3
+ import { g as I } from "../../RPDefaultLayout-4b330ca1.js";
4
4
  import "react/jsx-runtime";
5
5
  import "../../contexts/RPDocumentContext.js";
6
6
  import "../../contexts/DocumentPasswordContext.js";
@@ -5,7 +5,7 @@ import "../calculatePage.js";
5
5
  import "react/jsx-runtime";
6
6
  import "../../contexts/RPDocumentContext.js";
7
7
  import "../../contexts/DocumentPasswordContext.js";
8
- import { v as I } from "../../RPDefaultLayout-2cca5d34.js";
8
+ import { v as I } from "../../RPDefaultLayout-4b330ca1.js";
9
9
  import "../../contexts/DarkModeContext.js";
10
10
  import "../../contexts/RotationContext.js";
11
11
  import "../../contexts/LayerContext.js";
@@ -2,7 +2,7 @@ import "react";
2
2
  import "react/jsx-runtime";
3
3
  import "../../contexts/RPDocumentContext.js";
4
4
  import "../../contexts/DocumentPasswordContext.js";
5
- import { i as H } from "../../RPDefaultLayout-2cca5d34.js";
5
+ import { i as H } from "../../RPDefaultLayout-4b330ca1.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../../contexts/RotationContext.js";
8
8
  import "../../contexts/LayerContext.js";
@@ -3,7 +3,7 @@ import "../../contexts/ScrollModeContext.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
5
  import "../../contexts/DocumentPasswordContext.js";
6
- import { f as H } from "../../RPDefaultLayout-2cca5d34.js";
6
+ import { f as H } from "../../RPDefaultLayout-4b330ca1.js";
7
7
  import "../../contexts/DarkModeContext.js";
8
8
  import "../types.js";
9
9
  import "../../contexts/RotationContext.js";
@@ -7,7 +7,7 @@ import "../../contexts/RPDocumentContext.js";
7
7
  import "../../contexts/ZoomContext.js";
8
8
  import "react/jsx-runtime";
9
9
  import "../../contexts/DocumentPasswordContext.js";
10
- import { n as K } from "../../RPDefaultLayout-2cca5d34.js";
10
+ import { n as K } from "../../RPDefaultLayout-4b330ca1.js";
11
11
  import "../../contexts/DarkModeContext.js";
12
12
  import "../../contexts/RotationContext.js";
13
13
  import "../../contexts/LayerContext.js";
@@ -3,7 +3,7 @@ import "../renderPage.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
5
  import "../../contexts/DocumentPasswordContext.js";
6
- import { k as I } from "../../RPDefaultLayout-2cca5d34.js";
6
+ import { k as I } from "../../RPDefaultLayout-4b330ca1.js";
7
7
  import "../../contexts/DarkModeContext.js";
8
8
  import "../../contexts/RotationContext.js";
9
9
  import "../../contexts/LayerContext.js";
@@ -4,7 +4,7 @@ import "../../contexts/ScrollModeContext.js";
4
4
  import "react/jsx-runtime";
5
5
  import "../../contexts/RPDocumentContext.js";
6
6
  import "../../contexts/DocumentPasswordContext.js";
7
- import { s as F } from "../../RPDefaultLayout-2cca5d34.js";
7
+ import { s as F } from "../../RPDefaultLayout-4b330ca1.js";
8
8
  import "../../contexts/DarkModeContext.js";
9
9
  import "../../contexts/RotationContext.js";
10
10
  import "../../contexts/LayerContext.js";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
5
- "version": "1.8.0-rc.1",
5
+ "version": "1.8.0",
6
6
  "keywords": [
7
7
  "react-pdf",
8
8
  "react-pdf-viewer",