@quantumwake/terminal-ux-dashboard-components 0.1.5 → 0.1.7

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
@@ -10,10 +10,13 @@ var heatmap = require('@nivo/heatmap');
10
10
  var PivotTableUI = require('react-pivottable/PivotTableUI');
11
11
  require('react-pivottable/pivottable.css');
12
12
  var lucideReact = require('lucide-react');
13
+ var CodeMirror = require('@uiw/react-codemirror');
14
+ var langSql = require('@codemirror/lang-sql');
13
15
 
14
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
17
 
16
18
  var PivotTableUI__default = /*#__PURE__*/_interopDefault(PivotTableUI);
19
+ var CodeMirror__default = /*#__PURE__*/_interopDefault(CodeMirror);
17
20
 
18
21
  // src/context/DashboardContext.tsx
19
22
  var DashboardContext = react.createContext(null);
@@ -675,12 +678,24 @@ function SqlConsole({ columns = [], stateId, defaultColumnsOpen = false, default
675
678
  setSql(defaultSql);
676
679
  void run(defaultSql);
677
680
  }, [stateId, autoRun, defaultSql]);
678
- const onKeyDown = (e) => {
679
- if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
680
- e.preventDefault();
681
- void run();
682
- }
681
+ const runRef = react.useRef(() => {
682
+ });
683
+ runRef.current = () => {
684
+ void run();
683
685
  };
686
+ const schemaKey = columns.map((c) => c.name).join(",");
687
+ const extensions = react.useMemo(
688
+ () => [
689
+ langSql.sql({ schema: { data: columns.map((c) => c.name) }, upperCaseKeywords: true }),
690
+ CodeMirror.EditorView.lineWrapping,
691
+ CodeMirror.Prec.highest(CodeMirror.keymap.of([{ key: "Mod-Enter", run: () => {
692
+ runRef.current();
693
+ return true;
694
+ } }]))
695
+ ],
696
+ [schemaKey]
697
+ // eslint-disable-line react-hooks/exhaustive-deps
698
+ );
684
699
  const resultColumns = result?.columns || [];
685
700
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [
686
701
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `border-b ${theme.border} bg-midnight-elevated p-3 shrink-0`, children: [
@@ -704,15 +719,16 @@ function SqlConsole({ columns = [], stateId, defaultColumnsOpen = false, default
704
719
  )
705
720
  ] }),
706
721
  /* @__PURE__ */ jsxRuntime.jsx(
707
- "textarea",
722
+ CodeMirror__default.default,
708
723
  {
709
724
  value: sql,
710
- onChange: (e) => setSql(e.target.value),
711
- onKeyDown,
712
- spellCheck: false,
713
- rows: 5,
714
- className: "w-full bg-midnight-surface border border-midnight-border px-3 py-2 text-sm font-mono outline-none text-midnight-text-body resize-y focus:border-midnight-accent transition-colors",
715
- placeholder: "SELECT ... FROM data"
725
+ onChange: setSql,
726
+ extensions,
727
+ theme: "dark",
728
+ basicSetup: { lineNumbers: false, foldGutter: false, highlightActiveLine: false },
729
+ height: "120px",
730
+ placeholder: "SELECT ... FROM data",
731
+ className: "border border-midnight-border text-sm overflow-hidden focus-within:border-midnight-accent"
716
732
  }
717
733
  ),
718
734
  columns.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [