feat(grid): add configurable column width layout

Closes #10366
This commit is contained in:
t8y2 authored and t8y2 committed 2026-09-27 12:04:10 +08:00
1 parent 72f8dfeb7c
commit 4a7b8f0f27
21 files changed
+165 -2

No files matched your search

@@ -2266,6 +2266,7 @@ function scrollToColumnIndex(columnIndex: number) {
// --- Column resize composable ---
const columnWidthDensity = computed(() => settingsStore.editorSettings.columnWidthDensity);
const columnWidthMode = computed(() => settingsStore.editorSettings.dataGridColumnWidthMode ?? "fill");
const tableFontFamily = computed(() => settingsStore.editorSettings.tableFontFamily);
const columnWidthCacheKey = computed(() => props.columnWidthCacheKey?.trim() || props.cacheKey?.trim() || undefined);
const columnStructureSignature = computed(() => createDataGridColumnStructureSignature(props.result.columns, props.result.column_types));
@@ -2317,6 +2318,7 @@ const { initColumnWidths, onResizeStart, autoFitColumn, autoFitAllColumns, rende
sourceRows: computed(() => props.result.rows),
columnIndexes: visibleColumnIndexes,
density: columnWidthDensity,
widthMode: columnWidthMode,
compactColumnHeaderActions,
columnIndexIndicators: visibleColumnIndexIndicators,
cacheKey: columnWidthCacheKey,
@@ -0,0 +1,37 @@
<script setup lang="ts">
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useSettingsStore, type DataGridColumnWidthMode } from "@/stores/settingsStore";
const { t } = useI18n();
const settingsStore = useSettingsStore();
const columnWidthMode = computed(() => settingsStore.editorSettings.dataGridColumnWidthMode ?? "fill");
function setColumnWidthMode(value: DataGridColumnWidthMode) {
settingsStore.updateEditorSettings({ dataGridColumnWidthMode: value });
}
</script>
<template>
<div class="flex items-center justify-between gap-3 px-3 py-1.5 text-xs">
<div class="min-w-0 flex items-center gap-2 font-medium">
<span class="flex h-3.5 w-3.5 shrink-0 items-center justify-center text-[11px] text-muted-foreground" aria-hidden="true">↔</span>
<span>{{ t("grid.columnWidthMode") }}</span>
</div>
<div role="group" :aria-label="t('grid.columnWidthMode')" class="grid w-48 grid-cols-2 rounded-md border bg-muted/40 p-0.5">
<button
v-for="mode in ['fill', 'content'] as const"
:key="mode"
type="button"
class="h-5 min-w-0 truncate whitespace-nowrap rounded-[5px] px-1.5 text-xs transition-colors"
:class="columnWidthMode === mode ? 'bg-background font-semibold text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground'"
:aria-pressed="columnWidthMode === mode"
:data-column-width-mode="mode"
:title="t(`grid.columnWidthMode${mode === 'fill' ? 'Fill' : 'Content'}`)"
@click="setColumnWidthMode(mode)"
>
{{ t(`grid.columnWidthMode${mode === "fill" ? "Fill" : "Content"}`) }}
</button>
</div>
</div>
</template>