@quantumwake/terminal-ux-dashboard-components 0.1.1 → 0.1.3

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
@@ -11,6 +11,13 @@ interface SavedDashboard {
11
11
  name: string;
12
12
  [key: string]: unknown;
13
13
  }
14
+ interface PanelInput {
15
+ title: string;
16
+ type: string;
17
+ config: Record<string, unknown>;
18
+ width: number;
19
+ height: number;
20
+ }
14
21
  interface DashboardCapabilities {
15
22
  runQuery: (sql: string, stateId?: string) => Promise<QueryResult>;
16
23
  saveDashboard?: (name?: string) => Promise<void> | void;
@@ -20,6 +27,8 @@ interface DashboardCapabilities {
20
27
  deleteDashboard?: (id: string) => Promise<void> | void;
21
28
  analyzeDataset?: () => Promise<void> | void;
22
29
  refineDashboard?: (prompt: string) => Promise<void> | void;
30
+ newDashboard?: () => void;
31
+ addPanel?: (panel: PanelInput) => void;
23
32
  removePanel?: (panelId: string) => void;
24
33
  }
25
34
  interface DashboardContextValue extends DashboardCapabilities {
@@ -40,6 +49,8 @@ declare function useCapabilities(): {
40
49
  canDelete: boolean;
41
50
  canAnalyze: boolean;
42
51
  canRefine: boolean;
52
+ canNew: boolean;
53
+ canAddPanel: boolean;
43
54
  canEditPanels: boolean;
44
55
  };
45
56
 
@@ -474,4 +485,4 @@ interface DataExplorerProps {
474
485
  }
475
486
  declare function DataExplorer({ records, columns, states, activeStateId, profile, dashboard, dashboardId, savedDashboards, loading, analyzing, onSelectState, onRefreshStates, }: DataExplorerProps): react.JSX.Element;
476
487
 
477
- 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 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 };
488
+ 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 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 };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,13 @@ interface SavedDashboard {
11
11
  name: string;
12
12
  [key: string]: unknown;
13
13
  }
14
+ interface PanelInput {
15
+ title: string;
16
+ type: string;
17
+ config: Record<string, unknown>;
18
+ width: number;
19
+ height: number;
20
+ }
14
21
  interface DashboardCapabilities {
15
22
  runQuery: (sql: string, stateId?: string) => Promise<QueryResult>;
16
23
  saveDashboard?: (name?: string) => Promise<void> | void;
@@ -20,6 +27,8 @@ interface DashboardCapabilities {
20
27
  deleteDashboard?: (id: string) => Promise<void> | void;
21
28
  analyzeDataset?: () => Promise<void> | void;
22
29
  refineDashboard?: (prompt: string) => Promise<void> | void;
30
+ newDashboard?: () => void;
31
+ addPanel?: (panel: PanelInput) => void;
23
32
  removePanel?: (panelId: string) => void;
24
33
  }
25
34
  interface DashboardContextValue extends DashboardCapabilities {
@@ -40,6 +49,8 @@ declare function useCapabilities(): {
40
49
  canDelete: boolean;
41
50
  canAnalyze: boolean;
42
51
  canRefine: boolean;
52
+ canNew: boolean;
53
+ canAddPanel: boolean;
43
54
  canEditPanels: boolean;
44
55
  };
45
56
 
@@ -474,4 +485,4 @@ interface DataExplorerProps {
474
485
  }
475
486
  declare function DataExplorer({ records, columns, states, activeStateId, profile, dashboard, dashboardId, savedDashboards, loading, analyzing, onSelectState, onRefreshStates, }: DataExplorerProps): react.JSX.Element;
476
487
 
477
- 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 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 };
488
+ 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 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 };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { ResponsiveScatterPlot } from '@nivo/scatterplot';
7
7
  import { ResponsiveHeatMap } from '@nivo/heatmap';
8
8
  import PivotTableUI from 'react-pivottable/PivotTableUI';
9
9
  import 'react-pivottable/pivottable.css';
10
- import { Loader2, Play, AlertCircle, Rows3, BarChart3, PieChart, TrendingUp, ScatterChart, LayoutGrid, Code, ChevronDown, Sparkles, X, RefreshCw, Minimize2, Maximize2, Terminal, Save, FolderOpen, Trash2, Plus, Filter, Database, Send, GripVertical } from 'lucide-react';
10
+ import { Loader2, Play, AlertCircle, Rows3, BarChart3, PieChart, TrendingUp, ScatterChart, LayoutGrid, Code, ChevronDown, Sparkles, X, RefreshCw, Minimize2, Maximize2, Terminal, Plus, Save, FolderOpen, Trash2, Filter, Database, Send, GripVertical } from 'lucide-react';
11
11
 
12
12
  // src/context/DashboardContext.tsx
13
13
  var DashboardContext = createContext(null);
