@pdf-viewer/react 1.6.0-rc.0 → 1.6.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,8 +1,9 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import { createContext as m, useContext as x, useState as C, useCallback as r } from "react";
1
+ import { jsx as D } from "react/jsx-runtime";
2
+ import { createContext as x, useContext as C, useState as P, useCallback as r } from "react";
3
3
  import { useDocumentContext as h } from "./RPDocumentContext.js";
4
- import { useToolbarComponentContext as P } from "./ToolbarComponentContext.js";
5
- const p = m({
4
+ import { useToolbarComponentContext as F } from "./ToolbarComponentContext.js";
5
+ import { useDocumentPasswordContext as v } from "./DocumentPasswordContext.js";
6
+ const p = x({
6
7
  dragging: !1,
7
8
  handleDragLeave: () => {
8
9
  },
@@ -10,34 +11,36 @@ const p = m({
10
11
  },
11
12
  handleDrop: () => {
12
13
  }
13
- }), T = () => x(p), Z = ({ children: i }) => {
14
- const [c, o] = C(!1), { setFilename: n, setPdfSrc: a } = h(), { openFileTool: s } = P(), f = r(
14
+ }), w = () => C(p), E = ({ children: i }) => {
15
+ const [c, o] = P(!1), { setFilename: n, setPdfSrc: a } = h(), { openFileTool: s } = F(), {
16
+ setPassword: f
17
+ } = v(), u = r(
15
18
  (e) => {
16
19
  var l;
17
20
  e.preventDefault(), e.stopPropagation(), o(!1);
18
21
  const t = (l = e.dataTransfer) == null ? void 0 : l.files[0];
19
22
  if (!t || t.type !== "application/pdf")
20
23
  return;
21
- const D = URL.createObjectURL(t);
22
- n(t.name), a(D);
24
+ const m = URL.createObjectURL(t);
25
+ n(t.name), a(m), f("");
23
26
  },
24
27
  [n, a]
25
- ), u = r(
28
+ ), g = r(
26
29
  (e) => {
27
30
  e.preventDefault(), e.stopPropagation(), s && o(!0);
28
31
  },
29
32
  [s]
30
- ), g = r((e) => {
33
+ ), d = r((e) => {
31
34
  e.preventDefault(), e.stopPropagation(), o(!1);
32
35
  }, []);
33
- return /* @__PURE__ */ d(
36
+ return /* @__PURE__ */ D(
34
37
  p.Provider,
35
38
  {
36
39
  value: {
37
40
  dragging: c,
38
- handleDragLeave: g,
39
- handleDragEnter: u,
40
- handleDrop: f
41
+ handleDragLeave: d,
42
+ handleDragEnter: g,
43
+ handleDrop: u
41
44
  },
42
45
  children: i
43
46
  }
@@ -45,6 +48,6 @@ const p = m({
45
48
  };
46
49
  export {
47
50
  p as DropFileZoneContext,
48
- Z as DropFileZoneProvider,
49
- T as useDropFileZoneContext
51
+ E as DropFileZoneProvider,
52
+ w as useDropFileZoneContext
50
53
  };
@@ -1,21 +1,24 @@
1
- import { jsxs as a, jsx as f } from "react/jsx-runtime";
2
- import { createContext as d, useRef as m, useContext as x } from "react";
3
- import { useDocumentContext as C } from "./RPDocumentContext.js";
4
- const i = d(null), y = ({ children: e }) => {
5
- const { setFilename: l, setPdfSrc: s } = C(), o = m(null), c = () => {
6
- var t;
7
- (t = o.current) == null || t.click();
8
- }, p = (t) => {
1
+ import { jsxs as f, jsx as m } from "react/jsx-runtime";
2
+ import { createContext as d, useRef as x, useContext as C } from "react";
3
+ import { useDocumentContext as F } from "./RPDocumentContext.js";
4
+ import { useDocumentPasswordContext as h } from "./DocumentPasswordContext.js";
5
+ const s = d(null), y = ({ children: t }) => {
6
+ const { setFilename: i, setPdfSrc: c } = F(), o = x(null), {
7
+ setPassword: l
8
+ } = h(), u = () => {
9
+ var e;
10
+ (e = o.current) == null || e.click();
11
+ }, p = (e) => {
9
12
  var r;
10
- const n = (r = t.target.files) == null ? void 0 : r[0];
13
+ const n = (r = e.target.files) == null ? void 0 : r[0];
11
14
  if (!n || n.type !== "application/pdf")
12
15
  return;
13
- const u = URL.createObjectURL(n);
14
- l(n.name), s(u);
16
+ const a = URL.createObjectURL(n);
17
+ i(n.name), c(a), e.target.value = "", l("");
15
18
  };
16
- return /* @__PURE__ */ a(i.Provider, { value: { openFile: c }, children: [
17
- e,
18
- /* @__PURE__ */ f(
19
+ return /* @__PURE__ */ f(s.Provider, { value: { openFile: u }, children: [
20
+ t,
21
+ /* @__PURE__ */ m(
19
22
  "input",
20
23
  {
21
24
  accept: "application/pdf",
@@ -27,10 +30,10 @@ const i = d(null), y = ({ children: e }) => {
27
30
  )
28
31
  ] });
29
32
  }, I = () => {
30
- const e = x(i);
31
- if (!e)
33
+ const t = C(s);
34
+ if (!t)
32
35
  throw new Error("useOpenFileContext must be used within FileInputProvider");
33
- return e;
36
+ return t;
34
37
  };
35
38
  export {
36
39
  y as FileInputProvider,
@@ -1,6 +1,6 @@
1
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-23T02:59:08.768Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2025-05-26T08:41:06.647Z"), 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}`,
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-rc.0",
5
+ "version": "1.6.0",
6
6
  "keywords": [
7
7
  "component",
8
8
  "frontend",