pdf-tsx 0.1.6 → 0.3.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 (53) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +296 -212
  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/PDFNavigation.module.cjs +1 -1
  9. package/dist/cjs/components/features/PDFOutline.module.cjs +1 -1
  10. package/dist/cjs/components/features/PDFPageFit.cjs +1 -1
  11. package/dist/cjs/components/features/PDFPrintButton.cjs +1 -1
  12. package/dist/cjs/components/features/PDFSearch.module.cjs +1 -1
  13. package/dist/cjs/components/features/PDFSignatures.cjs +1 -1
  14. package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -1
  15. package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -1
  16. package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -1
  17. package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -1
  18. package/dist/cjs/context/ThemeContext.cjs +1 -1
  19. package/dist/cjs/hooks/useTextLayer.cjs +1 -1
  20. package/dist/cjs/index.cjs +1 -1
  21. package/dist/cjs/pdf-tsx.css +1 -1
  22. package/dist/cjs/utils/pdfFit.cjs +1 -0
  23. package/dist/components/PDFViewer.d.ts +7 -0
  24. package/dist/components/features/PDFAnnotations.d.ts +4 -0
  25. package/dist/components/features/PDFSignatures.d.ts +4 -0
  26. package/dist/context/ThemeContext.d.ts +8 -2
  27. package/dist/es/components/PDFSidebar.module.js +7 -7
  28. package/dist/es/components/PDFViewer.js +188 -175
  29. package/dist/es/components/PDFViewer.module.js +15 -12
  30. package/dist/es/components/features/PDFAnnotations.js +16 -2
  31. package/dist/es/components/features/PDFAnnotations.module.js +12 -10
  32. package/dist/es/components/features/PDFNavigation.module.js +3 -3
  33. package/dist/es/components/features/PDFOutline.module.js +5 -5
  34. package/dist/es/components/features/PDFPageFit.js +24 -34
  35. package/dist/es/components/features/PDFPrintButton.js +2 -2
  36. package/dist/es/components/features/PDFSearch.module.js +4 -4
  37. package/dist/es/components/features/PDFSignatures.js +20 -12
  38. package/dist/es/components/features/PDFSignatures.module.js +16 -14
  39. package/dist/es/components/features/PDFThumbnails.module.js +7 -7
  40. package/dist/es/components/features/PDFZoomControls.module.js +1 -1
  41. package/dist/es/components/ui/ToolbarButton.module.js +2 -2
  42. package/dist/es/context/ThemeContext.js +31 -24
  43. package/dist/es/hooks/useTextLayer.js +0 -1
  44. package/dist/es/index.js +17 -16
  45. package/dist/es/pdf-tsx.css +1 -1
  46. package/dist/es/utils/pdfFit.js +13 -0
  47. package/dist/index.d.ts +4 -2
  48. package/dist/utils/pdfFit.d.ts +2 -0
  49. package/package.json +61 -61
  50. package/dist/pdf-tsx.cjs.js +0 -5
  51. package/dist/pdf-tsx.css +0 -2
  52. package/dist/pdf-tsx.es.js +0 -2637
  53. package/dist/vite.svg +0 -1
@@ -1,43 +1,33 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
- import { ToolbarButton as t } from "../ui/ToolbarButton.js";
2
+ import { computeFit as t } from "../../utils/pdfFit.js";
3
+ import { ToolbarButton as n } from "../ui/ToolbarButton.js";
3
4
  import "react";
4
- import { c as n } from "react/compiler-runtime";
5
- import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
5
+ import { c as r } from "react/compiler-runtime";
6
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
6
7
  //#region src/components/features/PDFPageFit.tsx
