@factorialco/f0-react 8.10.1 → 8.11.1

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.
Files changed (35) hide show
  1. package/dist/{ChatPdfThumbnail-DtCxNTHV.js → ChatPdfThumbnail-ELD5oua9.js} +1 -1
  2. package/dist/{ChatPostComposerDialog-DvRj6Soh.js → ChatPostComposerDialog-CwJQrIoS.js} +3 -3
  3. package/dist/DocumentToolbar-BtBTQCtY.js +113 -0
  4. package/dist/DocxViewer-DnBEWb0C.js +72 -0
  5. package/dist/{F0AiProcessingOverlay-DfZDuEp8.js → F0AiProcessingOverlay-BikXmclE.js} +1 -1
  6. package/dist/{F0CanvasPanel-CTqnQRE3.js → F0CanvasPanel-rSEKuj9G.js} +865 -863
  7. package/dist/{F0Map-CXih9UM9.js → F0Map-DFbZHu7m.js} +4 -4
  8. package/dist/{F0VideoPlayer-DK2PVVlI.js → F0VideoPlayer-Ba0vlv2e.js} +2 -2
  9. package/dist/{MapProvider-BTkCnHkC.js → MapProvider-YNqPcTEY.js} +12966 -12902
  10. package/dist/SheetViewer-Cms_aBKz.js +111 -0
  11. package/dist/{TextViewer-DK0N_Kiz.js → TextViewer-a0sR0H4H.js} +37 -32
  12. package/dist/ai.d.ts +12 -12
  13. package/dist/ai.js +2 -2
  14. package/dist/component-status.d.ts +12 -12
  15. package/dist/component-status.js +1 -1
  16. package/dist/{experimental-CpcmlTSN.js → experimental-BdZCIB78.js} +8 -8
  17. package/dist/experimental.d.ts +12 -12
  18. package/dist/experimental.js +4 -4
  19. package/dist/f0.d.ts +87 -63
  20. package/dist/f0.js +49 -48
  21. package/dist/i18n-provider-defaults.d.ts +12 -12
  22. package/dist/{index-BjzZa_Vz.js → index-BIsKzqtW.js} +2 -2
  23. package/dist/{index-4Y21ajv9.js → index-D-9j-pbd.js} +1 -1
  24. package/dist/index-DWQKn9x1.js +4 -0
  25. package/dist/{index--AsP5ABt.js → index-Df2nVRI0.js} +3 -3
  26. package/dist/index-qNKyBZ0l.js +589 -0
  27. package/dist/index2.css +1 -1
  28. package/dist/{pdfWorker-DHCbnpQ0.js → pdfWorker-Ce0sEPyw.js} +2 -2
  29. package/dist/styles.css +1 -1
  30. package/package.json +1 -1
  31. package/dist/DocumentToolbar-BIEBSN8G.js +0 -93
  32. package/dist/DocxViewer-FAppzCEm.js +0 -67
  33. package/dist/SheetViewer-DgXiYpJt.js +0 -108
  34. package/dist/index-BZYFr1nf.js +0 -4
  35. package/dist/index-zpnaxwYU.js +0 -556
