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