@peeekpage/viewer 0.3.16 → 0.3.17
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/index.js +64 -55
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as y, jsx as a, Fragment as Ze } from "react/jsx-runtime";
|
|
2
2
|
import { useState as w, useRef as O, useEffect as T, useCallback as S, useMemo as Ue } from "react";
|
|
3
3
|
const je = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
4
4
|
function D(t) {
|
|
@@ -262,7 +262,7 @@ function st(t) {
|
|
|
262
262
|
onToggleFullscreen: P,
|
|
263
263
|
onAbout: Z
|
|
264
264
|
} = t;
|
|
265
|
-
return /* @__PURE__ */
|
|
265
|
+
return /* @__PURE__ */ y("div", { className: "peeek__toolbar", children: [
|
|
266
266
|
/* @__PURE__ */ a("span", { className: "peeek__label", children: n }),
|
|
267
267
|
h.bar && /* @__PURE__ */ a("div", { className: "peeek__scrubber", "aria-hidden": !0, children: /* @__PURE__ */ a("div", { className: "peeek__scrubber-fill", style: { width: `${r}%` } }) }),
|
|
268
268
|
/* @__PURE__ */ a(
|
|
@@ -349,7 +349,7 @@ function it({ pages: t, layout: e, rtl: n, activePages: r, onJump: l }) {
|
|
|
349
349
|
const c = t.length, p = new Set(r), b = ae(c, e);
|
|
350
350
|
return /* @__PURE__ */ a("div", { className: "peeek__thumbs", role: "group", "aria-label": "Pages", children: Array.from({ length: b }, (d, i) => {
|
|
351
351
|
const h = he(i, c, e), _ = h.length === 2;
|
|
352
|
-
return /* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ y("div", { className: "peeek__thumb-group", children: [
|
|
353
353
|
h.map((u, f) => {
|
|
354
354
|
let s = "";
|
|
355
355
|
return _ && (s = (n ? f === 1 : f === 0) ? " peeek__thumb--flat-right" : " peeek__thumb--flat-left"), /* @__PURE__ */ a(
|
|
@@ -385,7 +385,7 @@ function ct(t) {
|
|
|
385
385
|
isFullscreen: _,
|
|
386
386
|
onToggleFullscreen: u,
|
|
387
387
|
onAbout: f
|
|
388
|
-
} = t, s = e.length, P = ae(s, r), N = be() || !p, [W, z] = w(0), [C, U] = w(1), [X,
|
|
388
|
+
} = t, s = e.length, P = ae(s, r), N = be() || !p, [W, z] = w(0), [C, U] = w(1), [X, v] = w(!1), [g, $] = w({ x: 0, y: 0 }), [A, R] = w(!1), G = O(null), oe = O(null), [k, le] = w(null), se = O(null), [_e, ke] = w(0.707);
|
|
389
389
|
T(() => {
|
|
390
390
|
if (!e[0]) return;
|
|
391
391
|
const o = new globalThis.Image();
|
|
@@ -393,7 +393,7 @@ function ct(t) {
|
|
|
393
393
|
o.naturalWidth && o.naturalHeight && ke(o.naturalWidth / o.naturalHeight);
|
|
394
394
|
}, o.src = e[0];
|
|
395
395
|
}, [e]);
|
|
396
|
-
const
|
|
396
|
+
const F = ee(W, s, r), ye = F <= 0, q = F >= P - 1, E = S(
|
|
397
397
|
(o) => {
|
|
398
398
|
k || z((m) => {
|
|
399
399
|
const x = ee(m + o, s, r);
|
|
@@ -434,14 +434,14 @@ function ct(t) {
|
|
|
434
434
|
if (!b || q) return;
|
|
435
435
|
const o = setTimeout(() => E(1), d);
|
|
436
436
|
return () => clearTimeout(o);
|
|
437
|
-
}, [b, d, q,
|
|
437
|
+
}, [b, d, q, F, E]);
|
|
438
438
|
const Te = () => U((o) => Math.min(ne, o + me)), Ce = () => U((o) => Math.max(te, o - me)), K = S((o, m, x) => {
|
|
439
439
|
const Q = oe.current;
|
|
440
440
|
if (!Q || x <= 1) return { x: 0, y: 0 };
|
|
441
441
|
const ue = (x - 1) * Q.clientWidth / 2, de = (x - 1) * Q.clientHeight / 2;
|
|
442
442
|
return { x: Math.max(-ue, Math.min(ue, o)), y: Math.max(-de, Math.min(de, m)) };
|
|
443
443
|
}, []);
|
|
444
|
-
T(() => $((o) => K(o.x, o.y, C)), [C, K]), T(() => $({ x: 0, y: 0 }), [
|
|
444
|
+
T(() => $((o) => K(o.x, o.y, C)), [C, K]), T(() => $({ x: 0, y: 0 }), [F]);
|
|
445
445
|
const xe = (o) => {
|
|
446
446
|
C <= 1 || (G.current = { x: o.clientX, y: o.clientY, px: g.x, py: g.y }, R(!0), o.currentTarget.setPointerCapture(o.pointerId));
|
|
447
447
|
}, Ie = (o) => {
|
|
@@ -455,12 +455,12 @@ function ct(t) {
|
|
|
455
455
|
} catch {
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
}, j = he(
|
|
458
|
+
}, j = he(F, s, r), J = j[0] ?? 0, Pe = r === "double" && j.length === 2 ? `${j[0] + 1} - ${j[1] + 1} / ${s}` : `${J + 1} / ${s}`, $e = P <= 1 ? 100 : F / (P - 1) * 100, Ae = n.prev, Fe = n.next, Me = k ? k.to : F, L = Y(Me, s, r), Se = L.left < 0 && L.right >= 0, ze = L.left >= 0 && L.right < 0, Ee = L.left >= 0 && L.right >= 0, Le = Se ? "-25%" : ze ? "25%" : "0%", M = Y(F, s, r), B = k ? Y(k.to, s, r) : M, Oe = k ? k.dir === 1 ? M.right >= 0 ? M.right : M.left : M.left >= 0 ? M.left : M.right : J, Re = k ? k.dir === 1 ? B.left >= 0 ? B.left : B.right : B.right >= 0 ? B.right : B.left : J, Be = k ? k.dir === 1 ? "left" : "right" : null, ce = (o) => o === Be ? M[o] : L[o], De = [
|
|
459
459
|
["left", ce("left")],
|
|
460
460
|
["right", ce("right")]
|
|
461
461
|
];
|
|
462
|
-
return /* @__PURE__ */
|
|
463
|
-
/* @__PURE__ */
|
|
462
|
+
return /* @__PURE__ */ y(Ze, { children: [
|
|
463
|
+
/* @__PURE__ */ y(
|
|
464
464
|
"div",
|
|
465
465
|
{
|
|
466
466
|
ref: oe,
|
|
@@ -474,7 +474,7 @@ function ct(t) {
|
|
|
474
474
|
{
|
|
475
475
|
type: "button",
|
|
476
476
|
className: "peeek__arrow peeek__arrow--prev",
|
|
477
|
-
"aria-label":
|
|
477
|
+
"aria-label": Ae,
|
|
478
478
|
disabled: ye,
|
|
479
479
|
onClick: () => E(-1),
|
|
480
480
|
children: "‹"
|
|
@@ -486,13 +486,13 @@ function ct(t) {
|
|
|
486
486
|
className: `peeek__zoom${C > 1 ? " peeek__zoom--pannable" : ""}`,
|
|
487
487
|
style: {
|
|
488
488
|
transform: `translate(${g.x}px, ${g.y}px) scale(${C})`,
|
|
489
|
-
transition: N ||
|
|
489
|
+
transition: N || A ? "none" : void 0
|
|
490
490
|
},
|
|
491
491
|
onPointerDown: xe,
|
|
492
492
|
onPointerMove: Ie,
|
|
493
493
|
onPointerUp: ie,
|
|
494
494
|
onPointerCancel: ie,
|
|
495
|
-
children: /* @__PURE__ */
|
|
495
|
+
children: /* @__PURE__ */ y(
|
|
496
496
|
"div",
|
|
497
497
|
{
|
|
498
498
|
className: `peeek__spread${c ? " peeek--shadows" : ""}${Ee ? " peeek__spread--pair" : ""}`,
|
|
@@ -518,7 +518,7 @@ function ct(t) {
|
|
|
518
518
|
o
|
|
519
519
|
);
|
|
520
520
|
}),
|
|
521
|
-
k && /* @__PURE__ */
|
|
521
|
+
k && /* @__PURE__ */ y(
|
|
522
522
|
"div",
|
|
523
523
|
{
|
|
524
524
|
ref: se,
|
|
@@ -540,7 +540,7 @@ function ct(t) {
|
|
|
540
540
|
{
|
|
541
541
|
type: "button",
|
|
542
542
|
className: "peeek__arrow peeek__arrow--next",
|
|
543
|
-
"aria-label":
|
|
543
|
+
"aria-label": Fe,
|
|
544
544
|
disabled: q,
|
|
545
545
|
onClick: () => E(1),
|
|
546
546
|
children: "›"
|
|
@@ -565,7 +565,7 @@ function ct(t) {
|
|
|
565
565
|
onZoomIn: Te,
|
|
566
566
|
onZoomOut: Ce,
|
|
567
567
|
onZoomSet: (o) => U(Math.min(ne, Math.max(te, o))),
|
|
568
|
-
onToggleThumbs: () =>
|
|
568
|
+
onToggleThumbs: () => v((o) => !o),
|
|
569
569
|
onToggleFullscreen: u,
|
|
570
570
|
onAbout: f
|
|
571
571
|
}
|
|
@@ -605,35 +605,35 @@ function ft(t) {
|
|
|
605
605
|
onAbout: _,
|
|
606
606
|
show: u
|
|
607
607
|
} = t, f = e.length, [s, P] = w(0), Z = be(), N = S(
|
|
608
|
-
(
|
|
608
|
+
(v) => P((g) => Math.max(0, Math.min(f - 1, g + v))),
|
|
609
609
|
[f]
|
|
610
610
|
), W = s <= 0, z = s >= f - 1, C = O([]);
|
|
611
611
|
T(() => {
|
|
612
|
-
var
|
|
613
|
-
(g = (
|
|
612
|
+
var v, g;
|
|
613
|
+
(g = (v = C.current[s]) == null ? void 0 : v.scrollIntoView) == null || g.call(v, { behavior: "smooth", inline: "center", block: "nearest" });
|
|
614
614
|
}, [s]), T(() => {
|
|
615
615
|
if (!p || Z || z) return;
|
|
616
|
-
const
|
|
617
|
-
return () => clearTimeout(
|
|
616
|
+
const v = setTimeout(() => N(1), b);
|
|
617
|
+
return () => clearTimeout(v);
|
|
618
618
|
}, [p, b, Z, z, s, N]);
|
|
619
619
|
const U = S(
|
|
620
|
-
(
|
|
621
|
-
|
|
620
|
+
(v) => {
|
|
621
|
+
v.key === "ArrowRight" ? N(c ? -1 : 1) : v.key === "ArrowLeft" && N(c ? 1 : -1);
|
|
622
622
|
},
|
|
623
623
|
[N, c]
|
|
624
624
|
), X = ut(r, l);
|
|
625
|
-
return /* @__PURE__ */
|
|
626
|
-
/* @__PURE__ */
|
|
625
|
+
return /* @__PURE__ */ y("div", { className: "peeek__cf", children: [
|
|
626
|
+
/* @__PURE__ */ y("div", { className: "peeek__cf-header", children: [
|
|
627
627
|
/* @__PURE__ */ a("span", { className: "peeek__cf-badge", children: X }),
|
|
628
|
-
/* @__PURE__ */
|
|
628
|
+
/* @__PURE__ */ y("div", { className: "peeek__cf-meta", children: [
|
|
629
629
|
/* @__PURE__ */ a("span", { className: "peeek__cf-name", children: r }),
|
|
630
|
-
/* @__PURE__ */
|
|
630
|
+
/* @__PURE__ */ y("span", { className: "peeek__cf-count", children: [
|
|
631
631
|
f,
|
|
632
632
|
" ",
|
|
633
633
|
f === 1 ? n.page : n.pages
|
|
634
634
|
] })
|
|
635
635
|
] }),
|
|
636
|
-
/* @__PURE__ */
|
|
636
|
+
/* @__PURE__ */ y("span", { className: "peeek__cf-indicator", children: [
|
|
637
637
|
s + 1,
|
|
638
638
|
" / ",
|
|
639
639
|
f
|
|
@@ -672,7 +672,7 @@ function ft(t) {
|
|
|
672
672
|
}
|
|
673
673
|
)
|
|
674
674
|
] }),
|
|
675
|
-
/* @__PURE__ */
|
|
675
|
+
/* @__PURE__ */ y(
|
|
676
676
|
"div",
|
|
677
677
|
{
|
|
678
678
|
className: "peeek__cf-stage",
|
|
@@ -690,20 +690,20 @@ function ft(t) {
|
|
|
690
690
|
children: "‹"
|
|
691
691
|
}
|
|
692
692
|
),
|
|
693
|
-
e.map((
|
|
693
|
+
e.map((v, g) => {
|
|
694
694
|
const $ = g - s;
|
|
695
695
|
if (Math.abs($) > 1) return null;
|
|
696
|
-
const
|
|
696
|
+
const A = $ === 0, R = A && u.fullscreen;
|
|
697
697
|
return /* @__PURE__ */ a(
|
|
698
698
|
"button",
|
|
699
699
|
{
|
|
700
700
|
type: "button",
|
|
701
|
-
className: `peeek__cf-card${
|
|
701
|
+
className: `peeek__cf-card${A ? " peeek__cf-card--center" : ""}${R ? " peeek__cf-card--zoom" : ""}`,
|
|
702
702
|
style: dt($, c),
|
|
703
|
-
tabIndex:
|
|
703
|
+
tabIndex: A ? 0 : -1,
|
|
704
704
|
"aria-label": R ? n.openFullscreen : `Go to page ${g + 1}`,
|
|
705
705
|
onClick: () => R ? h() : P(g),
|
|
706
|
-
children: /* @__PURE__ */ a("img", { src:
|
|
706
|
+
children: /* @__PURE__ */ a("img", { src: v, alt: A ? `Page ${g + 1}` : "", loading: "lazy", referrerPolicy: "no-referrer" })
|
|
707
707
|
},
|
|
708
708
|
g
|
|
709
709
|
);
|
|
@@ -722,13 +722,13 @@ function ft(t) {
|
|
|
722
722
|
]
|
|
723
723
|
}
|
|
724
724
|
),
|
|
725
|
-
u.thumbnails && /* @__PURE__ */ a("div", { className: "peeek__cf-thumbs", role: "group", "aria-label": "Pages", children: e.map((
|
|
725
|
+
u.thumbnails && /* @__PURE__ */ a("div", { className: "peeek__cf-thumbs", role: "group", "aria-label": "Pages", children: e.map((v, g) => {
|
|
726
726
|
const $ = g === s;
|
|
727
|
-
return /* @__PURE__ */
|
|
727
|
+
return /* @__PURE__ */ y(
|
|
728
728
|
"button",
|
|
729
729
|
{
|
|
730
|
-
ref: (
|
|
731
|
-
C.current[g] =
|
|
730
|
+
ref: (A) => {
|
|
731
|
+
C.current[g] = A;
|
|
732
732
|
},
|
|
733
733
|
type: "button",
|
|
734
734
|
className: `peeek__cf-thumb${$ ? " peeek__cf-thumb--active" : ""}`,
|
|
@@ -736,7 +736,7 @@ function ft(t) {
|
|
|
736
736
|
"aria-current": $ ? "page" : void 0,
|
|
737
737
|
onClick: () => P(g),
|
|
738
738
|
children: [
|
|
739
|
-
/* @__PURE__ */ a("img", { src:
|
|
739
|
+
/* @__PURE__ */ a("img", { src: v, alt: "", loading: "lazy", referrerPolicy: "no-referrer" }),
|
|
740
740
|
/* @__PURE__ */ a("span", { className: "peeek__cf-thumb-num", children: String(g + 1).padStart(2, "0") })
|
|
741
741
|
]
|
|
742
742
|
},
|
|
@@ -760,7 +760,7 @@ function gt({ strings: t, onClose: e }) {
|
|
|
760
760
|
l.key === "Escape" && e();
|
|
761
761
|
};
|
|
762
762
|
return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
|
|
763
|
-
}, [e]), /* @__PURE__ */ a("div", { className: "peeek__about-backdrop", onClick: e, children: /* @__PURE__ */
|
|
763
|
+
}, [e]), /* @__PURE__ */ a("div", { className: "peeek__about-backdrop", onClick: e, children: /* @__PURE__ */ y(
|
|
764
764
|
"div",
|
|
765
765
|
{
|
|
766
766
|
role: "dialog",
|
|
@@ -780,31 +780,40 @@ function gt({ strings: t, onClose: e }) {
|
|
|
780
780
|
children: "×"
|
|
781
781
|
}
|
|
782
782
|
),
|
|
783
|
-
/* @__PURE__ */
|
|
783
|
+
/* @__PURE__ */ y(
|
|
784
784
|
"svg",
|
|
785
785
|
{
|
|
786
786
|
className: "peeek__about-mark",
|
|
787
|
-
width: "
|
|
788
|
-
height: "
|
|
789
|
-
viewBox: "0 0
|
|
790
|
-
fill: "none",
|
|
791
|
-
stroke: "currentColor",
|
|
792
|
-
strokeWidth: "1.6",
|
|
793
|
-
strokeLinecap: "round",
|
|
794
|
-
strokeLinejoin: "round",
|
|
787
|
+
width: "44",
|
|
788
|
+
height: "44",
|
|
789
|
+
viewBox: "0 0 256 256",
|
|
795
790
|
"aria-hidden": "true",
|
|
796
791
|
children: [
|
|
797
|
-
/* @__PURE__ */ a("
|
|
798
|
-
|
|
799
|
-
|
|
792
|
+
/* @__PURE__ */ a("defs", { children: /* @__PURE__ */ y("radialGradient", { id: "peeek-about-orb", cx: "38%", cy: "30%", r: "80%", children: [
|
|
793
|
+
/* @__PURE__ */ a("stop", { offset: "0%", stopColor: "#9aa2e6" }),
|
|
794
|
+
/* @__PURE__ */ a("stop", { offset: "55%", stopColor: "#6E79D6" }),
|
|
795
|
+
/* @__PURE__ */ a("stop", { offset: "100%", stopColor: "#535cc0" })
|
|
796
|
+
] }) }),
|
|
797
|
+
/* @__PURE__ */ a("circle", { cx: "128", cy: "128", r: "128", fill: "url(#peeek-about-orb)" }),
|
|
798
|
+
/* @__PURE__ */ a(
|
|
799
|
+
"path",
|
|
800
|
+
{
|
|
801
|
+
d: "M90 196 V70 H140 A38 38 0 0 1 140 146 H90",
|
|
802
|
+
fill: "none",
|
|
803
|
+
stroke: "#fff",
|
|
804
|
+
strokeWidth: "30",
|
|
805
|
+
strokeLinecap: "round",
|
|
806
|
+
strokeLinejoin: "round"
|
|
807
|
+
}
|
|
808
|
+
)
|
|
800
809
|
]
|
|
801
810
|
}
|
|
802
811
|
),
|
|
803
812
|
/* @__PURE__ */ a("div", { className: "peeek__about-name", children: "Peeek Viewer" }),
|
|
804
813
|
/* @__PURE__ */ a("div", { className: "peeek__about-tagline", children: t.aboutTagline }),
|
|
805
|
-
/* @__PURE__ */
|
|
814
|
+
/* @__PURE__ */ y("div", { className: "peeek__about-version", children: [
|
|
806
815
|
"v",
|
|
807
|
-
"0.3.
|
|
816
|
+
"0.3.17"
|
|
808
817
|
] }),
|
|
809
818
|
/* @__PURE__ */ a("p", { className: "peeek__about-desc", children: t.aboutDescription })
|
|
810
819
|
]
|
|
@@ -828,7 +837,7 @@ function ht(t) {
|
|
|
828
837
|
overview: e.pagesOverview,
|
|
829
838
|
about: e.aboutButton
|
|
830
839
|
};
|
|
831
|
-
return /* @__PURE__ */
|
|
840
|
+
return /* @__PURE__ */ y(
|
|
832
841
|
"div",
|
|
833
842
|
{
|
|
834
843
|
ref: r,
|