pdf-tsx 0.8.0 → 0.10.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.
Files changed (103) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/components/PDFSidebar.cjs +1 -1
  3. package/dist/cjs/components/PDFSidebar.module.cjs +1 -1
  4. package/dist/cjs/components/PDFViewer.cjs +1 -1
  5. package/dist/cjs/components/PDFViewer.module.cjs +1 -1
  6. package/dist/cjs/components/features/PDFAnnotations.cjs +1 -1
  7. package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -1
  8. package/dist/cjs/components/features/PDFAttachments.cjs +1 -1
  9. package/dist/cjs/components/features/PDFAttachments.module.cjs +1 -1
  10. package/dist/cjs/components/features/PDFChangeFile.cjs +1 -1
  11. package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -1
  12. package/dist/cjs/components/features/PDFNavigation.cjs +1 -1
  13. package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -1
  14. package/dist/cjs/components/features/PDFOutline.cjs +1 -1
  15. package/dist/cjs/components/features/PDFOutline.module.cjs +1 -1
  16. package/dist/cjs/components/features/PDFPageFit.cjs +1 -1
  17. package/dist/cjs/components/features/PDFPrintButton.cjs +1 -1
  18. package/dist/cjs/components/features/PDFRotationControl.cjs +1 -1
  19. package/dist/cjs/components/features/PDFSearch.cjs +1 -1
  20. package/dist/cjs/components/features/PDFSearch.module.cjs +1 -1
  21. package/dist/cjs/components/features/PDFSidebarToggle.cjs +1 -1
  22. package/dist/cjs/components/features/PDFSignatures.cjs +1 -1
  23. package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -1
  24. package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -1
  25. package/dist/cjs/components/features/PDFThumbnails.cjs +1 -1
  26. package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -1
  27. package/dist/cjs/components/features/PDFZoomControls.cjs +1 -1
  28. package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -1
  29. package/dist/cjs/components/ui/PDFToolbar.cjs +1 -1
  30. package/dist/cjs/components/ui/PDFToolbarDropdownContext.cjs +1 -0
  31. package/dist/cjs/components/ui/PDFToolbarItem.cjs +1 -1
  32. package/dist/cjs/components/ui/ToolbarButton.cjs +1 -1
  33. package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -1
  34. package/dist/cjs/components/ui/icons.cjs +1 -1
  35. package/dist/cjs/context/ThemeContext.cjs +1 -1
  36. package/dist/cjs/hooks/useAnnotationLayer.cjs +1 -1
  37. package/dist/cjs/hooks/useKeyboardShortcuts.cjs +1 -1
  38. package/dist/cjs/hooks/useOutline.cjs +1 -1
  39. package/dist/cjs/hooks/useOverlayRects.cjs +1 -1
  40. package/dist/cjs/hooks/usePDFLoader.cjs +1 -1
  41. package/dist/cjs/hooks/useScrollTracking.cjs +1 -1
  42. package/dist/cjs/hooks/useTextLayer.cjs +1 -1
  43. package/dist/cjs/hooks/useTextSearch.cjs +1 -1
  44. package/dist/cjs/hooks/useThumbnails.cjs +1 -1
  45. package/dist/cjs/pdf-tsx.css +1 -1
  46. package/dist/components/features/PDFSearch.d.ts +1 -1
  47. package/dist/components/features/PDFSidebarToggle.d.ts +1 -1
  48. package/dist/components/features/PDFZoomControls.d.ts +1 -1
  49. package/dist/components/ui/PDFToolbar.d.ts +2 -2
  50. package/dist/components/ui/PDFToolbarDropdownContext.d.ts +1 -0
  51. package/dist/context/ThemeContext.d.ts +1 -1
  52. package/dist/es/components/PDFSidebar.js +25 -39
  53. package/dist/es/components/PDFSidebar.module.js +9 -9
  54. package/dist/es/components/PDFViewer.js +210 -234
  55. package/dist/es/components/PDFViewer.module.js +15 -15
  56. package/dist/es/components/features/PDFAnnotations.js +54 -62
  57. package/dist/es/components/features/PDFAnnotations.module.js +12 -12
  58. package/dist/es/components/features/PDFAttachments.js +52 -70
  59. package/dist/es/components/features/PDFAttachments.module.js +8 -8
  60. package/dist/es/components/features/PDFChangeFile.js +13 -24
  61. package/dist/es/components/features/PDFDownloadButton.js +10 -13
  62. package/dist/es/components/features/PDFNavigation.js +38 -59
  63. package/dist/es/components/features/PDFNavigation.module.js +3 -3
  64. package/dist/es/components/features/PDFOutline.js +66 -83
  65. package/dist/es/components/features/PDFOutline.module.js +5 -5
  66. package/dist/es/components/features/PDFPageFit.js +18 -23
  67. package/dist/es/components/features/PDFPrintButton.js +14 -17
  68. package/dist/es/components/features/PDFRotationControl.js +7 -13
  69. package/dist/es/components/features/PDFSearch.js +60 -69
  70. package/dist/es/components/features/PDFSearch.module.js +5 -5
  71. package/dist/es/components/features/PDFSidebarToggle.js +8 -13
  72. package/dist/es/components/features/PDFSignatures.js +116 -139
  73. package/dist/es/components/features/PDFSignatures.module.js +16 -16
  74. package/dist/es/components/features/PDFThemeToggle.js +10 -11
  75. package/dist/es/components/features/PDFThumbnails.js +25 -34
  76. package/dist/es/components/features/PDFThumbnails.module.js +9 -9
  77. package/dist/es/components/features/PDFZoomControls.js +21 -36
  78. package/dist/es/components/features/PDFZoomControls.module.js +1 -1
  79. package/dist/es/components/ui/PDFToolbar.js +33 -32
  80. package/dist/es/components/ui/PDFToolbarDropdownContext.js +5 -0
  81. package/dist/es/components/ui/PDFToolbarItem.js +11 -20
  82. package/dist/es/components/ui/ToolbarButton.js +8 -11
  83. package/dist/es/components/ui/ToolbarButton.module.js +2 -2
  84. package/dist/es/components/ui/icons.js +5 -16
  85. package/dist/es/context/ThemeContext.js +28 -38
  86. package/dist/es/hooks/useAnnotationLayer.js +33 -42
  87. package/dist/es/hooks/useKeyboardShortcuts.js +25 -34
  88. package/dist/es/hooks/useOutline.js +18 -23
  89. package/dist/es/hooks/useOverlayRects.js +42 -51
  90. package/dist/es/hooks/usePDFLoader.js +13 -16
  91. package/dist/es/hooks/useScrollTracking.js +24 -25
  92. package/dist/es/hooks/useTextLayer.js +34 -29
  93. package/dist/es/hooks/useTextSearch.js +31 -38
  94. package/dist/es/hooks/useThumbnails.js +33 -44
  95. package/dist/es/pdf-tsx.css +1 -1
  96. package/dist/hooks/useAttachments.d.ts +1 -1
  97. package/dist/hooks/useOutline.d.ts +1 -1
  98. package/dist/hooks/useOverlayRects.d.ts +1 -1
  99. package/dist/hooks/usePDFRenderer.d.ts +1 -1
  100. package/dist/hooks/useSignatures.d.ts +1 -1
  101. package/dist/hooks/useThumbnails.d.ts +1 -1
  102. package/dist/index.d.ts +3 -3
  103. package/package.json +3 -3
