@quantumwake/terminal-ux-dashboard-components 0.1.2 → 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
@@ -27,6 +27,7 @@ interface DashboardCapabilities {
27
27
  deleteDashboard?: (id: string) => Promise<void> | void;
28
28
  analyzeDataset?: () => Promise<void> | void;
29
29
  refineDashboard?: (prompt: string) => Promise<void> | void;
30
+ newDashboard?: () => void;
30
31
  addPanel?: (panel: PanelInput) => void;
31
32
  removePanel?: (panelId: string) => void;
32
33
  }
@@ -48,6 +49,7 @@ declare function useCapabilities(): {
48
49
  canDelete: boolean;
49
50
  canAnalyze: boolean;
50
51
  canRefine: boolean;
52
+ canNew: boolean;
51
53
  canAddPanel: boolean;
52
54
  canEditPanels: boolean;
53
55
  };
package/dist/index.d.ts CHANGED
@@ -27,6 +27,7 @@ interface DashboardCapabilities {
27
27
  deleteDashboard?: (id: string) => Promise<void> | void;
28
28
  analyzeDataset?: () => Promise<void> | void;
29
29
  refineDashboard?: (prompt: string) => Promise<void> | void;
30
+ newDashboard?: () => void;
30
31
  addPanel?: (panel: PanelInput) => void;
31
32
  removePanel?: (panelId: string) => void;
32
33
  }
@@ -48,6 +49,7 @@ declare function useCapabilities(): {
48
49
  canDelete: boolean;
49
50
  canAnalyze: boolean;
50
51
  canRefine: boolean;
52
+ canNew: boolean;
51
53
  canAddPanel: boolean;
52
54
  canEditPanels: boolean;
53
55
  };
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,7 @@ function useCapabilities() {
32
32
  canDelete: !!c.deleteDashboard,
33
33
  canAnalyze: !!c.analyzeDataset,
34
34
  canRefine: !!c.refineDashboard,
35
+ canNew: !!c.newDashboard,
35
36
  canAddPanel: !!c.addPanel,
36
37
  canEditPanels: !!c.removePanel
37
38
  };
@@ -1619,7 +1620,7 @@ function DataExplorer({
1619
1620
  onSelectState,
1620
1621
  onRefreshStates
1621
1622
  }) {
1622
- const { theme, addPanel, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
1623
+ const { theme, newDashboard, addPanel, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
1623
1624
  const caps = useCapabilities();
1624
1625
  const [mode, setMode] = useState("dashboard");
1625
1626
  const [fullscreen, setFullscreen] = useState(false);
@@ -1689,6 +1690,21 @@ function DataExplorer({
1689
1690
  /* @__PURE__ */ jsx(ModeTab, { active: mode === "dashboard", onClick: () => setMode("dashboard"), icon: Sparkles, label: "Dashboard" }),
1690
1691
  /* @__PURE__ */ jsx(ModeTab, { active: mode === "builder", onClick: () => setMode("builder"), icon: BarChart3, label: "Chart Builder" }),
1691
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
+ ),
1692
1708
  showPersistence && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 ml-auto", children: [
1693
1709
  caps.canSave && showSaveInput && /* @__PURE__ */ jsx(
1694
1710
  "input",
@@ -1757,14 +1773,39 @@ function DataExplorer({
1757
1773
  )
1758
1774
  ] }, d.id))
1759
1775
  ] }),
1760
- /* @__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, onSave: addPanel }) : /* @__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: [
1761
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: [
1762
1789
  /* @__PURE__ */ jsx(Sparkles, { className: "w-8 h-8" }),
1763
1790
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: caps.canAnalyze ? /* @__PURE__ */ jsxs(Fragment, { children: [
1764
1791
  "Click ",
1765
1792
  /* @__PURE__ */ jsx("strong", { children: "Auto-Analyze" }),
1766
1793
  " to generate an AI dashboard"
1767
- ] }) : "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
+ )
1768
1809
  ] }) }),
1769
1810
  dashboard && caps.canRefine && refineDashboard && /* @__PURE__ */ jsx(ChatInput, { onSend: refineDashboard, loading: analyzing, theme })
1770
1811
  ] }) })