@pdf-viewer/react 1.0.1-rc.0 → 1.0.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 (58) hide show
  1. package/dist/{RPDefaultLayout-07939e60.js → RPDefaultLayout-adbb0836.js} +246 -246
  2. package/dist/components/RPConfig.js +318 -340
  3. package/dist/components/RPController.js +43 -45
  4. package/dist/components/RPPages.js +2 -3
  5. package/dist/components/RPProvider.js +1 -1
  6. package/dist/components/layout/RPDefaultLayout.js +3 -2
  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/DocumentDialog.js +2 -3
  11. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  12. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  13. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  14. package/dist/components/layout/toolbar/MostPageTool.js +3 -4
  15. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  16. package/dist/components/layout/toolbar/Paginate.js +1 -1
  17. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  18. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  19. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  20. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  21. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  22. package/dist/components/layout/toolbar/SearchTool.js +2 -3
  23. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  24. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  25. package/dist/components/layout/toolbar/ZoomTool.js +3 -3
  26. package/dist/components/page/AnnotationLayer.js +2 -3
  27. package/dist/components/page/CanvasLayer.js +2 -3
  28. package/dist/components/page/DualPage.js +1 -1
  29. package/dist/components/page/RPPage.js +2 -3
  30. package/dist/components/page/SinglePage.js +1 -1
  31. package/dist/components/page/TextLayer.js +2 -3
  32. package/dist/components/ui/Checkbox.js +252 -92
  33. package/dist/components/ui/DropDown.js +1 -1
  34. package/dist/components/ui/LoadingIndicator.js +1 -1
  35. package/dist/components/ui/RPTooltip.js +961 -224
  36. package/dist/contexts/PaginationContext.js +1 -1
  37. package/dist/contexts/PrintContext.js +1 -1
  38. package/dist/contexts/SearchContext.js +1 -1
  39. package/dist/contexts/ThumbnailsContext.js +1 -1
  40. package/dist/contexts/ViewportContext.js +41 -41
  41. package/dist/floating-ui.react-dom-e6d5fe8f.js +1327 -0
  42. package/dist/index-316854c1.js +2299 -0
  43. package/dist/index-71898eb9.js +139 -0
  44. package/dist/main.js +1 -1
  45. package/dist/types/contexts/ViewportContext.d.ts +0 -1
  46. package/dist/types/utils/types.d.ts +2 -2
  47. package/dist/utils/hooks/useFileDownload.js +2 -3
  48. package/dist/utils/hooks/useLicense.js +1 -1
  49. package/dist/utils/hooks/usePaginate.js +2 -3
  50. package/dist/utils/hooks/usePrint.js +2 -3
  51. package/dist/utils/hooks/useScrollToPage.js +2 -3
  52. package/dist/utils/hooks/useSearch.js +2 -3
  53. package/dist/utils/hooks/useThumbnail.js +2 -3
  54. package/dist/utils/hooks/useVirtualReactWindow.js +2 -3
  55. package/package.json +1 -1
  56. package/dist/index-1db49c1a.js +0 -1664
  57. package/dist/index-3dff3fa8.js +0 -307
  58. package/dist/index-4f17fe4d.js +0 -1657
