@pdf-viewer/react 1.6.0-beta.1 → 1.6.0-beta.10

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 (77) hide show
  1. package/dist/RPDefaultLayout-4518b3d3.js +3059 -0
  2. package/dist/{SearchCloseButton-d6135e7c.js → SearchCloseButton-959cc1ed.js} +11 -11
  3. package/dist/assets/Container.css +1 -1
  4. package/dist/assets/PasswordModal.css +1 -0
  5. package/dist/assets/RPDefaultLayout.css +1 -1
  6. package/dist/assets/SearchCloseButton.css +1 -1
  7. package/dist/components/RPController.js +1 -1
  8. package/dist/components/RPPages.js +4 -2
  9. package/dist/components/RPProvider.js +13 -12
  10. package/dist/components/layout/Container.js +7 -6
  11. package/dist/components/layout/LayoutContainer.js +3 -2
  12. package/dist/components/layout/RPDefaultLayout.js +1 -1
  13. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  14. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  15. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  16. package/dist/components/layout/toolbar/DocumentDialog.js +3 -2
  17. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  18. package/dist/components/layout/toolbar/MostPageTool.js +3 -2
  19. package/dist/components/layout/toolbar/OtherTool.js +1 -1
  20. package/dist/components/layout/toolbar/Paginate.js +1 -1
  21. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  22. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  23. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  24. package/dist/components/layout/toolbar/SearchCloseButton.js +1 -1
  25. package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
  26. package/dist/components/layout/toolbar/SearchTool.js +4 -3
  27. package/dist/components/layout/toolbar/ViewModeTool.js +18 -19
  28. package/dist/components/layout/toolbar/ZoomTool.js +7 -26
  29. package/dist/components/page/AnnotationLayer.js +3 -2
  30. package/dist/components/page/CanvasLayer.js +3 -2
  31. package/dist/components/page/DualPage.js +1 -1
  32. package/dist/components/page/RPPage.js +3 -2
  33. package/dist/components/page/SinglePage.js +1 -1
  34. package/dist/components/page/TextHighlightLayer.js +3 -2
  35. package/dist/components/page/TextLayer.js +3 -2
  36. package/dist/components/ui/LoadingIndicator.js +1 -1
  37. package/dist/components/ui/PasswordModal.js +58 -0
  38. package/dist/contexts/DocumentPasswordContext.js +40 -0
  39. package/dist/contexts/PaginationContext.js +1 -1
  40. package/dist/contexts/PrintContext.js +1 -1
  41. package/dist/contexts/RPDocumentContext.js +11 -8
  42. package/dist/contexts/SearchContext.js +1 -1
  43. package/dist/contexts/SmoothScrollContext.js +8 -9
  44. package/dist/contexts/ThumbnailsContext.js +1 -1
  45. package/dist/contexts/ToolbarComponentContext.js +2 -2
  46. package/dist/contexts/ViewModeContext.js +16 -17
  47. package/dist/contexts/ZoomContext.js +17 -16
  48. package/dist/main.js +1 -1
  49. package/dist/types/components/layout/toolbar/ViewModeTool.d.ts +1 -1
  50. package/dist/types/components/ui/PasswordModal.d.ts +3 -0
  51. package/dist/types/contexts/DocumentPasswordContext.d.ts +14 -0
  52. package/dist/types/contexts/SmoothScrollContext.d.ts +1 -3
  53. package/dist/types/utils/constants.d.ts +1 -0
  54. package/dist/types/utils/getScrollDistance.d.ts +1 -0
  55. package/dist/types/utils/getWordPositionInPage.d.ts +11 -0
  56. package/dist/types/utils/getZoomLevel.d.ts +2 -2
  57. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -0
  58. package/dist/types/utils/types.d.ts +20 -3
  59. package/dist/utils/constants.js +3 -2
  60. package/dist/utils/getScrollDistance.js +4 -0
  61. package/dist/utils/getWordPositionInPage.js +19 -0
  62. package/dist/utils/getZoomLevel.js +13 -9
  63. package/dist/utils/highlight.js +141 -126
  64. package/dist/utils/hooks/useFileDownload.js +3 -2
  65. package/dist/utils/hooks/useLicense.js +18 -18
  66. package/dist/utils/hooks/useLoadPdf.js +52 -40
  67. package/dist/utils/hooks/usePaginate.js +4 -2
  68. package/dist/utils/hooks/usePinch.js +68 -17
  69. package/dist/utils/hooks/usePresentPage.js +3 -2
  70. package/dist/utils/hooks/usePrint.js +3 -2
  71. package/dist/utils/hooks/useScrollToPage.js +4 -2
  72. package/dist/utils/hooks/useSearch.js +5 -3
  73. package/dist/utils/hooks/useThumbnail.js +3 -2
  74. package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
  75. package/dist/utils/types.js +4 -4
  76. package/package.json +1 -1
  77. package/dist/RPDefaultLayout-3a892bb5.js +0 -3041
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { t as i } from "../../RPDefaultLayout-3a892bb5.js";
3
+ import { t as i } from "../../RPDefaultLayout-4518b3d3.js";
4
4
  export {
5
5
  i as SinglePage
6
6
  };