@@ -2,11 +2,10 @@ import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
2
  import { useOutline as t } from "../../hooks/useOutline.js";
3
3
  import { IconChevronDown as n, IconChevronRight as r } from "../ui/icons.js";
4
4
  import i from "./PDFOutline.module.js";
5
- import { c as a } from "react/compiler-runtime";
6
- import { useState as o } from "react";
7
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
5
+ import { memo as a, useCallback as o, useMemo as s, useState as c } from "react";
6
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
7
  //#region src/components/features/PDFOutline.tsx
9
- async function u(e, t) {
8
+ async function f(e, t) {
10
9
  if (!e || !t) return null;
11
10
  try {
12
11
  let n = typeof t == "string" ? await e.getDestination(t) : t;
@@ -20,94 +19,78 @@ async function u(e, t) {
20
19
  return null;
21
20
  }
22
21
  }
23
- function d(e) {
24
- let t = a(25), { node: u, depth: p, onNavigate: m } = e, [h, g] = o(p === 0), _ = u.items.length > 0, v = 12 + p * 14, y = u.bold ? 600 : 400, b = u.italic ? "italic" : "normal", x;
25
- t[0] !== v || t[1] !== y || t[2] !== b ? (x = {
26
- paddingLeft: v,
27
- fontWeight: y,
28
- fontStyle: b
29
- }, t[0] = v, t[1] = y, t[2] = b, t[3] = x) : x = t[3];
30
- let S;
31
- t[4] !== u.dest || t[5] !== m ? (S = () => m(u.dest), t[4] = u.dest, t[5] = m, t[6] = S) : S = t[6];
32
- let C;
33
- t[7] !== _ || t[8] !== h ? (C = _ ? /* @__PURE__ */ c("button", {
34
- className: i.chevronBtn,
35
- onClick: (e) => {
36
- e.stopPropagation(), g(f);
37
- },
38
- children: c(h ? n : r, { size: 12 })
39
- }) : /* @__PURE__ */ c("span", { style: {
40
- width: 16,
41
- flexShrink: 0
42
- } }), t[7] = _, t[8] = h, t[9] = C) : C = t[9];
43
- let w;
44
- t[10] === u.title ? w = t[11] : (w = /* @__PURE__ */ c("span", {
45
- className: i.title,
46
- title: u.title,
47
- children: u.title
48
- }), t[10] = u.title, t[11] = w);
49
- let T;
50
- t[12] !== x || t[13] !== S || t[14] !== C || t[15] !== w ? (T = /* @__PURE__ */ l("div", {
22
+ var p = a(function e({ node: t, depth: a, onNavigate: f }) {
23
+ let [p, m] = c(a === 0), h = t.items.length > 0, g = o((e) => {
24
+ e.stopPropagation(), m((e) => !e);
25
+ }, []), _ = o(() => f(t.dest), [f, t.dest]), v = s(() => ({
26
+ paddingLeft: 12 + a * 14,
27
+ fontWeight: t.bold ? 600 : 400,
28
+ fontStyle: t.italic ? "italic" : "normal"
29
+ }), [
30
+ a,
31
+ t.bold,
32
+ t.italic
33
+ ]);
34
+ return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ d("div", {
51
35
  className: i.row,
52
- style: x,
53
- onClick: S,
54
- children: [C, w]
55
- }), t[12] = x, t[13] = S, t[14] = C, t[15] = w, t[16] = T) : T = t[16];
56
- let E;
57
- t[17] !== p || t[18] !== u.items || t[19] !== m || t[20] !== h ? (E = h && u.items.map((e, t) => /* @__PURE__ */ c(d, {
58
- node: e,
59
- depth: p + 1,
60
- onNavigate: m
61
- }, t)), t[17] = p, t[18] = u.items, t[19] = m, t[20] = h, t[21] = E) : E = t[21];
62
- let D;
63
- return t[22] !== T || t[23] !== E ? (D = /* @__PURE__ */ l(s, { children: [T, E] }), t[22] = T, t[23] = E, t[24] = D) : D = t[24], D;
64
- }
65
- function f(e) {
66
- return !e;
67
- }
68
- function p() {
69
- let n = a(20), { pdf: r, zoom: o, rotation: s, goToPage: f } = e(), p;
70
- n[0] === r ? p = n[1] : (p = { pdf: r }, n[0] = r, n[1] = p);
71
- let { outline: m, loading: h } = t(p), g;
72
- n[2] !== f || n[3] !== r || n[4] !== s || n[5] !== o ? (g = async (e) => {
73
- let t = await u(r, e);
36
+ style: v,
37
+ onClick: _,
38
+ children: [h ? /* @__PURE__ */ u("button", {
39
+ className: i.chevronBtn,
40
+ onClick: g,
41
+ children: u(p ? n : r, { size: 12 })
42
+ }) : /* @__PURE__ */ u("span", { style: {
43
+ width: 16,
44
+ flexShrink: 0
45
+ } }), /* @__PURE__ */ u("span", {
46
+ className: i.title,
47
+ title: t.title,
48
+ children: t.title
49
+ })]
50
+ }), p && t.items.map((t, n) => /* @__PURE__ */ u(e, {
51
+ node: t,
52
+ depth: a + 1,
53
+ onNavigate: f
54
+ }, n))] });
55
+ });
56
+ function m() {
57
+ let { pdf: n, zoom: r, rotation: a, goToPage: s } = e(), { outline: c, loading: l } = t({ pdf: n }), m = o(async (e) => {
58
+ let t = await f(n, e);
74
59
  if (t) {
75
60
  if (t.pdfTop !== null) try {
76
- let [, e] = (await r.getPage(t.page)).getViewport({
77
- scale: o,
78
- rotation: s
61
+ let [, e] = (await n.getPage(t.page)).getViewport({
62
+ scale: r,
63
+ rotation: a
79
64
  }).convertToViewportPoint(0, t.pdfTop);
80
- f(t.page, e);
65
+ s(t.page, e);
81
66
  return;
82
67
  } catch {}
83
- f(t.page);
68
+ s(t.page);
84
69
  }
85
- }, n[2] = f, n[3] = r, n[4] = s, n[5] = o, n[6] = g) : g = n[6];
86
- let _ = g, v;
87
- n[7] === h ? v = n[8] : (v = h && /* @__PURE__ */ c("div", {
88
- className: i.emptyState,
89
- children: "Caricamento..."
90
- }), n[7] = h, n[8] = v);
91
- let y;
92
- n[9] !== h || n[10] !== m ? (y = !h && m.length === 0 && /* @__PURE__ */ c("div", {
93
- className: i.emptyState,
94
- children: "Nessun segnalibro disponibile."
95
- }), n[9] = h, n[10] = m, n[11] = y) : y = n[11];
96
- let b;
97
- n[12] !== _ || n[13] !== h || n[14] !== m ? (b = !h && m.map((e, t) => /* @__PURE__ */ c(d, {
98
- node: e,
99
- depth: 0,
100
- onNavigate: _
101
- }, t)), n[12] = _, n[13] = h, n[14] = m, n[15] = b) : b = n[15];
102
- let x;
103
- return n[16] !== v || n[17] !== y || n[18] !== b ? (x = /* @__PURE__ */ l("div", {
70
+ }, [
71
+ n,
72
+ r,
73
+ a,
74
+ s
75
+ ]);
76
+ return /* @__PURE__ */ d("div", {
104
77
  className: i.tree,
105
78
  children: [
106
- v,
107
- y,
108
- b
79
+ l && /* @__PURE__ */ u("div", {
80
+ className: i.emptyState,
81
+ children: "Caricamento..."
82
+ }),
83
+ !l && c.length === 0 && /* @__PURE__ */ u("div", {
84
+ className: i.emptyState,
85
+ children: "Nessun segnalibro disponibile."
86
+ }),
87
+ !l && c.map((e, t) => /* @__PURE__ */ u(p, {
88
+ node: e,
89
+ depth: 0,
90
+ onNavigate: m
91
+ }, t))
109
92
  ]
110
- }), n[16] = v, n[17] = y, n[18] = b, n[19] = x) : x = n[19], x;
93
+ });
111
94
  }
112
95
  //#endregion
113
- export { p as PDFOutline };
96
+ export { m as PDFOutline };
@@ -1,9 +1,9 @@
1
1
  var e = {
2
- emptyState: "_emptyState_1w4ic_1",
3
- tree: "_tree_1w4ic_13",
4
- row: "_row_1w4ic_25",
5
- chevronBtn: "_chevronBtn_1w4ic_61",
6
- title: "_title_1w4ic_91"
2
+ emptyState: "_emptyState_hqvdn_1",
3
+ tree: "_tree_hqvdn_7",
4
+ row: "_row_hqvdn_13",
5
+ chevronBtn: "_chevronBtn_hqvdn_31",
6
+ title: "_title_hqvdn_46"
7
7
  };
8
8
  //#endregion
9
9
  export { e as default };
@@ -1,33 +1,28 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
2
  import { computeFit as t } from "../../utils/pdfFit.js";
3
3
  import { ToolbarButton as n } from "../ui/ToolbarButton.js";
4
- import { c as r } from "react/compiler-runtime";
5
- import "react";
4
+ import { useCallback as r } from "react";
6
5
  import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
7
6
  //#region src/components/features/PDFPageFit.tsx
8
- function s(s) {
9
- let c = r(19), { fitWidthIcon: l, fitPageIcon: u } = s, { pdf: d, rotation: f, setZoom: p, setFitMode: m, containerRef: h } = e(), g;
10
- c[0] !== h || c[1] !== d || c[2] !== f || c[3] !== m || c[4] !== p ? (g = async (e) => {
11
- !d || !h.current || (m(e), p(await t(e, d, h.current, f)));
12
- }, c[0] = h, c[1] = d, c[2] = f, c[3] = m, c[4] = p, c[5] = g) : g = c[5];
13
- let _ = g, v;
14
- c[6] === _ ? v = c[7] : (v = () => _("width"), c[6] = _, c[7] = v);
15
- let y;
16
- c[8] !== l || c[9] !== v ? (y = /* @__PURE__ */ a(n, {
17
- onClick: v,
7
+ function s({ fitWidthIcon: s, fitPageIcon: c }) {
8
+ let { pdf: l, rotation: u, setZoom: d, setFitMode: f, containerRef: p } = e(), m = r(async (e) => {
9
+ !l || !p.current || (f(e), d(await t(e, l, p.current, u)));
10
+ }, [
11
+ l,
12
+ u,
13
+ d,
14
+ f,
15
+ p
16
+ ]), h = r(() => m("width"), [m]), g = r(() => m("page"), [m]);
17
+ return /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a(n, {
18
+ onClick: h,
18
19
  title: "Adatta alla larghezza",
19
- children: l
20
- }), c[8] = l, c[9] = v, c[10] = y) : y = c[10];
21
- let b;
22
- c[11] === _ ? b = c[12] : (b = () => _("page"), c[11] = _, c[12] = b);
23
- let x;
24
- c[13] !== u || c[14] !== b ? (x = /* @__PURE__ */ a(n, {
25
- onClick: b,
20
+ children: s
21
+ }), /* @__PURE__ */ a(n, {
22
+ onClick: g,
26
23
  title: "Adatta pagina intera",
27
- children: u
28
- }), c[13] = u, c[14] = b, c[15] = x) : x = c[15];
29
- let S;
30
- return c[16] !== y || c[17] !== x ? (S = /* @__PURE__ */ o(i, { children: [y, x] }), c[16] = y, c[17] = x, c[18] = S) : S = c[18], S;
24
+ children: c
25
+ })] });
31
26
  }