7
- var o = 60, s = 10;
8
- function c(c) {
9
- let l = n(19), { fitWidthIcon: u, fitPageIcon: d } = c, { pdf: f, rotation: p, setZoom: m, containerRef: h } = e(), g;
10
- l[0] !== h || l[1] !== f || l[2] !== p || l[3] !== m ? (g = async () => {
11
- if (!f || !h.current) return;
12
- let e = (await f.getPage(1)).getViewport({
13
- scale: 1,
14
- rotation: p
15
- });
16
- m((h.current.clientWidth - o) / e.width);
17
- }, l[0] = h, l[1] = f, l[2] = p, l[3] = m, l[4] = g) : g = l[4];
18
- let _ = g, v;
19
- l[5] !== h || l[6] !== f || l[7] !== p || l[8] !== m ? (v = async () => {
20
- if (!f || !h.current) return;
21
- let e = (await f.getPage(1)).getViewport({
22
- scale: 1,
23
- rotation: p
24
- }), t = h.current.clientWidth - o, n = h.current.clientHeight - s * 2;
25
- m(Math.min(t / e.width, n / e.height));
26
- }, l[5] = h, l[6] = f, l[7] = p, l[8] = m, l[9] = v) : v = l[9];
27
- let y = v, b;
28
- l[10] !== u || l[11] !== _ ? (b = /* @__PURE__ */ i(t, {
8
+ function s(s) {
9
+ let c = r(18), { fitWidthIcon: l, fitPageIcon: u } = s, { pdf: d, rotation: f, setZoom: p, containerRef: m } = e(), h;
10
+ c[0] !== m || c[1] !== d || c[2] !== f || c[3] !== p ? (h = async (e) => {
11
+ !d || !m.current || p(await t(e, d, m.current, f));
12
+ }, c[0] = m, c[1] = d, c[2] = f, c[3] = p, c[4] = h) : h = c[4];
13
+ let g = h, _;
14
+ c[5] === g ? _ = c[6] : (_ = () => g("width"), c[5] = g, c[6] = _);
15
+ let v;
16
+ c[7] !== l || c[8] !== _ ? (v = /* @__PURE__ */ a(n, {
29
17
  onClick: _,
30
18
  title: "Adatta alla larghezza",
31
- children: u
32
- }), l[10] = u, l[11] = _, l[12] = b) : b = l[12];
33
- let x;
34
- l[13] !== d || l[14] !== y ? (x = /* @__PURE__ */ i(t, {
19
+ children: l
20
+ }), c[7] = l, c[8] = _, c[9] = v) : v = c[9];
21
+ let y;
22
+ c[10] === g ? y = c[11] : (y = () => g("page"), c[10] = g, c[11] = y);
23
+ let b;
24
+ c[12] !== u || c[13] !== y ? (b = /* @__PURE__ */ a(n, {
35
25
  onClick: y,
36
26
  title: "Adatta pagina intera",
37
- children: d
38
- }), l[13] = d, l[14] = y, l[15] = x) : x = l[15];
39
- let S;
40
- return l[16] !== b || l[17] !== x ? (S = /* @__PURE__ */ a(r, { children: [b, x] }), l[16] = b, l[17] = x, l[18] = S) : S = l[18], S;
27
+ children: u
28
+ }), c[12] = u, c[13] = y, c[14] = b) : b = c[14];
29
+ let x;
30
+ return c[15] !== v || c[16] !== b ? (x = /* @__PURE__ */ o(i, { children: [v, b] }), c[15] = v, c[16] = b, c[17] = x) : x = c[17], x;
41
31
  }
42
32
  //#endregion
43
- export { c as PDFPageFit };
33
+ export { s as PDFPageFit };
@@ -9,9 +9,9 @@ function i(i) {
9
9
  a[0] === s ? c = a[1] : (c = () => {
10
10
  let e = URL.createObjectURL(s), t = document.createElement("iframe");
11
11
  t.style.display = "none", t.src = e, document.body.appendChild(t), t.onload = () => {
12
- t.contentWindow?.print(), setTimeout(() => {
12
+ t.contentWindow?.addEventListener("afterprint", () => {
13
13
  document.body.removeChild(t), URL.revokeObjectURL(e);
14
- }, 1e3);
14
+ }, { once: !0 }), t.contentWindow?.print();
15
15
  };
16
16
  }, a[0] = s, a[1] = c);
17
17
  let l = c, u;
@@ -1,8 +1,8 @@
1
1
  var e = {
2
- wrapper: "_wrapper_1x913_1",
3
- searchInput: "_searchInput_1x913_7",
4
- navButton: "_navButton_1x913_27",
5
- counter: "_counter_1x913_48"
2
+ wrapper: "_wrapper_yinyt_1",
3
+ searchInput: "_searchInput_yinyt_13",
4
+ navButton: "_navButton_yinyt_53",
5
+ counter: "_counter_yinyt_95"
6
6
  };
7
7
  //#endregion
8
8
  export { e as default };
@@ -87,8 +87,22 @@ function s(e) {
87
87
  children: [g, C]
88
88
  }), t[26] = c, t[27] = l, t[28] = C, t[29] = g, t[30] = w) : w = t[30], w;
89
89
  }
