feat(grid): enable canvas renderer by default

This commit is contained in:
t8y2 committed 2026-06-02 21:40:51 +08:00
1 parent 06a862c539
commit 38f25d8629
7 files changed
+27 -16

No files matched your search

@@ -280,9 +280,10 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
const rowSelectionVisual = rowCellsUseSelectionVisual(item.id);
const isSingleSelectedCell =
singleSelectedCell?.rowIndex === item.displayIndex && singleSelectedCell.visibleColIdx === visibleColIdx;
const selectedFillVisual = rowSelectionVisual || (selectedCell && !isSingleSelectedCell);
const selectedBorderVisual = rowSelectionVisual || selectedCell;
const isDirtyCell = item.isDirtyCol[actualColIdx];
const selectedFillVisual =
rowSelectionVisual || (selectedCell && !isSingleSelectedCell && (!rowIsActive || isDirtyCell));
const selectedBorderVisual = rowSelectionVisual || selectedCell;
const isSearchMatch = paintSearchMatches && searchMatchKeys.has(`${item.displayIndex}:${actualColIdx}`);
const isCurrentSearchMatch =
paintSearchMatches &&
@@ -363,12 +364,10 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
const selectedBottomY = y + CANVAS_DATA_GRID_ROW_HEIGHT - 1.5;
ctx.strokeStyle = theme.cellSelectedBorder;
ctx.beginPath();
if (!rowSelectionVisual) {
ctx.moveTo(selectedLeftX, selectedTopY);
ctx.lineTo(selectedRightX, selectedTopY);
ctx.moveTo(selectedLeftX, selectedBottomY);
ctx.lineTo(selectedRightX, selectedBottomY);
}
ctx.moveTo(selectedLeftX, selectedTopY);
ctx.lineTo(selectedRightX, selectedTopY);
ctx.moveTo(selectedLeftX, selectedBottomY);
ctx.lineTo(selectedRightX, selectedBottomY);
ctx.moveTo(selectedLeftX, selectedTopY);
ctx.lineTo(selectedLeftX, selectedBottomY);
ctx.moveTo(selectedRightX, selectedTopY);
+15 -3
View File
@@ -40,10 +40,22 @@ export function cssVarColor(getVar: (name: string) => string, name: string, fall
return value.startsWith("#") || /^(rgb|hsl|oklch|oklab|lab|lch|color-mix)\(/.test(value) ? value : `hsl(${value})`;
}
function resolveCssVarReferences(value: string, getVar: (name: string) => string, depth = 0): string {
if (depth > 6 || !value.includes("var(")) return value;
return value.replace(/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/g, (_match, name: string, fallback?: string) => {
const resolved = getVar(name).trim() || fallback?.trim() || "";
if (!resolved) return "";
const nested = resolveCssVarReferences(resolved, getVar, depth + 1);
return cssVarColor(() => nested, name, nested);
});
}
function paintToken(getVar: (name: string) => string, name: string, fallback: string): string {
const value = getVar(name).trim();
if (!value || value.includes("var(")) return fallback;
return cssVarColor(getVar, name, fallback);
const value = resolveCssVarReferences(getVar(name).trim(), getVar);
if (!value) return fallback;
return value.startsWith("#") || /^(rgb|hsl|oklch|oklab|lab|lch|color-mix)\(/.test(value)
? value
: cssVarColor(() => value, name, fallback);
}
export function resolveDataGridPaintTheme(options: {