fix(grid): contain query grid scrollbars below sticky header
This commit is contained in:
1 parent
070e09c615
commit
6db2589e37
2 files changed
+455
-414
No files matched your search
@@ -13226,436 +13226,442 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="!hasVisibleRows" class="relative min-h-0 flex-1">
|
<!-- Body wrapper: gives the vertical/horizontal scrollbars (absolutely
|
||||||
<div class="data-grid-scroller h-full overflow-x-auto overflow-y-hidden overscroll-none" :class="{ 'is-scrolling': isScrolling }" @scroll="onScrollerScroll" @wheel="onDomGridWheel">
|
positioned) their own stacking context below the header, so their
|
||||||
<div class="h-full min-h-[220px]" :style="{ width: 'max(100%, var(--total-w))' }" />
|
`top`/`inset` offsets are measured from the body instead of from the
|
||||||
</div>
|
grid's outer relative container (which starts at the header row). -->
|
||||||
<div class="pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 px-6 text-center text-muted-foreground">
|
<div class="relative min-h-0 flex-1 flex flex-col overflow-hidden">
|
||||||
<component :is="hasActiveFilter ? SearchX : Inbox" class="h-8 w-8 text-muted-foreground/50" aria-hidden="true" />
|
<div v-if="!hasVisibleRows" class="relative min-h-0 flex-1">
|
||||||
<div class="space-y-1">
|
<div class="data-grid-scroller h-full overflow-x-auto overflow-y-hidden overscroll-none" :class="{ 'is-scrolling': isScrolling }" @scroll="onScrollerScroll" @wheel="onDomGridWheel">
|
||||||
<div class="text-sm font-medium text-foreground">
|
<div class="h-full min-h-[220px]" :style="{ width: 'max(100%, var(--total-w))' }" />
|
||||||
{{ emptyTitle }}
|
</div>
|
||||||
|
<div class="pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 px-6 text-center text-muted-foreground">
|
||||||
|
<component :is="hasActiveFilter ? SearchX : Inbox" class="h-8 w-8 text-muted-foreground/50" aria-hidden="true" />
|
||||||
|
<div class="space-y-1">
|
||||||
|
<div class="text-sm font-medium text-foreground">
|
||||||
|
{{ emptyTitle }}
|
||||||
|
</div>
|
||||||
|
<div class="text-xs">{{ emptyDescription }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs">{{ emptyDescription }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="useCanvasGridRows"
|
|
||||||
ref="scrollerRef"
|
|
||||||
class="data-grid-scroller canvas-grid-scroller flex-1 overflow-auto overscroll-none relative"
|
|
||||||
:class="{
|
|
||||||
'is-scrolling': isScrolling,
|
|
||||||
'has-horizontal-scrollbar': hasGridHorizontalOverflow,
|
|
||||||
}"
|
|
||||||
@scroll="onCanvasScroll"
|
|
||||||
@wheel="onCanvasWheel"
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
class="relative"
|
v-else-if="useCanvasGridRows"
|
||||||
:style="{
|
|
||||||
width: `${totalWidth}px`,
|
|
||||||
height: `${canvasContentHeight}px`,
|
|
||||||
}"
|
|
||||||
@dblclick="onCanvasDblClick"
|
|
||||||
>
|
|
||||||
<canvas
|
|
||||||
ref="canvasRef"
|
|
||||||
class="canvas-grid-surface dbx-data-grid-font-family sticky left-0 top-0 z-0 block font-normal"
|
|
||||||
:style="{
|
|
||||||
width: `${canvasSurfaceWidth}px`,
|
|
||||||
height: `${canvasViewportHeight}px`,
|
|
||||||
display: canvasUsingBackSurface ? 'none' : '',
|
|
||||||
}"
|
|
||||||
@mousemove="onCanvasMouseMove"
|
|
||||||
@mouseleave="onCanvasMouseLeave"
|
|
||||||
@mousedown="onCanvasMouseDown"
|
|
||||||
@contextmenu="onCanvasContext"
|
|
||||||
/>
|
|
||||||
<canvas
|
|
||||||
ref="canvasBackRef"
|
|
||||||
class="canvas-grid-surface dbx-data-grid-font-family sticky left-0 top-0 z-0 block font-normal"
|
|
||||||
:style="{
|
|
||||||
width: `${canvasSurfaceWidth}px`,
|
|
||||||
height: `${canvasViewportHeight}px`,
|
|
||||||
display: canvasUsingBackSurface ? '' : 'none',
|
|
||||||
}"
|
|
||||||
@mousemove="onCanvasMouseMove"
|
|
||||||
@mouseleave="onCanvasMouseLeave"
|
|
||||||
@mousedown="onCanvasMouseDown"
|
|
||||||
@contextmenu="onCanvasContext"
|
|
||||||
/>
|
|
||||||
<div ref="canvasOverlayRef" class="canvas-grid-overlay dbx-data-grid-font-family sticky left-0 top-0 z-10 overflow-visible" :style="canvasOverlayStyle" @dblclick.stop>
|
|
||||||
<div v-if="canvasReadonlyTextCell" class="absolute pointer-events-auto z-20 tabular-nums" :style="canvasReadonlyTextCellStyle" @mousedown.stop @click.stop>
|
|
||||||
<DataGridReadonlyTextSelection :value="canvasReadonlyTextCell.value" :expanded="canvasReadonlyTextCell.expanded" @close="closeReadonlyCellTextSelection" @escape="escapeReadonlyCellTextSelection" />
|
|
||||||
</div>
|
|
||||||
<div v-if="canvasEditingCell" class="absolute pointer-events-auto z-20 tabular-nums" :style="canvasEditingCellStyle" @mousedown.stop @click.stop>
|
|
||||||
<TemporalCellEditor
|
|
||||||
v-if="temporalEditorConfigForColumn(canvasEditingCell.actualColIdx)"
|
|
||||||
v-model="editValue"
|
|
||||||
:kind="temporalEditorConfigForColumn(canvasEditingCell.actualColIdx)!.kind"
|
|
||||||
:fraction-precision="temporalEditorConfigForColumn(canvasEditingCell.actualColIdx)!.fractionPrecision"
|
|
||||||
:normalize-value="(value) => normalizeTemporalCellEditorValue(value, canvasEditingCell!.actualColIdx)"
|
|
||||||
@cancel="cancelEdit"
|
|
||||||
@commit="commitGridEdit"
|
|
||||||
/>
|
|
||||||
<EnumCellEditor
|
|
||||||
v-else-if="isBooleanGridCell(getRowItem(canvasEditingCell.rowId), canvasEditingCell.actualColIdx)"
|
|
||||||
v-model="booleanEditorModelValue"
|
|
||||||
:values="BOOLEAN_CELL_EDITOR_VALUES"
|
|
||||||
:nullable="isBooleanGridColumnNullable(canvasEditingCell.actualColIdx)"
|
|
||||||
:initial-null="isGridCellInitialNull(canvasEditingCell.rowId, canvasEditingCell.actualColIdx)"
|
|
||||||
@cancel="cancelEdit"
|
|
||||||
@commit="commitBooleanGridEdit"
|
|
||||||
/>
|
|
||||||
<EnumCellEditor
|
|
||||||
v-else-if="isEnumGridColumn(canvasEditingCell.actualColIdx)"
|
|
||||||
v-model="editValue"
|
|
||||||
:values="enumValuesForGridColumn(canvasEditingCell.actualColIdx)"
|
|
||||||
:nullable="isEnumGridColumnNullable(canvasEditingCell.actualColIdx)"
|
|
||||||
:initial-null="isGridCellInitialNull(canvasEditingCell.rowId, canvasEditingCell.actualColIdx)"
|
|
||||||
@cancel="cancelEdit"
|
|
||||||
@commit="commitGridEdit"
|
|
||||||
/>
|
|
||||||
<textarea
|
|
||||||
v-else-if="cellUsesExpandedEditor(canvasEditingCell.rowId, canvasEditingCell.actualColIdx)"
|
|
||||||
v-model="editValue"
|
|
||||||
data-expanded-cell-editor="true"
|
|
||||||
rows="1"
|
|
||||||
:inputmode="cellEditInputModeForColumn(canvasEditingCell.actualColIdx)"
|
|
||||||
autocapitalize="off"
|
|
||||||
autocorrect="off"
|
|
||||||
spellcheck="false"
|
|
||||||
class="cell-edit-input cell-edit-input--expanded absolute left-0 top-0 min-h-full bg-background px-2.5 py-1 leading-[18px] outline-none z-10"
|
|
||||||
@blur="commitEditFromCellBlur"
|
|
||||||
@click.stop
|
|
||||||
@focus="onCellEditTextareaInput"
|
|
||||||
@input="onCellEditTextareaInput"
|
|
||||||
@keydown.stop="onCellEditKeydown"
|
|
||||||
@paste.stop="onCellEditTextareaPaste"
|
|
||||||
@wheel.stop
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
v-else
|
|
||||||
v-model="editValue"
|
|
||||||
:inputmode="cellEditInputModeForColumn(canvasEditingCell.actualColIdx)"
|
|
||||||
autocapitalize="off"
|
|
||||||
autocorrect="off"
|
|
||||||
spellcheck="false"
|
|
||||||
class="cell-edit-input absolute inset-0 bg-background border-2 border-primary px-2.5 py-0 leading-[22px] outline-none z-10"
|
|
||||||
@blur="commitEditFromCellBlur"
|
|
||||||
@click.stop
|
|
||||||
@input="onCellEditTextareaInput"
|
|
||||||
@keydown.stop="onCellEditKeydown"
|
|
||||||
@paste.stop="onCellEditTextareaPaste"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div v-if="canvasDetailButtonCell" class="absolute pointer-events-auto z-20 flex -translate-y-1/2 items-center gap-1" :style="canvasDetailButtonStyle" @mouseenter="keepCanvasDetailHover" @mouseleave="clearCanvasDetailHover">
|
|
||||||
<LightDropdownMenu
|
|
||||||
v-if="canvasDetailButtonCell.canQuickDownload"
|
|
||||||
:items="binaryCellDownloadMenuItems"
|
|
||||||
:open="quickDownloadMenuOpenFor(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.actualColIdx)"
|
|
||||||
align="end"
|
|
||||||
content-class="w-44"
|
|
||||||
:match-trigger-width="false"
|
|
||||||
@update:open="(value: boolean) => handleQuickDownloadMenuOpenChange(value, canvasDetailButtonCell!.rowIndex, canvasDetailButtonCell!.actualColIdx)"
|
|
||||||
@select="(mode: string) => downloadCellBinaryValue(canvasDetailButtonCell!.rowIndex, canvasDetailButtonCell!.actualColIdx, mode as BinaryCellDownloadMode)"
|
|
||||||
>
|
|
||||||
<template #trigger="{ open, toggle }">
|
|
||||||
<button class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground" :title="t('grid.downloadBinaryValue')" :aria-expanded="open" @mousedown.stop @click.stop="toggle">
|
|
||||||
<Download class="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
</LightDropdownMenu>
|
|
||||||
<button
|
|
||||||
v-if="canvasDetailButtonCell.externalUrl"
|
|
||||||
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
|
||||||
:title="t('grid.openUrl')"
|
|
||||||
:aria-label="t('grid.openUrl')"
|
|
||||||
@mousedown.stop
|
|
||||||
@click.stop="openCellExternalUrl(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.actualColIdx)"
|
|
||||||
>
|
|
||||||
<ExternalLink class="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-if="canvasDetailButtonCell.foreignKey"
|
|
||||||
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
|
||||||
:title="
|
|
||||||
t('grid.foreignKeyNavigate', {
|
|
||||||
table: canvasDetailButtonCell.foreignKey.ref_table,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
@mousedown.stop
|
|
||||||
@click.stop="navigateToForeignKeyCell(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.actualColIdx)"
|
|
||||||
>
|
|
||||||
<ArrowUpRight class="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-if="cellDetailButtonEnabled"
|
|
||||||
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
|
||||||
:title="t('grid.cellDetails')"
|
|
||||||
@mousedown.stop
|
|
||||||
@click.stop="showCellDetailsForVisibleCell(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.visibleColIdx, canvasDetailButtonCell.actualColIdx)"
|
|
||||||
>
|
|
||||||
<Info class="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Infinite scroll loading indicator for Canvas -->
|
|
||||||
<div v-if="infiniteScrollEnabled && infiniteScrollLoading" class="absolute bottom-0 left-0 right-0 flex items-center justify-center py-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm z-10">
|
|
||||||
<Loader2 class="w-3 h-3 animate-spin mr-1" />
|
|
||||||
{{ t("grid.loadingMore") }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Virtual scrolled rows -->
|
|
||||||
<div v-else-if="hasVisibleRows" class="relative min-h-0 flex-1">
|
|
||||||
<RecycleScroller
|
|
||||||
ref="scrollerRef"
|
ref="scrollerRef"
|
||||||
class="data-grid-scroller dbx-data-grid-font-family h-full overflow-x-auto overscroll-none"
|
class="data-grid-scroller canvas-grid-scroller flex-1 overflow-auto overscroll-none relative"
|
||||||
:class="{
|
:class="{
|
||||||
'is-scrolling': isScrolling,
|
'is-scrolling': isScrolling,
|
||||||
'has-horizontal-scrollbar': hasGridHorizontalOverflow,
|
'has-horizontal-scrollbar': hasGridHorizontalOverflow,
|
||||||
}"
|
}"
|
||||||
:items="displayItems"
|
@scroll="onCanvasScroll"
|
||||||
:item-size="DOM_DATA_GRID_ROW_HEIGHT"
|
@wheel="onCanvasWheel"
|
||||||
:buffer="600"
|
|
||||||
:skip-hover="true"
|
|
||||||
key-field="id"
|
|
||||||
@scroll="onScrollerScroll"
|
|
||||||
@wheel="onDomGridWheel"
|
|
||||||
>
|
>
|
||||||
<template #default="{ item }">
|
<div
|
||||||
<div
|
class="relative"
|
||||||
class="data-grid-row flex border-b border-border h-6.5 w-(--total-w)"
|
:style="{
|
||||||
:class="{
|
width: `${totalWidth}px`,
|
||||||
'data-grid-row--deleted opacity-70': item.isDeleted,
|
height: `${canvasContentHeight}px`,
|
||||||
'data-grid-row--new': item.isNew && !isRowActive(item.displayIndex),
|
}"
|
||||||
'data-grid-row--draft': item.isDraft && !isRowActive(item.displayIndex),
|
@dblclick="onCanvasDblClick"
|
||||||
'data-grid-row--striped': !item.isNew && !item.isDraft && !item.isDeleted && !isRowActive(item.displayIndex) && item.displayIndex % 2 === 1,
|
>
|
||||||
'active-row': isRowActive(item.displayIndex) && !item.isDeleted,
|
<canvas
|
||||||
'crosshair-row': !!crosshairTarget?.rowCrosshair && crosshairTarget.rowIndex === item.displayIndex && !item.isDeleted,
|
ref="canvasRef"
|
||||||
'relative z-20 overflow-visible': editingCell?.rowId === item.id || readonlyTextCell?.rowId === item.id,
|
class="canvas-grid-surface dbx-data-grid-font-family sticky left-0 top-0 z-0 block font-normal"
|
||||||
|
:style="{
|
||||||
|
width: `${canvasSurfaceWidth}px`,
|
||||||
|
height: `${canvasViewportHeight}px`,
|
||||||
|
display: canvasUsingBackSurface ? 'none' : '',
|
||||||
}"
|
}"
|
||||||
:style="dataGridRowStyle(item)"
|
@mousemove="onCanvasMouseMove"
|
||||||
:data-row-index="item.displayIndex"
|
@mouseleave="onCanvasMouseLeave"
|
||||||
>
|
@mousedown="onCanvasMouseDown"
|
||||||
<div
|
@contextmenu="onCanvasContext"
|
||||||
class="data-grid-row-number w-(--row-num-w) shrink-0 px-2 py-1 border-r text-center select-none cursor-default sticky left-0 z-10"
|
/>
|
||||||
:class="[
|
<canvas
|
||||||
rowNumberStatusClass(item),
|
ref="canvasBackRef"
|
||||||
{
|
class="canvas-grid-surface dbx-data-grid-font-family sticky left-0 top-0 z-0 block font-normal"
|
||||||
'data-grid-row-number--selected': isRowSelected(item.id),
|
:style="{
|
||||||
'data-grid-row-number--in-selection': rowNumberShowsSelectionTint(item),
|
width: `${canvasSurfaceWidth}px`,
|
||||||
},
|
height: `${canvasViewportHeight}px`,
|
||||||
]"
|
display: canvasUsingBackSurface ? '' : 'none',
|
||||||
@mousedown="onRowNumberMouseDown(item, $event)"
|
}"
|
||||||
@dblclick.stop="toggleTranspose(item.displayIndex)"
|
@mousemove="onCanvasMouseMove"
|
||||||
@contextmenu="onRowContext(item.id, item.displayIndex)"
|
@mouseleave="onCanvasMouseLeave"
|
||||||
>
|
@mousedown="onCanvasMouseDown"
|
||||||
{{ rowNumberText(item) }}
|
@contextmenu="onCanvasContext"
|
||||||
|
/>
|
||||||
|
<div ref="canvasOverlayRef" class="canvas-grid-overlay dbx-data-grid-font-family sticky left-0 top-0 z-10 overflow-visible" :style="canvasOverlayStyle" @dblclick.stop>
|
||||||
|
<div v-if="canvasReadonlyTextCell" class="absolute pointer-events-auto z-20 tabular-nums" :style="canvasReadonlyTextCellStyle" @mousedown.stop @click.stop>
|
||||||
|
<DataGridReadonlyTextSelection :value="canvasReadonlyTextCell.value" :expanded="canvasReadonlyTextCell.expanded" @close="closeReadonlyCellTextSelection" @escape="escapeReadonlyCellTextSelection" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-if="canvasEditingCell" class="absolute pointer-events-auto z-20 tabular-nums" :style="canvasEditingCellStyle" @mousedown.stop @click.stop>
|
||||||
class="shrink-0"
|
<TemporalCellEditor
|
||||||
:style="{
|
v-if="temporalEditorConfigForColumn(canvasEditingCell.actualColIdx)"
|
||||||
width: `${horizontalColumnWindowBeforeWidth}px`,
|
v-model="editValue"
|
||||||
}"
|
:kind="temporalEditorConfigForColumn(canvasEditingCell.actualColIdx)!.kind"
|
||||||
/>
|
:fraction-precision="temporalEditorConfigForColumn(canvasEditingCell.actualColIdx)!.fractionPrecision"
|
||||||
<div
|
:normalize-value="(value) => normalizeTemporalCellEditorValue(value, canvasEditingCell!.actualColIdx)"
|
||||||
v-for="col in renderedGridColumns"
|
@cancel="cancelEdit"
|
||||||
:key="col.actualColIdx"
|
@commit="commitGridEdit"
|
||||||
class="data-grid-cell group/cell shrink-0 px-3 py-1 border-r border-border whitespace-nowrap overflow-hidden text-ellipsis relative select-none inline-block items-center tabular-nums"
|
/>
|
||||||
:style="renderedColumnStyle(col.visibleColIdx)"
|
<EnumCellEditor
|
||||||
:class="[
|
v-else-if="isBooleanGridCell(getRowItem(canvasEditingCell.rowId), canvasEditingCell.actualColIdx)"
|
||||||
gridCellTextColorClass(item, col.actualColIdx, col.visibleColIdx),
|
v-model="booleanEditorModelValue"
|
||||||
selectionFrameEdgeClass(item.displayIndex, col.visibleColIdx),
|
:values="BOOLEAN_CELL_EDITOR_VALUES"
|
||||||
{
|
:nullable="isBooleanGridColumnNullable(canvasEditingCell.actualColIdx)"
|
||||||
'data-grid-cell--frozen': col.visibleColIdx < frozenColumnCount,
|
:initial-null="isGridCellInitialNull(canvasEditingCell.rowId, canvasEditingCell.actualColIdx)"
|
||||||
'data-grid-cell--frozen-separator': frozenColumnCount > 0 && col.visibleColIdx === frozenColumnCount - 1,
|
@cancel="cancelEdit"
|
||||||
'text-right': columnAligns[col.visibleColIdx] === 'right',
|
@commit="commitBooleanGridEdit"
|
||||||
'bg-yellow-500/10 cell-dirty': item.isDirtyCol[col.actualColIdx],
|
/>
|
||||||
'cell-selected': cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
<EnumCellEditor
|
||||||
'cell-selected-dirty': cellIsSelected(item.displayIndex, col.visibleColIdx) && item.isDirtyCol[col.actualColIdx],
|
v-else-if="isEnumGridColumn(canvasEditingCell.actualColIdx)"
|
||||||
'cell-selected--single': !selectionUsesOuterFrame && selectionFrameKindForCell(item.displayIndex, col.visibleColIdx) === 'single' && cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
v-model="editValue"
|
||||||
'cell-selected--sparse': selectionFramesData.sparse && cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
:values="enumValuesForGridColumn(canvasEditingCell.actualColIdx)"
|
||||||
'cell-selected-dirty--sparse': selectionFramesData.sparse && cellIsSelected(item.displayIndex, col.visibleColIdx) && item.isDirtyCol[col.actualColIdx],
|
:nullable="isEnumGridColumnNullable(canvasEditingCell.actualColIdx)"
|
||||||
'row-cell-selected': rowCellsUseSelectionVisual(item.id) && !cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
:initial-null="isGridCellInitialNull(canvasEditingCell.rowId, canvasEditingCell.actualColIdx)"
|
||||||
'row-cell-selected-dirty': rowCellsUseSelectionVisual(item.id) && !cellIsSelected(item.displayIndex, col.visibleColIdx) && item.isDirtyCol[col.actualColIdx],
|
@cancel="cancelEdit"
|
||||||
'crosshair-column': !!crosshairTarget?.columnCrosshair && crosshairTarget.visibleColIdx === col.visibleColIdx && !item.isDeleted,
|
@commit="commitGridEdit"
|
||||||
'cell-search-match': cellIsSearchMatch(item.displayIndex, col.actualColIdx),
|
/>
|
||||||
'cell-current-search-match': cellIsCurrentMatch(item.displayIndex, col.actualColIdx),
|
<textarea
|
||||||
'bg-yellow-200/60 dark:bg-yellow-500/20': cellIsSearchMatch(item.displayIndex, col.actualColIdx),
|
v-else-if="cellUsesExpandedEditor(canvasEditingCell.rowId, canvasEditingCell.actualColIdx)"
|
||||||
'ring-2 ring-inset ring-yellow-500 bg-yellow-300/60 dark:bg-yellow-500/40': cellIsCurrentMatch(item.displayIndex, col.actualColIdx),
|
v-model="editValue"
|
||||||
'tabular-nums': typeof item.data[col.actualColIdx] === 'number',
|
data-expanded-cell-editor="true"
|
||||||
'cursor-text': !isScrolling && !canEditCellItem(item, col.actualColIdx),
|
rows="1"
|
||||||
'cursor-text hover:bg-gray-200 hover:text-foreground dark:hover:bg-gray-800': !isScrolling && canEditCellItem(item, col.actualColIdx) && !(booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] !== null),
|
:inputmode="cellEditInputModeForColumn(canvasEditingCell.actualColIdx)"
|
||||||
'cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-800': !isScrolling && booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] !== null && canEditCellItem(item, col.actualColIdx),
|
autocapitalize="off"
|
||||||
'line-through': item.isDeleted,
|
autocorrect="off"
|
||||||
'overflow-visible z-20 border-r-transparent': (editingCell?.rowId === item.id && editingCell?.col === col.actualColIdx) || readonlyTextCellMatches(item.id, col.actualColIdx),
|
spellcheck="false"
|
||||||
'overflow-hidden': !((editingCell?.rowId === item.id && editingCell?.col === col.actualColIdx) || readonlyTextCellMatches(item.id, col.actualColIdx)),
|
class="cell-edit-input cell-edit-input--expanded absolute left-0 top-0 min-h-full bg-background px-2.5 py-1 leading-[18px] outline-none z-10"
|
||||||
},
|
@blur="commitEditFromCellBlur"
|
||||||
]"
|
@click.stop
|
||||||
@mousedown="
|
@focus="onCellEditTextareaInput"
|
||||||
prepareDataCellMouseDown(item, col.actualColIdx);
|
@input="onCellEditTextareaInput"
|
||||||
handleDataCellMousedown(item.displayIndex, col.visibleColIdx, item.id, $event);
|
@keydown.stop="onCellEditKeydown"
|
||||||
"
|
@paste.stop="onCellEditTextareaPaste"
|
||||||
@mouseenter="onCellMouseenter(item.displayIndex, col.visibleColIdx, col.actualColIdx, $event)"
|
@wheel.stop
|
||||||
@mouseleave="onCellMouseleave(item.displayIndex, col.actualColIdx)"
|
/>
|
||||||
@dblclick="onDomCellDblClick(item, col.actualColIdx, $event)"
|
<input
|
||||||
:data-visible-col-index="col.visibleColIdx"
|
v-else
|
||||||
@contextmenu="onCellContext(item.id, item.displayIndex, col.actualColIdx, col.visibleColIdx, $event)"
|
v-model="editValue"
|
||||||
>
|
:inputmode="cellEditInputModeForColumn(canvasEditingCell.actualColIdx)"
|
||||||
<template v-if="readonlyTextCellMatches(item.id, col.actualColIdx)">
|
autocapitalize="off"
|
||||||
<DataGridReadonlyTextSelection :value="readonlyTextCell!.value" :expanded="readonlyTextCell!.expanded" @close="closeReadonlyCellTextSelection" @escape="escapeReadonlyCellTextSelection" />
|
autocorrect="off"
|
||||||
</template>
|
spellcheck="false"
|
||||||
<template v-else-if="editingCell?.rowId === item.id && editingCell?.col === col.actualColIdx">
|
class="cell-edit-input absolute inset-0 bg-background border-2 border-primary px-2.5 py-0 leading-[22px] outline-none z-10"
|
||||||
<TemporalCellEditor
|
@blur="commitEditFromCellBlur"
|
||||||
v-if="temporalEditorConfigForColumn(col.actualColIdx)"
|
@click.stop
|
||||||
v-model="editValue"
|
@input="onCellEditTextareaInput"
|
||||||
:kind="temporalEditorConfigForColumn(col.actualColIdx)!.kind"
|
@keydown.stop="onCellEditKeydown"
|
||||||
:fraction-precision="temporalEditorConfigForColumn(col.actualColIdx)!.fractionPrecision"
|
@paste.stop="onCellEditTextareaPaste"
|
||||||
:normalize-value="(value) => normalizeTemporalCellEditorValue(value, col.actualColIdx)"
|
/>
|
||||||
@cancel="cancelEdit"
|
</div>
|
||||||
@commit="commitGridEdit"
|
<div v-if="canvasDetailButtonCell" class="absolute pointer-events-auto z-20 flex -translate-y-1/2 items-center gap-1" :style="canvasDetailButtonStyle" @mouseenter="keepCanvasDetailHover" @mouseleave="clearCanvasDetailHover">
|
||||||
/>
|
<LightDropdownMenu
|
||||||
<EnumCellEditor
|
v-if="canvasDetailButtonCell.canQuickDownload"
|
||||||
v-else-if="isBooleanGridCell(item, col.actualColIdx)"
|
:items="binaryCellDownloadMenuItems"
|
||||||
v-model="booleanEditorModelValue"
|
:open="quickDownloadMenuOpenFor(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.actualColIdx)"
|
||||||
:values="BOOLEAN_CELL_EDITOR_VALUES"
|
align="end"
|
||||||
:nullable="isBooleanGridColumnNullable(col.actualColIdx)"
|
content-class="w-44"
|
||||||
:initial-null="isGridCellInitialNull(item.id, col.actualColIdx)"
|
:match-trigger-width="false"
|
||||||
@cancel="cancelEdit"
|
@update:open="(value: boolean) => handleQuickDownloadMenuOpenChange(value, canvasDetailButtonCell!.rowIndex, canvasDetailButtonCell!.actualColIdx)"
|
||||||
@commit="commitBooleanGridEdit"
|
@select="(mode: string) => downloadCellBinaryValue(canvasDetailButtonCell!.rowIndex, canvasDetailButtonCell!.actualColIdx, mode as BinaryCellDownloadMode)"
|
||||||
/>
|
>
|
||||||
<EnumCellEditor
|
<template #trigger="{ open, toggle }">
|
||||||
v-else-if="isEnumGridColumn(col.actualColIdx)"
|
<button class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground" :title="t('grid.downloadBinaryValue')" :aria-expanded="open" @mousedown.stop @click.stop="toggle">
|
||||||
v-model="editValue"
|
<Download class="h-3 w-3" />
|
||||||
:values="enumValuesForGridColumn(col.actualColIdx)"
|
</button>
|
||||||
:nullable="isEnumGridColumnNullable(col.actualColIdx)"
|
|
||||||
:initial-null="isGridCellInitialNull(item.id, col.actualColIdx)"
|
|
||||||
@cancel="cancelEdit"
|
|
||||||
@commit="commitGridEdit"
|
|
||||||
/>
|
|
||||||
<textarea
|
|
||||||
v-else-if="cellUsesExpandedEditor(item.id, col.actualColIdx)"
|
|
||||||
v-model="editValue"
|
|
||||||
data-expanded-cell-editor="true"
|
|
||||||
rows="1"
|
|
||||||
:inputmode="cellEditInputModeForColumn(col.actualColIdx)"
|
|
||||||
autocapitalize="off"
|
|
||||||
autocorrect="off"
|
|
||||||
spellcheck="false"
|
|
||||||
class="cell-edit-input cell-edit-input--expanded absolute left-0 top-0 min-h-full bg-background px-2.5 py-1 leading-[18px] outline-none z-10"
|
|
||||||
@blur="commitEditFromCellBlur"
|
|
||||||
@click.stop
|
|
||||||
@focus="onCellEditTextareaInput"
|
|
||||||
@input="onCellEditTextareaInput"
|
|
||||||
@keydown.stop="onCellEditKeydown"
|
|
||||||
@paste.stop="onCellEditTextareaPaste"
|
|
||||||
@wheel.stop
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
v-else
|
|
||||||
v-model="editValue"
|
|
||||||
:inputmode="cellEditInputModeForColumn(col.actualColIdx)"
|
|
||||||
autocapitalize="off"
|
|
||||||
autocorrect="off"
|
|
||||||
spellcheck="false"
|
|
||||||
class="cell-edit-input absolute inset-0 bg-background border-2 border-primary px-2.5 py-0 leading-[22px] outline-none z-10"
|
|
||||||
@blur="commitEditFromCellBlur"
|
|
||||||
@click.stop
|
|
||||||
@input="onCellEditTextareaInput"
|
|
||||||
@keydown.stop="onCellEditKeydown"
|
|
||||||
@paste.stop="onCellEditTextareaPaste"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] !== null && canEditCellItem(item, col.actualColIdx)">
|
|
||||||
<div class="flex h-full items-center justify-center">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
class="h-3.5 w-3.5 rounded border-border/70 bg-background text-primary focus:ring-0"
|
|
||||||
:checked="booleanCellChecked(item.data[col.actualColIdx])"
|
|
||||||
:disabled="!canEditCellItem(item, col.actualColIdx)"
|
|
||||||
@mousedown.stop
|
|
||||||
@click.stop="cycleBooleanGridCell(item, col.actualColIdx, $event)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] === null && canEditCellItem(item, col.actualColIdx)">
|
|
||||||
<span class="italic text-muted-foreground cursor-pointer select-none" @click.stop="cycleBooleanGridCell(item, col.actualColIdx, $event)">{{
|
|
||||||
firstLineCellDisplayValue(newRowCellPlaceholder(item, col.actualColIdx) ?? formatCellCached(item.data[col.actualColIdx], col.actualColIdx), flatteningMultiLineEnabled)
|
|
||||||
}}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<template v-if="newRowCellPlaceholder(item, col.actualColIdx)">
|
|
||||||
<span class="text-muted-foreground/70 italic">{{ firstLineCellDisplayValue(newRowCellPlaceholder(item, col.actualColIdx) ?? "", flatteningMultiLineEnabled) }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>{{ gridCellDisplayValue(formatGridItemCell(item, col.actualColIdx), flatteningMultiLineEnabled, showWhitespaceEnabled) }}</template>
|
</LightDropdownMenu>
|
||||||
<div v-if="cellDetailButtonVisible(item.displayIndex, col.actualColIdx)" class="absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1">
|
<button
|
||||||
<LightDropdownMenu
|
v-if="canvasDetailButtonCell.externalUrl"
|
||||||
v-if="canQuickDownloadCellValue(item.displayIndex, col.actualColIdx)"
|
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
||||||
:items="binaryCellDownloadMenuItems"
|
:title="t('grid.openUrl')"
|
||||||
:open="quickDownloadMenuOpenFor(item.displayIndex, col.actualColIdx)"
|
:aria-label="t('grid.openUrl')"
|
||||||
align="end"
|
@mousedown.stop
|
||||||
content-class="w-44"
|
@click.stop="openCellExternalUrl(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.actualColIdx)"
|
||||||
:match-trigger-width="false"
|
>
|
||||||
@update:open="(value: boolean) => handleQuickDownloadMenuOpenChange(value, item.displayIndex, col.actualColIdx)"
|
<ExternalLink class="h-3 w-3" />
|
||||||
@select="(mode: string) => downloadCellBinaryValue(item.displayIndex, col.actualColIdx, mode as BinaryCellDownloadMode)"
|
</button>
|
||||||
>
|
<button
|
||||||
<template #trigger="{ open, toggle }">
|
v-if="canvasDetailButtonCell.foreignKey"
|
||||||
<button class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground" :title="t('grid.downloadBinaryValue')" :aria-expanded="open" @mousedown.stop @click.stop="toggle">
|
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
||||||
<Download class="h-3 w-3" />
|
:title="
|
||||||
</button>
|
t('grid.foreignKeyNavigate', {
|
||||||
</template>
|
table: canvasDetailButtonCell.foreignKey.ref_table,
|
||||||
</LightDropdownMenu>
|
})
|
||||||
<button
|
"
|
||||||
v-if="canOpenCellExternalUrl(item.displayIndex, col.actualColIdx)"
|
@mousedown.stop
|
||||||
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
@click.stop="navigateToForeignKeyCell(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.actualColIdx)"
|
||||||
:title="t('grid.openUrl')"
|
>
|
||||||
:aria-label="t('grid.openUrl')"
|
<ArrowUpRight class="h-3 w-3" />
|
||||||
@mousedown.stop
|
</button>
|
||||||
@click.stop="openCellExternalUrl(item.displayIndex, col.actualColIdx)"
|
<button
|
||||||
>
|
v-if="cellDetailButtonEnabled"
|
||||||
<ExternalLink class="h-3 w-3" />
|
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
||||||
</button>
|
:title="t('grid.cellDetails')"
|
||||||
<button
|
@mousedown.stop
|
||||||
v-if="cellDetailButtonEnabled"
|
@click.stop="showCellDetailsForVisibleCell(canvasDetailButtonCell.rowIndex, canvasDetailButtonCell.visibleColIdx, canvasDetailButtonCell.actualColIdx)"
|
||||||
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
>
|
||||||
:title="t('grid.cellDetails')"
|
<Info class="h-3 w-3" />
|
||||||
@mousedown.stop
|
</button>
|
||||||
@click.stop="showCellDetailsForVisibleCell(item.displayIndex, col.visibleColIdx, col.actualColIdx)"
|
|
||||||
>
|
|
||||||
<Info class="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
class="shrink-0"
|
|
||||||
:style="{
|
|
||||||
width: `${horizontalColumnWindow.afterWidth}px`,
|
|
||||||
}"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</div>
|
||||||
</RecycleScroller>
|
<!-- Infinite scroll loading indicator for Canvas -->
|
||||||
<div v-if="domSelectionDragOverlayStyle" class="data-grid-selection-drag-overlay pointer-events-none absolute z-20" :style="domSelectionDragOverlayStyle" />
|
<div v-if="infiniteScrollEnabled && infiniteScrollLoading" class="absolute bottom-0 left-0 right-0 flex items-center justify-center py-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm z-10">
|
||||||
</div>
|
<Loader2 class="w-3 h-3 animate-spin mr-1" />
|
||||||
<!-- Infinite scroll loading indicator for RecycleScroller -->
|
{{ t("grid.loadingMore") }}
|
||||||
<div v-if="infiniteScrollEnabled && infiniteScrollLoading && !gridSurfaceBusy" class="flex items-center justify-center py-2 text-xs text-muted-foreground">
|
</div>
|
||||||
<Loader2 class="w-3 h-3 animate-spin mr-1" />
|
</div>
|
||||||
{{ t("grid.loadingMore") }}
|
|
||||||
</div>
|
<!-- Virtual scrolled rows -->
|
||||||
<div v-if="hasGridHorizontalOverflow" ref="gridHorizontalScrollbarTrackRef" class="data-grid-horizontal-scrollbar" @pointerdown="startGridHorizontalScrollbarDrag">
|
<div v-else-if="hasVisibleRows" class="relative min-h-0 flex-1">
|
||||||
<div ref="gridHorizontalScrollbarThumbRef" class="data-grid-horizontal-scrollbar__thumb" />
|
<RecycleScroller
|
||||||
</div>
|
ref="scrollerRef"
|
||||||
<div v-if="hasGridVerticalOverflow" ref="gridVerticalScrollbarTrackRef" class="data-grid-vertical-scrollbar" @pointerdown="startGridVerticalScrollbarDrag">
|
class="data-grid-scroller dbx-data-grid-font-family h-full overflow-x-auto overscroll-none"
|
||||||
<div ref="gridVerticalScrollbarThumbRef" class="data-grid-vertical-scrollbar__thumb" />
|
:class="{
|
||||||
</div>
|
'is-scrolling': isScrolling,
|
||||||
<div v-if="gridSurfaceBusy" class="absolute inset-0 z-20 flex items-center justify-center" :class="pageJumpProgress ? 'bg-background/35 backdrop-blur-[1px]' : 'bg-background/50'">
|
'has-horizontal-scrollbar': hasGridHorizontalOverflow,
|
||||||
<DataGridBusyOverlay :elapsed-ms="loadingElapsed" :page-jump-progress="pageJumpProgress" :show-cancel="showCancel" :cancelling="cancelling" :cancel-disabled="cancelDisabled" @cancel="emit('cancel')" />
|
}"
|
||||||
|
:items="displayItems"
|
||||||
|
:item-size="DOM_DATA_GRID_ROW_HEIGHT"
|
||||||
|
:buffer="600"
|
||||||
|
:skip-hover="true"
|
||||||
|
key-field="id"
|
||||||
|
@scroll="onScrollerScroll"
|
||||||
|
@wheel="onDomGridWheel"
|
||||||
|
>
|
||||||
|
<template #default="{ item }">
|
||||||
|
<div
|
||||||
|
class="data-grid-row flex border-b border-border h-6.5 w-(--total-w)"
|
||||||
|
:class="{
|
||||||
|
'data-grid-row--deleted opacity-70': item.isDeleted,
|
||||||
|
'data-grid-row--new': item.isNew && !isRowActive(item.displayIndex),
|
||||||
|
'data-grid-row--draft': item.isDraft && !isRowActive(item.displayIndex),
|
||||||
|
'data-grid-row--striped': !item.isNew && !item.isDraft && !item.isDeleted && !isRowActive(item.displayIndex) && item.displayIndex % 2 === 1,
|
||||||
|
'active-row': isRowActive(item.displayIndex) && !item.isDeleted,
|
||||||
|
'crosshair-row': !!crosshairTarget?.rowCrosshair && crosshairTarget.rowIndex === item.displayIndex && !item.isDeleted,
|
||||||
|
'relative z-20 overflow-visible': editingCell?.rowId === item.id || readonlyTextCell?.rowId === item.id,
|
||||||
|
}"
|
||||||
|
:style="dataGridRowStyle(item)"
|
||||||
|
:data-row-index="item.displayIndex"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="data-grid-row-number w-(--row-num-w) shrink-0 px-2 py-1 border-r text-center select-none cursor-default sticky left-0 z-10"
|
||||||
|
:class="[
|
||||||
|
rowNumberStatusClass(item),
|
||||||
|
{
|
||||||
|
'data-grid-row-number--selected': isRowSelected(item.id),
|
||||||
|
'data-grid-row-number--in-selection': rowNumberShowsSelectionTint(item),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
@mousedown="onRowNumberMouseDown(item, $event)"
|
||||||
|
@dblclick.stop="toggleTranspose(item.displayIndex)"
|
||||||
|
@contextmenu="onRowContext(item.id, item.displayIndex)"
|
||||||
|
>
|
||||||
|
{{ rowNumberText(item) }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="shrink-0"
|
||||||
|
:style="{
|
||||||
|
width: `${horizontalColumnWindowBeforeWidth}px`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-for="col in renderedGridColumns"
|
||||||
|
:key="col.actualColIdx"
|
||||||
|
class="data-grid-cell group/cell shrink-0 px-3 py-1 border-r border-border whitespace-nowrap overflow-hidden text-ellipsis relative select-none inline-block items-center tabular-nums"
|
||||||
|
:style="renderedColumnStyle(col.visibleColIdx)"
|
||||||
|
:class="[
|
||||||
|
gridCellTextColorClass(item, col.actualColIdx, col.visibleColIdx),
|
||||||
|
selectionFrameEdgeClass(item.displayIndex, col.visibleColIdx),
|
||||||
|
{
|
||||||
|
'data-grid-cell--frozen': col.visibleColIdx < frozenColumnCount,
|
||||||
|
'data-grid-cell--frozen-separator': frozenColumnCount > 0 && col.visibleColIdx === frozenColumnCount - 1,
|
||||||
|
'text-right': columnAligns[col.visibleColIdx] === 'right',
|
||||||
|
'bg-yellow-500/10 cell-dirty': item.isDirtyCol[col.actualColIdx],
|
||||||
|
'cell-selected': cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
||||||
|
'cell-selected-dirty': cellIsSelected(item.displayIndex, col.visibleColIdx) && item.isDirtyCol[col.actualColIdx],
|
||||||
|
'cell-selected--single': !selectionUsesOuterFrame && selectionFrameKindForCell(item.displayIndex, col.visibleColIdx) === 'single' && cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
||||||
|
'cell-selected--sparse': selectionFramesData.sparse && cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
||||||
|
'cell-selected-dirty--sparse': selectionFramesData.sparse && cellIsSelected(item.displayIndex, col.visibleColIdx) && item.isDirtyCol[col.actualColIdx],
|
||||||
|
'row-cell-selected': rowCellsUseSelectionVisual(item.id) && !cellIsSelected(item.displayIndex, col.visibleColIdx) && !item.isDirtyCol[col.actualColIdx],
|
||||||
|
'row-cell-selected-dirty': rowCellsUseSelectionVisual(item.id) && !cellIsSelected(item.displayIndex, col.visibleColIdx) && item.isDirtyCol[col.actualColIdx],
|
||||||
|
'crosshair-column': !!crosshairTarget?.columnCrosshair && crosshairTarget.visibleColIdx === col.visibleColIdx && !item.isDeleted,
|
||||||
|
'cell-search-match': cellIsSearchMatch(item.displayIndex, col.actualColIdx),
|
||||||
|
'cell-current-search-match': cellIsCurrentMatch(item.displayIndex, 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),
|
||||||
|
'tabular-nums': typeof item.data[col.actualColIdx] === 'number',
|
||||||
|
'cursor-text': !isScrolling && !canEditCellItem(item, col.actualColIdx),
|
||||||
|
'cursor-text hover:bg-gray-200 hover:text-foreground dark:hover:bg-gray-800': !isScrolling && canEditCellItem(item, col.actualColIdx) && !(booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] !== null),
|
||||||
|
'cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-800': !isScrolling && booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] !== null && canEditCellItem(item, col.actualColIdx),
|
||||||
|
'line-through': item.isDeleted,
|
||||||
|
'overflow-visible z-20 border-r-transparent': (editingCell?.rowId === item.id && editingCell?.col === col.actualColIdx) || readonlyTextCellMatches(item.id, col.actualColIdx),
|
||||||
|
'overflow-hidden': !((editingCell?.rowId === item.id && editingCell?.col === col.actualColIdx) || readonlyTextCellMatches(item.id, col.actualColIdx)),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
@mousedown="
|
||||||
|
prepareDataCellMouseDown(item, col.actualColIdx);
|
||||||
|
handleDataCellMousedown(item.displayIndex, col.visibleColIdx, item.id, $event);
|
||||||
|
"
|
||||||
|
@mouseenter="onCellMouseenter(item.displayIndex, col.visibleColIdx, col.actualColIdx, $event)"
|
||||||
|
@mouseleave="onCellMouseleave(item.displayIndex, col.actualColIdx)"
|
||||||
|
@dblclick="onDomCellDblClick(item, col.actualColIdx, $event)"
|
||||||
|
:data-visible-col-index="col.visibleColIdx"
|
||||||
|
@contextmenu="onCellContext(item.id, item.displayIndex, col.actualColIdx, col.visibleColIdx, $event)"
|
||||||
|
>
|
||||||
|
<template v-if="readonlyTextCellMatches(item.id, col.actualColIdx)">
|
||||||
|
<DataGridReadonlyTextSelection :value="readonlyTextCell!.value" :expanded="readonlyTextCell!.expanded" @close="closeReadonlyCellTextSelection" @escape="escapeReadonlyCellTextSelection" />
|
||||||
|
</template>
|
||||||
|
<template v-else-if="editingCell?.rowId === item.id && editingCell?.col === col.actualColIdx">
|
||||||
|
<TemporalCellEditor
|
||||||
|
v-if="temporalEditorConfigForColumn(col.actualColIdx)"
|
||||||
|
v-model="editValue"
|
||||||
|
:kind="temporalEditorConfigForColumn(col.actualColIdx)!.kind"
|
||||||
|
:fraction-precision="temporalEditorConfigForColumn(col.actualColIdx)!.fractionPrecision"
|
||||||
|
:normalize-value="(value) => normalizeTemporalCellEditorValue(value, col.actualColIdx)"
|
||||||
|
@cancel="cancelEdit"
|
||||||
|
@commit="commitGridEdit"
|
||||||
|
/>
|
||||||
|
<EnumCellEditor
|
||||||
|
v-else-if="isBooleanGridCell(item, col.actualColIdx)"
|
||||||
|
v-model="booleanEditorModelValue"
|
||||||
|
:values="BOOLEAN_CELL_EDITOR_VALUES"
|
||||||
|
:nullable="isBooleanGridColumnNullable(col.actualColIdx)"
|
||||||
|
:initial-null="isGridCellInitialNull(item.id, col.actualColIdx)"
|
||||||
|
@cancel="cancelEdit"
|
||||||
|
@commit="commitBooleanGridEdit"
|
||||||
|
/>
|
||||||
|
<EnumCellEditor
|
||||||
|
v-else-if="isEnumGridColumn(col.actualColIdx)"
|
||||||
|
v-model="editValue"
|
||||||
|
:values="enumValuesForGridColumn(col.actualColIdx)"
|
||||||
|
:nullable="isEnumGridColumnNullable(col.actualColIdx)"
|
||||||
|
:initial-null="isGridCellInitialNull(item.id, col.actualColIdx)"
|
||||||
|
@cancel="cancelEdit"
|
||||||
|
@commit="commitGridEdit"
|
||||||
|
/>
|
||||||
|
<textarea
|
||||||
|
v-else-if="cellUsesExpandedEditor(item.id, col.actualColIdx)"
|
||||||
|
v-model="editValue"
|
||||||
|
data-expanded-cell-editor="true"
|
||||||
|
rows="1"
|
||||||
|
:inputmode="cellEditInputModeForColumn(col.actualColIdx)"
|
||||||
|
autocapitalize="off"
|
||||||
|
autocorrect="off"
|
||||||
|
spellcheck="false"
|
||||||
|
class="cell-edit-input cell-edit-input--expanded absolute left-0 top-0 min-h-full bg-background px-2.5 py-1 leading-[18px] outline-none z-10"
|
||||||
|
@blur="commitEditFromCellBlur"
|
||||||
|
@click.stop
|
||||||
|
@focus="onCellEditTextareaInput"
|
||||||
|
@input="onCellEditTextareaInput"
|
||||||
|
@keydown.stop="onCellEditKeydown"
|
||||||
|
@paste.stop="onCellEditTextareaPaste"
|
||||||
|
@wheel.stop
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
v-else
|
||||||
|
v-model="editValue"
|
||||||
|
:inputmode="cellEditInputModeForColumn(col.actualColIdx)"
|
||||||
|
autocapitalize="off"
|
||||||
|
autocorrect="off"
|
||||||
|
spellcheck="false"
|
||||||
|
class="cell-edit-input absolute inset-0 bg-background border-2 border-primary px-2.5 py-0 leading-[22px] outline-none z-10"
|
||||||
|
@blur="commitEditFromCellBlur"
|
||||||
|
@click.stop
|
||||||
|
@input="onCellEditTextareaInput"
|
||||||
|
@keydown.stop="onCellEditKeydown"
|
||||||
|
@paste.stop="onCellEditTextareaPaste"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] !== null && canEditCellItem(item, col.actualColIdx)">
|
||||||
|
<div class="flex h-full items-center justify-center">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="h-3.5 w-3.5 rounded border-border/70 bg-background text-primary focus:ring-0"
|
||||||
|
:checked="booleanCellChecked(item.data[col.actualColIdx])"
|
||||||
|
:disabled="!canEditCellItem(item, col.actualColIdx)"
|
||||||
|
@mousedown.stop
|
||||||
|
@click.stop="cycleBooleanGridCell(item, col.actualColIdx, $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="booleanCellsUseCheckbox && isBooleanGridCell(item, col.actualColIdx) && item.data[col.actualColIdx] === null && canEditCellItem(item, col.actualColIdx)">
|
||||||
|
<span class="italic text-muted-foreground cursor-pointer select-none" @click.stop="cycleBooleanGridCell(item, col.actualColIdx, $event)">{{
|
||||||
|
firstLineCellDisplayValue(newRowCellPlaceholder(item, col.actualColIdx) ?? formatCellCached(item.data[col.actualColIdx], col.actualColIdx), flatteningMultiLineEnabled)
|
||||||
|
}}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<template v-if="newRowCellPlaceholder(item, col.actualColIdx)">
|
||||||
|
<span class="text-muted-foreground/70 italic">{{ firstLineCellDisplayValue(newRowCellPlaceholder(item, col.actualColIdx) ?? "", flatteningMultiLineEnabled) }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>{{ gridCellDisplayValue(formatGridItemCell(item, col.actualColIdx), flatteningMultiLineEnabled, showWhitespaceEnabled) }}</template>
|
||||||
|
<div v-if="cellDetailButtonVisible(item.displayIndex, col.actualColIdx)" class="absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1">
|
||||||
|
<LightDropdownMenu
|
||||||
|
v-if="canQuickDownloadCellValue(item.displayIndex, col.actualColIdx)"
|
||||||
|
:items="binaryCellDownloadMenuItems"
|
||||||
|
:open="quickDownloadMenuOpenFor(item.displayIndex, col.actualColIdx)"
|
||||||
|
align="end"
|
||||||
|
content-class="w-44"
|
||||||
|
:match-trigger-width="false"
|
||||||
|
@update:open="(value: boolean) => handleQuickDownloadMenuOpenChange(value, item.displayIndex, col.actualColIdx)"
|
||||||
|
@select="(mode: string) => downloadCellBinaryValue(item.displayIndex, col.actualColIdx, mode as BinaryCellDownloadMode)"
|
||||||
|
>
|
||||||
|
<template #trigger="{ open, toggle }">
|
||||||
|
<button class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground" :title="t('grid.downloadBinaryValue')" :aria-expanded="open" @mousedown.stop @click.stop="toggle">
|
||||||
|
<Download class="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</LightDropdownMenu>
|
||||||
|
<button
|
||||||
|
v-if="canOpenCellExternalUrl(item.displayIndex, col.actualColIdx)"
|
||||||
|
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
||||||
|
:title="t('grid.openUrl')"
|
||||||
|
:aria-label="t('grid.openUrl')"
|
||||||
|
@mousedown.stop
|
||||||
|
@click.stop="openCellExternalUrl(item.displayIndex, col.actualColIdx)"
|
||||||
|
>
|
||||||
|
<ExternalLink class="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="cellDetailButtonEnabled"
|
||||||
|
class="flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
|
||||||
|
:title="t('grid.cellDetails')"
|
||||||
|
@mousedown.stop
|
||||||
|
@click.stop="showCellDetailsForVisibleCell(item.displayIndex, col.visibleColIdx, col.actualColIdx)"
|
||||||
|
>
|
||||||
|
<Info class="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="shrink-0"
|
||||||
|
:style="{
|
||||||
|
width: `${horizontalColumnWindow.afterWidth}px`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</RecycleScroller>
|
||||||
|
<div v-if="domSelectionDragOverlayStyle" class="data-grid-selection-drag-overlay pointer-events-none absolute z-20" :style="domSelectionDragOverlayStyle" />
|
||||||
|
</div>
|
||||||
|
<!-- Infinite scroll loading indicator for RecycleScroller -->
|
||||||
|
<div v-if="infiniteScrollEnabled && infiniteScrollLoading && !gridSurfaceBusy" class="flex items-center justify-center py-2 text-xs text-muted-foreground">
|
||||||
|
<Loader2 class="w-3 h-3 animate-spin mr-1" />
|
||||||
|
{{ t("grid.loadingMore") }}
|
||||||
|
</div>
|
||||||
|
<div v-if="hasGridHorizontalOverflow" ref="gridHorizontalScrollbarTrackRef" class="data-grid-horizontal-scrollbar" @pointerdown="startGridHorizontalScrollbarDrag">
|
||||||
|
<div ref="gridHorizontalScrollbarThumbRef" class="data-grid-horizontal-scrollbar__thumb" />
|
||||||
|
</div>
|
||||||
|
<div v-if="hasGridVerticalOverflow" ref="gridVerticalScrollbarTrackRef" class="data-grid-vertical-scrollbar" @pointerdown="startGridVerticalScrollbarDrag">
|
||||||
|
<div ref="gridVerticalScrollbarThumbRef" class="data-grid-vertical-scrollbar__thumb" />
|
||||||
|
</div>
|
||||||
|
<div v-if="gridSurfaceBusy" class="absolute inset-0 z-20 flex items-center justify-center" :class="pageJumpProgress ? 'bg-background/35 backdrop-blur-[1px]' : 'bg-background/50'">
|
||||||
|
<DataGridBusyOverlay :elapsed-ms="loadingElapsed" :page-jump-progress="pageJumpProgress" :show-cancel="showCancel" :cancelling="cancelling" :cancel-disabled="cancelDisabled" @cancel="emit('cancel')" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
// Fixes #10095: the vertical/horizontal scrollbar overlays are absolutely
|
||||||
|
// positioned relative to the nearest ancestor with `position: relative`.
|
||||||
|
// Before this fix that ancestor was the grid's *outer* wrapper, which starts
|
||||||
|
// at the sticky column-header row — so `top: 10px` on the vertical scrollbar
|
||||||
|
// (and the horizontal scrollbar's `bottom: 0`) were measured from the header,
|
||||||
|
// landing the scrollbar visually on top of the header instead of below it.
|
||||||
|
const dataGridSource = readFileSync(new URL("../DataGrid.vue", import.meta.url), "utf8");
|
||||||
|
|
||||||
|
describe("DataGrid scrollbar positioning", () => {
|
||||||
|
it("wraps the header-less scroll body in its own relative stacking context", () => {
|
||||||
|
const headerEnd = dataGridSource.indexOf('<div v-if="gridScrollbarGutter > 0" class="shrink-0 border-l border-border w-(--grid-scrollbar-gutter)" />\n </div>\n </div>');
|
||||||
|
expect(headerEnd).toBeGreaterThanOrEqual(0);
|
||||||
|
|
||||||
|
const wrapperStart = dataGridSource.indexOf('<div class="relative min-h-0 flex-1 flex flex-col overflow-hidden">', headerEnd);
|
||||||
|
expect(wrapperStart).toBeGreaterThan(headerEnd);
|
||||||
|
|
||||||
|
// The vertical scrollbar (and its horizontal sibling) must be inside the
|
||||||
|
// new wrapper, not siblings of the header at the outer level. Anchor on
|
||||||
|
// the "Table Info Drawer" comment that follows the wrapper's own closing
|
||||||
|
// tags — an inner RecycleScroller slot's `</template>` closes earlier and
|
||||||
|
// is not a safe upper bound.
|
||||||
|
const verticalScrollbarIndex = dataGridSource.indexOf('ref="gridVerticalScrollbarTrackRef"', wrapperStart);
|
||||||
|
const drawerCommentIndex = dataGridSource.indexOf("<!-- Table Info Drawer -->", wrapperStart);
|
||||||
|
expect(verticalScrollbarIndex).toBeGreaterThan(wrapperStart);
|
||||||
|
expect(verticalScrollbarIndex).toBeLessThan(drawerCommentIndex);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("closes the wrapper before the sticky-header template ends, leaving markup balanced", () => {
|
||||||
|
const wrapperOpenCount = (dataGridSource.match(/<div class="relative min-h-0 flex-1 flex flex-col overflow-hidden">/g) || []).length;
|
||||||
|
expect(wrapperOpenCount).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user