90
- function c() {
91
- let o = r(22), { pdf: c, goToPage: l, setHighlight: u } = e(), d;
90
+ function c(o) {
91
+ let s = r(8), { icon: c } = o, { pdf: l } = e(), u;
92
+ s[0] === l ? u = s[1] : (u = { pdf: l }, s[0] = l, s[1] = u);
93
+ let { signatures: d, loading: f } = t(u), p = d.length, m;
94
+ s[2] !== p || s[3] !== f ? (m = !f && p > 0 && /* @__PURE__ */ i("span", {
95
+ className: n.badge,
96
+ children: p > 99 ? "99+" : p
97
+ }), s[2] = p, s[3] = f, s[4] = m) : m = s[4];
98
+ let h;
99
+ return s[5] !== c || s[6] !== m ? (h = /* @__PURE__ */ a("span", {
100
+ className: n.iconWrapper,
101
+ children: [c, m]
102
+ }), s[5] = c, s[6] = m, s[7] = h) : h = s[7], h;
103
+ }
104
+ function l() {
105
+ let o = r(18), { pdf: c, goToPage: l, setHighlight: u } = e(), d;
92
106
  o[0] === c ? d = o[1] : (d = { pdf: c }, o[0] = c, o[1] = d);
93
107
  let { signatures: f, loading: p } = t(d), m;
94
108
  o[2] !== l || o[3] !== u ? (m = (e) => {
@@ -113,20 +127,14 @@ function c() {
113
127
  onClick: () => h(e)
114
128
  }, t)), o[10] = h, o[11] = p, o[12] = f, o[13] = v) : v = o[13];
115
129
  let y;
116
- o[14] !== p || o[15] !== f ? (y = !p && f.length > 0 && /* @__PURE__ */ i("div", {
117
- className: n.disclaimer,
118
- children: "La presenza del campo firma non garantisce la validità crittografica."
119
- }), o[14] = p, o[15] = f, o[16] = y) : y = o[16];
120
- let b;
121
- return o[17] !== g || o[18] !== _ || o[19] !== v || o[20] !== y ? (b = /* @__PURE__ */ a("div", {
130
+ return o[14] !== g || o[15] !== _ || o[16] !== v ? (y = /* @__PURE__ */ a("div", {
122
131
  className: n.list,
123
132
  children: [
124
133
  g,
125
134
  _,
126
- v,
127
- y
135
+ v
128
136
  ]
129
- }), o[17] = g, o[18] = _, o[19] = v, o[20] = y, o[21] = b) : b = o[21], b;
137
+ }), o[14] = g, o[15] = _, o[16] = v, o[17] = y) : y = o[17], y;
130
138
  }
131
139
  //#endregion
132
- export { c as PDFSignatures };
140
+ export { l as PDFSignatures, c as PDFSignaturesIcon };
@@ -1,18 +1,20 @@
1
1
  var e = {
2
- list: "_list_m6w4t_1",
3
- emptyState: "_emptyState_m6w4t_6",
4
- card: "_card_m6w4t_12",
5
- cardClickable: "_cardClickable_m6w4t_23",
6
- cardSigned: "_cardSigned_m6w4t_31",
7
- cardHeader: "_cardHeader_m6w4t_36",
8
- statusDot: "_statusDot_m6w4t_43",
9
- statusDotSigned: "_statusDotSigned_m6w4t_57",
10
- statusLabel: "_statusLabel_m6w4t_61",
11
- statusLabelSigned: "_statusLabelSigned_m6w4t_69",
12
- fieldList: "_fieldList_m6w4t_73",
13
- fieldRow: "_fieldRow_m6w4t_79",
14
- fieldLabel: "_fieldLabel_m6w4t_84",
15
- disclaimer: "_disclaimer_m6w4t_88"
2
+ list: "_list_11831_1",
3
+ emptyState: "_emptyState_11831_11",
4
+ card: "_card_11831_23",
5
+ cardClickable: "_cardClickable_11831_45",
6
+ cardSigned: "_cardSigned_11831_61",
7
+ cardHeader: "_cardHeader_11831_71",
8
+ statusDot: "_statusDot_11831_85",
9
+ statusDotSigned: "_statusDotSigned_11831_113",
10
+ statusLabel: "_statusLabel_11831_121",
11
+ statusLabelSigned: "_statusLabelSigned_11831_137",
12
+ fieldList: "_fieldList_11831_145",
13
+ fieldRow: "_fieldRow_11831_157",
14
+ fieldLabel: "_fieldLabel_11831_167",
15
+ disclaimer: "_disclaimer_11831_175",
16
+ iconWrapper: "_iconWrapper_11831_197",
17
+ badge: "_badge_11831_211"
16
18
  };
17
19
  //#endregion
18
20
  export { e as default };
