@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.
Files changed (45) hide show
  1. package/dist/{PaginationContext-a3021a65.js → PaginationContext-bf510f3e.js} +68 -68
  2. package/dist/components/RPController.js +1 -1
  3. package/dist/components/RPPages.js +523 -511
  4. package/dist/components/RPProvider.js +1 -1
  5. package/dist/components/layout/RPDefaultLayout.js +1 -1
  6. package/dist/components/layout/RPLayout.js +1 -1
  7. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  8. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  9. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  10. package/dist/components/layout/toolbar/MostPageTool.js +1 -1
  11. package/dist/components/layout/toolbar/OtherTool.js +1 -1
  12. package/dist/components/layout/toolbar/Paginate.js +1 -1
  13. package/dist/components/layout/toolbar/RPMoreOptions.js +1 -1
  14. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  15. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  16. package/dist/components/layout/toolbar/SearchResultNavigator.js +1 -1
  17. package/dist/components/layout/toolbar/SearchTool.js +1 -1
  18. package/dist/components/layout/toolbar/ToolbarCustom.js +1 -1
  19. package/dist/components/layout/toolbar/ToolbarDefault.js +1 -1
  20. package/dist/components/layout/toolbar/ToolbarLayout.js +1 -1
  21. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
  22. package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
  23. package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
  24. package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
  25. package/dist/components/layout/toolbar/tools/NextPageTool.js +1 -1
  26. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
  27. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +1 -1
  28. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +1 -1
  29. package/dist/components/page/AnnotationLayer.js +1 -1
  30. package/dist/components/page/CanvasLayer.js +1 -1
  31. package/dist/components/page/DualPage.js +1 -1
  32. package/dist/components/page/DualPageWithCover.js +1 -1
  33. package/dist/components/page/RPPage.js +1 -1
  34. package/dist/components/page/SinglePage.js +1 -1
  35. package/dist/components/page/TextLayer.js +1 -1
  36. package/dist/contexts/PaginationContext.js +1 -1
  37. package/dist/contexts/RenderQueueProvider.js +1 -1
  38. package/dist/contexts/SearchContext.js +1 -1
  39. package/dist/main.js +1 -1
  40. package/dist/utils/hooks/useLicense.js +1 -1
  41. package/dist/utils/hooks/usePaginate.js +1 -1
  42. package/dist/utils/hooks/usePresentPage.js +1 -1
  43. package/dist/utils/hooks/useScrollToPage.js +1 -1
  44. package/dist/utils/hooks/useSearch.js +1 -1
  45. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
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";
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 N } from "./utils/smoothScrollTo.js";
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 R } from "./utils/getScrollDistance.js";
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: 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(() => {
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]), M(() => {
24
- l.current = e, x.current = o;
23
+ }, [i]), G(() => {
24
+ l.current = e, C.current = o;
25
25
  }, [e, o]);
26
- const A = p(
27
- (u, m) => {
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) => N(a, t, 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: m
46
+ behavior: d
47
47
  });
48
48
  },
49
- [a, c, N]
49
+ [a, c, F]
50
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);
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 (x.current === E.DUAL_PAGE && l.current === D.PAGE_SCROLLING) {
61
- A(u, m);
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 === D.PAGE_SCROLLING) {
65
- h(u);
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
- m === "smooth" && (I.current = u);
72
- const { columnsWidth: d, rowsHeight: L } = Y(
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 === D.HORIZONTAL_SCROLLING) {
76
+ if (l.current === E.HORIZONTAL_SCROLLING) {
77
77
  t = P;
78
- const w = R(d, t), _ = {
79
- left: Math.floor(w),
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: m
84
+ behavior: d
85
85
  });
86
86
  }
87
- if (x.current === E.DUAL_PAGE) {
87
+ if (C.current === I.DUAL_PAGE) {
88
88
  t = P % 2, T = Math.floor(P / 2);
89
- const _ = R(d, t), k = R(L, T), z = {
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: m
95
+ behavior: d
96
96
  });
97
97
  }
98
- const U = R(L, T), V = {
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: m
104
+ behavior: d
105
105
  });
106
106
  },
107
107
  [
108
108
  s,
109
109
  r,
110
- A,
111
- h,
112
- N,
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] = 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(
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 d = +t;
123
- return d < 0 || d > s ? { success: !1, currentPage: f.current } : (i(d), f.current = d, { success: !0, currentPage: +t });
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
- ), I = p(C, [C]), A = p((t) => {
126
+ ), A = h(m, [m]), S = h((t) => {
127
127
  i(t), f.current = t;
128
- }, []), S = p(
128
+ }, []), M = h(
129
129
  (t) => {
130
- const n = C(t);
131
- return n.success && h(n.currentPage), n;
130
+ const n = m(t);
131
+ return n.success && x(n.currentPage), n;
132
132
  },
133
- [C, h]
134
- ), u = p(
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 d = n ? g[t] : g[t - 1], L = n ? g[t + 1] : g[t];
140
- return r === E.DUAL_PAGE && d + L < l.clientWidth;
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
- ), m = p(() => {
143
+ ), d = h(() => {
144
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(() => {
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), S(t);
151
- }, [S, e, u, r, c, P]);
150
+ u(t) && (t = e + 2), M(t);
151
+ }, [M, e, u, r, c, P]);
152
152
  return {
153
- focusedPage: x,
153
+ focusedPage: C,
154
154
  totalPages: s,
155
- setFocusedPage: I,
156
- resetPage: A,
155
+ setFocusedPage: A,
156
+ resetPage: S,
157
157
  setTotalPages: a,
158
158
  nextPage: T,
159
- prevPage: m,
160
- goToPage: S
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: h,
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: x
187
- } = rt(s);
188
- return M(() => {
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 C = Math.min(Math.max(s, 1), e.numPages);
193
- r(C);
194
- }, [e, c, r]), M(() => {
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: h,
201
+ totalPages: x,
202
202
  setFocusedPage: f,
203
203
  setTotalPages: c,
204
204
  nextPage: l,
205
- prevPage: x,
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-a3021a65.js";
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";