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