@react-pdf-kit/viewer 2.2.1-rc.0 → 2.2.1-rc.1
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/dist/{PaginationContext-a3021a65.js → PaginationContext-bf510f3e.js} +68 -68
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPPages.js +523 -511
- package/dist/components/RPProvider.js +1 -1
- 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/OtherTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/RPMoreOptions.js +1 -1
- package/dist/components/layout/toolbar/RPToolbar.js +1 -1
- package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
- package/dist/components/layout/toolbar/SearchResultNavigator.js +1 -1
- package/dist/components/layout/toolbar/SearchTool.js +1 -1
- package/dist/components/layout/toolbar/ToolbarCustom.js +1 -1
- package/dist/components/layout/toolbar/ToolbarDefault.js +1 -1
- package/dist/components/layout/toolbar/ToolbarLayout.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/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/defaults/RPHorizontalBar.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +1 -1
- 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 +1 -1
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +1 -1
- package/dist/contexts/SearchContext.js +1 -1
- package/dist/main.js +1 -1
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/usePaginate.js +1 -1
- package/dist/utils/hooks/usePresentPage.js +1 -1
- package/dist/utils/hooks/useScrollToPage.js +1 -1
- package/dist/utils/hooks/useSearch.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as H } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { ViewMode as
|
|
2
|
+
import { useRef as L, useEffect as G, useCallback as h, useState as w, useMemo as y, createContext as j, useContext as Z } from "react";
|
|
3
|
+
import { ViewMode as I, ScrollMode as E } from "./utils/types.js";
|
|
4
4
|
import { useScrollModeContext as O } from "./contexts/ScrollModeContext.js";
|
|
5
5
|
import { useDocumentContext as $ } from "./contexts/RPDocumentContext.js";
|
|
6
6
|
import { appConsole as q } from "./utils/appConsole.js";
|
|
@@ -9,22 +9,22 @@ import { useInitialStateContext as J } from "./contexts/InitialStateContext.js";
|
|
|
9
9
|
import { useViewModeContext as W } from "./contexts/ViewModeContext.js";
|
|
10
10
|
import { useVirtualScrollContext as K } from "./contexts/VirtualScrollContext.js";
|
|
11
11
|
import { useVirtualGridContext as Q } from "./contexts/VirtualGridContext.js";
|
|
12
|
-
import { smoothScrollTo as
|
|
12
|
+
import { smoothScrollTo as F } from "./utils/smoothScrollTo.js";
|
|
13
13
|
import { useDimensionPagesContext as b } from "./contexts/DimensionPagesContext.js";
|
|
14
14
|
import { useSmoothScrollContext as X } from "./contexts/SmoothScrollContext.js";
|
|
15
|
-
import { getScrollDistance as
|
|
15
|
+
import { getScrollDistance as D } from "./utils/getScrollDistance.js";
|
|
16
16
|
import { getGridDimension as Y } from "./utils/calculatePage.js";
|
|
17
17
|
import { useDebounce as tt } from "./utils/hooks/useDebounce.js";
|
|
18
18
|
import { useLayoutContainer as et } from "./contexts/LayoutContainerContext.js";
|
|
19
19
|
const ot = () => {
|
|
20
|
-
const { viewMode: o } = W(), { scrollMode: e } = O(), { virtualScrollRef: i, virtualScrollableElementRef: s, pageScrollElementRef: a } = K(), { setFocusedPage:
|
|
21
|
-
|
|
20
|
+
const { viewMode: o } = W(), { scrollMode: e } = O(), { virtualScrollRef: i, virtualScrollableElementRef: s, pageScrollElementRef: a } = K(), { setFocusedPage: x } = st(), f = L(), { columnCount: r } = Q(), { widths: c, heights: g } = b(), l = L(e), C = L(o), m = L(r), { targetScrollPage: A } = X();
|
|
21
|
+
G(() => {
|
|
22
22
|
i != null && i.scrollToItem && (f.current = i);
|
|
23
|
-
}, [i]),
|
|
24
|
-
l.current = e,
|
|
23
|
+
}, [i]), G(() => {
|
|
24
|
+
l.current = e, C.current = o;
|
|
25
25
|
}, [e, o]);
|
|
26
|
-
const
|
|
27
|
-
(u,
|
|
26
|
+
const S = h(
|
|
27
|
+
(u, d) => {
|
|
28
28
|
if (!a)
|
|
29
29
|
return;
|
|
30
30
|
const P = Math.ceil(u / 2) * 2 - 1;
|
|
@@ -34,7 +34,7 @@ const ot = () => {
|
|
|
34
34
|
top: 0
|
|
35
35
|
};
|
|
36
36
|
return new Promise(
|
|
37
|
-
(n) =>
|
|
37
|
+
(n) => F(a, t, n)
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
const T = {
|
|
@@ -43,121 +43,121 @@ const ot = () => {
|
|
|
43
43
|
};
|
|
44
44
|
return a == null ? void 0 : a.scrollTo({
|
|
45
45
|
...T,
|
|
46
|
-
behavior:
|
|
46
|
+
behavior: d
|
|
47
47
|
});
|
|
48
48
|
},
|
|
49
|
-
[a, c,
|
|
49
|
+
[a, c, F]
|
|
50
50
|
);
|
|
51
|
-
return
|
|
52
|
-
l.current = e,
|
|
53
|
-
}, [e, o]),
|
|
54
|
-
|
|
55
|
-
}, [r]), { scrollToPage:
|
|
56
|
-
(u,
|
|
57
|
-
|
|
51
|
+
return G(() => {
|
|
52
|
+
l.current = e, C.current = o;
|
|
53
|
+
}, [e, o]), G(() => {
|
|
54
|
+
m.current = r;
|
|
55
|
+
}, [r]), { scrollToPage: h(
|
|
56
|
+
(u, d = "smooth") => {
|
|
57
|
+
x(u);
|
|
58
58
|
const P = u - 1;
|
|
59
59
|
let T = P, t = 0;
|
|
60
|
-
if (
|
|
61
|
-
|
|
60
|
+
if (C.current === I.DUAL_PAGE && l.current === E.PAGE_SCROLLING) {
|
|
61
|
+
S(u, d);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
if (l.current ===
|
|
65
|
-
|
|
64
|
+
if (l.current === E.PAGE_SCROLLING) {
|
|
65
|
+
x(u);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (!f.current || !s)
|
|
69
69
|
return;
|
|
70
70
|
const n = s;
|
|
71
|
-
|
|
72
|
-
const { columnsWidth:
|
|
71
|
+
d === "smooth" && (A.current = u);
|
|
72
|
+
const { columnsWidth: p, rowsHeight: R } = Y(
|
|
73
73
|
{ widths: c, heights: g },
|
|
74
74
|
r
|
|
75
75
|
);
|
|
76
|
-
if (l.current ===
|
|
76
|
+
if (l.current === E.HORIZONTAL_SCROLLING) {
|
|
77
77
|
t = P;
|
|
78
|
-
const
|
|
79
|
-
left: Math.floor(
|
|
78
|
+
const N = D(p, t), _ = {
|
|
79
|
+
left: Math.floor(N),
|
|
80
80
|
top: 0
|
|
81
81
|
};
|
|
82
82
|
return n.scrollTo({
|
|
83
83
|
..._,
|
|
84
|
-
behavior:
|
|
84
|
+
behavior: d
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
if (
|
|
87
|
+
if (C.current === I.DUAL_PAGE) {
|
|
88
88
|
t = P % 2, T = Math.floor(P / 2);
|
|
89
|
-
const _ =
|
|
89
|
+
const _ = D(p, t), k = D(R, T), z = {
|
|
90
90
|
left: Math.floor(_),
|
|
91
91
|
top: Math.floor(k)
|
|
92
92
|
};
|
|
93
93
|
return n.scrollTo({
|
|
94
94
|
...z,
|
|
95
|
-
behavior:
|
|
95
|
+
behavior: d
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
const U = R
|
|
98
|
+
const U = D(R, T), V = {
|
|
99
99
|
left: 0,
|
|
100
100
|
top: Math.floor(U)
|
|
101
101
|
};
|
|
102
102
|
return n.scrollTo({
|
|
103
103
|
...V,
|
|
104
|
-
behavior:
|
|
104
|
+
behavior: d
|
|
105
105
|
});
|
|
106
106
|
},
|
|
107
107
|
[
|
|
108
108
|
s,
|
|
109
109
|
r,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
S,
|
|
111
|
+
x,
|
|
112
|
+
F,
|
|
113
113
|
g,
|
|
114
114
|
c
|
|
115
115
|
]
|
|
116
116
|
) };
|
|
117
117
|
}, rt = (o = 1) => {
|
|
118
|
-
const [e, i] =
|
|
118
|
+
const [e, i] = w(o), [s, a] = w(0), { scrollToPage: x } = ot(), f = L(o), { viewMode: r } = W(), { scrollMode: c } = O(), { widths: g } = b(), { pagesRef: l } = et(), C = tt(e, 100), m = h(
|
|
119
119
|
(t) => {
|
|
120
120
|
if (!/^[0-9]*$/g.test(t.toString()) || !t)
|
|
121
121
|
return { success: !1, currentPage: f.current };
|
|
122
|
-
const
|
|
123
|
-
return
|
|
122
|
+
const p = +t;
|
|
123
|
+
return p < 0 || p > s ? { success: !1, currentPage: f.current } : (i(p), f.current = p, { success: !0, currentPage: +t });
|
|
124
124
|
},
|
|
125
125
|
[s]
|
|
126
|
-
),
|
|
126
|
+
), A = h(m, [m]), S = h((t) => {
|
|
127
127
|
i(t), f.current = t;
|
|
128
|
-
}, []),
|
|
128
|
+
}, []), M = h(
|
|
129
129
|
(t) => {
|
|
130
|
-
const n =
|
|
131
|
-
return n.success &&
|
|
130
|
+
const n = m(t);
|
|
131
|
+
return n.success && x(n.currentPage), n;
|
|
132
132
|
},
|
|
133
|
-
[
|
|
134
|
-
), u =
|
|
133
|
+
[m, x]
|
|
134
|
+
), u = h(
|
|
135
135
|
(t) => {
|
|
136
136
|
const n = t % 2 === 1;
|
|
137
137
|
if (!l || n)
|
|
138
138
|
return !1;
|
|
139
|
-
const
|
|
140
|
-
return r ===
|
|
139
|
+
const p = n ? g[t] : g[t - 1], R = n ? g[t + 1] : g[t];
|
|
140
|
+
return r === I.DUAL_PAGE && p + R < l.clientWidth;
|
|
141
141
|
},
|
|
142
142
|
[r, g, l, s]
|
|
143
|
-
),
|
|
143
|
+
), d = h(() => {
|
|
144
144
|
let t = e - 1;
|
|
145
|
-
u(t) && (t = e - 2),
|
|
146
|
-
}, [
|
|
145
|
+
u(t) && (t = e - 2), M(t);
|
|
146
|
+
}, [M, e, r, c, u]), P = y(() => r === I.DUAL_PAGE && c === E.PAGE_SCROLLING ? e === s - 1 : e === s, [e, s, r, c]), T = h(() => {
|
|
147
147
|
if (P)
|
|
148
148
|
return;
|
|
149
149
|
let t = e + 1;
|
|
150
|
-
u(t) && (t = e + 2),
|
|
151
|
-
}, [
|
|
150
|
+
u(t) && (t = e + 2), M(t);
|
|
151
|
+
}, [M, e, u, r, c, P]);
|
|
152
152
|
return {
|
|
153
|
-
focusedPage:
|
|
153
|
+
focusedPage: C,
|
|
154
154
|
totalPages: s,
|
|
155
|
-
setFocusedPage:
|
|
156
|
-
resetPage:
|
|
155
|
+
setFocusedPage: A,
|
|
156
|
+
resetPage: S,
|
|
157
157
|
setTotalPages: a,
|
|
158
158
|
nextPage: T,
|
|
159
|
-
prevPage:
|
|
160
|
-
goToPage:
|
|
159
|
+
prevPage: d,
|
|
160
|
+
goToPage: M
|
|
161
161
|
};
|
|
162
162
|
}, v = j({
|
|
163
163
|
focusedPage: 0,
|
|
@@ -177,32 +177,32 @@ const ot = () => {
|
|
|
177
177
|
}, Lt = ({ children: o }) => {
|
|
178
178
|
const { pdf: e } = $(), { setCurrentPage: i } = B(), { initialPage: s = 1 } = J(), {
|
|
179
179
|
focusedPage: a,
|
|
180
|
-
totalPages:
|
|
180
|
+
totalPages: x,
|
|
181
181
|
setFocusedPage: f,
|
|
182
182
|
resetPage: r,
|
|
183
183
|
setTotalPages: c,
|
|
184
184
|
goToPage: g,
|
|
185
185
|
nextPage: l,
|
|
186
|
-
prevPage:
|
|
187
|
-
} = rt(s);
|
|
188
|
-
return
|
|
186
|
+
prevPage: C
|
|
187
|
+
} = rt(s), m = L(!0);
|
|
188
|
+
return G(() => {
|
|
189
189
|
if (!(e != null && e.numPages))
|
|
190
190
|
return;
|
|
191
191
|
c(e.numPages);
|
|
192
|
-
const
|
|
193
|
-
r(
|
|
194
|
-
}, [e, c, r]),
|
|
192
|
+
const A = m.current ? s : 1, S = Math.min(Math.max(A, 1), e.numPages);
|
|
193
|
+
r(S), m.current = !1;
|
|
194
|
+
}, [e, c, r]), G(() => {
|
|
195
195
|
i(a);
|
|
196
196
|
}, [a, i]), /* @__PURE__ */ H(
|
|
197
197
|
v.Provider,
|
|
198
198
|
{
|
|
199
199
|
value: {
|
|
200
200
|
focusedPage: a,
|
|
201
|
-
totalPages:
|
|
201
|
+
totalPages: x,
|
|
202
202
|
setFocusedPage: f,
|
|
203
203
|
setTotalPages: c,
|
|
204
204
|
nextPage: l,
|
|
205
|
-
prevPage:
|
|
205
|
+
prevPage: C,
|
|
206
206
|
goToPage: g
|
|
207
207
|
},
|
|
208
208
|
children: o
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { useState as o } from "react";
|
|
3
|
-
import { P as w } from "../PaginationContext-
|
|
3
|
+
import { P as w } from "../PaginationContext-bf510f3e.js";
|
|
4
4
|
import { DarkModeProvider as D } from "../contexts/DarkModeContext.js";
|
|
5
5
|
import { ViewMode as E, ScrollMode as F, SelectionMode as G } from "../utils/types.js";
|
|
6
6
|
import { RotateProvider as I } from "../contexts/RotationContext.js";
|