@lensui/lens-table 0.1.14 → 0.1.16
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 -1
- package/dist/index.cjs +32 -11
- package/dist/index.css +4 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +32 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ export function Example() {
|
|
|
111
111
|
| `defaultSelectedCell` | `GridSelectionTarget \| null` | `null` | 默认选中单元格。传 `columnKey`,行可使用 `rowKey` 或 `rowIndex` 定位。 |
|
|
112
112
|
| `onSelectedCellChange` | `(selection) => void` | - | 单元格选中变化回调,`selection.value` 为当前单元格的原始值。 |
|
|
113
113
|
| `rangeSelection` | `boolean` | `false` | 是否允许鼠标拖动选择多个单元格。开启后支持范围复制、范围右键菜单和右下角拖拽扩展范围。 |
|
|
114
|
-
| `rowSelection` | `boolean \| RowSelectionConfig` | `false` |
|
|
114
|
+
| `rowSelection` | `boolean \| RowSelectionConfig` | `false` | 开启行选择。支持 `mode`、`showCheckbox`、`indicator: 'checkbox' \| 'arrow'` 和 `columnWidth`;箭头样式未选中时为空白。默认自动生成左侧选择列。 |
|
|
115
115
|
| `selectedRowKeys` | `GridKey[]` | 非受控 | 受控行选择 key 列表。 |
|
|
116
116
|
| `defaultSelectedRowKeys` | `GridKey[]` | `[]` | 非受控模式下默认选中的行 key。 |
|
|
117
117
|
| `onSelectedRowChange` | `(keys, rows, indices) => void` | - | 行选择变化回调。 |
|
|
@@ -600,6 +600,7 @@ const columns: GridColumn<Row>[] = [
|
|
|
600
600
|
| `--rvg-color-primary` | 选中、按钮、焦点等强调色。 |
|
|
601
601
|
| `--rvg-color-selection-fill` | 单元格选中背景。 |
|
|
602
602
|
| `--rvg-color-axis-selection-fill` | 行/列选中背景。 |
|
|
603
|
+
| `--rvg-color-axis-selection-text` | 行/列选中后的正文和选择标记颜色,默认继承主文本色。 |
|
|
603
604
|
| `--rvg-color-edited-fill` | 已编辑单元格背景。 |
|
|
604
605
|
| `--rvg-color-stripe` | `striped={true}` 时的斑马纹背景。也可以直接通过 `striped="#f6faff"` 单独指定。 |
|
|
605
606
|
|
package/dist/index.cjs
CHANGED
|
@@ -834,7 +834,8 @@ function getVisibleHeaderActions(column, width, columnDraggable = false, titleWi
|
|
|
834
834
|
}
|
|
835
835
|
function getMinimumColumnWidth(column, columnDraggable = false) {
|
|
836
836
|
if (column.rowDragHandle) return 36;
|
|
837
|
-
if (column.rowSelection
|
|
837
|
+
if (column.rowSelection) return Math.max(24, column.width ?? 44);
|
|
838
|
+
if (column.rowNumber) return 44;
|
|
838
839
|
return 60;
|
|
839
840
|
}
|
|
840
841
|
function buildColumnMetrics(columns, columnDraggableOrOptions = false) {
|
|
@@ -919,6 +920,7 @@ var COLORS = {
|
|
|
919
920
|
selection: "#1677ff",
|
|
920
921
|
selectionFill: "#edf4ff",
|
|
921
922
|
axisSelectionFill: "#e8f2ff",
|
|
923
|
+
axisSelectionText: "#202124",
|
|
922
924
|
rowHoverFill: "#f6f9fc",
|
|
923
925
|
editedFill: "#fff1b8",
|
|
924
926
|
insertedFill: "#c8ead4",
|
|
@@ -1017,6 +1019,7 @@ function paintGrid(options) {
|
|
|
1017
1019
|
const colSpan = span?.colSpan ?? 1;
|
|
1018
1020
|
const cellWidth = getCellWidth(columnIndex, colSpan);
|
|
1019
1021
|
const cellHeight = rowHeight * rowSpan;
|
|
1022
|
+
const isAxisSelected = selectedRowKeys.has(rowKey) || selectedColumnKeys.has(column.key);
|
|
1020
1023
|
const rangeRowStart = selectionRange ? Math.min(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
1021
1024
|
const rangeRowEnd = selectionRange ? Math.max(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
1022
1025
|
const rangeColumnStart = selectionRange ? Math.min(selectionRange.anchor.columnIndex, selectionRange.focus.columnIndex) : -1;
|
|
@@ -1026,7 +1029,7 @@ function paintGrid(options) {
|
|
|
1026
1029
|
ctx.fillStyle = striped && rowIndex % 2 === 1 ? colors.stripe : colors.background;
|
|
1027
1030
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1028
1031
|
}
|
|
1029
|
-
if (
|
|
1032
|
+
if (isAxisSelected) {
|
|
1030
1033
|
ctx.fillStyle = colors.axisSelectionFill;
|
|
1031
1034
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1032
1035
|
}
|
|
@@ -1071,14 +1074,14 @@ function paintGrid(options) {
|
|
|
1071
1074
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1072
1075
|
}
|
|
1073
1076
|
if (rowSpan > 1) {
|
|
1074
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill :
|
|
1077
|
+
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1075
1078
|
ctx.fillStyle = mergedFill;
|
|
1076
1079
|
for (let offset = 1; offset < rowSpan; offset += 1) {
|
|
1077
1080
|
ctx.fillRect(x, y + offset * rowHeight - 1, cellWidth, 2);
|
|
1078
1081
|
}
|
|
1079
1082
|
}
|
|
1080
1083
|
if (colSpan > 1 && !verticalBorderless) {
|
|
1081
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill :
|
|
1084
|
+
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1082
1085
|
ctx.fillStyle = mergedFill;
|
|
1083
1086
|
let offsetLeft = 0;
|
|
1084
1087
|
for (let offset = 1; offset < colSpan; offset += 1) {
|
|
@@ -1112,7 +1115,21 @@ function paintGrid(options) {
|
|
|
1112
1115
|
const checked = selectedRowKeys.has(rowKey);
|
|
1113
1116
|
ctx.save();
|
|
1114
1117
|
ctx.lineWidth = 1;
|
|
1115
|
-
if (
|
|
1118
|
+
if (column.rowSelectionIndicator === "arrow") {
|
|
1119
|
+
if (checked) {
|
|
1120
|
+
ctx.beginPath();
|
|
1121
|
+
ctx.moveTo(iconLeft + 3.5, iconTop + 8);
|
|
1122
|
+
ctx.lineTo(iconLeft + 12.5, iconTop + 8);
|
|
1123
|
+
ctx.moveTo(iconLeft + 8.5, iconTop + 4);
|
|
1124
|
+
ctx.lineTo(iconLeft + 12.5, iconTop + 8);
|
|
1125
|
+
ctx.lineTo(iconLeft + 8.5, iconTop + 12);
|
|
1126
|
+
ctx.strokeStyle = colors.axisSelectionText;
|
|
1127
|
+
ctx.lineWidth = 1.75;
|
|
1128
|
+
ctx.lineCap = "round";
|
|
1129
|
+
ctx.lineJoin = "round";
|
|
1130
|
+
ctx.stroke();
|
|
1131
|
+
}
|
|
1132
|
+
} else if (rowSelectionMode === "single") {
|
|
1116
1133
|
ctx.beginPath();
|
|
1117
1134
|
ctx.arc(iconLeft + 8, iconTop + 8, 6.25, 0, Math.PI * 2);
|
|
1118
1135
|
ctx.fillStyle = colors.background;
|
|
@@ -1160,7 +1177,7 @@ function paintGrid(options) {
|
|
|
1160
1177
|
ctx.beginPath();
|
|
1161
1178
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1162
1179
|
ctx.clip();
|
|
1163
|
-
ctx.fillStyle =
|
|
1180
|
+
ctx.fillStyle = isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? colors.text;
|
|
1164
1181
|
ctx.font = createCellFont(bodyFontSize);
|
|
1165
1182
|
ctx.textBaseline = "alphabetic";
|
|
1166
1183
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1675,6 +1692,8 @@ function TableInner({
|
|
|
1675
1692
|
const leafSourceColumns = (0, import_react5.useMemo)(() => flattenDataColumns(sourceColumns), [sourceColumns]);
|
|
1676
1693
|
const sourceColumnWidthsRef = (0, import_react5.useRef)(new Map(leafSourceColumns.map((column) => [column.key, column.width])));
|
|
1677
1694
|
const showRowCheckbox = Boolean(rowSelection) && (typeof rowSelection !== "object" || rowSelection.showCheckbox !== false);
|
|
1695
|
+
const rowSelectionIndicator = typeof rowSelection === "object" ? rowSelection.indicator ?? "checkbox" : "checkbox";
|
|
1696
|
+
const rowSelectionColumnWidth = typeof rowSelection === "object" ? Math.max(24, rowSelection.columnWidth ?? 44) : 44;
|
|
1678
1697
|
(0, import_react5.useEffect)(() => {
|
|
1679
1698
|
if (!isProductionRuntime() && hasNestedFixedColumns(sourceColumns)) {
|
|
1680
1699
|
console.warn("[Table] Multi-level headers only support fixed columns on top-level columns. Nested fixed values are ignored.");
|
|
@@ -1686,7 +1705,7 @@ function TableInner({
|
|
|
1686
1705
|
utilityColumns.push({ key: "__rvg_row_drag__", title: "", width: 36, align: "center", fixed: "left", rowDragHandle: true });
|
|
1687
1706
|
}
|
|
1688
1707
|
if (showRowCheckbox) {
|
|
1689
|
-
utilityColumns.push({ key: "__rvg_row_selection__", title: "", width:
|
|
1708
|
+
utilityColumns.push({ key: "__rvg_row_selection__", title: "", width: rowSelectionColumnWidth, align: "center", fixed: "left", rowSelection: true, rowSelectionIndicator });
|
|
1690
1709
|
}
|
|
1691
1710
|
if (rowNumber) {
|
|
1692
1711
|
utilityColumns.push({ key: "__rvg_row_number__", title: "#", width: getRowNumberColumnWidth(sourceRows.length), align: "center", fixed: typeof rowNumber === "object" && rowNumber.fixed === false ? void 0 : "left", rowNumber: true });
|
|
@@ -1696,7 +1715,7 @@ function TableInner({
|
|
|
1696
1715
|
return resizedWidth === void 0 ? column : { ...column, width: resizedWidth };
|
|
1697
1716
|
});
|
|
1698
1717
|
return [...utilityColumns, ...dataColumns];
|
|
1699
|
-
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, showRowCheckbox, sourceRows.length]);
|
|
1718
|
+
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length]);
|
|
1700
1719
|
const utilityColumnCount = (rowDraggable ? 1 : 0) + (showRowCheckbox ? 1 : 0) + (rowNumber ? 1 : 0);
|
|
1701
1720
|
const headerCells = (0, import_react5.useMemo)(() => buildHeaderCells(sourceColumns, utilityColumnCount, headerDepth), [headerDepth, sourceColumns, utilityColumnCount]);
|
|
1702
1721
|
const activeCustomHeaderLevels = (0, import_react5.useMemo)(() => {
|
|
@@ -2259,6 +2278,7 @@ function TableInner({
|
|
|
2259
2278
|
selection: readThemeColor(themeStyles, "--rvg-color-primary", "#1677ff"),
|
|
2260
2279
|
selectionFill: readThemeColor(themeStyles, "--rvg-color-selection-fill", "#edf4ff"),
|
|
2261
2280
|
axisSelectionFill: readThemeColor(themeStyles, "--rvg-color-axis-selection-fill", "#e8f2ff"),
|
|
2281
|
+
axisSelectionText: readThemeColor(themeStyles, "--rvg-color-axis-selection-text", readThemeColor(themeStyles, "--rvg-color-text", "#202124")),
|
|
2262
2282
|
rowHoverFill: readThemeColor(themeStyles, "--rvg-color-row-hover-fill", "#f6f9fc"),
|
|
2263
2283
|
editedFill: editedCellHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-edited-fill", "#fff1b8"),
|
|
2264
2284
|
insertedFill: insertedRowHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-inserted-fill", "#c8ead4"),
|
|
@@ -4132,7 +4152,7 @@ function TableInner({
|
|
|
4132
4152
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4133
4153
|
"div",
|
|
4134
4154
|
{
|
|
4135
|
-
className:
|
|
4155
|
+
className: `rvg-cell-render${selectedRowKeySet.has(getRowKey(row, rowIndex)) || selectedColumnKeySet.has(column.key) ? " is-axis-selected" : ""}`,
|
|
4136
4156
|
style: {
|
|
4137
4157
|
left,
|
|
4138
4158
|
top,
|
|
@@ -4167,7 +4187,7 @@ function TableInner({
|
|
|
4167
4187
|
);
|
|
4168
4188
|
}
|
|
4169
4189
|
if (column.rowSelection) {
|
|
4170
|
-
if (rowSelectionMode === "single") return null;
|
|
4190
|
+
if (rowSelectionMode === "single" || column.rowSelectionIndicator === "arrow") return null;
|
|
4171
4191
|
const allSelected = rows.length > 0 && selectedRowKeySet.size === rows.length;
|
|
4172
4192
|
const indeterminate = selectedRowKeySet.size > 0 && !allSelected;
|
|
4173
4193
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -4704,6 +4724,7 @@ function TableInner({
|
|
|
4704
4724
|
}
|
|
4705
4725
|
if (locateHeaderDragHandle(event.clientX, columnIndex)) return;
|
|
4706
4726
|
if (columnIndex >= 0 && columns[columnIndex].rowSelection && rowSelection) {
|
|
4727
|
+
if (columns[columnIndex].rowSelectionIndicator === "arrow") return;
|
|
4707
4728
|
setRowKeys(rowKeys.length === rows.length ? [] : rows.map(getRowKey));
|
|
4708
4729
|
} else if (columnIndex >= 0 && (columns[columnIndex].rowDragHandle || columns[columnIndex].rowNumber)) {
|
|
4709
4730
|
return;
|
|
@@ -4722,7 +4743,7 @@ function TableInner({
|
|
|
4722
4743
|
const clickedRowSelector = Boolean(columns[cell.columnIndex].rowSelection);
|
|
4723
4744
|
if (clickedRowSelector) {
|
|
4724
4745
|
clickedCellRef.current = null;
|
|
4725
|
-
selectRow(cell.rowIndex, event,
|
|
4746
|
+
selectRow(cell.rowIndex, event, columns[cell.columnIndex].rowSelectionIndicator !== "arrow");
|
|
4726
4747
|
return;
|
|
4727
4748
|
}
|
|
4728
4749
|
if (event.detail > 1) return;
|
package/dist/index.css
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--rvg-color-primary-soft: #edf4ff;
|
|
17
17
|
--rvg-color-selection-fill: #edf4ff;
|
|
18
18
|
--rvg-color-axis-selection-fill: #e8f2ff;
|
|
19
|
+
--rvg-color-axis-selection-text: var(--rvg-color-text);
|
|
19
20
|
--rvg-color-column-drop-target-fill: #eeeeee;
|
|
20
21
|
--rvg-color-range-fill: #e8f1ff;
|
|
21
22
|
--rvg-color-row-hover-fill: #f6f9fc;
|
|
@@ -270,6 +271,9 @@
|
|
|
270
271
|
overflow: hidden;
|
|
271
272
|
text-overflow: ellipsis;
|
|
272
273
|
}
|
|
274
|
+
.rvg-cell-render.is-axis-selected {
|
|
275
|
+
color: var(--rvg-color-axis-selection-text);
|
|
276
|
+
}
|
|
273
277
|
.rvg-summary-row {
|
|
274
278
|
position: absolute;
|
|
275
279
|
z-index: 4;
|
package/dist/index.d.cts
CHANGED
|
@@ -159,6 +159,10 @@ interface AxisSelectionConfig {
|
|
|
159
159
|
interface RowSelectionConfig extends AxisSelectionConfig {
|
|
160
160
|
/** Show the selection column. Defaults to true; when false, click body cells to select rows. */
|
|
161
161
|
showCheckbox?: boolean;
|
|
162
|
+
/** Selection marker style. Arrow stays blank until selected. Defaults to checkbox. */
|
|
163
|
+
indicator?: 'checkbox' | 'arrow';
|
|
164
|
+
/** Width of the generated selection column. Defaults to 44. */
|
|
165
|
+
columnWidth?: number;
|
|
162
166
|
}
|
|
163
167
|
interface TableRowNumberConfig {
|
|
164
168
|
/** Fix the row number column to the left. Defaults to true. */
|
package/dist/index.d.ts
CHANGED
|
@@ -159,6 +159,10 @@ interface AxisSelectionConfig {
|
|
|
159
159
|
interface RowSelectionConfig extends AxisSelectionConfig {
|
|
160
160
|
/** Show the selection column. Defaults to true; when false, click body cells to select rows. */
|
|
161
161
|
showCheckbox?: boolean;
|
|
162
|
+
/** Selection marker style. Arrow stays blank until selected. Defaults to checkbox. */
|
|
163
|
+
indicator?: 'checkbox' | 'arrow';
|
|
164
|
+
/** Width of the generated selection column. Defaults to 44. */
|
|
165
|
+
columnWidth?: number;
|
|
162
166
|
}
|
|
163
167
|
interface TableRowNumberConfig {
|
|
164
168
|
/** Fix the row number column to the left. Defaults to true. */
|
package/dist/index.js
CHANGED
|
@@ -804,7 +804,8 @@ function getVisibleHeaderActions(column, width, columnDraggable = false, titleWi
|
|
|
804
804
|
}
|
|
805
805
|
function getMinimumColumnWidth(column, columnDraggable = false) {
|
|
806
806
|
if (column.rowDragHandle) return 36;
|
|
807
|
-
if (column.rowSelection
|
|
807
|
+
if (column.rowSelection) return Math.max(24, column.width ?? 44);
|
|
808
|
+
if (column.rowNumber) return 44;
|
|
808
809
|
return 60;
|
|
809
810
|
}
|
|
810
811
|
function buildColumnMetrics(columns, columnDraggableOrOptions = false) {
|
|
@@ -889,6 +890,7 @@ var COLORS = {
|
|
|
889
890
|
selection: "#1677ff",
|
|
890
891
|
selectionFill: "#edf4ff",
|
|
891
892
|
axisSelectionFill: "#e8f2ff",
|
|
893
|
+
axisSelectionText: "#202124",
|
|
892
894
|
rowHoverFill: "#f6f9fc",
|
|
893
895
|
editedFill: "#fff1b8",
|
|
894
896
|
insertedFill: "#c8ead4",
|
|
@@ -987,6 +989,7 @@ function paintGrid(options) {
|
|
|
987
989
|
const colSpan = span?.colSpan ?? 1;
|
|
988
990
|
const cellWidth = getCellWidth(columnIndex, colSpan);
|
|
989
991
|
const cellHeight = rowHeight * rowSpan;
|
|
992
|
+
const isAxisSelected = selectedRowKeys.has(rowKey) || selectedColumnKeys.has(column.key);
|
|
990
993
|
const rangeRowStart = selectionRange ? Math.min(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
991
994
|
const rangeRowEnd = selectionRange ? Math.max(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
992
995
|
const rangeColumnStart = selectionRange ? Math.min(selectionRange.anchor.columnIndex, selectionRange.focus.columnIndex) : -1;
|
|
@@ -996,7 +999,7 @@ function paintGrid(options) {
|
|
|
996
999
|
ctx.fillStyle = striped && rowIndex % 2 === 1 ? colors.stripe : colors.background;
|
|
997
1000
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
998
1001
|
}
|
|
999
|
-
if (
|
|
1002
|
+
if (isAxisSelected) {
|
|
1000
1003
|
ctx.fillStyle = colors.axisSelectionFill;
|
|
1001
1004
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1002
1005
|
}
|
|
@@ -1041,14 +1044,14 @@ function paintGrid(options) {
|
|
|
1041
1044
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1042
1045
|
}
|
|
1043
1046
|
if (rowSpan > 1) {
|
|
1044
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill :
|
|
1047
|
+
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1045
1048
|
ctx.fillStyle = mergedFill;
|
|
1046
1049
|
for (let offset = 1; offset < rowSpan; offset += 1) {
|
|
1047
1050
|
ctx.fillRect(x, y + offset * rowHeight - 1, cellWidth, 2);
|
|
1048
1051
|
}
|
|
1049
1052
|
}
|
|
1050
1053
|
if (colSpan > 1 && !verticalBorderless) {
|
|
1051
|
-
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill :
|
|
1054
|
+
const mergedFill = annotation?.type === "background" ? annotation.color : isSelectedCell || isRangeCell ? colors.selectionFill : highlightEditedCells && !insertedRowKeys.has(rowKey) && editedCellKeys.has(`${typeof rowKey}:${String(rowKey)}\0${column.key}`) ? colors.editedFill : highlightInsertedRows && insertedRowKeys.has(rowKey) ? colors.insertedFill : hoveredRowIndex === rowIndex ? colors.rowHoverFill : isAxisSelected ? colors.axisSelectionFill : cellStyle?.backgroundColor ?? (striped && rowIndex % 2 === 1 ? colors.stripe : colors.background);
|
|
1052
1055
|
ctx.fillStyle = mergedFill;
|
|
1053
1056
|
let offsetLeft = 0;
|
|
1054
1057
|
for (let offset = 1; offset < colSpan; offset += 1) {
|
|
@@ -1082,7 +1085,21 @@ function paintGrid(options) {
|
|
|
1082
1085
|
const checked = selectedRowKeys.has(rowKey);
|
|
1083
1086
|
ctx.save();
|
|
1084
1087
|
ctx.lineWidth = 1;
|
|
1085
|
-
if (
|
|
1088
|
+
if (column.rowSelectionIndicator === "arrow") {
|
|
1089
|
+
if (checked) {
|
|
1090
|
+
ctx.beginPath();
|
|
1091
|
+
ctx.moveTo(iconLeft + 3.5, iconTop + 8);
|
|
1092
|
+
ctx.lineTo(iconLeft + 12.5, iconTop + 8);
|
|
1093
|
+
ctx.moveTo(iconLeft + 8.5, iconTop + 4);
|
|
1094
|
+
ctx.lineTo(iconLeft + 12.5, iconTop + 8);
|
|
1095
|
+
ctx.lineTo(iconLeft + 8.5, iconTop + 12);
|
|
1096
|
+
ctx.strokeStyle = colors.axisSelectionText;
|
|
1097
|
+
ctx.lineWidth = 1.75;
|
|
1098
|
+
ctx.lineCap = "round";
|
|
1099
|
+
ctx.lineJoin = "round";
|
|
1100
|
+
ctx.stroke();
|
|
1101
|
+
}
|
|
1102
|
+
} else if (rowSelectionMode === "single") {
|
|
1086
1103
|
ctx.beginPath();
|
|
1087
1104
|
ctx.arc(iconLeft + 8, iconTop + 8, 6.25, 0, Math.PI * 2);
|
|
1088
1105
|
ctx.fillStyle = colors.background;
|
|
@@ -1130,7 +1147,7 @@ function paintGrid(options) {
|
|
|
1130
1147
|
ctx.beginPath();
|
|
1131
1148
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1132
1149
|
ctx.clip();
|
|
1133
|
-
ctx.fillStyle =
|
|
1150
|
+
ctx.fillStyle = isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? colors.text;
|
|
1134
1151
|
ctx.font = createCellFont(bodyFontSize);
|
|
1135
1152
|
ctx.textBaseline = "alphabetic";
|
|
1136
1153
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1645,6 +1662,8 @@ function TableInner({
|
|
|
1645
1662
|
const leafSourceColumns = useMemo(() => flattenDataColumns(sourceColumns), [sourceColumns]);
|
|
1646
1663
|
const sourceColumnWidthsRef = useRef2(new Map(leafSourceColumns.map((column) => [column.key, column.width])));
|
|
1647
1664
|
const showRowCheckbox = Boolean(rowSelection) && (typeof rowSelection !== "object" || rowSelection.showCheckbox !== false);
|
|
1665
|
+
const rowSelectionIndicator = typeof rowSelection === "object" ? rowSelection.indicator ?? "checkbox" : "checkbox";
|
|
1666
|
+
const rowSelectionColumnWidth = typeof rowSelection === "object" ? Math.max(24, rowSelection.columnWidth ?? 44) : 44;
|
|
1648
1667
|
useEffect2(() => {
|
|
1649
1668
|
if (!isProductionRuntime() && hasNestedFixedColumns(sourceColumns)) {
|
|
1650
1669
|
console.warn("[Table] Multi-level headers only support fixed columns on top-level columns. Nested fixed values are ignored.");
|
|
@@ -1656,7 +1675,7 @@ function TableInner({
|
|
|
1656
1675
|
utilityColumns.push({ key: "__rvg_row_drag__", title: "", width: 36, align: "center", fixed: "left", rowDragHandle: true });
|
|
1657
1676
|
}
|
|
1658
1677
|
if (showRowCheckbox) {
|
|
1659
|
-
utilityColumns.push({ key: "__rvg_row_selection__", title: "", width:
|
|
1678
|
+
utilityColumns.push({ key: "__rvg_row_selection__", title: "", width: rowSelectionColumnWidth, align: "center", fixed: "left", rowSelection: true, rowSelectionIndicator });
|
|
1660
1679
|
}
|
|
1661
1680
|
if (rowNumber) {
|
|
1662
1681
|
utilityColumns.push({ key: "__rvg_row_number__", title: "#", width: getRowNumberColumnWidth(sourceRows.length), align: "center", fixed: typeof rowNumber === "object" && rowNumber.fixed === false ? void 0 : "left", rowNumber: true });
|
|
@@ -1666,7 +1685,7 @@ function TableInner({
|
|
|
1666
1685
|
return resizedWidth === void 0 ? column : { ...column, width: resizedWidth };
|
|
1667
1686
|
});
|
|
1668
1687
|
return [...utilityColumns, ...dataColumns];
|
|
1669
|
-
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, showRowCheckbox, sourceRows.length]);
|
|
1688
|
+
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length]);
|
|
1670
1689
|
const utilityColumnCount = (rowDraggable ? 1 : 0) + (showRowCheckbox ? 1 : 0) + (rowNumber ? 1 : 0);
|
|
1671
1690
|
const headerCells = useMemo(() => buildHeaderCells(sourceColumns, utilityColumnCount, headerDepth), [headerDepth, sourceColumns, utilityColumnCount]);
|
|
1672
1691
|
const activeCustomHeaderLevels = useMemo(() => {
|
|
@@ -2229,6 +2248,7 @@ function TableInner({
|
|
|
2229
2248
|
selection: readThemeColor(themeStyles, "--rvg-color-primary", "#1677ff"),
|
|
2230
2249
|
selectionFill: readThemeColor(themeStyles, "--rvg-color-selection-fill", "#edf4ff"),
|
|
2231
2250
|
axisSelectionFill: readThemeColor(themeStyles, "--rvg-color-axis-selection-fill", "#e8f2ff"),
|
|
2251
|
+
axisSelectionText: readThemeColor(themeStyles, "--rvg-color-axis-selection-text", readThemeColor(themeStyles, "--rvg-color-text", "#202124")),
|
|
2232
2252
|
rowHoverFill: readThemeColor(themeStyles, "--rvg-color-row-hover-fill", "#f6f9fc"),
|
|
2233
2253
|
editedFill: editedCellHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-edited-fill", "#fff1b8"),
|
|
2234
2254
|
insertedFill: insertedRowHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-inserted-fill", "#c8ead4"),
|
|
@@ -4102,7 +4122,7 @@ function TableInner({
|
|
|
4102
4122
|
return /* @__PURE__ */ jsx7(
|
|
4103
4123
|
"div",
|
|
4104
4124
|
{
|
|
4105
|
-
className:
|
|
4125
|
+
className: `rvg-cell-render${selectedRowKeySet.has(getRowKey(row, rowIndex)) || selectedColumnKeySet.has(column.key) ? " is-axis-selected" : ""}`,
|
|
4106
4126
|
style: {
|
|
4107
4127
|
left,
|
|
4108
4128
|
top,
|
|
@@ -4137,7 +4157,7 @@ function TableInner({
|
|
|
4137
4157
|
);
|
|
4138
4158
|
}
|
|
4139
4159
|
if (column.rowSelection) {
|
|
4140
|
-
if (rowSelectionMode === "single") return null;
|
|
4160
|
+
if (rowSelectionMode === "single" || column.rowSelectionIndicator === "arrow") return null;
|
|
4141
4161
|
const allSelected = rows.length > 0 && selectedRowKeySet.size === rows.length;
|
|
4142
4162
|
const indeterminate = selectedRowKeySet.size > 0 && !allSelected;
|
|
4143
4163
|
return /* @__PURE__ */ jsx7(
|
|
@@ -4674,6 +4694,7 @@ function TableInner({
|
|
|
4674
4694
|
}
|
|
4675
4695
|
if (locateHeaderDragHandle(event.clientX, columnIndex)) return;
|
|
4676
4696
|
if (columnIndex >= 0 && columns[columnIndex].rowSelection && rowSelection) {
|
|
4697
|
+
if (columns[columnIndex].rowSelectionIndicator === "arrow") return;
|
|
4677
4698
|
setRowKeys(rowKeys.length === rows.length ? [] : rows.map(getRowKey));
|
|
4678
4699
|
} else if (columnIndex >= 0 && (columns[columnIndex].rowDragHandle || columns[columnIndex].rowNumber)) {
|
|
4679
4700
|
return;
|
|
@@ -4692,7 +4713,7 @@ function TableInner({
|
|
|
4692
4713
|
const clickedRowSelector = Boolean(columns[cell.columnIndex].rowSelection);
|
|
4693
4714
|
if (clickedRowSelector) {
|
|
4694
4715
|
clickedCellRef.current = null;
|
|
4695
|
-
selectRow(cell.rowIndex, event,
|
|
4716
|
+
selectRow(cell.rowIndex, event, columns[cell.columnIndex].rowSelectionIndicator !== "arrow");
|
|
4696
4717
|
return;
|
|
4697
4718
|
}
|
|
4698
4719
|
if (event.detail > 1) return;
|