@pdf-viewer/react 1.15.0-beta.3 → 1.15.0-beta.4

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,20 +1,20 @@
1
- import { sanitizeExternalUrl as L } from "./sanitizeExternalUrl.js";
2
- import { AnnotationSubType as _, AnnotationType as l } from "./types.js";
1
+ import { sanitizeExternalUrl as _ } from "./sanitizeExternalUrl.js";
2
+ import { AnnotationSubType as E, AnnotationType as u } from "./types.js";
3
3
  import { dateFormatter as I } from "./dateFormatter.js";
4
4
  import "../th_TH-d627cd51.js";
5
- const v = ["click", "dblclick", "input", "change"], g = /* @__PURE__ */ new Map(), E = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
5
+ const v = ["click", "dblclick", "input", "change"], b = /* @__PURE__ */ new Map(), L = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
6
6
  function x(e, t) {
7
- const n = E(e, t);
8
- return g.has(n) ? g.get(n) ?? null : null;
7
+ const n = L(e, t);
8
+ return b.has(n) ? b.get(n) ?? null : null;
9
9
  }
10
10
  const B = (e, t, n) => {
11
- g.set(E(e, t), n);
11
+ b.set(L(e, t), n);
12
12
  }, O = (e, t) => {
13
13
  switch (t[1].name) {
14
14
  case "XYZ":
15
15
  return {
16
- bottomOffset: (n, a) => t[3] === null ? a : t[3],
17
- leftOffset: (n, a) => t[2] === null ? 0 : t[2],
16
+ bottomOffset: (n, s) => t[3] === null ? s : t[3],
17
+ leftOffset: (n, s) => t[2] === null ? 0 : t[2],
18
18
  pageIndex: e,
19
19
  scaleTo: t[4]
20
20
  };
@@ -43,15 +43,15 @@ const B = (e, t, n) => {
43
43
  };
44
44
  }
45
45
  };
