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

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
@@ -1020,6 +1020,8 @@ var ChartPreview = ({
1020
1020
  };
1021
1021
  function ChartBuilder({ records, columns, stateId, onSave }) {
1022
1022
  const { theme, runQuery } = useDashboard();
1023
+ const runQueryRef = react.useRef(runQuery);
1024
+ runQueryRef.current = runQuery;
1023
1025
  const [chartType, setChartType] = react.useState("bar");
1024
1026
  const [xFields, setXFields] = react.useState([]);
1025
1027
  const [yFields, setYFields] = react.useState([]);
@@ -1053,7 +1055,7 @@ function ChartBuilder({ records, columns, stateId, onSave }) {
1053
1055
  let cancelled = false;
1054
1056
  setSqlLoading(true);
1055
1057
  setSqlError(null);
1056
- runQuery(generatedSql, stateId).then((res) => {
1058
+ runQueryRef.current(generatedSql, stateId).then((res) => {
1057
1059
  if (cancelled) return;
1058
1060
  setSqlLoading(false);
1059
1061
  setSqlRows(res.rows || []);
@@ -1066,7 +1068,7 @@ function ChartBuilder({ records, columns, stateId, onSave }) {
1066
1068
  return () => {
1067
1069
  cancelled = true;
1068
1070
  };
1069
- }, [engineMode, generatedSql, runQuery, stateId]);
1071
+ }, [engineMode, generatedSql, stateId]);
1070
1072
  const addField = (zone, field) => {
1071
1073
  switch (zone) {
1072
1074
  case "x":
@@ -1349,6 +1351,8 @@ function ViewLoading() {
1349
1351
  }
1350
1352
  function SqlPanel({ panel }) {
1351
1353
  const { runQuery } = useDashboard();
1354
+ const runQueryRef = react.useRef(runQuery);
1355
+ runQueryRef.current = runQuery;
1352
1356
  const config = panel.config || {};
1353
1357
  const chartType = config.chartType || panel.type;
1354
1358
  const [rows, setRows] = react.useState(null);
@@ -1359,7 +1363,7 @@ function SqlPanel({ panel }) {
1359
1363
  setLoading(true);
1360
1364
  setError(null);
1361
1365
  const sql = config.sql || "";
1362
- runQuery(sql).then(
1366
+ runQueryRef.current(sql).then(
1363
1367
  (res) => {
1364
1368
  if (cancelled) return;
1365
1369
  setLoading(false);
@@ -1375,7 +1379,7 @@ function SqlPanel({ panel }) {
1375
1379
  return () => {
1376
1380
  cancelled = true;
1377
1381
  };
1378
- }, [config.sql, runQuery]);
1382
+ }, [config.sql]);
1379
1383
  if (loading && !rows) {
1380
1384
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full text-xs text-midnight-text-muted", children: "Running\u2026" });
1381
1385
  }