@factorialco/f0-react 8.28.3 → 8.29.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.
Files changed (33) hide show
  1. package/dist/{ChatDocxThumbnail-D5hDwmp7.js → ChatDocxThumbnail-DTpOzL9A.js} +7 -7
  2. package/dist/{ChatPdfThumbnail-Cf74m771.js → ChatPdfThumbnail-Dj7xNA9A.js} +1 -1
  3. package/dist/{ChatPostComposerDialog-pRNELk68.js → ChatPostComposerDialog-BX6memv2.js} +3 -3
  4. package/dist/{ChatSheetThumbnail-D8aN1W_0.js → ChatSheetThumbnail-CyiwSdZJ.js} +1 -1
  5. package/dist/{DocumentToolbar-C4DUcWl7.js → DocumentToolbar-kzj-lnsk.js} +2 -2
  6. package/dist/{DocxViewer-M4FGdd_h.js → DocxViewer-Dbi2Iu1v.js} +7 -7
  7. package/dist/{F0AiProcessingOverlay-Cpx37q3a.js → F0AiProcessingOverlay-B0cBiNJx.js} +1 -1
  8. package/dist/{F0CanvasPanel-CRTe0CIF.js → F0CanvasPanel-CruNufKc.js} +191 -191
  9. package/dist/{F0Map-BywRoarL.js → F0Map-vyJ9l9av.js} +1266 -1134
  10. package/dist/{F0VideoPlayer-DUv08bcV.js → F0VideoPlayer-B4Tyl9fv.js} +18 -18
  11. package/dist/{MapProvider-CTtL5mc3.js → MapProvider-DpAl-lEe.js} +2 -2
  12. package/dist/SheetViewer-Q6MZNxhH.js +123 -0
  13. package/dist/{TextViewer-54DAaDA1.js → TextViewer-CUzoNSgl.js} +2 -2
  14. package/dist/ai.js +2 -2
  15. package/dist/component-status.js +1 -1
  16. package/dist/{experimental-STLmChcB.js → experimental-yqG2fG7V.js} +179 -179
  17. package/dist/experimental.d.ts +29 -4
  18. package/dist/experimental.js +54 -53
  19. package/dist/f0.js +10 -10
  20. package/dist/index-Bigrthbl.js +4 -0
  21. package/dist/{index-BXS__6p-.js → index-CHdKPPbt.js} +3 -3
  22. package/dist/{index-CKzBQYgd.js → index-CJqhKIrf.js} +195 -145
  23. package/dist/index-D86jd9Uj.js +358 -0
  24. package/dist/{index-9MKvlApA.js → index-DIiH9OpT.js} +28 -28
  25. package/dist/{pdfWorker-DACTjTuR.js → pdfWorker-C1_PScVO.js} +2 -2
  26. package/dist/{docx-preview-BaRDMyPN.js → renderDocx-CVEzw9MK.js} +920 -901
  27. package/dist/sheetPreview-Bqj3xODH.js +51 -0
  28. package/dist/styles.css +1 -1
  29. package/package.json +1 -1
  30. package/dist/SheetViewer-BK9NNMZ9.js +0 -111
  31. package/dist/index-D0rQW0DI.js +0 -4
  32. package/dist/index-DFrzKaGA.js +0 -322
  33. package/dist/sheetPreview-Djc-YyVs.js +0 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/f0-react",
