@pdf-viewer/react 1.12.0-beta.4 → 1.12.0-rc.1

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 k } from "react/jsx-runtime";
2
- import { createContext as z, useState as H, useCallback as d, useContext as N, useRef as U, useMemo as q } from "react";
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 = z(void 0), Ve = ({ children: l }) => {
35
- const [s, m] = H({}), { 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(
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, W = f % E, j = Math.floor(f / E);
47
- p = w(r, j), P = w(t, W);
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__ */ k(
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 = N(S), { type: s, validating: m } = Q(), t = U(0), r = q(() => {
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
- const g = (l, s, c, h, a) => {
2
- let r = "center";
3
- switch (h) {
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
- r = `${l.width / 2}px ${l.width / 2}px`;
48
+ n = `${e.width / 2}px ${e.width / 2}px`;
6
49
  break;
7
50
  case -90:
8
51
  case 270:
9
- r = `${l.height / 2}px ${l.height / 2}px`;
52
+ n = `${e.height / 2}px ${e.height / 2}px`;
10
53
  break;
11
54
  default:
12
- r = "center";
55
+ n = "center";
13
56
  }
14
57
  const t = document.createElement("div");
15
- t.id = "parent-element", t.style.width = `${l.width}px`, t.style.height = `${l.height}px`, t.style.setProperty("--scale-factor", a.toString()), t.style.setProperty("--rotation", h.toString()), t.style.setProperty("--transform-origin", r), t.style.left = "-99999px", t.style.visibility = "hidden", t.style.position = "absolute";
16
- const i = document.createElement("div");
17
- i.style.position = "relative", i.style.width = "100%", i.style.height = "100%", t.appendChild(i);
18
- let e;
19
- if (c instanceof HTMLElement)
20
- e = c.cloneNode(!0), i.appendChild(e);
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 o = c.props;
23
- e = document.createElement("div"), o.style && Object.assign(e.style, o.style), o.className && (e.className = o.className), i.appendChild(e);
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
- s.appendChild(t);
26
- const d = t.getBoundingClientRect(), n = e.getBoundingClientRect();
27
- s.removeChild(t);
28
- const p = {
29
- top: s.clientHeight / 2,
30
- left: s.clientWidth / 2
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: n.left - d.left - p.left + n.width / 2,
34
- top: n.top - d.top - p.top + n.height / 2,
35
- width: n.width,
36
- height: n.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
- g as getElementPagePosition
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-07T07:01:42.875Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2025-11-11T07:26:49.211Z"), 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
@@ -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.12.0-beta.4",
5
+ "version": "1.12.0-rc.1",
6
6
  "keywords": [
7
7
  "react-pdf",
8
8
  "react-pdf-viewer",