import { IconDatabase } from "@tabler/icons-react"; import type { DataWidgetResult } from "./data-widget-types.js"; import { DataChartWidget } from "./DataChartWidget.js"; import { DataTableWidget } from "./DataTableWidget.js"; function SummaryPill({ label, value }: { label: string; value: unknown }) { if (value === undefined || value === null || value === "") return null; return (
{label}
{typeof value === "number" ? value.toLocaleString() : String(value)}
); } export function DataInsightsWidget({ result }: { result: DataWidgetResult }) { const title = result.display?.title ?? result.title ?? "Data insights"; const summary = result.summary ?? {}; return (
{title}
{result.display?.description ? (
{result.display.description}
) : null}
{Object.entries(summary) .filter(([, value]) => typeof value !== "object") .slice(0, 4) .map(([key, value]) => ( ))}
{result.chartSeries ? ( ) : null} {result.table ? ( ) : null}
); }