@factorialco/f0-react 12.10.0 → 12.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ArchiveThumbnail-b34U-zTc.js +70 -0
- package/dist/ArchiveViewer-BpmryW7A.js +172 -0
- package/dist/{ChatPostComposerDialog-DcmLrQk6.js → ChatPostComposerDialog-Cr207fXs.js} +4 -4
- package/dist/{CoachmarkProvider-XfLjB3dH.js → CoachmarkProvider-CsytVD-X.js} +29764 -29935
- package/dist/CodeThumbnail-8NiQ3uzU.js +31 -0
- package/dist/CodeViewer-BNZqt-5s.js +98 -0
- package/dist/DocumentToolbar-DUe9R1rU.js +74 -0
- package/dist/{DocxThumbnail-kHTNnwW0.js → DocxThumbnail-CK9vFoTB.js} +2 -2
- package/dist/{DocxViewer-CqHgSExq.js → DocxViewer-BUMy2iL7.js} +25 -23
- package/dist/ExternalLink-RdKU698E.js +22 -0
- package/dist/{F0AiProcessingOverlay-H23WHd7F.js → F0AiProcessingOverlay-CiUTeBwG.js} +1388 -1384
- package/dist/F0Alert-Ca8sBfXN.js +102 -0
- package/dist/F0AudioPlayer-BefDLQA2.js +1083 -0
- package/dist/F0AudioPlayer-CNb4kXOk.js +3 -0
- package/dist/{popover-BjrPOMeQ.js → F0Button-d91IgOnc.js} +3164 -8587
- package/dist/{F0CanvasPanel--hLKeQvg.js → F0CanvasPanel-BOo_mxBl.js} +10286 -9593
- package/dist/F0DocumentViewer-CaYAO9ok.js +3 -0
- package/dist/F0DocumentViewer-h0XY5tgT.js +90 -0
- package/dist/F0Icon-DmCBV0gK.js +202 -0
- package/dist/{F0Map-hvgCUGk8.js → F0Map-b1uYlF_H.js} +614 -613
- package/dist/F0SegmentedControl-DXoAzTmH.js +103 -0
- package/dist/{F0Select-B-ZxVjXG.js → F0Select-BZ20yXKy.js} +9172 -9251
- package/dist/{F0VideoPlayer-CNp5hXgp.js → F0VideoPlayer-D85XCpqh.js} +390 -430
- package/dist/F0VideoPlayer-_zLFiEIp.js +1 -0
- package/dist/HtmlThumbnail-BJuJkuvu.js +60 -0
- package/dist/HtmlViewer-DxOnMV30.js +208 -0
- package/dist/LayoutGroup-BGb5jMxE.js +57 -0
- package/dist/LockLocked-gdodYvT_.js +41 -0
- package/dist/{Map-eIXVKc1x.js → Map-BOMgctnS.js} +55 -52
- package/dist/{PdfThumbnail-CCSmwxQU.js → PdfThumbnail-98PDy4ud.js} +5 -5
- package/dist/PdfViewer-nBnKrTYD.js +296 -0
- package/dist/SandboxedHtmlFrame-B95lWsIP.js +309 -0
- package/dist/{SheetViewer-BN5UYkEZ.js → SheetViewer-CD9SHbXJ.js} +36 -26
- package/dist/TextThumbnail-DKNxh344.js +15 -0
- package/dist/{TextViewer-Bt0_dYB-.js → TextViewer-DxRBCXzV.js} +44 -41
- package/dist/ai.d.ts +3 -3
- package/dist/ai.js +5 -5
- package/dist/bash-BcZBmoDA.js +169 -0
- package/dist/c-Dv-5_kUQ.js +187 -0
- package/dist/component-status.js +2 -2
- package/dist/core-C0MCmPil.js +842 -0
- package/dist/cpp-CMQhucZt.js +236 -0
- package/dist/csharp-CuDKSCf2.js +260 -0
- package/dist/css-Dta7Q4Li.js +145 -0
- package/dist/dart-po7Eq73d.js +134 -0
- package/dist/diff-IgsQP-8T.js +39 -0
- package/dist/dist-CFY0KELA.js +55 -0
- package/dist/dist-DtILhk4w.js +253 -0
- package/dist/dist-zvwuNflP.js +59 -0
- package/dist/dockerfile-B4Bz9I5u.js +34 -0
- package/dist/dos-1TcyLtUq.js +57 -0
- package/dist/elixir-BnEjyLGa.js +189 -0
- package/dist/erlang-tgri7ZSv.js +218 -0
- package/dist/experimental.d.ts +24 -4
- package/dist/experimental.js +5957 -5752
- package/dist/{exports-BByQBwpi.d.ts → exports-cxvNeHfV.d.ts} +1 -1
- package/dist/f0.d.ts +130 -8
- package/dist/f0.js +1969 -3034
- package/dist/fetchText-o_GOtiv3.js +54 -0
- package/dist/go-CEVmppuo.js +144 -0
- package/dist/graphql-BWwc-u8d.js +67 -0
- package/dist/groovy-BELuqtd6.js +127 -0
- package/dist/haskell-Cxh7aaFM.js +138 -0
- package/dist/highlight-CqFL-_MG.js +114 -0
- package/dist/i18n-provider-Bdgo-LeP.js +150 -0
- package/dist/{i18n-provider-defaults-p0UGTA_k.js → i18n-provider-defaults-B9vdZZeS.js} +35 -1
- package/dist/{i18n-provider-defaults-DQxuUMpU.d.ts → i18n-provider-defaults-DyPn8R7T.d.ts} +34 -0
- package/dist/i18n-provider-defaults.d.ts +1 -1
- package/dist/i18n-provider-defaults.js +1 -1
- package/dist/{index-D3nEDg8x.d.ts → index-DF8ubeg6.d.ts} +1 -1
- package/dist/ini-DA-F0rRr.js +88 -0
- package/dist/java-Bujnoc_f.js +174 -0
- package/dist/javascript-BeEhpXRE.js +431 -0
- package/dist/json-CxvE7tEw.js +42 -0
- package/dist/kotlin-DOwDGI_m.js +206 -0
- package/dist/less-DWlR-e-o.js +196 -0
- package/dist/localized-BrUgGMzm.js +46 -0
- package/dist/lua-BlZiakwh.js +46 -0
- package/dist/makefile-D3841Yg4.js +57 -0
- package/dist/{maplibre-Bywi9z2G.js → maplibre-Ip4Qe9dM.js} +1 -1
- package/dist/markdown-D1wNG79U.js +178 -0
- package/dist/objectivec-DxtRzTBy.js +117 -0
- package/dist/ownValue-D4uSXt0d.js +4 -0
- package/dist/{pdfWorker-CKgxOaCl.js → pdfWorker-DMjHHAyP.js} +12 -9
- package/dist/pdfWorkerConfig-BwllKt1K.js +8 -0
- package/dist/perl-BWRmkuyz.js +192 -0
- package/dist/php-CjwybYSP.js +300 -0
- package/dist/popover-ics24JxK.js +4486 -0
- package/dist/{posts-DGtDUrKT.js → posts-BHRBUAYJ.js} +2 -0
- package/dist/powershell-CgKcNA5Q.js +188 -0
- package/dist/properties-Bc45MTzW.js +38 -0
- package/dist/protobuf-Bv_xSUaI.js +61 -0
- package/dist/purify.es-ZpfdAuNV.js +545 -0
- package/dist/python-D8PdGjgy.js +238 -0
- package/dist/r-DA-9ZIdU.js +140 -0
- package/dist/{renderDocx-_UmnE-yc.js → renderDocx-BW-uDyaZ.js} +2 -0
- package/dist/ruby-Bqr16BpN.js +262 -0
- package/dist/rust-BCvJMwk8.js +182 -0
- package/dist/scala-Du8mOD2z.js +162 -0
- package/dist/scrollarea-cxaFAWG5.js +691 -0
- package/dist/scss-AMxHqh46.js +155 -0
- package/dist/skeleton-AC0Fb8zj.js +72 -0
- package/dist/sql-BbYSgcOA.js +118 -0
- package/dist/styles.css +1 -1
- package/dist/swift-DRKtalPn.js +575 -0
- package/dist/toolbarStyles-lTj_42zD.js +52 -0
- package/dist/{types-UMYBr8Mi.d.ts → types-geibVrTM.d.ts} +3 -95
- package/dist/typescript-Bv8uKU6V.js +516 -0
- package/dist/{useData-B7LYSzh0.js → useData-BYkiGUHX.js} +4734 -5375
- package/dist/useFetchedText-BR3_KLXx.js +38 -0
- package/dist/useThumbnailText-DwXQvLIe.js +22 -0
- package/dist/xml-BVpP05uE.js +162 -0
- package/dist/yaml-BNe2WG-i.js +144 -0
- package/dist/zipTree-B2zUYl6b.js +247 -0
- package/package.json +2 -1
- package/dist/DocumentToolbar-CqbY6eID.js +0 -70
- package/dist/F0DocumentViewer-BN-2IVgz.js +0 -400
- package/dist/F0DocumentViewer-D1G3M2J_.js +0 -3
- package/dist/F0Text-D92NWQRd.js +0 -81
- package/dist/F0VideoPlayer-D4bZBBLK.js +0 -1
- package/dist/TextThumbnail-X04JgaNI.js +0 -26
- package/dist/dist-DvxtFKDL.js +0 -78
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { r as e } from "./i18n-provider-Bdgo-LeP.js";
|
|
2
|
+
import { t } from "./skeleton-AC0Fb8zj.js";
|
|
3
|
+
import { L as n } from "./tooltip-BX4dSfeL.js";
|
|
4
|
+
import { S as r } from "./F0Button-d91IgOnc.js";
|
|
5
|
+
import { Do as i, Ms as a, bo as o } from "./F0CanvasPanel-BOo_mxBl.js";
|
|
6
|
+
import { H as s, z as c } from "./useData-BYkiGUHX.js";
|
|
7
|
+
import { br as l, sr as u, t as d } from "./F0Select-BZ20yXKy.js";
|
|
8
|
+
import { a as f, i as p, l as ee, n as te, o as m, r as h, s as g, t as _, u as ne } from "./toolbarStyles-lTj_42zD.js";
|
|
9
|
+
import { n as re, r as ie, t as v } from "./pdfWorker-DMjHHAyP.js";
|
|
10
|
+
import { forwardRef as y, useCallback as b, useEffect as x, useMemo as S, useRef as C, useState as w } from "react";
|
|
11
|
+
import { jsx as T, jsxs as E } from "react/jsx-runtime";
|
|
12
|
+
//#region src/addons/documents/F0DocumentViewer/crispCanvas.ts
|
|
13
|
+
var D = (e, t) => t ? (O(e, t) + .001) / t : e, O = (e, t) => Math.round(t * e), k = (e, t, n) => O(e, n) === O(t, n), ae = (e, t = window.devicePixelRatio || 1) => {
|
|
14
|
+
e && e.width !== 0 && e.height !== 0 && (e.style.width = `${e.width / t}px`, e.style.height = `${e.height / t}px`);
|
|
15
|
+
}, oe = (e, t, n) => {
|
|
16
|
+
let r = null, i = 0;
|
|
17
|
+
return t.forEach((t, a) => {
|
|
18
|
+
if (!t) return;
|
|
19
|
+
let o = t.offsetHeight, s = t.offsetTop, c = s + o, l = e.offsetHeight - n, u = e.scrollTop + n, d = u + l;
|
|
20
|
+
if (!(u < c && d > s)) return;
|
|
21
|
+
let f;
|
|
22
|
+
if (u <= s) f = d > c ? o : d - s;
|
|
23
|
+
else {
|
|
24
|
+
let e = u - s;
|
|
25
|
+
d < c && (e += c - d), f = o - e;
|
|
26
|
+
}
|
|
27
|
+
f > i && (i = f, r = a + 1);
|
|
28
|
+
}), r;
|
|
29
|
+
}, se = ({ label: e, width: n, height: r }) => /* @__PURE__ */ T("div", {
|
|
30
|
+
role: "status",
|
|
31
|
+
"aria-label": e,
|
|
32
|
+
"aria-live": "polite",
|
|
33
|
+
"aria-busy": !0,
|
|
34
|
+
className: "F0DocumentViewer__page mx-auto w-fit px-4 pt-4 last:pb-4",
|
|
35
|
+
children: /* @__PURE__ */ T(t, {
|
|
36
|
+
style: {
|
|
37
|
+
width: n,
|
|
38
|
+
height: r
|
|
39
|
+
},
|
|
40
|
+
className: "rounded-lg border border-solid border-f1-border-secondary shadow-md"
|
|
41
|
+
})
|
|
42
|
+
}), A = ({ toolbarRef: t, currentPage: r, totalPages: f, hasDocument: p, selectedScale: ee, scaleOptions: m, onPreviousPage: g, onNextPage: ne, onZoomIn: re, onZoomOut: ie, onScaleChange: v, rotatable: y, onRotate: b, onPrint: x, onDownload: S, hideDownload: C = !1, actions: w, placement: D }) => {
|
|
43
|
+
let { pdfViewer: O } = e(), k = te(D);
|
|
44
|
+
return /* @__PURE__ */ E("div", {
|
|
45
|
+
ref: t,
|
|
46
|
+
role: "toolbar",
|
|
47
|
+
"aria-label": O.toolbar,
|
|
48
|
+
"data-placement": D,
|
|
49
|
+
className: _(D),
|
|
50
|
+
children: [
|
|
51
|
+
p ? /* @__PURE__ */ E("span", {
|
|
52
|
+
"aria-live": "polite",
|
|
53
|
+
className: n("whitespace-nowrap text-sm font-medium", D === "top" ? "text-f1-foreground-secondary" : "pl-2 text-f1-foreground-inverse"),
|
|
54
|
+
children: [
|
|
55
|
+
r,
|
|
56
|
+
" / ",
|
|
57
|
+
f
|
|
58
|
+
]
|
|
59
|
+
}) : null,
|
|
60
|
+
/* @__PURE__ */ E("div", {
|
|
61
|
+
className: k,
|
|
62
|
+
children: [/* @__PURE__ */ T(h, {
|
|
63
|
+
label: O.previousPage,
|
|
64
|
+
onClick: g,
|
|
65
|
+
icon: l,
|
|
66
|
+
size: "sm"
|
|
67
|
+
}), /* @__PURE__ */ T(h, {
|
|
68
|
+
label: O.nextPage,
|
|
69
|
+
onClick: ne,
|
|
70
|
+
icon: s,
|
|
71
|
+
size: "sm"
|
|
72
|
+
})]
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ E("div", {
|
|
75
|
+
className: k,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ T(h, {
|
|
78
|
+
label: O.zoomOut,
|
|
79
|
+
onClick: ie,
|
|
80
|
+
icon: c
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ T(h, {
|
|
83
|
+
label: O.zoomIn,
|
|
84
|
+
onClick: re,
|
|
85
|
+
icon: u
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ T(d, {
|
|
88
|
+
hideLabel: !0,
|
|
89
|
+
label: O.scaleSelector,
|
|
90
|
+
options: m,
|
|
91
|
+
value: ee,
|
|
92
|
+
onChange: (e) => v(e)
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ E("div", {
|
|
97
|
+
className: k,
|
|
98
|
+
children: [
|
|
99
|
+
y ? /* @__PURE__ */ T(h, {
|
|
100
|
+
label: O.rotate,
|
|
101
|
+
onClick: b,
|
|
102
|
+
icon: o
|
|
103
|
+
}) : null,
|
|
104
|
+
/* @__PURE__ */ T(h, {
|
|
105
|
+
label: O.print,
|
|
106
|
+
onClick: x,
|
|
107
|
+
icon: i
|
|
108
|
+
}),
|
|
109
|
+
C ? null : /* @__PURE__ */ T(h, {
|
|
110
|
+
label: O.download,
|
|
111
|
+
onClick: S,
|
|
112
|
+
icon: a
|
|
113
|
+
}),
|
|
114
|
+
w?.map((e, t) => /* @__PURE__ */ T(h, {
|
|
115
|
+
label: e.label,
|
|
116
|
+
onClick: e.onClick,
|
|
117
|
+
icon: e.icon
|
|
118
|
+
}, `${e.label}-${t}`))
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/addons/documents/F0DocumentViewer/components/PdfViewer.tsx
|
|
126
|
+
v();
|
|
127
|
+
var j = 48, ce = 150, M = y((n, i) => {
|
|
128
|
+
let { url: a, filename: o = "document.pdf", page: s = 0, pagesToDisplay: c = [], initialScale: l = "page-width", withCredentials: u = !0, rotatable: d = !1, initialRotation: te = 0, onRotationChange: h, onPdfLoaded: _, onPageChange: v, actions: y, toolbar: O = "top", hideDownload: M = !1, ...le } = n, { pdfViewer: N } = e(), P = Math.max(2, typeof window > "u" ? 1 : window.devicePixelRatio || 1), [F, ue] = w(null), [I, L] = w([]), [R, z] = w(1), [B, V] = w(0), [H, U] = w(l), [W, de] = w(te), G = C(null), K = C(null), q = C([]), J = c.length > 0 ? c.length : F?.numPages, Y = b(() => O === "top" ? K.current?.offsetHeight ?? 0 : 0, [O]), fe = I.find(Boolean), pe = (fe?.originalWidth ?? 595) * R, me = (fe?.originalHeight ?? 842) * R, he = S(() => [
|
|
129
|
+
{
|
|
130
|
+
value: "page-width",
|
|
131
|
+
label: N.pageWidth
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
value: "page-fit",
|
|
135
|
+
label: N.pageFit
|
|
136
|
+
},
|
|
137
|
+
...f.map((e) => ({
|
|
138
|
+
value: e,
|
|
139
|
+
label: `${Number(e) * 100}%`
|
|
140
|
+
}))
|
|
141
|
+
], [N.pageWidth, N.pageFit]), ge = S(() => ({
|
|
142
|
+
url: a,
|
|
143
|
+
withCredentials: u
|
|
144
|
+
}), [a, u]), X = b((e) => {
|
|
145
|
+
let t = (J ?? 1) - 1, n = Math.min(Math.max(e, 0), t), r = q.current[n], i = r?.offsetParent;
|
|
146
|
+
r && i instanceof HTMLElement && (i.scrollTop = r.offsetTop - Y() - 10);
|
|
147
|
+
}, [J, Y]), Z = b((e) => {
|
|
148
|
+
let t = I[B - 1], n = G.current;
|
|
149
|
+
if (!t || !n || n.clientWidth <= 0) return;
|
|
150
|
+
let r = K.current?.offsetHeight ?? 0, i = W === 90 || W === 270, a = (e) => i ? e.originalHeight : e.originalWidth, o = a(t), s = i ? t.originalWidth : t.originalHeight, c = e === "page-fit" ? Math.max(...I.filter(Boolean).map(a)) : o, l = p(e, {
|
|
151
|
+
width: c,
|
|
152
|
+
height: s
|
|
153
|
+
}, {
|
|
154
|
+
width: n.clientWidth - j,
|
|
155
|
+
height: n.clientHeight - r - j
|
|
156
|
+
});
|
|
157
|
+
z((e) => k(e, l, c) ? e : l), U(e);
|
|
158
|
+
}, [
|
|
159
|
+
I,
|
|
160
|
+
B,
|
|
161
|
+
W
|
|
162
|
+
]), _e = b((e) => {
|
|
163
|
+
e === "page-width" || e === "page-fit" ? Z(e) : (z(Number(e)), U(e));
|
|
164
|
+
}, [Z]), Q = b((e) => {
|
|
165
|
+
if (e === void 0) return;
|
|
166
|
+
z(e);
|
|
167
|
+
let t = f.find((t) => Number(t) === e);
|
|
168
|
+
t && U(t);
|
|
169
|
+
}, []), ve = b(() => Q(g(R)), [R, Q]), ye = b(() => Q(m(R)), [R, Q]), be = b(() => {
|
|
170
|
+
de((e) => {
|
|
171
|
+
let t = (e + 90) % 360;
|
|
172
|
+
return h?.(t), t;
|
|
173
|
+
});
|
|
174
|
+
}, [h]), xe = b((e) => {
|
|
175
|
+
ue(e), _?.(e), setTimeout(() => {
|
|
176
|
+
V(s + 1), X(s);
|
|
177
|
+
}, 0);
|
|
178
|
+
}, [
|
|
179
|
+
_,
|
|
180
|
+
s,
|
|
181
|
+
X
|
|
182
|
+
]), Se = b((e) => {
|
|
183
|
+
let t = e.target;
|
|
184
|
+
if (!(t instanceof HTMLElement)) return;
|
|
185
|
+
let n = oe(t, q.current, Y());
|
|
186
|
+
n && V(n);
|
|
187
|
+
}, [Y]), Ce = b(() => {
|
|
188
|
+
ne(F);
|
|
189
|
+
}, [F]), we = b(() => {
|
|
190
|
+
ee(F, o);
|
|
191
|
+
}, [F, o]);
|
|
192
|
+
x(() => {
|
|
193
|
+
ue(null), L([]), q.current = [];
|
|
194
|
+
}, [a]), x(() => {
|
|
195
|
+
X(s);
|
|
196
|
+
}, [s, X]), x(() => {
|
|
197
|
+
B > 0 && v?.(B);
|
|
198
|
+
}, [B, v]), x(() => {
|
|
199
|
+
I.length > 0 && (l === "page-width" || l === "page-fit") && Z(l);
|
|
200
|
+
}, [I.length, l]), x(() => {
|
|
201
|
+
(H === "page-width" || H === "page-fit") && Z(H);
|
|
202
|
+
}, [W]);
|
|
203
|
+
let $ = C();
|
|
204
|
+
r({
|
|
205
|
+
ref: G,
|
|
206
|
+
onResize: () => {
|
|
207
|
+
clearTimeout($.current), $.current = setTimeout(() => {
|
|
208
|
+
(H === "page-width" || H === "page-fit") && Z(H);
|
|
209
|
+
}, ce);
|
|
210
|
+
}
|
|
211
|
+
}), x(function() {
|
|
212
|
+
return () => clearTimeout($.current);
|
|
213
|
+
}, []), x(() => {
|
|
214
|
+
let e = G.current;
|
|
215
|
+
if (!e) return;
|
|
216
|
+
let t = (e) => {
|
|
217
|
+
let t = e.target;
|
|
218
|
+
t instanceof HTMLAnchorElement && (t.target = "_blank", t.rel = "noopener noreferrer");
|
|
219
|
+
};
|
|
220
|
+
return e.addEventListener("click", t, !0), () => e.removeEventListener("click", t, !0);
|
|
221
|
+
}, []);
|
|
222
|
+
let Te = {
|
|
223
|
+
toolbarRef: K,
|
|
224
|
+
placement: O,
|
|
225
|
+
currentPage: B,
|
|
226
|
+
totalPages: J,
|
|
227
|
+
hasDocument: !!F?.numPages,
|
|
228
|
+
selectedScale: H,
|
|
229
|
+
scaleOptions: he,
|
|
230
|
+
onPreviousPage: () => X(B - 2),
|
|
231
|
+
onNextPage: () => X(B),
|
|
232
|
+
onZoomIn: ve,
|
|
233
|
+
onZoomOut: ye,
|
|
234
|
+
onScaleChange: _e,
|
|
235
|
+
rotatable: d,
|
|
236
|
+
onRotate: be,
|
|
237
|
+
onPrint: Ce,
|
|
238
|
+
onDownload: we,
|
|
239
|
+
hideDownload: M,
|
|
240
|
+
actions: y
|
|
241
|
+
};
|
|
242
|
+
return /* @__PURE__ */ E("div", {
|
|
243
|
+
ref: i,
|
|
244
|
+
...le,
|
|
245
|
+
className: "F0DocumentViewer__surface relative flex h-full w-full flex-col overflow-hidden border border-solid border-f1-border-secondary",
|
|
246
|
+
children: [/* @__PURE__ */ E("div", {
|
|
247
|
+
ref: G,
|
|
248
|
+
onScroll: Se,
|
|
249
|
+
className: "F0DocumentViewer__surface relative flex h-full flex-col overflow-auto [scrollbar-gutter:stable_both-edges]",
|
|
250
|
+
children: [O === "top" ? /* @__PURE__ */ T(A, { ...Te }) : null, a ? /* @__PURE__ */ T(ie, {
|
|
251
|
+
file: ge,
|
|
252
|
+
onLoadSuccess: xe,
|
|
253
|
+
loading: /* @__PURE__ */ T(se, {
|
|
254
|
+
label: N.loading,
|
|
255
|
+
width: pe,
|
|
256
|
+
height: me
|
|
257
|
+
}),
|
|
258
|
+
children: F ? Array.from({ length: J ?? 0 }).map((e, n) => {
|
|
259
|
+
let r = (c.length > 0 ? c[n] : n) + 1;
|
|
260
|
+
return /* @__PURE__ */ T("div", {
|
|
261
|
+
className: "F0DocumentViewer__page mx-auto w-fit px-4 pt-4 last:pb-4",
|
|
262
|
+
children: /* @__PURE__ */ T(re, {
|
|
263
|
+
className: "overflow-hidden rounded-lg border border-solid border-f1-border-secondary shadow-md",
|
|
264
|
+
pageNumber: r,
|
|
265
|
+
scale: D(R, W === 90 || W === 270 ? I[n]?.originalHeight : I[n]?.originalWidth),
|
|
266
|
+
rotate: W,
|
|
267
|
+
devicePixelRatio: P,
|
|
268
|
+
loading: /* @__PURE__ */ T(t, { style: {
|
|
269
|
+
width: pe,
|
|
270
|
+
height: me
|
|
271
|
+
} }),
|
|
272
|
+
renderForms: !0,
|
|
273
|
+
renderTextLayer: !0,
|
|
274
|
+
inputRef: (e) => {
|
|
275
|
+
q.current[n] = e;
|
|
276
|
+
},
|
|
277
|
+
onRenderSuccess: () => ae(q.current[n]?.querySelector("canvas"), P),
|
|
278
|
+
onLoadSuccess: (e) => {
|
|
279
|
+
L((t) => {
|
|
280
|
+
let r = [...t];
|
|
281
|
+
return r[n] = {
|
|
282
|
+
originalWidth: e.originalWidth,
|
|
283
|
+
originalHeight: e.originalHeight
|
|
284
|
+
}, r;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
}, n);
|
|
289
|
+
}) : null
|
|
290
|
+
}) : null]
|
|
291
|
+
}), O === "floating" ? /* @__PURE__ */ T(A, { ...Te }) : null]
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
M.displayName = "PdfViewerBase";
|
|
295
|
+
//#endregion
|
|
296
|
+
export { M as default };
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { r as e } from "./i18n-provider-Bdgo-LeP.js";
|
|
2
|
+
import { L as t } from "./tooltip-BX4dSfeL.js";
|
|
3
|
+
import { t as n } from "./F0Button-d91IgOnc.js";
|
|
4
|
+
import { t as r } from "./ExternalLink-RdKU698E.js";
|
|
5
|
+
import { useEffect as i, useId as a, useLayoutEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
6
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
|
+
//#region src/addons/documents/lib/html-sandbox/messages.ts
|
|
8
|
+
var f = "f0-html", p = {
|
|
9
|
+
hostReady: "host-ready",
|
|
10
|
+
render: "render",
|
|
11
|
+
ready: "ready",
|
|
12
|
+
openLink: "open-link",
|
|
13
|
+
key: "key"
|
|
14
|
+
}, m = [
|
|
15
|
+
"Escape",
|
|
16
|
+
"ArrowLeft",
|
|
17
|
+
"ArrowRight",
|
|
18
|
+
"Home",
|
|
19
|
+
"End"
|
|
20
|
+
], h = (e) => typeof e == "object" && !!e, g = (e, t) => {
|
|
21
|
+
if (!h(e) || e.channel !== "f0-html" || e.token !== t) return null;
|
|
22
|
+
if (e.type === p.ready) return {
|
|
23
|
+
type: "ready",
|
|
24
|
+
token: t
|
|
25
|
+
};
|
|
26
|
+
if (e.type === p.openLink) return typeof e.href == "string" ? {
|
|
27
|
+
type: "open-link",
|
|
28
|
+
token: t,
|
|
29
|
+
href: e.href
|
|
30
|
+
} : null;
|
|
31
|
+
if (e.type === p.key) {
|
|
32
|
+
let n = m.find((t) => t === e.key);
|
|
33
|
+
return n ? {
|
|
34
|
+
type: "key",
|
|
35
|
+
token: t,
|
|
36
|
+
key: n
|
|
37
|
+
} : null;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}, _ = (e) => h(e) && e.channel === "f0-html" && e.type === p.hostReady, v = (e) => {
|
|
41
|
+
if (typeof e != "string") return null;
|
|
42
|
+
try {
|
|
43
|
+
let t = new URL(e);
|
|
44
|
+
return !["http:", "https:"].includes(t.protocol) || !t.hostname ? null : {
|
|
45
|
+
href: t.href,
|
|
46
|
+
host: t.hostname
|
|
47
|
+
};
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}, y = () => Array.from(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)), (e) => e.toString(16).padStart(2, "0")).join(""), b = [
|
|
52
|
+
"default-src 'none'",
|
|
53
|
+
"style-src 'unsafe-inline'",
|
|
54
|
+
"img-src data: blob:",
|
|
55
|
+
"font-src data:",
|
|
56
|
+
"media-src data: blob:",
|
|
57
|
+
"connect-src 'none'",
|
|
58
|
+
"form-action 'none'",
|
|
59
|
+
"base-uri 'none'",
|
|
60
|
+
"frame-src 'none'",
|
|
61
|
+
"child-src 'none'",
|
|
62
|
+
"worker-src 'none'",
|
|
63
|
+
"object-src 'none'"
|
|
64
|
+
], x = [
|
|
65
|
+
"default-src 'none'",
|
|
66
|
+
"script-src 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://unpkg.com https://cdn.tailwindcss.com",
|
|
67
|
+
"style-src 'unsafe-inline' https://fonts.googleapis.com https://cdn.jsdelivr.net",
|
|
68
|
+
"font-src https://fonts.gstatic.com data:",
|
|
69
|
+
...b.slice(2).filter((e) => !e.startsWith("font-src"))
|
|
70
|
+
], S = (e, t = "") => {
|
|
71
|
+
if (e === "run") return x.join("; ");
|
|
72
|
+
let n = e === "static" ? `script-src 'nonce-${t}'` : "script-src 'none'";
|
|
73
|
+
return [
|
|
74
|
+
b[0],
|
|
75
|
+
n,
|
|
76
|
+
...b.slice(1)
|
|
77
|
+
].join("; ");
|
|
78
|
+
}, C = [
|
|
79
|
+
"base",
|
|
80
|
+
"meta[http-equiv=\"refresh\" i]",
|
|
81
|
+
"iframe",
|
|
82
|
+
"frame",
|
|
83
|
+
"frameset",
|
|
84
|
+
"object",
|
|
85
|
+
"embed",
|
|
86
|
+
"portal"
|
|
87
|
+
].join(", "), w = ":where(html){background-color:#fff;color:#000}", T = (e) => JSON.stringify(e).replace(/</g, "\\u003c"), E = (e, t = "*") => `(() => {
|
|
88
|
+
const token = ${T(e)}
|
|
89
|
+
const target = ${T(t)}
|
|
90
|
+
if (document.currentScript) document.currentScript.remove()
|
|
91
|
+
const host = parent
|
|
92
|
+
// A plain literal, not Object.assign: author scripts run later and could
|
|
93
|
+
// patch globals to read the token.
|
|
94
|
+
const send = (type, value) => {
|
|
95
|
+
try { host.postMessage({ channel: ${T(f)}, token: token, type: type, href: value, key: value }, target) } catch (error) {}
|
|
96
|
+
}
|
|
97
|
+
;["RTCPeerConnection", "webkitRTCPeerConnection", "RTCDataChannel"].forEach((name) => {
|
|
98
|
+
try { Object.defineProperty(window, name, { value: undefined, writable: false, configurable: false }) } catch (error) {}
|
|
99
|
+
})
|
|
100
|
+
addEventListener("click", (event) => {
|
|
101
|
+
const link = event.target instanceof Element ? event.target.closest("a, area") : null
|
|
102
|
+
const href = link ? (link.getAttribute("href") || link.getAttribute("xlink:href") || "").trim() : ""
|
|
103
|
+
if (!link || !href) return
|
|
104
|
+
event.preventDefault()
|
|
105
|
+
if (href.charAt(0) === "#") {
|
|
106
|
+
let id = href.slice(1)
|
|
107
|
+
try { id = decodeURIComponent(id) } catch (error) {}
|
|
108
|
+
const anchor = id ? document.getElementById(id) || document.getElementsByName(id)[0] : null
|
|
109
|
+
if (anchor) anchor.scrollIntoView()
|
|
110
|
+
else if (!id || id.toLowerCase() === "top") scrollTo(0, 0)
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
let url = null
|
|
114
|
+
try { url = new URL(href) } catch (error) { return }
|
|
115
|
+
if (url.protocol === "http:" || url.protocol === "https:") send(${T(p.openLink)}, url.href)
|
|
116
|
+
}, true)
|
|
117
|
+
const keys = ${JSON.stringify(m)}
|
|
118
|
+
const editable = (node) => node instanceof Element && Boolean(node.closest("input, textarea, select, [contenteditable]:not([contenteditable='false']), [role='textbox'], [role='slider']"))
|
|
119
|
+
addEventListener("keydown", (event) => {
|
|
120
|
+
if (keys.indexOf(event.key) < 0 || event.defaultPrevented) return
|
|
121
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
|
|
122
|
+
if (editable(event.target)) return
|
|
123
|
+
send(${T(p.key)}, event.key)
|
|
124
|
+
})
|
|
125
|
+
addEventListener("load", () => send(${T(p.ready)}))
|
|
126
|
+
send(${T(p.ready)})
|
|
127
|
+
})()`, D = (e) => {
|
|
128
|
+
e.replaceWith(...Array.from(e.childNodes));
|
|
129
|
+
}, O = (e, { mode: t, token: n = "", nonce: r = "", parentOrigin: i }) => {
|
|
130
|
+
let a = new DOMParser().parseFromString(e, "text/html");
|
|
131
|
+
a.querySelectorAll(C).forEach((e) => e.remove()), a.querySelectorAll("link").forEach((e) => {
|
|
132
|
+
let n = /(^|\s)stylesheet(\s|$)/i.test(e.getAttribute("rel") ?? "");
|
|
133
|
+
(t !== "artifact" && t !== "run" || !n) && e.remove();
|
|
134
|
+
}), a.querySelectorAll("[target], [formtarget]").forEach((e) => {
|
|
135
|
+
e.removeAttribute("target"), e.removeAttribute("formtarget");
|
|
136
|
+
});
|
|
137
|
+
let o = t === "run" || t === "artifact";
|
|
138
|
+
a.querySelectorAll("noscript").forEach((e) => {
|
|
139
|
+
o ? e.remove() : D(e);
|
|
140
|
+
});
|
|
141
|
+
let s = [];
|
|
142
|
+
if (t !== "artifact") {
|
|
143
|
+
let e = a.createElement("meta");
|
|
144
|
+
e.setAttribute("http-equiv", "Content-Security-Policy"), e.setAttribute("content", S(t, r)), s.push(e);
|
|
145
|
+
}
|
|
146
|
+
let c = a.createElement("meta");
|
|
147
|
+
c.setAttribute("name", "color-scheme"), c.setAttribute("content", "light");
|
|
148
|
+
let l = a.createElement("style");
|
|
149
|
+
if (l.textContent = w, s.push(c, l), t === "static" || t === "thumbnail") {
|
|
150
|
+
let e = a.createElement("base");
|
|
151
|
+
e.setAttribute("target", "_blank"), s.push(e);
|
|
152
|
+
}
|
|
153
|
+
if (t !== "thumbnail") {
|
|
154
|
+
let e = a.createElement("script");
|
|
155
|
+
t === "static" && e.setAttribute("nonce", r), e.textContent = E(n, i), s.push(e);
|
|
156
|
+
}
|
|
157
|
+
return a.head.prepend(...s), `<!DOCTYPE html>${a.documentElement.outerHTML}`;
|
|
158
|
+
}, k = (e) => {
|
|
159
|
+
let t = new DOMParser().parseFromString(e, "text/html");
|
|
160
|
+
return { hasScripts: t.querySelector("script") !== null || Array.from(t.querySelectorAll("*")).some((e) => e.getAttributeNames().some((e) => e.startsWith("on"))) || t.querySelector("a[href^=\"javascript:\" i]") !== null };
|
|
161
|
+
}, A = ({ link: t, onClose: o }) => {
|
|
162
|
+
let s = e(), l = a(), f = c(null);
|
|
163
|
+
return i(() => {
|
|
164
|
+
f.current?.focus();
|
|
165
|
+
}, [t.href]), /* @__PURE__ */ d("div", {
|
|
166
|
+
role: "alertdialog",
|
|
167
|
+
"aria-labelledby": l,
|
|
168
|
+
onKeyDown: (e) => {
|
|
169
|
+
e.key === "Escape" && (e.stopPropagation(), o());
|
|
170
|
+
},
|
|
171
|
+
className: "absolute inset-x-3 top-3 z-10 flex flex-row flex-wrap items-center gap-3 rounded-lg border border-solid border-f1-border-secondary bg-f1-background p-3 shadow-md",
|
|
172
|
+
children: [/* @__PURE__ */ u("span", {
|
|
173
|
+
id: l,
|
|
174
|
+
className: "min-w-0 grow break-all text-sm text-f1-foreground",
|
|
175
|
+
children: s.t("pdfViewer.externalLinkTitle", { host: t.host })
|
|
176
|
+
}), /* @__PURE__ */ d("div", {
|
|
177
|
+
className: "flex shrink-0 flex-row gap-2",
|
|
178
|
+
children: [/* @__PURE__ */ u(n, {
|
|
179
|
+
variant: "outline",
|
|
180
|
+
size: "sm",
|
|
181
|
+
label: s.actions.cancel,
|
|
182
|
+
onClick: o
|
|
183
|
+
}), /* @__PURE__ */ u(n, {
|
|
184
|
+
ref: f,
|
|
185
|
+
variant: "default",
|
|
186
|
+
size: "sm",
|
|
187
|
+
icon: r,
|
|
188
|
+
label: s.pdfViewer.externalLinkOpen,
|
|
189
|
+
onClick: () => {
|
|
190
|
+
window.open(t.href, "_blank", "noopener,noreferrer"), o();
|
|
191
|
+
}
|
|
192
|
+
})]
|
|
193
|
+
})]
|
|
194
|
+
});
|
|
195
|
+
}, j = ({ frameRef: e, token: t, origin: n, onReady: r }) => {
|
|
196
|
+
let [a, o] = l(null), s = c(r);
|
|
197
|
+
return i(() => {
|
|
198
|
+
s.current = r;
|
|
199
|
+
}), i(() => {
|
|
200
|
+
let r = (r) => {
|
|
201
|
+
let i = e.current;
|
|
202
|
+
if (!i || r.source !== i.contentWindow || n !== void 0 && r.origin !== n) return;
|
|
203
|
+
let a = g(r.data, t);
|
|
204
|
+
if (a) {
|
|
205
|
+
if (a.type === "ready") s.current?.();
|
|
206
|
+
else if (document.activeElement === i) {
|
|
207
|
+
if (a.type === "open-link") {
|
|
208
|
+
let e = v(a.href);
|
|
209
|
+
e && o(e);
|
|
210
|
+
} else i.dispatchEvent(new KeyboardEvent("keydown", {
|
|
211
|
+
key: a.key,
|
|
212
|
+
bubbles: !0,
|
|
213
|
+
cancelable: !0
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
return window.addEventListener("message", r), () => window.removeEventListener("message", r);
|
|
219
|
+
}, [
|
|
220
|
+
e,
|
|
221
|
+
t,
|
|
222
|
+
n
|
|
223
|
+
]), {
|
|
224
|
+
link: a,
|
|
225
|
+
closeLink: () => o(null)
|
|
226
|
+
};
|
|
227
|
+
}, M = [
|
|
228
|
+
"accelerometer",
|
|
229
|
+
"autoplay",
|
|
230
|
+
"camera",
|
|
231
|
+
"clipboard-read",
|
|
232
|
+
"clipboard-write",
|
|
233
|
+
"display-capture",
|
|
234
|
+
"encrypted-media",
|
|
235
|
+
"fullscreen",
|
|
236
|
+
"geolocation",
|
|
237
|
+
"gyroscope",
|
|
238
|
+
"magnetometer",
|
|
239
|
+
"microphone",
|
|
240
|
+
"midi",
|
|
241
|
+
"payment",
|
|
242
|
+
"picture-in-picture",
|
|
243
|
+
"publickey-credentials-get",
|
|
244
|
+
"screen-wake-lock",
|
|
245
|
+
"usb",
|
|
246
|
+
"web-share",
|
|
247
|
+
"xr-spatial-tracking"
|
|
248
|
+
].map((e) => `${e} 'none'`).join("; "), N = "allow-scripts", P = 250, F = 3, I = ({ html: e, title: n, mode: r = "static", interactive: a = !0, className: f, onReady: p, onHandshakeFailed: m, onNavigatedAway: h }) => {
|
|
249
|
+
let g = c(null), [_] = l(y), [v] = l(y), [b, x] = l(0), [S, C] = l(null), w = c(null), T = c(!1), E = c(0), D = c(), k = c(m), I = c(h);
|
|
250
|
+
i(() => {
|
|
251
|
+
k.current = m, I.current = h;
|
|
252
|
+
});
|
|
253
|
+
let L = s(() => O(e, {
|
|
254
|
+
mode: a ? r : "thumbnail",
|
|
255
|
+
token: _,
|
|
256
|
+
nonce: v,
|
|
257
|
+
parentOrigin: window.location.origin
|
|
258
|
+
}), [
|
|
259
|
+
e,
|
|
260
|
+
a,
|
|
261
|
+
r,
|
|
262
|
+
_,
|
|
263
|
+
v
|
|
264
|
+
]), { link: R, closeLink: z } = j({
|
|
265
|
+
frameRef: g,
|
|
266
|
+
token: _,
|
|
267
|
+
onReady: () => {
|
|
268
|
+
T.current = !0, p?.();
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
return o(() => {
|
|
272
|
+
T.current = !1, clearTimeout(D.current);
|
|
273
|
+
}, [L, b]), i(() => {
|
|
274
|
+
E.current = 0, w.current = null;
|
|
275
|
+
}, [L]), i(() => () => clearTimeout(D.current), []), i(() => {
|
|
276
|
+
a || g.current?.setAttribute("inert", "");
|
|
277
|
+
}, [a, b]), S === L ? null : /* @__PURE__ */ d("div", {
|
|
278
|
+
className: t("relative h-full w-full", !a && "pointer-events-none", f),
|
|
279
|
+
children: [/* @__PURE__ */ u("iframe", {
|
|
280
|
+
ref: g,
|
|
281
|
+
title: n,
|
|
282
|
+
srcDoc: L,
|
|
283
|
+
sandbox: a ? N : "",
|
|
284
|
+
allow: M,
|
|
285
|
+
referrerPolicy: "no-referrer",
|
|
286
|
+
onLoad: () => {
|
|
287
|
+
if (a) {
|
|
288
|
+
if (w.current === L) {
|
|
289
|
+
if (w.current = null, z(), E.current >= F) {
|
|
290
|
+
clearTimeout(D.current), C(L), I.current?.();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
E.current += 1, x((e) => e + 1);
|
|
294
|
+
} else w.current = L, clearTimeout(D.current), D.current = setTimeout(() => {
|
|
295
|
+
T.current || k.current?.();
|
|
296
|
+
}, P);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
"aria-hidden": !a || void 0,
|
|
300
|
+
tabIndex: a ? void 0 : -1,
|
|
301
|
+
className: "block h-full w-full border-0"
|
|
302
|
+
}, b), R ? /* @__PURE__ */ u(A, {
|
|
303
|
+
link: R,
|
|
304
|
+
onClose: z
|
|
305
|
+
}) : null]
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
//#endregion
|
|
309
|
+
export { O as a, p as c, A as i, _ as l, I as n, k as o, j as r, f as s, M as t, y as u };
|