pdf-tsx 0.11.0 → 0.13.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 (74) hide show
  1. package/README.md +486 -418
  2. package/dist/cjs/components/PDFViewer.cjs +1 -1
  3. package/dist/cjs/components/PDFViewer.module.cjs +1 -1
  4. package/dist/cjs/components/features/PDFAnnotations.cjs +1 -1
  5. package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -1
  6. package/dist/cjs/components/features/PDFAttachments.cjs +1 -1
  7. package/dist/cjs/components/features/PDFChangeFile.cjs +1 -1
  8. package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -1
  9. package/dist/cjs/components/features/PDFNavigation.cjs +1 -1
  10. package/dist/cjs/components/features/PDFOutline.cjs +1 -1
  11. package/dist/cjs/components/features/PDFPageFit.cjs +1 -1
  12. package/dist/cjs/components/features/PDFPrintButton.cjs +1 -1
  13. package/dist/cjs/components/features/PDFRotationControl.cjs +1 -1
  14. package/dist/cjs/components/features/PDFSearch.cjs +1 -1
  15. package/dist/cjs/components/features/PDFSidebarToggle.cjs +1 -1
  16. package/dist/cjs/components/features/PDFSignatures.cjs +1 -1
  17. package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -1
  18. package/dist/cjs/components/features/PDFThumbnails.cjs +1 -1
  19. package/dist/cjs/components/features/PDFZoomControls.cjs +1 -1
  20. package/dist/cjs/components/ui/PDFToolbar.cjs +1 -1
  21. package/dist/cjs/context/LabelsContext.cjs +1 -0
  22. package/dist/cjs/context/labelsContextValue.cjs +1 -0
  23. package/dist/cjs/hooks/useAnnotationLayer.cjs +1 -1
  24. package/dist/cjs/hooks/useAnnotations.cjs +1 -1
  25. package/dist/cjs/hooks/useLabels.cjs +1 -0
  26. package/dist/cjs/index.cjs +1 -1
  27. package/dist/cjs/labels.cjs +1 -0
  28. package/dist/cjs/pdf-tsx.css +1 -1
  29. package/dist/components/PDFViewer.d.ts +3 -0
  30. package/dist/components/features/PDFChangeFile.d.ts +1 -1
  31. package/dist/components/features/PDFDownloadButton.d.ts +1 -1
  32. package/dist/components/features/PDFNavigation.d.ts +1 -1
  33. package/dist/components/features/PDFPageFit.d.ts +1 -1
  34. package/dist/components/features/PDFPrintButton.d.ts +1 -1
  35. package/dist/components/features/PDFRotationControl.d.ts +1 -1
  36. package/dist/components/features/PDFSearch.d.ts +3 -2
  37. package/dist/components/features/PDFSidebarToggle.d.ts +1 -1
  38. package/dist/components/features/PDFThemeToggle.d.ts +1 -1
  39. package/dist/components/features/PDFZoomControls.d.ts +1 -1
  40. package/dist/context/LabelsContext.d.ts +7 -0
  41. package/dist/context/PDFViewerContext.d.ts +1 -0
  42. package/dist/context/labelsContextValue.d.ts +2 -0
  43. package/dist/es/components/PDFViewer.js +359 -187
  44. package/dist/es/components/PDFViewer.module.js +23 -16
  45. package/dist/es/components/features/PDFAnnotations.js +132 -62
  46. package/dist/es/components/features/PDFAnnotations.module.js +12 -12
  47. package/dist/es/components/features/PDFAttachments.js +42 -41
  48. package/dist/es/components/features/PDFChangeFile.js +17 -16
  49. package/dist/es/components/features/PDFDownloadButton.js +15 -14
  50. package/dist/es/components/features/PDFNavigation.js +40 -38
  51. package/dist/es/components/features/PDFOutline.js +46 -45
  52. package/dist/es/components/features/PDFPageFit.js +19 -18
  53. package/dist/es/components/features/PDFPrintButton.js +14 -13
  54. package/dist/es/components/features/PDFRotationControl.js +12 -11
  55. package/dist/es/components/features/PDFSearch.js +71 -55
  56. package/dist/es/components/features/PDFSidebarToggle.js +13 -12
  57. package/dist/es/components/features/PDFSignatures.js +87 -84
  58. package/dist/es/components/features/PDFThemeToggle.js +12 -11
  59. package/dist/es/components/features/PDFThumbnails.js +33 -32
  60. package/dist/es/components/features/PDFZoomControls.js +23 -22
  61. package/dist/es/components/ui/PDFToolbar.js +56 -55
  62. package/dist/es/context/LabelsContext.js +14 -0
  63. package/dist/es/context/labelsContextValue.js +5 -0
  64. package/dist/es/hooks/useAnnotationLayer.js +37 -20
  65. package/dist/es/hooks/useAnnotations.js +5 -3
  66. package/dist/es/hooks/useLabels.js +9 -0
  67. package/dist/es/index.js +22 -21
  68. package/dist/es/labels.js +128 -0
  69. package/dist/es/pdf-tsx.css +1 -1
  70. package/dist/hooks/useAnnotationLayer.d.ts +15 -1
  71. package/dist/hooks/useLabels.d.ts +2 -0
  72. package/dist/index.d.ts +2 -0
  73. package/dist/labels.d.ts +53 -0
  74. package/package.json +2 -1