@@ -1,11 +1,11 @@
1
1
  var e = {
2
- thumbnailList: "_thumbnailList_f8jl0_1",
3
- thumbnailItem: "_thumbnailItem_f8jl0_6",
4
- thumbnailItemActive: "_thumbnailItemActive_f8jl0_19",
5
- thumbnailImg: "_thumbnailImg_f8jl0_28",
6
- thumbnailImgActive: "_thumbnailImgActive_f8jl0_34",
7
- thumbnailLabel: "_thumbnailLabel_f8jl0_38",
8
- thumbnailLabelActive: "_thumbnailLabelActive_f8jl0_45"
2
+ thumbnailList: "_thumbnailList_116om_1",
3
+ thumbnailItem: "_thumbnailItem_116om_11",
4
+ thumbnailItemActive: "_thumbnailItemActive_116om_37",
5
+ thumbnailImg: "_thumbnailImg_116om_55",
6
+ thumbnailImgActive: "_thumbnailImgActive_116om_67",
7
+ thumbnailLabel: "_thumbnailLabel_116om_75",
8
+ thumbnailLabelActive: "_thumbnailLabelActive_116om_89"
9
9
  };
10
10
  //#endregion
11
11
  export { e as default };
@@ -1,3 +1,3 @@
1
- var e = { zoomLabel: "_zoomLabel_m8iv9_1" };
1
+ var e = { zoomLabel: "_zoomLabel_1r6if_1" };
2
2
  //#endregion
3
3
  export { e as default };
@@ -1,6 +1,6 @@
1
1
  var e = {
2
- btn: "_btn_1x6vc_1",
3
- primary: "_primary_1x6vc_29"
2
+ btn: "_btn_12ml0_1",
3
+ primary: "_primary_12ml0_57"
4
4
  };
5
5
  //#endregion
6
6
  export { e as default };
@@ -5,31 +5,38 @@ import { jsx as s } from "react/jsx-runtime";
5
5
  //#region src/context/ThemeContext.tsx
6
6
  var c = r(null);
7
7
  function l(r) {
8
- let i = o(14), { children: l } = r, [d, f] = a(!0), p = d ? e : t, m;
9
- i[0] === p ? m = i[1] : (m = n(p), i[0] = p, i[1] = m);
10
- let h = m, g;
11
- i[2] === Symbol.for("react.memo_cache_sentinel") ? (g = () => f(u), i[2] = g) : g = i[2];
12
- let _;
13
- i[3] !== d || i[4] !== p ? (_ = {
14
- isDark: d,
15
- toggleTheme: g,
16
- theme: p
17
- }, i[3] = d, i[4] = p, i[5] = _) : _ = i[5];
18
- let v = h, y;
19
- i[6] === v ? y = i[7] : (y = {
20
- ...v,
21
- display: "contents"
22
- }, i[6] = v, i[7] = y);
23
- let b;
24
- i[8] !== l || i[9] !== y ? (b = /* @__PURE__ */ s("div", {
25
- style: y,
8
+ let i = o(17), { children: l, themeOverrides: d, defaultTheme: f } = r, [p, m] = a((f === void 0 ? "light" : f) === "dark"), h, g;
9
+ i[0] !== p || i[1] !== d?.dark || i[2] !== d?.light ? (g = p ? {
10
+ ...e,
11
+ ...d?.dark
12
+ } : {
13
+ ...t,
14
+ ...d?.light
15
+ }, h = n(g), i[0] = p, i[1] = d?.dark, i[2] = d?.light, i[3] = h, i[4] = g) : (h = i[3], g = i[4]);
16
+ let _ = h, v;
17
+ i[5] === Symbol.for("react.memo_cache_sentinel") ? (v = () => m(u), i[5] = v) : v = i[5];
18
+ let y;
19
+ i[6] !== p || i[7] !== g ? (y = {
20
+ isDark: p,
21
+ toggleTheme: v,
22
+ theme: g
23
+ }, i[6] = p, i[7] = g, i[8] = y) : y = i[8];
24
+ let b = _, x;
25
+ i[9] === b ? x = i[10] : (x = {
26
+ ...b,
27
+ height: "100%",
28
+ width: "100%"
29
+ }, i[9] = b, i[10] = x);
30
+ let S;
31
+ i[11] !== l || i[12] !== x ? (S = /* @__PURE__ */ s("div", {
32
+ style: x,
26
33
  children: l
27
- }), i[8] = l, i[9] = y, i[10] = b) : b = i[10];
28
- let x;
29
- return i[11] !== _ || i[12] !== b ? (x = /* @__PURE__ */ s(c.Provider, {
30
- value: _,
31
- children: b
32
- }), i[11] = _, i[12] = b, i[13] = x) : x = i[13], x;
34
+ }), i[11] = l, i[12] = x, i[13] = S) : S = i[13];
35
+ let C;
36
+ return i[14] !== y || i[15] !== S ? (C = /* @__PURE__ */ s(c.Provider, {
37
+ value: y,
38
+ children: S
39
+ }), i[14] = y, i[15] = S, i[16] = C) : C = i[16], C;
33
40
  }