@@ -2,7 +2,8 @@ import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "pdfjs-dist";
4
4
  import "../../contexts/RPDocumentContext.js";
5
- import { q as D } from "../../RPDefaultLayout-3a892bb5.js";
5
+ import "../../contexts/DocumentPasswordContext.js";
6
+ import { q as E } from "../../RPDefaultLayout-4518b3d3.js";
6
7
  import "../../contexts/DarkModeContext.js";
7
8
  import "../../contexts/RotationContext.js";
8
9
  import "../../contexts/LayerContext.js";
@@ -30,5 +31,5 @@ import "../RPDropFileZone.js";
30
31
  import "../../contexts/ToolbarComponentContext.js";
31
32
  import "../../utils/highlight.js";
32
33
  export {
33
- D as TextHighlightLayer
34
+ E as TextHighlightLayer
34
35
  };
@@ -1,7 +1,8 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../contexts/RPDocumentContext.js";
4
- import { p as E } from "../../RPDefaultLayout-3a892bb5.js";
4
+ import "../../contexts/DocumentPasswordContext.js";
5
+ import { p as F } from "../../RPDefaultLayout-4518b3d3.js";
5
6
  import "../../contexts/DarkModeContext.js";
6
7
  import "../../contexts/RotationContext.js";
7
8
  import "../../contexts/LayerContext.js";
@@ -30,5 +31,5 @@ import "../../contexts/ToolbarComponentContext.js";
30
31
  import "pdfjs-dist";
31
32
  import "../../utils/highlight.js";
32
33
  export {
33
- E as TextLayer
34
+ F as TextLayer
34
35
  };
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import { L as i } from "../../RPDefaultLayout-3a892bb5.js";
2
+ import { L as i } from "../../RPDefaultLayout-4518b3d3.js";
3
3
  import "../../clsx-0c6e471a.js";
4
4
  import "../../contexts/LocalizationContext.js";
