-
{{ error }}
-
-
+ {{ error }}
+
+
+
Results appear here after Run.
@@ -158,7 +150,9 @@ const previewRows = computed(() => rows.value.slice(0, 50));
.result-pane {
min-height: 0;
- overflow: auto;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
padding: 8px 10px 10px;
border-top: 1px solid
color-mix(
@@ -169,12 +163,18 @@ const previewRows = computed(() => rows.value.slice(0, 50));
}
.meta {
+ flex: 0 0 auto;
font-size: 11px;
color: var(--q-muted-foreground);
margin-bottom: 6px;
font-family: var(--q-font-mono);
}
+.grid-host {
+ flex: 1;
+ min-height: 0;
+}
+
.empty,
.error {
margin: 12px 0;
@@ -185,35 +185,4 @@ const previewRows = computed(() => rows.value.slice(0, 50));
.error {
color: var(--q-danger, #c44);
}
-
-.table-wrap {
- overflow: auto;
-}
-
-table {
- border-collapse: collapse;
- width: max-content;
- min-width: 100%;
- font-size: 12px;
- font-family: var(--q-font-mono);
-}
-
-th,
-td {
- border: 1px solid
- color-mix(in srgb, var(--q-border) 70%, transparent);
- padding: 4px 8px;
- text-align: left;
- white-space: nowrap;
- max-width: 28rem;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-th {
- background: var(--q-sidebar-bg);
- position: sticky;
- top: 0;
- font-weight: 600;
-}
diff --git a/apps/tauri/src/ui/glide/ResultDataEditor.ts b/apps/tauri/src/ui/glide/ResultDataEditor.ts
new file mode 100644
index 00000000..0edf2b36
--- /dev/null
+++ b/apps/tauri/src/ui/glide/ResultDataEditor.ts
@@ -0,0 +1,72 @@
+import {
+ createElement,
+ useCallback,
+ useMemo,
+ type ReactElement,
+} from "react";
+import {
+ DataEditor,
+ GridCellKind,
+ type GridCell,
+ type GridColumn,
+ type Item,
+} from "@glideapps/glide-data-grid";
+
+export type ResultDataEditorProps = {
+ columns: string[];
+ rows: unknown[][];
+ width: number;
+ height: number;
+};
+
+function cellText(value: unknown): string {
+ if (value === null || value === undefined) return "";
+ if (typeof value === "string") return value;
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
+ return JSON.stringify(value);
+}
+
+export function ResultDataEditor(props: ResultDataEditorProps): ReactElement {
+ const { columns, rows, width, height } = props;
+
+ const gridColumns: GridColumn[] = useMemo(
+ () =>
+ columns.map((title) => ({
+ id: title,
+ title,
+ width: Math.min(280, Math.max(96, title.length * 9 + 40)),
+ })),
+ [columns],
+ );
+
+ const getCellContent = useCallback(
+ ([col, row]: Item): GridCell => {
+ const raw = rows[row]?.[col];
+ const isNull = raw === null || raw === undefined;
+ return {
+ kind: GridCellKind.Text,
+ data: isNull ? "" : cellText(raw),
+ displayData: isNull ? "NULL" : cellText(raw),
+ allowOverlay: true,
+ readonly: true,
+ themeOverride: isNull
+ ? { textDark: "var(--q-muted-foreground)" }
+ : undefined,
+ };
+ },
+ [rows],
+ );
+
+ return createElement(DataEditor, {
+ columns: gridColumns,
+ rows: rows.length,
+ getCellContent,
+ width,
+ height,
+ rowMarkers: "number",
+ smoothScrollX: true,
+ smoothScrollY: true,
+ getCellsForSelection: true,
+ keybindings: { search: true },
+ });
+}