@nice2dev/ui-forms 1.1.6 → 1.1.7
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/NiceDocumentViewer-8ghRVtfO-Cz6L9k3M.js +674 -0
- package/dist/NiceDocumentViewer-8ghRVtfO-DZtJyNGD.cjs +180 -0
- package/dist/NiceDocumentViewer-DwLUV7Tc-BysllG28.cjs +180 -0
- package/dist/NiceDocumentViewer-DwLUV7Tc-xda8GbQr.js +674 -0
- package/dist/NiceDocumentViewer-gt1mxzP8-Bdqrwhm4.js +674 -0
- package/dist/NiceDocumentViewer-gt1mxzP8-DU8ygbNM.cjs +180 -0
- package/dist/index-B8LQvpDi.cjs +6675 -0
- package/dist/index-CaXW3Fx9.js +96603 -0
- package/dist/index-D94jDKUG.js +96640 -0
- package/dist/index-DIKjjZIH.cjs +6675 -0
- package/dist/index-DaptCzDp.js +96887 -0
- package/dist/index-DmmYQaJo.cjs +6675 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +25 -15
- package/dist/index.mjs +1 -1
- package/dist/ui-forms.css +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { A as g } from "./index-DaptCzDp.js";
|
|
3
|
+
import { forwardRef as be, useRef as V, useState as f, useMemo as _e, useCallback as l, useEffect as q, useImperativeHandle as xe } from "react";
|
|
4
|
+
function ye(r, o) {
|
|
5
|
+
var a;
|
|
6
|
+
const n = ((a = r.split(".").pop()) == null ? void 0 : a.toLowerCase().split("?")[0]) ?? "";
|
|
7
|
+
return n === "pdf" ? "pdf" : ["jpg", "jpeg", "png", "gif", "bmp", "webp", "svg", "ico", "tiff", "tif"].includes(n) ? "image" : ["mp4", "webm", "ogg", "mov", "avi", "mkv"].includes(n) ? "video" : ["mp3", "wav", "flac", "aac", "m4a", "ogg"].includes(n) ? "audio" : ["doc", "docx", "xls", "xlsx", "ppt", "pptx", "odt", "ods", "odp"].includes(n) ? "office" : n === "html" || n === "htm" ? "html" : ["txt", "log", "md", "json", "xml", "csv", "yaml", "yml"].includes(n) ? "text" : "unknown";
|
|
8
|
+
}
|
|
9
|
+
function ke(r) {
|
|
10
|
+
if (r === 0)
|
|
11
|
+
return "0 B";
|
|
12
|
+
const o = 1024, n = ["B", "KB", "MB", "GB"], a = Math.floor(Math.log(r) / Math.log(o));
|
|
13
|
+
return parseFloat((r / Math.pow(o, a)).toFixed(1)) + " " + n[a];
|
|
14
|
+
}
|
|
15
|
+
function Ce(r) {
|
|
16
|
+
const o = Math.floor(r / 3600), n = Math.floor(r % 3600 / 60), a = Math.floor(r % 60);
|
|
17
|
+
return o > 0 ? `${o}:${n.toString().padStart(2, "0")}:${a.toString().padStart(2, "0")}` : `${n}:${a.toString().padStart(2, "0")}`;
|
|
18
|
+
}
|
|
19
|
+
function Ne({
|
|
20
|
+
src: r,
|
|
21
|
+
page: o,
|
|
22
|
+
zoom: n,
|
|
23
|
+
rotation: a,
|
|
24
|
+
onPageChange: u,
|
|
25
|
+
onLoad: d,
|
|
26
|
+
onError: h,
|
|
27
|
+
workerUrl: p
|
|
28
|
+
}) {
|
|
29
|
+
const v = V(null), z = V(null), [_, J] = f(0), [U, B] = f(!1);
|
|
30
|
+
return q(() => {
|
|
31
|
+
let x = !1;
|
|
32
|
+
return (async () => {
|
|
33
|
+
try {
|
|
34
|
+
let s;
|
|
35
|
+
if (s = window.pdfjsLib, !s)
|
|
36
|
+
try {
|
|
37
|
+
s = await new Function("m", "return import(m)")("pdfjs-dist");
|
|
38
|
+
} catch {
|
|
39
|
+
throw new Error(
|
|
40
|
+
'PDF.js library not found. Please install pdfjs-dist or include it via CDN: <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"><\/script>'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
p ? s.GlobalWorkerOptions.workerSrc = p : s.version && (s.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${s.version}/pdf.worker.min.js`);
|
|
44
|
+
const b = await s.getDocument(r).promise;
|
|
45
|
+
if (x)
|
|
46
|
+
return;
|
|
47
|
+
z.current = b, J(b.numPages), d({
|
|
48
|
+
name: r.split("/").pop() ?? "document.pdf",
|
|
49
|
+
type: "pdf",
|
|
50
|
+
mimeType: "application/pdf",
|
|
51
|
+
pageCount: b.numPages
|
|
52
|
+
});
|
|
53
|
+
} catch (s) {
|
|
54
|
+
x || h(s instanceof Error ? s : new Error("Failed to load PDF"));
|
|
55
|
+
}
|
|
56
|
+
})(), () => {
|
|
57
|
+
x = !0;
|
|
58
|
+
};
|
|
59
|
+
}, [r, p, d, h]), q(() => {
|
|
60
|
+
const x = z.current, s = v.current;
|
|
61
|
+
if (!x || !s || _ === 0)
|
|
62
|
+
return;
|
|
63
|
+
let b = !1;
|
|
64
|
+
return (async () => {
|
|
65
|
+
if (!U) {
|
|
66
|
+
B(!0);
|
|
67
|
+
try {
|
|
68
|
+
const P = Math.max(1, Math.min(o, _)), M = await x.getPage(P);
|
|
69
|
+
if (b)
|
|
70
|
+
return;
|
|
71
|
+
const y = M.getViewport({ scale: n, rotation: a }), E = s.getContext("2d");
|
|
72
|
+
if (!E)
|
|
73
|
+
return;
|
|
74
|
+
s.height = y.height, s.width = y.width, await M.render({
|
|
75
|
+
canvasContext: E,
|
|
76
|
+
viewport: y
|
|
77
|
+
}).promise;
|
|
78
|
+
} catch (P) {
|
|
79
|
+
console.error("Error rendering PDF page:", P);
|
|
80
|
+
} finally {
|
|
81
|
+
b || B(!1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})(), () => {
|
|
85
|
+
b = !0;
|
|
86
|
+
};
|
|
87
|
+
}, [o, n, a, _, U]), /* @__PURE__ */ e("div", { className: "nice-document-viewer__pdf", children: /* @__PURE__ */ e("canvas", { ref: v, className: "nice-document-viewer__pdf-canvas" }) });
|
|
88
|
+
}
|
|
89
|
+
function ze({
|
|
90
|
+
src: r,
|
|
91
|
+
zoom: o,
|
|
92
|
+
rotation: n,
|
|
93
|
+
onLoad: a,
|
|
94
|
+
onError: u
|
|
95
|
+
}) {
|
|
96
|
+
const [d, h] = f(!1), p = l(
|
|
97
|
+
(z) => {
|
|
98
|
+
const _ = z.currentTarget;
|
|
99
|
+
h(!0), a({
|
|
100
|
+
name: r.split("/").pop() ?? "image",
|
|
101
|
+
type: "image",
|
|
102
|
+
width: _.naturalWidth,
|
|
103
|
+
height: _.naturalHeight
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
[r, a]
|
|
107
|
+
), v = l(() => {
|
|
108
|
+
u(new Error("Failed to load image"));
|
|
109
|
+
}, [u]);
|
|
110
|
+
return /* @__PURE__ */ e("div", { className: "nice-document-viewer__image", children: /* @__PURE__ */ e(
|
|
111
|
+
"img",
|
|
112
|
+
{
|
|
113
|
+
src: r,
|
|
114
|
+
alt: "Document",
|
|
115
|
+
onLoad: p,
|
|
116
|
+
onError: v,
|
|
117
|
+
style: {
|
|
118
|
+
transform: `scale(${o}) rotate(${n}deg)`,
|
|
119
|
+
opacity: d ? 1 : 0
|
|
120
|
+
},
|
|
121
|
+
draggable: !1
|
|
122
|
+
}
|
|
123
|
+
) });
|
|
124
|
+
}
|
|
125
|
+
function Ee({ src: r, type: o, onLoad: n, onError: a }) {
|
|
126
|
+
const u = V(null), d = l(() => {
|
|
127
|
+
const p = u.current;
|
|
128
|
+
if (!p)
|
|
129
|
+
return;
|
|
130
|
+
const v = {
|
|
131
|
+
name: r.split("/").pop() ?? (o === "video" ? "video" : "audio"),
|
|
132
|
+
type: o,
|
|
133
|
+
duration: p.duration
|
|
134
|
+
};
|
|
135
|
+
o === "video" && "videoWidth" in p && (v.width = p.videoWidth, v.height = p.videoHeight), n(v);
|
|
136
|
+
}, [r, o, n]), h = l(() => {
|
|
137
|
+
a(new Error(`Failed to load ${o}`));
|
|
138
|
+
}, [o, a]);
|
|
139
|
+
return o === "video" ? /* @__PURE__ */ e("div", { className: "nice-document-viewer__video", children: /* @__PURE__ */ e(
|
|
140
|
+
"video",
|
|
141
|
+
{
|
|
142
|
+
ref: u,
|
|
143
|
+
src: r,
|
|
144
|
+
controls: !0,
|
|
145
|
+
onLoadedMetadata: d,
|
|
146
|
+
onError: h
|
|
147
|
+
}
|
|
148
|
+
) }) : /* @__PURE__ */ e("div", { className: "nice-document-viewer__audio", children: /* @__PURE__ */ e(
|
|
149
|
+
"audio",
|
|
150
|
+
{
|
|
151
|
+
ref: u,
|
|
152
|
+
src: r,
|
|
153
|
+
controls: !0,
|
|
154
|
+
onLoadedMetadata: d,
|
|
155
|
+
onError: h
|
|
156
|
+
}
|
|
157
|
+
) });
|
|
158
|
+
}
|
|
159
|
+
function Le({ src: r, viewerUrl: o, onLoad: n }) {
|
|
160
|
+
const [a, u] = f(!1), d = `${o ?? "https://view.officeapps.live.com/op/embed.aspx?src="}${encodeURIComponent(r)}`, h = l(() => {
|
|
161
|
+
u(!0), n({
|
|
162
|
+
name: r.split("/").pop() ?? "document",
|
|
163
|
+
type: "office"
|
|
164
|
+
});
|
|
165
|
+
}, [r, n]);
|
|
166
|
+
return /* @__PURE__ */ e("div", { className: "nice-document-viewer__office", children: /* @__PURE__ */ e(
|
|
167
|
+
"iframe",
|
|
168
|
+
{
|
|
169
|
+
src: d,
|
|
170
|
+
onLoad: h,
|
|
171
|
+
title: "Office Document",
|
|
172
|
+
style: { opacity: a ? 1 : 0 }
|
|
173
|
+
}
|
|
174
|
+
) });
|
|
175
|
+
}
|
|
176
|
+
function je({ src: r, onLoad: o, onError: n }) {
|
|
177
|
+
const [a, u] = f(null);
|
|
178
|
+
return q(() => {
|
|
179
|
+
fetch(r).then((d) => {
|
|
180
|
+
if (!d.ok)
|
|
181
|
+
throw new Error("Failed to fetch text");
|
|
182
|
+
return d.text();
|
|
183
|
+
}).then((d) => {
|
|
184
|
+
u(d), o({
|
|
185
|
+
name: r.split("/").pop() ?? "text",
|
|
186
|
+
type: "text",
|
|
187
|
+
size: d.length
|
|
188
|
+
});
|
|
189
|
+
}).catch((d) => {
|
|
190
|
+
n(d instanceof Error ? d : new Error("Failed to load text"));
|
|
191
|
+
});
|
|
192
|
+
}, [r, o, n]), a === null ? /* @__PURE__ */ e("div", { className: "nice-document-viewer__loading", children: "Loading..." }) : /* @__PURE__ */ e("div", { className: "nice-document-viewer__text", children: /* @__PURE__ */ e("pre", { children: a }) });
|
|
193
|
+
}
|
|
194
|
+
function Pe({ src: r, onLoad: o }) {
|
|
195
|
+
const n = l(() => {
|
|
196
|
+
o({
|
|
197
|
+
name: r.split("/").pop() ?? "page.html",
|
|
198
|
+
type: "html"
|
|
199
|
+
});
|
|
200
|
+
}, [r, o]);
|
|
201
|
+
return /* @__PURE__ */ e("div", { className: "nice-document-viewer__html", children: /* @__PURE__ */ e(
|
|
202
|
+
"iframe",
|
|
203
|
+
{
|
|
204
|
+
src: r,
|
|
205
|
+
onLoad: n,
|
|
206
|
+
title: "HTML Document",
|
|
207
|
+
sandbox: "allow-same-origin allow-scripts"
|
|
208
|
+
}
|
|
209
|
+
) });
|
|
210
|
+
}
|
|
211
|
+
const $e = be(
|
|
212
|
+
function(r, o) {
|
|
213
|
+
const {
|
|
214
|
+
src: n,
|
|
215
|
+
type: a,
|
|
216
|
+
name: u,
|
|
217
|
+
height: d = 600,
|
|
218
|
+
width: h = "100%",
|
|
219
|
+
zoom: p = 1,
|
|
220
|
+
minZoom: v = 0.25,
|
|
221
|
+
maxZoom: z = 4,
|
|
222
|
+
page: _ = 1,
|
|
223
|
+
showToolbar: J = !0,
|
|
224
|
+
showPageNav: U = !0,
|
|
225
|
+
showZoomControls: B = !0,
|
|
226
|
+
showFullscreen: x = !0,
|
|
227
|
+
showDownload: s = !0,
|
|
228
|
+
showPrint: b = !0,
|
|
229
|
+
showRotate: P = !0,
|
|
230
|
+
enableKeyboard: M = !0,
|
|
231
|
+
onLoad: y,
|
|
232
|
+
onError: E,
|
|
233
|
+
onPageChange: I,
|
|
234
|
+
onZoomChange: W,
|
|
235
|
+
pdfWorkerUrl: oe,
|
|
236
|
+
officeViewerUrl: ie,
|
|
237
|
+
loading: ae,
|
|
238
|
+
errorContent: Y,
|
|
239
|
+
className: ce,
|
|
240
|
+
"data-testid": de
|
|
241
|
+
} = r, Q = V(null), [t, le] = f(null), [k, se] = f(_), [L, ue] = f(p), [ee, me] = f(0), [H, ne] = f(!1), [T, pe] = f(null), [fe, te] = f(!0), C = _e(() => a ?? ye(n), [n, a]), j = l(
|
|
242
|
+
(i) => {
|
|
243
|
+
le(i), te(!1), y == null || y(i);
|
|
244
|
+
},
|
|
245
|
+
[y]
|
|
246
|
+
), A = l(
|
|
247
|
+
(i) => {
|
|
248
|
+
pe(i), te(!1), E == null || E(i);
|
|
249
|
+
},
|
|
250
|
+
[E]
|
|
251
|
+
), w = l(
|
|
252
|
+
(i) => {
|
|
253
|
+
const c = (t == null ? void 0 : t.pageCount) ?? 1, Z = Math.max(1, Math.min(i, c));
|
|
254
|
+
se(Z), I == null || I(Z);
|
|
255
|
+
},
|
|
256
|
+
[t == null ? void 0 : t.pageCount, I]
|
|
257
|
+
), D = l(() => w(k + 1), [k, w]), F = l(() => w(k - 1), [k, w]), N = l(
|
|
258
|
+
(i) => {
|
|
259
|
+
const c = Math.max(v, Math.min(i, z));
|
|
260
|
+
ue(c), W == null || W(c);
|
|
261
|
+
},
|
|
262
|
+
[v, z, W]
|
|
263
|
+
), $ = l(() => N(L * 1.25), [L, N]), K = l(() => N(L / 1.25), [L, N]), R = l(() => N(1), [N]), G = l((i) => {
|
|
264
|
+
me((c) => (c + i) % 360);
|
|
265
|
+
}, []), O = l(() => {
|
|
266
|
+
const i = document.createElement("a");
|
|
267
|
+
i.href = n, i.download = u ?? (t == null ? void 0 : t.name) ?? "document", document.body.appendChild(i), i.click(), document.body.removeChild(i);
|
|
268
|
+
}, [n, u, t == null ? void 0 : t.name]), X = l(() => {
|
|
269
|
+
const i = window.open(n, "_blank");
|
|
270
|
+
i && (i.onload = () => i.print());
|
|
271
|
+
}, [n]), S = l(() => {
|
|
272
|
+
var i, c, Z;
|
|
273
|
+
Q.current && (H ? ((i = document.exitFullscreen) == null || i.call(document), ne(!1)) : ((Z = (c = Q.current).requestFullscreen) == null || Z.call(c), ne(!0)));
|
|
274
|
+
}, [H]);
|
|
275
|
+
q(() => {
|
|
276
|
+
if (!M)
|
|
277
|
+
return;
|
|
278
|
+
const i = (c) => {
|
|
279
|
+
switch (c.key) {
|
|
280
|
+
case "ArrowRight":
|
|
281
|
+
case "PageDown":
|
|
282
|
+
D();
|
|
283
|
+
break;
|
|
284
|
+
case "ArrowLeft":
|
|
285
|
+
case "PageUp":
|
|
286
|
+
F();
|
|
287
|
+
break;
|
|
288
|
+
case "Home":
|
|
289
|
+
w(1);
|
|
290
|
+
break;
|
|
291
|
+
case "End":
|
|
292
|
+
w((t == null ? void 0 : t.pageCount) ?? 1);
|
|
293
|
+
break;
|
|
294
|
+
case "+":
|
|
295
|
+
case "=":
|
|
296
|
+
(c.ctrlKey || c.metaKey) && (c.preventDefault(), $());
|
|
297
|
+
break;
|
|
298
|
+
case "-":
|
|
299
|
+
(c.ctrlKey || c.metaKey) && (c.preventDefault(), K());
|
|
300
|
+
break;
|
|
301
|
+
case "0":
|
|
302
|
+
(c.ctrlKey || c.metaKey) && (c.preventDefault(), R());
|
|
303
|
+
break;
|
|
304
|
+
case "f":
|
|
305
|
+
(c.ctrlKey || c.metaKey) && (c.preventDefault(), S());
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
|
|
310
|
+
}, [
|
|
311
|
+
M,
|
|
312
|
+
D,
|
|
313
|
+
F,
|
|
314
|
+
w,
|
|
315
|
+
t == null ? void 0 : t.pageCount,
|
|
316
|
+
$,
|
|
317
|
+
K,
|
|
318
|
+
R,
|
|
319
|
+
S
|
|
320
|
+
]), xe(
|
|
321
|
+
o,
|
|
322
|
+
() => ({
|
|
323
|
+
goToPage: w,
|
|
324
|
+
nextPage: D,
|
|
325
|
+
prevPage: F,
|
|
326
|
+
setZoom: N,
|
|
327
|
+
zoomIn: $,
|
|
328
|
+
zoomOut: K,
|
|
329
|
+
resetZoom: R,
|
|
330
|
+
rotate: G,
|
|
331
|
+
download: O,
|
|
332
|
+
print: X,
|
|
333
|
+
toggleFullscreen: S,
|
|
334
|
+
getInfo: () => t
|
|
335
|
+
}),
|
|
336
|
+
[
|
|
337
|
+
w,
|
|
338
|
+
D,
|
|
339
|
+
F,
|
|
340
|
+
N,
|
|
341
|
+
$,
|
|
342
|
+
K,
|
|
343
|
+
R,
|
|
344
|
+
G,
|
|
345
|
+
O,
|
|
346
|
+
X,
|
|
347
|
+
S,
|
|
348
|
+
t
|
|
349
|
+
]
|
|
350
|
+
);
|
|
351
|
+
const he = () => {
|
|
352
|
+
if (T)
|
|
353
|
+
return (typeof Y == "function" ? Y(T) : Y) ?? /* @__PURE__ */ e("div", { className: "nice-document-viewer__error", children: /* @__PURE__ */ m("span", { children: [
|
|
354
|
+
/* @__PURE__ */ e(g, { name: "warning", size: 14 }),
|
|
355
|
+
" ",
|
|
356
|
+
T.message
|
|
357
|
+
] }) });
|
|
358
|
+
switch (C) {
|
|
359
|
+
case "pdf":
|
|
360
|
+
return /* @__PURE__ */ e(
|
|
361
|
+
Ne,
|
|
362
|
+
{
|
|
363
|
+
src: n,
|
|
364
|
+
page: k,
|
|
365
|
+
zoom: L,
|
|
366
|
+
rotation: ee,
|
|
367
|
+
onPageChange: w,
|
|
368
|
+
onLoad: j,
|
|
369
|
+
onError: A,
|
|
370
|
+
workerUrl: oe
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
case "image":
|
|
374
|
+
return /* @__PURE__ */ e(
|
|
375
|
+
ze,
|
|
376
|
+
{
|
|
377
|
+
src: n,
|
|
378
|
+
zoom: L,
|
|
379
|
+
rotation: ee,
|
|
380
|
+
onLoad: j,
|
|
381
|
+
onError: A
|
|
382
|
+
}
|
|
383
|
+
);
|
|
384
|
+
case "video":
|
|
385
|
+
case "audio":
|
|
386
|
+
return /* @__PURE__ */ e(Ee, { src: n, type: C, onLoad: j, onError: A });
|
|
387
|
+
case "office":
|
|
388
|
+
return /* @__PURE__ */ e(Le, { src: n, viewerUrl: ie, onLoad: j });
|
|
389
|
+
case "text":
|
|
390
|
+
return /* @__PURE__ */ e(je, { src: n, onLoad: j, onError: A });
|
|
391
|
+
case "html":
|
|
392
|
+
return /* @__PURE__ */ e(Pe, { src: n, onLoad: j });
|
|
393
|
+
default:
|
|
394
|
+
return /* @__PURE__ */ m("div", { className: "nice-document-viewer__unknown", children: [
|
|
395
|
+
/* @__PURE__ */ m("span", { children: [
|
|
396
|
+
/* @__PURE__ */ e(g, { name: "file", size: 14 }),
|
|
397
|
+
" Unknown document type"
|
|
398
|
+
] }),
|
|
399
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: O, children: "Download" })
|
|
400
|
+
] });
|
|
401
|
+
}
|
|
402
|
+
}, ve = U && C === "pdf" && ((t == null ? void 0 : t.pageCount) ?? 0) > 1, we = B && (C === "pdf" || C === "image"), ge = P && (C === "pdf" || C === "image");
|
|
403
|
+
return /* @__PURE__ */ m(
|
|
404
|
+
"div",
|
|
405
|
+
{
|
|
406
|
+
ref: Q,
|
|
407
|
+
className: `nice-document-viewer ${H ? "nice-document-viewer--fullscreen" : ""} ${ce ?? ""}`,
|
|
408
|
+
style: { height: d, width: h },
|
|
409
|
+
"data-testid": de,
|
|
410
|
+
"data-type": C,
|
|
411
|
+
children: [
|
|
412
|
+
J && /* @__PURE__ */ m("div", { className: "nice-document-viewer__toolbar", children: [
|
|
413
|
+
/* @__PURE__ */ e("div", { className: "nice-document-viewer__toolbar-left", children: ve && /* @__PURE__ */ m("div", { className: "nice-document-viewer__pagination", children: [
|
|
414
|
+
/* @__PURE__ */ e(
|
|
415
|
+
"button",
|
|
416
|
+
{
|
|
417
|
+
type: "button",
|
|
418
|
+
onClick: F,
|
|
419
|
+
disabled: k <= 1,
|
|
420
|
+
"aria-label": "Previous page",
|
|
421
|
+
children: /* @__PURE__ */ e(g, { name: "chevron-left", size: 16 })
|
|
422
|
+
}
|
|
423
|
+
),
|
|
424
|
+
/* @__PURE__ */ m("span", { children: [
|
|
425
|
+
/* @__PURE__ */ e(
|
|
426
|
+
"input",
|
|
427
|
+
{
|
|
428
|
+
type: "number",
|
|
429
|
+
value: k,
|
|
430
|
+
onChange: (i) => w(parseInt(i.target.value, 10)),
|
|
431
|
+
min: 1,
|
|
432
|
+
max: (t == null ? void 0 : t.pageCount) ?? 1
|
|
433
|
+
}
|
|
434
|
+
),
|
|
435
|
+
"/ ",
|
|
436
|
+
(t == null ? void 0 : t.pageCount) ?? 1
|
|
437
|
+
] }),
|
|
438
|
+
/* @__PURE__ */ e(
|
|
439
|
+
"button",
|
|
440
|
+
{
|
|
441
|
+
type: "button",
|
|
442
|
+
onClick: D,
|
|
443
|
+
disabled: k >= ((t == null ? void 0 : t.pageCount) ?? 1),
|
|
444
|
+
"aria-label": "Next page",
|
|
445
|
+
children: /* @__PURE__ */ e(g, { name: "chevron-right", size: 16 })
|
|
446
|
+
}
|
|
447
|
+
)
|
|
448
|
+
] }) }),
|
|
449
|
+
/* @__PURE__ */ m("div", { className: "nice-document-viewer__toolbar-center", children: [
|
|
450
|
+
we && /* @__PURE__ */ m("div", { className: "nice-document-viewer__zoom", children: [
|
|
451
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: K, "aria-label": "Zoom out", children: "−" }),
|
|
452
|
+
/* @__PURE__ */ m("span", { children: [
|
|
453
|
+
Math.round(L * 100),
|
|
454
|
+
"%"
|
|
455
|
+
] }),
|
|
456
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: $, "aria-label": "Zoom in", children: "+" }),
|
|
457
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: R, "aria-label": "Reset zoom", children: /* @__PURE__ */ e(g, { name: "refresh", size: 16 }) })
|
|
458
|
+
] }),
|
|
459
|
+
ge && /* @__PURE__ */ m("div", { className: "nice-document-viewer__rotation", children: [
|
|
460
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: () => G(270), "aria-label": "Rotate left", children: /* @__PURE__ */ e(g, { name: "refresh", size: 16 }) }),
|
|
461
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: () => G(90), "aria-label": "Rotate right", children: /* @__PURE__ */ e(g, { name: "refresh", size: 16 }) })
|
|
462
|
+
] })
|
|
463
|
+
] }),
|
|
464
|
+
/* @__PURE__ */ m("div", { className: "nice-document-viewer__toolbar-right", children: [
|
|
465
|
+
s && /* @__PURE__ */ e("button", { type: "button", onClick: O, "aria-label": "Download", children: /* @__PURE__ */ e(g, { name: "download", size: 16 }) }),
|
|
466
|
+
b && /* @__PURE__ */ e("button", { type: "button", onClick: X, "aria-label": "Print", children: /* @__PURE__ */ e(g, { name: "printer", size: 16 }) }),
|
|
467
|
+
x && /* @__PURE__ */ e("button", { type: "button", onClick: S, "aria-label": "Fullscreen", children: /* @__PURE__ */ e(g, { name: H ? "collapse" : "expand", size: 16 }) })
|
|
468
|
+
] })
|
|
469
|
+
] }),
|
|
470
|
+
/* @__PURE__ */ m("div", { className: "nice-document-viewer__content", children: [
|
|
471
|
+
fe && !T && (ae ?? /* @__PURE__ */ e("div", { className: "nice-document-viewer__loading", children: "Loading..." })),
|
|
472
|
+
he()
|
|
473
|
+
] }),
|
|
474
|
+
t && /* @__PURE__ */ m("div", { className: "nice-document-viewer__info", children: [
|
|
475
|
+
/* @__PURE__ */ e("span", { className: "nice-document-viewer__name", children: u ?? t.name }),
|
|
476
|
+
t.size && /* @__PURE__ */ e("span", { className: "nice-document-viewer__size", children: ke(t.size) }),
|
|
477
|
+
t.width && t.height && /* @__PURE__ */ m("span", { className: "nice-document-viewer__dimensions", children: [
|
|
478
|
+
t.width,
|
|
479
|
+
" × ",
|
|
480
|
+
t.height
|
|
481
|
+
] }),
|
|
482
|
+
t.duration && /* @__PURE__ */ e("span", { className: "nice-document-viewer__duration", children: Ce(t.duration) })
|
|
483
|
+
] })
|
|
484
|
+
]
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
), re = "nice-document-viewer-styles";
|
|
489
|
+
if (typeof document < "u" && !document.getElementById(re)) {
|
|
490
|
+
const r = document.createElement("style");
|
|
491
|
+
r.id = re, r.textContent = `
|
|
492
|
+
.nice-document-viewer {
|
|
493
|
+
display: flex;
|
|
494
|
+
flex-direction: column;
|
|
495
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
496
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
497
|
+
overflow: hidden;
|
|
498
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.nice-document-viewer--fullscreen {
|
|
502
|
+
position: fixed;
|
|
503
|
+
top: 0;
|
|
504
|
+
left: 0;
|
|
505
|
+
right: 0;
|
|
506
|
+
bottom: 0;
|
|
507
|
+
z-index: 9999;
|
|
508
|
+
border: none;
|
|
509
|
+
border-radius: 0;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.nice-document-viewer__toolbar {
|
|
513
|
+
display: flex;
|
|
514
|
+
align-items: center;
|
|
515
|
+
justify-content: space-between;
|
|
516
|
+
padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
|
|
517
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
518
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
519
|
+
flex-shrink: 0;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.nice-document-viewer__toolbar-left,
|
|
523
|
+
.nice-document-viewer__toolbar-center,
|
|
524
|
+
.nice-document-viewer__toolbar-right {
|
|
525
|
+
display: flex;
|
|
526
|
+
align-items: center;
|
|
527
|
+
gap: var(--nice-space-2, 8px);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.nice-document-viewer__toolbar button {
|
|
531
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
532
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
533
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
534
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
535
|
+
cursor: pointer;
|
|
536
|
+
font-size: 14px;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.nice-document-viewer__toolbar button:hover:not(:disabled) {
|
|
540
|
+
background: var(--nice-hover-bg, color-mix(in srgb, var(--nice-text-primary, #000) 4%, transparent));
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.nice-document-viewer__toolbar button:disabled {
|
|
544
|
+
opacity: 0.4;
|
|
545
|
+
cursor: not-allowed;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.nice-document-viewer__pagination,
|
|
549
|
+
.nice-document-viewer__zoom,
|
|
550
|
+
.nice-document-viewer__rotation {
|
|
551
|
+
display: flex;
|
|
552
|
+
align-items: center;
|
|
553
|
+
gap: var(--nice-space-1-5, 6px);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.nice-document-viewer__pagination input {
|
|
557
|
+
width: 50px;
|
|
558
|
+
padding: var(--nice-space-1, 4px);
|
|
559
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
560
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
561
|
+
text-align: center;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
.nice-document-viewer__zoom span {
|
|
565
|
+
min-width: 50px;
|
|
566
|
+
text-align: center;
|
|
567
|
+
font-size: 13px;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.nice-document-viewer__content {
|
|
571
|
+
flex: 1;
|
|
572
|
+
overflow: auto;
|
|
573
|
+
display: flex;
|
|
574
|
+
align-items: center;
|
|
575
|
+
justify-content: center;
|
|
576
|
+
position: relative;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.nice-document-viewer__loading,
|
|
580
|
+
.nice-document-viewer__error,
|
|
581
|
+
.nice-document-viewer__unknown {
|
|
582
|
+
display: flex;
|
|
583
|
+
flex-direction: column;
|
|
584
|
+
align-items: center;
|
|
585
|
+
justify-content: center;
|
|
586
|
+
gap: var(--nice-space-3, 12px);
|
|
587
|
+
padding: var(--nice-space-10, 40px);
|
|
588
|
+
color: var(--nice-text-secondary, #475569);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.nice-document-viewer__error span {
|
|
592
|
+
color: var(--nice-error, #d32f2f);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.nice-document-viewer__pdf,
|
|
596
|
+
.nice-document-viewer__image {
|
|
597
|
+
display: flex;
|
|
598
|
+
align-items: center;
|
|
599
|
+
justify-content: center;
|
|
600
|
+
min-height: 100%;
|
|
601
|
+
min-width: 100%;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
.nice-document-viewer__pdf-canvas {
|
|
605
|
+
max-width: 100%;
|
|
606
|
+
height: auto;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
.nice-document-viewer__image img {
|
|
610
|
+
max-width: 100%;
|
|
611
|
+
max-height: 100%;
|
|
612
|
+
object-fit: contain;
|
|
613
|
+
transition: transform 0.2s;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
.nice-document-viewer__video,
|
|
617
|
+
.nice-document-viewer__audio {
|
|
618
|
+
display: flex;
|
|
619
|
+
align-items: center;
|
|
620
|
+
justify-content: center;
|
|
621
|
+
width: 100%;
|
|
622
|
+
height: 100%;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.nice-document-viewer__video video,
|
|
626
|
+
.nice-document-viewer__audio audio {
|
|
627
|
+
max-width: 100%;
|
|
628
|
+
max-height: 100%;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.nice-document-viewer__office iframe,
|
|
632
|
+
.nice-document-viewer__html iframe {
|
|
633
|
+
width: 100%;
|
|
634
|
+
height: 100%;
|
|
635
|
+
border: none;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.nice-document-viewer__text {
|
|
639
|
+
width: 100%;
|
|
640
|
+
height: 100%;
|
|
641
|
+
overflow: auto;
|
|
642
|
+
padding: var(--nice-space-4, 16px);
|
|
643
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.nice-document-viewer__text pre {
|
|
647
|
+
margin: 0;
|
|
648
|
+
font-family: 'Fira Code', monospace;
|
|
649
|
+
font-size: 13px;
|
|
650
|
+
white-space: pre-wrap;
|
|
651
|
+
word-wrap: break-word;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.nice-document-viewer__info {
|
|
655
|
+
display: flex;
|
|
656
|
+
align-items: center;
|
|
657
|
+
gap: var(--nice-space-4, 16px);
|
|
658
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
|
|
659
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
660
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
661
|
+
font-size: 12px;
|
|
662
|
+
color: var(--nice-text-secondary, #475569);
|
|
663
|
+
flex-shrink: 0;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.nice-document-viewer__name {
|
|
667
|
+
font-weight: 500;
|
|
668
|
+
color: var(--nice-text-primary, #0f172a);
|
|
669
|
+
}
|
|
670
|
+
`, document.head.appendChild(r);
|
|
671
|
+
}
|
|
672
|
+
export {
|
|
673
|
+
$e as NiceDocumentViewer
|
|
674
|
+
};
|