46
- async function b(e, t) {
46
+ async function h(e, t) {
47
47
  let n;
48
48
  if (typeof t == "string" ? n = await e.getDestination(t) : n = t, n && typeof n[0] == "object" && n[0] !== null) {
49
- const a = n[0], s = x(e, a);
50
- if (s === null) {
51
- const r = await e.getPageIndex(a);
52
- return B(e, a, r), await b(e, n);
49
+ const s = n[0], a = x(e, s);
50
+ if (a === null) {
51
+ const r = await e.getPageIndex(s);
52
+ return B(e, s, r), await h(e, n);
53
53
  } else
54
- return O(s, n);
54
+ return O(a, n);
55
55
  } else
56
56
  return O(n[0], n);
57
57
  }
@@ -59,40 +59,40 @@ const M = (e) => {
59
59
  const n = e.target.parentNode;
60
60
  if (!n)
61
61
  return;
62
- const a = new MutationObserver((s) => {
63
- s.forEach(() => {
62
+ const s = new MutationObserver((a) => {
63
+ a.forEach(() => {
64
64
  n.querySelectorAll(
65
65
  '[data-l10n-id="pdfjs-annotation-date-time-string"]'
66
66
  ).forEach((o) => {
67
- const c = o.getAttribute("data-l10n-args");
68
- if (c) {
67
+ const i = o.getAttribute("data-l10n-args");
68
+ if (i) {
69
69
  try {
70
- const { dateObj: i } = JSON.parse(c);
71
- i && (o.textContent = I(i));
70
+ const { dateObj: c } = JSON.parse(i);
71
+ c && (o.textContent = I(c));
72
72
  } catch {
73
73
  }
74
- a.disconnect();
74
+ s.disconnect();
75
75
  }
76
76
  });
77
77
  });
78
78
  });
79
- return a.observe(n, {
79
+ return s.observe(n, {
80
80
  childList: !0,
81
81
  // Watch for changes to child elements
82
82
  subtree: !0,
83
83
  // Watch all descendants, not just direct children
84
84
  attributes: !0
85
85
  // Watch for changes to attributes
86
- }), () => a.disconnect();
87
- }, P = (e, t, n, a) => {
86
+ }), () => s.disconnect();
87
+ }, P = (e, t, n, s) => {
88
88
  if (e.type !== "click")
89
89
  return;
90
- const s = e.target, r = s.getAttribute("data-element-id"), o = s.getAttribute("href");
90
+ const a = e.target, r = a.getAttribute("data-element-id"), o = a.getAttribute("href");
91
91
  if (o && o !== "#")
92
92
  return;
93
- const c = t.find((i) => i.id === r);
94
- !c || c.annotationType !== _.Link || c.dest && b(n, c.dest).then((i) => {
95
- a(i);
93
+ const i = t.find((c) => c.id === r);
94
+ !i || i.annotationType !== E.Link || i.dest && h(n, i.dest).then((c) => {
95
+ s(c);
96
96
  });
97
97
  };
98
98
  function U(e, t) {
@@ -104,36 +104,44 @@ function V(e, t) {
104
104
  e.removeEventListener(n, t);
105
105
  }
106
106
  function $(e) {
107
- const { id: t, url: n, unsafeUrl: a } = e;
108
- new MutationObserver((r, o) => {
107
+ const { id: t, url: n, unsafeUrl: s, dest: a } = e;
108
+ new MutationObserver((o, i) => {
109
109
  const c = document.querySelector(`[data-annotation-id="${t}"]`);
110
110
  if (c) {
111
- const i = c.querySelector("a"), p = L((n || a) ?? "", "");
112
- i && (i == null || i.setAttribute("target", "_blank"), i == null || i.setAttribute("href", p), i == null || i.setAttribute("rel", "noopener noreferrer")), o.disconnect();
111
+ const l = c.querySelector("a");
112
+ if (l)
113
+ if (a && !n && !s)
114
+ l == null || l.setAttribute("href", "#");
115
+ else if (n || s) {
116
+ const g = _((n || s) ?? "", "");
117
+ l == null || l.setAttribute("target", "_blank"), l == null || l.setAttribute("href", g), l == null || l.setAttribute("rel", "noopener noreferrer");
118
+ } else
119
+ l == null || l.setAttribute("href", "");
120
+ i.disconnect();
113
121
  }
114
122
  }).observe(document.body, { childList: !0, subtree: !0 });
115
123
  }
116
124
  function D(e, t, n) {
117
- const { rotation: a, scale: s } = t, r = a % 180 === 0;
125
+ const { rotation: s, scale: a } = t, r = s % 180 === 0;
118
126
  if (e.fieldType === "Btn" && e.pushButton) {
119
- const o = e.rect[2] - e.rect[0], c = e.rect[3] - e.rect[1], i = document.createElement("canvas");
120
- i.setAttribute("width", ((r ? o : c) * s).toString()), i.setAttribute("height", ((r ? c : o) * s).toString()), n.set(e.id, i);
127
+ const o = e.rect[2] - e.rect[0], i = e.rect[3] - e.rect[1], c = document.createElement("canvas");
128
+ c.setAttribute("width", ((r ? o : i) * a).toString()), c.setAttribute("height", ((r ? i : o) * a).toString()), n.set(e.id, c);
121
129
  }
122
130
  }
123
- function k(e) {
131
+ function S(e) {
124
132
  var r;
125
133
  let t = e;
126
134
  for (; t.tagName !== "SECTION"; )
127
135
  t = t.parentElement;
128
- const n = t.getAttribute("aria-haspopup") === "dialog", a = t.classList.contains("popupAnnotation");
129
- if (!n && !a)
136
+ const n = t.getAttribute("aria-haspopup") === "dialog", s = t.classList.contains("popupAnnotation");
137
+ if (!n && !s)
130
138
  return;
131
- let s = t.id || t.getAttribute("aria-controls");
132
- if (s || (s = (r = t.firstChild) == null ? void 0 : r.id), s && t.parentElement) {
133
- const o = t.parentElement.querySelector(`[aria-controls="${s}"]`);
134
- o && new MutationObserver((i, p) => {
135
- const h = document.querySelectorAll(".popupDate");
136
- h.length > 0 && (h.forEach((m) => {
139
+ let a = t.id || t.getAttribute("aria-controls");
140
+ if (a || (a = (r = t.firstChild) == null ? void 0 : r.id), a && t.parentElement) {
141
+ const o = t.parentElement.querySelector(`[aria-controls="${a}"]`);
142
+ o && new MutationObserver((c, l) => {
143
+ const g = document.querySelectorAll(".popupDate");
144
+ g.length > 0 && (g.forEach((m) => {
137
145
  if (m.innerHTML)
138
146
  return !1;
139
147
  const N = m.getAttribute("data-l10n-args");
@@ -141,31 +149,31 @@ function k(e) {
141
149
  const { date: y, time: A } = JSON.parse(N);
142
150
  y && A && (m.textContent = `${y}, ${A}`);
143
151
  }
144
- }), p.disconnect());
152
+ }), l.disconnect());
145
153
  }).observe(o, { childList: !0, subtree: !0 });
146
154
  }
147
155
  }
148
- function d(e, t, n) {
149
- const a = [];
156
+ function p(e, t, n) {
157
+ const s = [];
150
158
  if (n)
151
- for (const s of n)
152
- s[e] === t && a.push(s);
153
- return a;
159
+ for (const a of n)
160
+ a[e] === t && s.push(a);
161
+ return s;
154
162
  }
155
- function u(e, t) {
163
+ function f(e, t) {
156
164
  return { type: e, data: t };
157
165
  }
158
- async function S(e, t) {
166
+ async function w(e, t) {
159
167
  if (e.dest)
160
168
  if (typeof e.dest == "string") {
161
- const n = await b(t, e.dest);
162
- return u(l.INTERNAL_LINK, {
169
+ const n = await h(t, e.dest);
170
+ return f(u.INTERNAL_LINK, {
163
171
  referencedPage: n.pageIndex,
164
172
  offset: null
165
173
  });
166
174
  } else {
167
175
  const n = await t.getPageIndex(e.dest[0]);
168
- return u(l.INTERNAL_LINK, {
176
+ return f(u.INTERNAL_LINK, {
169
177
  referencedPage: n,
170
178
  offset: {
171
179
  left: e.dest[2],
@@ -174,7 +182,7 @@ async function S(e, t) {
174
182
  });
175
183
  }
176
184
  else if (e.url)
177
- return u(l.LINK, {
185
+ return f(u.LINK, {
178
186
  url: e.url,
179
187
  unsafeUrl: e.unsafeUrl
180
188
  });
@@ -182,113 +190,113 @@ async function S(e, t) {
182
190
  function T(e) {
183
191
  for (const t of e.getElementsByTagName("span")) {
184
192
  let n = t.textContent;
185
- const a = JSON.parse(t.dataset.l10nArgs ?? "{}");
193
+ const s = JSON.parse(t.dataset.l10nArgs ?? "{}");
186
194
  if (n)
187
- for (const s in a)
188
- n = n.replace(`{{${s}}}`, a[s]);
195
+ for (const a in s)
196
+ n = n.replace(`{{${a}}}`, s[a]);
189
197
  t.textContent = n;
190
198
  }
191
199
  }
192
- function w(e) {
193
- return u(l.FILE_ATTACHMENT, e.file);
200
+ function C(e) {
201
+ return f(u.FILE_ATTACHMENT, e.file);
194
202
  }
195
- function f(e, t) {
203
+ function d(e, t) {
196
204
  switch (e.type) {
197
205
  case "textarea":
198
206
  case "text":
199
- return u(l.FORM_TEXT, {
207
+ return f(u.FORM_TEXT, {
200
208
  fieldName: e.name,
201
209
  value: e.value
202
210
  });
203
211
  case "select-one":
204
212
  case "select-multiple":
205
213
  const n = [];
206
- for (const s of e.options)
214
+ for (const a of e.options)
207
215
  n.push({
208
- value: s.value,
209
- label: s.label
216
+ value: a.value,
217
+ label: a.label
210
218
  });
211
- const a = [];
212
- for (const s of e.selectedOptions)
213
- a.push({
214
- value: s.value,
215
- label: s.label
219
+ const s = [];
220
+ for (const a of e.selectedOptions)
221
+ s.push({
222
+ value: a.value,
223
+ label: a.label
216
224
  });
217
- return u(l.FORM_SELECT, {
225
+ return f(u.FORM_SELECT, {
218
226
  fieldName: e.name,
219
- value: a,
227
+ value: s,
220
228
  options: n
221
229
  });
222
230
  case "checkbox":
223
- return u(l.FORM_CHECKBOX, {
231
+ return f(u.FORM_CHECKBOX, {
224
232
  fieldName: e.name,
225
233
  checked: e.checked
226
234
  });
227
235
  case "radio":
228
- return u(l.FORM_RADIO, {
236
+ return f(u.FORM_RADIO, {
229
237
  fieldName: e.name,
230
238
  ...t
231
239
  });
232
240
  case "button":
233
- return u(l.FORM_BUTTON, {
241
+ return f(u.FORM_BUTTON, {
234
242
  fieldName: e.name,
235
243
  ...t
236
244
  });
237
245
  }
238
246
  }
239
247
  async function W(e, t, n) {
240
- var s;
241
- let a = e.target.parentNode;
242
- if (a.tagName === "DIV" && (a = a.firstChild), k(a), typeof a.className != "object")
243
- if (a.className === "linkAnnotation" && e.type === "click") {
244
- const r = (s = a.dataset) == null ? void 0 : s.annotationId;
248
+ var a;
249
+ let s = e.target.parentNode;
250
+ if (s.tagName === "DIV" && (s = s.firstChild), S(s), typeof s.className != "object")
251
+ if (s.className === "linkAnnotation" && e.type === "click") {
252
+ const r = (a = s.dataset) == null ? void 0 : a.annotationId;
245
253
  if (r) {
246
- const o = d("id", r, n);
254
+ const o = p("id", r, n);
247
255
  if (o.length)
248
- return await S(o[0], t);
256
+ return await w(o[0], t);
249
257
  }
250
258
  } else if (
251
259
  /* annotation.className.includes('popupAnnotation') || */
252
- a.className.includes("textAnnotation")
260
+ s.className.includes("textAnnotation")
253
261
  )
254
- T(a);
255
- else if (a.className.includes("fileAttachmentAnnotation")) {
256
- T(a);
257
- const r = a.dataset.annotationId;
262
+ T(s);
263
+ else if (s.className.includes("fileAttachmentAnnotation")) {
264
+ T(s);
265
+ const r = s.dataset.annotationId;
258
266
  if (r && e.type === "dblclick")
259
- return w(d("id", r, n)[0]);
260
- } else if (a.className.includes("textWidgetAnnotation") && e.type === "input") {
261
- let r = a.getElementsByTagName("input")[0];
262
- return r || (r = a.getElementsByTagName("textarea")[0]), f(r);
267
+ return C(p("id", r, n)[0]);
268
+ } else if (s.className.includes("textWidgetAnnotation") && e.type === "input") {
269
+ let r = s.getElementsByTagName("input")[0];
270
+ return r || (r = s.getElementsByTagName("textarea")[0]), d(r);
263
271
  } else {
264
- if (a.className.includes("choiceWidgetAnnotation") && e.type === "input")
265
- return f(a.getElementsByTagName("select")[0]);
266
- if (a.className.includes("buttonWidgetAnnotation checkBox") && e.type === "change")
267
- return f(a.getElementsByTagName("input")[0]);
268
- if (a.className.includes("buttonWidgetAnnotation radioButton") && e.type === "change") {
269
- const r = a.dataset.annotationId;
272
+ if (s.className.includes("choiceWidgetAnnotation") && e.type === "input")
273
+ return d(s.getElementsByTagName("select")[0]);
274
+ if (s.className.includes("buttonWidgetAnnotation checkBox") && e.type === "change")
275
+ return d(s.getElementsByTagName("input")[0]);
276
+ if (s.className.includes("buttonWidgetAnnotation radioButton") && e.type === "change") {
277
+ const r = s.dataset.annotationId;
270
278
  if (r) {
271
- const o = d("id", r, n)[0], c = [];
272
- for (const i of d(
279
+ const o = p("id", r, n)[0], i = [];
280
+ for (const c of p(
273
281
  "fieldName",
274
282
  o.fieldName,
275
283
  n
276
284
  ))
277
- i.buttonValue && c.push(i.buttonValue);
278
- return f(a.getElementsByTagName("input")[0], {
285
+ c.buttonValue && i.push(c.buttonValue);
286
+ return d(s.getElementsByTagName("input")[0], {
279
287
  value: o.buttonValue,
280
288
  defaultValue: o.fieldValue,
281
- options: c
289
+ options: i
282
290
  });
283
291
  }
284
- } else if (a.className.includes("buttonWidgetAnnotation pushButton") && e.type === "click") {
285
- const r = a.dataset.annotationId;
292
+ } else if (s.className.includes("buttonWidgetAnnotation pushButton") && e.type === "click") {
293
+ const r = s.dataset.annotationId;
286
294
  if (r) {
287
- const o = d("id", r, n)[0], { action: c } = o;
288
- return c && ["Print", "SaveAs"].includes(c) ? { type: l.BUTTON, data: o } : o.resetForm ? f(
295
+ const o = p("id", r, n)[0], { action: i } = o;
296
+ return i && ["Print", "SaveAs"].includes(i) ? { type: u.BUTTON, data: o } : o.resetForm ? d(
289
297
  { name: o.fieldName, type: "button" },
290
298
  { actions: o.actions, reset: !0 }
291
- ) : f(
299
+ ) : d(
292
300
  { name: o.fieldName, type: "button" },
293
301
  { actions: o.actions, reset: !1 }
294
302
  );
@@ -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-12-15T18:53:04.244Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2025-12-16T03:06:14.614Z"), 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.15.0-beta.3",
5
+ "version": "1.15.0-beta.4",
6
6
  "keywords": [
7
7
  "react-pdf",
8
8
  "react-pdf-viewer",