@quantumwake/terminal-ux-dashboard-components 0.1.17 → 0.1.19

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.
package/dist/index.d.cts CHANGED
@@ -32,6 +32,12 @@ interface DashboardCapabilities {
32
32
  removePanel?: (panelId: string) => void;
33
33
  persistPanelData?: (panelId: string, rows: QueryResult['rows'], refreshedAt: string) => void;
34
34
  persistLayout?: (items: PanelLayout[]) => void;
35
+ panelHeaderExtra?: (panel: PanelRef) => ReactNode;
36
+ }
37
+ interface PanelRef {
38
+ id: string;
39
+ type: string;
40
+ title?: string;
35
41
  }
36
42
  interface PanelLayout {
37
43
  id: string;
@@ -65,7 +71,7 @@ declare function useCapabilities(): {
65
71
  canEditLayout: boolean;
66
72
  };
67
73
 
68
- type ChartType = 'bar' | 'grouped-bar' | 'pie' | 'line' | 'scatter' | 'heatmap';
74
+ type ChartType = 'bar' | 'grouped-bar' | 'pie' | 'line' | 'scatter' | 'heatmap' | 'heatmap-plus';
69
75
  interface ChartField {
70
76
  name: string;
71
77
  agg?: string;
@@ -81,13 +87,16 @@ interface ChartConfig {
81
87
  yFields?: ChartField[];
82
88
  valueField?: ChartField | null;
83
89
  filters?: ChartFilter[];
90
+ labelStat?: string;
91
+ colorStat?: string;
92
+ blockField?: string;
84
93
  }
85
94
  type Row = Record<string, unknown>;
86
95
  declare const qIdent: (name: string) => string;
87
96
  declare const qLit: (v: unknown) => string;
88
97
  declare const aggExpr: (agg: string | undefined, col?: string) => string;
89
98
  declare const compileWhere: (filters?: ChartFilter[]) => string;
90
- declare const buildChartSQL: ({ chartType, xFields, yFields, valueField, filters, }: ChartConfig) => string | null;
99
+ declare const buildChartSQL: ({ chartType, xFields, yFields, valueField, filters, labelStat, colorStat, blockField, }: ChartConfig) => string | null;
91
100
  declare const shapeChartData: (chartType: ChartType, rows: Row[], { yFields }?: {
92
101
  yFields?: ChartField[];
93
102
  }) => unknown;
@@ -209,10 +218,30 @@ declare const axisLegend: (style: Partial<ChartStyle> | null | undefined, axis:
209
218
  numeric?: boolean;
210
219
  }) => Record<string, unknown>;
211
220
 
212
- type AggFn = 'count' | 'distinct' | 'sum' | 'avg' | 'min' | 'max';
221
+ type AggFn = 'count' | 'distinct' | 'sum' | 'avg' | 'min' | 'max' | 'median';
213
222
  declare const groupBy: (records: Row[], column: string) => Record<string, Row[]>;
214
223
  declare const aggregate: (records: Row[], column: string, fn: AggFn | string) => number;
215
224
 
225
+ type HeatStat = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'median';
226
+ type ColorScope = 'global' | 'row' | 'column' | 'block';
227
+ type ColorMethod = 'linear' | 'rank';
228
+ declare const HEAT_STATS: HeatStat[];
229
+ interface HeatCell {
230
+ row: string;
231
+ col: string;
232
+ colorValue: number;
233
+ block?: string;
234
+ }
235
+ interface ColorOptions {
236
+ scope?: ColorScope;
237
+ method?: ColorMethod;
238
+ vmin?: number;
239
+ vmax?: number;
240
+ }
241
+ declare const normalizeCells: (cells: HeatCell[], { scope, method, vmin, vmax }?: ColorOptions) => Map<string, number>;
242
+ declare const heatColor: (t: number) => string;
243
+ declare const heatLabelColor: (t: number) => string;
244
+
216
245
  interface MetricConfig {
217
246
  column: string;
218
247
  agg?: string;
@@ -306,7 +335,7 @@ interface HeatmapSerie {
306
335
  y: number;
307
336
  }[];
308
337
  }
309
- type AxisOrder = 'alpha' | 'total-asc' | 'total-desc';
338
+ type AxisOrder$1 = 'alpha' | 'total-asc' | 'total-desc';
310
339
  interface HeatmapViewProps {
311
340
  records?: Row[];
312
341
  rowColumn: string;
@@ -314,8 +343,8 @@ interface HeatmapViewProps {
314
343
  valueColumn?: string;
315
344
  aggFn?: string;
316
345
  data?: HeatmapSerie[];
317
- rowOrder?: AxisOrder;
318
- colOrder?: AxisOrder;
346
+ rowOrder?: AxisOrder$1;
347
+ colOrder?: AxisOrder$1;
319
348
  marginAgg?: string;
320
349
  showTotals?: boolean;
321
350
  style?: Partial<ChartStyle>;
@@ -327,6 +356,42 @@ interface HeatmapViewProps {
327
356
  */
328
357
  declare function HeatmapView({ records, rowColumn, colColumn, valueColumn, aggFn, data: presetData, rowOrder, colOrder, marginAgg, showTotals, style, }: HeatmapViewProps): react.JSX.Element;
329
358
 
359
+ interface HeatPlusDatum {
360
+ r: string | null;
361
+ c: string | null;
362
+ lv: number;
363
+ cv: number;
364
+ gr?: number;
365
+ gc?: number;
366
+ block?: string;
367
+ }
368
+ type AxisOrder = 'alpha' | 'margin-asc' | 'margin-desc' | 'total-asc' | 'total-desc';
369
+ interface HeatmapPlusViewProps {
370
+ records?: Row[];
371
+ rowColumn: string;
372
+ colColumn: string;
373
+ valueColumn?: string;
374
+ labelStat?: HeatStat;
375
+ colorStat?: HeatStat;
376
+ blockField?: string;
377
+ data?: HeatPlusDatum[];
378
+ scope?: ColorScope;
379
+ method?: ColorMethod;
380
+ vmin?: number;
381
+ vmax?: number;
382
+ rowOrder?: AxisOrder;
383
+ colOrder?: AxisOrder;
384
+ showMargins?: boolean;
385
+ style?: Partial<ChartStyle>;
386
+ }
387
+ /**
388
+ * HeatmapPlusView — a cross-tab heatmap with independent label/color stats,
389
+ * margins computed over the underlying rows, and a scope/method color engine
390
+ * (see heatmapColor.ts). nivo's built-in scales normalize globally, so colors
391
+ * are precomputed per cell here and handed to nivo as a function.
392
+ */
393
+ declare function HeatmapPlusView({ records, rowColumn, colColumn, valueColumn, labelStat, colorStat, blockField, data: presetData, scope, method, vmin, vmax, rowOrder, colOrder, showMargins, style, }: HeatmapPlusViewProps): react.JSX.Element;
394
+
330
395
  interface PivotViewProps {
331
396
  records?: Row[];
332
397
  }
@@ -377,6 +442,14 @@ interface PanelConfig {
377
442
  colOrder?: string;
378
443
  marginAgg?: string;
379
444
  showTotals?: boolean;
445
+ labelStat?: string;
446
+ colorStat?: string;
447
+ blockField?: string;
448
+ scope?: string;
449
+ method?: string;
450
+ vmin?: number;
451
+ vmax?: number;
452
+ showMargins?: boolean;
380
453
  columns?: string[];
381
454
  text?: string;
382
455
  label?: string;
@@ -408,6 +481,19 @@ interface DashboardRendererProps {
408
481
  records?: Row[];
409
482
  columns?: ColumnDef[];
410
483
  }
484
+ interface PanelContentProps {
485
+ panel: DashboardPanel$1;
486
+ records?: Row[];
487
+ columns?: ColumnDef[];
488
+ }
489
+ /**
490
+ * Renders a single dashboard panel based on its type and config.
491
+ * Panels saved with a SQL query render server-side (full dataset); the rest
492
+ * fall back to client-side aggregation over the loaded records.
493
+ */
494
+ declare function PanelContent({ panel, records, columns }: PanelContentProps): react.JSX.Element | null;
495
+ declare const PanelChart: typeof PanelContent;
496
+ type PanelChartProps = PanelContentProps;
411
497
  /**
412
498
  * DashboardRenderer — renders a grid of AI-generated or manually configured
413
499
  * panels via react-grid-layout. Editing is capability-gated:
@@ -443,7 +529,7 @@ interface Column {
443
529
  name: string;
444
530
  type: string;
445
531
  }
446
- /** A selectable state (dataset) in the statefs catalog. */
532
+ /** A selectable state (dataset) in the host's catalog. */
447
533
  interface StatefsState {
448
534
  state_id: string;
449
535
  row_count?: number;
@@ -520,4 +606,4 @@ interface DataExplorerProps {
520
606
  }
521
607
  declare function DataExplorer({ records, columns, states, activeStateId, profile, dashboard, dashboardId, savedDashboards, loading, analyzing, defaultMode, tabs, onSelectState, onRefreshStates, }: DataExplorerProps): react.JSX.Element;
522
608
 
523
- export { type AggFn, type BarDatum, BarView, type BarViewProps, ChartBuilder, type ChartBuilderColumn, type ChartBuilderProps, type ChartConfig, type ChartField, type ChartFilter, type ChartPanel, type ChartStyle, ChartStyleControls, type ChartStyleControlsProps, type ChartType, DEFAULT_CHART_STYLE, type Dashboard$1 as Dashboard, type DashboardCapabilities, type DashboardContextValue, type DashboardPanel$1 as DashboardPanel, DashboardProvider, type DashboardProviderProps, DashboardRenderer, type DashboardRendererProps, type DashboardTheme, DataExplorer, type DataExplorerProps, type HeatmapSerie, HeatmapView, type HeatmapViewProps, type InsightConfig, InsightView, type InsightViewProps, LEGEND_ANCHORS, type LegendAnchor, type LegendPosition, type LineSerie, LineView, type LineViewProps, type MetricConfig, MetricView, type MetricViewProps, type PanelInput, type PanelLayout, type PieDatum, PieView, type PieViewProps, PivotView, type PivotViewProps, type QueryResult, type Row, type SavedDashboard, type ScatterSerie, ScatterView, type ScatterViewProps, SqlConsole, type SqlConsoleColumn, type SqlConsoleProps, type TitleAlign, aggExpr, aggregate, axisLegend, buildChartSQL, buildNivoTheme, compileWhere, groupBy, legendConfig, qIdent, qLit, shapeChartData, useCapabilities, useDashboard, withStyleDefaults };
609
+ export { type AggFn, type BarDatum, BarView, type BarViewProps, ChartBuilder, type ChartBuilderColumn, type ChartBuilderProps, type ChartConfig, type ChartField, type ChartFilter, type ChartPanel, type ChartStyle, ChartStyleControls, type ChartStyleControlsProps, type ChartType, type ColorMethod, type ColorOptions, type ColorScope, DEFAULT_CHART_STYLE, type Dashboard$1 as Dashboard, type DashboardCapabilities, type DashboardContextValue, type DashboardPanel$1 as DashboardPanel, DashboardProvider, type DashboardProviderProps, DashboardRenderer, type DashboardRendererProps, type DashboardTheme, DataExplorer, type DataExplorerProps, HEAT_STATS, type HeatCell, type HeatPlusDatum, type HeatStat, HeatmapPlusView, type HeatmapPlusViewProps, type HeatmapSerie, HeatmapView, type HeatmapViewProps, type InsightConfig, InsightView, type InsightViewProps, LEGEND_ANCHORS, type LegendAnchor, type LegendPosition, type LineSerie, LineView, type LineViewProps, type MetricConfig, MetricView, type MetricViewProps, PanelChart, type PanelChartProps, type PanelInput, type PanelLayout, type PanelRef, type PieDatum, PieView, type PieViewProps, PivotView, type PivotViewProps, type QueryResult, type Row, type SavedDashboard, type ScatterSerie, ScatterView, type ScatterViewProps, SqlConsole, type SqlConsoleColumn, type SqlConsoleProps, type TitleAlign, aggExpr, aggregate, axisLegend, buildChartSQL, buildNivoTheme, compileWhere, groupBy, heatColor, heatLabelColor, legendConfig, normalizeCells, qIdent, qLit, shapeChartData, useCapabilities, useDashboard, withStyleDefaults };
package/dist/index.d.ts CHANGED
@@ -32,6 +32,12 @@ interface DashboardCapabilities {
32
32
  removePanel?: (panelId: string) => void;
33
33
  persistPanelData?: (panelId: string, rows: QueryResult['rows'], refreshedAt: string) => void;
34
34
  persistLayout?: (items: PanelLayout[]) => void;
35
+ panelHeaderExtra?: (panel: PanelRef) => ReactNode;
36
+ }
37
+ interface PanelRef {
38
+ id: string;
39
+ type: string;
40
+ title?: string;
35
41
  }
36
42
  interface PanelLayout {
37
43
  id: string;
@@ -65,7 +71,7 @@ declare function useCapabilities(): {
65
71
  canEditLayout: boolean;
66
72
  };
67
73
 
68
- type ChartType = 'bar' | 'grouped-bar' | 'pie' | 'line' | 'scatter' | 'heatmap';
74
+ type ChartType = 'bar' | 'grouped-bar' | 'pie' | 'line' | 'scatter' | 'heatmap' | 'heatmap-plus';
69
75
  interface ChartField {
70
76
  name: string;
71
77
  agg?: string;
@@ -81,13 +87,16 @@ interface ChartConfig {
81
87
  yFields?: ChartField[];
82
88
  valueField?: ChartField | null;
83
89
  filters?: ChartFilter[];
90
+ labelStat?: string;
91
+ colorStat?: string;
92
+ blockField?: string;
84
93
  }
85
94
  type Row = Record<string, unknown>;
86
95
  declare const qIdent: (name: string) => string;
87
96
  declare const qLit: (v: unknown) => string;
88
97
  declare const aggExpr: (agg: string | undefined, col?: string) => string;
89
98
  declare const compileWhere: (filters?: ChartFilter[]) => string;
90
- declare const buildChartSQL: ({ chartType, xFields, yFields, valueField, filters, }: ChartConfig) => string | null;
99
+ declare const buildChartSQL: ({ chartType, xFields, yFields, valueField, filters, labelStat, colorStat, blockField, }: ChartConfig) => string | null;
91
100
  declare const shapeChartData: (chartType: ChartType, rows: Row[], { yFields }?: {
92
101
  yFields?: ChartField[];
93
102
  }) => unknown;
@@ -209,10 +218,30 @@ declare const axisLegend: (style: Partial<ChartStyle> | null | undefined, axis:
209
218
  numeric?: boolean;
210
219
  }) => Record<string, unknown>;
211
220
 
212
- type AggFn = 'count' | 'distinct' | 'sum' | 'avg' | 'min' | 'max';
221
+ type AggFn = 'count' | 'distinct' | 'sum' | 'avg' | 'min' | 'max' | 'median';
213
222
  declare const groupBy: (records: Row[], column: string) => Record<string, Row[]>;
214
223
  declare const aggregate: (records: Row[], column: string, fn: AggFn | string) => number;
215
224
 
225
+ type HeatStat = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'median';
226
+ type ColorScope = 'global' | 'row' | 'column' | 'block';
227
+ type ColorMethod = 'linear' | 'rank';
228
+ declare const HEAT_STATS: HeatStat[];
229
+ interface HeatCell {
230
+ row: string;
231
+ col: string;
232
+ colorValue: number;
233
+ block?: string;
234
+ }
235
+ interface ColorOptions {
236
+ scope?: ColorScope;
237
+ method?: ColorMethod;
238
+ vmin?: number;
239
+ vmax?: number;
240
+ }
241
+ declare const normalizeCells: (cells: HeatCell[], { scope, method, vmin, vmax }?: ColorOptions) => Map<string, number>;
242
+ declare const heatColor: (t: number) => string;
243
+ declare const heatLabelColor: (t: number) => string;
244
+
216
245
  interface MetricConfig {
217
246
  column: string;
218
247
  agg?: string;
@@ -306,7 +335,7 @@ interface HeatmapSerie {
306
335
  y: number;
307
336
  }[];
308
337
  }
309
- type AxisOrder = 'alpha' | 'total-asc' | 'total-desc';
338
+ type AxisOrder$1 = 'alpha' | 'total-asc' | 'total-desc';
310
339
  interface HeatmapViewProps {
311
340
  records?: Row[];
312
341
  rowColumn: string;
@@ -314,8 +343,8 @@ interface HeatmapViewProps {
314
343
  valueColumn?: string;
315
344
  aggFn?: string;
316
345
  data?: HeatmapSerie[];
317
- rowOrder?: AxisOrder;
318
- colOrder?: AxisOrder;
346
+ rowOrder?: AxisOrder$1;
347
+ colOrder?: AxisOrder$1;
319
348
  marginAgg?: string;
320
349
  showTotals?: boolean;
321
350
  style?: Partial<ChartStyle>;
@@ -327,6 +356,42 @@ interface HeatmapViewProps {
327
356
  */
328
357
  declare function HeatmapView({ records, rowColumn, colColumn, valueColumn, aggFn, data: presetData, rowOrder, colOrder, marginAgg, showTotals, style, }: HeatmapViewProps): react.JSX.Element;
329
358
 
359
+ interface HeatPlusDatum {
360
+ r: string | null;
361
+ c: string | null;
362
+ lv: number;
363
+ cv: number;
364
+ gr?: number;
365
+ gc?: number;
366
+ block?: string;
367
+ }
368
+ type AxisOrder = 'alpha' | 'margin-asc' | 'margin-desc' | 'total-asc' | 'total-desc';
369
+ interface HeatmapPlusViewProps {
370
+ records?: Row[];
371
+ rowColumn: string;
372
+ colColumn: string;
373
+ valueColumn?: string;
374
+ labelStat?: HeatStat;
375
+ colorStat?: HeatStat;
376
+ blockField?: string;
377
+ data?: HeatPlusDatum[];
378
+ scope?: ColorScope;
379
+ method?: ColorMethod;
380
+ vmin?: number;
381
+ vmax?: number;
382
+ rowOrder?: AxisOrder;
383
+ colOrder?: AxisOrder;
384
+ showMargins?: boolean;
385
+ style?: Partial<ChartStyle>;
386
+ }
387
+ /**
388
+ * HeatmapPlusView — a cross-tab heatmap with independent label/color stats,
389
+ * margins computed over the underlying rows, and a scope/method color engine
390
+ * (see heatmapColor.ts). nivo's built-in scales normalize globally, so colors
391
+ * are precomputed per cell here and handed to nivo as a function.
392
+ */
393
+ declare function HeatmapPlusView({ records, rowColumn, colColumn, valueColumn, labelStat, colorStat, blockField, data: presetData, scope, method, vmin, vmax, rowOrder, colOrder, showMargins, style, }: HeatmapPlusViewProps): react.JSX.Element;
394
+
330
395
  interface PivotViewProps {
331
396
  records?: Row[];
332
397
  }
@@ -377,6 +442,14 @@ interface PanelConfig {
377
442
  colOrder?: string;
378
443
  marginAgg?: string;
379
444
  showTotals?: boolean;
445
+ labelStat?: string;
446
+ colorStat?: string;
447
+ blockField?: string;
448
+ scope?: string;
449
+ method?: string;
450
+ vmin?: number;
451
+ vmax?: number;
452
+ showMargins?: boolean;
380
453
  columns?: string[];
381
454
  text?: string;
382
455
  label?: string;
@@ -408,6 +481,19 @@ interface DashboardRendererProps {
408
481
  records?: Row[];
409
482
  columns?: ColumnDef[];
410
483
  }
484
+ interface PanelContentProps {
485
+ panel: DashboardPanel$1;
486
+ records?: Row[];
487
+ columns?: ColumnDef[];
488
+ }
489
+ /**
490
+ * Renders a single dashboard panel based on its type and config.
491
+ * Panels saved with a SQL query render server-side (full dataset); the rest
492
+ * fall back to client-side aggregation over the loaded records.
493
+ */
494
+ declare function PanelContent({ panel, records, columns }: PanelContentProps): react.JSX.Element | null;
495
+ declare const PanelChart: typeof PanelContent;
496
+ type PanelChartProps = PanelContentProps;
411
497
  /**
412
498
  * DashboardRenderer — renders a grid of AI-generated or manually configured
413
499
  * panels via react-grid-layout. Editing is capability-gated:
@@ -443,7 +529,7 @@ interface Column {
443
529
  name: string;
444
530
  type: string;
445
531
  }
446
- /** A selectable state (dataset) in the statefs catalog. */
532
+ /** A selectable state (dataset) in the host's catalog. */
447
533
  interface StatefsState {
448
534
  state_id: string;
449
535
  row_count?: number;
@@ -520,4 +606,4 @@ interface DataExplorerProps {
520
606
  }
521
607
  declare function DataExplorer({ records, columns, states, activeStateId, profile, dashboard, dashboardId, savedDashboards, loading, analyzing, defaultMode, tabs, onSelectState, onRefreshStates, }: DataExplorerProps): react.JSX.Element;
522
608
 
523
- export { type AggFn, type BarDatum, BarView, type BarViewProps, ChartBuilder, type ChartBuilderColumn, type ChartBuilderProps, type ChartConfig, type ChartField, type ChartFilter, type ChartPanel, type ChartStyle, ChartStyleControls, type ChartStyleControlsProps, type ChartType, DEFAULT_CHART_STYLE, type Dashboard$1 as Dashboard, type DashboardCapabilities, type DashboardContextValue, type DashboardPanel$1 as DashboardPanel, DashboardProvider, type DashboardProviderProps, DashboardRenderer, type DashboardRendererProps, type DashboardTheme, DataExplorer, type DataExplorerProps, type HeatmapSerie, HeatmapView, type HeatmapViewProps, type InsightConfig, InsightView, type InsightViewProps, LEGEND_ANCHORS, type LegendAnchor, type LegendPosition, type LineSerie, LineView, type LineViewProps, type MetricConfig, MetricView, type MetricViewProps, type PanelInput, type PanelLayout, type PieDatum, PieView, type PieViewProps, PivotView, type PivotViewProps, type QueryResult, type Row, type SavedDashboard, type ScatterSerie, ScatterView, type ScatterViewProps, SqlConsole, type SqlConsoleColumn, type SqlConsoleProps, type TitleAlign, aggExpr, aggregate, axisLegend, buildChartSQL, buildNivoTheme, compileWhere, groupBy, legendConfig, qIdent, qLit, shapeChartData, useCapabilities, useDashboard, withStyleDefaults };
609
+ export { type AggFn, type BarDatum, BarView, type BarViewProps, ChartBuilder, type ChartBuilderColumn, type ChartBuilderProps, type ChartConfig, type ChartField, type ChartFilter, type ChartPanel, type ChartStyle, ChartStyleControls, type ChartStyleControlsProps, type ChartType, type ColorMethod, type ColorOptions, type ColorScope, DEFAULT_CHART_STYLE, type Dashboard$1 as Dashboard, type DashboardCapabilities, type DashboardContextValue, type DashboardPanel$1 as DashboardPanel, DashboardProvider, type DashboardProviderProps, DashboardRenderer, type DashboardRendererProps, type DashboardTheme, DataExplorer, type DataExplorerProps, HEAT_STATS, type HeatCell, type HeatPlusDatum, type HeatStat, HeatmapPlusView, type HeatmapPlusViewProps, type HeatmapSerie, HeatmapView, type HeatmapViewProps, type InsightConfig, InsightView, type InsightViewProps, LEGEND_ANCHORS, type LegendAnchor, type LegendPosition, type LineSerie, LineView, type LineViewProps, type MetricConfig, MetricView, type MetricViewProps, PanelChart, type PanelChartProps, type PanelInput, type PanelLayout, type PanelRef, type PieDatum, PieView, type PieViewProps, PivotView, type PivotViewProps, type QueryResult, type Row, type SavedDashboard, type ScatterSerie, ScatterView, type ScatterViewProps, SqlConsole, type SqlConsoleColumn, type SqlConsoleProps, type TitleAlign, aggExpr, aggregate, axisLegend, buildChartSQL, buildNivoTheme, compileWhere, groupBy, heatColor, heatLabelColor, legendConfig, normalizeCells, qIdent, qLit, shapeChartData, useCapabilities, useDashboard, withStyleDefaults };