@react-pdf-kit/viewer 2.8.0-beta.6 → 2.8.0-beta.8
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-CAIvKf_O.js → AnnotationLayer-CyOYh0Tw.js} +2 -2
- package/dist/CanvasLayer-CJqCJ30J.js +111 -0
- package/dist/{LoadingIndicator-DiWoWs4Y.js → LoadingIndicator-B_Jsf8No.js} +7 -7
- package/dist/MenuItem-D-GflAAo.js +31 -0
- package/dist/PaginationContext-DIzsZhFd.js +194 -0
- package/dist/{PasswordModal-CB9Rd2zJ.js → PasswordModal-S0leMhEd.js} +11 -11
- package/dist/RPLayout.module-BH5r8dDc.js +14 -0
- package/dist/RPPages-BQw330_L.js +655 -0
- package/dist/{RPTooltip-ZZoFqP7C.js → RPTooltip-COLVx-C_.js} +123 -91
- package/dist/SearchTool.module-DY8Ucfb_.js +17 -0
- package/dist/{SkipLink-CdcjClGB.js → SkipLink-Dj83gZdk.js} +3 -3
- package/dist/{TextLayer-DWGFN9SF.js → TextLayer-D-V9kogG.js} +5 -5
- package/dist/{Thumbnail-CzclS3h_.js → Thumbnail-C6zkvwcs.js} +6 -6
- package/dist/{Thumbnails-DnAsrttK.js → Thumbnails-DKG6I7pb.js} +2 -2
- package/dist/assets/AnnotationLayer.css +1 -1
- package/dist/assets/CanvasLayer.css +1 -0
- package/dist/assets/LoadingIndicator.css +1 -1
- package/dist/assets/MenuItem.css +1 -1
- package/dist/assets/PasswordModal.css +1 -1
- package/dist/assets/RPLayout.css +1 -1
- package/dist/assets/RPPages.css +1 -1
- package/dist/assets/SearchTool.css +1 -1
- package/dist/assets/SkipLink.css +1 -1
- package/dist/assets/TextLayer.css +1 -1
- package/dist/assets/Thumbnail.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 +2 -2
- package/dist/components/layout/RPLayout.js +2 -2
- package/dist/components/layout/SkipLink.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +2 -2
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/DarkModeTool.js +1 -1
- package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/FileDownloadTool.js +6 -6
- package/dist/components/layout/toolbar/FileUploadTool.js +6 -6
- package/dist/components/layout/toolbar/FullScreenTool.js +9 -8
- package/dist/components/layout/toolbar/MenuItem.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +23 -29
- package/dist/components/layout/toolbar/OtherTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +2 -2
- package/dist/components/layout/toolbar/PrintTool.js +6 -6
- package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
- package/dist/components/layout/toolbar/RPMoreOptions.js +1 -1
- package/dist/components/layout/toolbar/RPToolbar.js +1 -1
- package/dist/components/layout/toolbar/RotateTool.js +10 -10
- package/dist/components/layout/toolbar/ScrollModeTool.js +17 -17
- package/dist/components/layout/toolbar/SearchCloseButton.js +2 -2
- package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
- package/dist/components/layout/toolbar/SearchTool.js +133 -121
- package/dist/components/layout/toolbar/SelectionModeTool.js +10 -10
- package/dist/components/layout/toolbar/ThumbnailTool.js +1 -1
- package/dist/components/layout/toolbar/ToolbarCustom.js +2 -2
- package/dist/components/layout/toolbar/ToolbarDefault.js +2 -2
- package/dist/components/layout/toolbar/ViewModeTool.js +16 -16
- package/dist/components/layout/toolbar/ZoomTool.js +82 -80
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +1 -1
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +3 -3
- package/dist/components/layout/toolbar/tools/InputPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +1 -1
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PrintTool.js +1 -1
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +1 -1
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +1 -1
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +1 -1
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +1 -1
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +1 -1
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +25 -23
- package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +1 -1
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +25 -23
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +3 -3
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +7 -7
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/CanvasLayer.js +2 -48
- package/dist/components/page/DualPage.js +2 -2
- package/dist/components/page/DualPageWithCover.js +2 -2
- package/dist/components/page/RPPage.js +94 -2
- package/dist/components/page/SinglePage.js +2 -2
- package/dist/components/page/TextHighlightLayer.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/PasswordModal.js +1 -1
- package/dist/components/ui/RPTooltip.js +1 -1
- package/dist/contexts/DimensionPagesContext.js +38 -22
- 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 +24 -18
- package/dist/contexts/RenderedPagesCache.js +32 -13
- package/dist/contexts/VirtualScrollContext.js +10 -13
- package/dist/contexts/ZoomContext.js +119 -61
- package/dist/{de_DE-DwUvXUWH.js → de_DE-x4Z-jQrz.js} +30 -0
- package/dist/{main-CKr9unOk.js → main-7sMXtgRg.js} +2 -2
- package/dist/main.js +4 -4
- package/dist/style-CJtyyrJx.js +5 -0
- package/dist/types/components/page/CanvasLayer.d.ts +4 -1
- package/dist/types/components/ui/RPTooltip.d.ts +3 -2
- package/dist/types/contexts/RenderQueueProvider.d.ts +2 -0
- 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 +5 -0
- package/dist/types/locales/en_US.json.d.ts +5 -0
- package/dist/types/locales/it_IT.json.d.ts +5 -0
- package/dist/types/locales/pt_PT.json.d.ts +5 -0
- package/dist/types/locales/th_TH.json.d.ts +5 -0
- package/dist/types/locales/zh_CN.json.d.ts +5 -0
- package/dist/types/utils/Queue.d.ts +1 -0
- package/dist/types/utils/const.d.ts +3 -0
- package/dist/types/utils/constants.d.ts +9 -0
- package/dist/types/utils/documentLayout.d.ts +60 -0
- package/dist/types/utils/hooks/usePinch.d.ts +14 -1
- package/dist/types/utils/hooks/usePresentPage.d.ts +2 -2
- package/dist/types/utils/hooks/useZoomOrigin.d.ts +4 -0
- package/dist/types/utils/types.d.ts +21 -2
- package/dist/types/utils/zoom.d.ts +2 -0
- package/dist/utils/Queue.js +5 -0
- 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 +109 -56
- package/dist/utils/hooks/usePresentPage.js +33 -57
- package/dist/utils/hooks/useScrollToPage.js +1 -1
- package/dist/utils/hooks/useSearch.js +66 -67
- package/dist/utils/hooks/useZoomOrigin.js +37 -0
- package/dist/utils/renderPage.js +21 -14
- package/dist/utils/types.js +3 -3
- package/dist/utils/zoom.js +8 -2
- package/package.json +1 -1
- package/dist/MenuItem-BJDWfzAw.js +0 -15
- package/dist/PaginationContext-Cwf8sCpK.js +0 -242
- package/dist/RPLayout.module-Vc3h4xxS.js +0 -14
- package/dist/RPPage-C_r8aeTc.js +0 -91
- package/dist/RPPages-CmXHTAqF.js +0 -1007
- package/dist/SearchTool.module-DUkVXfOn.js +0 -16
- package/dist/assets/RPPage.css +0 -1
- package/dist/contexts/VirtualGridContext.js +0 -18
- package/dist/style-C8T5x1fE.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/{TextHighlightLayer-BSVgBxR3.js → TextHighlightLayer-3vIZbRyL.js} +0 -0
|
@@ -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
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n } from "react";
|
|
2
|
+
//#region lib/utils/hooks/useZoomOrigin.ts
|
|
3
|
+
var r = (e, t, n) => Math.max(t, Math.min(e, n)), i = (e) => Number.isFinite(e.left) && Number.isFinite(e.top) && Number.isFinite(e.width) && Number.isFinite(e.height) && e.width > 0 && e.height > 0, a = (e, t, n) => {
|
|
4
|
+
if (!e || !Number.isFinite(t) || !Number.isFinite(n)) return null;
|
|
5
|
+
let a = e.getBoundingClientRect();
|
|
6
|
+
return i(a) ? [r(t - a.left, 0, a.width), r(n - a.top, 0, a.height)] : null;
|
|
7
|
+
}, o = (e) => {
|
|
8
|
+
if (!e) return;
|
|
9
|
+
let t = e.getBoundingClientRect();
|
|
10
|
+
if (!i(t)) return;
|
|
11
|
+
let { width: n, height: r } = t;
|
|
12
|
+
return [n / 2, r / 2];
|
|
13
|
+
}, s = (s) => {
|
|
14
|
+
let c = n(null), l = e((e, t) => a(s, e, t), [s]);
|
|
15
|
+
return t(() => {
|
|
16
|
+
if (!s) {
|
|
17
|
+
c.current = null;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let e = (e) => {
|
|
21
|
+
c.current = l(e.clientX, e.clientY);
|
|
22
|
+
}, t = (e) => {
|
|
23
|
+
c.current = l(e.clientX, e.clientY);
|
|
24
|
+
};
|
|
25
|
+
return s.addEventListener("pointermove", e, { passive: !0 }), s.addEventListener("mousemove", t, { passive: !0 }), () => {
|
|
26
|
+
s.removeEventListener("pointermove", e), s.removeEventListener("mousemove", t);
|
|
27
|
+
};
|
|
28
|
+
}, [s, l]), e(() => {
|
|
29
|
+
if (!s) return;
|
|
30
|
+
let e = s.getBoundingClientRect();
|
|
31
|
+
if (!i(e)) return;
|
|
32
|
+
let { width: t, height: n } = e, a = c.current;
|
|
33
|
+
return a ? [r(a[0], 0, t), r(a[1], 0, n)] : o(s);
|
|
34
|
+
}, [s]);
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { o as getZoomCenterOrigin, a as getZoomOriginFromClientPoint, s as useZoomOrigin };
|
package/dist/utils/renderPage.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IOS_MAX_CANVAS_PIXELS as e, MAX_CANVAS_DIM as t, MAX_CANVAS_PIXELS as n, SAFARI_MAX_CANVAS_PIXELS as r } from "./constants.js";
|
|
2
|
+
import { AnnotationMode as i } from "pdfjs-dist";
|
|
2
3
|
//#region lib/utils/renderPage.ts
|
|
3
|
-
var
|
|
4
|
-
let
|
|
5
|
-
|
|
4
|
+
var a = () => {
|
|
5
|
+
let t = navigator.userAgent, i = /iPad|iPhone|iPod/.test(t) && !window.MSStream, a = /^((?!chrome|android).)*safari/i.test(t);
|
|
6
|
+
return i ? e : a ? r : n;
|
|
7
|
+
}, o = (e, n) => {
|
|
8
|
+
let r = window.devicePixelRatio || 1, i = Math.max(e * n, 1), o = Math.min(a(), i * 200), s = Math.sqrt(o / i), c = t / Math.max(e, 1), l = t / Math.max(n, 1), u = Math.min(r, s, c, l);
|
|
9
|
+
return Number.isFinite(u) && u > 0 ? u : 1;
|
|
10
|
+
}, s = (e, t, n = {}) => {
|
|
11
|
+
let { scale: r = 1, rotate: a = 0, renderForms: s = !1, interactiveForm: c = !0 } = n, l = t.getContext("2d", { desynchronized: !1 }), u = e.getViewport({
|
|
12
|
+
scale: r,
|
|
6
13
|
rotation: a
|
|
7
|
-
}), d =
|
|
8
|
-
scale:
|
|
14
|
+
}), d = o(u.width, u.height), f = e.getViewport({
|
|
15
|
+
scale: r * d,
|
|
9
16
|
rotation: a
|
|
10
17
|
});
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
return
|
|
14
|
-
canvas:
|
|
15
|
-
canvasContext:
|
|
16
|
-
viewport:
|
|
17
|
-
annotationMode:
|
|
18
|
+
t.width = Math.floor(f.width), t.height = Math.floor(f.height), t.style.width = `${Math.floor(u.width)}px`, t.style.height = `${Math.floor(u.height)}px`;
|
|
19
|
+
let p = s ? i.ENABLE_FORMS : void 0;
|
|
20
|
+
return c || (p = i.ENABLE), e.render({
|
|
21
|
+
canvas: t,
|
|
22
|
+
canvasContext: l,
|
|
23
|
+
viewport: f,
|
|
24
|
+
annotationMode: p
|
|
18
25
|
});
|
|
19
26
|
};
|
|
20
27
|
//#endregion
|
|
21
|
-
export {
|
|
28
|
+
export { s as renderPage };
|
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) {
|
|
@@ -13,7 +13,7 @@ var o = /* @__PURE__ */ function(e) {
|
|
|
13
13
|
}({}), d = /* @__PURE__ */ function(e) {
|
|
14
14
|
return e.SINGLE_PAGE = "Single", e.DUAL_PAGE = "Dual", e.DUAL_PAGE_WITH_COVER = "DualWithCover", e;
|
|
15
15
|
}({}), f = /* @__PURE__ */ function(e) {
|
|
16
|
-
return e.FONT_FAMILY = "--rp-font-family", e.PRIMARY_COLOR = "--rp-primary-color", e.BORDER_RADIUS = "--rp-border-radius", e.TEXT_COLOR = "--rp-text-color", e.OUTLINE_COLOR = "--rp-outline-color", e.FONT_SIZE = "--rp-font-size", e.DROP_MASK_BACKGROUND_COLOR = "--rp-drop-mask-background-color", e.LOADER_BACKDROP_COLOR = "--rp-loader-backdrop-color", e.ICON_DISABLED = "--rp-icon-disabled", e.ICON_FONT_SIZE = "--rp-icon-font-size", e.TOOLBAR_BACKGROUND = "--rp-toolbar-background", e.TOOLBAR_BORDER_COLOR = "--rp-toolbar-border-color", e.TOOLBAR_PADDING = "--rp-toolbar-padding", e.TOOLBAR_GAP = "--rp-toolbar-gap", e.TOOLBAR_SIZE = "--rp-toolbar-size", e.SIDEBAR_WIDTH = "--rp-sidebar-width", e.THUMBNAIL_BORDER_COLOR = "--rp-thumbnail-border-color", e.THUMBNAIL_BACKGROUND_COLOR = "--rp-thumbnail-background-color", e.THUMBNAIL_ACTIVE_COLOR = "--rp-thumbnail-active-color", e.THUMBNAIL_PADDING_Y = "--rp-thumbnail-padding-y", e.BUTTON_HOVER_BACKGROUND = "--rp-button-hover-background", e.BUTTON_PADDING = "--rp-button-padding", e.INPUT_PADDING = "--rp-input-padding", e.INPUT_BORDER_RADIUS = "--rp-input-border-radius", e.INPUT_BACKGROUND_COLOR = "--rp-input-background-color", e.INPUT_PLACEHOLDER_COLOR = "--rp-input-placeholder-color", e.PAGES_BACKGROUND_COLOR = "--rp-pages-background-color", e.PAGE_SHADOW = "--rp-page-shadow", e.PAGE_OUTLINE = "--rp-page-outline", e.PAGE_OUTLINE_OFFSET = "--rp-page-outline-offset", e.ANNOTATION_LAYER_LINK_HOVER_BACKGROUND = "--rp-annotation-layer__link-hover-background", e.DROPDOWN_BACKGROUND_COLOR = "--rp-dropdown-background-color", e.DROPDOWN_PADDING = "--rp-dropdown-padding", e.DROPDOWN_HOVER_BACKGROUND_COLOR = "--rp-dropdown-hover-background-color", e.DROPDOWN_SEPARATOR_COLOR = "--rp-dropdown-separator-color", e.DROPDOWN_SEPARATOR_MARGIN = "--rp-dropdown-separator-margin", e.DROPDOWN_PADDING_MENU_ITEM = "--rp-dropdown-padding-menu-item", e.DROPDOWN_FONT_SIZE = "--rp-dropdown-font-size", e.DROPDOWN_BORDER_RADIUS = "--rp-dropdown-border-radius", e.SEARCH_TOOL_DROPDOWN_PADDING = "--rp-search-tool-dropdown-padding", e.POPOVER_FONT_SIZE = "--rp-popover-font-size", e.POPOVER_BACKGROUND_COLOR = "--rp-popover-background-color", e.POPOVER_COLOR = "--rp-popover-color", e.POPOVER_BORDER_COLOR = "--rp-popover-border-color", e.POPOVER_BORDER_RADIUS = "--rp-popover-border-radius", e.OVERLAY_BACKGROUND_COLOR = "--rp-overlay-background-color", e.DIALOG_BACKGROUND_COLOR = "--rp-dialog-background-color", e.PROPERTIES_DIVIDER_COLOR = "--rp-properties-divider-color", e.PROPERTIES_DIVIDER_MARGIN = "--rp-properties-divider-margin", e.PROPERTY_ITEM_GAP = "--rp-property-item-gap", e.DIALOG_TITLE_COLOR = "--rp-dialog-title-color", e.PROPERTY_ITEM_LABEL_COLOR = "--rp-property-item-label-color", e.PROPERTY_CLOSE_ICON_SIZE = "--rp-property-close-icon-size", e.PROPERTY_ITEM_FONT_SIZE = "--rp-property-item-font-size", e.PROPERTY_ITEM_FONT_WEIGHT = "--rp-property-item-font-weight", e.DIALOG_TITLE_FONT_SIZE = "--rp-dialog-title-font-size", e.DIALOG_TITLE_FONT_WEIGHT = "--rp-dialog-title-font-weight", e.MENU_ITEM_ICON_SIZE = "--rp-menu-item-icon-size", e.PRINT_PROGRESS_BACKGROUND = "--rp-print-progress-background", e.PRINT_PROGRESS_COLOR = "--rp-print-progress-color", e.DROP_ZONE_BORDER = "--rp-drop-zone-border", e.DROP_ZONE_FONT_COLOR = "--rp-drop-zone-font-color", e.DROP_ZONE_FONT_SIZE = "--rp-drop-zone-font-size", e.DROP_ZONE_BACKGROUND_COLOR = "--rp-drop-zone-background-color", e.CHECKBOX_BORDER_RADIUS = "--rp-checkbox-border-radius", e.CHECKBOX_BORDER_COLOR = "--rp-checkbox-border-color", e.CHECKBOX_INDICATOR_COLOR = "--rp-checkbox-indicator-color", e.HIGHLIGHT_BACKGROUND_COLOR = "--rp-highlight-background-color", e.TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius", e.CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color", e.TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color", e.TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius", e.TOOLTIP_FONT_COLOR = "--rp-tooltip-font-color", e.TOOLTIP_FONT_SIZE = "--rp-tooltip-font-size", e.TOOLTIP_PADDING = "--rp-tooltip-padding", e.PASSWORD_MODAL_BACKGROUND_COLOR = "--rp-password-background-color", e.PASSWORD_MODAL_TITLE_FONT_COLOR = "--rp-password-title-font-color", e.PASSWORD_MODAL_CONTENT_FONT_COLOR = "--rp-password-content-font-color", e.PASSWORD_MODAL_INPUT_PLACEHOLDER_COLOR = "--rp-password-input-placeholder-color", e.PASSWORD_MODAL_INPUT_BORDER_COLOR = "--rp-password-input-border-color", e.PASSWORD_MODAL_INPUT_FONT_COLOR = "--rp-password-input-font-color", e.PASSWORD_MODAL_BUTTON_FONT_COLOR = "--rp-password-button-font-color", e.PASSWORD_MODAL_BUTTON_BACKGROUND_COLOR = "--rp-password-button-background-color", e.PASSWORD_MODAL_BUTTON_BORDER_COLOR = "--rp-password-button-border-color", e.PASSWORD_MODAL_BORDER_COLOR = "--rp-password-border-color", e.CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width", e.CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color", e.CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset", e.BUTTON_BORDER_RADIUS = "--rp-button-border-radius", e.SKIP_LINK_FONT_SIZE = "--rp-skip-link-font-size", e.SKIP_LINK_COLOR = "--rp-skip-link-color", e.SKIP_LINK_BACKGROUND_COLOR = "--rp-skip-link-background-color", e.SKIP_LINK_BORDER_COLOR = "--rp-skip-link-border-color", e;
|
|
16
|
+
return e.FONT_FAMILY = "--rp-font-family", e.PRIMARY_COLOR = "--rp-primary-color", e.BORDER_RADIUS = "--rp-border-radius", e.TEXT_COLOR = "--rp-text-color", e.OUTLINE_COLOR = "--rp-outline-color", e.FONT_SIZE = "--rp-font-size", e.DROP_MASK_BACKGROUND_COLOR = "--rp-drop-mask-background-color", e.LOADER_BACKDROP_COLOR = "--rp-loader-backdrop-color", e.ICON_DISABLED = "--rp-icon-disabled", e.ICON_FONT_SIZE = "--rp-icon-font-size", e.TOOLBAR_BACKGROUND = "--rp-toolbar-background", e.TOOLBAR_BORDER_COLOR = "--rp-toolbar-border-color", e.TOOLBAR_PADDING = "--rp-toolbar-padding", e.TOOLBAR_GAP = "--rp-toolbar-gap", e.TOOLBAR_SIZE = "--rp-toolbar-size", e.SIDEBAR_WIDTH = "--rp-sidebar-width", e.THUMBNAIL_BORDER_COLOR = "--rp-thumbnail-border-color", e.THUMBNAIL_BACKGROUND_COLOR = "--rp-thumbnail-background-color", e.THUMBNAIL_ACTIVE_COLOR = "--rp-thumbnail-active-color", e.THUMBNAIL_PADDING_Y = "--rp-thumbnail-padding-y", e.BUTTON_HOVER_BACKGROUND = "--rp-button-hover-background", e.BUTTON_PADDING = "--rp-button-padding", e.INPUT_PADDING = "--rp-input-padding", e.INPUT_BORDER_RADIUS = "--rp-input-border-radius", e.INPUT_BACKGROUND_COLOR = "--rp-input-background-color", e.INPUT_PLACEHOLDER_COLOR = "--rp-input-placeholder-color", e.SEARCH_INPUT_BORDER_COLOR = "--rp-search-input-border-color", e.PAGES_BACKGROUND_COLOR = "--rp-pages-background-color", e.PAGE_SHADOW = "--rp-page-shadow", e.PAGE_OUTLINE = "--rp-page-outline", e.PAGE_OUTLINE_OFFSET = "--rp-page-outline-offset", e.ANNOTATION_LAYER_LINK_HOVER_BACKGROUND = "--rp-annotation-layer__link-hover-background", e.DROPDOWN_BACKGROUND_COLOR = "--rp-dropdown-background-color", e.DROPDOWN_PADDING = "--rp-dropdown-padding", e.DROPDOWN_HOVER_BACKGROUND_COLOR = "--rp-dropdown-hover-background-color", e.DROPDOWN_SEPARATOR_COLOR = "--rp-dropdown-separator-color", e.DROPDOWN_SEPARATOR_MARGIN = "--rp-dropdown-separator-margin", e.DROPDOWN_PADDING_MENU_ITEM = "--rp-dropdown-padding-menu-item", e.DROPDOWN_FONT_SIZE = "--rp-dropdown-font-size", e.DROPDOWN_BORDER_RADIUS = "--rp-dropdown-border-radius", e.SEARCH_TOOL_DROPDOWN_PADDING = "--rp-search-tool-dropdown-padding", e.POPOVER_FONT_SIZE = "--rp-popover-font-size", e.POPOVER_BACKGROUND_COLOR = "--rp-popover-background-color", e.POPOVER_COLOR = "--rp-popover-color", e.POPOVER_BORDER_COLOR = "--rp-popover-border-color", e.POPOVER_BORDER_RADIUS = "--rp-popover-border-radius", e.OVERLAY_BACKGROUND_COLOR = "--rp-overlay-background-color", e.DIALOG_BACKGROUND_COLOR = "--rp-dialog-background-color", e.PROPERTIES_DIVIDER_COLOR = "--rp-properties-divider-color", e.PROPERTIES_DIVIDER_MARGIN = "--rp-properties-divider-margin", e.PROPERTY_ITEM_GAP = "--rp-property-item-gap", e.DIALOG_TITLE_COLOR = "--rp-dialog-title-color", e.PROPERTY_ITEM_LABEL_COLOR = "--rp-property-item-label-color", e.PROPERTY_CLOSE_ICON_SIZE = "--rp-property-close-icon-size", e.PROPERTY_ITEM_FONT_SIZE = "--rp-property-item-font-size", e.PROPERTY_ITEM_FONT_WEIGHT = "--rp-property-item-font-weight", e.DIALOG_TITLE_FONT_SIZE = "--rp-dialog-title-font-size", e.DIALOG_TITLE_FONT_WEIGHT = "--rp-dialog-title-font-weight", e.MENU_ITEM_ICON_SIZE = "--rp-menu-item-icon-size", e.PRINT_PROGRESS_BACKGROUND = "--rp-print-progress-background", e.PRINT_PROGRESS_COLOR = "--rp-print-progress-color", e.PRINT_PROGRESS_CANCEL_BUTTON_BORDER_COLOR = "--rp-print-progress-cancel-button-border-color", e.DROP_ZONE_BORDER = "--rp-drop-zone-border", e.DROP_ZONE_FONT_COLOR = "--rp-drop-zone-font-color", e.DROP_ZONE_FONT_SIZE = "--rp-drop-zone-font-size", e.DROP_ZONE_BACKGROUND_COLOR = "--rp-drop-zone-background-color", e.CHECKBOX_BORDER_RADIUS = "--rp-checkbox-border-radius", e.CHECKBOX_BORDER_COLOR = "--rp-checkbox-border-color", e.CHECKBOX_INDICATOR_COLOR = "--rp-checkbox-indicator-color", e.HIGHLIGHT_BACKGROUND_COLOR = "--rp-highlight-background-color", e.TEXT_LAYER_HIGHLIGHT_BORDER_RADIUS = "--rp-text-layer-highlight-border-radius", e.CURRENT_HIGHLIGHT_BACKGROUND_COLOR = "--rp-current-highlight-background-color", e.TOOLTIP_BACKGROUND_COLOR = "--rp-tooltip-background-color", e.TOOLTIP_BORDER_RADIUS = "--rp-tooltip-border-radius", e.TOOLTIP_FONT_COLOR = "--rp-tooltip-font-color", e.TOOLTIP_FONT_SIZE = "--rp-tooltip-font-size", e.TOOLTIP_PADDING = "--rp-tooltip-padding", e.PASSWORD_MODAL_BACKGROUND_COLOR = "--rp-password-background-color", e.PASSWORD_MODAL_TITLE_FONT_COLOR = "--rp-password-title-font-color", e.PASSWORD_MODAL_CONTENT_FONT_COLOR = "--rp-password-content-font-color", e.PASSWORD_MODAL_INPUT_PLACEHOLDER_COLOR = "--rp-password-input-placeholder-color", e.PASSWORD_MODAL_INPUT_BORDER_COLOR = "--rp-password-input-border-color", e.PASSWORD_MODAL_INPUT_FONT_COLOR = "--rp-password-input-font-color", e.PASSWORD_MODAL_BUTTON_FONT_COLOR = "--rp-password-button-font-color", e.PASSWORD_MODAL_BUTTON_BACKGROUND_COLOR = "--rp-password-button-background-color", e.PASSWORD_MODAL_BUTTON_BORDER_COLOR = "--rp-password-button-border-color", e.PASSWORD_MODAL_BORDER_COLOR = "--rp-password-border-color", e.CONTAINER_FOCUS_OUTLINE_WIDTH = "--rp-container-focus-outline-width", e.CONTAINER_FOCUS_OUTLINE_COLOR = "--rp-container-focus-outline-color", e.CONTAINER_FOCUS_OUTLINE_OFFSET = "--rp-container-focus-outline-offset", e.BUTTON_BORDER_RADIUS = "--rp-button-border-radius", e.SKIP_LINK_FONT_SIZE = "--rp-skip-link-font-size", e.SKIP_LINK_COLOR = "--rp-skip-link-color", e.SKIP_LINK_BACKGROUND_COLOR = "--rp-skip-link-background-color", e.SKIP_LINK_BORDER_COLOR = "--rp-skip-link-border-color", e;
|
|
17
17
|
}({}), p = /* @__PURE__ */ function(e) {
|
|
18
18
|
return e.PAGE_SCROLLING = "PAGE", e.VERTICAL_SCROLLING = "VERTICAL", e.HORIZONTAL_SCROLLING = "HORIZONTAL", e;
|
|
19
19
|
}({}), m = /* @__PURE__ */ function(e) {
|
package/dist/utils/zoom.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { MAX_ZOOM_SCALE as e } from "./constants.js";
|
|
2
2
|
//#region lib/utils/zoom.ts
|
|
3
|
-
var t = (e) => e * 100 <= 25, n = (t) => t * 100 >= e
|
|
3
|
+
var t = (e) => e * 100 <= 25, n = (t) => t * 100 >= e, r = (t) => {
|
|
4
|
+
let n = Math.floor(t / 25) * 25;
|
|
5
|
+
return Math.min(n + 25, e);
|
|
6
|
+
}, i = (e) => {
|
|
7
|
+
let t = Math.ceil(e / 25) * 25;
|
|
8
|
+
return Math.max(t - 25, 25);
|
|
9
|
+
};
|
|
4
10
|
//#endregion
|
|
5
|
-
export { n as isZoomInDisabled, t as isZoomOutDisabled };
|
|
11
|
+
export { r as getNextZoomInLevel, i as getNextZoomOutLevel, n as isZoomInDisabled, t as isZoomOutDisabled };
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./clsx-B7LyVm5O.js";
|
|
2
|
-
import { r as t } from "./dist-CKteKPPA.js";
|
|
3
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
-
import './assets/MenuItem.css';//#region lib/components/layout/toolbar/MenuItem.module.css
|
|
5
|
-
var r = { "rp-menu-item": "_rp-menu-item_cu12j_1" }, i = (i) => {
|
|
6
|
-
let { children: a, className: o, ...s } = i;
|
|
7
|
-
return /* @__PURE__ */ n(t, {
|
|
8
|
-
...s,
|
|
9
|
-
tabIndex: 0,
|
|
10
|
-
className: e(r["rp-menu-item"], o),
|
|
11
|
-
children: a
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { i as t };
|
|
@@ -1,242 +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, useMemo as S, useRef as C, useState as w } from "react";
|
|
18
|
-
import { jsx as T } from "react/jsx-runtime";
|
|
19
|
-
//#region lib/utils/hooks/useScrollToPage.ts
|
|
20
|
-
var E = () => {
|
|
21
|
-
let { viewMode: n } = o(), { scrollMode: r } = a(), { virtualScrollRef: i, virtualScrollableElementRef: u, pageScrollElementRef: d } = s(), { setFocusedPage: f } = k(), v = C(), { columnCount: b } = c(), { widths: S, heights: w } = p(), T = C(r), E = C(n), D = C(b), { targetScrollPage: O, scrollBehavior: A } = m(), j = C(null);
|
|
22
|
-
x(() => {
|
|
23
|
-
i?.scrollToItem && (v.current = i);
|
|
24
|
-
}, [i]), x(() => {
|
|
25
|
-
T.current = r, E.current = n;
|
|
26
|
-
}, [r, n]);
|
|
27
|
-
let M = 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: S[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
|
-
S,
|
|
45
|
-
l
|
|
46
|
-
]);
|
|
47
|
-
x(() => {
|
|
48
|
-
T.current = r, E.current = n;
|
|
49
|
-
}, [r, n]), x(() => {
|
|
50
|
-
D.current = b;
|
|
51
|
-
}, [b]);
|
|
52
|
-
let N = y((n, r = A) => {
|
|
53
|
-
f(n);
|
|
54
|
-
let i = n - 1, a = i, o = 0;
|
|
55
|
-
if (E.current === t.DUAL_PAGE && T.current === e.PAGE_SCROLLING) {
|
|
56
|
-
M(n, r);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (T.current === e.PAGE_SCROLLING) {
|
|
60
|
-
f(n);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (!v.current || !u) {
|
|
64
|
-
j.current = {
|
|
65
|
-
page: n,
|
|
66
|
-
behavior: r
|
|
67
|
-
};
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
j.current = null;
|
|
71
|
-
let s = u;
|
|
72
|
-
r === "smooth" && (O.current = n);
|
|
73
|
-
let c = E.current === t.DUAL_PAGE_WITH_COVER, { columnsWidth: l, rowsHeight: d } = g({
|
|
74
|
-
widths: S,
|
|
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
|
-
M,
|
|
121
|
-
f,
|
|
122
|
-
l,
|
|
123
|
-
w,
|
|
124
|
-
S,
|
|
125
|
-
A
|
|
126
|
-
]);
|
|
127
|
-
return x(() => {
|
|
128
|
-
if (!u || !j.current) return;
|
|
129
|
-
let { page: e, behavior: t } = j.current;
|
|
130
|
-
j.current = null, N(e, t);
|
|
131
|
-
}, [u, N]), { scrollToPage: N };
|
|
132
|
-
}, D = (n = 1) => {
|
|
133
|
-
let [r, i] = w(n), [s, c] = w(0), { scrollToPage: l } = E(), d = C(n), { viewMode: m } = o(), { scrollMode: h } = a(), { widths: g } = p(), { pagesRef: _ } = u(), v = f(r, 100), b = y((e) => {
|
|
134
|
-
if (!/^[0-9]*$/g.test(e.toString()) || !e) return {
|
|
135
|
-
success: !1,
|
|
136
|
-
currentPage: d.current
|
|
137
|
-
};
|
|
138
|
-
let t = +e;
|
|
139
|
-
return t <= 0 || t > s ? {
|
|
140
|
-
success: !1,
|
|
141
|
-
currentPage: d.current
|
|
142
|
-
} : (i(t), d.current = t, {
|
|
143
|
-
success: !0,
|
|
144
|
-
currentPage: +e
|
|
145
|
-
});
|
|
146
|
-
}, [s]), x = y(b, [b]), T = y((e) => {
|
|
147
|
-
i(e), d.current = e;
|
|
148
|
-
}, []), D = y((e, t) => {
|
|
149
|
-
let n = b(e);
|
|
150
|
-
return n.success && l(n.currentPage, t), n;
|
|
151
|
-
}, [b, l]), O = y((e) => {
|
|
152
|
-
let n = e % 2 == 1;
|
|
153
|
-
if (!_ || n) return !1;
|
|
154
|
-
let r = n ? g[e] : g[e - 1], i = n ? g[e + 1] : g[e];
|
|
155
|
-
return m === t.DUAL_PAGE && r + i < _.clientWidth;
|
|
156
|
-
}, [
|
|
157
|
-
m,
|
|
158
|
-
g,
|
|
159
|
-
_,
|
|
160
|
-
s
|
|
161
|
-
]), k = y(() => {
|
|
162
|
-
let e = r - 1;
|
|
163
|
-
O(e) && (e = r - 2), D(e);
|
|
164
|
-
}, [
|
|
165
|
-
D,
|
|
166
|
-
r,
|
|
167
|
-
m,
|
|
168
|
-
h,
|
|
169
|
-
O
|
|
170
|
-
]), A = S(() => m === t.DUAL_PAGE && h === e.PAGE_SCROLLING ? r === s - 1 : r === s, [
|
|
171
|
-
r,
|
|
172
|
-
s,
|
|
173
|
-
m,
|
|
174
|
-
h
|
|
175
|
-
]);
|
|
176
|
-
return {
|
|
177
|
-
focusedPage: v,
|
|
178
|
-
totalPages: s,
|
|
179
|
-
setFocusedPage: x,
|
|
180
|
-
resetPage: T,
|
|
181
|
-
setTotalPages: c,
|
|
182
|
-
nextPage: y(() => {
|
|
183
|
-
if (A) return;
|
|
184
|
-
let e = r + 1;
|
|
185
|
-
O(e) && (e = r + 2), D(e);
|
|
186
|
-
}, [
|
|
187
|
-
D,
|
|
188
|
-
r,
|
|
189
|
-
O,
|
|
190
|
-
m,
|
|
191
|
-
h,
|
|
192
|
-
A
|
|
193
|
-
]),
|
|
194
|
-
prevPage: k,
|
|
195
|
-
goToPage: D
|
|
196
|
-
};
|
|
197
|
-
}, O = v({
|
|
198
|
-
focusedPage: 0,
|
|
199
|
-
setFocusedPage: (e) => {},
|
|
200
|
-
goToPage: (e, t) => ({
|
|
201
|
-
success: !!e,
|
|
202
|
-
currentPage: +e
|
|
203
|
-
}),
|
|
204
|
-
totalPages: 0,
|
|
205
|
-
setTotalPages: (e) => {},
|
|
206
|
-
prevPage: () => {},
|
|
207
|
-
nextPage: () => {}
|
|
208
|
-
}), k = () => {
|
|
209
|
-
let e = b(O);
|
|
210
|
-
return e?.focusedPage === void 0 && n.error("Please use this hooks inside children component of RPProvider"), e;
|
|
211
|
-
}, A = ({ children: e }) => {
|
|
212
|
-
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 } = D(a), h = C(!0);
|
|
213
|
-
return x(() => {
|
|
214
|
-
if (!t) {
|
|
215
|
-
h.current || (u(0), l(1));
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (!t.numPages) return;
|
|
219
|
-
u(t.numPages);
|
|
220
|
-
let e = h.current ? a : 1;
|
|
221
|
-
l(Math.min(Math.max(e, 1), t.numPages)), h.current = !1;
|
|
222
|
-
}, [
|
|
223
|
-
t,
|
|
224
|
-
u,
|
|
225
|
-
l
|
|
226
|
-
]), x(() => {
|
|
227
|
-
n(o);
|
|
228
|
-
}, [o, n]), /* @__PURE__ */ T(O.Provider, {
|
|
229
|
-
value: {
|
|
230
|
-
focusedPage: o,
|
|
231
|
-
totalPages: s,
|
|
232
|
-
setFocusedPage: c,
|
|
233
|
-
setTotalPages: u,
|
|
234
|
-
nextPage: p,
|
|
235
|
-
prevPage: m,
|
|
236
|
-
goToPage: f
|
|
237
|
-
},
|
|
238
|
-
children: e
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
//#endregion
|
|
242
|
-
export { E as a, D as i, A as n, k as r, O as t };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import './assets/RPLayout.css';//#region lib/components/layout/RPLayout.module.css
|
|
2
|
-
var e = {
|
|
3
|
-
"rp-layout": "_rp-layout_1yzm4_1",
|
|
4
|
-
"rp-layout-wrapper": "_rp-layout-wrapper_1yzm4_5",
|
|
5
|
-
"rp-content": "_rp-content_1yzm4_11",
|
|
6
|
-
"rp-sidebar": "_rp-sidebar_1yzm4_18",
|
|
7
|
-
"rp-pages": "_rp-pages_1yzm4_23",
|
|
8
|
-
"rp-container": "_rp-container_1yzm4_29",
|
|
9
|
-
"rp-loader": "_rp-loader_1yzm4_33",
|
|
10
|
-
"rp-theme-variables": "_rp-theme-variables_1yzm4_37",
|
|
11
|
-
"rp-dark-mode": "_rp-dark-mode_1yzm4_156"
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { e as t };
|