@turinhub/atomix-common-ui 0.4.0 → 0.6.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/README.md +20 -2
- package/dist/AuthPanel-CTKx618F.cjs +2 -0
- package/dist/AuthPanel-CTKx618F.cjs.map +1 -0
- package/dist/AuthPanel-Cn_WwmjX.js +703 -0
- package/dist/AuthPanel-Cn_WwmjX.js.map +1 -0
- package/dist/PDFSidebar-4DtXqqzN.cjs +2 -0
- package/dist/PDFSidebar-4DtXqqzN.cjs.map +1 -0
- package/dist/PDFSidebar-ClnrF4Br.js +239 -0
- package/dist/PDFSidebar-ClnrF4Br.js.map +1 -0
- package/dist/auth.cjs +2 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.ts +11 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +9 -0
- package/dist/auth.js.map +1 -0
- package/dist/components/AuthLoginPanel.d.ts +55 -0
- package/dist/components/AuthLoginPanel.d.ts.map +1 -0
- package/dist/components/AuthPageShell.d.ts +11 -0
- package/dist/components/AuthPageShell.d.ts.map +1 -0
- package/dist/components/AuthPanel.d.ts +20 -0
- package/dist/components/AuthPanel.d.ts.map +1 -0
- package/dist/components/AuthRegisterPanel.d.ts +34 -0
- package/dist/components/AuthRegisterPanel.d.ts.map +1 -0
- package/dist/components/AuthVisualCarousel.d.ts +22 -0
- package/dist/components/AuthVisualCarousel.d.ts.map +1 -0
- package/dist/components/DataTable.d.ts +2 -2
- package/dist/components/DataTable.d.ts.map +1 -1
- package/dist/components/ImageReader.d.ts +44 -0
- package/dist/components/ImageReader.d.ts.map +1 -0
- package/dist/components/MarkdownReader.d.ts.map +1 -1
- package/dist/components/PDFReader.d.ts.map +1 -1
- package/dist/components/PDFSidebar.d.ts.map +1 -1
- package/dist/components/SimplePDFReader.d.ts.map +1 -1
- package/dist/components/TableHeader.d.ts.map +1 -1
- package/dist/components/TablePagination.d.ts +2 -1
- package/dist/components/TablePagination.d.ts.map +1 -1
- package/dist/components/VideoReader.d.ts +39 -0
- package/dist/components/VideoReader.d.ts.map +1 -0
- package/dist/components/media-utils.d.ts +9 -0
- package/dist/components/media-utils.d.ts.map +1 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.cjs.map +1 -1
- package/dist/data-table.js +83 -73
- package/dist/data-table.js.map +1 -1
- package/dist/file-upload.cjs +1 -1
- package/dist/file-upload.cjs.map +1 -1
- package/dist/file-upload.js +36 -36
- package/dist/file-upload.js.map +1 -1
- package/dist/image-reader.cjs +2 -0
- package/dist/image-reader.cjs.map +1 -0
- package/dist/image-reader.d.ts +3 -0
- package/dist/image-reader.d.ts.map +1 -0
- package/dist/image-reader.js +215 -0
- package/dist/image-reader.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/markdown-reader.cjs +1 -1
- package/dist/markdown-reader.cjs.map +1 -1
- package/dist/markdown-reader.js +28 -24
- package/dist/markdown-reader.js.map +1 -1
- package/dist/media-utils-5UPuocc1.js +23 -0
- package/dist/media-utils-5UPuocc1.js.map +1 -0
- package/dist/media-utils-X1dDYP9W.cjs +2 -0
- package/dist/media-utils-X1dDYP9W.cjs.map +1 -0
- package/dist/pdf-reader.cjs +1 -1
- package/dist/pdf-reader.cjs.map +1 -1
- package/dist/pdf-reader.js +170 -121
- package/dist/pdf-reader.js.map +1 -1
- package/dist/pdf-sidebar.cjs +1 -1
- package/dist/pdf-sidebar.js +1 -1
- package/dist/simple-pdf-reader.cjs +1 -1
- package/dist/simple-pdf-reader.cjs.map +1 -1
- package/dist/simple-pdf-reader.js +138 -105
- package/dist/simple-pdf-reader.js.map +1 -1
- package/dist/table-header.cjs +1 -1
- package/dist/table-header.cjs.map +1 -1
- package/dist/table-header.js +42 -34
- package/dist/table-header.js.map +1 -1
- package/dist/table-pagination.cjs +1 -1
- package/dist/table-pagination.cjs.map +1 -1
- package/dist/table-pagination.js +49 -43
- package/dist/table-pagination.js.map +1 -1
- package/dist/types/component-types.d.ts +2 -0
- package/dist/types/component-types.d.ts.map +1 -1
- package/dist/video-reader.cjs +2 -0
- package/dist/video-reader.cjs.map +1 -0
- package/dist/video-reader.d.ts +3 -0
- package/dist/video-reader.d.ts.map +1 -0
- package/dist/video-reader.js +158 -0
- package/dist/video-reader.js.map +1 -0
- package/package.json +32 -1
- package/dist/PDFSidebar-BBtucLK6.js +0 -232
- package/dist/PDFSidebar-BBtucLK6.js.map +0 -1
- package/dist/PDFSidebar-Di0D-yPS.cjs +0 -2
- package/dist/PDFSidebar-Di0D-yPS.cjs.map +0 -1
- package/dist/index-BiA_tnaq.cjs +0 -13
- package/dist/index-BiA_tnaq.cjs.map +0 -1
- package/dist/index-BypbGNpR.js +0 -18821
- package/dist/index-BypbGNpR.js.map +0 -1
package/dist/pdf-reader.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { j as t } from "./jsx-runtime-B4hRZ52C.js";
|
|
2
2
|
import { PanelLeft as Xe, ZoomOut as Ye, ZoomIn as Je, RotateCw as Qe, ScrollText as He, FileText as Ue, Minimize2 as et, Maximize2 as tt, ChevronLeft as de, ChevronRight as fe } from "lucide-react";
|
|
3
|
-
import { useState as u, useEffect as
|
|
4
|
-
import { P as nt } from "./PDFSidebar-
|
|
3
|
+
import { useState as u, useEffect as T, useRef as R, useMemo as st, useCallback as m } from "react";
|
|
4
|
+
import { P as nt } from "./PDFSidebar-ClnrF4Br.js";
|
|
5
5
|
function rt(x, v) {
|
|
6
|
-
const
|
|
6
|
+
const N = R(
|
|
7
7
|
void 0
|
|
8
8
|
);
|
|
9
9
|
return m(
|
|
10
|
-
(...
|
|
11
|
-
|
|
10
|
+
(...L) => {
|
|
11
|
+
N.current && clearTimeout(N.current), N.current = setTimeout(() => x(...L), v);
|
|
12
12
|
},
|
|
13
13
|
[x, v]
|
|
14
14
|
);
|
|
@@ -16,63 +16,63 @@ function rt(x, v) {
|
|
|
16
16
|
function ot({
|
|
17
17
|
url: x,
|
|
18
18
|
initialPage: v = 1,
|
|
19
|
-
initialScale:
|
|
20
|
-
initialRotation:
|
|
21
|
-
currentPage:
|
|
19
|
+
initialScale: N = 1,
|
|
20
|
+
initialRotation: L = 0,
|
|
21
|
+
currentPage: U,
|
|
22
22
|
onPageChange: P,
|
|
23
|
-
scale:
|
|
23
|
+
scale: G,
|
|
24
24
|
onScaleChange: C,
|
|
25
|
-
rotation:
|
|
25
|
+
rotation: K,
|
|
26
26
|
onRotationChange: F,
|
|
27
|
-
minScale:
|
|
28
|
-
maxScale:
|
|
27
|
+
minScale: _ = 0.5,
|
|
28
|
+
maxScale: B = 2.5,
|
|
29
29
|
showToolbar: me = !0,
|
|
30
|
-
showSidebar:
|
|
30
|
+
showSidebar: b = !0,
|
|
31
31
|
showRotation: xe = !0,
|
|
32
32
|
showModeToggle: he = !0,
|
|
33
33
|
showFullscreen: pe = !0,
|
|
34
|
-
enableHotkeys:
|
|
34
|
+
enableHotkeys: ee = !0,
|
|
35
35
|
enableMobileNav: ve = !0,
|
|
36
|
-
displayMode:
|
|
37
|
-
className:
|
|
36
|
+
displayMode: be = "single",
|
|
37
|
+
className: je,
|
|
38
38
|
toolbarClassName: ge,
|
|
39
39
|
contentClassName: ye,
|
|
40
40
|
contentHeight: Te = "80vh",
|
|
41
|
-
pageClassName:
|
|
42
|
-
workerUrl:
|
|
43
|
-
cMapUrl:
|
|
44
|
-
standardFontDataUrl:
|
|
45
|
-
components:
|
|
41
|
+
pageClassName: te,
|
|
42
|
+
workerUrl: V,
|
|
43
|
+
cMapUrl: k,
|
|
44
|
+
standardFontDataUrl: w,
|
|
45
|
+
components: c,
|
|
46
46
|
onLoadSuccess: z,
|
|
47
47
|
onLoadError: h,
|
|
48
|
-
onPageRender:
|
|
48
|
+
onPageRender: j,
|
|
49
49
|
loadingText: Ne = "正在加载PDF文档...",
|
|
50
|
-
errorText:
|
|
50
|
+
errorText: se = "PDF加载失败"
|
|
51
51
|
}) {
|
|
52
|
-
const [
|
|
53
|
-
|
|
54
|
-
), [
|
|
55
|
-
|
|
56
|
-
ie(
|
|
57
|
-
}, [
|
|
58
|
-
const [le, Fe] = u(void 0), [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, [x, v,
|
|
52
|
+
const [ne, Z] = u(null), [ke, q] = u(v), [we, De] = u(N), [Me, Pe] = u(L), [Ce, A] = u(!1), [D, I] = u(null), [d, X] = u(0), [E, Y] = u(!1), [g, re] = u(
|
|
53
|
+
be === "scroll"
|
|
54
|
+
), [O, ie] = u(b);
|
|
55
|
+
T(() => {
|
|
56
|
+
ie(b);
|
|
57
|
+
}, [b]);
|
|
58
|
+
const [le, Fe] = u(void 0), [ae, ze] = u(null), ce = R(null), W = R(null), J = R(/* @__PURE__ */ new Map()), r = U ?? ke, p = G ?? we, $ = K ?? Me, y = U !== void 0, a = g, { Card: Ae, CardContent: Ie, Button: f, Input: Ee, Skeleton: Oe } = c || {};
|
|
59
|
+
T(() => {
|
|
60
|
+
Z(null), X(0), I(null), A(!1), y || q(Math.max(1, v));
|
|
61
|
+
}, [x, v, y]);
|
|
62
62
|
const We = st(() => {
|
|
63
63
|
const e = {
|
|
64
64
|
withCredentials: !1
|
|
65
65
|
};
|
|
66
|
-
return
|
|
67
|
-
}, [
|
|
68
|
-
|
|
66
|
+
return k && (e.cMapUrl = k, e.cMapPacked = !0), w && (e.standardFontDataUrl = w), e;
|
|
67
|
+
}, [k, w]);
|
|
68
|
+
T(() => {
|
|
69
69
|
let e = !0;
|
|
70
70
|
return (async () => {
|
|
71
71
|
try {
|
|
72
|
-
const i = await import("
|
|
72
|
+
const i = await import("react-pdf");
|
|
73
73
|
if (typeof window < "u") {
|
|
74
74
|
const n = i.pdfjs, l = n == null ? void 0 : n.version;
|
|
75
|
-
n != null && n.GlobalWorkerOptions && l && (
|
|
75
|
+
n != null && n.GlobalWorkerOptions && l && (V ? n.GlobalWorkerOptions.workerSrc = V : n.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${l}/build/pdf.worker.min.mjs`, !k && n.GlobalWorkerOptions && (n.GlobalWorkerOptions.cMapUrl = `https://unpkg.com/pdfjs-dist@${l}/cmaps/`), !w && n.GlobalWorkerOptions && (n.GlobalWorkerOptions.standardFontDataUrl = `https://unpkg.com/pdfjs-dist@${l}/standard_fonts/`));
|
|
76
76
|
}
|
|
77
77
|
e && ze(i);
|
|
78
78
|
} catch (i) {
|
|
@@ -84,59 +84,59 @@ function ot({
|
|
|
84
84
|
})(), () => {
|
|
85
85
|
e = !1;
|
|
86
86
|
};
|
|
87
|
-
}, [
|
|
87
|
+
}, [V, k, w, h]);
|
|
88
88
|
const $e = m(
|
|
89
89
|
(e) => {
|
|
90
|
-
console.error("PDF加载失败:", e), console.error("PDF URL:", x),
|
|
91
|
-
new Error(`${
|
|
90
|
+
console.error("PDF加载失败:", e), console.error("PDF URL:", x), Z(null), X(0), I(
|
|
91
|
+
new Error(`${se}: ${e.message || "请检查文件路径或网络连接"}`)
|
|
92
92
|
), A(!1), h == null || h(e);
|
|
93
93
|
},
|
|
94
|
-
[x,
|
|
94
|
+
[x, se, h]
|
|
95
95
|
), Se = m(
|
|
96
96
|
(e) => {
|
|
97
|
-
|
|
97
|
+
Z(e), X(e.numPages), I(null), A(!1), y || q(
|
|
98
98
|
(s) => Math.max(1, Math.min(s, Math.max(e.numPages, 1)))
|
|
99
99
|
), z == null || z(e);
|
|
100
100
|
},
|
|
101
|
-
[
|
|
101
|
+
[y, z]
|
|
102
102
|
), o = m(
|
|
103
103
|
(e) => {
|
|
104
104
|
if (!Number.isFinite(e)) return;
|
|
105
105
|
const s = d > 0 ? Math.max(1, Math.min(Math.trunc(e), d)) : Math.max(1, Math.trunc(e));
|
|
106
|
-
|
|
106
|
+
y || q(s), s !== r && (P == null || P(s));
|
|
107
107
|
},
|
|
108
|
-
[d,
|
|
108
|
+
[d, y, r, P]
|
|
109
109
|
), Re = m(
|
|
110
110
|
(e, s) => {
|
|
111
|
-
s ?
|
|
111
|
+
s ? J.current.set(e, s) : J.current.delete(e);
|
|
112
112
|
},
|
|
113
113
|
[]
|
|
114
114
|
), Le = m(() => {
|
|
115
|
-
const e =
|
|
116
|
-
if (!e || !
|
|
115
|
+
const e = W.current;
|
|
116
|
+
if (!e || !a || d <= 0) return;
|
|
117
117
|
const s = e.getBoundingClientRect().top;
|
|
118
118
|
let i = r, n = Number.POSITIVE_INFINITY;
|
|
119
|
-
|
|
119
|
+
J.current.forEach((l, S) => {
|
|
120
120
|
const ue = Math.abs(
|
|
121
121
|
l.getBoundingClientRect().top - s
|
|
122
122
|
);
|
|
123
|
-
ue < n && (n = ue, i =
|
|
123
|
+
ue < n && (n = ue, i = S);
|
|
124
124
|
}), i !== r && o(i);
|
|
125
|
-
}, [r, o,
|
|
125
|
+
}, [r, o, a, d]), M = m(
|
|
126
126
|
(e) => {
|
|
127
|
-
const s = Math.max(
|
|
128
|
-
|
|
127
|
+
const s = Math.max(_, Math.min(B, p + e));
|
|
128
|
+
G === void 0 && De(s), C == null || C(s);
|
|
129
129
|
},
|
|
130
|
-
[p,
|
|
130
|
+
[p, _, B, G, C]
|
|
131
131
|
), Ge = m(() => {
|
|
132
|
-
const e = (
|
|
133
|
-
|
|
134
|
-
}, [
|
|
132
|
+
const e = ($ + 90) % 360;
|
|
133
|
+
K === void 0 && Pe(e), F == null || F(e);
|
|
134
|
+
}, [$, K, F]), oe = rt((e) => {
|
|
135
135
|
Fe(e);
|
|
136
136
|
}, 100);
|
|
137
|
-
|
|
138
|
-
if (!
|
|
139
|
-
const e =
|
|
137
|
+
T(() => {
|
|
138
|
+
if (!W.current) return;
|
|
139
|
+
const e = W.current, s = () => {
|
|
140
140
|
oe(e.clientWidth);
|
|
141
141
|
};
|
|
142
142
|
s();
|
|
@@ -146,32 +146,32 @@ function ot({
|
|
|
146
146
|
return i.observe(e), () => {
|
|
147
147
|
i.disconnect();
|
|
148
148
|
};
|
|
149
|
-
}, [oe]),
|
|
150
|
-
if (!
|
|
149
|
+
}, [oe]), T(() => {
|
|
150
|
+
if (!ee) return;
|
|
151
151
|
const e = (s) => {
|
|
152
|
-
const i = s.target, n = typeof document < "u" ? document.activeElement : null, l = i || n,
|
|
153
|
-
l && (l.tagName === "INPUT" || l.tagName === "TEXTAREA" || l.tagName === "SELECT" || l.isContentEditable ||
|
|
152
|
+
const i = s.target, n = typeof document < "u" ? document.activeElement : null, l = i || n, S = l == null ? void 0 : l.getAttribute("role");
|
|
153
|
+
l && (l.tagName === "INPUT" || l.tagName === "TEXTAREA" || l.tagName === "SELECT" || l.isContentEditable || S === "textbox" || S === "spinbutton") || ((s.ctrlKey || s.metaKey) && (s.key === "=" || s.key === "+") ? (s.preventDefault(), M(0.1)) : (s.ctrlKey || s.metaKey) && s.key === "-" ? (s.preventDefault(), M(-0.1)) : !a && s.key === "ArrowLeft" ? (s.preventDefault(), o(r - 1)) : !a && s.key === "ArrowRight" && (s.preventDefault(), o(r + 1)));
|
|
154
154
|
};
|
|
155
155
|
return document.addEventListener("keydown", e), () => {
|
|
156
156
|
document.removeEventListener("keydown", e);
|
|
157
157
|
};
|
|
158
|
-
}, [
|
|
158
|
+
}, [ee, r, o, a, M]);
|
|
159
159
|
const Ke = m(async () => {
|
|
160
160
|
var e, s;
|
|
161
161
|
if (!(typeof document > "u"))
|
|
162
162
|
if (document.fullscreenElement)
|
|
163
|
-
document.exitFullscreen && (await document.exitFullscreen(),
|
|
163
|
+
document.exitFullscreen && (await document.exitFullscreen(), Y(!1));
|
|
164
164
|
else
|
|
165
165
|
try {
|
|
166
|
-
await ((s = (e =
|
|
166
|
+
await ((s = (e = ce.current) == null ? void 0 : e.requestFullscreen) == null ? void 0 : s.call(e)), Y(!0);
|
|
167
167
|
} catch (i) {
|
|
168
168
|
console.error("Error attempting to enable fullscreen:", i);
|
|
169
169
|
}
|
|
170
170
|
}, []);
|
|
171
|
-
|
|
171
|
+
T(() => {
|
|
172
172
|
if (typeof document > "u") return;
|
|
173
173
|
const e = () => {
|
|
174
|
-
|
|
174
|
+
Y(!!document.fullscreenElement);
|
|
175
175
|
};
|
|
176
176
|
return document.addEventListener("fullscreenchange", e), () => {
|
|
177
177
|
document.removeEventListener("fullscreenchange", e);
|
|
@@ -188,13 +188,14 @@ function ot({
|
|
|
188
188
|
className: `flex items-center justify-between gap-4 border-b px-4 py-2 ${ge || ""}`,
|
|
189
189
|
children: [
|
|
190
190
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
191
|
-
|
|
191
|
+
b && /* @__PURE__ */ t.jsx(
|
|
192
192
|
f,
|
|
193
193
|
{
|
|
194
194
|
variant: "outline",
|
|
195
195
|
size: "icon",
|
|
196
|
-
onClick: () => ie(!
|
|
197
|
-
|
|
196
|
+
onClick: () => ie(!O),
|
|
197
|
+
"aria-label": O ? "隐藏侧边栏" : "显示侧边栏",
|
|
198
|
+
title: O ? "隐藏侧边栏" : "显示侧边栏",
|
|
198
199
|
children: /* @__PURE__ */ t.jsx(Xe, {})
|
|
199
200
|
}
|
|
200
201
|
),
|
|
@@ -204,7 +205,9 @@ function ot({
|
|
|
204
205
|
variant: "outline",
|
|
205
206
|
size: "icon",
|
|
206
207
|
onClick: () => M(-0.1),
|
|
207
|
-
disabled: p <=
|
|
208
|
+
disabled: p <= _,
|
|
209
|
+
"aria-label": "缩小",
|
|
210
|
+
title: "缩小",
|
|
208
211
|
children: /* @__PURE__ */ t.jsx(Ye, {})
|
|
209
212
|
}
|
|
210
213
|
),
|
|
@@ -218,31 +221,56 @@ function ot({
|
|
|
218
221
|
variant: "outline",
|
|
219
222
|
size: "icon",
|
|
220
223
|
onClick: () => M(0.1),
|
|
221
|
-
disabled: p >=
|
|
224
|
+
disabled: p >= B,
|
|
225
|
+
"aria-label": "放大",
|
|
226
|
+
title: "放大",
|
|
222
227
|
children: /* @__PURE__ */ t.jsx(Je, {})
|
|
223
228
|
}
|
|
224
229
|
),
|
|
225
|
-
xe && /* @__PURE__ */ t.jsx(
|
|
230
|
+
xe && /* @__PURE__ */ t.jsx(
|
|
231
|
+
f,
|
|
232
|
+
{
|
|
233
|
+
variant: "outline",
|
|
234
|
+
size: "icon",
|
|
235
|
+
onClick: Ge,
|
|
236
|
+
"aria-label": "顺时针旋转",
|
|
237
|
+
title: "顺时针旋转",
|
|
238
|
+
children: /* @__PURE__ */ t.jsx(Qe, {})
|
|
239
|
+
}
|
|
240
|
+
),
|
|
226
241
|
he && /* @__PURE__ */ t.jsx(
|
|
227
242
|
f,
|
|
228
243
|
{
|
|
229
244
|
variant: "outline",
|
|
230
245
|
size: "icon",
|
|
231
|
-
onClick: () => re(!
|
|
232
|
-
|
|
233
|
-
|
|
246
|
+
onClick: () => re(!g),
|
|
247
|
+
"aria-label": g ? "切换到单页模式" : "切换到滚动模式",
|
|
248
|
+
title: g ? "单页模式" : "滚动模式",
|
|
249
|
+
children: g ? /* @__PURE__ */ t.jsx(He, {}) : /* @__PURE__ */ t.jsx(Ue, {})
|
|
234
250
|
}
|
|
235
251
|
),
|
|
236
|
-
pe && /* @__PURE__ */ t.jsx(
|
|
252
|
+
pe && /* @__PURE__ */ t.jsx(
|
|
253
|
+
f,
|
|
254
|
+
{
|
|
255
|
+
variant: "outline",
|
|
256
|
+
size: "icon",
|
|
257
|
+
onClick: Ke,
|
|
258
|
+
"aria-label": E ? "退出全屏" : "进入全屏",
|
|
259
|
+
title: E ? "退出全屏" : "进入全屏",
|
|
260
|
+
children: E ? /* @__PURE__ */ t.jsx(et, {}) : /* @__PURE__ */ t.jsx(tt, {})
|
|
261
|
+
}
|
|
262
|
+
)
|
|
237
263
|
] }),
|
|
238
264
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
239
|
-
!
|
|
265
|
+
!a && /* @__PURE__ */ t.jsx(
|
|
240
266
|
f,
|
|
241
267
|
{
|
|
242
268
|
variant: "outline",
|
|
243
269
|
size: "icon",
|
|
244
270
|
onClick: () => o(r - 1),
|
|
245
271
|
disabled: r <= 1,
|
|
272
|
+
"aria-label": "上一页",
|
|
273
|
+
title: "上一页",
|
|
246
274
|
children: /* @__PURE__ */ t.jsx(de, {})
|
|
247
275
|
}
|
|
248
276
|
),
|
|
@@ -250,13 +278,17 @@ function ot({
|
|
|
250
278
|
Ee,
|
|
251
279
|
{
|
|
252
280
|
type: "number",
|
|
281
|
+
name: "pdf-page",
|
|
253
282
|
min: 1,
|
|
254
283
|
max: d,
|
|
255
284
|
value: r,
|
|
256
285
|
onChange: (e) => o(parseInt(e.target.value) || 1),
|
|
257
|
-
disabled:
|
|
258
|
-
readOnly:
|
|
259
|
-
|
|
286
|
+
disabled: a,
|
|
287
|
+
readOnly: a,
|
|
288
|
+
"aria-label": "当前页码",
|
|
289
|
+
inputMode: "numeric",
|
|
290
|
+
autoComplete: "off",
|
|
291
|
+
title: a ? "滚动模式下页码仅显示当前位置" : void 0,
|
|
260
292
|
className: "w-16 text-center"
|
|
261
293
|
}
|
|
262
294
|
),
|
|
@@ -264,30 +296,47 @@ function ot({
|
|
|
264
296
|
"/ ",
|
|
265
297
|
d
|
|
266
298
|
] }),
|
|
267
|
-
!
|
|
299
|
+
!a && /* @__PURE__ */ t.jsx(
|
|
268
300
|
f,
|
|
269
301
|
{
|
|
270
302
|
variant: "outline",
|
|
271
303
|
size: "icon",
|
|
272
304
|
onClick: () => o(r + 1),
|
|
273
305
|
disabled: d > 0 && r >= d,
|
|
306
|
+
"aria-label": "下一页",
|
|
307
|
+
title: "下一页",
|
|
274
308
|
children: /* @__PURE__ */ t.jsx(fe, {})
|
|
275
309
|
}
|
|
276
310
|
)
|
|
277
311
|
] })
|
|
278
312
|
]
|
|
279
313
|
}
|
|
280
|
-
) : null,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
314
|
+
) : null, Q = () => /* @__PURE__ */ t.jsx(
|
|
315
|
+
"div",
|
|
316
|
+
{
|
|
317
|
+
className: "flex h-full items-center justify-center",
|
|
318
|
+
role: "status",
|
|
319
|
+
"aria-live": "polite",
|
|
320
|
+
children: /* @__PURE__ */ t.jsx("p", { className: "text-muted-foreground", children: Ne })
|
|
321
|
+
}
|
|
322
|
+
), H = () => /* @__PURE__ */ t.jsx(
|
|
323
|
+
"div",
|
|
324
|
+
{
|
|
325
|
+
className: "flex h-full min-h-[400px] items-center justify-center px-4 text-center text-destructive",
|
|
326
|
+
role: "alert",
|
|
327
|
+
children: /* @__PURE__ */ t.jsxs("div", { className: "max-w-md", children: [
|
|
328
|
+
/* @__PURE__ */ t.jsx("p", { className: "mb-2 text-lg font-medium", children: "文件加载失败" }),
|
|
329
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-sm opacity-80", children: D == null ? void 0 : D.message })
|
|
330
|
+
] })
|
|
331
|
+
}
|
|
332
|
+
), Ve = () => {
|
|
333
|
+
if (!ae) return Q();
|
|
334
|
+
const { Document: e, Page: s } = ae;
|
|
286
335
|
return /* @__PURE__ */ t.jsx(
|
|
287
336
|
"div",
|
|
288
337
|
{
|
|
289
|
-
ref:
|
|
290
|
-
onScroll:
|
|
338
|
+
ref: W,
|
|
339
|
+
onScroll: a ? Le : void 0,
|
|
291
340
|
className: `pdf-container flex-1 overflow-y-auto ${ye || ""}`,
|
|
292
341
|
children: /* @__PURE__ */ t.jsx("div", { className: "flex min-h-full justify-center px-4", children: /* @__PURE__ */ t.jsx(
|
|
293
342
|
e,
|
|
@@ -295,17 +344,17 @@ function ot({
|
|
|
295
344
|
file: x,
|
|
296
345
|
onLoadError: $e,
|
|
297
346
|
options: We,
|
|
298
|
-
loading:
|
|
299
|
-
error:
|
|
347
|
+
loading: Q(),
|
|
348
|
+
error: H(),
|
|
300
349
|
onLoadSuccess: Se,
|
|
301
|
-
children:
|
|
350
|
+
children: D ? H() : g ? (
|
|
302
351
|
// 显示所有页面模式
|
|
303
352
|
Array.from(new Array(d), (i, n) => /* @__PURE__ */ t.jsx(
|
|
304
353
|
"div",
|
|
305
354
|
{
|
|
306
355
|
ref: (l) => Re(n + 1, l),
|
|
307
356
|
"data-page-number": n + 1,
|
|
308
|
-
className: `mb-4 ${
|
|
357
|
+
className: `mb-4 ${te || ""}`,
|
|
309
358
|
children: /* @__PURE__ */ t.jsx(
|
|
310
359
|
s,
|
|
311
360
|
{
|
|
@@ -314,8 +363,8 @@ function ot({
|
|
|
314
363
|
renderAnnotationLayer: !1,
|
|
315
364
|
width: le,
|
|
316
365
|
scale: p,
|
|
317
|
-
rotate:
|
|
318
|
-
onRenderSuccess: () =>
|
|
366
|
+
rotate: $,
|
|
367
|
+
onRenderSuccess: () => j == null ? void 0 : j(n + 1)
|
|
319
368
|
}
|
|
320
369
|
)
|
|
321
370
|
},
|
|
@@ -323,7 +372,7 @@ function ot({
|
|
|
323
372
|
))
|
|
324
373
|
) : (
|
|
325
374
|
// 单页模式
|
|
326
|
-
/* @__PURE__ */ t.jsx("div", { className:
|
|
375
|
+
/* @__PURE__ */ t.jsx("div", { className: te || "", children: /* @__PURE__ */ t.jsx(
|
|
327
376
|
s,
|
|
328
377
|
{
|
|
329
378
|
pageNumber: r,
|
|
@@ -331,8 +380,8 @@ function ot({
|
|
|
331
380
|
renderAnnotationLayer: !1,
|
|
332
381
|
width: le,
|
|
333
382
|
scale: p,
|
|
334
|
-
rotate:
|
|
335
|
-
onRenderSuccess: () =>
|
|
383
|
+
rotate: $,
|
|
384
|
+
onRenderSuccess: () => j == null ? void 0 : j(r)
|
|
336
385
|
}
|
|
337
386
|
) })
|
|
338
387
|
)
|
|
@@ -342,33 +391,33 @@ function ot({
|
|
|
342
391
|
}
|
|
343
392
|
);
|
|
344
393
|
}, Ze = () => {
|
|
345
|
-
if (!
|
|
394
|
+
if (!b || !O || !ne) return null;
|
|
346
395
|
const e = nt;
|
|
347
396
|
return /* @__PURE__ */ t.jsx(
|
|
348
397
|
e,
|
|
349
398
|
{
|
|
350
|
-
pdfDocument:
|
|
399
|
+
pdfDocument: ne,
|
|
351
400
|
currentPage: r,
|
|
352
401
|
onPageClick: _e,
|
|
353
402
|
components: {
|
|
354
|
-
Tabs:
|
|
355
|
-
TabsList:
|
|
356
|
-
TabsTrigger:
|
|
357
|
-
TabsContent:
|
|
358
|
-
ScrollArea:
|
|
403
|
+
Tabs: c.Tabs,
|
|
404
|
+
TabsList: c.TabsList,
|
|
405
|
+
TabsTrigger: c.TabsTrigger,
|
|
406
|
+
TabsContent: c.TabsContent,
|
|
407
|
+
ScrollArea: c.ScrollArea,
|
|
359
408
|
Skeleton: Oe
|
|
360
409
|
}
|
|
361
410
|
}
|
|
362
411
|
);
|
|
363
|
-
}, qe = () => !ve ||
|
|
412
|
+
}, qe = () => !ve || a ? null : /* @__PURE__ */ t.jsxs("div", { className: "fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 gap-2 md:hidden", children: [
|
|
364
413
|
/* @__PURE__ */ t.jsxs(
|
|
365
414
|
f,
|
|
366
415
|
{
|
|
367
416
|
variant: "secondary",
|
|
368
417
|
size: "sm",
|
|
369
418
|
onClick: () => o(r - 1),
|
|
370
|
-
disabled:
|
|
371
|
-
title:
|
|
419
|
+
disabled: a || r <= 1,
|
|
420
|
+
title: a ? "滚动模式下通过滚动定位页面" : void 0,
|
|
372
421
|
children: [
|
|
373
422
|
/* @__PURE__ */ t.jsx(de, {}),
|
|
374
423
|
/* @__PURE__ */ t.jsx("span", { className: "ml-1", children: "上一页" })
|
|
@@ -381,8 +430,8 @@ function ot({
|
|
|
381
430
|
variant: "secondary",
|
|
382
431
|
size: "sm",
|
|
383
432
|
onClick: () => o(r + 1),
|
|
384
|
-
disabled:
|
|
385
|
-
title:
|
|
433
|
+
disabled: a || r >= d,
|
|
434
|
+
title: a ? "滚动模式下通过滚动定位页面" : void 0,
|
|
386
435
|
children: [
|
|
387
436
|
/* @__PURE__ */ t.jsx("span", { className: "mr-1", children: "下一页" }),
|
|
388
437
|
/* @__PURE__ */ t.jsx(fe, {})
|
|
@@ -390,11 +439,11 @@ function ot({
|
|
|
390
439
|
}
|
|
391
440
|
)
|
|
392
441
|
] });
|
|
393
|
-
if (!
|
|
442
|
+
if (!c)
|
|
394
443
|
return /* @__PURE__ */ t.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
|
|
395
|
-
if (
|
|
444
|
+
if (b) {
|
|
396
445
|
const e = [];
|
|
397
|
-
if (
|
|
446
|
+
if (c.Tabs || e.push("Tabs"), c.TabsList || e.push("TabsList"), c.TabsTrigger || e.push("TabsTrigger"), c.TabsContent || e.push("TabsContent"), c.ScrollArea || e.push("ScrollArea"), e.length > 0) {
|
|
398
447
|
const s = e.length === 1 ? e[0] : `${e.slice(0, -1).join("、")} 和 ${e[e.length - 1]}`;
|
|
399
448
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 text-center text-destructive", children: [
|
|
400
449
|
"错误:侧边栏功能需要注入 ",
|
|
@@ -403,17 +452,17 @@ function ot({
|
|
|
403
452
|
] });
|
|
404
453
|
}
|
|
405
454
|
}
|
|
406
|
-
return /* @__PURE__ */ t.jsxs("div", { ref:
|
|
407
|
-
/* @__PURE__ */ t.jsxs(Ae, { className:
|
|
455
|
+
return /* @__PURE__ */ t.jsxs("div", { ref: ce, children: [
|
|
456
|
+
/* @__PURE__ */ t.jsxs(Ae, { className: je, children: [
|
|
408
457
|
Be(),
|
|
409
458
|
/* @__PURE__ */ t.jsx(
|
|
410
459
|
Ie,
|
|
411
460
|
{
|
|
412
461
|
className: "p-0",
|
|
413
|
-
style: { height:
|
|
462
|
+
style: { height: E ? "100vh" : Te },
|
|
414
463
|
children: /* @__PURE__ */ t.jsx("div", { className: "flex h-full flex-col", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
415
464
|
Ze(),
|
|
416
|
-
Ce ?
|
|
465
|
+
Ce ? Q() : D ? H() : Ve()
|
|
417
466
|
] }) })
|
|
418
467
|
}
|
|
419
468
|
)
|