@factorialco/f0-react 4.43.0 → 4.44.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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as O_ } from "react/jsx-runtime";
2
- import { h as V_ } from "./F0CanvasPanel-DbqD05BD.js";
2
+ import { n as V_ } from "./F0CanvasPanel-VGTPb68G.js";
3
3
  import { useRef as Ru, useEffect as yd, useState as j_ } from "react";
4
4
  import './LocationMap.css';var Lu = { exports: {} };
5
5
  var N_ = Lu.exports, Uf;
@@ -0,0 +1,137 @@
1
+ import { jsxs as m, jsx as r, Fragment as N } from "react/jsx-runtime";
2
+ import { useState as b, useEffect as S } from "react";
3
+ import { u as v, T as _, l as R, S as V } from "./F0CanvasPanel-VGTPb68G.js";
4
+ import { utils as p, read as E } from "./xlsx-CzlURDDb.js";
5
+ import { u as M, D as j } from "./DocumentToolbar-D3GqxyBD.js";
6
+ const z = (a, { maxRows: d, maxCols: s }) => {
7
+ const n = E(a, { type: "array" });
8
+ return n.SheetNames.map((t) => {
9
+ const i = n.Sheets[t], c = i?.["!ref"];
10
+ if (!i || !c) return { name: t, rows: [], truncatedRows: !1 };
11
+ const o = p.decode_range(c), h = o.e.r - o.s.r + 1 > d;
12
+ o.e.r = Math.min(o.e.r, o.s.r + d - 1), o.e.c = Math.min(o.e.c, o.s.c + s - 1);
13
+ const f = p.sheet_to_json(i, {
14
+ header: 1,
15
+ raw: !1,
16
+ // formatted text, not raw values
17
+ defval: "",
18
+ range: o
19
+ });
20
+ return { name: t, rows: f, truncatedRows: h };
21
+ });
22
+ }, F = (a) => {
23
+ const d = a.reduce((s, n) => Math.max(s, n.length), 0);
24
+ return Array.from({ length: d }, (s, n) => p.encode_col(n));
25
+ }, W = async (a, {
26
+ maxRows: d,
27
+ maxCols: s,
28
+ withCredentials: n = !0
29
+ }) => {
30
+ const t = await fetch(a, {
31
+ credentials: n ? "include" : "same-origin"
32
+ });
33
+ if (!t.ok) throw new Error(`Failed to fetch sheet: ${t.status}`);
34
+ return z(await t.arrayBuffer(), { maxRows: d, maxCols: s });
35
+ }, k = 1e3, A = 100, O = ({
36
+ url: a,
37
+ filename: d,
38
+ withCredentials: s = !0,
39
+ actions: n
40
+ }) => {
41
+ const t = v(), i = M(), [c, o] = b(null), [h, f] = b(!1), [g, y] = b(0);
42
+ S(() => {
43
+ let e = !1;
44
+ return o(null), f(!1), y(0), W(a, {
45
+ maxRows: k,
46
+ maxCols: A,
47
+ withCredentials: s
48
+ }).then((l) => {
49
+ e || (l.length === 0 ? f(!0) : o(l));
50
+ }).catch(() => {
51
+ e || f(!0);
52
+ }), () => {
53
+ e = !0;
54
+ };
55
+ }, [a, s]);
56
+ const u = c ? c[Math.min(g, c.length - 1)] : null, w = u ? F(u.rows) : [];
57
+ return /* @__PURE__ */ m("div", { className: "flex h-full w-full flex-col bg-f1-background", children: [
58
+ /* @__PURE__ */ r(
59
+ j,
60
+ {
61
+ url: a,
62
+ filename: d,
63
+ withCredentials: s,
64
+ actions: n,
65
+ zoom: i,
66
+ children: c && c.length > 1 && /* @__PURE__ */ r(
67
+ _,
68
+ {
69
+ type: "single",
70
+ size: "sm",
71
+ value: String(g),
72
+ onValueChange: (e) => {
73
+ e && y(Number(e));
74
+ },
75
+ className: "justify-start",
76
+ children: c.map((e, l) => /* @__PURE__ */ r(
77
+ R,
78
+ {
79
+ value: String(l),
80
+ className: "whitespace-nowrap",
81
+ children: e.name
82
+ },
83
+ `${e.name}-${l}`
84
+ ))
85
+ }
86
+ )
87
+ }
88
+ ),
89
+ h ? /* @__PURE__ */ r("div", { className: "flex min-h-0 grow items-center justify-center text-f1-foreground-secondary", children: t.pdfViewer.previewFailed }) : u ? /* @__PURE__ */ m(N, { children: [
90
+ /* @__PURE__ */ r("div", { className: "min-h-0 grow overflow-auto", children: /* @__PURE__ */ m(
91
+ "table",
92
+ {
93
+ className: "border-collapse text-sm",
94
+ style: { zoom: i.scale },
95
+ children: [
96
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ m("tr", { children: [
97
+ /* @__PURE__ */ r("th", { className: "sticky top-0 z-10 border border-solid border-f1-border-secondary bg-f1-background-secondary px-2 py-1" }),
98
+ w.map((e) => /* @__PURE__ */ r(
99
+ "th",
100
+ {
101
+ className: "sticky top-0 z-10 border border-solid border-f1-border-secondary bg-f1-background-secondary px-2 py-1 text-center font-medium text-f1-foreground-secondary",
102
+ children: e
103
+ },
104
+ e
105
+ ))
106
+ ] }) }),
107
+ /* @__PURE__ */ r("tbody", { children: u.rows.map((e, l) => /* @__PURE__ */ m("tr", { children: [
108
+ /* @__PURE__ */ r("td", { className: "border border-solid border-f1-border-secondary bg-f1-background-secondary px-2 py-1 text-center text-f1-foreground-secondary", children: l + 1 }),
109
+ w.map((I, x) => /* @__PURE__ */ r(
110
+ "td",
111
+ {
112
+ className: "whitespace-nowrap border border-solid border-f1-border-secondary px-2 py-1 text-f1-foreground",
113
+ children: e[x] ?? ""
114
+ },
115
+ x
116
+ ))
117
+ ] }, l)) })
118
+ ]
119
+ }
120
+ ) }),
121
+ u.truncatedRows && /* @__PURE__ */ r("div", { className: "shrink-0 border-0 border-t border-solid border-f1-border-secondary px-3 py-1.5 text-sm text-f1-foreground-secondary", children: t.t("pdfViewer.showingFirstRows.other", {
122
+ count: k
123
+ }) })
124
+ ] }) : /* @__PURE__ */ r(
125
+ V,
126
+ {
127
+ role: "status",
128
+ "aria-busy": !0,
129
+ "aria-label": t.pdfViewer.loading,
130
+ className: "min-h-0 w-full grow rounded-none"
131
+ }
132
+ )
133
+ ] });
134
+ };
135
+ export {
136
+ O as default
137
+ };
@@ -0,0 +1,74 @@
1
+ import { jsxs as b, jsx as e } from "react/jsx-runtime";
2
+ import { useState as _, useEffect as h } from "react";
3
+ import { u as x, S as p, p as w } from "./F0CanvasPanel-VGTPb68G.js";
4
+ import { u as y, D as g } from "./DocumentToolbar-D3GqxyBD.js";
5
+ const k = 2 * 1024 * 1024, v = [
6
+ "[&_h1]:mb-3 [&_h1]:mt-6 [&_h1]:text-2xl [&_h1]:font-semibold",
7
+ "[&_h2]:mb-2 [&_h2]:mt-5 [&_h2]:text-xl [&_h2]:font-semibold",
8
+ "[&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-lg [&_h3]:font-semibold",
9
+ "[&_h4]:mb-2 [&_h4]:mt-4 [&_h4]:font-semibold",
10
+ "[&_p]:my-3",
11
+ "[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-6",
12
+ "[&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-6",
13
+ "[&_li]:my-1",
14
+ "[&_a]:text-f1-foreground-accent [&_a]:underline",
15
+ "[&_blockquote]:my-3 [&_blockquote]:border-0 [&_blockquote]:border-l-2 [&_blockquote]:border-solid [&_blockquote]:border-f1-border [&_blockquote]:pl-3 [&_blockquote]:text-f1-foreground-secondary",
16
+ "[&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-f1-background-secondary [&_pre]:p-3",
17
+ "[&_code]:font-mono [&_code]:text-sm",
18
+ "[&_table]:my-3 [&_table]:border-collapse",
19
+ "[&_th]:border [&_th]:border-solid [&_th]:border-f1-border-secondary [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-medium",
20
+ "[&_td]:border [&_td]:border-solid [&_td]:border-f1-border-secondary [&_td]:px-2 [&_td]:py-1",
21
+ "[&_hr]:my-4 [&_hr]:border-f1-border-secondary"
22
+ ].join(" "), q = (o, r) => !!r?.toLowerCase().includes("markdown") || o.toLowerCase().endsWith(".md") || o.toLowerCase().endsWith(".markdown"), M = ({
23
+ url: o,
24
+ name: r,
25
+ mimeType: i,
26
+ withCredentials: l = !0,
27
+ actions: u
28
+ }) => {
29
+ const n = x(), a = y(), [d, c] = _(null), [f, m] = _(!1);
30
+ return h(() => {
31
+ let s = !1;
32
+ return c(null), m(!1), fetch(o, { credentials: l ? "include" : "same-origin" }).then((t) => {
33
+ if (!t.ok) throw new Error(`${t.status}`);
34
+ return t.text();
35
+ }).then((t) => {
36
+ s || c(t.slice(0, k));
37
+ }).catch(() => {
38
+ s || m(!0);
39
+ }), () => {
40
+ s = !0;
41
+ };
42
+ }, [o, l]), /* @__PURE__ */ b("div", { className: "flex h-full w-full flex-col bg-f1-background", children: [
43
+ /* @__PURE__ */ e(
44
+ g,
45
+ {
46
+ url: o,
47
+ filename: r,
48
+ withCredentials: l,
49
+ actions: u,
50
+ zoom: a
51
+ }
52
+ ),
53
+ f ? /* @__PURE__ */ e("div", { className: "flex min-h-0 grow items-center justify-center text-f1-foreground-secondary", children: n.pdfViewer.previewFailed }) : d === null ? /* @__PURE__ */ e(
54
+ p,
55
+ {
56
+ role: "status",
57
+ "aria-busy": !0,
58
+ "aria-label": n.pdfViewer.loading,
59
+ className: "min-h-0 w-full grow rounded-none"
60
+ }
61
+ ) : /* @__PURE__ */ e("div", { className: "min-h-0 grow overflow-auto", children: /* @__PURE__ */ e("div", { style: { zoom: a.scale }, children: q(r, i) ? /* @__PURE__ */ e(
62
+ "div",
63
+ {
64
+ className: `mx-auto max-w-3xl px-6 py-4 text-base text-f1-foreground ${v}`,
65
+ dangerouslySetInnerHTML: {
66
+ __html: w(d)
67
+ }
68
+ }
69
+ ) : /* @__PURE__ */ e("pre", { className: "m-0 whitespace-pre-wrap break-words px-6 py-4 font-mono text-sm text-f1-foreground", children: d }) }) })
70
+ ] });
71
+ };
72
+ export {
73
+ M as default
74
+ };
package/dist/ai.d.ts CHANGED
@@ -2397,6 +2397,8 @@ export declare const defaultTranslations: {
2397
2397
  readonly closePreview: "Close";
2398
2398
  readonly previousImage: "Previous image";
2399
2399
  readonly nextImage: "Next image";
2400
+ readonly openDocument: "Open document";
2401
+ readonly documentPreview: "Document preview";
2400
2402
  readonly photo: "Photo";
2401
2403
  readonly photoCount: {
2402
2404
  readonly one: "{{count}} photo";
@@ -2704,6 +2706,11 @@ export declare const defaultTranslations: {
2704
2706
  readonly print: "Print";
2705
2707
  readonly download: "Download";
2706
2708
  readonly loading: "Loading document";
2709
+ readonly previewFailed: "Preview isn't available for this file";
2710
+ readonly showingFirstRows: {
2711
+ readonly one: "Showing the first row";
2712
+ readonly other: "Showing the first {{count}} rows";
2713
+ };
2707
2714
  };
2708
2715
  };
2709
2716
 
package/dist/ai.js CHANGED
@@ -1,6 +1,6 @@
1
- import { C as e, D as r, c as t, F as i, a as o, f as n, g as F, d as C, e as l, I as A, P as d, b as u, u as h } from "./F0CanvasPanel-DbqD05BD.js";
1
+ import { C as e, D as r, c as t, F as i, a as o, f as n, g as F, d as C, e as l, I as A, P as d, b as u, u as h } from "./F0CanvasPanel-VGTPb68G.js";
2
2
  import { defaultTranslations as c } from "./i18n-provider-defaults.js";
3
- import { A as P, C as T, t as p, s as v, v as g, y as f, l as y, i as S, q as x, z as b, B as k, p as H, r as O, j as V, e as w, g as B, k as M, F as z, T as D, w as L, h as j, a as q, n as E, m as G, o as R, b as J, f as K, x as N, c as Q, d as U, u as W } from "./F0AiProcessingOverlay-BEP7sCit.js";
3
+ import { A as P, C as T, t as p, s as v, v as g, y as f, l as y, i as S, q as x, z as b, B as k, p as H, r as O, j as V, e as w, g as B, k as M, F as z, T as D, w as L, h as j, a as q, n as E, m as G, o as R, b as J, f as K, x as N, c as Q, d as U, u as W } from "./F0AiProcessingOverlay-rViVqtAb.js";
4
4
  export {
5
5
  P as AiChatTranslationsProvider,
6
6
  e as ChatSpinner,