@frontera-sdk/chat-ui 1.50.40
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/LICENSE +202 -0
- package/README.md +348 -0
- package/dist/af-DK_CjRn6-OPBHDTNZ.js +197 -0
- package/dist/agent-picker.d.ts +38 -0
- package/dist/agent-picker.js +8 -0
- package/dist/as-BPtSu6VN-O4ZZEAJG.js +11 -0
- package/dist/be-CrQ0smca-5HIE5K27.js +11 -0
- package/dist/bg-CrQqGwni-3IRVPZQ7.js +11 -0
- package/dist/bn-NCLZcWHi-XOZJFNIB.js +11 -0
- package/dist/ca-SUf6Y2Om-V6F2EBCA.js +38 -0
- package/dist/capture-NO5ZIGP6.js +1652 -0
- package/dist/chat.css +3555 -0
- package/dist/chat.d.ts +161 -0
- package/dist/chat.js +60498 -0
- package/dist/chunk-2KEBRV3W.js +191 -0
- package/dist/chunk-6BPHEBCF.js +639 -0
- package/dist/chunk-6HYPVNVA.js +25 -0
- package/dist/chunk-7ADM3CKD.js +10 -0
- package/dist/chunk-AFVU5VT6.js +5601 -0
- package/dist/chunk-BEJ3HQG4.js +93 -0
- package/dist/chunk-CCVPZVFK.js +28 -0
- package/dist/chunk-DGDHKMDB.js +10 -0
- package/dist/chunk-FXKXDR5K.js +2166 -0
- package/dist/chunk-GTQH7MPF.js +129 -0
- package/dist/chunk-I7SXWUAN.js +1258 -0
- package/dist/chunk-IQRPGFLI.js +234 -0
- package/dist/chunk-IXDM5R55.js +23 -0
- package/dist/chunk-JD6ETTXC.js +178 -0
- package/dist/chunk-OP4MLJDA.js +215 -0
- package/dist/chunk-PQZ2CS26.js +2315 -0
- package/dist/chunk-PR4QN5HX.js +38 -0
- package/dist/chunk-PUIVKDV5.js +271 -0
- package/dist/chunk-QSSFBZAS.js +6914 -0
- package/dist/chunk-RAKKA3WU.js +5896 -0
- package/dist/chunk-RB2Y4NYC.js +681 -0
- package/dist/chunk-VDZH5Z3K.js +72 -0
- package/dist/chunk-WMN6BPPS.js +49 -0
- package/dist/chunk-WO6DJLFE.js +10857 -0
- package/dist/chunk-X5E2DJVO.js +47634 -0
- package/dist/chunk-XJFTVKLW.js +2687 -0
- package/dist/chunk-ZS6PXIZP.js +187 -0
- package/dist/client.d.ts +89 -0
- package/dist/client.js +20 -0
- package/dist/composer.d.ts +23 -0
- package/dist/composer.js +89 -0
- package/dist/cop-C3sk0IUo-CIZA2H43.js +11 -0
- package/dist/credential.d.ts +75 -0
- package/dist/credential.js +3 -0
- package/dist/cs-CmAteokq-HAKEQPB4.js +17 -0
- package/dist/cu-CBUlrW6Y-QTZ6ZLA4.js +32 -0
- package/dist/cy-BBPa6z2x-MX6DGDNW.js +11 -0
- package/dist/da-CCDXfXtG-5YEOHMG3.js +11 -0
- package/dist/de-1901-CWoAOigE-63QFSF2A.js +11 -0
- package/dist/de-1996-BL6awyxG-R2PHKMAB.js +11 -0
- package/dist/de-ch-1901-hVThVHVb-JSDB53OZ.js +11 -0
- package/dist/el-monoton-D3aKqTz2-2V4OOFBB.js +11 -0
- package/dist/el-polyton-ogVWcTzh-3U7NGQMT.js +11 -0
- package/dist/en-gb-B7Al27b_-UKCBQFSU.js +21 -0
- package/dist/es-DcaaHPU_-NOBXSOZK.js +11 -0
- package/dist/esm-MHF25KDL.js +3 -0
- package/dist/et-B_spaleu-5UAYIW62.js +11 -0
- package/dist/eu-Ctv_kq9Z-V5DREOPN.js +11 -0
- package/dist/fi-RW5VB8Yp-YSXBK7LW.js +11 -0
- package/dist/fr-BC2onEz9-7KH5T76G.js +11 -0
- package/dist/frame.d.ts +59 -0
- package/dist/frame.js +111 -0
- package/dist/fur-AC12wySk-4PD2Y72H.js +11 -0
- package/dist/ga-Cn6LkudM-RRAAJT3N.js +58 -0
- package/dist/gl-DZGc-K_G-KYSXXTCY.js +11 -0
- package/dist/grc-DOlGgO8T-2HXBZVJ5.js +11 -0
- package/dist/gu-Bjl0l-cf-4CFSVZHZ.js +11 -0
- package/dist/header.d.ts +78 -0
- package/dist/header.js +18 -0
- package/dist/hi-DsAaTPCC-KMCFBWK7.js +11 -0
- package/dist/hr-DT1SBBes-X2TIX6EI.js +11 -0
- package/dist/hsb-DC_ITc1e-PXLERA7R.js +46 -0
- package/dist/hu-DVk7Y_ka-PJPVU54B.js +11 -0
- package/dist/hy-e995ysyO-MZBRFX52.js +11 -0
- package/dist/ia-Cr4TJH0c-D3O2FHGP.js +22 -0
- package/dist/id-DifDyWg9-MZ2BGHWI.js +58 -0
- package/dist/is-BT8UVRze-CZZCKEFI.js +11 -0
- package/dist/it-Bt_Meacx-T4Y5JYV6.js +11 -0
- package/dist/ka-jyoLzyDE-ES6EXZLW.js +11 -0
- package/dist/kmr-Cfwhwuff-TSW2R2KS.js +11 -0
- package/dist/kn-C6Lov-DP-B4BL47CE.js +11 -0
- package/dist/la-DuvHjUWw-6K7TFU6X.js +11 -0
- package/dist/la-x-classic-yTyAOQEt-YWTKMM2L.js +11 -0
- package/dist/la-x-liturgic-CXeQb4FY-B772L5E7.js +11 -0
- package/dist/lib-3ZKX25RJ.js +4511 -0
- package/dist/lt-BBe8DlDF-4YINVOZR.js +11 -0
- package/dist/lv-Q2BBHnzp-TMVQ3MX2.js +11 -0
- package/dist/message.d.ts +64 -0
- package/dist/message.js +18 -0
- package/dist/ml-2xLVYkVY-NGZLAPIN.js +11 -0
- package/dist/mn-cyrl-lHM4n0oC-DGBYYUT3.js +11 -0
- package/dist/mn-cyrl-x-lmc-3aetruI8-QHJABMOO.js +11 -0
- package/dist/mr-CjWJPVmH-X5UHV65O.js +11 -0
- package/dist/mul-ethi-D_CMSMEq-H7UMQSOQ.js +11 -0
- package/dist/nb-DI8u59ch-J4CAVI4Y.js +122 -0
- package/dist/new-session-Dw7JOgzu.d.ts +141 -0
- package/dist/new-session.d.ts +4 -0
- package/dist/new-session.js +10 -0
- package/dist/nl-BHQJ6Gvn-7BH55RA7.js +52 -0
- package/dist/nn-ntZvarUK-KKNCHHJ4.js +122 -0
- package/dist/no-B8ItS0F3-3ZXIRJ6U.js +120 -0
- package/dist/oauth-callback.d.ts +35 -0
- package/dist/oauth-callback.js +18 -0
- package/dist/oc-P_i3-xLA-XZM6E5YZ.js +11 -0
- package/dist/or-50rxpoq4-5VELAFMJ.js +11 -0
- package/dist/pa-C54UG8eN-WEJPMZ6Z.js +11 -0
- package/dist/parts.d.ts +49 -0
- package/dist/parts.js +106 -0
- package/dist/pdf-cover-thumbnail-inner-4N2Q5AAG.js +36 -0
- package/dist/pdf-deck-view-inner-FZVLAEQR.js +575 -0
- package/dist/pdf-document-view-inner-6DF54JWK.js +585 -0
- package/dist/pdf-viewer-inner-GPES3KG2.js +256 -0
- package/dist/pending-cards.d.ts +26 -0
- package/dist/pending-cards.js +9 -0
- package/dist/pi-B9cgjyG1-GD5ASDDU.js +11 -0
- package/dist/pl-9fg-ESVt-UMX7MCJM.js +32 -0
- package/dist/platform.css +4013 -0
- package/dist/pms-BRGfm5gS-SSE3AUW5.js +11 -0
- package/dist/pt-Cum2_NUC-W35JYVR4.js +11 -0
- package/dist/rm-C0MIK9N4-IWL4YTNT.js +11 -0
- package/dist/ro-0fmdH0HA-46WUTOYH.js +11 -0
- package/dist/ru-v4l-ayaq-BUGK6XCN.js +196 -0
- package/dist/sa-CKY9c_Vq-4KIJOI5Y.js +11 -0
- package/dist/sh-cyrl-BpCRFOmq-DSLQ4UY2.js +128 -0
- package/dist/sh-latn-sRy4Tuaj-UNQOR63V.js +128 -0
- package/dist/sk-_iOeDNrQ-NCTQKH25.js +17 -0
- package/dist/sl-DpiklF-D-6GG5TDVN.js +11 -0
- package/dist/sr-cyrl-Dpzrbd0W-4Q5226YJ.js +142 -0
- package/dist/sv-CFm5y56M-VTWNPZ7I.js +11 -0
- package/dist/ta-BcghgTbD-NRT35DW6.js +11 -0
- package/dist/te-B5Spl2Jk-5VE6CLN4.js +11 -0
- package/dist/th-DWX5iPSo-N5GMOQOP.js +11 -0
- package/dist/theme.d.ts +49 -0
- package/dist/theme.js +3 -0
- package/dist/tk-BMbKB10q-HGWWY5L3.js +11 -0
- package/dist/tr-CIHIuzqc-6ISBNYLV.js +11 -0
- package/dist/types-BDqLaBfH.d.ts +60 -0
- package/dist/uk-Dir3oxLs-YQ3QZRI4.js +11 -0
- package/dist/univer-workbook-BSSUE5TG.css +3555 -0
- package/dist/univer-workbook-N5IIN7CH.js +290849 -0
- package/dist/vega-chart-block-NQADYNWQ.js +2857 -0
- package/dist/zh-latn-pinyin-BdYb-Ey_-RB542AHF.js +11 -0
- package/package.json +137 -0
- package/src/styles.css +996 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { DeckNotesCard, deckOwnsArrowKeys } from './chunk-WMN6BPPS.js';
|
|
3
|
+
import { resolveStageWidth, zoomPercent, DECK_ZOOM_LEVELS, LazyThumb, ArtifactSkeleton } from './chunk-PUIVKDV5.js';
|
|
4
|
+
import { useTranslation } from './chunk-QSSFBZAS.js';
|
|
5
|
+
import { Button, ScrollArea } from './chunk-GTQH7MPF.js';
|
|
6
|
+
import { useIsMobile } from './chunk-IXDM5R55.js';
|
|
7
|
+
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from './chunk-ZS6PXIZP.js';
|
|
8
|
+
import { cn } from './chunk-DGDHKMDB.js';
|
|
9
|
+
import { ChevronDownMediumIcon, ChevronLeftIcon, ChevronRightIcon } from './chunk-AFVU5VT6.js';
|
|
10
|
+
import './chunk-PR4QN5HX.js';
|
|
11
|
+
import { useState, useRef, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
12
|
+
import { pdfjs, Document, Page } from 'react-pdf';
|
|
13
|
+
import 'react-pdf/dist/Page/TextLayer.css';
|
|
14
|
+
import 'react-pdf/dist/Page/AnnotationLayer.css';
|
|
15
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
16
|
+
|
|
17
|
+
pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
|
|
18
|
+
var THUMB_W = 120;
|
|
19
|
+
var COMPACT_THUMB_W = 76;
|
|
20
|
+
var COMPACT_PANEL_WIDTH = 700;
|
|
21
|
+
var COMPACT_RAIL_CLOSE_DELAY_MS = 60;
|
|
22
|
+
var STRIP_THUMB_W = 112;
|
|
23
|
+
var HOLD_PREVIOUS_MAX_MS = 1500;
|
|
24
|
+
var PDF_OPTIONS = { verbosity: pdfjs.VerbosityLevel?.ERRORS ?? 0 };
|
|
25
|
+
function PdfDeckViewInner({
|
|
26
|
+
fileUrl,
|
|
27
|
+
label,
|
|
28
|
+
notes,
|
|
29
|
+
onError
|
|
30
|
+
}) {
|
|
31
|
+
const { t } = useTranslation();
|
|
32
|
+
const isMobile = useIsMobile();
|
|
33
|
+
const [compact, setCompact] = useState(false);
|
|
34
|
+
const [compactRailOpen, setCompactRailOpen] = useState(false);
|
|
35
|
+
const [pages, setPages] = useState(0);
|
|
36
|
+
const [loadedFileUrl, setLoadedFileUrl] = useState(null);
|
|
37
|
+
const [sel, setSel] = useState(0);
|
|
38
|
+
const [zoom, setZoom] = useState("fit");
|
|
39
|
+
const [pageDims, setPageDims] = useState(null);
|
|
40
|
+
const [paintedPage, setPaintedPage] = useState(null);
|
|
41
|
+
const [box, setBox] = useState(null);
|
|
42
|
+
const [hostEl, setHostEl] = useState(null);
|
|
43
|
+
const viewerRef = useRef(null);
|
|
44
|
+
const railRef = useRef(null);
|
|
45
|
+
const hoverRef = useRef(false);
|
|
46
|
+
const selRef = useRef(0);
|
|
47
|
+
const compactRailCloseTimerRef = useRef(
|
|
48
|
+
null
|
|
49
|
+
);
|
|
50
|
+
const currentFileUrlRef = useRef(fileUrl);
|
|
51
|
+
currentFileUrlRef.current = fileUrl;
|
|
52
|
+
useEffect(
|
|
53
|
+
() => () => {
|
|
54
|
+
if (compactRailCloseTimerRef.current) {
|
|
55
|
+
clearTimeout(compactRailCloseTimerRef.current);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
[]
|
|
59
|
+
);
|
|
60
|
+
const visiblePages = loadedFileUrl === fileUrl ? pages : 0;
|
|
61
|
+
const last = visiblePages - 1;
|
|
62
|
+
useEffect(() => () => setLoadedFileUrl(null), []);
|
|
63
|
+
const next = useCallback(
|
|
64
|
+
() => setSel(
|
|
65
|
+
(value) => Math.min(Math.max(0, visiblePages - 1), value + 1)
|
|
66
|
+
),
|
|
67
|
+
[visiblePages]
|
|
68
|
+
);
|
|
69
|
+
const prev = useCallback(() => setSel((v) => Math.max(0, v - 1)), []);
|
|
70
|
+
const openCompactRail = useCallback(() => {
|
|
71
|
+
if (compactRailCloseTimerRef.current) {
|
|
72
|
+
clearTimeout(compactRailCloseTimerRef.current);
|
|
73
|
+
compactRailCloseTimerRef.current = null;
|
|
74
|
+
}
|
|
75
|
+
setCompactRailOpen(true);
|
|
76
|
+
}, []);
|
|
77
|
+
const closeCompactRail = useCallback(() => {
|
|
78
|
+
if (compactRailCloseTimerRef.current) {
|
|
79
|
+
clearTimeout(compactRailCloseTimerRef.current);
|
|
80
|
+
}
|
|
81
|
+
compactRailCloseTimerRef.current = setTimeout(() => {
|
|
82
|
+
setCompactRailOpen(false);
|
|
83
|
+
compactRailCloseTimerRef.current = null;
|
|
84
|
+
}, COMPACT_RAIL_CLOSE_DELAY_MS);
|
|
85
|
+
}, []);
|
|
86
|
+
useEffect(
|
|
87
|
+
() => () => {
|
|
88
|
+
if (compactRailCloseTimerRef.current) {
|
|
89
|
+
clearTimeout(compactRailCloseTimerRef.current);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[]
|
|
93
|
+
);
|
|
94
|
+
useLayoutEffect(() => {
|
|
95
|
+
const viewer = viewerRef.current;
|
|
96
|
+
if (!viewer) return;
|
|
97
|
+
const compute = () => {
|
|
98
|
+
const nextCompact = viewer.clientWidth < COMPACT_PANEL_WIDTH;
|
|
99
|
+
setCompact(nextCompact);
|
|
100
|
+
if (!nextCompact) setCompactRailOpen(false);
|
|
101
|
+
};
|
|
102
|
+
compute();
|
|
103
|
+
const observer = new ResizeObserver(compute);
|
|
104
|
+
observer.observe(viewer);
|
|
105
|
+
return () => observer.disconnect();
|
|
106
|
+
}, []);
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
if (!hostEl) return;
|
|
109
|
+
const compute = () => {
|
|
110
|
+
const cs = getComputedStyle(hostEl);
|
|
111
|
+
const padX = (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
|
|
112
|
+
const padY = (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0);
|
|
113
|
+
const w = hostEl.clientWidth - padX;
|
|
114
|
+
const h = hostEl.clientHeight - padY;
|
|
115
|
+
if (w > 0 && h > 0) setBox({ w, h });
|
|
116
|
+
};
|
|
117
|
+
compute();
|
|
118
|
+
const ro = new ResizeObserver(compute);
|
|
119
|
+
ro.observe(hostEl);
|
|
120
|
+
return () => ro.disconnect();
|
|
121
|
+
}, [hostEl]);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const onKey = (e) => {
|
|
124
|
+
if (!deckOwnsArrowKeys(viewerRef.current, hoverRef.current, e.target)) return;
|
|
125
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown" || e.key === "PageDown" || e.key === " ") {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
next();
|
|
128
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowUp" || e.key === "PageUp") {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
prev();
|
|
131
|
+
} else if (e.key === "Home") {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
setSel(0);
|
|
134
|
+
} else if (e.key === "End") {
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
setSel(Math.max(0, pages - 1));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
window.addEventListener("keydown", onKey);
|
|
140
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
141
|
+
}, [next, prev, visiblePages]);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (visiblePages === 0) return;
|
|
144
|
+
if (compact && !compactRailOpen) return;
|
|
145
|
+
const active = railRef.current?.querySelector('[data-active="true"]');
|
|
146
|
+
active?.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
147
|
+
const focusIsInRail = document.activeElement instanceof HTMLElement && railRef.current?.contains(document.activeElement);
|
|
148
|
+
if (focusIsInRail && active instanceof HTMLElement) {
|
|
149
|
+
active.focus({ preventScroll: true });
|
|
150
|
+
}
|
|
151
|
+
}, [compact, compactRailOpen, sel, visiblePages]);
|
|
152
|
+
const stageWidth = pageDims ? resolveStageWidth({ zoom, pageW: pageDims.w, pageH: pageDims.h, boxW: box?.w ?? 0, boxH: box?.h ?? 0 }) : 0;
|
|
153
|
+
const stageHeight = pageDims && stageWidth > 0 ? Math.round(stageWidth * pageDims.h / pageDims.w) : 0;
|
|
154
|
+
const stageScale = pageDims && stageWidth > 0 ? stageWidth / pageDims.w : 1;
|
|
155
|
+
const pct = pageDims ? zoomPercent(stageWidth, pageDims.w) : null;
|
|
156
|
+
const zoomLabel = zoom === "fit" ? pct !== null ? `${pct}%` : t("deck.zoomFit") : `${Math.round(zoom * 100)}%`;
|
|
157
|
+
const thumbH = pageDims ? Math.round(THUMB_W * pageDims.h / pageDims.w) : Math.round(THUMB_W * 9 / 16);
|
|
158
|
+
const compactThumbH = pageDims ? Math.round(COMPACT_THUMB_W * pageDims.h / pageDims.w) : Math.round(COMPACT_THUMB_W * 9 / 16);
|
|
159
|
+
const stripThumbH = pageDims ? Math.round(STRIP_THUMB_W * pageDims.h / pageDims.w) : Math.round(STRIP_THUMB_W * 9 / 16);
|
|
160
|
+
selRef.current = sel;
|
|
161
|
+
const activeNote = notes?.[sel];
|
|
162
|
+
const handlePageRendered = useCallback(() => {
|
|
163
|
+
setPaintedPage((current) => current === selRef.current ? current : selRef.current);
|
|
164
|
+
}, []);
|
|
165
|
+
const stagePages = paintedPage !== null && paintedPage !== sel ? [paintedPage, sel].sort((a, b) => a - b) : [sel];
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (paintedPage === null || paintedPage === sel) return;
|
|
168
|
+
const timer = setTimeout(() => setPaintedPage(sel), HOLD_PREVIOUS_MAX_MS);
|
|
169
|
+
return () => clearTimeout(timer);
|
|
170
|
+
}, [paintedPage, sel]);
|
|
171
|
+
return /* @__PURE__ */ jsxs(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
ref: viewerRef,
|
|
175
|
+
className: "relative flex h-full min-h-0 flex-col bg-muted/30",
|
|
176
|
+
onMouseEnter: () => {
|
|
177
|
+
hoverRef.current = true;
|
|
178
|
+
},
|
|
179
|
+
onMouseLeave: () => {
|
|
180
|
+
hoverRef.current = false;
|
|
181
|
+
},
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center justify-between gap-2 px-3 py-1.5 border-b border-border-secondary", children: [
|
|
184
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: label ?? "" }),
|
|
185
|
+
/* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
186
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
187
|
+
Button,
|
|
188
|
+
{
|
|
189
|
+
variant: "ghost",
|
|
190
|
+
className: "gap-1 px-2 text-xs tabular-nums text-muted-foreground hover:text-foreground",
|
|
191
|
+
"aria-label": t("deck.zoom"),
|
|
192
|
+
children: [
|
|
193
|
+
zoomLabel,
|
|
194
|
+
/* @__PURE__ */ jsx(ChevronDownMediumIcon, { className: "size-3.5" })
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
) }),
|
|
198
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-28", children: [
|
|
199
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => setZoom("fit"), className: cn(zoom === "fit" && "font-medium"), children: t("deck.zoomFit") }),
|
|
200
|
+
DECK_ZOOM_LEVELS.map((z) => /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => setZoom(z), className: cn(zoom === z && "font-medium"), children: [
|
|
201
|
+
Math.round(z * 100),
|
|
202
|
+
"%"
|
|
203
|
+
] }, z))
|
|
204
|
+
] })
|
|
205
|
+
] }) })
|
|
206
|
+
] }),
|
|
207
|
+
/* @__PURE__ */ jsxs(
|
|
208
|
+
Document,
|
|
209
|
+
{
|
|
210
|
+
file: fileUrl,
|
|
211
|
+
options: PDF_OPTIONS,
|
|
212
|
+
onLoadSuccess: (doc) => {
|
|
213
|
+
if (doc.loadingTask.destroyed) return;
|
|
214
|
+
const loadedUrl = fileUrl;
|
|
215
|
+
setLoadedFileUrl(loadedUrl);
|
|
216
|
+
setPages(doc.numPages);
|
|
217
|
+
setSel(0);
|
|
218
|
+
setPageDims(null);
|
|
219
|
+
void doc.getPage(1).then((page) => {
|
|
220
|
+
if (currentFileUrlRef.current !== loadedUrl) return;
|
|
221
|
+
const viewport = page.getViewport({ scale: 1 });
|
|
222
|
+
setPageDims({ w: viewport.width, h: viewport.height });
|
|
223
|
+
}).catch(() => {
|
|
224
|
+
if (currentFileUrlRef.current === loadedUrl) onError();
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
onLoadError: onError,
|
|
228
|
+
loading: /* @__PURE__ */ jsx(ArtifactSkeleton, { format: "htmldeck", showChrome: false }),
|
|
229
|
+
error: /* @__PURE__ */ jsx("div", { className: "p-6 text-sm text-muted-foreground", children: t("library.failedToLoad") }),
|
|
230
|
+
className: cn(
|
|
231
|
+
"flex min-h-0 flex-1 [&>.react-pdf__message]:min-w-0 [&>.react-pdf__message]:flex-1",
|
|
232
|
+
isMobile ? "flex-col" : "flex-row"
|
|
233
|
+
),
|
|
234
|
+
children: [
|
|
235
|
+
!isMobile && compact && /* @__PURE__ */ jsxs(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
className: "relative flex min-h-0 w-11 shrink-0 items-center justify-center",
|
|
239
|
+
onMouseEnter: openCompactRail,
|
|
240
|
+
onMouseLeave: closeCompactRail,
|
|
241
|
+
onFocusCapture: openCompactRail,
|
|
242
|
+
onBlurCapture: (event) => {
|
|
243
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
244
|
+
closeCompactRail();
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ jsx(
|
|
249
|
+
"button",
|
|
250
|
+
{
|
|
251
|
+
type: "button",
|
|
252
|
+
className: "flex h-11 w-11 flex-col items-center justify-center gap-1.5 bg-transparent p-0 outline-none focus-visible:ring-2 focus-visible:ring-ring/60",
|
|
253
|
+
"aria-label": t("deck.showSlides"),
|
|
254
|
+
"aria-expanded": compactRailOpen,
|
|
255
|
+
onClick: (event) => {
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
openCompactRail();
|
|
258
|
+
},
|
|
259
|
+
children: Array.from({ length: visiblePages }, (_, slideIndex) => /* @__PURE__ */ jsx(
|
|
260
|
+
"span",
|
|
261
|
+
{
|
|
262
|
+
"data-slide-indicator": slideIndex,
|
|
263
|
+
"data-active": slideIndex === sel,
|
|
264
|
+
"aria-hidden": true,
|
|
265
|
+
className: cn(
|
|
266
|
+
"h-0.5 w-5 shrink-0 transition-colors",
|
|
267
|
+
slideIndex === sel ? "bg-foreground" : "bg-muted-foreground/20"
|
|
268
|
+
)
|
|
269
|
+
},
|
|
270
|
+
slideIndex
|
|
271
|
+
))
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
/* @__PURE__ */ jsx(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
role: "dialog",
|
|
278
|
+
"aria-label": t("deck.showSlides"),
|
|
279
|
+
"aria-hidden": !compactRailOpen,
|
|
280
|
+
inert: !compactRailOpen,
|
|
281
|
+
"data-testid": "compact-slide-overlay",
|
|
282
|
+
"data-state": compactRailOpen ? "open" : "closed",
|
|
283
|
+
className: cn(
|
|
284
|
+
"absolute left-3 top-1/2 z-50 max-h-[70vh] w-36 -translate-y-1/2 overflow-hidden rounded-xl border border-border bg-surface-overlay p-1.5 shadow-lg transition-opacity duration-[120ms] ease-out will-change-opacity motion-reduce:transition-none",
|
|
285
|
+
compactRailOpen ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"
|
|
286
|
+
),
|
|
287
|
+
children: /* @__PURE__ */ jsx(
|
|
288
|
+
"div",
|
|
289
|
+
{
|
|
290
|
+
ref: railRef,
|
|
291
|
+
className: "max-h-[calc(70vh-0.75rem)] overflow-y-auto scrollbar",
|
|
292
|
+
children: Array.from({ length: visiblePages }, (_, i) => /* @__PURE__ */ jsxs(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
type: "button",
|
|
296
|
+
"data-active": i === sel,
|
|
297
|
+
onClick: () => setSel(i),
|
|
298
|
+
className: cn(
|
|
299
|
+
"flex w-full items-start gap-2 rounded-lg p-1.5 text-left transition-colors",
|
|
300
|
+
i === sel ? "bg-surface-active" : "hover:bg-surface-overlay-hover"
|
|
301
|
+
),
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsx(
|
|
304
|
+
"span",
|
|
305
|
+
{
|
|
306
|
+
className: cn(
|
|
307
|
+
"w-3 shrink-0 pt-0.5 text-right text-xs tabular-nums",
|
|
308
|
+
i === sel ? "font-semibold text-foreground" : "text-muted-foreground"
|
|
309
|
+
),
|
|
310
|
+
children: i + 1
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
/* @__PURE__ */ jsx(
|
|
314
|
+
"div",
|
|
315
|
+
{
|
|
316
|
+
className: cn(
|
|
317
|
+
"shrink-0 overflow-hidden rounded-md border bg-surface shadow-sm",
|
|
318
|
+
i === sel ? "border-transparent ring ring-foreground" : "border-border"
|
|
319
|
+
),
|
|
320
|
+
children: /* @__PURE__ */ jsx(
|
|
321
|
+
LazyThumb,
|
|
322
|
+
{
|
|
323
|
+
width: COMPACT_THUMB_W,
|
|
324
|
+
height: compactThumbH,
|
|
325
|
+
className: "bg-muted",
|
|
326
|
+
children: /* @__PURE__ */ jsx(
|
|
327
|
+
Page,
|
|
328
|
+
{
|
|
329
|
+
pageNumber: i + 1,
|
|
330
|
+
width: COMPACT_THUMB_W,
|
|
331
|
+
renderTextLayer: false,
|
|
332
|
+
renderAnnotationLayer: false,
|
|
333
|
+
loading: /* @__PURE__ */ jsx(
|
|
334
|
+
"div",
|
|
335
|
+
{
|
|
336
|
+
style: { width: COMPACT_THUMB_W, height: compactThumbH },
|
|
337
|
+
className: "animate-pulse bg-muted"
|
|
338
|
+
}
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
]
|
|
347
|
+
},
|
|
348
|
+
i
|
|
349
|
+
))
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
),
|
|
357
|
+
!isMobile && !compact && /* @__PURE__ */ jsx(
|
|
358
|
+
ScrollArea,
|
|
359
|
+
{
|
|
360
|
+
scrollbars: "both",
|
|
361
|
+
className: "w-full shrink-0 border-b border-border sm:w-[164px]",
|
|
362
|
+
children: /* @__PURE__ */ jsx("div", { ref: railRef, className: "flex flex-row gap-1 p-2 sm:flex-col", children: Array.from({ length: visiblePages }, (_, i) => /* @__PURE__ */ jsxs(
|
|
363
|
+
"button",
|
|
364
|
+
{
|
|
365
|
+
type: "button",
|
|
366
|
+
"data-active": i === sel,
|
|
367
|
+
onClick: () => setSel(i),
|
|
368
|
+
className: cn(
|
|
369
|
+
"flex w-fit shrink-0 items-start gap-1.5 rounded-md p-2 text-left transition-colors",
|
|
370
|
+
i === sel ? "bg-surface-active" : "hover:bg-muted/60"
|
|
371
|
+
),
|
|
372
|
+
children: [
|
|
373
|
+
/* @__PURE__ */ jsx(
|
|
374
|
+
"span",
|
|
375
|
+
{
|
|
376
|
+
className: cn(
|
|
377
|
+
"w-3 shrink-0 pt-0.5 text-right text-xs tabular-nums",
|
|
378
|
+
i === sel ? "font-semibold text-foreground" : "text-muted-foreground"
|
|
379
|
+
),
|
|
380
|
+
children: i + 1
|
|
381
|
+
}
|
|
382
|
+
),
|
|
383
|
+
/* @__PURE__ */ jsx(
|
|
384
|
+
"div",
|
|
385
|
+
{
|
|
386
|
+
className: cn(
|
|
387
|
+
"w-[120px] shrink-0 overflow-hidden rounded border bg-surface shadow-sm",
|
|
388
|
+
i === sel ? "border-transparent ring ring-foreground" : "border-border"
|
|
389
|
+
),
|
|
390
|
+
children: /* @__PURE__ */ jsx(LazyThumb, { width: THUMB_W, height: thumbH, className: "bg-muted", children: /* @__PURE__ */ jsx(
|
|
391
|
+
Page,
|
|
392
|
+
{
|
|
393
|
+
pageNumber: i + 1,
|
|
394
|
+
width: THUMB_W,
|
|
395
|
+
renderTextLayer: false,
|
|
396
|
+
renderAnnotationLayer: false,
|
|
397
|
+
loading: /* @__PURE__ */ jsx(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
style: { width: THUMB_W, height: thumbH },
|
|
401
|
+
className: "animate-pulse bg-muted"
|
|
402
|
+
}
|
|
403
|
+
)
|
|
404
|
+
}
|
|
405
|
+
) })
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
]
|
|
409
|
+
},
|
|
410
|
+
i
|
|
411
|
+
)) })
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
/* @__PURE__ */ jsxs(
|
|
415
|
+
"div",
|
|
416
|
+
{
|
|
417
|
+
className: "group/stage relative flex min-w-0 flex-1 flex-col",
|
|
418
|
+
onMouseEnter: () => {
|
|
419
|
+
hoverRef.current = true;
|
|
420
|
+
},
|
|
421
|
+
onMouseLeave: () => {
|
|
422
|
+
hoverRef.current = false;
|
|
423
|
+
},
|
|
424
|
+
children: [
|
|
425
|
+
/* @__PURE__ */ jsx(
|
|
426
|
+
"div",
|
|
427
|
+
{
|
|
428
|
+
ref: setHostEl,
|
|
429
|
+
className: "flex min-h-0 flex-1 flex-col items-center overflow-auto scrollbar p-3 sm:p-6",
|
|
430
|
+
children: visiblePages > 0 && stageWidth > 0 && pageDims && /* @__PURE__ */ jsxs("div", { className: "m-auto flex w-fit flex-col items-center gap-4", children: [
|
|
431
|
+
/* @__PURE__ */ jsx(
|
|
432
|
+
"div",
|
|
433
|
+
{
|
|
434
|
+
"data-testid": "pdf-stage",
|
|
435
|
+
"data-width": stageWidth,
|
|
436
|
+
className: "overflow-hidden rounded-md border border-border bg-surface shadow-sm",
|
|
437
|
+
style: { width: stageWidth, height: stageHeight },
|
|
438
|
+
children: /* @__PURE__ */ jsx(
|
|
439
|
+
"div",
|
|
440
|
+
{
|
|
441
|
+
className: "relative",
|
|
442
|
+
style: {
|
|
443
|
+
width: pageDims.w,
|
|
444
|
+
height: pageDims.h,
|
|
445
|
+
transform: `scale(${stageScale})`,
|
|
446
|
+
transformOrigin: "left top"
|
|
447
|
+
},
|
|
448
|
+
children: stagePages.map((pageIndex) => /* @__PURE__ */ jsx(
|
|
449
|
+
"div",
|
|
450
|
+
{
|
|
451
|
+
className: pageIndex === sel ? "h-full w-full" : "pointer-events-none absolute inset-0 z-10",
|
|
452
|
+
children: /* @__PURE__ */ jsx(
|
|
453
|
+
Page,
|
|
454
|
+
{
|
|
455
|
+
pageNumber: pageIndex + 1,
|
|
456
|
+
width: pageDims.w,
|
|
457
|
+
renderTextLayer: false,
|
|
458
|
+
renderAnnotationLayer: false,
|
|
459
|
+
loading: null,
|
|
460
|
+
onRenderSuccess: pageIndex === sel ? handlePageRendered : void 0
|
|
461
|
+
}
|
|
462
|
+
)
|
|
463
|
+
},
|
|
464
|
+
pageIndex
|
|
465
|
+
))
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
}
|
|
469
|
+
),
|
|
470
|
+
activeNote?.trim() ? /* @__PURE__ */ jsx(DeckNotesCard, { text: activeNote, width: stageWidth }) : null
|
|
471
|
+
] })
|
|
472
|
+
}
|
|
473
|
+
),
|
|
474
|
+
!isMobile && !compact && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
475
|
+
/* @__PURE__ */ jsx(
|
|
476
|
+
"button",
|
|
477
|
+
{
|
|
478
|
+
type: "button",
|
|
479
|
+
onClick: prev,
|
|
480
|
+
disabled: sel === 0,
|
|
481
|
+
title: t("deck.prevPage"),
|
|
482
|
+
"aria-label": t("deck.prevPage"),
|
|
483
|
+
className: "absolute left-3 top-1/2 z-10 inline-flex size-9 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-background/80 text-foreground opacity-0 shadow-sm backdrop-blur transition hover:bg-muted disabled:pointer-events-none disabled:opacity-0 group-hover/stage:opacity-100",
|
|
484
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "size-5" })
|
|
485
|
+
}
|
|
486
|
+
),
|
|
487
|
+
/* @__PURE__ */ jsx(
|
|
488
|
+
"button",
|
|
489
|
+
{
|
|
490
|
+
type: "button",
|
|
491
|
+
onClick: next,
|
|
492
|
+
disabled: sel === last,
|
|
493
|
+
title: t("deck.nextPage"),
|
|
494
|
+
"aria-label": t("deck.nextPage"),
|
|
495
|
+
className: "absolute right-3 top-1/2 z-10 inline-flex size-9 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-background/80 text-foreground opacity-0 shadow-sm backdrop-blur transition hover:bg-muted disabled:pointer-events-none disabled:opacity-0 group-hover/stage:opacity-100",
|
|
496
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "size-5" })
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
] }),
|
|
500
|
+
isMobile && visiblePages > 1 && /* @__PURE__ */ jsx(
|
|
501
|
+
"div",
|
|
502
|
+
{
|
|
503
|
+
ref: railRef,
|
|
504
|
+
className: "flex shrink-0 gap-2 overflow-x-auto border-t border-border bg-surface px-2 py-2 scrollbar-hide",
|
|
505
|
+
children: Array.from({ length: visiblePages }, (_, i) => /* @__PURE__ */ jsxs(
|
|
506
|
+
"button",
|
|
507
|
+
{
|
|
508
|
+
type: "button",
|
|
509
|
+
"data-active": i === sel,
|
|
510
|
+
onClick: () => setSel(i),
|
|
511
|
+
"aria-label": `${t("deck.slide")} ${i + 1}`,
|
|
512
|
+
"aria-current": i === sel,
|
|
513
|
+
className: cn(
|
|
514
|
+
"relative shrink-0 overflow-hidden rounded border bg-surface transition-colors",
|
|
515
|
+
i === sel ? "border-transparent ring ring-foreground" : "border-border"
|
|
516
|
+
),
|
|
517
|
+
children: [
|
|
518
|
+
/* @__PURE__ */ jsx(
|
|
519
|
+
LazyThumb,
|
|
520
|
+
{
|
|
521
|
+
width: STRIP_THUMB_W,
|
|
522
|
+
height: stripThumbH,
|
|
523
|
+
className: "bg-muted",
|
|
524
|
+
children: /* @__PURE__ */ jsx(
|
|
525
|
+
Page,
|
|
526
|
+
{
|
|
527
|
+
pageNumber: i + 1,
|
|
528
|
+
width: STRIP_THUMB_W,
|
|
529
|
+
renderTextLayer: false,
|
|
530
|
+
renderAnnotationLayer: false,
|
|
531
|
+
loading: /* @__PURE__ */ jsx(
|
|
532
|
+
"div",
|
|
533
|
+
{
|
|
534
|
+
style: { width: STRIP_THUMB_W, height: stripThumbH },
|
|
535
|
+
className: "animate-pulse bg-muted"
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
/* @__PURE__ */ jsx(
|
|
543
|
+
"span",
|
|
544
|
+
{
|
|
545
|
+
className: cn(
|
|
546
|
+
"absolute bottom-0.5 right-0.5 rounded bg-surface-overlay/85 px-1 text-[10px] tabular-nums",
|
|
547
|
+
i === sel ? "text-foreground" : "text-muted-foreground"
|
|
548
|
+
),
|
|
549
|
+
children: i + 1
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
]
|
|
553
|
+
},
|
|
554
|
+
i
|
|
555
|
+
))
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
visiblePages > 0 && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-3 flex items-center justify-center", children: /* @__PURE__ */ jsxs("span", { className: "rounded-full border border-border bg-background/80 px-3 py-1 text-xs tabular-nums text-muted-foreground shadow-sm backdrop-blur", children: [
|
|
559
|
+
sel + 1,
|
|
560
|
+
" / ",
|
|
561
|
+
visiblePages
|
|
562
|
+
] }) })
|
|
563
|
+
]
|
|
564
|
+
}
|
|
565
|
+
)
|
|
566
|
+
]
|
|
567
|
+
},
|
|
568
|
+
fileUrl
|
|
569
|
+
)
|
|
570
|
+
]
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export { PdfDeckViewInner as default };
|