@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.cjs CHANGED
@@ -38,6 +38,8 @@ function useCapabilities() {
38
38
  canDelete: !!c.deleteDashboard,
39
39
  canAnalyze: !!c.analyzeDataset,
40
40
  canRefine: !!c.refineDashboard,
41
+ canNew: !!c.newDashboard,
42
+ canAddPanel: !!c.addPanel,
41
43
  canEditPanels: !!c.removePanel
42
44
  };
43
45
  }
@@ -1624,7 +1626,7 @@ function DataExplorer({
1624
1626
  onSelectState,
1625
1627
  onRefreshStates
1626
1628
  }) {
1627
- const { theme, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
1629
+ const { theme, newDashboard, addPanel, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
1628
1630
  const caps = useCapabilities();
1629
1631
  const [mode, setMode] = react.useState("dashboard");
1630
1632
  const [fullscreen, setFullscreen] = react.useState(false);
@@ -1694,6 +1696,21 @@ function DataExplorer({
1694
1696
  /* @__PURE__ */ jsxRuntime.jsx(ModeTab, { active: mode === "dashboard", onClick: () => setMode("dashboard"), icon: lucideReact.Sparkles, label: "Dashboard" }),
1695
1697
  /* @__PURE__ */ jsxRuntime.jsx(ModeTab, { active: mode === "builder", onClick: () => setMode("builder"), icon: lucideReact.BarChart3, label: "Chart Builder" }),
1696
1698
  /* @__PURE__ */ jsxRuntime.jsx(ModeTab, { active: mode === "sql", onClick: () => setMode("sql"), icon: lucideReact.Terminal, label: "SQL" }),
1699
+ caps.canNew && /* @__PURE__ */ jsxRuntime.jsxs(
1700
+ "button",
1701
+ {
1702
+ onClick: () => {
1703
+ newDashboard?.();
1704
+ setMode("builder");
1705
+ },
1706
+ title: "Start a new dashboard",
1707
+ 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",
1708
+ children: [
1709
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-3.5 h-3.5" }),
1710
+ " New Dashboard"
1711
+ ]
1712
+ }
1713
+ ),
1697
1714
  showPersistence && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 ml-auto", children: [
1698
1715
  caps.canSave && showSaveInput && /* @__PURE__ */ jsxRuntime.jsx(
1699
1716
  "input",
@@ -1762,14 +1779,39 @@ function DataExplorer({
1762
1779
  )
1763
1780
  ] }, d.id))
1764
1781
  ] }),
1765
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `border ${theme.border} bg-midnight-surface flex-1 flex flex-col min-h-0`, children: mode === "sql" ? /* @__PURE__ */ jsxRuntime.jsx(SqlConsole, { columns, stateId: activeStateId ?? void 0 }) : mode === "builder" ? /* @__PURE__ */ jsxRuntime.jsx(ChartBuilder, { records, columns, stateId: activeStateId ?? void 0 }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1782
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `border ${theme.border} bg-midnight-surface flex-1 flex flex-col min-h-0`, children: mode === "sql" ? /* @__PURE__ */ jsxRuntime.jsx(SqlConsole, { columns, stateId: activeStateId ?? void 0 }) : mode === "builder" ? /* @__PURE__ */ jsxRuntime.jsx(
1783
+ ChartBuilder,
1784
+ {
1785
+ records,
1786
+ columns,
1787
+ stateId: activeStateId ?? void 0,
1788
+ onSave: addPanel ? (panel) => {
1789
+ addPanel(panel);
1790
+ setMode("dashboard");
1791
+ } : void 0
1792
+ }
1793
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1766
1794
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0 overflow-auto", children: dashboard ? /* @__PURE__ */ jsxRuntime.jsx(DashboardRenderer, { dashboard, records, columns }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center h-full gap-4 text-midnight-text-muted", children: [
1767
1795
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sparkles, { className: "w-8 h-8" }),
1768
1796
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: caps.canAnalyze ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1769
1797
  "Click ",
1770
1798
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Auto-Analyze" }),
1771
1799
  " to generate an AI dashboard"
1772
- ] }) : "No dashboard to display" })
1800
+ ] }) : caps.canNew ? "Start a new dashboard, then add charts from the Chart Builder" : "No dashboard to display" }),
1801
+ caps.canNew && /* @__PURE__ */ jsxRuntime.jsxs(
1802
+ "button",
1803
+ {
1804
+ onClick: () => {
1805
+ newDashboard?.();
1806
+ setMode("builder");
1807
+ },
1808
+ 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",
1809
+ children: [
1810
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-4 h-4" }),
1811
+ " Create Dashboard"
1812
+ ]
1813
+ }
1814
+ )
1773
1815
  ] }) }),
1774
1816
  dashboard && caps.canRefine && refineDashboard && /* @__PURE__ */ jsxRuntime.jsx(ChatInput, { onSend: refineDashboard, loading: analyzing, theme })
1775
1817
  ] }) })