style: improve UI interface

This commit is contained in:
Libon authored and GitHub committed 2026-06-18 02:01:00 +08:00
1 parent 4aa907d8b5
commit f1b8579994
8 files changed
+111 -70

No files matched your search

+47 -44
View File
@@ -2845,6 +2845,7 @@ const selection = useDataGridSelection({
});
const {
isSelectingAll,
selectedRange,
selectedCells,
selectedCellCount,
@@ -4110,12 +4111,12 @@ function drawCanvasGrid() {
hoverCell: canvasHoverCell.value,
isScrolling: isScrolling.value,
editingCell: editingCell.value,
singleSelectedCell: canvasSingleSelectedCell.value,
searchMatchKeys: searchMatchSet.value,
currentSearchMatch: currentSearchMatch.value,
formatCell: formatCellCached,
isRowActive,
isRowSelected,
isSelectingAll: isSelectingAll.value,
rowCellsUseSelectionVisual,
cellIsSelected,
cellCanHover: canEditCellItem,
@@ -4132,6 +4133,7 @@ watch(
selectedRowIds,
hasCellSelection,
hasRowSelection,
isSelectingAll,
searchMatchSet,
currentSearchMatch,
isDark,
@@ -6333,9 +6335,9 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<div v-if="whereSuggestions.length > 0" class="fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md" :style="whereSuggestionStyle">
<div
v-for="(sug, idx) in whereSuggestions"
:key="`${sug.kind}:${sug.value}`"
:key="`${sug.kind}:${sug.value}`"
class="flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer"
:class="idx === whereSuggestionIndex ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/50'"
:class="idx === whereSuggestionIndex ? 'bg-accent text-accent-foreground' : 'hover:bg-gray-200 dark:hover:bg-gray-800'"
@mousedown.prevent="
whereSuggestionIndex = idx;
acceptWhereSuggestion();
@@ -6396,7 +6398,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
v-for="(sug, idx) in orderBySuggestions"
:key="`${sug.kind}:${sug.value}`"
class="flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer"
:class="idx === orderBySuggestionIndex ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/50'"
:class="idx === orderBySuggestionIndex ? 'bg-accent text-accent-foreground' : 'hover:bg-gray-200 dark:hover:bg-gray-800'"
@mousedown.prevent="
orderBySuggestionIndex = idx;
acceptOrderBySuggestion();
@@ -6519,7 +6521,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
v-for="(sug, idx) in searchSuggestions"
:key="sug"
class="flex items-center px-3 py-1.5 text-xs cursor-pointer"
:class="idx === suggestionIndex ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/50'"
:class="idx === suggestionIndex ? 'bg-accent text-accent-foreground' : 'hover:bg-gray-200 dark:hover:bg-gray-800'"
@mousedown.prevent="
suggestionIndex = idx;
acceptSuggestion();
@@ -6620,7 +6622,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
'bg-primary/15': transposeRecordUsesActiveHighlight(cell.recordIndex) && !transposeRecordUsesSelectionVisual(cell.recordIndex) && !displayItems[cell.recordIndex]?.isDirtyCol[cell.valueIndex] && !transposeCellIsSelected(cell.recordIndex, cell.valueIndex),
'bg-yellow-500/10 cell-dirty': displayItems[cell.recordIndex]?.isDirtyCol[cell.valueIndex],
'cursor-text': !isScrolling && canEditCellItem(displayItems[cell.recordIndex], cell.valueIndex),
'hover:bg-accent/50':
'hover:bg-gray-200 dark:hover:bg-gray-800':
!isScrolling && canEditCellItem(displayItems[cell.recordIndex], cell.valueIndex) && !transposeRecordUsesSelectionVisual(cell.recordIndex) && !transposeRecordUsesActiveHighlight(cell.recordIndex) && !transposeCellIsSelected(cell.recordIndex, cell.valueIndex),
}"
:style="{ width: `${getTransposeRecordWidth(cell.recordIndex)}px` }"
@@ -6680,15 +6682,21 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
</div>
<template v-else>
<!-- Sticky header -->
<div ref="headerRef" class="shrink-0 bg-[rgb(239_239_239)] dark:bg-muted/60 z-10 border-y border-border overflow-hidden">
<div class="flex text-xs font-semibold text-foreground" :style="{ width: 'var(--header-total-w)' }">
<div class="shrink-0 px-2 py-1.5 border-r border-border text-center text-muted-foreground select-none cursor-pointer hover:bg-accent/60 sticky left-0 z-20 bg-[rgb(239_239_239)] dark:bg-muted" :style="{ width: 'var(--row-num-w)' }" @click="selectAllCells">#</div>
<div ref="headerRef" class="shrink-0 bg-[rgb(239_239_239)] dark:bg-muted/60 z-10 w-(--header-total-w) border-y border-border overflow-hidden">
<div class="flex text-xs font-semibold text-foreground">
<div
class="shrink-0 px-2 py-1.5 border-r w-(--row-num-w) border-border text-center text-muted-foreground select-none cursor-default hover:bg-gray-200 dark:hover:bg-gray-800 sticky left-0 z-20 bg-[rgb(239_239_239)] dark:bg-muted"
:class="{ '!bg-gray-300 dark:!bg-gray-900 outline outline-primary -outline-offset-1': isSelectingAll }"
@click="selectAllCells"
>
#
</div>
<div class="shrink-0" :style="{ width: `${horizontalColumnWindow.beforeWidth}px` }" />
<LightTooltip v-for="col in renderedGridColumns" :key="`${col.name}-${col.actualColIdx}`" :text="col.name" side="bottom" :side-offset="4">
<div
class="shrink-0 px-2 py-1.5 border-r border-border whitespace-nowrap hover:bg-accent/60 select-none relative overflow-hidden"
class="shrink-0 px-2 py-1.5 border-r border-border whitespace-nowrap hover:bg-gray-200 dark:hover:bg-gray-800 select-none relative overflow-hidden"
:class="{
'bg-primary/15 ring-1 ring-inset ring-primary/40': highlightedColumnIndex === col.actualColIdx || columnIsSelected(col.visibleColIdx),
'!bg-gray-300 dark:!bg-gray-900 outline outline-primary -outline-offset-1': highlightedColumnIndex === col.actualColIdx || columnIsSelected(col.visibleColIdx),
'bg-amber-500/20 ring-1 ring-inset ring-amber-500/40': currentSearchMatch?.kind === 'column' && currentSearchMatch.col === col.actualColIdx,
}"
:style="renderedColumnStyle(col.visibleColIdx)"
@@ -6711,7 +6719,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<button
v-if="headerColumnSortable(col.actualColIdx)"
type="button"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-gray-200 dark:hover:bg-gray-800 hover:text-foreground"
:class="sortCol === col.name && sortColIndex === col.actualColIdx ? 'text-primary opacity-100' : 'opacity-80'"
:title="t('grid.sort')"
@click.stop="toggleSort(col.name, col.actualColIdx)"
@@ -6724,7 +6732,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<DropdownMenuTrigger as-child>
<button
type="button"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-gray-200 dark:hover:bg-gray-800 hover:text-foreground"
:class="columnHasFormatter(col.actualColIdx) || localFilterActive(col.actualColIdx) ? 'text-primary opacity-90' : 'opacity-80'"
:title="t('grid.columnActions')"
@click.stop
@@ -6750,7 +6758,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<PopoverTrigger v-else as-child>
<button
type="button"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-gray-200 dark:hover:bg-gray-800 hover:text-foreground"
:class="columnHasFormatter(col.actualColIdx) ? 'text-primary opacity-100' : 'opacity-80'"
:disabled="!formatterKeyForColumn(col.name)"
:title="t('grid.columnFormatter')"
@@ -6894,7 +6902,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<PopoverTrigger v-else as-child>
<button
type="button"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground"
class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-gray-200 dark:hover:bg-gray-800 hover:text-foreground"
:class="localFilterActive(col.actualColIdx) ? 'text-primary opacity-100' : 'opacity-80'"
:title="t('grid.localFilter')"
@click.stop
@@ -6983,7 +6991,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
</template>
</LightTooltip>
<div class="shrink-0" :style="{ width: `${horizontalColumnWindow.afterWidth}px` }" />
<div v-if="gridScrollbarGutter > 0" class="shrink-0 border-l border-border" :style="{ width: 'var(--grid-scrollbar-gutter)' }" />
<div v-if="gridScrollbarGutter > 0" class="shrink-0 border-l border-border w-(--grid-scrollbar-gutter)" />
</div>
</div>
@@ -7086,25 +7094,24 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
>
<template #default="{ item }">
<div
class="flex text-xs border-b border-border"
class="flex text-[13px] border-b border-border h-6.5 w-(--total-w)"
:class="{
'bg-destructive/5 opacity-70': item.isDeleted,
'bg-primary/5': item.isNew && !isRowActive(item.displayIndex),
'bg-muted/30': !item.isNew && !item.isDeleted && !isRowActive(item.displayIndex) && item.displayIndex % 2 === 1,
'active-row': isRowActive(item.displayIndex) && !item.isDeleted,
}"
:style="{ height: '26px', width: 'var(--total-w)' }"
:data-row-index="item.displayIndex"
>
<div
class="data-grid-row-number shrink-0 px-2 py-1 border-r border-border text-center select-none cursor-default hover:bg-accent/50 sticky left-0 z-10 bg-[rgb(255_255_255)] dark:bg-[rgb(35_37_42)]"
class="data-grid-row-number w-(--row-num-w) shrink-0 px-2 py-1 border-r text-center select-none cursor-default hover:bg-gray-200 dark:hover:bg-gray-800 sticky left-0 z-10 bg-background"
:class="[
rowNumberStatusClass(item),
{
'text-primary font-semibold !bg-primary/25': isRowSelected(item.id) && item.status !== 'new' && item.status !== 'edited' && item.status !== 'deleted',
'row-selected': isSelectingAll,
'row-selected text-primary font-semibold !bg-gray-300 dark:!bg-gray-800': isRowSelected(item.id) && item.status !== 'new' && item.status !== 'edited' && item.status !== 'deleted',
},
]"
:style="{ width: 'var(--row-num-w)' }"
@click="handleRowClick(item.displayIndex, item.id, $event)"
@dblclick.stop="toggleTranspose(item.displayIndex)"
@contextmenu="onRowContext(item.id, item.displayIndex)"
@@ -7126,7 +7133,8 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
'row-cell-selected-dirty': rowCellsUseSelectionVisual(item.id) && !cellIsSelected(item.displayIndex, col.visibleColIdx) && item.isDirtyCol[col.actualColIdx],
'bg-yellow-200/60 dark:bg-yellow-500/20': cellIsSearchMatch(item.displayIndex, col.actualColIdx),
'ring-2 ring-inset ring-yellow-500 bg-yellow-300/60 dark:bg-yellow-500/40': cellIsCurrentMatch(item.displayIndex, col.actualColIdx),
'cursor-text hover:bg-accent/50': !isScrolling && canEditCellItem(item, col.actualColIdx),
'tabular-nums': typeof item.data[col.actualColIdx] === 'number',
'cursor-text hover:bg-gray-200 dark:hover:bg-gray-800': !isScrolling && canEditCellItem(item, col.actualColIdx),
'line-through': item.isDeleted,
}"
@mousedown="handleDataCellMousedown(item.displayIndex, col.visibleColIdx, item.id, $event)"
@@ -7204,14 +7212,14 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<!-- Table Info Drawer -->
<div v-if="showTableInfo" class="relative col-start-2 row-start-1 border-l flex flex-col bg-background min-w-0" :class="[{ 'row-span-2': cellDetailPanelIsBottom }, { 'ddl-drawer-resizing': isResizingDdl }]" :style="ddlDrawerStyle" @contextmenu="onDrawerContextMenu">
<div class="absolute left-0 top-0 bottom-0 z-20 w-1.5 -translate-x-1/2 cursor-col-resize hover:bg-primary/30" @mousedown.prevent="onDdlResizeStart" />
<div class="flex items-center gap-2 px-3 py-1.5 border-b shrink-0 bg-muted/20">
<div class="flex items-center gap-2 px-3 py-1.5 border-b shrink-0 bg-muted/20 h-9">
<TableProperties class="w-3.5 h-3.5 text-muted-foreground" />
<span class="text-xs font-medium flex-1 min-w-0 truncate">{{ tableMeta?.tableName }}</span>
<Button v-if="activeTableInfoTab === 'ddl'" variant="ghost" size="sm" class="h-6 px-2 text-xs" :title="t('grid.copyDdl')" :aria-label="t('grid.copyDdl')" @click="copyDdl">
<Copy class="w-3 h-3" />
<span>{{ t("grid.copyDdl") }}</span>
</Button>
<Button v-if="activeTableInfoTab === 'ddl'" variant="ghost" size="icon" class="h-5 w-5" :class="{ 'bg-accent': ddlWrap }" @click="toggleDdlWrap">
<Button v-if="activeTableInfoTab === 'ddl'" variant="ghost" size="icon" class="h-6 w-6" :class="{ 'bg-accent': ddlWrap }" @click="toggleDdlWrap">
<WrapText class="w-3 h-3" />
</Button>
<Button variant="ghost" size="icon" class="h-5 w-5" @click="showTableInfo = false">
@@ -7222,7 +7230,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<button
v-for="tab in tableInfoTabs"
:key="tab.id"
class="h-9 min-w-0 px-1.5 text-[11px] text-muted-foreground border-b-2 border-transparent hover:bg-muted/50 hover:text-foreground"
class="h-9 min-w-0 px-1.5 text-[11px] text-muted-foreground border-b-2 border-transparent hover:bg-gray-200 dark:hover:bg-gray-800/50 hover:text-foreground"
:class="{ 'border-primary text-foreground bg-muted/40': activeTableInfoTab === tab.id }"
:title="tab.label"
@click="selectTableInfoTab(tab.id)"
@@ -7249,17 +7257,17 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<table v-else class="w-full text-xs">
<thead class="sticky top-0 bg-muted text-muted-foreground">
<tr class="border-b">
<th class="text-left font-medium px-3 py-2 w-8">#</th>
<th class="text-left font-medium px-3 py-2">{{ t("grid.columnName") }}</th>
<th class="text-left font-medium px-3 py-2">{{ t("grid.columnType") }}</th>
<th class="text-left font-medium px-3 py-2">{{ t("grid.tableInfoNullable") }}</th>
<th class="text-left text-nowrap font-medium px-3 py-2 w-8">#</th>
<th class="text-left text-nowrap font-medium px-3 py-2">{{ t("grid.columnName") }}</th>
<th class="text-left text-nowrap font-medium px-3 py-2">{{ t("grid.columnType") }}</th>
<th class="text-left text-nowrap font-medium px-3 py-2">{{ t("grid.tableInfoNullable") }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="(column, index) in filteredColumns"
:key="column.name"
class="border-b cursor-pointer hover:bg-muted/30"
class="border-b cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-800/30"
role="button"
tabindex="0"
:title="column.name"
@@ -7978,6 +7986,8 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
</template>
<style scoped>
@reference "../../styles/globals.css";
[data-grid-root] {
--data-grid-row-muted-bg: rgb(248 248 248);
--data-grid-row-new-bg: rgb(243 243 243);
@@ -8150,7 +8160,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
.canvas-grid-surface {
cursor: cell;
font-family: var(--dbx-data-grid-font-family);
font-size: 12.5px;
font-size: 13px;
font-weight: 400;
line-height: 1rem;
outline: none;
@@ -8191,12 +8201,6 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
transition: none;
}
.cell-selected {
background-color: var(--data-grid-cell-selected-bg);
outline: 1px solid var(--data-grid-cell-selected-border);
outline-offset: -1px;
}
.row-cell-selected {
background-color: var(--data-grid-cell-selected-bg);
outline: 1px solid var(--data-grid-cell-selected-border);
@@ -8237,16 +8241,15 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
background-color: var(--data-grid-row-number-deleted-bg);
}
.active-row > div:not(.cell-dirty) {
background-color: var(--data-grid-cell-active-bg);
}
.cell-selected,
.active-row > div:not(.cell-dirty),
.active-row > .data-grid-row-number:not(.cell-dirty) {
background-color: var(--data-grid-row-number-active-bg);
@apply text-foreground bg-gray-300 dark:bg-gray-900;
}
.data-grid-row-number.\!bg-primary\/25 {
background-color: var(--data-grid-row-number-selected-bg) !important;
.cell-selected,
.active-row .row-selected.data-grid-row-number {
@apply outline outline-primary -outline-offset-1;
}
.ddl-code :deep(.ddl-kw) {