@lensui/lens-table 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs +26 -18
- package/dist/index.css +12 -8
- package/dist/index.js +26 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -579,6 +579,7 @@ const columns: GridColumn<Row>[] = [
|
|
|
579
579
|
'--rvg-color-bg': '#0f172a',
|
|
580
580
|
'--rvg-color-text': '#e5e7eb',
|
|
581
581
|
'--rvg-color-grid': '#334155',
|
|
582
|
+
'--rvg-font-size-body': '12px',
|
|
582
583
|
} as React.CSSProperties}
|
|
583
584
|
/>
|
|
584
585
|
```
|
|
@@ -587,6 +588,7 @@ const columns: GridColumn<Row>[] = [
|
|
|
587
588
|
|
|
588
589
|
| 变量 | 说明 |
|
|
589
590
|
| ----------------------------------- | ---------------------------------------------------------------------------------- |
|
|
591
|
+
| `--rvg-font-size-body` | 数据正文及单元格编辑器字号,默认 `13px`;不影响表头字号。 |
|
|
590
592
|
| `--rvg-color-bg` | 表格背景色。 |
|
|
591
593
|
| `--rvg-color-header-bg` | 表头背景色。 |
|
|
592
594
|
| `--rvg-color-text` | 主文本颜色。 |
|
package/dist/index.cjs
CHANGED
|
@@ -692,18 +692,6 @@ function DateEditor({ editor, value: draft, style, locale, labels, onChange, onC
|
|
|
692
692
|
);
|
|
693
693
|
}
|
|
694
694
|
|
|
695
|
-
// src/core/typography.ts
|
|
696
|
-
var CELL_FONT = "13px Inter, ui-sans-serif, system-ui, sans-serif";
|
|
697
|
-
function getCellBaselineOffset(context) {
|
|
698
|
-
context.save();
|
|
699
|
-
context.textBaseline = "alphabetic";
|
|
700
|
-
const metrics = context.measureText("Mg");
|
|
701
|
-
context.restore();
|
|
702
|
-
const ascent = metrics.fontBoundingBoxAscent;
|
|
703
|
-
const descent = metrics.fontBoundingBoxDescent;
|
|
704
|
-
return Number.isFinite(ascent) && Number.isFinite(descent) ? (ascent - descent) / 2 : 0;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
695
|
// src/components/editors/TextEditor.tsx
|
|
708
696
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
709
697
|
function TextEditor({ value, type, style, labels, onChange, onCommit, onCancel }) {
|
|
@@ -717,7 +705,7 @@ function TextEditor({ value, type, style, labels, onChange, onCommit, onCancel }
|
|
|
717
705
|
"input",
|
|
718
706
|
{
|
|
719
707
|
type,
|
|
720
|
-
style: { font:
|
|
708
|
+
style: { font: "var(--rvg-font-size-body) Inter, ui-sans-serif, system-ui, sans-serif", textAlign: style.textAlign },
|
|
721
709
|
value,
|
|
722
710
|
autoFocus: true,
|
|
723
711
|
onChange: (event) => onChange(event.target.value),
|
|
@@ -906,6 +894,18 @@ function hitTestColumn(metrics, contentX) {
|
|
|
906
894
|
return index < metrics.length ? index : -1;
|
|
907
895
|
}
|
|
908
896
|
|
|
897
|
+
// src/core/typography.ts
|
|
898
|
+
var createCellFont = (fontSize = 13) => `${fontSize}px Inter, ui-sans-serif, system-ui, sans-serif`;
|
|
899
|
+
function getCellBaselineOffset(context) {
|
|
900
|
+
context.save();
|
|
901
|
+
context.textBaseline = "alphabetic";
|
|
902
|
+
const metrics = context.measureText("Mg");
|
|
903
|
+
context.restore();
|
|
904
|
+
const ascent = metrics.fontBoundingBoxAscent;
|
|
905
|
+
const descent = metrics.fontBoundingBoxDescent;
|
|
906
|
+
return Number.isFinite(ascent) && Number.isFinite(descent) ? (ascent - descent) / 2 : 0;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
909
|
// src/core/render.ts
|
|
910
910
|
var getCellCoordKey = (rowIndex, columnIndex) => `${rowIndex}:${columnIndex}`;
|
|
911
911
|
var COLORS = {
|
|
@@ -942,7 +942,7 @@ function ellipsizeText(context, text, maxWidth) {
|
|
|
942
942
|
return `${text.slice(0, start)}${ellipsis}`;
|
|
943
943
|
}
|
|
944
944
|
function paintGrid(options) {
|
|
945
|
-
const { context: ctx, width, height, pixelRatio, scrollLeft, scrollTop, rowHeight, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, striped, columnDraggable, sortState, filterValues, hoveredHeaderAction, rows, columns, metrics, range, selection, editing, hoveredRowIndex, selectionRange, selectedRowKeys, rowSelectionMode, selectedColumnKeys, highlightEditedCells, highlightInsertedRows, insertedRowKeys, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget } = options;
|
|
945
|
+
const { context: ctx, width, height, pixelRatio, scrollLeft, scrollTop, rowHeight, bodyFontSize, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, striped, columnDraggable, sortState, filterValues, hoveredHeaderAction, rows, columns, metrics, range, selection, editing, hoveredRowIndex, selectionRange, selectedRowKeys, rowSelectionMode, selectedColumnKeys, highlightEditedCells, highlightInsertedRows, insertedRowKeys, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget } = options;
|
|
946
946
|
const headerLeafTop = options.headerLeafTop ?? 0;
|
|
947
947
|
const headerLeafHeight = options.headerLeafHeight ?? headerHeight;
|
|
948
948
|
const colors = { ...COLORS, ...options.colors };
|
|
@@ -959,7 +959,7 @@ function paintGrid(options) {
|
|
|
959
959
|
ctx.clearRect(0, 0, width, height);
|
|
960
960
|
ctx.fillStyle = colors.background;
|
|
961
961
|
ctx.fillRect(0, 0, width, height);
|
|
962
|
-
ctx.font =
|
|
962
|
+
ctx.font = createCellFont(bodyFontSize);
|
|
963
963
|
const cellBaselineOffset = getCellBaselineOffset(ctx);
|
|
964
964
|
ctx.textBaseline = "middle";
|
|
965
965
|
const leftFixedWidth = columns.reduce((value, column, index) => column.fixed === "left" ? value + metrics[index].width : value, 0);
|
|
@@ -1159,7 +1159,7 @@ function paintGrid(options) {
|
|
|
1159
1159
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1160
1160
|
ctx.clip();
|
|
1161
1161
|
ctx.fillStyle = cellStyle?.color ?? colors.text;
|
|
1162
|
-
ctx.font =
|
|
1162
|
+
ctx.font = createCellFont(bodyFontSize);
|
|
1163
1163
|
ctx.textBaseline = "alphabetic";
|
|
1164
1164
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
1165
1165
|
ctx.fillText(label, textX, y + cellHeight / 2 + cellBaselineOffset);
|
|
@@ -1468,6 +1468,10 @@ var waitForPaint = () => new Promise((resolve) => {
|
|
|
1468
1468
|
function readThemeColor(styles, name, fallback) {
|
|
1469
1469
|
return styles.getPropertyValue(name).trim() || fallback;
|
|
1470
1470
|
}
|
|
1471
|
+
function readThemePixel(styles, name, fallback) {
|
|
1472
|
+
const value = Number.parseFloat(styles.getPropertyValue(name));
|
|
1473
|
+
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
1474
|
+
}
|
|
1471
1475
|
function getDefaultRowKey(row, index) {
|
|
1472
1476
|
const id = row.id;
|
|
1473
1477
|
return typeof id === "string" || typeof id === "number" ? id : index;
|
|
@@ -2212,6 +2216,7 @@ function TableInner({
|
|
|
2212
2216
|
const context = canvas.getContext("2d");
|
|
2213
2217
|
if (!context) return;
|
|
2214
2218
|
const themeStyles = getComputedStyle(canvas);
|
|
2219
|
+
const bodyFontSize = readThemePixel(themeStyles, "--rvg-font-size-body", 13);
|
|
2215
2220
|
const themeColors = {
|
|
2216
2221
|
background: readThemeColor(themeStyles, "--rvg-color-bg", "#ffffff"),
|
|
2217
2222
|
header: readThemeColor(themeStyles, "--rvg-color-header-bg", "#f5f6f7"),
|
|
@@ -2232,7 +2237,7 @@ function TableInner({
|
|
|
2232
2237
|
const scroll = scrollRef.current;
|
|
2233
2238
|
const rowScrollTop = fixedHeader ? scroll.top : Math.max(0, scroll.top - bodyTop);
|
|
2234
2239
|
const range = isVirtualized ? getViewportRange(scroll.left, rowScrollTop, viewport.width, bodyViewportHeight, rows.length, rowHeight, metrics, virtualOverscan) : { rowStart: 0, rowEnd: rows.length, columnStart: 0, columnEnd: columns.length };
|
|
2235
|
-
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, striped: hasStripedRows, columnDraggable, sortState, filterValues, hoveredHeaderAction: hoveredHeaderActionRef.current, rows, columns, metrics, range, selection, editing, hoveredRowIndex: hoveredRowIndexRef.current, selectionRange, selectedRowKeys: selectedRowKeySet, rowSelectionMode, selectedColumnKeys: selectedColumnKeySet, cellSpans: cellSpanLookup.covered, maxRowSpan: cellSpanLookup.maxRowSpan, highlightEditedCells: highlightsEditedCells, highlightInsertedRows: highlightsInsertedRows, insertedRowKeys: insertedRowKeySet, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget, colors: themeColors });
|
|
2240
|
+
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, bodyFontSize, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, striped: hasStripedRows, columnDraggable, sortState, filterValues, hoveredHeaderAction: hoveredHeaderActionRef.current, rows, columns, metrics, range, selection, editing, hoveredRowIndex: hoveredRowIndexRef.current, selectionRange, selectedRowKeys: selectedRowKeySet, rowSelectionMode, selectedColumnKeys: selectedColumnKeySet, cellSpans: cellSpanLookup.covered, maxRowSpan: cellSpanLookup.maxRowSpan, highlightEditedCells: highlightsEditedCells, highlightInsertedRows: highlightsInsertedRows, insertedRowKeys: insertedRowKeySet, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget, colors: themeColors });
|
|
2236
2241
|
}, [bodyTop, bodyViewportHeight, bottomSummaryHeight, cellAnnotations, cellSpanLookup, columnDraggable, columnDropTarget, columns, editedCellHighlightColor, editedCellKeys, editing, renderHeight, filterValues, fixedHeader, getRowKey, hasStripedRows, hasVerticalBorders, headerDepth, headerHeight, headerLeafHeight, headerLeafTop, horizontalBorderless, highlightsEditedCells, highlightsInsertedRows, insertedRowHighlightColor, insertedRowKeySet, isVirtualized, metrics, rowDragPreview, rowHeight, rowSelectionMode, rows, selectedColumnKeySet, selectedRowKeySet, selection, selectionRange, sortState, stripedColor, viewport.width, virtualOverscan]);
|
|
2237
2242
|
const scheduleDraw = (0, import_react5.useCallback)(() => {
|
|
2238
2243
|
if (frameRef.current === null) frameRef.current = requestAnimationFrame(draw);
|
|
@@ -4547,7 +4552,10 @@ function TableInner({
|
|
|
4547
4552
|
} else {
|
|
4548
4553
|
const label = getCellLabel(cell.rowIndex, cell.columnIndex);
|
|
4549
4554
|
const context = event.currentTarget.getContext("2d");
|
|
4550
|
-
if (context)
|
|
4555
|
+
if (context) {
|
|
4556
|
+
const bodyFontSize = readThemePixel(getComputedStyle(event.currentTarget), "--rvg-font-size-body", 13);
|
|
4557
|
+
context.font = `${bodyFontSize}px Inter, ui-sans-serif, system-ui, sans-serif`;
|
|
4558
|
+
}
|
|
4551
4559
|
const truncated = Boolean(label && context && context.measureText(label).width + 20 > metrics[cell.columnIndex].width);
|
|
4552
4560
|
if (!label || !tooltipConfig.cell && !truncated) {
|
|
4553
4561
|
showCellTooltipAfterDelay(null);
|
package/dist/index.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* src/style.css */
|
|
2
2
|
:root {
|
|
3
|
+
--rvg-font-size-body: 13px;
|
|
3
4
|
--rvg-color-bg: #fff;
|
|
4
5
|
--rvg-color-header-bg: #f5f6f7;
|
|
5
6
|
--rvg-color-grid: #e3e6e8;
|
|
@@ -205,11 +206,12 @@
|
|
|
205
206
|
padding: 0 10px;
|
|
206
207
|
overflow: hidden;
|
|
207
208
|
color: var(--rvg-color-text);
|
|
208
|
-
font:
|
|
209
|
-
|
|
209
|
+
font-family:
|
|
210
|
+
Inter,
|
|
210
211
|
ui-sans-serif,
|
|
211
212
|
system-ui,
|
|
212
213
|
sans-serif;
|
|
214
|
+
font-size: 13px;
|
|
213
215
|
white-space: nowrap;
|
|
214
216
|
user-select: text;
|
|
215
217
|
pointer-events: auto;
|
|
@@ -220,6 +222,7 @@
|
|
|
220
222
|
cursor: default;
|
|
221
223
|
}
|
|
222
224
|
.rvg-cell-text {
|
|
225
|
+
font-size: var(--rvg-font-size-body);
|
|
223
226
|
transition: transform 140ms ease, opacity 100ms ease;
|
|
224
227
|
}
|
|
225
228
|
.rvg-row-drop-settling .rvg-cell-text {
|
|
@@ -251,11 +254,12 @@
|
|
|
251
254
|
align-items: center;
|
|
252
255
|
overflow: hidden;
|
|
253
256
|
color: var(--rvg-color-text);
|
|
254
|
-
font:
|
|
255
|
-
|
|
257
|
+
font-family:
|
|
258
|
+
Inter,
|
|
256
259
|
ui-sans-serif,
|
|
257
260
|
system-ui,
|
|
258
261
|
sans-serif;
|
|
262
|
+
font-size: var(--rvg-font-size-body);
|
|
259
263
|
white-space: nowrap;
|
|
260
264
|
pointer-events: none;
|
|
261
265
|
box-sizing: border-box;
|
|
@@ -1587,7 +1591,7 @@
|
|
|
1587
1591
|
background: var(--rvg-color-bg);
|
|
1588
1592
|
color: var(--rvg-color-text);
|
|
1589
1593
|
font:
|
|
1590
|
-
|
|
1594
|
+
var(--rvg-font-size-body) Inter,
|
|
1591
1595
|
ui-sans-serif,
|
|
1592
1596
|
system-ui,
|
|
1593
1597
|
sans-serif;
|
|
@@ -1635,7 +1639,7 @@
|
|
|
1635
1639
|
background: transparent;
|
|
1636
1640
|
color: var(--rvg-color-text);
|
|
1637
1641
|
font:
|
|
1638
|
-
|
|
1642
|
+
var(--rvg-font-size-body) Inter,
|
|
1639
1643
|
ui-sans-serif,
|
|
1640
1644
|
system-ui,
|
|
1641
1645
|
sans-serif;
|
|
@@ -1670,7 +1674,7 @@
|
|
|
1670
1674
|
background: transparent;
|
|
1671
1675
|
color: var(--rvg-color-text);
|
|
1672
1676
|
font:
|
|
1673
|
-
|
|
1677
|
+
var(--rvg-font-size-body) Inter,
|
|
1674
1678
|
ui-sans-serif,
|
|
1675
1679
|
system-ui,
|
|
1676
1680
|
sans-serif;
|
|
@@ -1903,7 +1907,7 @@
|
|
|
1903
1907
|
background: var(--rvg-color-bg);
|
|
1904
1908
|
color: var(--rvg-color-text);
|
|
1905
1909
|
font:
|
|
1906
|
-
|
|
1910
|
+
var(--rvg-font-size-body) Inter,
|
|
1907
1911
|
ui-sans-serif,
|
|
1908
1912
|
system-ui,
|
|
1909
1913
|
sans-serif;
|
package/dist/index.js
CHANGED
|
@@ -662,18 +662,6 @@ function DateEditor({ editor, value: draft, style, locale, labels, onChange, onC
|
|
|
662
662
|
);
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
-
// src/core/typography.ts
|
|
666
|
-
var CELL_FONT = "13px Inter, ui-sans-serif, system-ui, sans-serif";
|
|
667
|
-
function getCellBaselineOffset(context) {
|
|
668
|
-
context.save();
|
|
669
|
-
context.textBaseline = "alphabetic";
|
|
670
|
-
const metrics = context.measureText("Mg");
|
|
671
|
-
context.restore();
|
|
672
|
-
const ascent = metrics.fontBoundingBoxAscent;
|
|
673
|
-
const descent = metrics.fontBoundingBoxDescent;
|
|
674
|
-
return Number.isFinite(ascent) && Number.isFinite(descent) ? (ascent - descent) / 2 : 0;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
665
|
// src/components/editors/TextEditor.tsx
|
|
678
666
|
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
679
667
|
function TextEditor({ value, type, style, labels, onChange, onCommit, onCancel }) {
|
|
@@ -687,7 +675,7 @@ function TextEditor({ value, type, style, labels, onChange, onCommit, onCancel }
|
|
|
687
675
|
"input",
|
|
688
676
|
{
|
|
689
677
|
type,
|
|
690
|
-
style: { font:
|
|
678
|
+
style: { font: "var(--rvg-font-size-body) Inter, ui-sans-serif, system-ui, sans-serif", textAlign: style.textAlign },
|
|
691
679
|
value,
|
|
692
680
|
autoFocus: true,
|
|
693
681
|
onChange: (event) => onChange(event.target.value),
|
|
@@ -876,6 +864,18 @@ function hitTestColumn(metrics, contentX) {
|
|
|
876
864
|
return index < metrics.length ? index : -1;
|
|
877
865
|
}
|
|
878
866
|
|
|
867
|
+
// src/core/typography.ts
|
|
868
|
+
var createCellFont = (fontSize = 13) => `${fontSize}px Inter, ui-sans-serif, system-ui, sans-serif`;
|
|
869
|
+
function getCellBaselineOffset(context) {
|
|
870
|
+
context.save();
|
|
871
|
+
context.textBaseline = "alphabetic";
|
|
872
|
+
const metrics = context.measureText("Mg");
|
|
873
|
+
context.restore();
|
|
874
|
+
const ascent = metrics.fontBoundingBoxAscent;
|
|
875
|
+
const descent = metrics.fontBoundingBoxDescent;
|
|
876
|
+
return Number.isFinite(ascent) && Number.isFinite(descent) ? (ascent - descent) / 2 : 0;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
879
|
// src/core/render.ts
|
|
880
880
|
var getCellCoordKey = (rowIndex, columnIndex) => `${rowIndex}:${columnIndex}`;
|
|
881
881
|
var COLORS = {
|
|
@@ -912,7 +912,7 @@ function ellipsizeText(context, text, maxWidth) {
|
|
|
912
912
|
return `${text.slice(0, start)}${ellipsis}`;
|
|
913
913
|
}
|
|
914
914
|
function paintGrid(options) {
|
|
915
|
-
const { context: ctx, width, height, pixelRatio, scrollLeft, scrollTop, rowHeight, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, striped, columnDraggable, sortState, filterValues, hoveredHeaderAction, rows, columns, metrics, range, selection, editing, hoveredRowIndex, selectionRange, selectedRowKeys, rowSelectionMode, selectedColumnKeys, highlightEditedCells, highlightInsertedRows, insertedRowKeys, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget } = options;
|
|
915
|
+
const { context: ctx, width, height, pixelRatio, scrollLeft, scrollTop, rowHeight, bodyFontSize, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, striped, columnDraggable, sortState, filterValues, hoveredHeaderAction, rows, columns, metrics, range, selection, editing, hoveredRowIndex, selectionRange, selectedRowKeys, rowSelectionMode, selectedColumnKeys, highlightEditedCells, highlightInsertedRows, insertedRowKeys, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget } = options;
|
|
916
916
|
const headerLeafTop = options.headerLeafTop ?? 0;
|
|
917
917
|
const headerLeafHeight = options.headerLeafHeight ?? headerHeight;
|
|
918
918
|
const colors = { ...COLORS, ...options.colors };
|
|
@@ -929,7 +929,7 @@ function paintGrid(options) {
|
|
|
929
929
|
ctx.clearRect(0, 0, width, height);
|
|
930
930
|
ctx.fillStyle = colors.background;
|
|
931
931
|
ctx.fillRect(0, 0, width, height);
|
|
932
|
-
ctx.font =
|
|
932
|
+
ctx.font = createCellFont(bodyFontSize);
|
|
933
933
|
const cellBaselineOffset = getCellBaselineOffset(ctx);
|
|
934
934
|
ctx.textBaseline = "middle";
|
|
935
935
|
const leftFixedWidth = columns.reduce((value, column, index) => column.fixed === "left" ? value + metrics[index].width : value, 0);
|
|
@@ -1129,7 +1129,7 @@ function paintGrid(options) {
|
|
|
1129
1129
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1130
1130
|
ctx.clip();
|
|
1131
1131
|
ctx.fillStyle = cellStyle?.color ?? colors.text;
|
|
1132
|
-
ctx.font =
|
|
1132
|
+
ctx.font = createCellFont(bodyFontSize);
|
|
1133
1133
|
ctx.textBaseline = "alphabetic";
|
|
1134
1134
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
1135
1135
|
ctx.fillText(label, textX, y + cellHeight / 2 + cellBaselineOffset);
|
|
@@ -1438,6 +1438,10 @@ var waitForPaint = () => new Promise((resolve) => {
|
|
|
1438
1438
|
function readThemeColor(styles, name, fallback) {
|
|
1439
1439
|
return styles.getPropertyValue(name).trim() || fallback;
|
|
1440
1440
|
}
|
|
1441
|
+
function readThemePixel(styles, name, fallback) {
|
|
1442
|
+
const value = Number.parseFloat(styles.getPropertyValue(name));
|
|
1443
|
+
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
1444
|
+
}
|
|
1441
1445
|
function getDefaultRowKey(row, index) {
|
|
1442
1446
|
const id = row.id;
|
|
1443
1447
|
return typeof id === "string" || typeof id === "number" ? id : index;
|
|
@@ -2182,6 +2186,7 @@ function TableInner({
|
|
|
2182
2186
|
const context = canvas.getContext("2d");
|
|
2183
2187
|
if (!context) return;
|
|
2184
2188
|
const themeStyles = getComputedStyle(canvas);
|
|
2189
|
+
const bodyFontSize = readThemePixel(themeStyles, "--rvg-font-size-body", 13);
|
|
2185
2190
|
const themeColors = {
|
|
2186
2191
|
background: readThemeColor(themeStyles, "--rvg-color-bg", "#ffffff"),
|
|
2187
2192
|
header: readThemeColor(themeStyles, "--rvg-color-header-bg", "#f5f6f7"),
|
|
@@ -2202,7 +2207,7 @@ function TableInner({
|
|
|
2202
2207
|
const scroll = scrollRef.current;
|
|
2203
2208
|
const rowScrollTop = fixedHeader ? scroll.top : Math.max(0, scroll.top - bodyTop);
|
|
2204
2209
|
const range = isVirtualized ? getViewportRange(scroll.left, rowScrollTop, viewport.width, bodyViewportHeight, rows.length, rowHeight, metrics, virtualOverscan) : { rowStart: 0, rowEnd: rows.length, columnStart: 0, columnEnd: columns.length };
|
|
2205
|
-
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, striped: hasStripedRows, columnDraggable, sortState, filterValues, hoveredHeaderAction: hoveredHeaderActionRef.current, rows, columns, metrics, range, selection, editing, hoveredRowIndex: hoveredRowIndexRef.current, selectionRange, selectedRowKeys: selectedRowKeySet, rowSelectionMode, selectedColumnKeys: selectedColumnKeySet, cellSpans: cellSpanLookup.covered, maxRowSpan: cellSpanLookup.maxRowSpan, highlightEditedCells: highlightsEditedCells, highlightInsertedRows: highlightsInsertedRows, insertedRowKeys: insertedRowKeySet, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget, colors: themeColors });
|
|
2210
|
+
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, bodyFontSize, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, striped: hasStripedRows, columnDraggable, sortState, filterValues, hoveredHeaderAction: hoveredHeaderActionRef.current, rows, columns, metrics, range, selection, editing, hoveredRowIndex: hoveredRowIndexRef.current, selectionRange, selectedRowKeys: selectedRowKeySet, rowSelectionMode, selectedColumnKeys: selectedColumnKeySet, cellSpans: cellSpanLookup.covered, maxRowSpan: cellSpanLookup.maxRowSpan, highlightEditedCells: highlightsEditedCells, highlightInsertedRows: highlightsInsertedRows, insertedRowKeys: insertedRowKeySet, editedCellKeys, cellAnnotations, getRowKey, rowDragPreview, columnDropTarget, colors: themeColors });
|
|
2206
2211
|
}, [bodyTop, bodyViewportHeight, bottomSummaryHeight, cellAnnotations, cellSpanLookup, columnDraggable, columnDropTarget, columns, editedCellHighlightColor, editedCellKeys, editing, renderHeight, filterValues, fixedHeader, getRowKey, hasStripedRows, hasVerticalBorders, headerDepth, headerHeight, headerLeafHeight, headerLeafTop, horizontalBorderless, highlightsEditedCells, highlightsInsertedRows, insertedRowHighlightColor, insertedRowKeySet, isVirtualized, metrics, rowDragPreview, rowHeight, rowSelectionMode, rows, selectedColumnKeySet, selectedRowKeySet, selection, selectionRange, sortState, stripedColor, viewport.width, virtualOverscan]);
|
|
2207
2212
|
const scheduleDraw = useCallback2(() => {
|
|
2208
2213
|
if (frameRef.current === null) frameRef.current = requestAnimationFrame(draw);
|
|
@@ -4517,7 +4522,10 @@ function TableInner({
|
|
|
4517
4522
|
} else {
|
|
4518
4523
|
const label = getCellLabel(cell.rowIndex, cell.columnIndex);
|
|
4519
4524
|
const context = event.currentTarget.getContext("2d");
|
|
4520
|
-
if (context)
|
|
4525
|
+
if (context) {
|
|
4526
|
+
const bodyFontSize = readThemePixel(getComputedStyle(event.currentTarget), "--rvg-font-size-body", 13);
|
|
4527
|
+
context.font = `${bodyFontSize}px Inter, ui-sans-serif, system-ui, sans-serif`;
|
|
4528
|
+
}
|
|
4521
4529
|
const truncated = Boolean(label && context && context.measureText(label).width + 20 > metrics[cell.columnIndex].width);
|
|
4522
4530
|
if (!label || !tooltipConfig.cell && !truncated) {
|
|
4523
4531
|
showCellTooltipAfterDelay(null);
|