@adoptai/genui-components 0.1.68 → 0.1.69

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
  "use client";
2
- import React10, { lazy, createContext, useState, useCallback, useEffect, useRef, useContext, Suspense } from 'react';
2
+ import React11, { lazy, createContext, useState, useCallback, useEffect, useRef, useContext, Suspense } from 'react';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
  import { Document, Page, pdfjs } from 'react-pdf';
5
5
  import 'react-pdf/dist/Page/AnnotationLayer.css';
@@ -1123,6 +1123,89 @@ var init_DocxViewer = __esm({
1123
1123
  }
1124
1124
  });
1125
1125
 
1126
+ // src/shared/viewers/HtmlViewer.tsx
1127
+ var HtmlViewer_exports = {};
1128
+ __export(HtmlViewer_exports, {
1129
+ HtmlViewer: () => HtmlViewer
1130
+ });
1131
+ function HtmlViewer({ url, base64, height = 480 }) {
1132
+ const { MUTED: MUTED2 } = useTheme();
1133
+ const [html, setHtml] = useState("");
1134
+ const [loading, setLoading] = useState(true);
1135
+ const [error, setError] = useState(null);
1136
+ useEffect(() => {
1137
+ let cancelled = false;
1138
+ setLoading(true);
1139
+ setError(null);
1140
+ if (base64) {
1141
+ try {
1142
+ if (!cancelled) {
1143
+ setHtml(base64ToText(base64));
1144
+ setLoading(false);
1145
+ }
1146
+ } catch (e) {
1147
+ if (!cancelled) {
1148
+ setError(e instanceof Error ? e.message : "Failed to decode HTML");
1149
+ setLoading(false);
1150
+ }
1151
+ }
1152
+ return () => {
1153
+ cancelled = true;
1154
+ };
1155
+ }
1156
+ if (!url) {
1157
+ setError("No file source provided");
1158
+ setLoading(false);
1159
+ return () => {
1160
+ cancelled = true;
1161
+ };
1162
+ }
1163
+ fetch(url).then((r) => {
1164
+ if (!r.ok) throw new Error(`Failed to fetch: ${r.status}`);
1165
+ return r.text();
1166
+ }).then((t) => {
1167
+ if (cancelled) return;
1168
+ setHtml(t);
1169
+ setLoading(false);
1170
+ }).catch((e) => {
1171
+ if (cancelled) return;
1172
+ setError(e.message);
1173
+ setLoading(false);
1174
+ });
1175
+ return () => {
1176
+ cancelled = true;
1177
+ };
1178
+ }, [url, base64]);
1179
+ if (loading) {
1180
+ return /* @__PURE__ */ jsx("div", { style: { padding: "24px", color: MUTED2, fontSize: "13px", textAlign: "center" }, children: "Loading\u2026" });
1181
+ }
1182
+ if (error) {
1183
+ return /* @__PURE__ */ jsx("div", { style: { padding: "24px", color: "#dc2626", fontSize: "13px", textAlign: "center" }, children: error });
1184
+ }
1185
+ return /* @__PURE__ */ jsx(
1186
+ "iframe",
1187
+ {
1188
+ title: "HTML preview",
1189
+ sandbox: "",
1190
+ srcDoc: html,
1191
+ style: {
1192
+ width: "100%",
1193
+ height: `${height}px`,
1194
+ border: "none",
1195
+ background: "white",
1196
+ display: "block"
1197
+ }
1198
+ }
1199
+ );
1200
+ }
1201
+ var init_HtmlViewer = __esm({
1202
+ "src/shared/viewers/HtmlViewer.tsx"() {
1203
+ "use client";
1204
+ init_ThemeContext();
1205
+ init_decode();
1206
+ }
1207
+ });
1208
+
1126
1209
  // src/shared/ColumnSettingsPanel.tsx
1127
1210
  init_ThemeContext();