@@ -1,114 +1,274 @@
1
- import { jsxs as g, jsx as s } from "react/jsx-runtime";
2
- import * as c from "react";
3
- import { c as O, a as j, u as A, P as S, b as _, d as B, e as H } from "../../index-3dff3fa8.js";
4
- import { CheckIcon as K } from "../icons/CheckIcon.js";
5
- import '../../assets/Checkbox.css';function L(e) {
6
- const r = c.useRef({ value: e, previous: e });
7
- return c.useMemo(() => (r.current.value !== e && (r.current.previous = r.current.value, r.current.value = e), r.current.previous), [e]);
1
+ import { jsx as f, Fragment as q, jsxs as M } from "react/jsx-runtime";
2
+ import * as i from "react";
3
+ import { a as A, c as B, b as K, d as z } from "../../index-71898eb9.js";
4
+ import "react-dom";
5
+ import { CheckIcon as X } from "../icons/CheckIcon.js";
6
+ import '../../assets/Checkbox.css';function S(e, t) {
7
+ if (typeof e == "function")
8
+ return e(t);
9
+ e != null && (e.current = t);
8
10
  }
9
- var E = "Checkbox", [z, W] = O(E), [F, T] = z(E), w = c.forwardRef(
10
- (e, r) => {
11
+ function I(...e) {
12
+ return (t) => {
13
+ let n = !1;
14
+ const r = e.map((o) => {
15
+ const c = S(o, t);
16
+ return !n && typeof c == "function" && (n = !0), c;
17
+ });
18
+ if (n)
19
+ return () => {
20
+ for (let o = 0; o < r.length; o++) {
21
+ const c = r[o];
22
+ typeof c == "function" ? c() : S(e[o], null);
23
+ }
24
+ };
25
+ };
26
+ }
27
+ function T(...e) {
28
+ return i.useCallback(I(...e), e);
29
+ }
30
+ function O(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
31
+ return function(o) {
32
+ if (e == null || e(o), n === !1 || !o.defaultPrevented)
33
+ return t == null ? void 0 : t(o);
34
+ };
35
+ }
36
+ function $(e) {
37
+ const t = i.useRef({ value: e, previous: e });
38
+ return i.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
39
+ }
40
+ function Z(e, t) {
41
+ return i.useReducer((n, r) => t[n][r] ?? n, e);
42
+ }
43
+ var _ = (e) => {
44
+ const { present: t, children: n } = e, r = G(t), o = typeof n == "function" ? n({ present: r.isPresent }) : i.Children.only(n), c = T(r.ref, J(o));
45
+ return typeof n == "function" || r.isPresent ? i.cloneElement(o, { ref: c }) : null;
46
+ };
47
+ _.displayName = "Presence";
48
+ function G(e) {
49
+ const [t, n] = i.useState(), r = i.useRef({}), o = i.useRef(e), c = i.useRef("none"), a = e ? "mounted" : "unmounted", [s, l] = Z(a, {
50
+ mounted: {
51
+ UNMOUNT: "unmounted",
52
+ ANIMATION_OUT: "unmountSuspended"
53
+ },
54
+ unmountSuspended: {
55
+ MOUNT: "mounted",
56
+ ANIMATION_END: "unmounted"
57
+ },
58
+ unmounted: {
59
+ MOUNT: "mounted"
60
+ }
61
+ });
62
+ return i.useEffect(() => {
63
+ const u = R(r.current);
64
+ c.current = s === "mounted" ? u : "none";
65
+ }, [s]), A(() => {
66
+ const u = r.current, p = o.current;
67
+ if (p !== e) {
68
+ const d = c.current, m = R(u);
69
+ e ? l("MOUNT") : m === "none" || (u == null ? void 0 : u.display) === "none" ? l("UNMOUNT") : l(p && d !== m ? "ANIMATION_OUT" : "UNMOUNT"), o.current = e;
70
+ }
71
+ }, [e, l]), A(() => {
72
+ if (t) {
73
+ let u;
74
+ const p = t.ownerDocument.defaultView ?? window, C = (m) => {
75
+ const y = R(r.current).includes(m.animationName);
76
+ if (m.target === t && y && (l("ANIMATION_END"), !o.current)) {
77
+ const g = t.style.animationFillMode;
78
+ t.style.animationFillMode = "forwards", u = p.setTimeout(() => {
79
+ t.style.animationFillMode === "forwards" && (t.style.animationFillMode = g);
80
+ });
81
+ }
82
+ }, d = (m) => {
83
+ m.target === t && (c.current = R(r.current));
84
+ };
85
+ return t.addEventListener("animationstart", d), t.addEventListener("animationcancel", C), t.addEventListener("animationend", C), () => {
86
+ p.clearTimeout(u), t.removeEventListener("animationstart", d), t.removeEventListener("animationcancel", C), t.removeEventListener("animationend", C);
87
+ };
88
+ } else
89
+ l("ANIMATION_END");
90
+ }, [t, l]), {
91
+ isPresent: ["mounted", "unmountSuspended"].includes(s),
92
+ ref: i.useCallback((u) => {
93
+ u && (r.current = getComputedStyle(u)), n(u);
94
+ }, [])
95
+ };
96
+ }
97
+ function R(e) {
98
+ return (e == null ? void 0 : e.animationName) || "none";
99
+ }
100
+ function J(e) {
101
+ var r, o;
102
+ let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
103
+ return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
104
+ }
105
+ var D = i.forwardRef((e, t) => {
106
+ const { children: n, ...r } = e, o = i.Children.toArray(n), c = o.find(Y);
107
+ if (c) {
108
+ const a = c.props.children, s = o.map((l) => l === c ? i.Children.count(a) > 1 ? i.Children.only(null) : i.isValidElement(a) ? a.props.children : null : l);
109
+ return /* @__PURE__ */ f(E, { ...r, ref: t, children: i.isValidElement(a) ? i.cloneElement(a, void 0, s) : null });
110
+ }
111
+ return /* @__PURE__ */ f(E, { ...r, ref: t, children: n });
112
+ });
113
+ D.displayName = "Slot";
114
+ var E = i.forwardRef((e, t) => {
115
+ const { children: n, ...r } = e;
116
+ if (i.isValidElement(n)) {
117
+ const o = ee(n);
118
+ return i.cloneElement(n, {
119
+ ...H(r, n.props),
120
+ // @ts-ignore
121
+ ref: t ? I(t, o) : o
122
+ });
123
+ }
124
+ return i.Children.count(n) > 1 ? i.Children.only(null) : null;
125
+ });
126
+ E.displayName = "SlotClone";
127
+ var Q = ({ children: e }) => /* @__PURE__ */ f(q, { children: e });
128
+ function Y(e) {
129
+ return i.isValidElement(e) && e.type === Q;
130
+ }
131
+ function H(e, t) {
132
+ const n = { ...t };
133
+ for (const r in t) {
134
+ const o = e[r], c = t[r];
135
+ /^on[A-Z]/.test(r) ? o && c ? n[r] = (...s) => {
136
+ c(...s), o(...s);
137
+ } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...c } : r === "className" && (n[r] = [o, c].filter(Boolean).join(" "));
138
+ }
139
+ return { ...e, ...n };
140
+ }
141
+ function ee(e) {
142
+ var r, o;
143
+ let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
144
+ return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
145
+ }
146
+ var te = [
147
+ "a",
148
+ "button",
149
+ "div",
150
+ "form",
151
+ "h2",
152
+ "h3",
153
+ "img",
154
+ "input",
155
+ "label",
156
+ "li",
157
+ "nav",
158
+ "ol",
159
+ "p",
160
+ "span",
161
+ "svg",
162
+ "ul"
163
+ ], U = te.reduce((e, t) => {
164
+ const n = i.forwardRef((r, o) => {
165
+ const { asChild: c, ...a } = r, s = c ? D : t;
166
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(s, { ...a, ref: o });
167
+ });
168
+ return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
169
+ }, {}), w = "Checkbox", [ne, fe] = B(w), [re, oe] = ne(w), W = i.forwardRef(
170
+ (e, t) => {
11
171
  const {
12
- __scopeCheckbox: t,
13
- name: a,
14
- checked: f,
15
- defaultChecked: n,
16
- required: h,
17
- disabled: u,
18
- value: b = "on",
19
- onCheckedChange: m,
20
- form: l,
21
- ...x
22
- } = e, [i, C] = c.useState(null), v = j(r, (o) => C(o)), y = c.useRef(!1), I = i ? l || !!i.closest("form") : !0, [p = !1, P] = A({
23
- prop: f,
24
- defaultProp: n,
25
- onChange: m
26
- }), q = c.useRef(p);
27
- return c.useEffect(() => {
28
- const o = i == null ? void 0 : i.form;
29
- if (o) {
30
- const k = () => P(q.current);
31
- return o.addEventListener("reset", k), () => o.removeEventListener("reset", k);
172
+ __scopeCheckbox: n,
173
+ name: r,
174
+ checked: o,
175
+ defaultChecked: c,
176
+ required: a,
177
+ disabled: s,
178
+ value: l = "on",
179
+ onCheckedChange: u,
180
+ form: p,
181
+ ...C
182
+ } = e, [d, m] = i.useState(null), k = T(t, (h) => m(h)), y = i.useRef(!1), g = d ? p || !!d.closest("form") : !0, [N = !1, x] = K({
183
+ prop: o,
184
+ defaultProp: c,
185
+ onChange: u
186
+ }), V = i.useRef(N);
187
+ return i.useEffect(() => {
188
+ const h = d == null ? void 0 : d.form;
189
+ if (h) {
190
+ const v = () => x(V.current);
191
+ return h.addEventListener("reset", v), () => h.removeEventListener("reset", v);
32
192
  }
33
- }, [i, P]), /* @__PURE__ */ g(F, { scope: t, state: p, disabled: u, children: [
34
- /* @__PURE__ */ s(
35
- S.button,
193
+ }, [d, x]), /* @__PURE__ */ M(re, { scope: n, state: N, disabled: s, children: [
194
+ /* @__PURE__ */ f(
195
+ U.button,
36
196
  {
37
197
  type: "button",
38
198
  role: "checkbox",
39
- "aria-checked": d(p) ? "mixed" : p,
40
- "aria-required": h,
41
- "data-state": M(p),
42
- "data-disabled": u ? "" : void 0,
43
- disabled: u,
44
- value: b,
45
- ...x,
46
- ref: v,
47
- onKeyDown: _(e.onKeyDown, (o) => {
48
- o.key === "Enter" && o.preventDefault();
199
+ "aria-checked": b(N) ? "mixed" : N,
200
+ "aria-required": a,
201
+ "data-state": F(N),
202
+ "data-disabled": s ? "" : void 0,
203
+ disabled: s,
204
+ value: l,
205
+ ...C,
206
+ ref: k,
207
+ onKeyDown: O(e.onKeyDown, (h) => {
208
+ h.key === "Enter" && h.preventDefault();
49
209
  }),
50
- onClick: _(e.onClick, (o) => {
51
- P((k) => d(k) ? !0 : !k), I && (y.current = o.isPropagationStopped(), y.current || o.stopPropagation());
210
+ onClick: O(e.onClick, (h) => {
211
+ x((v) => b(v) ? !0 : !v), g && (y.current = h.isPropagationStopped(), y.current || h.stopPropagation());
52
212
  })
53
213
  }
54
214
  ),
55
- I && /* @__PURE__ */ s(
56
- X,
215
+ g && /* @__PURE__ */ f(
216
+ ie,
57
217
  {
58
- control: i,
218
+ control: d,
59
219
  bubbles: !y.current,
60
- name: a,
61
- value: b,
62
- checked: p,
63
- required: h,
64
- disabled: u,
65
- form: l,
220
+ name: r,
221
+ value: l,
222
+ checked: N,
223
+ required: a,
224
+ disabled: s,
225
+ form: p,
66
226
  style: { transform: "translateX(-100%)" },
67
- defaultChecked: d(n) ? !1 : n
227
+ defaultChecked: b(c) ? !1 : c
68
228
  }
69
229
  )
70
230
  ] });
71
231
  }
72
232
  );
73
- w.displayName = E;
74
- var N = "CheckboxIndicator", D = c.forwardRef(
75
- (e, r) => {
76
- const { __scopeCheckbox: t, forceMount: a, ...f } = e, n = T(N, t);
77
- return /* @__PURE__ */ s(B, { present: a || d(n.state) || n.state === !0, children: /* @__PURE__ */ s(
78
- S.span,
233
+ W.displayName = w;
234
+ var L = "CheckboxIndicator", j = i.forwardRef(
235
+ (e, t) => {
236
+ const { __scopeCheckbox: n, forceMount: r, ...o } = e, c = oe(L, n);
237
+ return /* @__PURE__ */ f(_, { present: r || b(c.state) || c.state === !0, children: /* @__PURE__ */ f(
238
+ U.span,
79
239
  {
80
- "data-state": M(n.state),
81
- "data-disabled": n.disabled ? "" : void 0,
82
- ...f,
83
- ref: r,
240
+ "data-state": F(c.state),
241
+ "data-disabled": c.disabled ? "" : void 0,
242
+ ...o,
243
+ ref: t,
84
244
  style: { pointerEvents: "none", ...e.style }
85
245
  }
86
246
  ) });
87
247
  }
88
248
  );
89
- D.displayName = N;
90
- var X = (e) => {
91
- const { control: r, checked: t, bubbles: a = !0, defaultChecked: f, ...n } = e, h = c.useRef(null), u = L(t), b = H(r);
92
- c.useEffect(() => {
93
- const l = h.current, x = window.HTMLInputElement.prototype, C = Object.getOwnPropertyDescriptor(x, "checked").set;
94
- if (u !== t && C) {
95
- const v = new Event("click", { bubbles: a });
96
- l.indeterminate = d(t), C.call(l, d(t) ? !1 : t), l.dispatchEvent(v);
249
+ j.displayName = L;
250
+ var ie = (e) => {
251
+ const { control: t, checked: n, bubbles: r = !0, defaultChecked: o, ...c } = e, a = i.useRef(null), s = $(n), l = z(t);
252
+ i.useEffect(() => {
253
+ const p = a.current, C = window.HTMLInputElement.prototype, m = Object.getOwnPropertyDescriptor(C, "checked").set;
254
+ if (s !== n && m) {
255
+ const k = new Event("click", { bubbles: r });
256
+ p.indeterminate = b(n), m.call(p, b(n) ? !1 : n), p.dispatchEvent(k);
97
257
  }
98
- }, [u, t, a]);
99
- const m = c.useRef(d(t) ? !1 : t);
100
- return /* @__PURE__ */ s(
258
+ }, [s, n, r]);
259
+ const u = i.useRef(b(n) ? !1 : n);
260
+ return /* @__PURE__ */ f(
101
261
  "input",
102
262
  {
103
263
  type: "checkbox",
104
264
  "aria-hidden": !0,
105
- defaultChecked: f ?? m.current,
106
- ...n,
265
+ defaultChecked: o ?? u.current,
266
+ ...c,
107
267
  tabIndex: -1,
108
- ref: h,
268
+ ref: a,
109
269
  style: {
110
270
  ...e.style,
111
- ...b,
271
+ ...l,
112
272
  position: "absolute",
113
273
  pointerEvents: "none",
114
274
  opacity: 0,
@@ -117,25 +277,25 @@ var X = (e) => {
117
277
  }
118
278
  );
119
279
  };
120
- function d(e) {
280
+ function b(e) {
121
281
  return e === "indeterminate";
122
282
  }
123
- function M(e) {
124
- return d(e) ? "indeterminate" : e ? "checked" : "unchecked";
283
+ function F(e) {
284
+ return b(e) ? "indeterminate" : e ? "checked" : "unchecked";
125
285
  }
126
- var U = w, G = D;
127
- const R = {
286
+ var ce = W, se = j;
287
+ const P = {
128
288
  "rp-checkbox": "_rp-checkbox_11dq0_1",
129
289
  "rp-checkbox-indicator": "_rp-checkbox-indicator_11dq0_18"
130
- }, Y = ({
290
+ }, pe = ({
131
291
  children: e,
132
- value: r,
133
- name: t,
134
- onChange: a
135
- }) => /* @__PURE__ */ g("div", { style: { display: "flex", alignItems: "center", position: "relative" }, children: [
136
- /* @__PURE__ */ s(U, { className: R["rp-checkbox"], checked: r, id: t, onCheckedChange: a, children: /* @__PURE__ */ s(G, { className: R["rp-checkbox-indicator"], children: /* @__PURE__ */ s(K, {}) }) }),
137
- /* @__PURE__ */ s("label", { className: R["rp-checkbox-label"], htmlFor: t, children: e })
292
+ value: t,
293
+ name: n,
294
+ onChange: r
295
+ }) => /* @__PURE__ */ M("div", { style: { display: "flex", alignItems: "center", position: "relative" }, children: [
296
+ /* @__PURE__ */ f(ce, { className: P["rp-checkbox"], checked: t, id: n, onCheckedChange: r, children: /* @__PURE__ */ f(se, { className: P["rp-checkbox-indicator"], children: /* @__PURE__ */ f(X, {}) }) }),
297
+ /* @__PURE__ */ f("label", { className: P["rp-checkbox-label"], htmlFor: n, children: e })
138
298
  ] });
139
299
  export {
140
- Y as UICheckbox
300
+ pe as UICheckbox
141
301
  };
@@ -1,5 +1,5 @@
1
1
  import { jsxs as i, jsx as d } from "react/jsx-runtime";
2
- import { R as l, T as c, P as p, C as _ } from "../../index-1db49c1a.js";
2
+ import { R as l, T as c, P as p, C as _ } from "../../index-316854c1.js";
3
3
  import { c as A } from "../../clsx-0c6e471a.js";
4
4
  import '../../assets/DropDown.css';const F = "_slideDownAndFade_1000s_1", w = "_slideLeftAndFade_1000s_1", m = "_slideUpAndFade_1000s_1", f = "_slideRightAndFade_1000s_1", g = {
5
5
  "rp-dropdown-content": "_rp-dropdown-content_1000s_1",
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import { L as p } from "../../RPDefaultLayout-07939e60.js";
2
+ import { L as p } from "../../RPDefaultLayout-adbb0836.js";
3
3
  import "../../clsx-0c6e471a.js";
4
4
  export {
5
5
  p as default