5
5
  export {
@@ -0,0 +1,58 @@
1
+ import { jsx as a, jsxs as d } from "react/jsx-runtime";
2
+ import { useState as c } from "react";
3
+ import { c as o } from "../../clsx-0c6e471a.js";
4
+ import { useLocalizationContext as u } from "../../contexts/LocalizationContext.js";
5
+ import { useDocumentPasswordContext as _ } from "../../contexts/DocumentPasswordContext.js";
6
+ import '../../assets/PasswordModal.css';const r = {
7
+ "rp-password-overlay": "_rp-password-overlay_2kyt7_1",
8
+ "rp-password-modal": "_rp-password-modal_2kyt7_14",
9
+ "rp-password-title": "_rp-password-title_2kyt7_27",
10
+ "rp-password-content": "_rp-password-content_2kyt7_35",
11
+ "rp-password-form": "_rp-password-form_2kyt7_41",
12
+ "rp-password-input": "_rp-password-input_2kyt7_45",
13
+ "rp-password-input-invalid": "_rp-password-input-invalid_2kyt7_62",
14
+ "rp-password-message-invalid": "_rp-password-message-invalid_2kyt7_66",
15
+ "rp-password-submit-button": "_rp-password-submit-button_2kyt7_71"
16
+ }, k = () => {
17
+ const [t, e] = c(""), { localeMessages: s } = u(), { setPassword: l, invalidPassword: i } = _(), m = (p) => {
18
+ e(p.target.value);
19
+ }, n = (p) => {
20
+ p.preventDefault(), t && t.trim() && l(t);
21
+ }, w = !t.trim();
22
+ return /* @__PURE__ */ a("div", { className: o(r["rp-password-overlay"]), children: /* @__PURE__ */ d("div", { className: o(r["rp-password-modal"]), children: [
23
+ /* @__PURE__ */ a("div", { className: o(r["rp-password-title"]), children: s == null ? void 0 : s.passwordModalTitle }),
24
+ /* @__PURE__ */ a("div", { className: o(r["rp-password-content"]), children: s == null ? void 0 : s.passwordModalMessage }),
25
+ /* @__PURE__ */ d("form", { onSubmit: n, children: [
26
+ /* @__PURE__ */ d("div", { className: o(r["rp-password-form"]), children: [
27
+ /* @__PURE__ */ a(
28
+ "input",
29
+ {
30
+ type: "password",
31
+ value: t,
32
+ onChange: m,
33
+ className: o(
34
+ r["rp-password-input"],
35
+ i && r["rp-password-input-invalid"]
36
+ ),
37
+ placeholder: "Enter password",
38
+ autoComplete: "off"
39
+ }
40
+ ),
41
+ i && /* @__PURE__ */ a("div", { className: o(r["rp-password-message-invalid"]), children: "Incorrect password" })
42
+ ] }),
43
+ /* @__PURE__ */ a(
44
+ "button",
45
+ {
46
+ type: "submit",
47
+ disabled: w,
48
+ className: o(r["rp-password-submit-button"]),
49
+ onClick: n,
50
+ children: s == null ? void 0 : s.passwordConfirmLabel
51
+ }
52
+ )
53
+ ] })
54
+ ] }) });
55
+ };
56
+ export {
57
+ k as default
58
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx as P } from "react/jsx-runtime";
2
+ import { createContext as l, useState as r, useEffect as p, useMemo as m, useContext as f } from "react";
3
+ import { appConsole as v } from "../utils/appConsole.js";
4
+ const a = l({
5
+ password: void 0,
6
+ setPassword: () => {
7
+ },
8
+ passwordError: void 0,
9
+ setPasswordError: () => {
10
+ },
11
+ passwordRequired: void 0,
12
+ setPasswordRequired: () => {
13
+ },
14
+ invalidPassword: !1
15
+ }), q = ({
16
+ children: s
17
+ }) => {
18
+ const [e, n] = r(), [o, i] = r(), [t, c] = r(!1), [d, w] = r(!1);
19
+ p(() => {
20
+ w(o === "Incorrect Password");
21
+ }, [o]);
22
+ const u = m(() => ({
23
+ password: e,
24
+ setPassword: n,
25
+ passwordError: o,
26
+ setPasswordError: i,
27
+ passwordRequired: t,
28
+ setPasswordRequired: c,
29
+ invalidPassword: d
30
+ }), [e, o, t, d]);
31
+ return /* @__PURE__ */ P(a.Provider, { value: u, children: s });
32
+ }, D = () => {
33
+ const s = f(a);
34
+ return s || v.error("Please use this hooks inside children component of DocumentPasswordContext"), s;
35
+ };
36
+ export {
37
+ q as DocumentPasswordProvider,
38
+ a as default,
39
+ D as useDocumentPasswordContext
40
+ };
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { h as e, P as m, u as p } from "../RPDefaultLayout-3a892bb5.js";
3
+ import { h as e, P as m, u as p } from "../RPDefaultLayout-4518b3d3.js";
4
4
  import "./RPDocumentContext.js";
5
5
  import "../utils/appConsole.js";
6
6
  export {
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { j as e, a as n, d as a } from "../RPDefaultLayout-3a892bb5.js";
3
+ import { j as e, a as n, d as a } from "../RPDefaultLayout-4518b3d3.js";
4
4
  export {
5
5
  e as PrintContext,
6
6
  n as PrintProvider,
@@ -19,21 +19,24 @@ const m = C({
19
19
  onLoadError: c,
20
20
  onLoaded: P
21
21
  }) => {
22
- const [o, n] = l(e), { pdf: r, pages: s, loading: i, loadingProgress: p } = D(o, u, { onLoadError: c, onLoaded: P }), [d, f] = l(), a = F(o, r, d);
22
+ const [o, n] = l(e), [s, i] = l(), { pdf: r, pages: p, loading: d, loadingProgress: f } = D(o, u, {
23
+ onLoadError: c,
24
+ onLoaded: P
25
+ }), a = F(o, r, s);
23
26
  h(() => {
24
- f(e == null ? void 0 : e.split("/").pop()), n(e);
27
+ i(e == null ? void 0 : e.split("/").pop()), n(e);
25
28
  }, [e]);
26
29
  const g = S(() => ({
27
30
  pdf: r,
28
- pages: s,
31
+ pages: p,
29
32
  pdfSrc: o,
30
33
  setPdfSrc: n,
31
34
  pdfProperties: a,
32
- setFilename: f,
33
- filename: d,
34
- loading: i,
35
- loaderProgress: p
36
- }), [r, s, o, a, i, p]);
35
+ setFilename: i,
36
+ filename: s,
37
+ loading: d,
38
+ loaderProgress: f
39
+ }), [r, p, o, a, d, f]);
37
40
  return /* @__PURE__ */ x(m.Provider, { value: g, children: o ? t : null });
38
41
  }, b = () => {
39
42
  const t = v(m);
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { o as a, S as s, e as S } from "../RPDefaultLayout-3a892bb5.js";
3
+ import { o as a, S as s, e as S } from "../RPDefaultLayout-4518b3d3.js";
4
4
  export {
5
5
  a as SearchContext,
6
6
  s as SearchProvider,
@@ -1,12 +1,11 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { createContext as c, useRef as o, useContext as s } from "react";
3
- const t = c({
4
- smoothScrolling: { current: !1 },
5
- targetScrollPosition: { current: { left: 0, top: 0 } }
6
- }), m = ({ children: r }) => {
7
- const e = o(!1), l = o({ left: 0, top: 0 });
8
- return /* @__PURE__ */ n(t.Provider, { value: { smoothScrolling: e, targetScrollPosition: l }, children: r });
9
- }, u = () => s(t);
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { createContext as c, useRef as l, useContext as n } from "react";
3
+ const o = c({
4
+ targetScrollPage: { current: void 0 }
5
+ }), m = ({ children: t }) => {
6
+ const r = l();
7
+ return /* @__PURE__ */ e(o.Provider, { value: { targetScrollPage: r }, children: t });
8
+ }, u = () => n(o);
10
9
  export {
11
10
  m as SmoothScrollProvider,
12
11
  u as useSmoothScrollContext
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { l as i, T as r, m as e } from "../RPDefaultLayout-3a892bb5.js";
3
+ import { l as i, T as r, m as e } from "../RPDefaultLayout-4518b3d3.js";
4
4
  export {
5
5
  i as ThumbnailContext,
6
6
  r as ThumbnailProvider,
@@ -8,7 +8,7 @@ const e = l({
8
8
  openFileTool: !0,
9
9
  dropFileZone: !0,
10
10
  downloadTool: !0,
11
- viewModeTool: !0,
11
+ // viewModeTool: true,
12
12
  scrollModeTool: !0,
13
13
  printTool: !0,
14
14
  showPrintProgress: !0,
@@ -23,7 +23,7 @@ const e = l({
23
23
  openFileTool: !0,
24
24
  dropFileZone: !0,
25
25
  downloadTool: !0,
26
- viewModeTool: !0,
26
+ // viewModeTool: true,
27
27
  scrollModeTool: !0,
28
28
  printTool: !0,
29
29
  thumbnailTool: !0,
@@ -1,28 +1,27 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { createContext as m, useContext as d, useState as P, useCallback as i, useMemo as C } from "react";
3
- import { appConsole as p } from "../utils/appConsole.js";
4
- import { ViewMode as e } from "../utils/types.js";
5
- import { useInitialStateContext as f } from "./InitialStateContext.js";
6
- const r = m({
2
+ import { createContext as m, useContext as a, useState as d, useCallback as r, useMemo as P } from "react";
3
+ import { appConsole as C } from "../utils/appConsole.js";
4
+ import { ViewMode as t } from "../utils/types.js";
5
+ const s = m({
7
6
  columnCount: 1,
8
7
  setSinglePage: () => {
9
8
  },
10
9
  setDualPage: () => {
11
10
  },
12
- viewMode: e.SINGLE_PAGE
13
- }), w = () => {
14
- const o = d(r);
15
- return typeof o.columnCount > "u" && p.error("Please use this hooks inside children component of RPProvider"), o;
16
- }, g = ({ children: o }) => {
17
- const { initialViewMode: s = e.SINGLE_PAGE } = f(), [t, n] = P(s === e.SINGLE_PAGE ? 1 : 2), u = i(() => {
11
+ viewMode: t.SINGLE_PAGE
12
+ }), g = () => {
13
+ const e = a(s);
14
+ return typeof e.columnCount > "u" && C.error("Please use this hooks inside children component of RPProvider"), e;
15
+ }, v = ({ children: e }) => {
16
+ const [o, n] = d(1), i = r(() => {
18
17
  n(1);
19
- }, []), c = i(() => {
18
+ }, []), u = r(() => {
20
19
  n(2);
21
- }, []), a = C(() => t === 1 ? e.SINGLE_PAGE : e.DUAL_PAGE, [t]);
22
- return /* @__PURE__ */ l(r.Provider, { value: { columnCount: t, setSinglePage: u, setDualPage: c, viewMode: a }, children: o });
20
+ }, []), c = P(() => o === 1 ? t.SINGLE_PAGE : t.DUAL_PAGE, [o]);
21
+ return /* @__PURE__ */ l(s.Provider, { value: { columnCount: o, setSinglePage: i, setDualPage: u, viewMode: c }, children: e });
23
22
  };
24
23
  export {
25
- r as ViewModeContext,
26
- g as ViewModeProvider,
27
- w as useViewModeContext
24
+ s as ViewModeContext,
25
+ v as ViewModeProvider,
26
+ g as useViewModeContext
28
27
  };
@@ -1,46 +1,47 @@
1
- import { jsx as P } from "react/jsx-runtime";
2
- import { createContext as v, useContext as C, useState as L, useMemo as s, useEffect as y } from "react";
3
- import { ZoomLevel as S } from "../utils/types.js";
1
+ import { jsx as C } from "react/jsx-runtime";
2
+ import { createContext as P, useContext as L, useState as y, useMemo as s, useEffect as S } from "react";
3
+ import { ZoomLevel as V } from "../utils/types.js";
4
4
  import { appConsole as b } from "../utils/appConsole.js";
5
5
  import { useInitialStateContext as A } from "./InitialStateContext.js";
6
6
  import { useDocumentContext as D } from "./RPDocumentContext.js";
7
7
  import { PAGE_PADDING as f } from "../utils/constants.js";
8
8
  import { getZoomLevel as E } from "../utils/getZoomLevel.js";
9
9
  import { useLayoutContainer as G } from "./LayoutContainerContext.js";
10
- const g = v({
10
+ import { useViewModeContext as H } from "./ViewModeContext.js";
11
+ const g = P({
11
12
  zoomLevel: 100,
12
13
  currentZoom: 1,
13
14
  setZoomLevel: () => {
14
15
  }
15
- }), M = () => {
16
- const n = C(g);
16
+ }), T = () => {
17
+ const n = L(g);
17
18
  return typeof n.currentZoom != "number" && b.warn("Please use this hooks inside children component of RPProvider"), n;
18
- }, N = ({ children: n }) => {
19
+ }, q = ({ children: n }) => {
19
20
  const {
20
- initialScale: r = S.PAGE_FIT,
21
+ initialScale: r = V.PAGE_FIT,
21
22
  initialPage: u = 1,
22
23
  initialRotation: l = 0
23
- } = A(), [i, a] = L(typeof r == "number" ? r : 100), { pages: c } = D(), { contentRef: o } = G(), p = s(() => i / 100, [i]), t = s(() => {
24
+ } = A(), [i, a] = y(typeof r == "number" ? r : 100), { pages: c } = D(), { contentRef: o } = G(), { viewMode: h } = H(), p = s(() => i / 100, [i]), t = s(() => {
24
25
  let e = c.get(u);
25
26
  return e || (e = c.get(1)), e == null ? void 0 : e.page.getViewport({ scale: 1, rotation: l });
26
27
  }, [c, u, l]), m = s(() => {
27
28
  if (!t)
28
29
  return 0;
29
- const e = ((t == null ? void 0 : t.width) || 0) + 2 * f, x = ((t == null ? void 0 : t.height) || 0) + 2 * f, Z = (o == null ? void 0 : o.clientWidth) || 0, d = (o == null ? void 0 : o.clientHeight) || 0;
30
- return E(r, Z, d, e, x);
30
+ const e = ((t == null ? void 0 : t.width) || 0) + 2 * f, x = ((t == null ? void 0 : t.height) || 0) + 2 * f, Z = (o == null ? void 0 : o.clientWidth) || 0, v = (o == null ? void 0 : o.clientHeight) || 0;
31
+ return E(r, Z, v, e, x, h);
31
32
  }, [t, r, o]);
32
- y(() => {
33
+ S(() => {
33
34
  typeof m == "number" && m && a(m);
34
35
  }, [m]);
35
- const h = s(() => ({
36
+ const d = s(() => ({
36
37
  zoomLevel: i,
37
38
  currentZoom: p,
38
39
  setZoomLevel: a
39
40
  }), [p, i]);
40
- return /* @__PURE__ */ P(g.Provider, { value: h, children: n });
41
+ return /* @__PURE__ */ C(g.Provider, { value: d, children: n });
41
42
  };
42
43
  export {
43
44
  g as ZoomContext,
44
- N as ZoomProvider,
45
- M as useZoomContext
45
+ q as ZoomProvider,
46
+ T as useZoomContext
46
47
  };
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RPProvider as t } from "./components/RPProvider.js";
2
- import { b as x, R as n, c as s, u as m, d as p, e as f } from "./RPDefaultLayout-3a892bb5.js";
2
+ import { b as x, R as n, c as s, u as m, d as p, e as f } from "./RPDefaultLayout-4518b3d3.js";
3
3
  import { RPConfig as a } from "./components/RPConfig.js";
4
4
  import { RPController as l } from "./components/RPController.js";
5
5
  import { RPTheme as P } from "./components/RPTheme.js";
@@ -1 +1 @@
1
- export declare const ViewModeTool: () => import("react/jsx-runtime").JSX.Element | null;
1
+ export declare const ViewModeTool: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ declare const PasswordModal: FC;
3
+ export default PasswordModal;
@@ -0,0 +1,14 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ export interface DocumentPasswordContextType {
3
+ password?: string;
4
+ setPassword: React.Dispatch<React.SetStateAction<string | undefined>>;
5
+ passwordError?: string;
6
+ setPasswordError: React.Dispatch<React.SetStateAction<string | undefined>>;
7
+ passwordRequired?: boolean;
8
+ setPasswordRequired: React.Dispatch<React.SetStateAction<boolean | undefined>>;
9
+ invalidPassword?: boolean;
10
+ }
11
+ declare const DocumentPasswordContext: React.Context<DocumentPasswordContextType>;
12
+ export declare const DocumentPasswordProvider: FC<PropsWithChildren>;
13
+ export declare const useDocumentPasswordContext: () => DocumentPasswordContextType;
14
+ export default DocumentPasswordContext;
@@ -1,7 +1,5 @@
1
- import { ScrollPosition } from '../utils/types';
2
1
  interface SmoothScrollContextType {
3
- smoothScrolling: React.MutableRefObject<boolean>;
4
- targetScrollPosition: React.MutableRefObject<ScrollPosition>;
2
+ targetScrollPage: React.MutableRefObject<number | undefined>;
5
3
  }
6
4
  export declare const SmoothScrollProvider: ({ children }: {
7
5
  children: React.ReactNode;
@@ -1,2 +1,3 @@
1
1
  export declare const PAGE_PADDING = 4;
2
2
  export declare const THUMBNAIL_MIN_WIDTH = 200;
3
+ export declare const SCROLL_BAR_WIDTH = 20;
@@ -0,0 +1 @@
1
+ export declare const getScrollDistance: (distanceList: number[], targetIndex: number) => number;
@@ -0,0 +1,11 @@
1
+ import { WordPositionRect } from './types';
2
+ export declare const getWordPositionInPage: (matchPageDimension: {
3
+ width: number;
4
+ height: number;
5
+ }, space: {
6
+ top: number;
7
+ left: number;
8
+ }, wordPosition: WordPositionRect, scale: number, rotation: number) => {
9
+ leftInPage: number;
10
+ topInPage: number;
11
+ };
@@ -1,2 +1,2 @@
1
- import { ZoomLevel } from './types';
2
- export declare const getZoomLevel: (zoomLevel: number | ZoomLevel, clientWidth: number, clientHeight: number, pageWidth: number, pageHeight: number) => number;
1
+ import { ZoomLevel, ViewMode } from './types';
2
+ export declare const getZoomLevel: (zoomLevel: number | ZoomLevel, clientWidth: number, clientHeight: number, pageWidth: number, pageHeight: number, viewMode: ViewMode) => number;
@@ -5,4 +5,6 @@ export declare const useLoadPdf: (src?: RPSrc, characterMap?: CharacterMap, opti
5
5
  pages: Map<number, PdfPage>;
6
6
  loading: boolean;
7
7
  loadingProgress: number;
8
+ passwordRequired: boolean | undefined;
9
+ passwordError: string | undefined;
8
10
  };
@@ -140,6 +140,11 @@ export type Localization = {
140
140
  propertiesPDFVersionLabel?: string;
141
141
  propertiesPageCountLabel?: string;
142
142
  thumbnailTooltip?: string;
143
+ passwordModalTitle?: string;
144
+ passwordModalMessage?: string;
145
+ passwordPlaceholder?: string;
146
+ passwordConfirmLabel?: string;
147
+ passwordError?: string;
143
148
  dragDropFileMessage?: string;
144
149
  };
145
150
  interface Attachment {
@@ -324,7 +329,6 @@ export interface RPSlots {
324
329
  dropFileZone?: boolean | React.ReactNode | React.ComponentType;
325
330
  downloadTool?: boolean | FC<DownloadToolProps>;
326
331
  zoomTool?: boolean | FC<ZoomProps>;
327
- viewModeTool?: boolean;
328
332
  scrollModeTool?: boolean;
329
333
  thumbnailTool?: boolean | FC<ThumbnailToolProps>;
330
334
  pageNavigationTool?: boolean | FC<PageNavigationToolProps>;
@@ -446,7 +450,13 @@ export declare enum ThemeVariables {
446
450
  TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius",
447
451
  CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color",
448
452
  TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color",
449
- TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius"
453
+ TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius",
454
+ PASSWORD_MODAL_BACKGROUND = "--rp-password-background",
455
+ PASSWORD_MODAL_TITLE_COLOR = "--rp-password-title-color",
456
+ PASSWORD_MODAL_CONTENT_COLOR = "--rp-password-content-color",
457
+ CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width",
458
+ CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color",
459
+ CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset"
450
460
  }
451
461
  export interface DarkModeProviderProps extends PropsWithChildren, Partial<Omit<DarkMode, 'setDarkMode'>> {
452
462
  }
@@ -500,7 +510,7 @@ export interface ZoomContextType {
500
510
  export type ZoomProps = Omit<ZoomContextType, 'currentZoom'>;
501
511
  export type InitialStateContextType = {
502
512
  instanceId: string;
503
- } & ZoomProviderProps & PageProviderProps & ViewModeProps & ScrollModeProps & RotateProviderProps;
513
+ } & ZoomProviderProps & PageProviderProps & ScrollModeProps & RotateProviderProps;
504
514
  export interface ZoomProviderProps {
505
515
  initialScale?: number | ZoomLevel;
506
516
  }
@@ -532,6 +542,12 @@ export interface ScrollModeContextType {
532
542
  export interface ScrollModeProps {
533
543
  initialScrollMode?: ScrollMode;
534
544
  }
545
+ export interface WordPositionRect {
546
+ left: number;
547
+ top: number;
548
+ width: number;
549
+ height: number;
550
+ }
535
551
  export interface Match {
536
552
  start: {
537
553
  idx: number;
@@ -544,6 +560,7 @@ export interface Match {
544
560
  str: string;
545
561
  oIndex: number;
546
562
  pageIndex: number;
563
+ rect: WordPositionRect;
547
564
  }
548
565
  export interface MatchValue extends Match {
549
566
  page: number;
@@ -1,5 +1,6 @@
1
- const I = 4, o = 200;
1
+ const I = 4, _ = 200, o = 20;
2
2
  export {
3
3
  I as PAGE_PADDING,
4
- o as THUMBNAIL_MIN_WIDTH
4
+ o as SCROLL_BAR_WIDTH,
5
+ _ as THUMBNAIL_MIN_WIDTH
5
6
  };
@@ -0,0 +1,4 @@
1
+ const o = (e, t) => e.reduce((r, n, u) => u < t ? r + n : r, 0);
2
+ export {
3
+ o as getScrollDistance
4
+ };
@@ -0,0 +1,19 @@
1
+ const a = (n, c) => {
2
+ const t = c * (Math.PI / 180);
3
+ return {
4
+ x: n.x * Math.cos(t) - n.y * Math.sin(t),
5
+ y: n.x * Math.sin(t) + n.y * Math.cos(t)
6
+ };
7
+ }, W = (n, c, t, e, h) => {
8
+ const s = t.height * e, r = t.width * e, f = t.top * e, g = t.left * e, M = n.height - f, { x: p, y: i } = a(
9
+ { x: r, y: s },
10
+ h
11
+ ), d = c.left + Math.abs(p) / 2, x = c.top + Math.abs(i) / 2, { x: y, y: u } = a({ x: g, y: M }, h), o = {
12
+ left: y,
13
+ top: u
14
+ }, P = o.left - d, I = o.top - x;
15
+ return { leftInPage: P, topInPage: I };
16
+ };
17
+ export {
18
+ W as getWordPositionInPage
19
+ };
@@ -1,20 +1,24 @@
1
- import { ZoomLevel as t } from "./types.js";
2
- const c = (o, r, m, e, s) => {
1
+ import { SCROLL_BAR_WIDTH as s } from "./constants.js";
2
+ import { ZoomLevel as e, ViewMode as c } from "./types.js";
3
+ const Z = (o, t, m, r, a, u) => {
3
4
  if (typeof o == "number")
4
5
  return o;
5
6
  switch (o) {
6
- case t.ACTUAL:
7
+ case e.ACTUAL:
7
8
  return 100;
8
- case t.PAGE_FIT:
9
+ case e.PAGE_FIT:
9
10
  let n = 0;
10
- const f = r > m;
11
- return s > e && f ? n = m / s : n = r / e, Math.floor(n * 100);
12
- case t.PAGE_WIDTH:
13
- return Math.floor(r / e * 100);
11
+ const l = u === c.DUAL_PAGE ? 2 * r : r;
12
+ return n = Math.min(
13
+ (t - s) / l,
14
+ m / a
15
+ ), Math.floor(n * 100);
16
+ case e.PAGE_WIDTH:
17
+ return Math.floor(t / r * 100);
14
18
  default:
15
19
  return 100;
16
20
  }
17
21
  };
18
22
  export {
19
- c as getZoomLevel
23
+ Z as getZoomLevel
20
24
  };