3
- "version": "8.28.3",
3
+ "version": "8.29.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/factorialco/f0.git",
@@ -1,111 +0,0 @@
1
- import { jsx as r, jsxs as n, Fragment as k } from "react/jsx-runtime";
2
- import { useState as f, useEffect as S } from "react";
3
- import { u as V, T as E, h as R, S as z } from "./F0CanvasPanel-CRTe0CIF.js";
4
- import { f as _, c as j } from "./sheetPreview-Djc-YyVs.js";
5
- import { u as F, D as I } from "./DocumentToolbar-C4DUcWl7.js";
6
- const x = 1e3, T = 100, O = ({
7
- url: a,
8
- filename: w,
9
- withCredentials: l = !0,
10
- actions: N,
11
- toolbar: c = "top"
12
- }) => {
13
- const d = V(), m = F(), [t, u] = f(null), [v, i] = f(!1), [h, b] = f(0);
14
- S(() => {
15
- let e = !1;
16
- return u(null), i(!1), b(0), _(a, {
17
- maxRows: x,
18
- maxCols: T,
19
- withCredentials: l
20
- }).then((o) => {
21
- e || (o.length === 0 ? i(!0) : u(o));
22
- }).catch(() => {
23
- e || i(!0);
24
- }), () => {
25
- e = !0;
26
- };
27
- }, [a, l]);
28
- const s = t ? t[Math.min(h, t.length - 1)] : null, p = s ? j(s.rows) : [], g = /* @__PURE__ */ r(
29
- I,
30
- {
31
- url: a,
32
- filename: w,
33
- withCredentials: l,
34
- actions: N,
35
- zoom: m,
36
- placement: c,
37
- children: t && t.length > 1 ? /* @__PURE__ */ r(
38
- E,
39
- {
40
- type: "single",
41
- size: "sm",
42
- value: String(h),
43
- onValueChange: (e) => {
44
- e && b(Number(e));
45
- },
46
- className: "justify-start",
47
- children: t.map((e, o) => /* @__PURE__ */ r(
48
- R,
49
- {
50
- value: String(o),
51
- className: "whitespace-nowrap",
52
- children: e.name
53
- },
54
- `${e.name}-${o}`
55
- ))
56
- }
57
- ) : null
58
- }
59
- );
60
- return /* @__PURE__ */ n("div", { className: "relative flex h-full w-full flex-col bg-f1-background", children: [
61
- c === "top" ? g : null,
62
- v ? /* @__PURE__ */ r("div", { className: "flex min-h-0 grow items-center justify-center text-f1-foreground-secondary", children: d.pdfViewer.previewFailed }) : s ? /* @__PURE__ */ n(k, { children: [
63
- /* @__PURE__ */ r("div", { className: "min-h-0 grow overflow-auto", children: /* @__PURE__ */ n(
64
- "table",
65
- {
66
- className: "border-collapse text-sm",
67
- style: { zoom: m.scale },
68
- children: [
69
- /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ n("tr", { children: [
70
- /* @__PURE__ */ r("th", { className: "sticky top-0 z-10 border border-solid border-f1-border-secondary bg-f1-background-secondary px-2 py-1" }),
71
- p.map((e) => /* @__PURE__ */ r(
72
- "th",
73
- {
74
- 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",
75
- children: e
76
- },
77
- e
78
- ))
79
- ] }) }),
80
- /* @__PURE__ */ r("tbody", { children: s.rows.map((e, o) => /* @__PURE__ */ n("tr", { children: [
81
- /* @__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: o + 1 }),
82
- p.map((W, y) => /* @__PURE__ */ r(
83
- "td",
84
- {
85
- className: "whitespace-nowrap border border-solid border-f1-border-secondary px-2 py-1 text-f1-foreground",
86
- children: e[y] ?? ""
87
- },
88
- y
89
- ))
90
- ] }, o)) })
91
- ]
92
- }
93
- ) }),
94
- s.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: d.t("pdfViewer.showingFirstRows.other", {
95
- count: x
96
- }) }) : null
97
- ] }) : /* @__PURE__ */ r(
98
- z,
99
- {
100
- role: "status",
101
- "aria-busy": !0,
102
- "aria-label": d.pdfViewer.loading,
103
- className: "min-h-0 w-full grow rounded-none"
104
- }
105
- ),
106
- c === "floating" ? g : null
107
- ] });
108
- };
109
- export {
110
- O as default
111
- };
@@ -1,4 +0,0 @@
1
- import { F as r } from "./F0VideoPlayer-DUv08bcV.js";
2
- export {
3
- r as F0VideoPlayer
4
- };
@@ -1,322 +0,0 @@
1
- import { n as E } from "./F0CanvasPanel-CRTe0CIF.js";
2
- const P = 5.3, G = 11 - P, S = (e) => {
3
- let t, r;
4
- return {
5
- set: (s) => {
6
- if (!s) {
7
- r?.remove(), r = void 0, t = void 0;
8
- return;
9
- }
10
- if (!t) {
11
- t = document.createElement("div"), t.style.cssText = [
12
- `width:${P * 2}px`,
13
- `height:${P * 2}px`,
14
- "border-radius:50%",
15
- `background:hsl(${E.malibu[60]})`,
16
- `box-shadow:0 0 0 ${G}px hsl(${E.malibu[50]} / 0.3)`,
17
- "pointer-events:none"
18
- ].join(";"), r = e.add(t, s, { beneath: !0 });
19
- return;
20
- }
21
- r?.setPosition(s);
22
- }
23
- };
24
- }, _ = (e) => e.map(([t, r]) => ({ lat: r, lng: t })), b = (e, t) => ({
25
- strokeColor: t && e.hover?.color || e.color,
26
- strokeWeight: t && e.hover?.width || e.width,
27
- strokeOpacity: e.dashed ? 0 : (t ? e.hover?.opacity : void 0) ?? e.opacity,
28
- // Google has no dash array on a stroke: a dashed line is an invisible stroke
29
- // carrying repeated dot symbols, spaced to match MapLibre's [1.5, 2.8].
30
- icons: e.dashed ? [
31
- {
32
- icon: {
33
- path: "M 0,-1 0,1",
34
- strokeOpacity: (t ? e.hover?.opacity : void 0) ?? e.opacity,
35
- strokeWeight: t && e.hover?.width || e.width,
36
- scale: 1
37
- },
38
- offset: "0",
39
- repeat: `${(t && e.hover?.width || e.width) * 2.9}px`
40
- }
41
- ] : void 0
42
- }), W = (e) => {
43
- let t = [];
44
- const r = () => {
45
- for (const s of t)
46
- s.listeners.forEach((a) => a.remove()), s.polyline.setMap(null);
47
- t = [];
48
- };
49
- return {
50
- set: (s, a) => {
51
- r(), t = s.map((l) => {
52
- const p = new google.maps.Polyline({
53
- map: e,
54
- path: _(l.coordinates),
55
- clickable: !!a,
56
- ...b(l, !1)
57
- }), u = [];
58
- return a && u.push(
59
- p.addListener("mouseover", () => {
60
- p.setOptions(b(l, !0)), e.setOptions({ draggableCursor: "pointer" });
61
- }),
62
- p.addListener("mouseout", () => {
63
- p.setOptions(b(l, !1)), e.setOptions({ draggableCursor: null });
64
- }),
65
- p.addListener("click", () => a(l.id))
66
- ), { line: l, polyline: p, listeners: u };
67
- });
68
- },
69
- destroy: r
70
- };
71
- }, L = "__f0GoogleMapsReady", j = "https://maps.googleapis.com/maps/api/js";
72
- let v;
73
- const C = () => new Error("F0Map: the Google Maps JavaScript API failed to load."), A = () => window.google?.maps, B = async () => {
74
- const e = A();
75
- if (e?.importLibrary) {
76
- await e.importLibrary("maps");
77
- return;
78
- }
79
- if (!e?.Map)
80
- throw C();
81
- }, H = (e) => new Promise((t, r) => {
82
- e.addEventListener("load", () => t(), { once: !0 }), e.addEventListener("error", () => r(C()), { once: !0 });
83
- }), K = (e) => new Promise((t, r) => {
84
- const s = window;
85
- s[L] = () => {
86
- Reflect.deleteProperty(s, L), t();
87
- };
88
- const a = document.createElement("script");
89
- a.async = !0, a.src = j + `?key=${encodeURIComponent(e)}&v=weekly&loading=async&libraries=maps&callback=${L}`, a.onerror = () => {
90
- a.remove(), r(C());
91
- }, document.head.appendChild(a);
92
- }), D = (e) => {
93
- if (v)
94
- return v;
95
- const t = document.querySelector(
96
- `script[src^="${j}"]`
97
- );
98
- return v = (A() ? Promise.resolve() : t ? H(t) : K(e)).then(B).catch((s) => {
99
- throw v = void 0, s;
100
- }), v;
101
- }, U = (e) => {
102
- const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
103
- let s, a, l = !1, p = !1;
104
- const u = (c, h) => {
105
- const o = h.fromLatLngToDivPixel(
106
- new google.maps.LatLng(c.at[1], c.at[0])
107
- );
108
- o && (c.element.style.transform = `translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`);
109
- };
110
- class x extends google.maps.OverlayView {
111
- onAdd() {
112
- const h = this.getPanes(), o = () => {
113
- const n = document.createElement("div");
114
- return n.style.cssText = "position:absolute;left:0;top:0;width:0;height:0", n;
115
- };
116
- s = o(), a = o();
117
- for (const n of t)
118
- (n.beneath ? a : s).appendChild(n.element);
119
- h?.overlayMouseTarget.appendChild(s), h?.mapPane.appendChild(a);
120
- }
121
- draw() {
122
- const h = this.getProjection();
123
- if (h) {
124
- for (const o of t)
125
- u(o, h);
126
- l || (l = !0, r.forEach((o) => o()));
127
- }
128
- }
129
- onRemove() {
130
- s?.remove(), a?.remove(), s = void 0, a = void 0;
131
- }
132
- }
133
- const y = new x();
134
- y.setMap(e);
135
- const f = () => p ? void 0 : y.getProjection();
136
- return {
137
- add: (c, h, o) => {
138
- const n = { element: c, at: h, beneath: o?.beneath ?? !1 };
139
- t.add(n), c.style.position = "absolute", (n.beneath ? a : s)?.appendChild(c);
140
- const d = f();
141
- return d && u(n, d), {
142
- setPosition: (i) => {
143
- n.at = i;
144
- const m = f();
145
- m && u(n, m);
146
- },
147
- remove: () => {
148
- t.delete(n), c.remove();
149
- }
150
- };
151
- },
152
- onReady: (c) => l ? (c(), () => {
153
- }) : (r.add(c), () => r.delete(c)),
154
- isReady: () => l,
155
- destroy: () => {
156
- p = !0, l = !1, r.clear();
157
- for (const c of t)
158
- c.element.remove();
159
- t.clear(), y.setMap(null);
160
- }
161
- };
162
- }, M = 256, O = ([e, t]) => {
163
- const r = Math.min(
164
- Math.max(Math.sin(t * Math.PI / 180), -0.9999),
165
- 0.9999
166
- );
167
- return {
168
- x: M * (0.5 + e / 360),
169
- y: M * (0.5 - Math.log((1 + r) / (1 - r)) / (4 * Math.PI))
170
- };
171
- }, N = ({ x: e, y: t }) => [
172
- (e / M - 0.5) * 360,
173
- Math.atan(Math.sinh(Math.PI * (1 - 2 * t / M))) * 180 / Math.PI
174
- ], V = {
175
- globeProjection: !1,
176
- /**
177
- * The getters report the destination in the same tick, so a flight in
178
- * progress cannot be read even though the renderer glides.
179
- */
180
- observableFlight: !1
181
- }, I = (e) => e, w = ([e, t]) => ({ lat: t, lng: e }), q = {
182
- move: "bounds_changed",
183
- zoom: "zoom_changed",
184
- click: "click",
185
- styled: "idle"
186
- }, J = (e) => {
187
- const t = document.createElement("div");
188
- t.style.cssText = "position:absolute;inset:0", e.container.appendChild(t);
189
- const r = new google.maps.Map(t, {
190
- center: w(e.center),
191
- zoom: e.zoom,
192
- minZoom: e.minZoom,
193
- maxZoom: e.maxZoom,
194
- // No `mapId` deliberately: with one, `styles` is ignored and the theme is
195
- // immutable after the first render, so a light/dark swap means a teardown.
196
- styles: I(e.style),
197
- disableDefaultUI: !0,
198
- gestureHandling: e.interactive ? e.cooperativeGestures ? "cooperative" : "greedy" : "none"
199
- }), s = U(r), a = S(s), l = W(r);
200
- let p = !1;
201
- const u = () => r.getZoom() ?? e.zoom, x = () => {
202
- const o = r.getCenter();
203
- return o ? [o.lng(), o.lat()] : e.center;
204
- }, y = () => p || !s.isReady() ? null : {
205
- scale: 2 ** u(),
206
- centre: O(x()),
207
- half: { x: t.clientWidth / 2, y: t.clientHeight / 2 }
208
- }, f = (o) => {
209
- const n = y();
210
- if (!n)
211
- return null;
212
- const d = O(o);
213
- return {
214
- x: (d.x - n.centre.x) * n.scale + n.half.x,
215
- y: (d.y - n.centre.y) * n.scale + n.half.y
216
- };
217
- }, c = (o) => {
218
- const n = y();
219
- return n ? N({
220
- x: n.centre.x + (o.x - n.half.x) / n.scale,
221
- y: n.centre.y + (o.y - n.half.y) / n.scale
222
- }) : null;
223
- }, h = (o) => {
224
- r.panTo(w(o.center)), o.zoom !== void 0 && r.setZoom(o.zoom);
225
- };
226
- return {
227
- provider: "google",
228
- capabilities: V,
229
- native: () => r,
230
- isAlive: () => !p,
231
- destroy: () => {
232
- p = !0, l.destroy(), a.set(null), s.destroy(), t.remove();
233
- },
234
- on: (o, n) => {
235
- if (o === "ready")
236
- return s.onReady(n);
237
- if (o === "resize") {
238
- const i = new ResizeObserver(() => n());
239
- return i.observe(e.container), () => i.disconnect();
240
- }
241
- if (o === "error") {
242
- const i = window, m = i.gm_authFailure;
243
- return i.gm_authFailure = n, () => {
244
- i.gm_authFailure = m;
245
- };
246
- }
247
- const d = r.addListener(q[o], n);
248
- return () => d.remove();
249
- },
250
- project: f,
251
- unproject: c,
252
- getZoom: u,
253
- getCenter: x,
254
- jumpTo: (o) => {
255
- r.moveCamera({
256
- center: w(o.center),
257
- ...o.zoom === void 0 ? {} : { zoom: o.zoom }
258
- });
259
- },
260
- easeTo: h,
261
- // No coupled pan+zoom arc exists here; the renderer glides on its own.
262
- flyTo: h,
263
- fitCoordinates: (o, n) => {
264
- const d = new google.maps.LatLngBounds();
265
- o.forEach((m) => d.extend(w(m)));
266
- const i = n?.gutter ?? 0;
267
- if (r.fitBounds(d, {
268
- top: i,
269
- right: i,
270
- bottom: i,
271
- left: i
272
- }), n?.maxZoom !== void 0) {
273
- const m = r.getZoom();
274
- m !== void 0 && m > n.maxZoom && r.setZoom(n.maxZoom);
275
- }
276
- },
277
- // Google has no `cameraForBounds`: the pixel box at the current zoom gives
278
- // the scale change to fit, which is a zoom delta.
279
- cameraForCoordinates: (o, n) => {
280
- if (o.length === 0)
281
- return null;
282
- const d = o.map(f);
283
- if (d.some((g) => g === null))
284
- return null;
285
- const i = d.map((g) => g.x), m = d.map((g) => g.y), z = c({
286
- x: (Math.min(...i) + Math.max(...i)) / 2,
287
- y: (Math.min(...m) + Math.max(...m)) / 2
288
- });
289
- if (!z)
290
- return null;
291
- const Z = n?.gutter ?? 0, R = Math.max(Math.max(...i) - Math.min(...i), 1), T = Math.max(Math.max(...m) - Math.min(...m), 1), k = {
292
- width: Math.max(e.container.clientWidth - Z * 2, 1),
293
- height: Math.max(e.container.clientHeight - Z * 2, 1)
294
- }, $ = Math.min(k.width / R, k.height / T), F = Math.min(
295
- u() + Math.log2($),
296
- n?.maxZoom ?? 1 / 0
297
- );
298
- return { center: z, zoom: F };
299
- },
300
- addDomMarker: s.add,
301
- setLines: (o, n) => l.set(o, n?.onClick),
302
- setCurrentLocation: (o) => a.set(o),
303
- zoomIn: () => r.setZoom(u() + 1),
304
- zoomOut: () => r.setZoom(u() - 1),
305
- // Google re-reads its container on its own; there is nothing to poke.
306
- resize: () => {
307
- },
308
- applyStyle: (o) => r.setOptions({ styles: I(o) }),
309
- setGlobeProjection: () => {
310
- }
311
- };
312
- }, X = async (e) => {
313
- if (!e?.apiKey)
314
- throw new Error(
315
- "F0Map: the google provider needs an apiKey on <F0Provider map={{ config: { apiKey } }}>."
316
- );
317
- return await D(e.apiKey), J;
318
- };
319
- export {
320
- J as createGoogleAdapter,
321
- X as loadGoogleAdapter
322
- };
@@ -1,37 +0,0 @@
1
- import { read as d, utils as c } from "./xlsx-CzlURDDb.js";
2
- const i = (n, { maxRows: o, maxCols: s }) => {
3
- const r = d(n, { type: "array" });
4
- return r.SheetNames.map((t) => {
5
- const a = r.Sheets[t], f = a?.["!ref"];
6
- if (!a || !f)
7
- return { name: t, rows: [], truncatedRows: !1 };
8
- const e = c.decode_range(f), h = e.e.r - e.s.r + 1 > o;
9
- e.e.r = Math.min(e.e.r, e.s.r + o - 1), e.e.c = Math.min(e.e.c, e.s.c + s - 1);
10
- const u = c.sheet_to_json(a, {
11
- header: 1,
12
- raw: !1,
13
- // formatted text, not raw values
14
- defval: "",
15
- range: e
16
- });
17
- return { name: t, rows: u, truncatedRows: h };
18
- });
19
- }, w = (n) => {
20
- const o = n.reduce((s, r) => Math.max(s, r.length), 0);
21
- return Array.from({ length: o }, (s, r) => c.encode_col(r));
22
- }, k = async (n, {
23
- maxRows: o,
24
- maxCols: s,
25
- withCredentials: r = !0
26
- }) => {
27
- const t = await fetch(n, {
28
- credentials: r ? "include" : "same-origin"
29
- });
30
- if (!t.ok)
31
- throw new Error(`Failed to fetch sheet: ${t.status}`);
32
- return i(await t.arrayBuffer(), { maxRows: o, maxCols: s });
33
- };
34
- export {
35
- w as c,
36
- k as f
37
- };