pdf-tsx 0.5.0 → 0.7.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/LICENSE +21 -21
- package/README.md +411 -350
- package/dist/cjs/components/PDFSidebar.module.cjs +1 -1
- package/dist/cjs/components/PDFViewer.cjs +1 -1
- package/dist/cjs/components/PDFViewer.module.cjs +1 -1
- package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -1
- package/dist/cjs/components/features/PDFAttachments.cjs +1 -0
- package/dist/cjs/components/features/PDFAttachments.module.cjs +1 -0
- package/dist/cjs/components/features/PDFChangeFile.cjs +1 -1
- package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -1
- package/dist/cjs/components/features/PDFNavigation.cjs +1 -1
- package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -1
- package/dist/cjs/components/features/PDFOutline.cjs +1 -1
- package/dist/cjs/components/features/PDFOutline.module.cjs +1 -1
- package/dist/cjs/components/features/PDFPageFit.cjs +1 -1
- package/dist/cjs/components/features/PDFPrintButton.cjs +1 -1
- package/dist/cjs/components/features/PDFRotationControl.cjs +1 -1
- package/dist/cjs/components/features/PDFSearch.cjs +1 -1
- package/dist/cjs/components/features/PDFSearch.module.cjs +1 -1
- package/dist/cjs/components/features/PDFSidebarToggle.cjs +1 -1
- package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -1
- package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -1
- package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -1
- package/dist/cjs/components/features/PDFZoomControls.cjs +1 -1
- package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -1
- package/dist/cjs/components/ui/PDFToolbar.cjs +1 -0
- package/dist/cjs/components/ui/PDFToolbar.module.cjs +1 -0
- package/dist/cjs/components/ui/PDFToolbarItem.cjs +1 -0
- package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -1
- package/dist/cjs/context/ThemeContext.cjs +1 -1
- package/dist/cjs/hooks/useAnnotations.cjs +1 -1
- package/dist/cjs/hooks/useAttachments.cjs +1 -0
- package/dist/cjs/hooks/useKeyboardShortcuts.cjs +1 -1
- package/dist/cjs/hooks/usePDFRenderer.cjs +1 -1
- package/dist/cjs/hooks/useScrollTracking.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/pdf-tsx.css +1 -1
- package/dist/cjs/theme.cjs +1 -1
- package/dist/components/features/PDFAttachments.d.ts +5 -0
- package/dist/components/features/PDFChangeFile.d.ts +3 -0
- package/dist/components/features/PDFDownloadButton.d.ts +3 -0
- package/dist/components/features/PDFNavigation.d.ts +3 -0
- package/dist/components/features/PDFPageFit.d.ts +3 -0
- package/dist/components/features/PDFPrintButton.d.ts +3 -0
- package/dist/components/features/PDFRotationControl.d.ts +3 -0
- package/dist/components/features/PDFSearch.d.ts +3 -0
- package/dist/components/features/PDFSidebarToggle.d.ts +3 -0
- package/dist/components/features/PDFThemeToggle.d.ts +3 -0
- package/dist/components/features/PDFZoomControls.d.ts +3 -0
- package/dist/components/ui/PDFToolbar.d.ts +8 -0
- package/dist/components/ui/PDFToolbarItem.d.ts +7 -0
- package/dist/context/PDFViewerContext.d.ts +3 -1
- package/dist/es/components/PDFSidebar.module.js +9 -9
- package/dist/es/components/PDFViewer.js +168 -173
- package/dist/es/components/PDFViewer.module.js +15 -15
- package/dist/es/components/features/PDFAnnotations.module.js +12 -12
- package/dist/es/components/features/PDFAttachments.js +117 -0
- package/dist/es/components/features/PDFAttachments.module.js +12 -0
- package/dist/es/components/features/PDFChangeFile.js +1 -0
- package/dist/es/components/features/PDFDownloadButton.js +1 -0
- package/dist/es/components/features/PDFNavigation.js +1 -0
- package/dist/es/components/features/PDFNavigation.module.js +3 -3
- package/dist/es/components/features/PDFOutline.js +37 -24
- package/dist/es/components/features/PDFOutline.module.js +5 -5
- package/dist/es/components/features/PDFPageFit.js +18 -17
- package/dist/es/components/features/PDFPrintButton.js +1 -0
- package/dist/es/components/features/PDFRotationControl.js +1 -0
- package/dist/es/components/features/PDFSearch.js +1 -0
- package/dist/es/components/features/PDFSearch.module.js +5 -5
- package/dist/es/components/features/PDFSidebarToggle.js +8 -7
- package/dist/es/components/features/PDFSignatures.module.js +16 -16
- package/dist/es/components/features/PDFThemeToggle.js +1 -0
- package/dist/es/components/features/PDFThumbnails.module.js +9 -9
- package/dist/es/components/features/PDFZoomControls.js +29 -30
- package/dist/es/components/features/PDFZoomControls.module.js +1 -1
- package/dist/es/components/ui/PDFToolbar.js +84 -0
- package/dist/es/components/ui/PDFToolbar.module.js +13 -0
- package/dist/es/components/ui/PDFToolbarItem.js +25 -0
- package/dist/es/components/ui/ToolbarButton.module.js +2 -2
- package/dist/es/context/ThemeContext.js +1 -0
- package/dist/es/hooks/useAnnotations.js +2 -6
- package/dist/es/hooks/useAttachments.js +31 -0
- package/dist/es/hooks/useKeyboardShortcuts.js +8 -7
- package/dist/es/hooks/usePDFRenderer.js +20 -10
- package/dist/es/hooks/useScrollTracking.js +20 -30
- package/dist/es/index.js +18 -15
- package/dist/es/pdf-tsx.css +1 -1
- package/dist/es/theme.js +9 -3
- package/dist/hooks/useAnnotations.d.ts +1 -1
- package/dist/hooks/useAttachments.d.ts +11 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +2 -1
- package/dist/hooks/useScrollTracking.d.ts +2 -7
- package/dist/index.d.ts +3 -0
- package/dist/theme.d.ts +2 -0
- package/package.json +61 -61
- package/dist/pdf-tsx.cjs.js +0 -5
- package/dist/pdf-tsx.css +0 -2
- package/dist/pdf-tsx.es.js +0 -2637
- package/dist/vite.svg +0 -1
|
@@ -11,8 +11,11 @@ async function u(e, t) {
|
|
|
11
11
|
try {
|
|
12
12
|
let n = typeof t == "string" ? await e.getDestination(t) : t;
|
|
13
13
|
if (!n || n.length === 0) return null;
|
|
14
|
-
let r = n[0];
|
|
15
|
-
return
|
|
14
|
+
let r = n[0], i = await e.getPageIndex(r) + 1, a = n[1], o = null;
|
|
15
|
+
return a?.name === "XYZ" ? o = n[3] ?? null : (a?.name === "FitH" || a?.name === "FitBH") && (o = n[2] ?? null), {
|
|
16
|
+
page: i,
|
|
17
|
+
pdfTop: o
|
|
18
|
+
};
|
|
16
19
|
} catch {
|
|
17
20
|
return null;
|
|
18
21
|
}
|
|
@@ -63,38 +66,48 @@ function f(e) {
|
|
|
63
66
|
return !e;
|
|
64
67
|
}
|
|
65
68
|
function p() {
|
|
66
|
-
let n = a(
|
|
67
|
-
n[0] === r ?
|
|
68
|
-
let { outline:
|
|
69
|
-
n[2] !==
|
|
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) => {
|
|
70
73
|
let t = await u(r, e);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
if (t) {
|
|
75
|
+
if (t.pdfTop !== null) try {
|
|
76
|
+
let [, e] = (await r.getPage(t.page)).getViewport({
|
|
77
|
+
scale: o,
|
|
78
|
+
rotation: s
|
|
79
|
+
}).convertToViewportPoint(0, t.pdfTop);
|
|
80
|
+
f(t.page, e);
|
|
81
|
+
return;
|
|
82
|
+
} catch {}
|
|
83
|
+
f(t.page);
|
|
84
|
+
}
|
|
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", {
|
|
75
88
|
className: i.emptyState,
|
|
76
89
|
children: "Caricamento..."
|
|
77
|
-
}), n[
|
|
78
|
-
let
|
|
79
|
-
n[
|
|
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", {
|
|
80
93
|
className: i.emptyState,
|
|
81
94
|
children: "Nessun segnalibro disponibile."
|
|
82
|
-
}), n[
|
|
83
|
-
let
|
|
84
|
-
n[
|
|
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, {
|
|
85
98
|
node: e,
|
|
86
99
|
depth: 0,
|
|
87
|
-
onNavigate:
|
|
88
|
-
}, t)), n[
|
|
89
|
-
let
|
|
90
|
-
return n[
|
|
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", {
|
|
91
104
|
className: i.tree,
|
|
92
105
|
children: [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
v,
|
|
107
|
+
y,
|
|
108
|
+
b
|
|
96
109
|
]
|
|
97
|
-
}), n[
|
|
110
|
+
}), n[16] = v, n[17] = y, n[18] = b, n[19] = x) : x = n[19], x;
|
|
98
111
|
}
|
|
99
112
|
//#endregion
|
|
100
113
|
export { p as PDFOutline };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
emptyState: "
|
|
3
|
-
tree: "
|
|
4
|
-
row: "
|
|
5
|
-
chevronBtn: "
|
|
6
|
-
title: "
|
|
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"
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
9
9
|
export { e as default };
|
|
@@ -6,28 +6,29 @@ import "react";
|
|
|
6
6
|
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/features/PDFPageFit.tsx
|
|
8
8
|
function s(s) {
|
|
9
|
-
let c = r(
|
|
10
|
-
c[0] !==
|
|
11
|
-
!d || !
|
|
12
|
-
}, c[0] =
|
|
13
|
-
let
|
|
14
|
-
c[
|
|
15
|
-
let
|
|
16
|
-
c[
|
|
17
|
-
onClick:
|
|
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,
|
|
18
18
|
title: "Adatta alla larghezza",
|
|
19
19
|
children: l
|
|
20
|
-
}), c[
|
|
21
|
-
let y;
|
|
22
|
-
c[10] === g ? y = c[11] : (y = () => g("page"), c[10] = g, c[11] = y);
|
|
20
|
+
}), c[8] = l, c[9] = v, c[10] = y) : y = c[10];
|
|
23
21
|
let b;
|
|
24
|
-
c[
|
|
25
|
-
|
|
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,
|
|
26
26
|
title: "Adatta pagina intera",
|
|
27
27
|
children: u
|
|
28
|
-
}), c[
|
|
29
|
-
let
|
|
30
|
-
return c[
|
|
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;
|
|
31
31
|
}
|
|
32
|
+
s.toolbarLabel = "Adatta";
|
|
32
33
|
//#endregion
|
|
33
34
|
export { s as PDFPageFit };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
wrapper: "
|
|
3
|
-
searchIconWrapper: "
|
|
4
|
-
searchInput: "
|
|
5
|
-
navButton: "
|
|
6
|
-
counter: "
|
|
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"
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
9
9
|
export { e as default };
|
|
@@ -4,18 +4,19 @@ import { c as n } from "react/compiler-runtime";
|
|
|
4
4
|
import { jsx as r } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/features/PDFSidebarToggle.tsx
|
|
6
6
|
function i(i) {
|
|
7
|
-
let o = n(6), { collapseIcon: s, expandIcon: c } = i, { sidebarCollapsed: l, setSidebarCollapsed: u } = e(), d;
|
|
8
|
-
o[0] === u ?
|
|
9
|
-
let
|
|
10
|
-
return o[2] !== d || o[3] !==
|
|
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", {
|
|
11
11
|
className: t.btn,
|
|
12
|
-
onClick:
|
|
12
|
+
onClick: p,
|
|
13
13
|
title: f,
|
|
14
|
-
children:
|
|
15
|
-
}), o[2] = d, o[3] =
|
|
14
|
+
children: d
|
|
15
|
+
}), o[2] = d, o[3] = p, o[4] = f, o[5] = m) : m = o[5], m;
|
|
16
16
|
}
|
|
17
17
|
function a(e) {
|
|
18
18
|
return !e;
|
|
19
19
|
}
|
|
20
|
+
i.toolbarLabel = "Sidebar";
|
|
20
21
|
//#endregion
|
|
21
22
|
export { i as PDFSidebarToggle };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
list: "
|
|
3
|
-
emptyState: "
|
|
4
|
-
card: "
|
|
5
|
-
cardSigned: "
|
|
6
|
-
cardClickable: "
|
|
7
|
-
cardBody: "
|
|
8
|
-
cardHeader: "
|
|
9
|
-
fieldName: "
|
|
10
|
-
statusChip: "
|
|
11
|
-
statusChipSigned: "
|
|
12
|
-
fieldList: "
|
|
13
|
-
fieldRow: "
|
|
14
|
-
fieldLabel: "
|
|
15
|
-
fieldValue: "
|
|
16
|
-
iconWrapper: "
|
|
17
|
-
badge: "
|
|
2
|
+
list: "_list_irrdi_1",
|
|
3
|
+
emptyState: "_emptyState_irrdi_15",
|
|
4
|
+
card: "_card_irrdi_29",
|
|
5
|
+
cardSigned: "_cardSigned_irrdi_63",
|
|
6
|
+
cardClickable: "_cardClickable_irrdi_73",
|
|
7
|
+
cardBody: "_cardBody_irrdi_99",
|
|
8
|
+
cardHeader: "_cardHeader_irrdi_107",
|
|
9
|
+
fieldName: "_fieldName_irrdi_123",
|
|
10
|
+
statusChip: "_statusChip_irrdi_145",
|
|
11
|
+
statusChipSigned: "_statusChipSigned_irrdi_177",
|
|
12
|
+
fieldList: "_fieldList_irrdi_189",
|
|
13
|
+
fieldRow: "_fieldRow_irrdi_201",
|
|
14
|
+
fieldLabel: "_fieldLabel_irrdi_217",
|
|
15
|
+
fieldValue: "_fieldValue_irrdi_227",
|
|
16
|
+
iconWrapper: "_iconWrapper_irrdi_237",
|
|
17
|
+
badge: "_badge_irrdi_251"
|
|
18
18
|
};
|
|
19
19
|
//#endregion
|
|
20
20
|
export { e as default };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
thumbnailList: "
|
|
3
|
-
thumbnailItem: "
|
|
4
|
-
thumbnailItemActive: "
|
|
5
|
-
thumbnailImg: "
|
|
6
|
-
thumbnailImgActive: "
|
|
7
|
-
thumbnailSkeleton: "
|
|
8
|
-
shimmer: "
|
|
9
|
-
thumbnailLabel: "
|
|
10
|
-
thumbnailLabelActive: "
|
|
2
|
+
thumbnailList: "_thumbnailList_vk7sw_1",
|
|
3
|
+
thumbnailItem: "_thumbnailItem_vk7sw_11",
|
|
4
|
+
thumbnailItemActive: "_thumbnailItemActive_vk7sw_37",
|
|
5
|
+
thumbnailImg: "_thumbnailImg_vk7sw_55",
|
|
6
|
+
thumbnailImgActive: "_thumbnailImgActive_vk7sw_67",
|
|
7
|
+
thumbnailSkeleton: "_thumbnailSkeleton_vk7sw_75",
|
|
8
|
+
shimmer: "_shimmer_vk7sw_1",
|
|
9
|
+
thumbnailLabel: "_thumbnailLabel_vk7sw_103",
|
|
10
|
+
thumbnailLabelActive: "_thumbnailLabelActive_vk7sw_117"
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
13
|
export { e as default };
|
|
@@ -6,41 +6,40 @@ import "react";
|
|
|
6
6
|
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/features/PDFZoomControls.tsx
|
|
8
8
|
function s(s) {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
children: d
|
|
16
|
-
}), u[2] = h, u[3] = d, u[4] = g) : g = u[4];
|
|
9
|
+
let c = r(21), { zoomOutIcon: l, zoomInIcon: u } = s, { zoom: d, setZoom: f, setFitMode: p } = e(), m;
|
|
10
|
+
c[0] !== p || c[1] !== f ? (m = (e) => {
|
|
11
|
+
p(null), f((t) => Math.min(Math.max(t + e, .2), 3));
|
|
12
|
+
}, c[0] = p, c[1] = f, c[2] = m) : m = c[2];
|
|
13
|
+
let h = m, g;
|
|
14
|
+
c[3] === h ? g = c[4] : (g = () => h(-.2), c[3] = h, c[4] = g);
|
|
17
15
|
let _;
|
|
18
|
-
|
|
16
|
+
c[5] !== g || c[6] !== l ? (_ = /* @__PURE__ */ a(t, {
|
|
17
|
+
onClick: g,
|
|
18
|
+
title: "Riduci zoom",
|
|
19
|
+
children: l
|
|
20
|
+
}), c[5] = g, c[6] = l, c[7] = _) : _ = c[7];
|
|
19
21
|
let v;
|
|
20
|
-
|
|
21
|
-
className: n.zoomLabel,
|
|
22
|
-
children: [_, "%"]
|
|
23
|
-
}), u[7] = _, u[8] = v);
|
|
22
|
+
c[8] === d ? v = c[9] : (v = Math.round(d * 100), c[8] = d, c[9] = v);
|
|
24
23
|
let y;
|
|
25
|
-
|
|
24
|
+
c[10] === v ? y = c[11] : (y = /* @__PURE__ */ o("span", {
|
|
25
|
+
className: n.zoomLabel,
|
|
26
|
+
children: [v, "%"]
|
|
27
|
+
}), c[10] = v, c[11] = y);
|
|
26
28
|
let b;
|
|
27
|
-
|
|
28
|
-
onClick: y,
|
|
29
|
-
title: "Aumenta zoom",
|
|
30
|
-
children: f
|
|
31
|
-
}), u[11] = y, u[12] = f, u[13] = b) : b = u[13];
|
|
29
|
+
c[12] === h ? b = c[13] : (b = () => h(.2), c[12] = h, c[13] = b);
|
|
32
30
|
let x;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
c[14] !== b || c[15] !== u ? (x = /* @__PURE__ */ a(t, {
|
|
32
|
+
onClick: b,
|
|
33
|
+
title: "Aumenta zoom",
|
|
34
|
+
children: u
|
|
35
|
+
}), c[14] = b, c[15] = u, c[16] = x) : x = c[16];
|
|
36
|
+
let S;
|
|
37
|
+
return c[17] !== _ || c[18] !== y || c[19] !== x ? (S = /* @__PURE__ */ o(i, { children: [
|
|
38
|
+
_,
|
|
39
|
+
y,
|
|
40
|
+
x
|
|
41
|
+
] }), c[17] = _, c[18] = y, c[19] = x, c[20] = S) : S = c[20], S;
|
|
44
42
|
}
|
|
43
|
+
s.toolbarLabel = "Zoom";
|
|
45
44
|
//#endregion
|
|
46
45
|
export { s as PDFZoomControls };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ToolbarButton as e } from "./ToolbarButton.js";
|
|
2
|
+
import t from "./PDFToolbar.module.js";
|
|
3
|
+
import n, { createContext as r, useEffect as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
|
|
4
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ui/PDFToolbar.tsx
|
|
6
|
+
var u = r(!1), d = 40;
|
|
7
|
+
function f({ children: r, overflowIcon: f = "···" }) {
|
|
8
|
+
let p = o(null), m = o([]), h = o([]), g = o(() => {}), [_, v] = s(null), [y, b] = s(!1), x = o(null), S = n.Children.toArray(r);
|
|
9
|
+
g.current = () => {
|
|
10
|
+
let e = p.current, t = h.current;
|
|
11
|
+
if (!e || t.length === 0) return;
|
|
12
|
+
let n = e.offsetWidth;
|
|
13
|
+
if (t.reduce((e, t) => e + t, 0) <= n) {
|
|
14
|
+
v(null);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let r = 0, i = 0;
|
|
18
|
+
for (let e = 0; e < t.length && r + t[e] + d <= n; e++) r += t[e], i++;
|
|
19
|
+
v(i);
|
|
20
|
+
}, a(() => {
|
|
21
|
+
h.current = m.current.slice(0, S.length).map((e) => e?.offsetWidth ?? 0), g.current();
|
|
22
|
+
}, []), i(() => {
|
|
23
|
+
let e = p.current;
|
|
24
|
+
if (!e) return;
|
|
25
|
+
let t = new ResizeObserver(() => g.current());
|
|
26
|
+
return t.observe(e), () => t.disconnect();
|
|
27
|
+
}, []), i(() => {
|
|
28
|
+
if (!y) return;
|
|
29
|
+
let e = (e) => {
|
|
30
|
+
x.current?.contains(e.target) || b(!1);
|
|
31
|
+
};
|
|
32
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
33
|
+
}, [y]);
|
|
34
|
+
let C = _ !== null && _ < S.length, w = C ? S.slice(_) : [];
|
|
35
|
+
return /* @__PURE__ */ l("div", {
|
|
36
|
+
ref: p,
|
|
37
|
+
className: t.toolbar,
|
|
38
|
+
children: [S.map((e, n) => /* @__PURE__ */ c("div", {
|
|
39
|
+
ref: (e) => {
|
|
40
|
+
m.current[n] = e;
|
|
41
|
+
},
|
|
42
|
+
className: t.item,
|
|
43
|
+
style: _ !== null && n >= _ ? { display: "none" } : void 0,
|
|
44
|
+
children: e
|
|
45
|
+
}, n)), C && /* @__PURE__ */ l("div", {
|
|
46
|
+
ref: x,
|
|
47
|
+
className: t.overflowWrapper,
|
|
48
|
+
children: [/* @__PURE__ */ c(e, {
|
|
49
|
+
onClick: () => b((e) => !e),
|
|
50
|
+
"aria-label": "Altre opzioni",
|
|
51
|
+
"aria-expanded": y,
|
|
52
|
+
"aria-haspopup": "true",
|
|
53
|
+
title: "Altre opzioni",
|
|
54
|
+
className: y ? t.overflowBtnActive : void 0,
|
|
55
|
+
children: f
|
|
56
|
+
}), y && /* @__PURE__ */ c("div", {
|
|
57
|
+
className: t.dropdown,
|
|
58
|
+
role: "menu",
|
|
59
|
+
children: w.map((e, r) => {
|
|
60
|
+
let i = n.isValidElement(e) ? e.type.toolbarLabel : void 0;
|
|
61
|
+
return /* @__PURE__ */ c("div", {
|
|
62
|
+
className: t.dropdownItem,
|
|
63
|
+
role: "menuitem",
|
|
64
|
+
children: i ? /* @__PURE__ */ l("div", {
|
|
65
|
+
className: t.labeledItem,
|
|
66
|
+
children: [/* @__PURE__ */ c("span", {
|
|
67
|
+
className: t.itemLabel,
|
|
68
|
+
children: i
|
|
69
|
+
}), /* @__PURE__ */ c("div", {
|
|
70
|
+
className: t.itemContent,
|
|
71
|
+
children: e
|
|
72
|
+
})]
|
|
73
|
+
}) : /* @__PURE__ */ c(u.Provider, {
|
|
74
|
+
value: !0,
|
|
75
|
+
children: e
|
|
76
|
+
})
|
|
77
|
+
}, r);
|
|
78
|
+
})
|
|
79
|
+
})]
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { f as PDFToolbar, u as PDFToolbarDropdownContext };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var e = {
|
|
2
|
+
toolbar: "_toolbar_xoqxq_1",
|
|
3
|
+
item: "_item_xoqxq_9",
|
|
4
|
+
overflowWrapper: "_overflowWrapper_xoqxq_15",
|
|
5
|
+
overflowBtnActive: "_overflowBtnActive_xoqxq_21",
|
|
6
|
+
dropdown: "_dropdown_xoqxq_26",
|
|
7
|
+
dropdownItem: "_dropdownItem_xoqxq_41",
|
|
8
|
+
labeledItem: "_labeledItem_xoqxq_53",
|
|
9
|
+
itemContent: "_itemContent_xoqxq_60",
|
|
10
|
+
itemLabel: "_itemLabel_xoqxq_66"
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import e from "./PDFToolbar.module.js";
|
|
2
|
+
import { PDFToolbarDropdownContext as t } from "./PDFToolbar.js";
|
|
3
|
+
import { c as n } from "react/compiler-runtime";
|
|
4
|
+
import { useContext as r } from "react";
|
|
5
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ui/PDFToolbarItem.tsx
|
|
7
|
+
function s(s) {
|
|
8
|
+
let c = n(7), { children: l, label: u } = s;
|
|
9
|
+
if (!r(t) || !u) {
|
|
10
|
+
let e;
|
|
11
|
+
return c[0] === l ? e = c[1] : (e = /* @__PURE__ */ a(i, { children: l }), c[0] = l, c[1] = e), e;
|
|
12
|
+
}
|
|
13
|
+
let d;
|
|
14
|
+
c[2] === u ? d = c[3] : (d = /* @__PURE__ */ a("span", {
|
|
15
|
+
className: e.itemLabel,
|
|
16
|
+
children: u
|
|
17
|
+
}), c[2] = u, c[3] = d);
|
|
18
|
+
let f;
|
|
19
|
+
return c[4] !== l || c[5] !== d ? (f = /* @__PURE__ */ o("div", {
|
|
20
|
+
className: e.labeledItem,
|
|
21
|
+
children: [d, l]
|
|
22
|
+
}), c[4] = l, c[5] = d, c[6] = f) : f = c[6], f;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { s as PDFToolbarItem };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { useEffect as e, useState as t } from "react";
|
|
2
2
|
import "pdfjs-dist";
|
|
3
3
|
//#region src/hooks/useAnnotations.ts
|
|
4
|
-
var n = new Set([
|
|
5
|
-
"Widget",
|
|
6
|
-
"Link",
|
|
7
|
-
"Popup"
|
|
8
|
-
]);
|
|
4
|
+
var n = new Set(["Text", "PolyLine"]);
|
|
9
5
|
function r({ pdf: r }) {
|
|
10
6
|
let [i, a] = t([]), [o, s] = t(!1);
|
|
11
7
|
return e(() => {
|
|
@@ -17,7 +13,7 @@ function r({ pdf: r }) {
|
|
|
17
13
|
let i = await (await r.getPage(t)).getAnnotations();
|
|
18
14
|
for (let r of i) {
|
|
19
15
|
let i = r.subtype;
|
|
20
|
-
n.has(i)
|
|
16
|
+
n.has(i) && e.push({
|
|
21
17
|
id: r.id,
|
|
22
18
|
page: t,
|
|
23
19
|
subtype: i,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
import "pdfjs-dist";
|
|
3
|
+
//#region src/hooks/useAttachments.ts
|
|
4
|
+
function n({ pdf: n }) {
|
|
5
|
+
let [r, i] = t([]), [a, o] = t(!1);
|
|
6
|
+
return e(() => {
|
|
7
|
+
n && (async () => {
|
|
8
|
+
o(!0);
|
|
9
|
+
try {
|
|
10
|
+
let e = await n.getAttachments();
|
|
11
|
+
if (!e) {
|
|
12
|
+
i([]);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
i(Object.values(e).map((e) => ({
|
|
16
|
+
filename: e.filename,
|
|
17
|
+
content: e.content
|
|
18
|
+
})));
|
|
19
|
+
} catch {
|
|
20
|
+
i([]);
|
|
21
|
+
} finally {
|
|
22
|
+
o(!1);
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
}, [n]), {
|
|
26
|
+
attachments: r,
|
|
27
|
+
loading: a
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { n as useAttachments };
|
|
@@ -3,8 +3,8 @@ import { useEffect as t } from "react";
|
|
|
3
3
|
import "pdfjs-dist";
|
|
4
4
|
//#region src/hooks/useKeyboardShortcuts.ts
|
|
5
5
|
function n(n) {
|
|
6
|
-
let o = e(
|
|
7
|
-
o[0] !== c || o[1] !== l || o[2] !== s || o[3] !==
|
|
6
|
+
let o = e(8), { pdf: s, currentPage: c, goToPage: l, setZoom: u, setRotation: d, setFitMode: f } = n, p, m;
|
|
7
|
+
o[0] !== c || o[1] !== l || o[2] !== s || o[3] !== f || o[4] !== d || o[5] !== u ? (p = () => {
|
|
8
8
|
if (!s) return;
|
|
9
9
|
let e = (e) => {
|
|
10
10
|
let t = e.target.tagName;
|
|
@@ -19,23 +19,24 @@ function n(n) {
|
|
|
19
19
|
break bb13;
|
|
20
20
|
case "+":
|
|
21
21
|
case "=":
|
|
22
|
-
e.preventDefault(), u(a);
|
|
22
|
+
e.preventDefault(), f(null), u(a);
|
|
23
23
|
break bb13;
|
|
24
24
|
case "-":
|
|
25
|
-
e.preventDefault(), u(i);
|
|
25
|
+
e.preventDefault(), f(null), u(i);
|
|
26
26
|
break bb13;
|
|
27
27
|
case "r":
|
|
28
28
|
case "R": e.preventDefault(), d(r);
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
32
|
-
},
|
|
32
|
+
}, m = [
|
|
33
33
|
s,
|
|
34
34
|
c,
|
|
35
35
|
l,
|
|
36
36
|
u,
|
|
37
|
-
d
|
|
38
|
-
|
|
37
|
+
d,
|
|
38
|
+
f
|
|
39
|
+
], o[0] = c, o[1] = l, o[2] = s, o[3] = f, o[4] = d, o[5] = u, o[6] = p, o[7] = m) : (p = o[6], m = o[7]), t(p, m);
|
|
39
40
|
}
|
|
40
41
|
function r(e) {
|
|
41
42
|
return (e + 90) % 360;
|