@@ -1,556 +0,0 @@
1
- import { S as L, y as ye, u as q, z as Se, w as Re, i as ke, j as _e, k as Ne, A as Ce, l as Le, B as Fe, E as Ve, G as Te } from "./F0CanvasPanel-CTqnQRE3.js";
2
- import { jsx as t, jsxs as y } from "react/jsx-runtime";
3
- import { lazy as J, forwardRef as ne, Suspense as He, useState as V, useRef as A, useMemo as te, useCallback as w, useEffect as T } from "react";
4
- import { e as Ee, D as Ue, P as je, c as De } from "./pdfWorker-DHCbnpQ0.js";
5
- import { F as We } from "./Printer-BD-FEi_2.js";
6
- import { d as ae } from "./tooltip-CrXp1Uaz.js";
7
- import './index2.css';const Oe = ({
8
- label: o,
9
- width: a,
10
- height: e
11
- }) => /* @__PURE__ */ t(
12
- "div",
13
- {
14
- role: "status",
15
- "aria-label": o,
16
- "aria-live": "polite",
17
- "aria-busy": !0,
18
- className: "F0PdfViewer__page mx-auto w-fit px-4 pt-4 last:pb-4",
19
- children: /* @__PURE__ */ t(
20
- L,
21
- {
22
- style: { width: a, height: e },
23
- className: "rounded-lg border border-solid border-f1-border-secondary shadow-md"
24
- }
25
- )
26
- }
27
- ), R = ({
28
- label: o,
29
- icon: a,
30
- onClick: e,
31
- size: i = "md"
32
- }) => /* @__PURE__ */ t(
33
- ye,
34
- {
35
- label: o,
36
- icon: a,
37
- onClick: e,
38
- hideLabel: !0,
39
- variant: "outline",
40
- size: i
41
- }
42
- ), G = "flex flex-row items-center gap-2", Be = ({
43
- toolbarRef: o,
44
- currentPage: a,
45
- totalPages: e,
46
- hasDocument: i,
47
- selectedScale: s,
48
- scaleOptions: l,
49
- onPreviousPage: d,
50
- onNextPage: p,
51
- onZoomIn: m,
52
- onZoomOut: v,
53
- onScaleChange: k,
54
- rotatable: P,
55
- onRotate: g,
56
- onPrint: H,
57
- onDownload: x,
58
- actions: h
59
- }) => {
60
- const { pdfViewer: c } = q();
61
- return /* @__PURE__ */ y(
62
- "div",
63
- {
64
- ref: o,
65
- role: "toolbar",
66
- "aria-label": c.toolbar,
67
- className: ae(
68
- "F0PdfViewer__surface sticky top-0 z-10 flex flex-row items-center justify-between gap-2",
69
- "px-6 py-4"
70
- ),
71
- children: [
72
- /* @__PURE__ */ y("div", { className: G, children: [
73
- i ? /* @__PURE__ */ y(
74
- "span",
75
- {
76
- "aria-live": "polite",
77
- className: "whitespace-nowrap text-sm font-medium text-f1-foreground-secondary",
78
- children: [
79
- a,
80
- " / ",
81
- e
82
- ]
83
- }
84
- ) : null,
85
- /* @__PURE__ */ t(
86
- R,
87
- {
88
- label: c.previousPage,
89
- onClick: d,
90
- icon: Se,
91
- size: "sm"
92
- }
93
- ),
94
- /* @__PURE__ */ t(
95
- R,
96
- {
97
- label: c.nextPage,
98
- onClick: p,
99
- icon: Re,
100
- size: "sm"
101
- }
102
- )
103
- ] }),
104
- /* @__PURE__ */ y("div", { className: G, children: [
105
- /* @__PURE__ */ t(
106
- R,
107
- {
108
- label: c.zoomOut,
109
- onClick: v,
110
- icon: ke
111
- }
112
- ),
113
- /* @__PURE__ */ t(
114
- R,
115
- {
116
- label: c.zoomIn,
117
- onClick: m,
118
- icon: _e
119
- }
120
- ),
121
- /* @__PURE__ */ t(
122
- Ne,
123
- {
124
- hideLabel: !0,
125
- label: c.scaleSelector,
126
- options: l,
127
- value: s,
128
- onChange: (b) => k(b)
129
- }
130
- )
131
- ] }),
132
- /* @__PURE__ */ y("div", { className: G, children: [
133
- P ? /* @__PURE__ */ t(
134
- R,
135
- {
136
- label: c.rotate,
137
- onClick: g,
138
- icon: Ce
139
- }
140
- ) : null,
141
- /* @__PURE__ */ t(
142
- R,
143
- {
144
- label: c.print,
145
- onClick: H,
146
- icon: We
147
- }
148
- ),
149
- /* @__PURE__ */ t(
150
- R,
151
- {
152
- label: c.download,
153
- onClick: x,
154
- icon: Le
155
- }
156
- ),
157
- h?.map((b, _) => /* @__PURE__ */ t(
158
- R,
159
- {
160
- label: b.label,
161
- onClick: b.onClick,
162
- icon: b.icon
163
- },
164
- `${b.label}-${_}`
165
- ))
166
- ] })
167
- ]
168
- }
169
- );
170
- }, re = async (o) => {
171
- const a = await o.saveDocument();
172
- return new Blob([new Uint8Array(a)], { type: "application/pdf" });
173
- }, $e = async (o) => {
174
- if (!o)
175
- return;
176
- const a = URL.createObjectURL(await re(o)), e = document.createElement("iframe");
177
- e.style.display = "none", e.src = a, e.onload = () => {
178
- e.focus(), e.contentWindow?.print();
179
- const i = () => {
180
- URL.revokeObjectURL(a), e.remove();
181
- };
182
- e.contentWindow?.addEventListener("afterprint", i), setTimeout(i, 6e4);
183
- }, document.body.appendChild(e);
184
- }, ze = async (o, a) => {
185
- if (!o)
186
- return;
187
- const e = URL.createObjectURL(await re(o)), i = document.createElement("a");
188
- i.href = e, i.download = a.length > 0 ? a : "document.pdf", document.body.appendChild(i), i.click(), i.remove(), URL.revokeObjectURL(e);
189
- }, at = async (o, a, e = !0) => {
190
- let i = o, s;
191
- try {
192
- const d = await fetch(o, {
193
- credentials: e ? "include" : "same-origin"
194
- });
195
- if (!d.ok)
196
- throw new Error(`${d.status}`);
197
- s = URL.createObjectURL(await d.blob()), i = s;
198
- } catch {
199
- }
200
- const l = document.createElement("a");
201
- l.href = i, l.download = a ?? "", l.rel = "noreferrer", s || (l.target = "_blank"), document.body.appendChild(l), l.click(), l.remove(), s && URL.revokeObjectURL(s);
202
- }, Z = [
203
- "0.5",
204
- "0.75",
205
- "1",
206
- "1.25",
207
- "1.5",
208
- "2",
209
- "3",
210
- "4"
211
- ], ie = Z.map(Number), Me = (o) => ie.find((a) => a > o), Ie = (o) => [...ie].reverse().find((a) => a < o), Ae = (o, a, e) => {
212
- let i = null, s = 0;
213
- return a.forEach((l, d) => {
214
- if (!l)
215
- return;
216
- const p = l.offsetHeight, m = l.offsetTop, v = m + p, k = o.offsetHeight - e, P = o.scrollTop + e, g = P + k;
217
- if (!(P < v && g > m))
218
- return;
219
- let x;
220
- if (P <= m)
221
- x = g > v ? p : g - m;
222
- else {
223
- let h = P - m;
224
- g < v && (h += v - g), x = p - h;
225
- }
226
- x > s && (s = x, i = d + 1);
227
- }), i;
228
- };
229
- Ee();
230
- const Ge = J(() => import("./SheetViewer-DgXiYpJt.js")), Ze = J(() => import("./DocxViewer-FAppzCEm.js")), qe = J(() => import("./TextViewer-DK0N_Kiz.js")), oe = 48, le = ne(
231
- (o, a) => {
232
- const { kind: e = "pdf", mimeType: i, ...s } = o;
233
- if (e === "pdf")
234
- return /* @__PURE__ */ t(se, { ref: a, ...s });
235
- const {
236
- url: l,
237
- filename: d,
238
- actions: p,
239
- withCredentials: m = !0,
240
- page: v,
241
- pagesToDisplay: k,
242
- initialScale: P,
243
- rotatable: g,
244
- initialRotation: H,
245
- onRotationChange: x,
246
- onPdfLoaded: h,
247
- onPageChange: c,
248
- ...b
249
- } = s;
250
- return /* @__PURE__ */ t(
251
- "div",
252
- {
253
- ref: a,
254
- ...b,
255
- className: "F0PdfViewer__surface relative flex h-full w-full flex-col overflow-hidden border border-solid border-f1-border-secondary",
256
- children: /* @__PURE__ */ y(
257
- He,
258
- {
259
- fallback: /* @__PURE__ */ t(L, { className: "h-full w-full rounded-none" }),
260
- children: [
261
- e === "sheet" ? /* @__PURE__ */ t(
262
- Ge,
263
- {
264
- url: l,
265
- filename: d,
266
- withCredentials: m,
267
- actions: p
268
- }
269
- ) : null,
270
- e === "docx" ? /* @__PURE__ */ t(
271
- Ze,
272
- {
273
- url: l,
274
- filename: d,
275
- withCredentials: m,
276
- actions: p
277
- }
278
- ) : null,
279
- e === "text" ? /* @__PURE__ */ t(
280
- qe,
281
- {
282
- url: l,
283
- name: d ?? "",
284
- mimeType: i,
285
- withCredentials: m,
286
- actions: p
287
- }
288
- ) : null
289
- ]
290
- }
291
- )
292
- }
293
- );
294
- }
295
- );
296
- le.displayName = "F0PdfViewer";
297
- const se = ne((o, a) => {
298
- const {
299
- url: e,
300
- filename: i = "document.pdf",
301
- page: s = 0,
302
- pagesToDisplay: l = [],
303
- initialScale: d = "page-width",
304
- withCredentials: p = !0,
305
- rotatable: m = !1,
306
- initialRotation: v = 0,
307
- onRotationChange: k,
308
- onPdfLoaded: P,
309
- onPageChange: g,
310
- actions: H,
311
- ...x
312
- } = o, { pdfViewer: h } = q(), [c, b] = V(null), [_, K] = V([]), [N, z] = V(1), [S, Q] = V(0), [U, M] = V(d), [E, ce] = V(v), I = A(null), j = A(null), D = A([]), W = l.length > 0 ? l.length : c?.numPages, X = _.find(Boolean), Y = (X?.originalWidth ?? 595) * N, ee = (X?.originalHeight ?? 842) * N, de = te(
313
- () => [
314
- { value: "page-width", label: h.pageWidth },
315
- { value: "page-fit", label: h.pageFit },
316
- ...Z.map((n) => ({
317
- value: n,
318
- label: `${Number(n) * 100}%`
319
- }))
320
- ],
321
- [h.pageWidth, h.pageFit]
322
- ), fe = te(() => ({ url: e, withCredentials: p }), [e, p]), F = w(
323
- (n) => {
324
- const r = (W ?? 1) - 1, f = Math.min(Math.max(n, 0), r), u = D.current[f], C = u?.offsetParent;
325
- u && C instanceof HTMLElement && (C.scrollTop = u.offsetTop - (j.current?.offsetHeight ?? 0) - 10);
326
- },
327
- [W]
328
- ), O = w(
329
- (n) => {
330
- const r = _[S - 1], f = I.current;
331
- if (!r || !f)
332
- return;
333
- const u = j.current?.offsetHeight ?? 0, C = E === 90 || E === 270, $ = C ? r.originalHeight : r.originalWidth, ve = C ? r.originalWidth : r.originalHeight, xe = n === "page-width" ? (f.clientWidth - oe) / $ : (f.clientHeight - u - oe) / ve;
334
- z(xe), M(n);
335
- },
336
- [_, S, E]
337
- ), ue = w(
338
- (n) => {
339
- if (n === "page-width" || n === "page-fit") {
340
- O(n);
341
- return;
342
- }
343
- z(Number(n)), M(n);
344
- },
345
- [O]
346
- ), B = w((n) => {
347
- if (n === void 0)
348
- return;
349
- z(n);
350
- const r = Z.find((f) => Number(f) === n);
351
- r && M(r);
352
- }, []), me = w(
353
- () => B(Me(N)),
354
- [N, B]
355
- ), pe = w(
356
- () => B(Ie(N)),
357
- [N, B]
358
- ), ge = w(() => {
359
- ce((n) => {
360
- const r = (n + 90) % 360;
361
- return k?.(r), r;
362
- });
363
- }, [k]), he = w(
364
- (n) => {
365
- b(n), P?.(n), setTimeout(() => {
366
- Q(s + 1), F(s);
367
- }, 0);
368
- },
369
- [P, s, F]
370
- ), be = w((n) => {
371
- const r = n.target;
372
- if (!(r instanceof HTMLElement))
373
- return;
374
- const f = Ae(
375
- r,
376
- D.current,
377
- j.current?.offsetHeight ?? 0
378
- );
379
- f && Q(f);
380
- }, []), we = w(() => {
381
- $e(c);
382
- }, [c]), Pe = w(() => {
383
- ze(c, i);
384
- }, [c, i]);
385
- return T(() => {
386
- b(null), K([]), D.current = [];
387
- }, [e]), T(() => {
388
- F(s);
389
- }, [s, F]), T(() => {
390
- S > 0 && g?.(S);
391
- }, [S, g]), T(() => {
392
- _.length > 0 && (d === "page-width" || d === "page-fit") && O(d);
393
- }, [_.length, d]), T(() => {
394
- (U === "page-width" || U === "page-fit") && O(U);
395
- }, [E]), T(() => {
396
- const n = I.current;
397
- if (!n)
398
- return;
399
- const r = (f) => {
400
- const u = f.target;
401
- u instanceof HTMLAnchorElement && (u.target = "_blank", u.rel = "noopener noreferrer");
402
- };
403
- return n.addEventListener("click", r, !0), () => n.removeEventListener("click", r, !0);
404
- }, []), /* @__PURE__ */ t(
405
- "div",
406
- {
407
- ref: a,
408
- ...x,
409
- className: "F0PdfViewer__surface relative flex h-full w-full flex-col overflow-hidden border border-solid border-f1-border-secondary",
410
- children: /* @__PURE__ */ y(
411
- "div",
412
- {
413
- ref: I,
414
- onScroll: be,
415
- className: "F0PdfViewer__surface relative flex h-full flex-col overflow-auto [scrollbar-gutter:stable_both-edges]",
416
- children: [
417
- /* @__PURE__ */ t(
418
- Be,
419
- {
420
- toolbarRef: j,
421
- currentPage: S,
422
- totalPages: W,
423
- hasDocument: !!c?.numPages,
424
- selectedScale: U,
425
- scaleOptions: de,
426
- onPreviousPage: () => F(S - 2),
427
- onNextPage: () => F(S),
428
- onZoomIn: me,
429
- onZoomOut: pe,
430
- onScaleChange: ue,
431
- rotatable: m,
432
- onRotate: ge,
433
- onPrint: we,
434
- onDownload: Pe,
435
- actions: H
436
- }
437
- ),
438
- e ? /* @__PURE__ */ t(
439
- Ue,
440
- {
441
- file: fe,
442
- onLoadSuccess: he,
443
- loading: /* @__PURE__ */ t(
444
- Oe,
445
- {
446
- label: h.loading,
447
- width: Y,
448
- height: ee
449
- }
450
- ),
451
- children: c ? Array.from({ length: W ?? 0 }).map((n, r) => {
452
- const f = (l.length > 0 ? l[r] : r) + 1;
453
- return /* @__PURE__ */ t(
454
- "div",
455
- {
456
- className: "F0PdfViewer__page mx-auto w-fit px-4 pt-4 last:pb-4",
457
- children: /* @__PURE__ */ t(
458
- je,
459
- {
460
- className: "overflow-hidden rounded-lg border border-solid border-f1-border-secondary shadow-md",
461
- pageNumber: f,
462
- scale: N,
463
- rotate: E,
464
- loading: /* @__PURE__ */ t(
465
- L,
466
- {
467
- style: {
468
- width: Y,
469
- height: ee
470
- }
471
- }
472
- ),
473
- renderForms: !0,
474
- renderTextLayer: !0,
475
- inputRef: (u) => {
476
- D.current[r] = u;
477
- },
478
- onLoadSuccess: (u) => {
479
- K((C) => {
480
- const $ = [...C];
481
- return $[r] = {
482
- originalWidth: u.originalWidth,
483
- originalHeight: u.originalHeight
484
- }, $;
485
- });
486
- }
487
- }
488
- )
489
- },
490
- r
491
- );
492
- }) : null
493
- }
494
- ) : null
495
- ]
496
- }
497
- )
498
- }
499
- );
500
- });
501
- se.displayName = "PdfViewerBase";
502
- const Je = () => {
503
- const { pdfViewer: o } = q();
504
- return /* @__PURE__ */ y(
505
- "div",
506
- {
507
- role: "status",
508
- "aria-busy": "true",
509
- "aria-live": "polite",
510
- "aria-label": o.loading,
511
- className: ae(
512
- "F0PdfViewer__surface flex h-full w-full flex-col overflow-hidden",
513
- "border border-solid border-f1-border-secondary"
514
- ),
515
- children: [
516
- /* @__PURE__ */ y("div", { className: "flex flex-row items-center justify-between gap-2 px-6 py-4", children: [
517
- /* @__PURE__ */ t(L, { className: "h-8 w-24 rounded-md" }),
518
- /* @__PURE__ */ t(L, { className: "h-8 w-40 rounded-md" }),
519
- /* @__PURE__ */ t(L, { className: "h-8 w-20 rounded-md" })
520
- ] }),
521
- /* @__PURE__ */ t("div", { className: "flex flex-1 justify-center p-4", children: /* @__PURE__ */ t(L, { className: "h-full w-full max-w-[600px] rounded-md" }) })
522
- ]
523
- }
524
- );
525
- }, Ke = [
526
- "page-width",
527
- "page-fit",
528
- "0.5",
529
- "0.75",
530
- "1",
531
- "1.25",
532
- "1.5",
533
- "2",
534
- "3",
535
- "4"
536
- ], Qe = Fe(
537
- Ve(
538
- "F0PdfViewer",
539
- Te(le, Je)
540
- )
541
- ), rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
542
- __proto__: null,
543
- F0PdfViewer: Qe,
544
- configurePdfWorker: De,
545
- pdfScales: Ke
546
- }, Symbol.toStringTag, { value: "Module" }));
547
- export {
548
- Qe as F,
549
- R as T,
550
- Ie as a,
551
- at as d,
552
- Z as f,
553
- rt as i,
554
- Me as n,
555
- Ke as p
556
- };