@@ -32,6 +32,8 @@ function useCapabilities() {
32
32
  canDelete: !!c.deleteDashboard,
33
33
  canAnalyze: !!c.analyzeDataset,
34
34
  canRefine: !!c.refineDashboard,
35
+ canNew: !!c.newDashboard,
36
+ canAddPanel: !!c.addPanel,
35
37
  canEditPanels: !!c.removePanel
36
38
  };
37
39
  }
@@ -1618,7 +1620,7 @@ function DataExplorer({
1618
1620
  onSelectState,
1619
1621
  onRefreshStates
1620
1622
  }) {
1621
- const { theme, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
1623
+ const { theme, newDashboard, addPanel, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
1622
1624
  const caps = useCapabilities();
1623
1625
  const [mode, setMode] = useState("dashboard");
1624
1626
  const [fullscreen, setFullscreen] = useState(false);
@@ -1688,6 +1690,21 @@ function DataExplorer({
1688
1690
  /* @__PURE__ */ jsx(ModeTab, { active: mode === "dashboard", onClick: () => setMode("dashboard"), icon: Sparkles, label: "Dashboard" }),
1689
1691
  /* @__PURE__ */ jsx(ModeTab, { active: mode === "builder", onClick: () => setMode("builder"), icon: BarChart3, label: "Chart Builder" }),
1690
1692
  /* @__PURE__ */ jsx(ModeTab, { active: mode === "sql", onClick: () => setMode("sql"), icon: Terminal, label: "SQL" }),
1693
+ caps.canNew && /* @__PURE__ */ jsxs(
1694
+ "button",
1695
+ {
1696
+ onClick: () => {
1697
+ newDashboard?.();
1698
+ setMode("builder");
1699
+ },
1700
+ title: "Start a new dashboard",
1701
+ className: "flex items-center gap-1 px-2 py-1 text-xs font-mono border border-midnight-border text-midnight-text-muted hover:bg-midnight-raised hover:text-midnight-accent transition-colors",
1702
+ children: [
1703
+ /* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
1704
+ " New Dashboard"
1705
+ ]
1706
+ }
1707
+ ),
1691
1708
  showPersistence && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 ml-auto", children: [
1692
1709
  caps.canSave && showSaveInput && /* @__PURE__ */ jsx(
1693
1710
  "input",
@@ -1756,14 +1773,39 @@ function DataExplorer({
1756
1773
  )
1757
1774
  ] }, d.id))
1758
1775
  ] }),
1759
- /* @__PURE__ */ jsx("div", { className: `border ${theme.border} bg-midnight-surface flex-1 flex flex-col min-h-0`, children: mode === "sql" ? /* @__PURE__ */ jsx(SqlConsole, { columns, stateId: activeStateId ?? void 0 }) : mode === "builder" ? /* @__PURE__ */ jsx(ChartBuilder, { records, columns, stateId: activeStateId ?? void 0 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1776
+ /* @__PURE__ */ jsx("div", { className: `border ${theme.border} bg-midnight-surface flex-1 flex flex-col min-h-0`, children: mode === "sql" ? /* @__PURE__ */ jsx(SqlConsole, { columns, stateId: activeStateId ?? void 0 }) : mode === "builder" ? /* @__PURE__ */ jsx(
1777
+ ChartBuilder,
1778
+ {
1779
+ records,
1780
+ columns,
1781
+ stateId: activeStateId ?? void 0,
1782
+ onSave: addPanel ? (panel) => {
1783
+ addPanel(panel);
1784
+ setMode("dashboard");
1785
+ } : void 0
1786
+ }
1787
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
1760
1788
  /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-auto", children: dashboard ? /* @__PURE__ */ jsx(DashboardRenderer, { dashboard, records, columns }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full gap-4 text-midnight-text-muted", children: [
1761
1789
  /* @__PURE__ */ jsx(Sparkles, { className: "w-8 h-8" }),
1762
1790
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: caps.canAnalyze ? /* @__PURE__ */ jsxs(Fragment, { children: [
1763
1791
  "Click ",
1764
1792
  /* @__PURE__ */ jsx("strong", { children: "Auto-Analyze" }),
1765
1793
  " to generate an AI dashboard"
1766
- ] }) : "No dashboard to display" })
1794
+ ] }) : caps.canNew ? "Start a new dashboard, then add charts from the Chart Builder" : "No dashboard to display" }),
1795
+ caps.canNew && /* @__PURE__ */ jsxs(
1796
+ "button",
1797
+ {
1798
+ onClick: () => {
1799
+ newDashboard?.();
1800
+ setMode("builder");
1801
+ },
1802
+ className: "flex items-center gap-1.5 px-3 py-1.5 text-xs font-mono border border-midnight-accent text-midnight-accent hover:bg-midnight-accent/10 transition-colors",
1803
+ children: [
1804
+ /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4" }),
1805
+ " Create Dashboard"
1806
+ ]
1807
+ }
1808
+ )
1767
1809
  ] }) }),
1768
1810
  dashboard && caps.canRefine && refineDashboard && /* @__PURE__ */ jsx(ChatInput, { onSend: refineDashboard, loading: analyzing, theme })
1769
1811
  ] }) })