1128
1211
  function ColumnSettingsPanel({ columns, hidden, onToggle, onShowAll, onHideAll }) {
@@ -1328,7 +1411,7 @@ init_theme();
1328
1411
  var FAMILIES = [
1329
1412
  { exts: ["csv", "tsv", "xls", "xlsx", "numbers"], fg: SEMANTIC.success.color, bg: SEMANTIC.success.bg },
1330
1413
  { exts: ["pdf"], fg: SEMANTIC.error.color, bg: SEMANTIC.error.bg },
1331
- { exts: ["doc", "docx", "txt", "md", "rtf", "pages"], fg: SEMANTIC.info.color, bg: SEMANTIC.info.bg },
1414
+ { exts: ["doc", "docx", "txt", "md", "rtf", "pages", "html", "htm"], fg: SEMANTIC.info.color, bg: SEMANTIC.info.bg },
1332
1415
  { exts: ["json", "yaml", "yml", "xml", "toml"], fg: SEMANTIC.purple.color, bg: SEMANTIC.purple.bg },
1333
1416
  { exts: ["zip", "tar", "gz", "rar", "7z"], fg: SEMANTIC.warning.color, bg: SEMANTIC.warning.bg },
1334
1417
  { exts: ["png", "jpg", "jpeg", "gif", "svg", "webp", "bmp"], fg: SEMANTIC.info.color, bg: SEMANTIC.info.bg }
@@ -1355,7 +1438,9 @@ var PREVIEW_EXTS = {
1355
1438
  txt: "text",
1356
1439
  log: "text",
1357
1440
  text: "text",
1358
- docx: "docx"
1441
+ docx: "docx",
1442
+ html: "html",
1443
+ htm: "html"
1359
1444
  };
1360
1445
  function extOf(fileType, filename) {
1361
1446
  var _a;
@@ -1366,6 +1451,7 @@ function extOf(fileType, filename) {
1366
1451
  if (mime.includes("csv")) return "csv";
1367
1452
  if (mime.includes("markdown")) return "md";
1368
1453
  if (mime.includes("wordprocessing") || mime.includes("msword")) return "docx";
1454
+ if (mime.includes("html")) return "html";
1369
1455
  if (mime.startsWith("text/")) return "txt";
1370
1456
  } else if (fileType) {
1371
1457
  const t = fileType.toLowerCase().replace(/[^a-z0-9]/g, "");
@@ -1409,6 +1495,7 @@ var ExcelViewer2 = lazy(
1409
1495
  var CsvViewer2 = lazy(() => Promise.resolve().then(() => (init_CsvViewer(), CsvViewer_exports)).then((m) => ({ default: m.CsvViewer })));
1410
1496
  var TextViewer2 = lazy(() => Promise.resolve().then(() => (init_TextViewer(), TextViewer_exports)).then((m) => ({ default: m.TextViewer })));
1411
1497
  var DocxViewer2 = lazy(() => Promise.resolve().then(() => (init_DocxViewer(), DocxViewer_exports)).then((m) => ({ default: m.DocxViewer })));
1498
+ var HtmlViewer2 = lazy(() => Promise.resolve().then(() => (init_HtmlViewer(), HtmlViewer_exports)).then((m) => ({ default: m.HtmlViewer })));
1412
1499
  var PEEK_ROWS = 20;
1413
1500
  var PEEK_LINES = 40;
1414
1501
  function GatedPdfViewer({ source }) {
@@ -1448,6 +1535,9 @@ function PreviewHost({ kind, source, mode = "full" }) {
1448
1535
  case "docx":
1449
1536
  viewer = /* @__PURE__ */ jsx(DocxViewer2, { url: source.url, base64: source.base64 });
1450
1537
  break;
1538
+ case "html":
1539
+ viewer = /* @__PURE__ */ jsx(HtmlViewer2, { url: source.url, base64: source.base64, height: peek ? 240 : 480 });
1540
+ break;
1451
1541
  default:
1452
1542
  return null;
1453
1543
  }
@@ -1799,7 +1889,7 @@ function FileCard({
1799
1889
  whiteSpace: "nowrap"
1800
1890
  },
1801
1891
  children: [
1802
- metaTokens.map((t, i) => /* @__PURE__ */ jsxs(React10.Fragment, { children: [
1892
+ metaTokens.map((t, i) => /* @__PURE__ */ jsxs(React11.Fragment, { children: [
1803
1893
  i > 0 && /* @__PURE__ */ jsx("span", { style: { color: MUTED2 }, children: "\xB7" }),
1804
1894
  /* @__PURE__ */ jsx("span", { children: t })
1805
1895
  ] }, i)),