32
27
  s.toolbarLabel = "Adatta";
33
28
  //#endregion
@@ -1,26 +1,23 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
2
  import { ToolbarButton as t } from "../ui/ToolbarButton.js";
3
- import { c as n } from "react/compiler-runtime";
4
- import "react";
3
+ import { useCallback as n } from "react";
5
4
  import { jsx as r } from "react/jsx-runtime";
6
5
  //#region src/components/features/PDFPrintButton.tsx
7
- function i(i) {
8
- let a = n(5), { icon: o } = i, { file: s } = e(), c;
9
- a[0] === s ? c = a[1] : (c = () => {
10
- let e = URL.createObjectURL(s), t = document.createElement("iframe");
11
- t.style.display = "none", t.src = e, document.body.appendChild(t), t.onload = () => {
12
- let n = !1, r = () => {
13
- n || (n = !0, t.remove(), URL.revokeObjectURL(e));
6
+ function i({ icon: i }) {
7
+ let { file: a } = e();
8
+ return /* @__PURE__ */ r(t, {
9
+ onClick: n(() => {
10
+ let e = URL.createObjectURL(a), t = document.createElement("iframe");
11
+ t.style.display = "none", t.src = e, document.body.appendChild(t), t.onload = () => {
12
+ let n = !1, r = () => {
13
+ n || (n = !0, t.remove(), URL.revokeObjectURL(e));
14
+ };
15
+ t.contentWindow?.addEventListener("afterprint", r, { once: !0 }), setTimeout(r, 6e4), t.contentWindow?.print();
14
16
  };
15
- t.contentWindow?.addEventListener("afterprint", r, { once: !0 }), setTimeout(r, 6e4), t.contentWindow?.print();
16
- };
17
- }, a[0] = s, a[1] = c);
18
- let l = c, u;
19
- return a[2] !== l || a[3] !== o ? (u = /* @__PURE__ */ r(t, {
20
- onClick: l,
17
+ }, [a]),
21
18
  title: "Stampa PDF",
22
- children: o
23
- }), a[2] = l, a[3] = o, a[4] = u) : u = a[4], u;
19
+ children: i
20
+ });
24
21
  }
25
22
  i.toolbarLabel = "Stampa";
26
23
  //#endregion
@@ -1,21 +1,15 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
2
  import { ToolbarButton as t } from "../ui/ToolbarButton.js";
3
- import { c as n } from "react/compiler-runtime";
4
- import "react";
3
+ import { useCallback as n } from "react";
5
4
  import { jsx as r } from "react/jsx-runtime";
6
5
  //#region src/components/features/PDFRotationControl.tsx
7
- function i(i) {
8
- let o = n(5), { icon: s } = i, { setRotation: c } = e(), l;
9
- o[0] === c ? l = o[1] : (l = () => c(a), o[0] = c, o[1] = l);
10
- let u;
11
- return o[2] !== s || o[3] !== l ? (u = /* @__PURE__ */ r(t, {
12
- onClick: l,
6
+ function i({ icon: i }) {
7
+ let { setRotation: a } = e();
8
+ return /* @__PURE__ */ r(t, {
9
+ onClick: n(() => a((e) => (e + 90) % 360), [a]),
13
10
  title: "Ruota documento",
14
- children: s
15
- }), o[2] = s, o[3] = l, o[4] = u) : u = o[4], u;
16
- }
17
- function a(e) {
18
- return (e + 90) % 360;
11
+ children: i
12
+ });
19
13
  }
20
14
  i.toolbarLabel = "Ruota";
21
15
  //#endregion
@@ -1,82 +1,73 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
2
  import { useTextSearch as t } from "../../hooks/useTextSearch.js";
3
3
  import n from "./PDFSearch.module.js";
4
- import { c as r } from "react/compiler-runtime";
5
- import { useEffect as i, useState as a } from "react";
4
+ import { useCallback as r, useEffect as i, useState as a } from "react";
6
5
  import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
7
6
  //#region src/components/features/PDFSearch.tsx
8
- function l(l) {
9
- let u = r(35), { searchIcon: d, prevIcon: f, nextIcon: p, clearIcon: m } = l, { pdf: h, goToPage: g, setHighlight: _, setSearchMatches: v } = e(), [y, b] = a(""), [x, S] = a(0), C;
10
- u[0] !== h || u[1] !== y ? (C = {
11
- pdf: h,
12
- query: y
13
- }, u[0] = h, u[1] = y, u[2] = C) : C = u[2];
14
- let { matches: w, searching: T } = t(C), E = w.length, D, O;
15
- u[3] !== w || u[4] !== v ? (D = () => (v(w), () => v([])), O = [w, v], u[3] = w, u[4] = v, u[5] = D, u[6] = O) : (D = u[5], O = u[6]), i(D, O);
16
- let k;
17
- u[7] !== g || u[8] !== w || u[9] !== _ || u[10] !== E ? (k = (e) => {
18
- let t = (e + E) % E;
19
- S(t);
20
- let n = w[t];
21
- g(n.page), _({
7
+ var l = [];
8
+ function u({ searchIcon: u, prevIcon: d, nextIcon: f, clearIcon: p }) {
9
+ let { pdf: m, goToPage: h, setHighlight: g, setSearchMatches: _ } = e(), [v, y] = a(""), [b, x] = a(0), { matches: S, searching: C } = t({
10
+ pdf: m,
11
+ query: v
12
+ }), w = S.length;
13
+ i(() => (_(S), () => _(l)), [S, _]);
14
+ let T = r((e) => {
15
+ let t = (e + w) % w;
16
+ x(t);
17
+ let n = S[t];
18
+ h(n.page), g({
22
19
  page: n.page,
23
20
  pdfRect: n.pdfRect
24
21
  });
25
- }, u[7] = g, u[8] = w, u[9] = _, u[10] = E, u[11] = k) : k = u[11];
26
- let A = k, j;
27
- u[12] === _ ? j = u[13] : (j = (e) => {
28
- b(e.target.value), S(0), _(null);
29
- }, u[12] = _, u[13] = j);
30
- let M = j, N;
31
- u[14] === _ ? N = u[15] : (N = () => {
32
- b(""), S(0), _(null);
33
- }, u[14] = _, u[15] = N);
34
- let P = N, F;
35
- u[16] === d ? F = u[17] : (F = /* @__PURE__ */ s("span", {
36
- className: n.searchIconWrapper,
37
- children: d
38
- }), u[16] = d, u[17] = F);
39
- let I;
40
- u[18] !== M || u[19] !== y ? (I = /* @__PURE__ */ s("input", {
41
- className: n.searchInput,
42
- value: y,
43
- onChange: M,
44
- placeholder: "Cerca nel documento..."
45
- }), u[18] = M, u[19] = y, u[20] = I) : I = u[20];
46
- let L;
47
- u[21] !== m || u[22] !== P || u[23] !== x || u[24] !== A || u[25] !== p || u[26] !== f || u[27] !== y || u[28] !== T || u[29] !== E ? (L = y && /* @__PURE__ */ c(o, { children: [
48
- /* @__PURE__ */ s("span", {
49
- className: n.counter,
50
- children: T ? "…" : E === 0 ? "0" : `${x + 1}/${E}`
51
- }),
52
- /* @__PURE__ */ s("button", {
53
- className: n.navButton,
54
- onClick: () => A(x - 1),
55
- disabled: E === 0,
56
- children: f
57
- }),
58
- /* @__PURE__ */ s("button", {
59
- className: n.navButton,
60
- onClick: () => A(x + 1),
61
- disabled: E === 0,
62
- children: p
63
- }),
64
- /* @__PURE__ */ s("button", {
65
- className: n.navButton,
66
- onClick: P,
67
- children: m
68
- })
69
- ] }), u[21] = m, u[22] = P, u[23] = x, u[24] = A, u[25] = p, u[26] = f, u[27] = y, u[28] = T, u[29] = E, u[30] = L) : L = u[30];
70
- let R;
71
- return u[31] !== F || u[32] !== I || u[33] !== L ? (R = /* @__PURE__ */ c("div", {
22
+ }, [
23
+ w,
24
+ S,
25
+ h,
26
+ g
27
+ ]), E = r((e) => {
28
+ y(e.target.value), x(0), g(null);
29
+ }, [g]), D = r(() => {
30
+ y(""), x(0), g(null);
31
+ }, [g]);
32
+ return /* @__PURE__ */ c("div", {
72
33
  className: n.wrapper,
73
34
  children: [
74
- F,
75
- I,
76
- L
35
+ /* @__PURE__ */ s("span", {
36
+ className: n.searchIconWrapper,
37
+ children: u
38
+ }),
39
+ /* @__PURE__ */ s("input", {
40
+ className: n.searchInput,
41
+ value: v,
42
+ onChange: E,
43
+ placeholder: "Cerca nel documento..."
44
+ }),
45
+ v && /* @__PURE__ */ c(o, { children: [
46
+ /* @__PURE__ */ s("span", {
47
+ className: n.counter,
48
+ children: C ? "…" : w === 0 ? "0" : `${b + 1}/${w}`
49
+ }),
50
+ /* @__PURE__ */ s("button", {
51
+ className: n.navButton,
52
+ onClick: () => T(b - 1),
53
+ disabled: w === 0,
54
+ children: d
55
+ }),
56
+ /* @__PURE__ */ s("button", {
57
+ className: n.navButton,
58
+ onClick: () => T(b + 1),
59
+ disabled: w === 0,
60
+ children: f
61
+ }),
62
+ /* @__PURE__ */ s("button", {
63
+ className: n.navButton,
64
+ onClick: D,
65
+ children: p
66
+ })
67
+ ] })
77
68
  ]
78
- }), u[31] = F, u[32] = I, u[33] = L, u[34] = R) : R = u[34], R;
69
+ });
79
70
  }
80
- l.toolbarLabel = "Cerca";
71
+ u.toolbarLabel = "Cerca";
81
72
  //#endregion
82
- export { l as PDFSearch };
73
+ export { u as PDFSearch };
@@ -1,9 +1,9 @@
1
1
  var e = {
2
- wrapper: "_wrapper_4qrs1_1",
3
- searchIconWrapper: "_searchIconWrapper_4qrs1_13",
4
- searchInput: "_searchInput_4qrs1_25",
5
- navButton: "_navButton_4qrs1_65",
6
- counter: "_counter_4qrs1_107"
2
+ wrapper: "_wrapper_18kvs_1",
3
+ searchIconWrapper: "_searchIconWrapper_18kvs_7",
4
+ searchInput: "_searchInput_18kvs_13",
5
+ navButton: "_navButton_18kvs_33",
6
+ counter: "_counter_18kvs_54"
7
7
  };
8
8
  //#endregion
9
9
  export { e as default };
@@ -1,21 +1,16 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
2
  import t from "../ui/ToolbarButton.module.js";
3
- import { c as n } from "react/compiler-runtime";
3
+ import { useCallback as n } from "react";
4
4
  import { jsx as r } from "react/jsx-runtime";
5
5
  //#region src/components/features/PDFSidebarToggle.tsx
6
- function i(i) {
7
- let o = n(6), { collapseIcon: s, expandIcon: c } = i, { sidebarCollapsed: l, setSidebarCollapsed: u } = e(), d = l ? c ?? s : s, f = l ? "Espandi sidebar" : "Comprimi sidebar", p;
8
- o[0] === u ? p = o[1] : (p = () => u(a), o[0] = u, o[1] = p);
9
- let m;
10
- return o[2] !== d || o[3] !== p || o[4] !== f ? (m = /* @__PURE__ */ r("button", {
6
+ function i({ collapseIcon: i, expandIcon: a }) {
7
+ let { sidebarCollapsed: o, setSidebarCollapsed: s } = e(), c = o ? a ?? i : i, l = o ? "Espandi sidebar" : "Comprimi sidebar", u = n(() => s((e) => !e), [s]);
8
+ return /* @__PURE__ */ r("button", {
11
9
  className: t.btn,
12
- onClick: p,
13
- title: f,
14
- children: d
15
- }), o[2] = d, o[3] = p, o[4] = f, o[5] = m) : m = o[5], m;
16
- }
17
- function a(e) {
18
- return !e;
10
+ onClick: u,
11
+ title: l,
12
+ children: c
13
+ });
19
14
  }
20
15
  i.toolbarLabel = "Sidebar";
21
16
  //#endregion