@quantumwake/terminal-ux-dashboard-components 0.1.0 → 0.1.2
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 +11 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ function useCapabilities() {
|
|
|
38
38
|
canDelete: !!c.deleteDashboard,
|
|
39
39
|
canAnalyze: !!c.analyzeDataset,
|
|
40
40
|
canRefine: !!c.refineDashboard,
|
|
41
|
+
canAddPanel: !!c.addPanel,
|
|
41
42
|
canEditPanels: !!c.removePanel
|
|
42
43
|
};
|
|
43
44
|
}
|
|
@@ -1020,6 +1021,8 @@ var ChartPreview = ({
|
|
|
1020
1021
|
};
|
|
1021
1022
|
function ChartBuilder({ records, columns, stateId, onSave }) {
|
|
1022
1023
|
const { theme, runQuery } = useDashboard();
|
|
1024
|
+
const runQueryRef = react.useRef(runQuery);
|
|
1025
|
+
runQueryRef.current = runQuery;
|
|
1023
1026
|
const [chartType, setChartType] = react.useState("bar");
|
|
1024
1027
|
const [xFields, setXFields] = react.useState([]);
|
|
1025
1028
|
const [yFields, setYFields] = react.useState([]);
|
|
@@ -1053,7 +1056,7 @@ function ChartBuilder({ records, columns, stateId, onSave }) {
|
|
|
1053
1056
|
let cancelled = false;
|
|
1054
1057
|
setSqlLoading(true);
|
|
1055
1058
|
setSqlError(null);
|
|
1056
|
-
|
|
1059
|
+
runQueryRef.current(generatedSql, stateId).then((res) => {
|
|
1057
1060
|
if (cancelled) return;
|
|
1058
1061
|
setSqlLoading(false);
|
|
1059
1062
|
setSqlRows(res.rows || []);
|
|
@@ -1066,7 +1069,7 @@ function ChartBuilder({ records, columns, stateId, onSave }) {
|
|
|
1066
1069
|
return () => {
|
|
1067
1070
|
cancelled = true;
|
|
1068
1071
|
};
|
|
1069
|
-
}, [engineMode, generatedSql,
|
|
1072
|
+
}, [engineMode, generatedSql, stateId]);
|
|
1070
1073
|
const addField = (zone, field) => {
|
|
1071
1074
|
switch (zone) {
|
|
1072
1075
|
case "x":
|
|
@@ -1349,6 +1352,8 @@ function ViewLoading() {
|
|
|
1349
1352
|
}
|
|
1350
1353
|
function SqlPanel({ panel }) {
|
|
1351
1354
|
const { runQuery } = useDashboard();
|
|
1355
|
+
const runQueryRef = react.useRef(runQuery);
|
|
1356
|
+
runQueryRef.current = runQuery;
|
|
1352
1357
|
const config = panel.config || {};
|
|
1353
1358
|
const chartType = config.chartType || panel.type;
|
|
1354
1359
|
const [rows, setRows] = react.useState(null);
|
|
@@ -1359,7 +1364,7 @@ function SqlPanel({ panel }) {
|
|
|
1359
1364
|
setLoading(true);
|
|
1360
1365
|
setError(null);
|
|
1361
1366
|
const sql = config.sql || "";
|
|
1362
|
-
|
|
1367
|
+
runQueryRef.current(sql).then(
|
|
1363
1368
|
(res) => {
|
|
1364
1369
|
if (cancelled) return;
|
|
1365
1370
|
setLoading(false);
|
|
@@ -1375,7 +1380,7 @@ function SqlPanel({ panel }) {
|
|
|
1375
1380
|
return () => {
|
|
1376
1381
|
cancelled = true;
|
|
1377
1382
|
};
|
|
1378
|
-
}, [config.sql
|
|
1383
|
+
}, [config.sql]);
|
|
1379
1384
|
if (loading && !rows) {
|
|
1380
1385
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full text-xs text-midnight-text-muted", children: "Running\u2026" });
|
|
1381
1386
|
}
|
|
@@ -1620,7 +1625,7 @@ function DataExplorer({
|
|
|
1620
1625
|
onSelectState,
|
|
1621
1626
|
onRefreshStates
|
|
1622
1627
|
}) {
|
|
1623
|
-
const { theme, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
|
|
1628
|
+
const { theme, addPanel, saveDashboard, listDashboards, searchDashboards, loadDashboard, deleteDashboard, analyzeDataset, refineDashboard } = useDashboard();
|
|
1624
1629
|
const caps = useCapabilities();
|
|
1625
1630
|
const [mode, setMode] = react.useState("dashboard");
|
|
1626
1631
|
const [fullscreen, setFullscreen] = react.useState(false);
|
|
@@ -1758,7 +1763,7 @@ function DataExplorer({
|
|
|
1758
1763
|
)
|
|
1759
1764
|
] }, d.id))
|
|
1760
1765
|
] }),
|
|
1761
|
-
/* @__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: [
|
|
1766
|
+
/* @__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, onSave: addPanel }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1762
1767
|
/* @__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: [
|
|
1763
1768
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sparkles, { className: "w-8 h-8" }),
|
|
1764
1769
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: caps.canAnalyze ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|