@datatechsolutions/ui 2.11.52 → 2.11.55

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,9 +1,9 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
+ var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
4
5
  var chunkS7KHTUHA_js = require('./chunk-S7KHTUHA.js');
5
6
  var chunkUZ3CMNUJ_js = require('./chunk-UZ3CMNUJ.js');
6
- var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
7
7
  var Headless6 = require('@headlessui/react');
8
8
  var clsx = require('clsx');
9
9
  var React12 = require('react');
@@ -2248,6 +2248,143 @@ function renderBars(series, seriesIndex, seriesCount, count, domain, width, heig
2248
2248
  );
2249
2249
  }) }, series.name);
2250
2250
  }
2251
+ function DashboardView({ spec, className }) {
2252
+ const layout = spec.layout ?? "grid";
2253
+ const hasCharts = (spec.charts?.length ?? 0) > 0;
2254
+ const chartGrid = layout === "grid" && (spec.charts?.length ?? 0) > 1 ? "grid grid-cols-1 gap-4 lg:grid-cols-2" : "grid grid-cols-1 gap-4";
2255
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: className ?? "space-y-6", children: [
2256
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
2257
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-semibold text-slate-900 dark:text-slate-100", children: spec.title }),
2258
+ spec.subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-slate-500 dark:text-slate-400", children: spec.subtitle })
2259
+ ] }),
2260
+ spec.kpis && spec.kpis.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
2261
+ "section",
2262
+ {
2263
+ className: spec.kpis.length > 3 ? "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4" : "grid grid-cols-1 gap-3 sm:grid-cols-3",
2264
+ children: spec.kpis.map((kpi, index) => /* @__PURE__ */ jsxRuntime.jsx(KpiCard, { kpi }, `${kpi.label}-${index}`))
2265
+ }
2266
+ ),
2267
+ hasCharts && /* @__PURE__ */ jsxRuntime.jsx("section", { className: chartGrid, children: spec.charts?.map((chart, index) => /* @__PURE__ */ jsxRuntime.jsx(
2268
+ "div",
2269
+ {
2270
+ className: "rounded-xl border border-zinc-950/10 bg-white p-4 dark:border-white/10 dark:bg-zinc-900",
2271
+ children: /* @__PURE__ */ jsxRuntime.jsx(ChartRenderer, { spec: chart })
2272
+ },
2273
+ `${chart.title}-${index}`
2274
+ )) }),
2275
+ spec.table && spec.table.rows.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-xl border border-zinc-950/10 bg-white dark:border-white/10 dark:bg-zinc-900", children: [
2276
+ spec.table.title && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "border-b border-zinc-950/10 px-5 py-3 text-sm font-semibold text-slate-900 dark:border-white/10 dark:text-slate-100", children: spec.table.title }),
2277
+ /* @__PURE__ */ jsxRuntime.jsx(DashboardTableView, { table: spec.table })
2278
+ ] }),
2279
+ spec.recommendation && spec.recommendation.trim().length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-xl border border-indigo-500/20 bg-indigo-500/5 p-4 dark:border-indigo-400/30 dark:bg-indigo-500/10", children: [
2280
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-indigo-700 dark:text-indigo-300", children: "Recommendation" }),
2281
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-indigo-900 dark:text-indigo-100", children: spec.recommendation })
2282
+ ] }),
2283
+ spec.meta && Object.keys(spec.meta).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("footer", { className: "flex flex-wrap gap-4 text-[10px] text-slate-400 dark:text-slate-500", children: Object.entries(spec.meta).map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2284
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold uppercase tracking-wide", children: key }),
2285
+ ": ",
2286
+ value
2287
+ ] }, key)) })
2288
+ ] });
2289
+ }
2290
+ function KpiCard({ kpi }) {
2291
+ const value = typeof kpi.value === "number" ? formatNumber(kpi.value) : kpi.value;
2292
+ const displayValue = kpi.unit ? `${value}${kpi.unit}` : value;
2293
+ const variant = kpi.tone ?? "default";
2294
+ return /* @__PURE__ */ jsxRuntime.jsx(
2295
+ MetricCard,
2296
+ {
2297
+ title: kpi.label,
2298
+ value: displayValue,
2299
+ variant,
2300
+ trend: kpi.deltaPct !== void 0 ? { value: kpi.deltaPct } : void 0
2301
+ }
2302
+ );
2303
+ }
2304
+ function DashboardTableView({ table }) {
2305
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-zinc-200 text-sm dark:divide-zinc-700", children: [
2306
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-zinc-50 dark:bg-zinc-800/50", children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: table.columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
2307
+ "th",
2308
+ {
2309
+ scope: "col",
2310
+ className: `px-4 py-2 text-xs font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400 ${columnAlign(column.align)}`,
2311
+ children: column.label
2312
+ },
2313
+ column.key
2314
+ )) }) }),
2315
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-zinc-100 dark:divide-zinc-800", children: table.rows.map((row, rowIndex) => /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "hover:bg-zinc-50/70 dark:hover:bg-zinc-800/30", children: table.columns.map((column) => {
2316
+ const raw = row[column.key] ?? "";
2317
+ return /* @__PURE__ */ jsxRuntime.jsx(
2318
+ "td",
2319
+ {
2320
+ className: `px-4 py-2 text-slate-700 dark:text-slate-300 ${columnAlign(column.align)}`,
2321
+ children: formatCell(raw, column.format)
2322
+ },
2323
+ column.key
2324
+ );
2325
+ }) }, rowIndex)) })
2326
+ ] }) });
2327
+ }
2328
+ function columnAlign(align) {
2329
+ if (align === "right") return "text-right";
2330
+ if (align === "center") return "text-center";
2331
+ return "text-left";
2332
+ }
2333
+ function formatCell(value, format3) {
2334
+ if (value === null || value === void 0 || value === "") return "\u2014";
2335
+ if (format3 === "currency" && typeof value === "number") {
2336
+ return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(value);
2337
+ }
2338
+ if (format3 === "percent" && typeof value === "number") {
2339
+ return `${(value * 100).toFixed(1)}%`;
2340
+ }
2341
+ if (format3 === "number" && typeof value === "number") {
2342
+ return formatNumber(value);
2343
+ }
2344
+ return String(value);
2345
+ }
2346
+ function formatNumber(value) {
2347
+ if (Math.abs(value) >= 1e3) return new Intl.NumberFormat("en-US").format(Math.round(value));
2348
+ return value.toFixed(Math.abs(value) < 10 ? 2 : 1);
2349
+ }
2350
+
2351
+ // src/types/dashboard-spec.ts
2352
+ function validateDashboardSpec(spec) {
2353
+ const issues = [];
2354
+ const hasCharts = (spec.charts?.length ?? 0) > 0;
2355
+ const hasKpis = (spec.kpis?.length ?? 0) > 0;
2356
+ const hasTable = (spec.table?.rows.length ?? 0) > 0;
2357
+ const hasRecommendation = Boolean(spec.recommendation?.trim());
2358
+ if (!hasCharts && !hasKpis && !hasTable && !hasRecommendation) {
2359
+ issues.push({ kind: "empty", message: "Dashboard has no content (no charts, KPIs, table, or recommendation)." });
2360
+ }
2361
+ spec.charts?.forEach((chart, chartIndex) => {
2362
+ if (chart.series.length === 0) {
2363
+ issues.push({
2364
+ kind: "chartSeriesMissing",
2365
+ chartIndex,
2366
+ message: `Chart "${chart.title}" has no series.`
2367
+ });
2368
+ }
2369
+ });
2370
+ if (spec.table) {
2371
+ const columnKeys = new Set(spec.table.columns.map((column) => column.key));
2372
+ const reported = /* @__PURE__ */ new Set();
2373
+ for (const row of spec.table.rows) {
2374
+ for (const key of Object.keys(row)) {
2375
+ if (!columnKeys.has(key) && !reported.has(key)) {
2376
+ reported.add(key);
2377
+ issues.push({
2378
+ kind: "tableColumnMissing",
2379
+ column: key,
2380
+ message: `Table row references column "${key}" not declared in columns.`
2381
+ });
2382
+ }
2383
+ }
2384
+ }
2385
+ }
2386
+ return issues;
2387
+ }
2251
2388
  function AgentAnalysisCard({ name, avatar, duration, output }) {
2252
2389
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liquid-surface rounded-xl p-3 transition-all duration-300", children: [
2253
2390
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-1.5", children: [
@@ -20489,6 +20626,7 @@ exports.CountPill = CountPill;
20489
20626
  exports.CreateActionButton = CreateActionButton;
20490
20627
  exports.DE_THEME_CONFIG = DE_THEME_CONFIG;
20491
20628
  exports.DashboardProgressShell = DashboardProgressShell;
20629
+ exports.DashboardView = DashboardView;
20492
20630
  exports.DataPagination = DataPagination;
20493
20631
  exports.DatePicker = DatePicker;
20494
20632
  exports.DeleteSwipeAction = DeleteSwipeAction;
@@ -21109,7 +21247,8 @@ exports.useGeoMapState = useGeoMapState;
21109
21247
  exports.useNotifications = useNotifications;
21110
21248
  exports.usePlatformShellStore = usePlatformShellStore;
21111
21249
  exports.usePullToRefresh = usePullToRefresh;
21250
+ exports.validateDashboardSpec = validateDashboardSpec;
21112
21251
  exports.xScale = xScale;
21113
21252
  exports.yScale = yScale;
21114
- //# sourceMappingURL=chunk-2BUYACAN.js.map
21115
- //# sourceMappingURL=chunk-2BUYACAN.js.map
21253
+ //# sourceMappingURL=chunk-5N6QYUAA.js.map
21254
+ //# sourceMappingURL=chunk-5N6QYUAA.js.map