@gouvfr-lasuite/ui-kit 0.20.2 → 0.22.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/dist/PdfPreview-BOIgXF66.js +603 -0
- package/dist/PdfPreview-BOIgXF66.js.map +1 -0
- package/dist/PdfPreview-CnHLGN5f.cjs +2 -0
- package/dist/PdfPreview-CnHLGN5f.cjs.map +1 -0
- package/dist/index-BwV1Jx-_.js +28003 -0
- package/dist/index-BwV1Jx-_.js.map +1 -0
- package/dist/index-Bwp4cywr.cjs +108 -0
- package/dist/index-Bwp4cywr.cjs.map +1 -0
- package/dist/index.cjs +1 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +340 -0
- package/dist/index.js +361 -26689
- package/dist/index.js.map +1 -1
- package/dist/pdf.worker.mjs +58008 -0
- package/dist/storybook/preview-files/Archive.7z +0 -0
- package/dist/storybook/preview-files/CR Conseil municipal vfvdef_maireok.pdf +0 -0
- package/dist/storybook/preview-files/Folders.iso +0 -0
- package/dist/storybook/preview-files/IMG_7665.heic +0 -0
- package/dist/storybook/preview-files/Rembrandt_Winterlandschap_1646.jpg +0 -0
- package/dist/storybook/preview-files/Tableau.xlsx +0 -0
- package/dist/storybook/preview-files/XFA-3_3.pdf +0 -0
- package/dist/storybook/preview-files/art-institute-of-chicago-ce0DXHdjbhw-unsplash 1.png +0 -0
- package/dist/storybook/preview-files/chantier.mp4 +0 -0
- package/dist/storybook/preview-files/coucou.pages +0 -0
- package/dist/storybook/preview-files/mixed_page_sizes.pdf +379 -0
- package/dist/storybook/preview-files/monet_1.jpeg +0 -0
- package/dist/storybook/preview-files/nuissance_sonores.mp3 +0 -0
- package/dist/storybook/preview-files/pdf_corrupted.pdf +1 -0
- package/dist/storybook/preview-files/pdf_with_js.pdf +0 -0
- package/dist/storybook/preview-files/pdf_with_js_link.pdf +0 -0
- package/dist/storybook/preview-files/pdf_with_links.pdf +0 -0
- package/dist/storybook/preview-files/pv_cm.pdf +0 -0
- package/dist/storybook/preview-files/test-unsupported.bin +1 -0
- package/dist/style.css +1 -1
- package/package.json +16 -5
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
import { O as se, T as ie, j as n, a as E, b as A, c as W, L as ce, Z as ae, u as Y, D as le, I as de, d as ue, e as pe } from "./index-BwV1Jx-_.js";
|
|
2
|
+
import { useState as I, useCallback as u, useRef as b, useEffect as S, useMemo as $, useImperativeHandle as fe } from "react";
|
|
3
|
+
import { useQuery as he } from "@tanstack/react-query";
|
|
4
|
+
import { Thumbnail as we, Page as me, pdfjs as ge, Document as ve } from "react-pdf";
|
|
5
|
+
import "react-pdf/dist/Page/AnnotationLayer.css";
|
|
6
|
+
import "react-pdf/dist/Page/TextLayer.css";
|
|
7
|
+
import "react-virtualized/styles.css";
|
|
8
|
+
import { AutoSizer as J, List as X } from "react-virtualized";
|
|
9
|
+
import { Button as _e, Input as xe, useModals as Pe } from "@gouvfr-lasuite/cunningham-react";
|
|
10
|
+
typeof URL.parse > "u" && (URL.parse = function(t, e) {
|
|
11
|
+
try {
|
|
12
|
+
return new URL(t, e);
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const z = Promise;
|
|
18
|
+
typeof z.withResolvers > "u" && (z.withResolvers = function() {
|
|
19
|
+
let t, e;
|
|
20
|
+
return { promise: new Promise((a, o) => {
|
|
21
|
+
t = a, e = o;
|
|
22
|
+
}), resolve: t, reject: e };
|
|
23
|
+
});
|
|
24
|
+
const Re = ({
|
|
25
|
+
numPages: t,
|
|
26
|
+
currentPage: e,
|
|
27
|
+
scrollToPage: r
|
|
28
|
+
}) => {
|
|
29
|
+
const [a, o] = I("1"), i = u(
|
|
30
|
+
(h) => {
|
|
31
|
+
const x = Math.max(1, Math.min(t, h));
|
|
32
|
+
o(String(x)), r(x);
|
|
33
|
+
},
|
|
34
|
+
[t, r]
|
|
35
|
+
), p = u(
|
|
36
|
+
({ numPages: h }) => (o("1"), h),
|
|
37
|
+
[]
|
|
38
|
+
), R = (h) => {
|
|
39
|
+
o(h.target.value);
|
|
40
|
+
}, m = () => {
|
|
41
|
+
const h = parseInt(a, 10);
|
|
42
|
+
if (isNaN(h)) {
|
|
43
|
+
o(String(e));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
i(h);
|
|
47
|
+
}, f = (h) => {
|
|
48
|
+
h.key === "Enter" && m();
|
|
49
|
+
}, g = b(i);
|
|
50
|
+
S(() => {
|
|
51
|
+
g.current = i;
|
|
52
|
+
}, [i]);
|
|
53
|
+
const N = u((h) => {
|
|
54
|
+
g.current(h.pageNumber);
|
|
55
|
+
}, []);
|
|
56
|
+
return {
|
|
57
|
+
goToPage: i,
|
|
58
|
+
onDocumentLoadSuccess: p,
|
|
59
|
+
pageInputValue: a,
|
|
60
|
+
setPageInputValue: o,
|
|
61
|
+
handlePageInputChange: R,
|
|
62
|
+
handlePageInputSubmit: m,
|
|
63
|
+
handlePageInputKeyDown: f,
|
|
64
|
+
onItemClick: N
|
|
65
|
+
};
|
|
66
|
+
}, O = 1.414;
|
|
67
|
+
function je() {
|
|
68
|
+
const t = b(null), e = b(/* @__PURE__ */ new Map()), r = b(/* @__PURE__ */ new Map()), [a, o] = I(() => /* @__PURE__ */ new Map()), i = u((f) => {
|
|
69
|
+
t.current = f, e.current = /* @__PURE__ */ new Map(), r.current = /* @__PURE__ */ new Map(), o(/* @__PURE__ */ new Map());
|
|
70
|
+
}, []), p = u((f) => {
|
|
71
|
+
const g = t.current;
|
|
72
|
+
if (!g || r.current.has(f))
|
|
73
|
+
return Promise.resolve();
|
|
74
|
+
const N = e.current.get(f);
|
|
75
|
+
if (N)
|
|
76
|
+
return N;
|
|
77
|
+
const h = g.getPage(f).then((x) => {
|
|
78
|
+
const l = x.getViewport({ scale: 1 }), s = new Map(r.current);
|
|
79
|
+
s.set(f, { w: l.width, h: l.height }), r.current = s, o(s);
|
|
80
|
+
}).catch((x) => {
|
|
81
|
+
console.warn(`Failed to fetch dimensions for PDF page ${f}`, x);
|
|
82
|
+
}).finally(() => {
|
|
83
|
+
e.current.delete(f);
|
|
84
|
+
});
|
|
85
|
+
return e.current.set(f, h), h;
|
|
86
|
+
}, []), R = u(
|
|
87
|
+
(f) => {
|
|
88
|
+
p(f);
|
|
89
|
+
},
|
|
90
|
+
[p]
|
|
91
|
+
), m = u(
|
|
92
|
+
async (f) => (await Promise.all(f.map((g) => p(g))), r.current),
|
|
93
|
+
[p]
|
|
94
|
+
);
|
|
95
|
+
return {
|
|
96
|
+
pageDimensions: a,
|
|
97
|
+
requestPageDimension: R,
|
|
98
|
+
ensurePageDimensions: m,
|
|
99
|
+
setPdf: i
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function Ie(t) {
|
|
103
|
+
const [e, r] = I(!0), [a, o] = I(t.isOpen);
|
|
104
|
+
return S(() => {
|
|
105
|
+
let i;
|
|
106
|
+
return t.isOpen ? (r(!1), i = setTimeout(() => o(!0), se)) : (o(!1), i = setTimeout(() => r(!0), ie * 1.1)), () => clearTimeout(i);
|
|
107
|
+
}, [t.isOpen]), e ? null : /* @__PURE__ */ n.jsx(be, { ...t, isOpen: a });
|
|
108
|
+
}
|
|
109
|
+
function be({
|
|
110
|
+
numPages: t,
|
|
111
|
+
currentPage: e,
|
|
112
|
+
goToPage: r,
|
|
113
|
+
isOpen: a,
|
|
114
|
+
pageDimensions: o,
|
|
115
|
+
requestPageDimension: i
|
|
116
|
+
}) {
|
|
117
|
+
const p = b(null), R = b(!1), [m, f] = I(e - 1);
|
|
118
|
+
S(() => {
|
|
119
|
+
if (p.current) {
|
|
120
|
+
if (R.current) {
|
|
121
|
+
R.current = !1;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
p.current.scrollToRow(e - 1);
|
|
125
|
+
}
|
|
126
|
+
}, [e]);
|
|
127
|
+
const g = u(
|
|
128
|
+
(l) => {
|
|
129
|
+
const s = o.get(l + 1);
|
|
130
|
+
return s ? s.h / s.w : O;
|
|
131
|
+
},
|
|
132
|
+
[o]
|
|
133
|
+
), N = u(
|
|
134
|
+
({ index: l }) => {
|
|
135
|
+
const _ = E * g(l) + W + A;
|
|
136
|
+
return l === t - 1 ? _ + A : _;
|
|
137
|
+
},
|
|
138
|
+
[g, t]
|
|
139
|
+
);
|
|
140
|
+
S(() => {
|
|
141
|
+
var l;
|
|
142
|
+
(l = p.current) == null || l.recomputeRowHeights();
|
|
143
|
+
}, [o, t]);
|
|
144
|
+
const h = u(
|
|
145
|
+
({
|
|
146
|
+
overscanStartIndex: l,
|
|
147
|
+
overscanStopIndex: s
|
|
148
|
+
}) => {
|
|
149
|
+
for (let _ = l; _ <= s; _++)
|
|
150
|
+
i(_ + 1);
|
|
151
|
+
m !== void 0 && f(void 0);
|
|
152
|
+
},
|
|
153
|
+
[i, m]
|
|
154
|
+
), x = ({ index: l, key: s, style: _ }) => {
|
|
155
|
+
const P = l + 1, k = g(l), y = /* @__PURE__ */ n.jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: "pdf-preview__thumbnail-skeleton",
|
|
159
|
+
style: { width: E, height: E * k }
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
return /* @__PURE__ */ n.jsx(
|
|
163
|
+
"div",
|
|
164
|
+
{
|
|
165
|
+
style: {
|
|
166
|
+
..._,
|
|
167
|
+
paddingTop: A,
|
|
168
|
+
paddingBottom: l === t - 1 ? A : 0,
|
|
169
|
+
boxSizing: "border-box"
|
|
170
|
+
},
|
|
171
|
+
children: /* @__PURE__ */ n.jsxs(
|
|
172
|
+
"button",
|
|
173
|
+
{
|
|
174
|
+
"data-thumb-page": P,
|
|
175
|
+
className: `pdf-preview__thumbnail${e === P ? " pdf-preview__thumbnail--active" : ""}`,
|
|
176
|
+
onClick: () => {
|
|
177
|
+
R.current = !0, r(P);
|
|
178
|
+
},
|
|
179
|
+
"aria-label": `Go to page ${P}`,
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ n.jsx(
|
|
182
|
+
we,
|
|
183
|
+
{
|
|
184
|
+
pageNumber: P,
|
|
185
|
+
width: E,
|
|
186
|
+
loading: y
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ n.jsx("span", { className: "pdf-preview__thumbnail-number", children: P })
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
},
|
|
194
|
+
s
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
return /* @__PURE__ */ n.jsx(
|
|
198
|
+
"div",
|
|
199
|
+
{
|
|
200
|
+
className: `pdf-preview__sidebar${a ? "" : " pdf-preview__sidebar--closed"}`,
|
|
201
|
+
children: /* @__PURE__ */ n.jsx(J, { children: ({ height: l, width: s }) => /* @__PURE__ */ n.jsx(
|
|
202
|
+
X,
|
|
203
|
+
{
|
|
204
|
+
ref: p,
|
|
205
|
+
height: l,
|
|
206
|
+
width: s,
|
|
207
|
+
rowCount: t,
|
|
208
|
+
rowHeight: N,
|
|
209
|
+
estimatedRowSize: E * O + W + A,
|
|
210
|
+
overscanRowCount: 5,
|
|
211
|
+
rowRenderer: x,
|
|
212
|
+
scrollToIndex: m,
|
|
213
|
+
scrollToAlignment: "center",
|
|
214
|
+
onRowsRendered: h,
|
|
215
|
+
style: { outline: "none" }
|
|
216
|
+
}
|
|
217
|
+
) })
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function Ne({
|
|
222
|
+
numPages: t,
|
|
223
|
+
pageInputValue: e,
|
|
224
|
+
onToggleSidebar: r,
|
|
225
|
+
onPageInputChange: a,
|
|
226
|
+
onPageInputSubmit: o,
|
|
227
|
+
onPageInputKeyDown: i,
|
|
228
|
+
onZoomIn: p,
|
|
229
|
+
onZoomReset: R,
|
|
230
|
+
onZoomOut: m
|
|
231
|
+
}) {
|
|
232
|
+
return /* @__PURE__ */ n.jsxs("div", { className: "file-preview__controls", children: [
|
|
233
|
+
/* @__PURE__ */ n.jsx(
|
|
234
|
+
_e,
|
|
235
|
+
{
|
|
236
|
+
variant: "tertiary",
|
|
237
|
+
color: "neutral",
|
|
238
|
+
onClick: r,
|
|
239
|
+
"aria-label": "Toggle sidebar",
|
|
240
|
+
size: "small",
|
|
241
|
+
icon: /* @__PURE__ */ n.jsx(ce, {})
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
/* @__PURE__ */ n.jsx("div", { className: "file-preview__controls__separator" }),
|
|
245
|
+
/* @__PURE__ */ n.jsx("div", { className: "pdf-preview__page-nav", children: /* @__PURE__ */ n.jsxs("div", { className: "pdf-preview__page-indicator", children: [
|
|
246
|
+
/* @__PURE__ */ n.jsx(
|
|
247
|
+
xe,
|
|
248
|
+
{
|
|
249
|
+
variant: "classic",
|
|
250
|
+
value: e,
|
|
251
|
+
onChange: a,
|
|
252
|
+
onBlur: o,
|
|
253
|
+
onKeyDown: i,
|
|
254
|
+
"aria-label": "Current page",
|
|
255
|
+
size: e.length || 1
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
/* @__PURE__ */ n.jsxs("span", { className: "pdf-preview__page-total", children: [
|
|
259
|
+
"/ ",
|
|
260
|
+
t
|
|
261
|
+
] })
|
|
262
|
+
] }) }),
|
|
263
|
+
/* @__PURE__ */ n.jsx("div", { className: "file-preview__controls__separator" }),
|
|
264
|
+
/* @__PURE__ */ n.jsx(
|
|
265
|
+
ae,
|
|
266
|
+
{
|
|
267
|
+
zoomOut: m,
|
|
268
|
+
zoomIn: p,
|
|
269
|
+
resetView: R
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
] });
|
|
273
|
+
}
|
|
274
|
+
function Te(t, e = 300) {
|
|
275
|
+
let r;
|
|
276
|
+
const a = (...o) => {
|
|
277
|
+
r !== void 0 && clearTimeout(r), r = setTimeout(() => {
|
|
278
|
+
t(...o);
|
|
279
|
+
}, e);
|
|
280
|
+
};
|
|
281
|
+
return a.cancel = () => {
|
|
282
|
+
r !== void 0 && clearTimeout(r);
|
|
283
|
+
}, a;
|
|
284
|
+
}
|
|
285
|
+
const Se = () => {
|
|
286
|
+
const [t, e] = I({
|
|
287
|
+
width: window.innerWidth,
|
|
288
|
+
height: window.innerHeight
|
|
289
|
+
});
|
|
290
|
+
return S(() => {
|
|
291
|
+
const r = Te(() => {
|
|
292
|
+
e({ width: window.innerWidth, height: window.innerHeight });
|
|
293
|
+
}, 100);
|
|
294
|
+
return window.addEventListener("resize", r), () => {
|
|
295
|
+
r.cancel(), window.removeEventListener("resize", r);
|
|
296
|
+
};
|
|
297
|
+
}, []), t;
|
|
298
|
+
}, M = 16, q = 800, Q = 32;
|
|
299
|
+
function ye({
|
|
300
|
+
numPages: t,
|
|
301
|
+
zoom: e,
|
|
302
|
+
onCurrentPageChange: r,
|
|
303
|
+
onClick: a,
|
|
304
|
+
pageDimensions: o,
|
|
305
|
+
requestPageDimension: i,
|
|
306
|
+
ensurePageDimensions: p,
|
|
307
|
+
ref: R
|
|
308
|
+
}) {
|
|
309
|
+
const m = b(null), f = b(e), [g, N] = I(0), h = b(0), x = b(0), l = Se(), s = $(() => q + Q > l.width ? l.width - Q : q, [l.width]), _ = u(
|
|
310
|
+
(c) => {
|
|
311
|
+
const d = o.get(c + 1);
|
|
312
|
+
return d ? d.h / d.w : O;
|
|
313
|
+
},
|
|
314
|
+
[o]
|
|
315
|
+
), P = u(
|
|
316
|
+
(c) => {
|
|
317
|
+
const d = s * _(c) * e, w = M * e;
|
|
318
|
+
return c === t - 1 ? d + 2 * w : d + w;
|
|
319
|
+
},
|
|
320
|
+
[s, _, e, t]
|
|
321
|
+
), k = u(
|
|
322
|
+
({ index: c }) => P(c),
|
|
323
|
+
[P]
|
|
324
|
+
);
|
|
325
|
+
S(() => {
|
|
326
|
+
var c;
|
|
327
|
+
if ((c = m.current) == null || c.recomputeRowHeights(), f.current !== e && m.current) {
|
|
328
|
+
const d = e / f.current, w = Math.round(g * d);
|
|
329
|
+
m.current.scrollToPosition(w), f.current = e;
|
|
330
|
+
}
|
|
331
|
+
}, [e, s, o, t]);
|
|
332
|
+
const y = $(() => {
|
|
333
|
+
if (t === 0) return 1;
|
|
334
|
+
const c = g + h.current / 2;
|
|
335
|
+
let d = 0;
|
|
336
|
+
for (let w = 0; w < t; w++) {
|
|
337
|
+
const j = P(w);
|
|
338
|
+
if (d + j > c)
|
|
339
|
+
return w + 1;
|
|
340
|
+
d += j;
|
|
341
|
+
}
|
|
342
|
+
return t;
|
|
343
|
+
}, [g, t, P]);
|
|
344
|
+
S(() => {
|
|
345
|
+
r(y);
|
|
346
|
+
}, [y]);
|
|
347
|
+
const F = u(
|
|
348
|
+
(c) => {
|
|
349
|
+
x.current += 1;
|
|
350
|
+
const d = x.current, w = [];
|
|
351
|
+
for (let j = 1; j <= c; j++) w.push(j);
|
|
352
|
+
p(w).then((j) => {
|
|
353
|
+
if (x.current !== d || !m.current) return;
|
|
354
|
+
let C = 0;
|
|
355
|
+
for (let L = 0; L < c - 1; L++) {
|
|
356
|
+
const D = j.get(L + 1), K = D ? D.h / D.w : O;
|
|
357
|
+
C += s * K * e + M * e;
|
|
358
|
+
}
|
|
359
|
+
m.current.scrollToPosition(C);
|
|
360
|
+
});
|
|
361
|
+
},
|
|
362
|
+
[p, s, e]
|
|
363
|
+
);
|
|
364
|
+
fe(R, () => ({ scrollToPage: F }), [F]);
|
|
365
|
+
const U = u(
|
|
366
|
+
({
|
|
367
|
+
scrollTop: c,
|
|
368
|
+
clientHeight: d
|
|
369
|
+
}) => {
|
|
370
|
+
h.current = d, N(c);
|
|
371
|
+
},
|
|
372
|
+
[]
|
|
373
|
+
), B = u(
|
|
374
|
+
({
|
|
375
|
+
overscanStartIndex: c,
|
|
376
|
+
overscanStopIndex: d
|
|
377
|
+
}) => {
|
|
378
|
+
for (let w = c; w <= d; w++)
|
|
379
|
+
i(w + 1);
|
|
380
|
+
},
|
|
381
|
+
[i]
|
|
382
|
+
), G = ({ index: c, key: d, style: w }) => {
|
|
383
|
+
const j = _(c), C = /* @__PURE__ */ n.jsx(
|
|
384
|
+
"div",
|
|
385
|
+
{
|
|
386
|
+
className: "pdf-preview__page-skeleton pdf-preview__page-skeleton--measured",
|
|
387
|
+
style: { height: s * j * e, width: s * e }
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
return /* @__PURE__ */ n.jsx(
|
|
391
|
+
"div",
|
|
392
|
+
{
|
|
393
|
+
"data-preview-backdrop": "true",
|
|
394
|
+
className: "pdf-preview__page-container",
|
|
395
|
+
style: {
|
|
396
|
+
...w,
|
|
397
|
+
paddingTop: M * e,
|
|
398
|
+
paddingBottom: c === t - 1 ? M * e : 0
|
|
399
|
+
},
|
|
400
|
+
children: /* @__PURE__ */ n.jsx(
|
|
401
|
+
me,
|
|
402
|
+
{
|
|
403
|
+
pageNumber: c + 1,
|
|
404
|
+
width: s,
|
|
405
|
+
scale: e,
|
|
406
|
+
loading: C
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
},
|
|
410
|
+
d
|
|
411
|
+
);
|
|
412
|
+
};
|
|
413
|
+
return /* @__PURE__ */ n.jsx("div", { className: "pdf-preview__container", onClick: a, children: /* @__PURE__ */ n.jsx(J, { children: ({ height: c, width: d }) => {
|
|
414
|
+
const w = Math.max(d, s * e);
|
|
415
|
+
return /* @__PURE__ */ n.jsx(
|
|
416
|
+
"div",
|
|
417
|
+
{
|
|
418
|
+
style: {
|
|
419
|
+
width: d,
|
|
420
|
+
height: c
|
|
421
|
+
},
|
|
422
|
+
className: "pdf-preview__horizontal-scroll",
|
|
423
|
+
children: /* @__PURE__ */ n.jsx(
|
|
424
|
+
X,
|
|
425
|
+
{
|
|
426
|
+
ref: m,
|
|
427
|
+
height: c,
|
|
428
|
+
width: w,
|
|
429
|
+
rowCount: t,
|
|
430
|
+
rowHeight: k,
|
|
431
|
+
estimatedRowSize: s * O * e + M * e,
|
|
432
|
+
overscanRowCount: 3,
|
|
433
|
+
onScroll: U,
|
|
434
|
+
onRowsRendered: B,
|
|
435
|
+
rowRenderer: G,
|
|
436
|
+
style: { outline: "none" }
|
|
437
|
+
}
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
} }) });
|
|
442
|
+
}
|
|
443
|
+
const Ce = ["https:", "http:"], ke = () => {
|
|
444
|
+
const t = Pe(), { t: e } = Y();
|
|
445
|
+
return { handlePdfClick: u(
|
|
446
|
+
(a) => {
|
|
447
|
+
const i = a.target.closest("a");
|
|
448
|
+
if (i && i.href) {
|
|
449
|
+
if (i.closest("[data-internal-link]")) return;
|
|
450
|
+
a.preventDefault(), a.stopPropagation();
|
|
451
|
+
try {
|
|
452
|
+
const p = new URL(i.href);
|
|
453
|
+
if (!Ce.includes(p.protocol)) return;
|
|
454
|
+
} catch {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
t.confirmationModal({
|
|
458
|
+
title: e("components.filePreview.externalLink.title"),
|
|
459
|
+
children: /* @__PURE__ */ n.jsxs("div", { children: [
|
|
460
|
+
/* @__PURE__ */ n.jsx("p", { children: e("components.filePreview.externalLink.description") }),
|
|
461
|
+
/* @__PURE__ */ n.jsx("span", { className: "pdf-preview__external-link", children: i.href }),
|
|
462
|
+
/* @__PURE__ */ n.jsx("p", { children: e("components.filePreview.externalLink.confirmQuestion") })
|
|
463
|
+
] }),
|
|
464
|
+
onDecide: (p) => {
|
|
465
|
+
p === "yes" && window.open(i.href, "_blank", "noopener,noreferrer");
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
[t, e]
|
|
471
|
+
) };
|
|
472
|
+
}, Le = {
|
|
473
|
+
cMapUrl: "/cmaps/",
|
|
474
|
+
standardFontDataUrl: "/standard_fonts/",
|
|
475
|
+
wasmUrl: "/wasm/",
|
|
476
|
+
isEvalSupported: !1
|
|
477
|
+
};
|
|
478
|
+
function Ge({
|
|
479
|
+
src: t,
|
|
480
|
+
onThumbailSidebarOpen: e,
|
|
481
|
+
pdfWorkerSrc: r = le
|
|
482
|
+
}) {
|
|
483
|
+
ge.GlobalWorkerOptions.workerSrc = r;
|
|
484
|
+
const { t: a } = Y(), [o, i] = I(1), [p, R] = I(null), [m, f] = I(1), [g, N] = I(!1), h = b(null), { handlePdfClick: x } = ke(), [l, s] = I(1), { pageDimensions: _, requestPageDimension: P, ensurePageDimensions: k, setPdf: y } = je(), F = u(() => {
|
|
485
|
+
s((v) => Math.min(3, v + 0.25));
|
|
486
|
+
}, []), U = u(() => {
|
|
487
|
+
s((v) => Math.max(0.5, v - 0.25));
|
|
488
|
+
}, []), B = u(() => {
|
|
489
|
+
s(1);
|
|
490
|
+
}, []), G = u(() => {
|
|
491
|
+
N((v) => (e == null || e(!v), !v));
|
|
492
|
+
}, []), c = u((v) => {
|
|
493
|
+
var T;
|
|
494
|
+
(T = h.current) == null || T.scrollToPage(v);
|
|
495
|
+
}, []), {
|
|
496
|
+
goToPage: d,
|
|
497
|
+
onDocumentLoadSuccess: w,
|
|
498
|
+
pageInputValue: j,
|
|
499
|
+
setPageInputValue: C,
|
|
500
|
+
handlePageInputChange: L,
|
|
501
|
+
handlePageInputSubmit: D,
|
|
502
|
+
handlePageInputKeyDown: K,
|
|
503
|
+
onItemClick: ee
|
|
504
|
+
} = Re({ numPages: o, currentPage: m, scrollToPage: c });
|
|
505
|
+
S(() => {
|
|
506
|
+
C(String(m));
|
|
507
|
+
}, [m, C]);
|
|
508
|
+
const { data: Z, error: H } = he({
|
|
509
|
+
queryKey: ["pdf", t],
|
|
510
|
+
queryFn: async ({ signal: v }) => {
|
|
511
|
+
const T = await fetch(t, {
|
|
512
|
+
credentials: "include",
|
|
513
|
+
signal: v
|
|
514
|
+
});
|
|
515
|
+
if (!T.ok)
|
|
516
|
+
throw new Error(`Failed to fetch PDF: ${T.status}`);
|
|
517
|
+
const re = await T.blob(), oe = t.split("/").pop() || "document.pdf";
|
|
518
|
+
return new File([re], oe, { type: "application/pdf" });
|
|
519
|
+
},
|
|
520
|
+
staleTime: 1 / 0
|
|
521
|
+
}), te = u(
|
|
522
|
+
(v) => {
|
|
523
|
+
const T = w(v);
|
|
524
|
+
i(T), y(v);
|
|
525
|
+
},
|
|
526
|
+
[w, y]
|
|
527
|
+
), ne = u((v) => {
|
|
528
|
+
const T = [
|
|
529
|
+
"InvalidPDFException",
|
|
530
|
+
"FormatError",
|
|
531
|
+
"PasswordException",
|
|
532
|
+
"ResponseException"
|
|
533
|
+
];
|
|
534
|
+
console.log(v), R(T.includes(v.name) ? "generic" : "outdated");
|
|
535
|
+
}, []);
|
|
536
|
+
if (console.log(H), H != null && H.message || p === "generic")
|
|
537
|
+
return /* @__PURE__ */ n.jsxs("div", { className: "file-preview-unsupported", "data-preview-backdrop": "true", children: [
|
|
538
|
+
/* @__PURE__ */ n.jsx("div", { className: "file-preview-unsupported__icon", children: /* @__PURE__ */ n.jsx(de, { name: "error", type: ue.OUTLINED, size: 48 }) }),
|
|
539
|
+
/* @__PURE__ */ n.jsx("p", { className: "file-preview-unsupported__title", children: a("components.filePreview.error.title") }),
|
|
540
|
+
/* @__PURE__ */ n.jsx("p", { className: "file-preview-unsupported__description", children: a("components.filePreview.error.description") })
|
|
541
|
+
] });
|
|
542
|
+
if (p === "outdated")
|
|
543
|
+
return /* @__PURE__ */ n.jsx(pe, {});
|
|
544
|
+
const V = /* @__PURE__ */ n.jsx("div", { className: "pdf-preview__container-skeleton", children: /* @__PURE__ */ n.jsx("div", { className: "pdf-preview__page-skeleton" }) });
|
|
545
|
+
return /* @__PURE__ */ n.jsxs("div", { className: "pdf-preview", children: [
|
|
546
|
+
/* @__PURE__ */ n.jsx("div", { className: "pdf-preview__body", "data-preview-backdrop": "true", children: Z ? /* @__PURE__ */ n.jsxs(
|
|
547
|
+
ve,
|
|
548
|
+
{
|
|
549
|
+
file: Z,
|
|
550
|
+
onLoadSuccess: te,
|
|
551
|
+
onItemClick: ee,
|
|
552
|
+
options: Le,
|
|
553
|
+
loading: V,
|
|
554
|
+
onLoadError: ne,
|
|
555
|
+
children: [
|
|
556
|
+
/* @__PURE__ */ n.jsx(
|
|
557
|
+
Ie,
|
|
558
|
+
{
|
|
559
|
+
numPages: o,
|
|
560
|
+
currentPage: m,
|
|
561
|
+
goToPage: d,
|
|
562
|
+
isOpen: g,
|
|
563
|
+
pageDimensions: _,
|
|
564
|
+
requestPageDimension: P
|
|
565
|
+
}
|
|
566
|
+
),
|
|
567
|
+
/* @__PURE__ */ n.jsx(
|
|
568
|
+
ye,
|
|
569
|
+
{
|
|
570
|
+
ref: h,
|
|
571
|
+
numPages: o,
|
|
572
|
+
zoom: l,
|
|
573
|
+
onCurrentPageChange: f,
|
|
574
|
+
onClick: x,
|
|
575
|
+
pageDimensions: _,
|
|
576
|
+
requestPageDimension: P,
|
|
577
|
+
ensurePageDimensions: k
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
) : V }),
|
|
583
|
+
/* @__PURE__ */ n.jsx(
|
|
584
|
+
Ne,
|
|
585
|
+
{
|
|
586
|
+
numPages: o,
|
|
587
|
+
pageInputValue: j,
|
|
588
|
+
onToggleSidebar: G,
|
|
589
|
+
onPageInputChange: L,
|
|
590
|
+
onPageInputSubmit: D,
|
|
591
|
+
onPageInputKeyDown: K,
|
|
592
|
+
onZoomIn: F,
|
|
593
|
+
onZoomReset: B,
|
|
594
|
+
onZoomOut: U
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
] });
|
|
598
|
+
}
|
|
599
|
+
export {
|
|
600
|
+
Ge as PdfPreview,
|
|
601
|
+
Ge as default
|
|
602
|
+
};
|
|
603
|
+
//# sourceMappingURL=PdfPreview-BOIgXF66.js.map
|