@pdf-viewer/react 1.12.0-rc.0 → 1.12.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as z } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as H, useState as N, useCallback as d, useContext as U, useRef as W, useMemo as q } from "react";
|
|
3
3
|
import { ScrollMode as g, LicenseType as B } from "../utils/types.js";
|
|
4
4
|
import { useDimensionPagesContext as J } from "./DimensionPagesContext.js";
|
|
5
5
|
import { usePagesRotateContext as K } from "./PagesRotateContext.js";
|
|
@@ -31,8 +31,8 @@ import "../utils/hooks/useLicense.js";
|
|
|
31
31
|
import "../utils/getZoomLevel.js";
|
|
32
32
|
import "./GlobalCurrentPage.js";
|
|
33
33
|
import "../utils/hooks/useDebounce.js";
|
|
34
|
-
const S =
|
|
35
|
-
const [s, m] =
|
|
34
|
+
const S = H(void 0), Ve = ({ children: l }) => {
|
|
35
|
+
const [s, m] = N({}), { widths: t, heights: r } = J(), { pagesRef: c } = Y(), { scrollMode: C } = $(), { pageRotate: u } = K(), { currentZoom: a } = X(), { columnCount: R } = te(), { pageScrollElementRef: I, virtualScrollableElementRef: T } = oe(), M = d(
|
|
36
36
|
(e, i, o = { behavior: "smooth" }) => {
|
|
37
37
|
var v;
|
|
38
38
|
const n = T || I;
|
|
@@ -43,8 +43,8 @@ const S = z(void 0), Ve = ({ children: l }) => {
|
|
|
43
43
|
return;
|
|
44
44
|
let p = 0, P = 0;
|
|
45
45
|
if (C === g.VERTICAL_SCROLLING) {
|
|
46
|
-
const f = e - 1, E = R,
|
|
47
|
-
p = w(r,
|
|
46
|
+
const f = e - 1, E = R, j = f % E, k = Math.floor(f / E);
|
|
47
|
+
p = w(r, k), P = w(t, j);
|
|
48
48
|
}
|
|
49
49
|
C === g.HORIZONTAL_SCROLLING && (P = t.slice(0, e - 1).reduce((f, E) => f + E, 0));
|
|
50
50
|
const _ = {
|
|
@@ -93,7 +93,7 @@ const S = z(void 0), Ve = ({ children: l }) => {
|
|
|
93
93
|
return n[e] = n[e].filter((L, p) => p !== i), n;
|
|
94
94
|
});
|
|
95
95
|
}, []);
|
|
96
|
-
return /* @__PURE__ */
|
|
96
|
+
return /* @__PURE__ */ z(
|
|
97
97
|
S.Provider,
|
|
98
98
|
{
|
|
99
99
|
value: { updateElement: A, clearElements: O, removeElement: y, elementList: s, scrollToElement: M },
|
|
@@ -102,7 +102,7 @@ const S = z(void 0), Ve = ({ children: l }) => {
|
|
|
102
102
|
);
|
|
103
103
|
}, h = () => {
|
|
104
104
|
}, be = () => {
|
|
105
|
-
const l =
|
|
105
|
+
const l = U(S), { type: s, validating: m } = Q(), t = W(0), r = q(() => {
|
|
106
106
|
if (m !== !1)
|
|
107
107
|
return {
|
|
108
108
|
updateElement: h,
|
|
@@ -1,41 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
function g(e, o) {
|
|
2
|
+
!e || typeof e != "object" || Object.entries(e).forEach(([d, i]) => {
|
|
3
|
+
if (i == null)
|
|
4
|
+
return;
|
|
5
|
+
const s = d.replace(/([A-Z])/g, "-$1").toLowerCase(), n = [
|
|
6
|
+
"width",
|
|
7
|
+
"height",
|
|
8
|
+
"top",
|
|
9
|
+
"right",
|
|
10
|
+
"bottom",
|
|
11
|
+
"left",
|
|
12
|
+
"margin",
|
|
13
|
+
"margin-top",
|
|
14
|
+
"margin-right",
|
|
15
|
+
"margin-bottom",
|
|
16
|
+
"margin-left",
|
|
17
|
+
"padding",
|
|
18
|
+
"padding-top",
|
|
19
|
+
"padding-right",
|
|
20
|
+
"padding-bottom",
|
|
21
|
+
"padding-left",
|
|
22
|
+
"border-width",
|
|
23
|
+
"border-top-width",
|
|
24
|
+
"border-right-width",
|
|
25
|
+
"border-bottom-width",
|
|
26
|
+
"border-left-width",
|
|
27
|
+
"font-size",
|
|
28
|
+
"line-height",
|
|
29
|
+
"letter-spacing",
|
|
30
|
+
"word-spacing",
|
|
31
|
+
"min-width",
|
|
32
|
+
"min-height",
|
|
33
|
+
"max-width",
|
|
34
|
+
"max-height",
|
|
35
|
+
"flex-basis",
|
|
36
|
+
"grid-gap",
|
|
37
|
+
"grid-row-gap",
|
|
38
|
+
"grid-column-gap"
|
|
39
|
+
];
|
|
40
|
+
let t;
|
|
41
|
+
typeof i == "number" && i !== 0 ? t = n.includes(s) ? `${i}px` : String(i) : t = String(i), o.style.setProperty(s, t);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const f = (e, o, d, i, s) => {
|
|
45
|
+
let n = "center";
|
|
46
|
+
switch (i) {
|
|
4
47
|
case 90:
|
|
5
|
-
|
|
48
|
+
n = `${e.width / 2}px ${e.width / 2}px`;
|
|
6
49
|
break;
|
|
7
50
|
case -90:
|
|
8
51
|
case 270:
|
|
9
|
-
|
|
52
|
+
n = `${e.height / 2}px ${e.height / 2}px`;
|
|
10
53
|
break;
|
|
11
54
|
default:
|
|
12
|
-
|
|
55
|
+
n = "center";
|
|
13
56
|
}
|
|
14
57
|
const t = document.createElement("div");
|
|
15
|
-
t.id = "parent-element", t.style.width = `${
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
if (
|
|
20
|
-
|
|
58
|
+
t.id = "parent-element", t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.style.setProperty("--scale-factor", s.toString()), t.style.setProperty("--rotation", i.toString()), t.style.setProperty("--transform-origin", n), t.style.left = "-99999px", t.style.visibility = "hidden", t.style.position = "absolute";
|
|
59
|
+
const l = document.createElement("div");
|
|
60
|
+
l.style.position = "relative", l.style.width = "100%", l.style.height = "100%", t.appendChild(l);
|
|
61
|
+
let r;
|
|
62
|
+
if (d instanceof HTMLElement)
|
|
63
|
+
r = d.cloneNode(!0), l.appendChild(r);
|
|
21
64
|
else {
|
|
22
|
-
const
|
|
23
|
-
|
|
65
|
+
const p = d.props;
|
|
66
|
+
r = document.createElement("div"), p.style && g(p.style, r), p.className && (r.className = p.className), l.appendChild(r);
|
|
24
67
|
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
top:
|
|
30
|
-
left:
|
|
68
|
+
o.appendChild(t);
|
|
69
|
+
const c = t.getBoundingClientRect(), h = r.getBoundingClientRect();
|
|
70
|
+
o.removeChild(t);
|
|
71
|
+
const a = {
|
|
72
|
+
top: o.clientHeight / 2,
|
|
73
|
+
left: o.clientWidth / 2
|
|
31
74
|
};
|
|
32
75
|
return {
|
|
33
|
-
left:
|
|
34
|
-
top:
|
|
35
|
-
width:
|
|
36
|
-
height:
|
|
76
|
+
left: h.left - c.left - a.left,
|
|
77
|
+
top: h.top - c.top - a.top,
|
|
78
|
+
width: h.width,
|
|
79
|
+
height: h.height
|
|
37
80
|
};
|
|
38
81
|
};
|
|
39
82
|
export {
|
|
40
|
-
|
|
83
|
+
f as getElementPagePosition
|
|
41
84
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as E, useCallback as h, useEffect as A } from "react";
|
|
2
2
|
import { appConsole as l } from "../appConsole.js";
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2025-11-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-11-12T11:44:56.569Z"), d = "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. ${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