@@ -1,93 +1,163 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
2
  import { computeFit as t } from "../../utils/pdfFit.js";
3
- import { useAnnotations as n } from "../../hooks/useAnnotations.js";
4
- import r from "./PDFAnnotations.module.js";
5
- import { memo as i, useCallback as a, useMemo as o } from "react";
6
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
3
+ import { useLabels as n } from "../../hooks/useLabels.js";
4
+ import { useAnnotations as r } from "../../hooks/useAnnotations.js";
5
+ import i from "./PDFAnnotations.module.js";
6
+ import { memo as a, useCallback as o, useMemo as s } from "react";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
8
  //#region src/components/features/PDFAnnotations.tsx
8
- var l = {
9
- Text: "Nota",
10
- Highlight: "Evidenziazione",
11
- Underline: "Sottolineatura",
12
- StrikeOut: "Barrato",
13
- FreeText: "Testo libero",
14
- Ink: "Disegno",
15
- Square: "Rettangolo",
16
- Circle: "Cerchio",
17
- Line: "Linea",
18
- Stamp: "Timbro",
19
- FileAttachment: "Allegato"
20
- }, u = i(function({ ann: e, onNavigate: t }) {
21
- let n = l[e.subtype] ?? e.subtype, i = a(() => t(e), [t, e]);
22
- return /* @__PURE__ */ c("div", {
23
- className: `${r.card} ${e.rect ? r.cardClickable : ""}`,
24
- onClick: i,
9
+ function u({ subtype: e }) {
10
+ let t = {
11
+ width: 14,
12
+ height: 14,
13
+ fill: "none",
14
+ "aria-hidden": !0
15
+ };
16
+ return e === "Text" ? /* @__PURE__ */ l("svg", {
17
+ ...t,
18
+ viewBox: "0 0 12 12",
25
19
  children: [
26
- /* @__PURE__ */ c("div", {
27
- className: r.cardHeader,
28
- children: [/* @__PURE__ */ s("span", {
29
- className: r.cardLabel,
30
- children: n
31
- }), /* @__PURE__ */ c("span", {
32
- className: r.cardPage,
20
+ /* @__PURE__ */ c("rect", {
21
+ x: "0.5",
22
+ y: "0.5",
23
+ width: "9",
24
+ height: "8",
25
+ rx: "1",
26
+ fill: "rgba(255,210,0,0.9)",
27
+ stroke: "rgba(160,120,0,0.7)",
28
+ strokeWidth: "1"
29
+ }),
30
+ /* @__PURE__ */ c("path", {
31
+ d: "M9.5 5.5v3l2.5-3z",
32
+ fill: "rgba(255,210,0,0.9)",
33
+ stroke: "rgba(160,120,0,0.7)",
34
+ strokeWidth: "1"
35
+ }),
36
+ /* @__PURE__ */ c("line", {
37
+ x1: "2",
38
+ y1: "3",
39
+ x2: "8",
40
+ y2: "3",
41
+ stroke: "rgba(90,60,0,0.8)",
42
+ strokeWidth: "1",
43
+ strokeLinecap: "round"
44
+ }),
45
+ /* @__PURE__ */ c("line", {
46
+ x1: "2",
47
+ y1: "5.5",
48
+ x2: "7",
49
+ y2: "5.5",
50
+ stroke: "rgba(90,60,0,0.8)",
51
+ strokeWidth: "1",
52
+ strokeLinecap: "round"
53
+ })
54
+ ]
55
+ }) : /* @__PURE__ */ l("svg", {
56
+ ...t,
57
+ viewBox: "0 0 16 16",
58
+ children: [
59
+ /* @__PURE__ */ c("circle", {
60
+ cx: "8",
61
+ cy: "8",
62
+ r: "5.5",
63
+ stroke: "currentColor",
64
+ strokeWidth: "1.5"
65
+ }),
66
+ /* @__PURE__ */ c("line", {
67
+ x1: "8",
68
+ y1: "6",
69
+ x2: "8",
70
+ y2: "10",
71
+ stroke: "currentColor",
72
+ strokeWidth: "1.5",
73
+ strokeLinecap: "round"
74
+ }),
75
+ /* @__PURE__ */ c("circle", {
76
+ cx: "8",
77
+ cy: "4.5",
78
+ r: "0.75",
79
+ fill: "currentColor"
80
+ })
81
+ ]
82
+ });
83
+ }
84
+ var d = a(function({ ann: e, annotationTypes: t, onNavigate: n }) {
85
+ let r = t[e.subtype] ?? e.subtype, a = o(() => n(e), [n, e]);
86
+ return /* @__PURE__ */ l("div", {
87
+ className: `${i.card} ${e.rect ? i.cardClickable : ""}`,
88
+ onClick: a,
89
+ children: [
90
+ /* @__PURE__ */ l("div", {
91
+ className: i.cardHeader,
92
+ children: [/* @__PURE__ */ l("span", {
93
+ className: i.cardLabel,
94
+ children: [/* @__PURE__ */ c(u, { subtype: e.subtype }), r]
95
+ }), /* @__PURE__ */ l("span", {
96
+ className: i.cardPage,
33
97
  children: ["p.", e.page]
34
98
  })]
35
99
  }),
36
- e.title && /* @__PURE__ */ s("div", {
37
- className: r.cardAuthor,
100
+ e.title && /* @__PURE__ */ c("div", {
101
+ className: i.cardAuthor,
38
102
  children: e.title
39
103
  }),
40
- e.contents && /* @__PURE__ */ s("div", {
41
- className: r.cardContent,
104
+ e.contents && /* @__PURE__ */ c("div", {
105
+ className: i.cardContent,
42
106
  children: e.contents
43
107
  })
44
108
  ]
45
109
  });
46
110
  });
47
- function d({ icon: t }) {
48
- let { pdf: i } = e(), { annotations: a, loading: o } = n({ pdf: i }), l = a.length;
49
- return /* @__PURE__ */ c("span", {
50
- className: r.iconWrapper,
51
- children: [t, !o && l > 0 && /* @__PURE__ */ s("span", {
52
- className: r.badge,
53
- children: l > 99 ? "99+" : l
111
+ function f({ icon: t }) {
112
+ let { pdf: n } = e(), { annotations: a, loading: o } = r({ pdf: n }), s = a.length;
113
+ return /* @__PURE__ */ l("span", {
114
+ className: i.iconWrapper,
115
+ children: [t, !o && s > 0 && /* @__PURE__ */ c("span", {
116
+ className: i.badge,
117
+ children: s > 99 ? "99+" : s
54
118
  })]
55
119
  });
56
120
  }
57
- function f() {
58
- let { pdf: i, goToPage: l, setHighlight: d, setZoom: f, rotation: p, containerRef: m } = e(), { annotations: h, loading: g } = n({ pdf: i }), _ = a(async (e) => {
59
- i && m.current && f(await t("page", i, m.current, p)), l(e.page), e.rect && d({
121
+ function p() {
122
+ let { pdf: a, goToPage: u, setHighlight: f, setZoom: p, setFitMode: m, rotation: h, containerRef: g } = e(), _ = n(), { annotations: v, loading: y } = r({ pdf: a }), b = o(async (e) => {
123
+ m("page"), a && g.current && p(await t("page", a, g.current, h)), u(e.page), e.rect && f({
60
124
  page: e.page,
61
125
  pdfRect: e.rect
62
126
  });
63
127
  }, [
64
- i,
65
- m,
128
+ a,
129
+ g,
130
+ h,
131
+ u,
66
132
  p,
67
- l,
68
- f,
69
- d
70
- ]), v = o(() => h.reduce((e, t) => ((e[t.page] ??= []).push(t), e), {}), [h]);
71
- return /* @__PURE__ */ c("div", {
72
- className: r.list,
133
+ m,
134
+ f
135
+ ]), x = s(() => v.reduce((e, t) => ((e[t.page] ??= []).push(t), e), {}), [v]);
136
+ return /* @__PURE__ */ l("div", {
137
+ className: i.list,
73
138
  children: [
74
- g && /* @__PURE__ */ s("div", {
75
- className: r.emptyState,
76
- children: "Caricamento..."
139
+ y && /* @__PURE__ */ c("div", {
140
+ className: i.emptyState,
141
+ children: _.annotationsLoading
77
142
  }),
78
- !g && h.length === 0 && /* @__PURE__ */ s("div", {
79
- className: r.emptyState,
80
- children: "Nessuna annotazione rilevata."
143
+ !y && v.length === 0 && /* @__PURE__ */ c("div", {
144
+ className: i.emptyState,
145
+ children: _.annotationsEmpty
81
146
  }),
82
- !g && Object.entries(v).map(([e, t]) => /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ c("div", {
83
- className: r.pageHeader,
84
- children: ["Pagina ", e]
85
- }), t.map((e) => /* @__PURE__ */ s(u, {
147
+ !y && Object.entries(x).map(([e, t]) => /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ l("div", {
148
+ className: i.pageHeader,
149
+ children: [
150
+ _.annotationsPageHeader,
151
+ " ",
152
+ e
153
+ ]
154
+ }), t.map((e) => /* @__PURE__ */ c(d, {
86
155
  ann: e,
87
- onNavigate: _
156
+ annotationTypes: _.annotationTypes,
157
+ onNavigate: b
88
158
  }, e.id))] }, e))
89
159
  ]
90
160
  });
91
161
  }
92
162
  //#endregion
93
- export { f as PDFAnnotations, d as PDFAnnotationsIcon };
163
+ export { p as PDFAnnotations, f as PDFAnnotationsIcon };
@@ -1,16 +1,16 @@
1
1
  var e = {
2
- list: "_list_113xr_1",
3
- emptyState: "_emptyState_113xr_6",
4
- pageHeader: "_pageHeader_113xr_12",
5
- card: "_card_113xr_23",
6
- cardClickable: "_cardClickable_113xr_33",
7
- cardHeader: "_cardHeader_113xr_41",
8
- cardLabel: "_cardLabel_113xr_48",
9
- cardPage: "_cardPage_113xr_54",
10
- cardAuthor: "_cardAuthor_113xr_59",
11
- cardContent: "_cardContent_113xr_65",
12
- iconWrapper: "_iconWrapper_113xr_71",
13
- badge: "_badge_113xr_78"
2
+ list: "_list_gygvf_1",
3
+ emptyState: "_emptyState_gygvf_6",
4
+ pageHeader: "_pageHeader_gygvf_12",
5
+ card: "_card_gygvf_23",
6
+ cardClickable: "_cardClickable_gygvf_33",
7
+ cardHeader: "_cardHeader_gygvf_41",
8
+ cardLabel: "_cardLabel_gygvf_48",
9
+ cardPage: "_cardPage_gygvf_57",
10
+ cardAuthor: "_cardAuthor_gygvf_62",
11
+ cardContent: "_cardContent_gygvf_68",
12
+ iconWrapper: "_iconWrapper_gygvf_74",
13
+ badge: "_badge_gygvf_81"
14
14
  };
15
15
  //#endregion
16
16
  export { e as default };
@@ -1,22 +1,23 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
- import { useAttachments as t } from "../../hooks/useAttachments.js";
3
- import n from "./PDFAttachments.module.js";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
2
+ import { useLabels as t } from "../../hooks/useLabels.js";
3
+ import { useAttachments as n } from "../../hooks/useAttachments.js";
4
+ import r from "./PDFAttachments.module.js";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
6
  //#region src/components/features/PDFAttachments.tsx
6
- function a() {
7
- return /* @__PURE__ */ i("svg", {
7
+ function o() {
8
+ return /* @__PURE__ */ a("svg", {
8
9
  width: "13",
9
10
  height: "13",
10
11
  viewBox: "0 0 13 13",
11
12
  fill: "none",
12
13
  "aria-hidden": !0,
13
- children: [/* @__PURE__ */ r("path", {
14
+ children: [/* @__PURE__ */ i("path", {
14
15
  d: "M6.5 1.5v7M3.5 6l3 3 3-3",
15
16
  stroke: "currentColor",
16
17
  strokeWidth: "1.5",
17
18
  strokeLinecap: "round",
18
19
  strokeLinejoin: "round"
19
- }), /* @__PURE__ */ r("path", {
20
+ }), /* @__PURE__ */ i("path", {
20
21
  d: "M1.5 10.5h10",
21
22
  stroke: "currentColor",
22
23
  strokeWidth: "1.5",
@@ -24,19 +25,19 @@ function a() {
24
25
  })]
25
26
  });
26
27
  }
27
- function o() {
28
- return /* @__PURE__ */ i("svg", {
28
+ function s() {
29
+ return /* @__PURE__ */ a("svg", {
29
30
  width: "14",
30
31
  height: "14",
31
32
  viewBox: "0 0 14 14",
32
33
  fill: "none",
33
34
  "aria-hidden": !0,
34
- children: [/* @__PURE__ */ r("path", {
35
+ children: [/* @__PURE__ */ i("path", {
35
36
  d: "M3 1.5h5.5L11 4v8.5H3V1.5z",
36
37
  stroke: "currentColor",
37
38
  strokeWidth: "1.2",
38
39
  strokeLinejoin: "round"
39
- }), /* @__PURE__ */ r("path", {
40
+ }), /* @__PURE__ */ i("path", {
40
41
  d: "M8.5 1.5V4H11",
41
42
  stroke: "currentColor",
42
43
  strokeWidth: "1.2",
@@ -44,51 +45,51 @@ function o() {
44
45
  })]
45
46
  });
46
47
  }
47
- function s(e) {
48
+ function c(e) {
48
49
  let t = new Blob([new Uint8Array(e.content)]), n = URL.createObjectURL(t), r = document.createElement("a");
49
50
  r.href = n, r.download = e.filename, r.click(), URL.revokeObjectURL(n);
50
51
  }
51
- function c({ icon: a }) {
52
- let { pdf: o } = e(), { attachments: s, loading: c } = t({ pdf: o }), l = s.length;
53
- return /* @__PURE__ */ i("span", {
54
- className: n.iconWrapper,
55
- children: [a, !c && l > 0 && /* @__PURE__ */ r("span", {
56
- className: n.badge,
52
+ function l({ icon: t }) {
53
+ let { pdf: o } = e(), { attachments: s, loading: c } = n({ pdf: o }), l = s.length;
54
+ return /* @__PURE__ */ a("span", {
55
+ className: r.iconWrapper,
56
+ children: [t, !c && l > 0 && /* @__PURE__ */ i("span", {
57
+ className: r.badge,
57
58
  children: l > 99 ? "99+" : l
58
59
  })]
59
60
  });
60
61
  }
61
- function l() {
62
- let { pdf: c } = e(), { attachments: l, loading: u } = t({ pdf: c });
63
- return /* @__PURE__ */ i("div", {
64
- className: n.list,
62
+ function u() {
63
+ let { pdf: l } = e(), u = t(), { attachments: d, loading: f } = n({ pdf: l });
64
+ return /* @__PURE__ */ a("div", {
65
+ className: r.list,
65
66
  children: [
66
- u && /* @__PURE__ */ r("div", {
67
- className: n.emptyState,
68
- children: "Caricamento..."
67
+ f && /* @__PURE__ */ i("div", {
68
+ className: r.emptyState,
69
+ children: u.attachmentsLoading
69
70
  }),
70
- !u && l.length === 0 && /* @__PURE__ */ r("div", {
71
- className: n.emptyState,
72
- children: "Nessun allegato rilevato."
71
+ !f && d.length === 0 && /* @__PURE__ */ i("div", {
72
+ className: r.emptyState,
73
+ children: u.attachmentsEmpty
73
74
  }),
74
- !u && l.map((e, t) => /* @__PURE__ */ i("div", {
75
- className: n.card,
75
+ !f && d.map((e, t) => /* @__PURE__ */ a("div", {
76
+ className: r.card,
76
77
  children: [
77
- /* @__PURE__ */ r("span", {
78
- className: n.fileIcon,
79
- children: /* @__PURE__ */ r(o, {})
78
+ /* @__PURE__ */ i("span", {
79
+ className: r.fileIcon,
80
+ children: /* @__PURE__ */ i(s, {})
80
81
  }),
81
- /* @__PURE__ */ r("span", {
82
- className: n.filename,
82
+ /* @__PURE__ */ i("span", {
83
+ className: r.filename,
83
84
  title: e.filename,
84
85
  children: e.filename
85
86
  }),
86
- /* @__PURE__ */ r("button", {
87
+ /* @__PURE__ */ i("button", {
87
88
  type: "button",
88
- className: n.downloadBtn,
89
- title: `Scarica ${e.filename}`,
90
- onClick: () => s(e),
91
- children: /* @__PURE__ */ r(a, {})
89
+ className: r.downloadBtn,
90
+ title: `${u.downloadAttachmentTitle} ${e.filename}`,
91
+ onClick: () => c(e),
92
+ children: /* @__PURE__ */ i(o, {})
92
93
  })
93
94
  ]
94
95
  }, t))
@@ -96,4 +97,4 @@ function l() {
96
97
  });
97
98
  }
98
99
  //#endregion
99
- export { l as PDFAttachments, c as PDFAttachmentsIcon };
100
+ export { u as PDFAttachments, l as PDFAttachmentsIcon };
@@ -1,25 +1,26 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
- import { ToolbarButton as t } from "../ui/ToolbarButton.js";
3
- import { useCallback as n, useRef as r } from "react";
4
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
2
+ import { useLabels as t } from "../../hooks/useLabels.js";
3
+ import { ToolbarButton as n } from "../ui/ToolbarButton.js";
4
+ import { useCallback as r, useRef as i } from "react";
5
+ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
5
6
  //#region src/components/features/PDFChangeFile.tsx
6
- function s({ icon: s }) {
7
- let { onChangeFile: c } = e(), l = r(null), u = n((e) => {
7
+ function c({ icon: c }) {
8
+ let { onChangeFile: l } = e(), u = t(), d = i(null), f = r((e) => {
8
9
  let t = e.target.files?.[0];
9
- t && c?.(t), e.target.value = "";
10
- }, [c]), d = n(() => l.current?.click(), []);
11
- return /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("input", {
12
- ref: l,
10
+ t && l?.(t), e.target.value = "";
11
+ }, [l]), p = r(() => d.current?.click(), []);
12
+ return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("input", {
13
+ ref: d,
13
14
  type: "file",
14
15
  accept: ".pdf",
15
16
  style: { display: "none" },
16
- onChange: u
17
- }), /* @__PURE__ */ a(t, {
18
- onClick: d,
19
- title: "Apri altro file",
20
- children: s
17
+ onChange: f
18
+ }), /* @__PURE__ */ o(n, {
19
+ onClick: p,
20
+ title: u.changeFileTitle,
21
+ children: c
21
22
  })] });
22
23
  }
23
- s.toolbarLabel = "Apri file";
24
+ c.toolbarLabelKey = "changeFileToolbarLabel";
24
25
  //#endregion
25
- export { s as PDFChangeFile };
26
+ export { c as PDFChangeFile };
@@ -1,20 +1,21 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
- import { ToolbarButton as t } from "../ui/ToolbarButton.js";
3
- import { useCallback as n } from "react";
4
- import { jsxs as r } from "react/jsx-runtime";
2
+ import { useLabels as t } from "../../hooks/useLabels.js";
3
+ import { ToolbarButton as n } from "../ui/ToolbarButton.js";
4
+ import { useCallback as r } from "react";
5
+ import { jsxs as i } from "react/jsx-runtime";
5
6
  //#region src/components/features/PDFDownloadButton.tsx
6
- function i({ icon: i }) {
7
- let { file: a } = e();
8
- return /* @__PURE__ */ r(t, {
7
+ function a({ icon: a }) {
8
+ let { file: o } = e(), s = t();
9
+ return /* @__PURE__ */ i(n, {
9
10
  $primary: !0,
10
- onClick: n(() => {
11
- let e = URL.createObjectURL(a), t = document.createElement("a");
12
- t.href = e, t.download = a.name || "documento.pdf", t.click(), setTimeout(() => URL.revokeObjectURL(e), 0);
13
- }, [a]),
14
- title: "Scarica PDF",
15
- children: [i, "Scarica"]
11
+ onClick: r(() => {
12
+ let e = URL.createObjectURL(o), t = document.createElement("a");
13
+ t.href = e, t.download = o.name || s.downloadFallbackFilename, t.click(), setTimeout(() => URL.revokeObjectURL(e), 0);
14
+ }, [o, s.downloadFallbackFilename]),
15
+ title: s.downloadTitle,
16
+ children: [a, s.downloadText]
16
17
  });
17
18
  }
18
- i.toolbarLabel = "Scarica";
19
+ a.toolbarLabelKey = "downloadToolbarLabel";
19
20
  //#endregion
20
- export { i as PDFDownloadButton };
21
+ export { a as PDFDownloadButton };
@@ -1,50 +1,52 @@
1
1
  import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
- import { ToolbarButton as t } from "../ui/ToolbarButton.js";
3
- import n from "./PDFNavigation.module.js";
4
- import { useCallback as r, useState as i } from "react";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
2
+ import { useLabels as t } from "../../hooks/useLabels.js";
3
+ import { ToolbarButton as n } from "../ui/ToolbarButton.js";
4
+ import r from "./PDFNavigation.module.js";
5
+ import { useCallback as i, useState as a } from "react";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
7
  //#region src/components/features/PDFNavigation.tsx
7
- function s({ prevIcon: s, nextIcon: c }) {
8
- let { currentPage: l, numPages: u, goToPage: d } = e(), [f, p] = i(!1), [m, h] = i(""), g = r(() => {
9
- let e = parseInt(m, 10);
10
- isNaN(e) || d(e), p(!1);
11
- }, [m, d]), _ = r(() => {
12
- p(!0), h(String(l));
13
- }, [l]), v = r((e) => h(e.target.value), []), y = r((e) => {
14
- e.key === "Enter" && g(), e.key === "Escape" && p(!1);
15
- }, [g]), b = r(() => d(l - 1), [d, l]), x = r(() => d(l + 1), [d, l]);
16
- return /* @__PURE__ */ o("div", {
17
- className: n.navWrapper,
8
+ function c({ prevIcon: c, nextIcon: l }) {
9
+ let { currentPage: u, numPages: d, goToPage: f, navigationLocked: p } = e(), m = t(), [h, g] = a(!1), [_, v] = a(""), y = i(() => {
10
+ let e = parseInt(_, 10);
11
+ isNaN(e) || f(e), g(!1);
12
+ }, [_, f]), b = i(() => {
13
+ g(!0), v(String(u));
14
+ }, [u]), x = i((e) => v(e.target.value), []), S = i((e) => {
15
+ e.key === "Enter" && y(), e.key === "Escape" && g(!1);
16
+ }, [y]), C = i(() => f(u - 1), [f, u]), w = i(() => f(u + 1), [f, u]);
17
+ return /* @__PURE__ */ s("div", {
18
+ className: r.navWrapper,
18
19
  children: [
19
- /* @__PURE__ */ a(t, {
20
- onClick: b,
21
- disabled: l === 1,
22
- title: "Pagina precedente (←)",
23
- children: s
20
+ /* @__PURE__ */ o(n, {
21
+ onClick: C,
22
+ disabled: u === 1,
23
+ title: m.prevPageTitle,
24
+ children: c
24
25
  }),
25
- /* @__PURE__ */ a("input", {
26
- className: n.pageInput,
26
+ /* @__PURE__ */ o("input", {
27
+ className: r.pageInput,
27
28
  type: "number",
28
- value: f ? m : l,
29
- onFocus: _,
30
- onBlur: g,
31
- onChange: v,
32
- onKeyDown: y,
33
- title: "Vai alla pagina"
29
+ value: h ? _ : u,
30
+ onFocus: b,
31
+ onBlur: y,
32
+ onChange: x,
33
+ onKeyDown: S,
34
+ title: m.pageInputTitle,
35
+ readOnly: p
34
36
  }),
35
- /* @__PURE__ */ o("span", {
36
- className: n.pageTotal,
37
- children: ["/ ", u]
37
+ /* @__PURE__ */ s("span", {
38
+ className: r.pageTotal,
39
+ children: ["/ ", d]
38
40
  }),
39
- /* @__PURE__ */ a(t, {
40
- onClick: x,
41
- disabled: l === u,
42
- title: "Pagina successiva (→)",
43
- children: c
41
+ /* @__PURE__ */ o(n, {
42
+ onClick: w,
43
+ disabled: u === d,
44
+ title: m.nextPageTitle,
45
+ children: l
44
46
  })
45
47
  ]
46
48
  });
47
49
  }
48
- s.toolbarLabel = "Pagina";
50
+ c.toolbarLabelKey = "navigationToolbarLabel";
49
51
  //#endregion
50
- export { s as PDFNavigation };
52
+ export { c as PDFNavigation };