@react-pdf-kit/viewer 2.8.0-beta.7 → 2.8.0-beta.9
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.
- package/README.md +44 -30
- package/dist/{AnnotationLayer-Dl6VxRzL.js → AnnotationLayer-CyOYh0Tw.js} +1 -1
- package/dist/CanvasLayer-CJqCJ30J.js +111 -0
- package/dist/PaginationContext-DIzsZhFd.js +194 -0
- package/dist/RPPages-BQw330_L.js +655 -0
- package/dist/{Thumbnail-BVjnCNxv.js → Thumbnail-C6zkvwcs.js} +1 -1
- package/dist/{Thumbnails-CrKLESh3.js → Thumbnails-DKG6I7pb.js} +2 -2
- package/dist/assets/RPPages.css +1 -1
- package/dist/assets/style.js +1 -1
- package/dist/components/RPController.js +39 -39
- package/dist/components/RPPages.js +1 -1
- package/dist/components/RPProvider.js +1 -1
- package/dist/components/layout/LayoutContainer.js +6 -6
- package/dist/components/layout/LayoutWrapper.js +5 -5
- package/dist/components/layout/RPDefaultLayout.js +1 -1
- package/dist/components/layout/RPLayout.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/ScrollModeTool.js +4 -4
- package/dist/components/layout/toolbar/ToolbarCustom.js +1 -1
- package/dist/components/layout/toolbar/ToolbarDefault.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/NextPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +5 -5
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/CanvasLayer.js +1 -1
- package/dist/components/page/DualPage.js +1 -1
- package/dist/components/page/DualPageWithCover.js +1 -1
- package/dist/components/page/RPPage.js +18 -18
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextHighlightLayer.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/components/ui/PasswordModal.js +1 -1
- package/dist/contexts/ElementPageContext.js +46 -39
- package/dist/contexts/ElementThumbnailContext.js +1 -1
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +21 -17
- package/dist/contexts/RenderedPagesCache.js +32 -13
- package/dist/contexts/VirtualScrollContext.js +10 -13
- package/dist/{de_DE-C1OrwQKj.js → de_DE-x4Z-jQrz.js} +12 -0
- package/dist/{main-CdlJS0xf.js → main-7sMXtgRg.js} +1 -1
- package/dist/main.js +3 -3
- package/dist/style-CJtyyrJx.js +5 -0
- package/dist/types/components/page/CanvasLayer.d.ts +4 -1
- package/dist/types/contexts/RenderedPagesCache.d.ts +3 -0
- package/dist/types/contexts/VirtualScrollContext.d.ts +0 -3
- package/dist/types/locales/de_DE.json.d.ts +2 -0
- package/dist/types/locales/en_US.json.d.ts +2 -0
- package/dist/types/locales/it_IT.json.d.ts +2 -0
- package/dist/types/locales/pt_PT.json.d.ts +2 -0
- package/dist/types/locales/th_TH.json.d.ts +2 -0
- package/dist/types/locales/zh_CN.json.d.ts +2 -0
- package/dist/types/utils/const.d.ts +3 -0
- package/dist/types/utils/constants.d.ts +1 -0
- package/dist/types/utils/documentLayout.d.ts +60 -0
- package/dist/types/utils/hooks/usePresentPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +4 -1
- package/dist/utils/const.js +2 -2
- package/dist/utils/constants.js +2 -2
- package/dist/utils/documentLayout.js +141 -0
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +73 -63
- package/dist/utils/hooks/useLocalization.js +1 -1
- package/dist/utils/hooks/usePaginate.js +1 -1
- package/dist/utils/hooks/usePinch.js +56 -49
- package/dist/utils/hooks/usePresentPage.js +31 -59
- package/dist/utils/hooks/useScrollToPage.js +1 -1
- package/dist/utils/hooks/useSearch.js +66 -67
- package/dist/utils/types.js +2 -2
- package/package.json +1 -1
- package/dist/CanvasLayer-cRwL_IIT.js +0 -105
- package/dist/PaginationContext-B3qzCYJu.js +0 -235
- package/dist/RPPages-5yXo7yhq.js +0 -1307
- package/dist/contexts/VirtualGridContext.js +0 -18
- package/dist/style-CWQAmimK.js +0 -5
- package/dist/types/contexts/VirtualGridContext.d.ts +0 -9
- package/dist/types/utils/calculatePage.d.ts +0 -12
- package/dist/types/utils/hooks/useVirtualReactWindow.d.ts +0 -17
- package/dist/utils/calculatePage.js +0 -30
- package/dist/utils/hooks/useVirtualReactWindow.js +0 -86
- /package/dist/{PasswordModal-BW_C2ULg.js → PasswordModal-S0leMhEd.js} +0 -0
- /package/dist/{RPLayout.module-DCbTHUuG.js → RPLayout.module-BH5r8dDc.js} +0 -0
- /package/dist/{TextHighlightLayer-BSVgBxR3.js → TextHighlightLayer-3vIZbRyL.js} +0 -0
- /package/dist/{TextLayer-BdoXGj0Z.js → TextLayer-D-V9kogG.js} +0 -0
|
@@ -1,74 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useSmoothScrollContext as i } from "../../contexts/SmoothScrollContext.js";
|
|
6
|
-
import { getGridDimension as a, getPositionFromPage as o } from "../calculatePage.js";
|
|
7
|
-
import { r as s } from "../../PaginationContext-B3qzCYJu.js";
|
|
8
|
-
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
1
|
+
import { useDebounce as e } from "./useDebounce.js";
|
|
2
|
+
import { useSmoothScrollContext as t } from "../../contexts/SmoothScrollContext.js";
|
|
3
|
+
import { r as n } from "../../PaginationContext-DIzsZhFd.js";
|
|
4
|
+
import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
|
|
9
5
|
//#region lib/utils/hooks/usePresentPage.ts
|
|
10
|
-
var
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
let [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let a = x[i], s = o(i + 1, p, t), c = r.slice(0, s.columnIndex).reduce((e, t) => e + t, 0), l = n.slice(0, s.rowIndex).reduce((e, t) => e + t, 0), u = c + a, d = l + e;
|
|
20
|
-
return {
|
|
21
|
-
pageNumber: i + 1,
|
|
22
|
-
...s,
|
|
23
|
-
width: a,
|
|
24
|
-
height: e,
|
|
25
|
-
startX: c,
|
|
26
|
-
startY: l,
|
|
27
|
-
endX: u,
|
|
28
|
-
endY: d
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}, [
|
|
32
|
-
b,
|
|
33
|
-
x,
|
|
34
|
-
p,
|
|
35
|
-
m,
|
|
36
|
-
g
|
|
37
|
-
]);
|
|
38
|
-
l(() => {
|
|
39
|
-
D.length > 0 && !E.current && C.current(D[0].pageNumber);
|
|
40
|
-
let e = D[0]?.ratio, t = E.current;
|
|
41
|
-
e && D.some((e) => e.pageNumber === t) && (clearTimeout(v.current), v.current = setTimeout(() => {
|
|
42
|
-
E.current === t && (E.current = void 0);
|
|
6
|
+
var s = (s, c) => {
|
|
7
|
+
let l = a(), u = a(), { setFocusedPage: d } = n(), f = a(d);
|
|
8
|
+
f.current = d;
|
|
9
|
+
let [p, m] = o([]), { targetScrollPage: h } = t(), g = e(p, 0, 500);
|
|
10
|
+
i(() => {
|
|
11
|
+
g.length > 0 && !h.current && f.current(g[0].pageNumber);
|
|
12
|
+
let e = g[0]?.ratio, t = h.current;
|
|
13
|
+
e && g.some((e) => e.pageNumber === t) && (clearTimeout(u.current), u.current = setTimeout(() => {
|
|
14
|
+
h.current === t && (h.current = void 0);
|
|
43
15
|
}, 500));
|
|
44
|
-
}, [
|
|
45
|
-
clearTimeout(
|
|
16
|
+
}, [g, h]), i(() => () => {
|
|
17
|
+
clearTimeout(u.current), l.current && cancelAnimationFrame(l.current);
|
|
46
18
|
}, []);
|
|
47
|
-
let
|
|
48
|
-
|
|
19
|
+
let _ = r((e) => {
|
|
20
|
+
c && (l.current && cancelAnimationFrame(l.current), l.current = requestAnimationFrame(() => {
|
|
49
21
|
let t = e.target, n = {
|
|
50
|
-
startTop: t.scrollTop,
|
|
51
|
-
startLeft: t.scrollLeft,
|
|
52
|
-
endTop: t.scrollTop + t.clientHeight,
|
|
53
|
-
endLeft: t.scrollLeft + t.clientWidth
|
|
22
|
+
startTop: t.scrollTop - c.offsetTop,
|
|
23
|
+
startLeft: t.scrollLeft - c.offsetLeft,
|
|
24
|
+
endTop: t.scrollTop - c.offsetTop + t.clientHeight,
|
|
25
|
+
endLeft: t.scrollLeft - c.offsetLeft + t.clientWidth
|
|
54
26
|
};
|
|
55
|
-
|
|
56
|
-
let t = e.
|
|
27
|
+
m(c.pages.filter((e) => {
|
|
28
|
+
let t = e.left + e.width >= n.startLeft && e.top + e.height >= n.startTop, r = e.left <= n.endLeft && e.top <= n.endTop;
|
|
57
29
|
return t && r;
|
|
58
30
|
}).map((e) => {
|
|
59
|
-
let t =
|
|
31
|
+
let t = Math.max(n.startLeft, e.left), r = Math.max(n.startTop, e.top), i = Math.min(n.endLeft, e.left + e.width), a = Math.min(n.endTop, e.top + e.height), o = +(Math.max(0, i - t) * Math.max(0, a - r) / (e.width * e.height || 1) * 100).toFixed(2);
|
|
60
32
|
return {
|
|
61
33
|
pageNumber: e.pageNumber,
|
|
62
34
|
ratio: o
|
|
63
35
|
};
|
|
64
36
|
}).sort((e, t) => t.ratio - e.ratio));
|
|
65
|
-
});
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
|
|
37
|
+
}));
|
|
38
|
+
}, [c]);
|
|
39
|
+
i(() => {
|
|
40
|
+
if (s) return s?.addEventListener("scroll", _), _({ target: s }), () => {
|
|
41
|
+
s?.removeEventListener("scroll", _);
|
|
70
42
|
};
|
|
71
|
-
}, [
|
|
43
|
+
}, [s, _]);
|
|
72
44
|
};
|
|
73
45
|
//#endregion
|
|
74
|
-
export {
|
|
46
|
+
export { s as usePresentPage };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e } from "../../PaginationContext-
|
|
1
|
+
import { a as e } from "../../PaginationContext-DIzsZhFd.js";
|
|
2
2
|
export { e as useScrollToPage };
|
|
@@ -1,81 +1,80 @@
|
|
|
1
|
-
import { ScrollMode as e
|
|
2
|
-
import { useDocumentContext as
|
|
3
|
-
import { useScrollModeContext as
|
|
4
|
-
import { useViewModeContext as
|
|
5
|
-
import { useVirtualScrollContext as
|
|
6
|
-
import { useLayoutContainer as
|
|
7
|
-
import { useZoomContext as
|
|
8
|
-
import { usePagesRotateContext as
|
|
9
|
-
import { useDimensionPagesContext as
|
|
10
|
-
import { useSmoothScrollContext as
|
|
11
|
-
import {
|
|
12
|
-
import { r as f } from "../../PaginationContext-
|
|
1
|
+
import { ScrollMode as e } from "../types.js";
|
|
2
|
+
import { useDocumentContext as t } from "../../contexts/RPDocumentContext.js";
|
|
3
|
+
import { useScrollModeContext as n } from "../../contexts/ScrollModeContext.js";
|
|
4
|
+
import { useViewModeContext as r } from "../../contexts/ViewModeContext.js";
|
|
5
|
+
import { useVirtualScrollContext as i } from "../../contexts/VirtualScrollContext.js";
|
|
6
|
+
import { useLayoutContainer as a } from "../../contexts/LayoutContainerContext.js";
|
|
7
|
+
import { useZoomContext as o } from "../../contexts/ZoomContext.js";
|
|
8
|
+
import { usePagesRotateContext as s } from "../../contexts/PagesRotateContext.js";
|
|
9
|
+
import { useDimensionPagesContext as c } from "../../contexts/DimensionPagesContext.js";
|
|
10
|
+
import { useSmoothScrollContext as l } from "../../contexts/SmoothScrollContext.js";
|
|
11
|
+
import { buildDocumentLayout as u, getPagePlacement as d } from "../documentLayout.js";
|
|
12
|
+
import { r as f } from "../../PaginationContext-DIzsZhFd.js";
|
|
13
13
|
import { findMatches as p } from "../highlight.js";
|
|
14
14
|
import { getWordPositionInPage as m } from "../getWordPositionInPage.js";
|
|
15
15
|
import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
16
16
|
//#region lib/utils/hooks/useSearch.ts
|
|
17
17
|
var b = (b = {}, x = "") => {
|
|
18
|
-
let [S, C] = y(x), [w, T] = y(!1), { pdf: E, pages: D } =
|
|
19
|
-
if (
|
|
20
|
-
let
|
|
21
|
-
if (!
|
|
22
|
-
let
|
|
23
|
-
if (!
|
|
24
|
-
let
|
|
25
|
-
if (
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let
|
|
39
|
-
height: k[
|
|
40
|
-
width: O[
|
|
41
|
-
},
|
|
18
|
+
let [S, C] = y(x), [w, T] = y(!1), { pdf: E, pages: D } = t(), { widths: O, heights: k } = c(), A = v(!S), { currentZoom: j } = o(), [M, N] = y([]), { setFocusedPage: P } = f(), { viewMode: F } = r(), { pageRotate: I } = s(), [L, R] = y(0), { pageScrollElementRef: z, virtualScrollableElementRef: B } = i(), { scrollMode: V } = n(), { pagesRef: H } = a(), { scrollBehavior: U } = l(), W = v({}), G = v(0), K = _(() => L === 0 ? null : M[L - 1], [L, M]), q = _(() => M.length, [M]), J = h((t) => {
|
|
19
|
+
if (t === 0) return;
|
|
20
|
+
let n = M[t - 1];
|
|
21
|
+
if (!n || !D) return;
|
|
22
|
+
let r = B || z;
|
|
23
|
+
if (!r || !H) return;
|
|
24
|
+
let i = D.get(n.page);
|
|
25
|
+
if (V === e.PAGE_SCROLLING && P(n.page), !i) return;
|
|
26
|
+
let a = u({
|
|
27
|
+
pageDimensions: {
|
|
28
|
+
widths: O,
|
|
29
|
+
heights: k
|
|
30
|
+
},
|
|
31
|
+
viewportWidth: r.clientWidth,
|
|
32
|
+
viewportHeight: r.clientHeight,
|
|
33
|
+
scrollMode: V,
|
|
34
|
+
viewMode: F,
|
|
35
|
+
focusedPage: n.page
|
|
36
|
+
}), o = d(a, n.page);
|
|
37
|
+
if (!o) return;
|
|
38
|
+
let s = {
|
|
39
|
+
height: k[n.page - 1],
|
|
40
|
+
width: O[n.page - 1]
|
|
41
|
+
}, c = I[n.page], { leftInPage: l, topInPage: f } = m(s, H, n.rect, j, c), p = a.offsetLeft + o.left + l, h = a.offsetTop + o.top + f, g = {
|
|
42
42
|
left: Math.max(p, 0),
|
|
43
43
|
top: Math.max(h, 0)
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
r.scrollTo({
|
|
46
46
|
...g,
|
|
47
|
-
behavior:
|
|
47
|
+
behavior: U
|
|
48
48
|
});
|
|
49
49
|
}, [
|
|
50
50
|
D,
|
|
51
51
|
P,
|
|
52
52
|
O,
|
|
53
53
|
k,
|
|
54
|
-
H,
|
|
55
|
-
I,
|
|
56
|
-
F,
|
|
57
54
|
V,
|
|
55
|
+
F,
|
|
58
56
|
B,
|
|
59
|
-
|
|
57
|
+
z,
|
|
58
|
+
H,
|
|
60
59
|
M,
|
|
61
60
|
j,
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
I,
|
|
62
|
+
U
|
|
64
63
|
]);
|
|
65
64
|
g(() => {
|
|
66
|
-
|
|
67
|
-
}, [
|
|
68
|
-
let
|
|
69
|
-
|
|
65
|
+
L && J(L);
|
|
66
|
+
}, [L]);
|
|
67
|
+
let Y = h(() => {
|
|
68
|
+
R((e) => {
|
|
70
69
|
let t;
|
|
71
|
-
return t =
|
|
72
|
-
}),
|
|
73
|
-
}, [
|
|
74
|
-
|
|
70
|
+
return t = q ? e + 1 > q ? 1 : e + 1 : 0, G.current = t, t;
|
|
71
|
+
}), G.current === 1 && J(G.current);
|
|
72
|
+
}, [q, J]), X = h(() => {
|
|
73
|
+
R((e) => {
|
|
75
74
|
let t;
|
|
76
|
-
return t =
|
|
77
|
-
}),
|
|
78
|
-
}, [
|
|
75
|
+
return t = q ? e - 1 <= 0 ? q : e - 1 : 0, G.current = t, t;
|
|
76
|
+
}), G.current === 1 && J(G.current);
|
|
77
|
+
}, [q, J]), Z = h(async (e) => {
|
|
79
78
|
if (!e) return {};
|
|
80
79
|
let t = e.numPages, n = {};
|
|
81
80
|
for (let r = 1; r <= t; r++) {
|
|
@@ -87,11 +86,11 @@ var b = (b = {}, x = "") => {
|
|
|
87
86
|
}, []);
|
|
88
87
|
return g(() => {
|
|
89
88
|
if (!S) {
|
|
90
|
-
A.current = !0, N([]),
|
|
89
|
+
A.current = !0, N([]), R(0);
|
|
91
90
|
return;
|
|
92
91
|
}
|
|
93
|
-
A.current = !1, T(!0), N([]),
|
|
94
|
-
|
|
92
|
+
A.current = !1, T(!0), N([]), R(0), Z(E).then((e) => {
|
|
93
|
+
W.current = e;
|
|
95
94
|
let t = Object.keys(e).reduce((t, n) => {
|
|
96
95
|
let r = p([S], e[n], Number(n) - 1, b).map((e, t) => ({
|
|
97
96
|
...e,
|
|
@@ -100,13 +99,13 @@ var b = (b = {}, x = "") => {
|
|
|
100
99
|
}));
|
|
101
100
|
return [...t, ...r];
|
|
102
101
|
}, []);
|
|
103
|
-
N(t),
|
|
102
|
+
N(t), R(+!!t.length);
|
|
104
103
|
}).catch(() => {
|
|
105
|
-
N([]),
|
|
104
|
+
N([]), R(0);
|
|
106
105
|
}).finally(() => T(!1));
|
|
107
106
|
}, [
|
|
108
107
|
S,
|
|
109
|
-
|
|
108
|
+
Z,
|
|
110
109
|
E,
|
|
111
110
|
b
|
|
112
111
|
]), {
|
|
@@ -114,12 +113,12 @@ var b = (b = {}, x = "") => {
|
|
|
114
113
|
setSearch: C,
|
|
115
114
|
loading: w,
|
|
116
115
|
matches: M,
|
|
117
|
-
totalMatches:
|
|
118
|
-
currentMatchPosition:
|
|
119
|
-
currentMatch:
|
|
120
|
-
nextMatch:
|
|
121
|
-
prevMatch:
|
|
122
|
-
setCurrentMatchPosition:
|
|
116
|
+
totalMatches: q,
|
|
117
|
+
currentMatchPosition: L,
|
|
118
|
+
currentMatch: K,
|
|
119
|
+
nextMatch: Y,
|
|
120
|
+
prevMatch: X,
|
|
121
|
+
setCurrentMatchPosition: R
|
|
123
122
|
};
|
|
124
123
|
};
|
|
125
124
|
//#endregion
|
package/dist/utils/types.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "../de_DE-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "../de_DE-x4Z-jQrz.js";
|
|
2
2
|
//#region lib/utils/types.ts
|
|
3
3
|
var o = /* @__PURE__ */ function(e) {
|
|
4
4
|
return e[e.Text = 1] = "Text", e[e.Link = 2] = "Link", e[e.FreeText = 3] = "FreeText", e[e.Line = 4] = "Line", e[e.Square = 5] = "Square", e[e.Circle = 6] = "Circle", e[e.Polygon = 7] = "Polygon", e[e.Polyline = 8] = "Polyline", e[e.Highlight = 9] = "Highlight", e[e.Underline = 10] = "Underline", e[e.Squiggly = 11] = "Squiggly", e[e.StrikeOut = 12] = "StrikeOut", e[e.Stamp = 13] = "Stamp", e[e.Caret = 14] = "Caret", e[e.Ink = 15] = "Ink", e[e.Popup = 16] = "Popup", e[e.FileAttachment = 17] = "FileAttachment", e[e.Widget = 20] = "Widget", e;
|
|
5
5
|
}({}), s = /* @__PURE__ */ function(e) {
|
|
6
6
|
return e.INTERNAL_LINK = "internal-link", e.LINK = "link", e.FILE_ATTACHMENT = "file-attachment", e.FORM_TEXT = "form-text", e.FORM_SELECT = "form-select", e.FORM_CHECKBOX = "form-checkbox", e.FORM_RADIO = "form-radio", e.FORM_BUTTON = "form-button", e.BUTTON = "button", e;
|
|
7
7
|
}({}), c = /* @__PURE__ */ function(e) {
|
|
8
|
-
return e.NOT_SUPPORTED = "not-supported", e.INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf", e;
|
|
8
|
+
return e.NOT_SUPPORTED = "not-supported", e.INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf", e.WASM_URL_REQUIRED = "wasm-url-required", e;
|
|
9
9
|
}({}), l = /* @__PURE__ */ function(e) {
|
|
10
10
|
return e.ACTUAL = "Actual Size", e.PAGE_FIT = "Page Fit", e.PAGE_WIDTH = "Page Width", e;
|
|
11
11
|
}({}), u = /* @__PURE__ */ function(e) {
|
package/package.json
CHANGED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { useDocumentContext as e } from "./contexts/RPDocumentContext.js";
|
|
2
|
-
import { useInitialStateContext as t } from "./contexts/InitialStateContext.js";
|
|
3
|
-
import { useZoomContext as n } from "./contexts/ZoomContext.js";
|
|
4
|
-
import { usePagesRotateContext as r } from "./contexts/PagesRotateContext.js";
|
|
5
|
-
import { useRenderQueue as i } from "./contexts/RenderQueueProvider.js";
|
|
6
|
-
import { useCallback as a, useEffect as o, useRef as s } from "react";
|
|
7
|
-
import { jsx as c } from "react/jsx-runtime";
|
|
8
|
-
import './assets/CanvasLayer.css';//#region lib/components/page/RPPage.module.css
|
|
9
|
-
var l = {
|
|
10
|
-
"rp-page-wrapper": "_rp-page-wrapper_1iuev_1",
|
|
11
|
-
"rp-page": "_rp-page_1iuev_1",
|
|
12
|
-
"rp-canvas-layer": "_rp-canvas-layer_1iuev_17",
|
|
13
|
-
"rp-loader-wrapper": "_rp-loader-wrapper_1iuev_40"
|
|
14
|
-
}, u = (u) => {
|
|
15
|
-
let { pageNumber: d, onLoaded: f, onLoading: p } = u, m = s(null), h = s(null), g = s(null), { pages: _ } = e(), { pageRotate: v } = r(), { currentZoom: y, targetZoom: b, isZooming: x } = n(), { interactiveForm: S } = t(), C = i(), w = s(`page-${d}`), T = s(0), E = s(""), D = s(null), O = s(0), k = s(!1), A = a((e, t = !1) => {
|
|
16
|
-
e && (e.width = 0, e.height = 0, t && e.parentNode && e.parentNode.removeChild(e));
|
|
17
|
-
}, []), j = a((e = h.current) => {
|
|
18
|
-
if (!e) return;
|
|
19
|
-
let t = O.current, n = t ? (b || y || t || 1) / t : 1;
|
|
20
|
-
e.style.setProperty("--rp-canvas-scale-ratio", String(n));
|
|
21
|
-
}, [y, b]), M = a(() => {
|
|
22
|
-
let e = document.createElement("canvas");
|
|
23
|
-
return e.dataset.rp = `page-${d}-canvas`, e.style.opacity = "0", e.style.position = "absolute", e.style.inset = "0", j(e), e;
|
|
24
|
-
}, [d, j]), N = a(() => {
|
|
25
|
-
C.removeQueue(w.current), D.current &&= (D.current.cancel(), null);
|
|
26
|
-
}, [C]), P = a(() => {
|
|
27
|
-
g.current && !g.current.parentNode && (A(g.current), g.current = null);
|
|
28
|
-
}, [A]), F = a((e) => {
|
|
29
|
-
if (!k.current) return A(e), !1;
|
|
30
|
-
let t = m.current;
|
|
31
|
-
if (!t) return A(e), !1;
|
|
32
|
-
let n = h.current;
|
|
33
|
-
return n?.parentNode ? n.replaceWith(e) : t.appendChild(e), e.style.opacity = "1", h.current = e, A(n), !0;
|
|
34
|
-
}, [A]);
|
|
35
|
-
return o(() => (k.current = !0, () => {
|
|
36
|
-
k.current = !1, N(), A(g.current), A(h.current), g.current = null, h.current = null;
|
|
37
|
-
}), [N, A]), o(() => {
|
|
38
|
-
j();
|
|
39
|
-
}, [j]), o(() => {
|
|
40
|
-
w.current = `page-${d}`, E.current = "", O.current = 0, A(g.current, !0), A(h.current, !0), g.current = null, h.current = null;
|
|
41
|
-
}, [A, d]), o(() => {
|
|
42
|
-
x && (N(), P());
|
|
43
|
-
}, [
|
|
44
|
-
N,
|
|
45
|
-
P,
|
|
46
|
-
x
|
|
47
|
-
]), o(() => {
|
|
48
|
-
if (!_ || y === 0 || x) return;
|
|
49
|
-
let e = _.get(d), t = m.current;
|
|
50
|
-
if (!e || !t) return;
|
|
51
|
-
let n = v[d] ?? e.defaultRotation ?? 0, r = `${y}:${n}:${S ? "forms" : "static"}`;
|
|
52
|
-
if (E.current === r) return;
|
|
53
|
-
let i = h.current, a = !!i && i.width > 0 && i.height > 0, o = T.current + 1;
|
|
54
|
-
T.current = o, N(), P(), p && !a && p();
|
|
55
|
-
let s = M();
|
|
56
|
-
return g.current = s, C.enqueue(w.current, {
|
|
57
|
-
page: e.page,
|
|
58
|
-
canvasElem: s,
|
|
59
|
-
options: {
|
|
60
|
-
scale: y,
|
|
61
|
-
rotate: n,
|
|
62
|
-
renderForms: !0,
|
|
63
|
-
interactiveForm: S
|
|
64
|
-
},
|
|
65
|
-
onLoaded: () => {
|
|
66
|
-
if (T.current !== o || g.current !== s) {
|
|
67
|
-
A(s);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (O.current = y, j(s), !F(s)) {
|
|
71
|
-
g.current = null;
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
g.current = null, E.current = r, D.current = null, f?.();
|
|
75
|
-
},
|
|
76
|
-
onRenderTask: (e) => {
|
|
77
|
-
T.current === o && (D.current = e);
|
|
78
|
-
}
|
|
79
|
-
}, 3), () => {
|
|
80
|
-
N(), g.current === s && (A(s), g.current = null);
|
|
81
|
-
};
|
|
82
|
-
}, [
|
|
83
|
-
N,
|
|
84
|
-
A,
|
|
85
|
-
P,
|
|
86
|
-
M,
|
|
87
|
-
y,
|
|
88
|
-
S,
|
|
89
|
-
x,
|
|
90
|
-
f,
|
|
91
|
-
p,
|
|
92
|
-
d,
|
|
93
|
-
v,
|
|
94
|
-
_,
|
|
95
|
-
C,
|
|
96
|
-
F,
|
|
97
|
-
j
|
|
98
|
-
]), /* @__PURE__ */ c("div", {
|
|
99
|
-
className: l["rp-canvas-layer"],
|
|
100
|
-
"data-rp": `page-${d}-canvasLayer`,
|
|
101
|
-
ref: m
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
//#endregion
|
|
105
|
-
export { l as n, u as t };
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { ScrollMode as e, ViewMode as t } from "./utils/types.js";
|
|
2
|
-
import { appConsole as n } from "./utils/appConsole.js";
|
|
3
|
-
import { useDocumentContext as r } from "./contexts/RPDocumentContext.js";
|
|
4
|
-
import { useInitialStateContext as i } from "./contexts/InitialStateContext.js";
|
|
5
|
-
import { useScrollModeContext as a } from "./contexts/ScrollModeContext.js";
|
|
6
|
-
import { useViewModeContext as o } from "./contexts/ViewModeContext.js";
|
|
7
|
-
import { useVirtualScrollContext as s } from "./contexts/VirtualScrollContext.js";
|
|
8
|
-
import { useVirtualGridContext as c } from "./contexts/VirtualGridContext.js";
|
|
9
|
-
import { smoothScrollTo as l } from "./utils/smoothScrollTo.js";
|
|
10
|
-
import { useLayoutContainer as u } from "./contexts/LayoutContainerContext.js";
|
|
11
|
-
import { useGlobalCurrentPage as d } from "./contexts/GlobalCurrentPage.js";
|
|
12
|
-
import { useDebounce as f } from "./utils/hooks/useDebounce.js";
|
|
13
|
-
import { useDimensionPagesContext as p } from "./contexts/DimensionPagesContext.js";
|
|
14
|
-
import { useSmoothScrollContext as m } from "./contexts/SmoothScrollContext.js";
|
|
15
|
-
import { getScrollDistance as h } from "./utils/getScrollDistance.js";
|
|
16
|
-
import { getGridDimension as g, getPositionFromPage as _ } from "./utils/calculatePage.js";
|
|
17
|
-
import { createContext as v, useCallback as y, useContext as b, useEffect as x, useRef as S, useState as C } from "react";
|
|
18
|
-
import { jsx as w } from "react/jsx-runtime";
|
|
19
|
-
//#region lib/utils/hooks/useScrollToPage.ts
|
|
20
|
-
var T = () => {
|
|
21
|
-
let { viewMode: n } = o(), { scrollMode: r } = a(), { virtualScrollRef: i, virtualScrollableElementRef: u, pageScrollElementRef: d } = s(), { setFocusedPage: f } = O(), v = S(), { columnCount: b } = c(), { widths: C, heights: w } = p(), T = S(r), E = S(n), D = S(b), { targetScrollPage: k, scrollBehavior: A } = m(), j = S(null), M = S();
|
|
22
|
-
x(() => {
|
|
23
|
-
i?.scrollToItem && (v.current = i);
|
|
24
|
-
}, [i]), x(() => {
|
|
25
|
-
T.current = r, E.current = n;
|
|
26
|
-
}, [r, n]);
|
|
27
|
-
let N = y((e, t) => {
|
|
28
|
-
if (!d) return;
|
|
29
|
-
let n = Math.ceil(e / 2) * 2 - 1;
|
|
30
|
-
if (e === n + 1) {
|
|
31
|
-
let e = {
|
|
32
|
-
left: C[n],
|
|
33
|
-
top: 0
|
|
34
|
-
};
|
|
35
|
-
return new Promise((t) => l(d, e, t));
|
|
36
|
-
}
|
|
37
|
-
return d?.scrollTo({
|
|
38
|
-
left: 0,
|
|
39
|
-
top: 0,
|
|
40
|
-
behavior: t
|
|
41
|
-
});
|
|
42
|
-
}, [
|
|
43
|
-
d,
|
|
44
|
-
C,
|
|
45
|
-
l
|
|
46
|
-
]);
|
|
47
|
-
x(() => {
|
|
48
|
-
T.current = r, E.current = n;
|
|
49
|
-
}, [r, n]), x(() => {
|
|
50
|
-
D.current = b;
|
|
51
|
-
}, [b]);
|
|
52
|
-
let P = y((n, r = A) => {
|
|
53
|
-
f(n), k.current = n, clearTimeout(M.current), M.current = setTimeout(() => {
|
|
54
|
-
k.current === n && (k.current = void 0);
|
|
55
|
-
}, 3e3);
|
|
56
|
-
let i = n - 1, a = i, o = 0;
|
|
57
|
-
if (E.current === t.DUAL_PAGE && T.current === e.PAGE_SCROLLING) {
|
|
58
|
-
N(n, r);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (T.current === e.PAGE_SCROLLING) {
|
|
62
|
-
f(n);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (!v.current || !u) {
|
|
66
|
-
j.current = {
|
|
67
|
-
page: n,
|
|
68
|
-
behavior: r
|
|
69
|
-
};
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
j.current = null;
|
|
73
|
-
let s = u, c = E.current === t.DUAL_PAGE_WITH_COVER, { columnsWidth: l, rowsHeight: d } = g({
|
|
74
|
-
widths: C,
|
|
75
|
-
heights: w
|
|
76
|
-
}, b, c);
|
|
77
|
-
if (T.current === e.HORIZONTAL_SCROLLING) {
|
|
78
|
-
o = i;
|
|
79
|
-
let e = h(l, o), t = {
|
|
80
|
-
left: Math.floor(e),
|
|
81
|
-
top: 0
|
|
82
|
-
};
|
|
83
|
-
return s.scrollTo({
|
|
84
|
-
...t,
|
|
85
|
-
behavior: r
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (E.current === t.DUAL_PAGE_WITH_COVER) {
|
|
89
|
-
let { rowIndex: e, columnIndex: t } = _(n, b, !0), i = h(l, t), a = h(d, e), o = {
|
|
90
|
-
left: Math.floor(i),
|
|
91
|
-
top: Math.floor(a)
|
|
92
|
-
};
|
|
93
|
-
return s.scrollTo({
|
|
94
|
-
...o,
|
|
95
|
-
behavior: r
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
if (E.current === t.DUAL_PAGE) {
|
|
99
|
-
o = i % 2, a = Math.floor(i / 2);
|
|
100
|
-
let e = h(l, o), t = h(d, a), n = {
|
|
101
|
-
left: Math.floor(e),
|
|
102
|
-
top: Math.floor(t)
|
|
103
|
-
};
|
|
104
|
-
return s.scrollTo({
|
|
105
|
-
...n,
|
|
106
|
-
behavior: r
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
let p = h(d, a), m = {
|
|
110
|
-
left: 0,
|
|
111
|
-
top: Math.floor(p)
|
|
112
|
-
};
|
|
113
|
-
return s.scrollTo({
|
|
114
|
-
...m,
|
|
115
|
-
behavior: r
|
|
116
|
-
});
|
|
117
|
-
}, [
|
|
118
|
-
u,
|
|
119
|
-
b,
|
|
120
|
-
N,
|
|
121
|
-
f,
|
|
122
|
-
l,
|
|
123
|
-
w,
|
|
124
|
-
C,
|
|
125
|
-
A
|
|
126
|
-
]);
|
|
127
|
-
return x(() => () => {
|
|
128
|
-
clearTimeout(M.current);
|
|
129
|
-
}, []), x(() => {
|
|
130
|
-
if (!u || !j.current) return;
|
|
131
|
-
let { page: e, behavior: t } = j.current;
|
|
132
|
-
j.current = null, P(e, t);
|
|
133
|
-
}, [u, P]), { scrollToPage: P };
|
|
134
|
-
}, E = (n = 1) => {
|
|
135
|
-
let [r, i] = C(n), [s, c] = C(0), { scrollToPage: l } = T(), d = S(n), { viewMode: m } = o(), { scrollMode: h } = a(), { widths: g } = p(), { pagesRef: _ } = u(), v = f(r, 100), b = y((e) => {
|
|
136
|
-
if (!/^[0-9]*$/g.test(e.toString()) || !e) return {
|
|
137
|
-
success: !1,
|
|
138
|
-
currentPage: d.current
|
|
139
|
-
};
|
|
140
|
-
let t = +e;
|
|
141
|
-
return t <= 0 || t > s ? {
|
|
142
|
-
success: !1,
|
|
143
|
-
currentPage: d.current
|
|
144
|
-
} : (i(t), d.current = t, {
|
|
145
|
-
success: !0,
|
|
146
|
-
currentPage: +e
|
|
147
|
-
});
|
|
148
|
-
}, [s]), x = y(b, [b]), w = y((e) => {
|
|
149
|
-
i(e), d.current = e;
|
|
150
|
-
}, []), E = y((e, t) => {
|
|
151
|
-
let n = b(e);
|
|
152
|
-
return n.success && l(n.currentPage, t), n;
|
|
153
|
-
}, [b, l]), D = y((e) => {
|
|
154
|
-
let n = e % 2 == 1;
|
|
155
|
-
if (!_ || n) return !1;
|
|
156
|
-
let r = n ? g[e] : g[e - 1], i = n ? g[e + 1] : g[e];
|
|
157
|
-
return m === t.DUAL_PAGE && r + i < _.clientWidth;
|
|
158
|
-
}, [
|
|
159
|
-
m,
|
|
160
|
-
g,
|
|
161
|
-
_,
|
|
162
|
-
s
|
|
163
|
-
]), O = y((n) => m === t.DUAL_PAGE && h === e.PAGE_SCROLLING ? n >= s - 1 : n >= s, [
|
|
164
|
-
s,
|
|
165
|
-
m,
|
|
166
|
-
h
|
|
167
|
-
]), k = y(() => {
|
|
168
|
-
let e = d.current, t = e - 1;
|
|
169
|
-
D(t) && (t = e - 2), E(t);
|
|
170
|
-
}, [E, D]);
|
|
171
|
-
return {
|
|
172
|
-
focusedPage: v,
|
|
173
|
-
totalPages: s,
|
|
174
|
-
setFocusedPage: x,
|
|
175
|
-
resetPage: w,
|
|
176
|
-
setTotalPages: c,
|
|
177
|
-
nextPage: y(() => {
|
|
178
|
-
let e = d.current;
|
|
179
|
-
if (O(e)) return;
|
|
180
|
-
let t = e + 1;
|
|
181
|
-
D(t) && (t = e + 2), E(t);
|
|
182
|
-
}, [
|
|
183
|
-
E,
|
|
184
|
-
D,
|
|
185
|
-
O
|
|
186
|
-
]),
|
|
187
|
-
prevPage: k,
|
|
188
|
-
goToPage: E
|
|
189
|
-
};
|
|
190
|
-
}, D = v({
|
|
191
|
-
focusedPage: 0,
|
|
192
|
-
setFocusedPage: (e) => {},
|
|
193
|
-
goToPage: (e, t) => ({
|
|
194
|
-
success: !!e,
|
|
195
|
-
currentPage: +e
|
|
196
|
-
}),
|
|
197
|
-
totalPages: 0,
|
|
198
|
-
setTotalPages: (e) => {},
|
|
199
|
-
prevPage: () => {},
|
|
200
|
-
nextPage: () => {}
|
|
201
|
-
}), O = () => {
|
|
202
|
-
let e = b(D);
|
|
203
|
-
return e?.focusedPage === void 0 && n.error("Please use this hooks inside children component of RPProvider"), e;
|
|
204
|
-
}, k = ({ children: e }) => {
|
|
205
|
-
let { pdf: t } = r(), { setCurrentPage: n } = d(), { initialPage: a = 1 } = i(), { focusedPage: o, totalPages: s, setFocusedPage: c, resetPage: l, setTotalPages: u, goToPage: f, nextPage: p, prevPage: m } = E(a), h = S(!0);
|
|
206
|
-
return x(() => {
|
|
207
|
-
if (!t) {
|
|
208
|
-
h.current || (u(0), l(1));
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
if (!t.numPages) return;
|
|
212
|
-
u(t.numPages);
|
|
213
|
-
let e = h.current ? a : 1;
|
|
214
|
-
l(Math.min(Math.max(e, 1), t.numPages)), h.current = !1;
|
|
215
|
-
}, [
|
|
216
|
-
t,
|
|
217
|
-
u,
|
|
218
|
-
l
|
|
219
|
-
]), x(() => {
|
|
220
|
-
n(o);
|
|
221
|
-
}, [o, n]), /* @__PURE__ */ w(D.Provider, {
|
|
222
|
-
value: {
|
|
223
|
-
focusedPage: o,
|
|
224
|
-
totalPages: s,
|
|
225
|
-
setFocusedPage: c,
|
|
226
|
-
setTotalPages: u,
|
|
227
|
-
nextPage: p,
|
|
228
|
-
prevPage: m,
|
|
229
|
-
goToPage: f
|
|
230
|
-
},
|
|
231
|
-
children: e
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
//#endregion
|
|
235
|
-
export { T as a, E as i, k as n, O as r, D as t };
|