34
41
  function u(e) {
35
42
  return !e;
@@ -1,4 +1,3 @@
1
- /* empty css */
2
1
  import { useEffect as e, useRef as t } from "react";
3
2
  import * as n from "pdfjs-dist";
4
3
  import { c as r } from "react/compiler-runtime";
package/dist/es/index.js CHANGED
@@ -1,16 +1,17 @@
1
- import e from "./components/PDFViewer.js";
2
- import { PDFSidebar as t } from "./components/PDFSidebar.js";
3
- import { PDFAnnotations as n } from "./components/features/PDFAnnotations.js";
4
- import { PDFChangeFile as r } from "./components/features/PDFChangeFile.js";
5
- import { PDFDownloadButton as i } from "./components/features/PDFDownloadButton.js";
6
- import { PDFNavigation as a } from "./components/features/PDFNavigation.js";
7
- import { PDFOutline as o } from "./components/features/PDFOutline.js";
8
- import { PDFPageFit as s } from "./components/features/PDFPageFit.js";
9
- import { PDFRotationControl as c } from "./components/features/PDFRotationControl.js";
10
- import { PDFSearch as l } from "./components/features/PDFSearch.js";
11
- import { PDFSignatures as u } from "./components/features/PDFSignatures.js";
12
- import { PDFThumbnails as d } from "./components/features/PDFThumbnails.js";
13
- import { PDFZoomControls as f } from "./components/features/PDFZoomControls.js";
14
- import { PDFThemeToggle as p } from "./components/features/PDFThemeToggle.js";
15
- import { PDFPrintButton as m } from "./components/features/PDFPrintButton.js";
16
- export { n as PDFAnnotations, r as PDFChangeFile, i as PDFDownloadButton, a as PDFNavigation, o as PDFOutline, s as PDFPageFit, m as PDFPrintButton, c as PDFRotationControl, l as PDFSearch, t as PDFSidebar, u as PDFSignatures, p as PDFThemeToggle, d as PDFThumbnails, e as PDFViewer, f as PDFZoomControls };
1
+ import { darkTheme as e, lightTheme as t } from "./theme.js";
2
+ import n from "./components/PDFViewer.js";
3
+ import { PDFSidebar as r } from "./components/PDFSidebar.js";
4
+ import { PDFAnnotations as i, PDFAnnotationsIcon as a } from "./components/features/PDFAnnotations.js";
5
+ import { PDFChangeFile as o } from "./components/features/PDFChangeFile.js";
6
+ import { PDFDownloadButton as s } from "./components/features/PDFDownloadButton.js";
7
+ import { PDFNavigation as c } from "./components/features/PDFNavigation.js";
8
+ import { PDFOutline as l } from "./components/features/PDFOutline.js";
9
+ import { PDFPageFit as u } from "./components/features/PDFPageFit.js";
10
+ import { PDFRotationControl as d } from "./components/features/PDFRotationControl.js";
11
+ import { PDFSearch as f } from "./components/features/PDFSearch.js";
12
+ import { PDFSignatures as p, PDFSignaturesIcon as m } from "./components/features/PDFSignatures.js";
13
+ import { PDFThumbnails as h } from "./components/features/PDFThumbnails.js";
14
+ import { PDFZoomControls as g } from "./components/features/PDFZoomControls.js";
15
+ import { PDFThemeToggle as _ } from "./components/features/PDFThemeToggle.js";
16
+ import { PDFPrintButton as v } from "./components/features/PDFPrintButton.js";
17
+ export { i as PDFAnnotations, a as PDFAnnotationsIcon, o as PDFChangeFile, s as PDFDownloadButton, c as PDFNavigation, l as PDFOutline, u as PDFPageFit, v as PDFPrintButton, d as PDFRotationControl, f as PDFSearch, r as PDFSidebar, p as PDFSignatures, m as PDFSignaturesIcon, _ as PDFThemeToggle, h as PDFThumbnails, n as PDFViewer, g as PDFZoomControls, e as darkTheme, t as lightTheme };