@lensui/lens-table 0.1.15 → 0.1.17
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 +73 -26
- package/dist/index.css +13 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +73 -26
- 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` | 开启行选择。支持 `mode`、`showCheckbox`、`indicator: 'checkbox' \| 'arrow'` 和 `columnWidth
|
|
114
|
+
| `rowSelection` | `boolean \| RowSelectionConfig` | `false` | 开启行选择。支持 `mode`、`showCheckbox`、`indicator: 'checkbox' \| 'arrow' \| 'none'` 和 `columnWidth`;`none` 保留点击区域但不绘制标记。默认自动生成左侧选择列。 |
|
|
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
|
@@ -920,6 +920,7 @@ var COLORS = {
|
|
|
920
920
|
selection: "#1677ff",
|
|
921
921
|
selectionFill: "#edf4ff",
|
|
922
922
|
axisSelectionFill: "#e8f2ff",
|
|
923
|
+
axisSelectionText: "#202124",
|
|
923
924
|
rowHoverFill: "#f6f9fc",
|
|
924
925
|
editedFill: "#fff1b8",
|
|
925
926
|
insertedFill: "#c8ead4",
|
|
@@ -1018,6 +1019,7 @@ function paintGrid(options) {
|
|
|
1018
1019
|
const colSpan = span?.colSpan ?? 1;
|
|
1019
1020
|
const cellWidth = getCellWidth(columnIndex, colSpan);
|
|
1020
1021
|
const cellHeight = rowHeight * rowSpan;
|
|
1022
|
+
const isAxisSelected = selectedRowKeys.has(rowKey) || selectedColumnKeys.has(column.key);
|
|
1021
1023
|
const rangeRowStart = selectionRange ? Math.min(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
1022
1024
|
const rangeRowEnd = selectionRange ? Math.max(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
1023
1025
|
const rangeColumnStart = selectionRange ? Math.min(selectionRange.anchor.columnIndex, selectionRange.focus.columnIndex) : -1;
|
|
@@ -1027,7 +1029,7 @@ function paintGrid(options) {
|
|
|
1027
1029
|
ctx.fillStyle = striped && rowIndex % 2 === 1 ? colors.stripe : colors.background;
|
|
1028
1030
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1029
1031
|
}
|
|
1030
|
-
if (
|
|
1032
|
+
if (isAxisSelected) {
|
|
1031
1033
|
ctx.fillStyle = colors.axisSelectionFill;
|
|
1032
1034
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1033
1035
|
}
|
|
@@ -1072,14 +1074,14 @@ function paintGrid(options) {
|
|
|
1072
1074
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1073
1075
|
}
|
|
1074
1076
|
if (rowSpan > 1) {
|
|
1075
|
-
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);
|
|
1076
1078
|
ctx.fillStyle = mergedFill;
|
|
1077
1079
|
for (let offset = 1; offset < rowSpan; offset += 1) {
|
|
1078
1080
|
ctx.fillRect(x, y + offset * rowHeight - 1, cellWidth, 2);
|
|
1079
1081
|
}
|
|
1080
1082
|
}
|
|
1081
1083
|
if (colSpan > 1 && !verticalBorderless) {
|
|
1082
|
-
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);
|
|
1083
1085
|
ctx.fillStyle = mergedFill;
|
|
1084
1086
|
let offsetLeft = 0;
|
|
1085
1087
|
for (let offset = 1; offset < colSpan; offset += 1) {
|
|
@@ -1113,7 +1115,8 @@ function paintGrid(options) {
|
|
|
1113
1115
|
const checked = selectedRowKeys.has(rowKey);
|
|
1114
1116
|
ctx.save();
|
|
1115
1117
|
ctx.lineWidth = 1;
|
|
1116
|
-
if (column.rowSelectionIndicator === "
|
|
1118
|
+
if (column.rowSelectionIndicator === "none") {
|
|
1119
|
+
} else if (column.rowSelectionIndicator === "arrow") {
|
|
1117
1120
|
if (checked) {
|
|
1118
1121
|
ctx.beginPath();
|
|
1119
1122
|
ctx.moveTo(iconLeft + 3.5, iconTop + 8);
|
|
@@ -1121,7 +1124,7 @@ function paintGrid(options) {
|
|
|
1121
1124
|
ctx.moveTo(iconLeft + 8.5, iconTop + 4);
|
|
1122
1125
|
ctx.lineTo(iconLeft + 12.5, iconTop + 8);
|
|
1123
1126
|
ctx.lineTo(iconLeft + 8.5, iconTop + 12);
|
|
1124
|
-
ctx.strokeStyle = colors.
|
|
1127
|
+
ctx.strokeStyle = colors.axisSelectionText;
|
|
1125
1128
|
ctx.lineWidth = 1.75;
|
|
1126
1129
|
ctx.lineCap = "round";
|
|
1127
1130
|
ctx.lineJoin = "round";
|
|
@@ -1175,7 +1178,7 @@ function paintGrid(options) {
|
|
|
1175
1178
|
ctx.beginPath();
|
|
1176
1179
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1177
1180
|
ctx.clip();
|
|
1178
|
-
ctx.fillStyle =
|
|
1181
|
+
ctx.fillStyle = isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? colors.text;
|
|
1179
1182
|
ctx.font = createCellFont(bodyFontSize);
|
|
1180
1183
|
ctx.textBaseline = "alphabetic";
|
|
1181
1184
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1199,9 +1202,25 @@ function paintGrid(options) {
|
|
|
1199
1202
|
paintBodyColumns("scroll");
|
|
1200
1203
|
paintBodyColumns("left");
|
|
1201
1204
|
paintBodyColumns("right");
|
|
1202
|
-
if (extendVerticalGridLines
|
|
1205
|
+
if (extendVerticalGridLines) {
|
|
1203
1206
|
const extensionTop = Math.max(bodyTop, Math.min(height, bodyTop + rows.length * rowHeight - scrollTop));
|
|
1204
1207
|
const extensionHeight = Math.max(0, height - extensionTop);
|
|
1208
|
+
const paintExtendedColumnSelection = (layer) => {
|
|
1209
|
+
ctx.save();
|
|
1210
|
+
if (layer === "scroll") {
|
|
1211
|
+
ctx.beginPath();
|
|
1212
|
+
ctx.rect(leftFixedWidth, extensionTop, Math.max(0, rightFixedLeft - leftFixedWidth), extensionHeight);
|
|
1213
|
+
ctx.clip();
|
|
1214
|
+
}
|
|
1215
|
+
ctx.fillStyle = colors.axisSelectionFill;
|
|
1216
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex += 1) {
|
|
1217
|
+
if (!selectedColumnKeys.has(columns[columnIndex].key)) continue;
|
|
1218
|
+
if (layer === "scroll" ? columns[columnIndex].fixed !== void 0 : columns[columnIndex].fixed !== layer) continue;
|
|
1219
|
+
if (layer === "scroll" && (columnIndex < range.columnStart || columnIndex >= range.columnEnd)) continue;
|
|
1220
|
+
ctx.fillRect(getColumnX(columnIndex), extensionTop, metrics[columnIndex].width, extensionHeight);
|
|
1221
|
+
}
|
|
1222
|
+
ctx.restore();
|
|
1223
|
+
};
|
|
1205
1224
|
const paintExtendedColumnLines = (layer) => {
|
|
1206
1225
|
ctx.save();
|
|
1207
1226
|
if (layer === "scroll") {
|
|
@@ -1219,9 +1238,14 @@ function paintGrid(options) {
|
|
|
1219
1238
|
}
|
|
1220
1239
|
ctx.restore();
|
|
1221
1240
|
};
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1241
|
+
paintExtendedColumnSelection("scroll");
|
|
1242
|
+
paintExtendedColumnSelection("left");
|
|
1243
|
+
paintExtendedColumnSelection("right");
|
|
1244
|
+
if (!verticalBorderless) {
|
|
1245
|
+
paintExtendedColumnLines("scroll");
|
|
1246
|
+
paintExtendedColumnLines("left");
|
|
1247
|
+
paintExtendedColumnLines("right");
|
|
1248
|
+
}
|
|
1225
1249
|
}
|
|
1226
1250
|
const headerY = fixedHeader ? 0 : -scrollTop;
|
|
1227
1251
|
ctx.fillStyle = colors.header;
|
|
@@ -1237,8 +1261,9 @@ function paintGrid(options) {
|
|
|
1237
1261
|
ctx.fillStyle = colors.header;
|
|
1238
1262
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1239
1263
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1264
|
+
const isAxisSelected = selectedColumnKeys.has(columns[columnIndex].key);
|
|
1265
|
+
if (isAxisSelected) {
|
|
1266
|
+
ctx.fillStyle = colors.axisSelectionFill;
|
|
1242
1267
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1243
1268
|
}
|
|
1244
1269
|
if (columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex) {
|
|
@@ -1270,7 +1295,7 @@ function paintGrid(options) {
|
|
|
1270
1295
|
ctx.beginPath();
|
|
1271
1296
|
ctx.rect(x + 2, headerY + headerLeafTop + 1, Math.max(0, clipWidth - 4), headerLeafHeight - 2);
|
|
1272
1297
|
ctx.clip();
|
|
1273
|
-
ctx.fillStyle = colors.muted;
|
|
1298
|
+
ctx.fillStyle = isAxisSelected ? colors.axisSelectionText : colors.muted;
|
|
1274
1299
|
ctx.textAlign = titleAlign === "right" ? "right" : titleAlign === "center" ? "center" : "left";
|
|
1275
1300
|
ctx.fillText(title, textX, headerY + headerLeafTop + headerLeafHeight / 2);
|
|
1276
1301
|
ctx.restore();
|
|
@@ -2276,6 +2301,7 @@ function TableInner({
|
|
|
2276
2301
|
selection: readThemeColor(themeStyles, "--rvg-color-primary", "#1677ff"),
|
|
2277
2302
|
selectionFill: readThemeColor(themeStyles, "--rvg-color-selection-fill", "#edf4ff"),
|
|
2278
2303
|
axisSelectionFill: readThemeColor(themeStyles, "--rvg-color-axis-selection-fill", "#e8f2ff"),
|
|
2304
|
+
axisSelectionText: readThemeColor(themeStyles, "--rvg-color-axis-selection-text", readThemeColor(themeStyles, "--rvg-color-text", "#202124")),
|
|
2279
2305
|
rowHoverFill: readThemeColor(themeStyles, "--rvg-color-row-hover-fill", "#f6f9fc"),
|
|
2280
2306
|
editedFill: editedCellHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-edited-fill", "#fff1b8"),
|
|
2281
2307
|
insertedFill: insertedRowHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-inserted-fill", "#c8ead4"),
|
|
@@ -3375,6 +3401,9 @@ function TableInner({
|
|
|
3375
3401
|
}, [setSelection]);
|
|
3376
3402
|
const selectRow = (0, import_react5.useCallback)((rowIndex, event, forceToggle = false) => {
|
|
3377
3403
|
if (!rowSelection) return;
|
|
3404
|
+
clickedCellRef.current = null;
|
|
3405
|
+
setSelectionRange(null);
|
|
3406
|
+
setSelection(null);
|
|
3378
3407
|
const mode = typeof rowSelection === "object" ? rowSelection.mode ?? "multiple" : "multiple";
|
|
3379
3408
|
const key = getRowKey(rows[rowIndex], rowIndex);
|
|
3380
3409
|
let next;
|
|
@@ -3389,9 +3418,12 @@ function TableInner({
|
|
|
3389
3418
|
}
|
|
3390
3419
|
rowAnchorRef.current = rowIndex;
|
|
3391
3420
|
setRowKeys(next);
|
|
3392
|
-
}, [getRowKey, rowKeys, rowSelection, rows, selectedRowKeySet, setRowKeys]);
|
|
3421
|
+
}, [getRowKey, rowKeys, rowSelection, rows, selectedRowKeySet, setRowKeys, setSelection]);
|
|
3393
3422
|
const selectColumn = (0, import_react5.useCallback)((columnIndex, event) => {
|
|
3394
3423
|
if (!columnSelection || columnIndex < 0) return;
|
|
3424
|
+
clickedCellRef.current = null;
|
|
3425
|
+
setSelectionRange(null);
|
|
3426
|
+
setSelection(null);
|
|
3395
3427
|
const mode = typeof columnSelection === "object" ? columnSelection.mode ?? "multiple" : "multiple";
|
|
3396
3428
|
const key = columns[columnIndex].key;
|
|
3397
3429
|
let next;
|
|
@@ -3399,23 +3431,26 @@ function TableInner({
|
|
|
3399
3431
|
const start = Math.min(columnAnchorRef.current, columnIndex);
|
|
3400
3432
|
const end = Math.max(columnAnchorRef.current, columnIndex);
|
|
3401
3433
|
next = columns.slice(start, end + 1).map((column) => column.key);
|
|
3402
|
-
} else if (mode === "multiple") {
|
|
3434
|
+
} else if (mode === "multiple" && (event.ctrlKey || event.metaKey)) {
|
|
3403
3435
|
next = selectedColumnKeySet.has(key) ? columnKeys.filter((item) => item !== key) : [...columnKeys, key];
|
|
3404
3436
|
} else {
|
|
3405
3437
|
next = columnKeys.length === 1 && selectedColumnKeySet.has(key) ? [] : [key];
|
|
3406
3438
|
}
|
|
3407
3439
|
columnAnchorRef.current = columnIndex;
|
|
3408
3440
|
setColumnKeys(next);
|
|
3409
|
-
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys]);
|
|
3441
|
+
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys, setSelection]);
|
|
3410
3442
|
const toggleColumnFromMenu = (0, import_react5.useCallback)((columnIndex) => {
|
|
3411
3443
|
if (!columnSelection || columnIndex < 0) return;
|
|
3444
|
+
clickedCellRef.current = null;
|
|
3445
|
+
setSelectionRange(null);
|
|
3446
|
+
setSelection(null);
|
|
3412
3447
|
const key = columns[columnIndex].key;
|
|
3413
3448
|
const mode = typeof columnSelection === "object" ? columnSelection.mode ?? "multiple" : "multiple";
|
|
3414
3449
|
const selected = selectedColumnKeySet.has(key);
|
|
3415
3450
|
const next = selected ? columnKeys.filter((value) => value !== key) : mode === "multiple" ? [...columnKeys, key] : [key];
|
|
3416
3451
|
columnAnchorRef.current = columnIndex;
|
|
3417
3452
|
setColumnKeys(next);
|
|
3418
|
-
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys]);
|
|
3453
|
+
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys, setSelection]);
|
|
3419
3454
|
const revealCell = (0, import_react5.useCallback)((cell) => {
|
|
3420
3455
|
const scroller = scrollerRef.current;
|
|
3421
3456
|
const metric = metrics[cell.columnIndex];
|
|
@@ -3767,6 +3802,8 @@ function TableInner({
|
|
|
3767
3802
|
const renderHeaderIcons = (columnIndex, left) => {
|
|
3768
3803
|
const column = columns[columnIndex];
|
|
3769
3804
|
if (column.rowSelection || column.rowDragHandle || column.rowNumber) return null;
|
|
3805
|
+
const isAxisSelected = selectedColumnKeySet.has(column.key);
|
|
3806
|
+
const selectedClassName = isAxisSelected ? " is-axis-selected" : "";
|
|
3770
3807
|
const top = headerLeafTop + (headerLeafHeight - headerActionSize) / 2;
|
|
3771
3808
|
const visibleActions = getVisibleHeaderActions(column, metrics[columnIndex].width, columnDraggable, measureHeaderTitleWidth(columnIndex), headerActionSlotWidth);
|
|
3772
3809
|
let right = left + metrics[columnIndex].width - (visibleActions.drag ? headerActionSlotWidth : 2);
|
|
@@ -3774,21 +3811,21 @@ function TableInner({
|
|
|
3774
3811
|
if (visibleActions.drag) {
|
|
3775
3812
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "drag";
|
|
3776
3813
|
icons.push(
|
|
3777
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderDragIcon, { className: `rvg-header-icon rvg-header-drag-icon${hovered ? " is-hovered" : ""}`, style: { left: left + metrics[columnIndex].width - headerActionSlotWidth, top } }, "drag")
|
|
3814
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderDragIcon, { className: `rvg-header-icon rvg-header-drag-icon${selectedClassName}${hovered ? " is-hovered" : ""}`, style: { left: left + metrics[columnIndex].width - headerActionSlotWidth, top } }, "drag")
|
|
3778
3815
|
);
|
|
3779
3816
|
}
|
|
3780
3817
|
if (visibleActions.sort) {
|
|
3781
3818
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "sort";
|
|
3782
3819
|
const direction = sortState?.columnKey === column.key ? sortState.direction : null;
|
|
3783
3820
|
icons.push(
|
|
3784
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderSortIcon, { className: `rvg-header-icon${hovered ? " is-hovered" : ""}`, style: { left: right - headerActionSlotWidth, top }, direction }, "sort")
|
|
3821
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderSortIcon, { className: `rvg-header-icon${selectedClassName}${hovered ? " is-hovered" : ""}`, style: { left: right - headerActionSlotWidth, top }, direction }, "sort")
|
|
3785
3822
|
);
|
|
3786
3823
|
right -= headerActionSlotWidth;
|
|
3787
3824
|
}
|
|
3788
3825
|
if (visibleActions.filter) {
|
|
3789
3826
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "filter";
|
|
3790
3827
|
icons.push(
|
|
3791
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderSearchIcon, { className: `rvg-header-icon rvg-header-search-icon${hovered ? " is-hovered" : ""}${filterValues[column.key] ? " is-active" : ""}`, style: { left: right - headerActionSlotWidth, top: top + 1 } }, "filter")
|
|
3828
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderSearchIcon, { className: `rvg-header-icon rvg-header-search-icon${selectedClassName}${hovered ? " is-hovered" : ""}${filterValues[column.key] ? " is-active" : ""}`, style: { left: right - headerActionSlotWidth, top: top + 1 } }, "filter")
|
|
3792
3829
|
);
|
|
3793
3830
|
}
|
|
3794
3831
|
return icons;
|
|
@@ -4149,7 +4186,7 @@ function TableInner({
|
|
|
4149
4186
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4150
4187
|
"div",
|
|
4151
4188
|
{
|
|
4152
|
-
className:
|
|
4189
|
+
className: `rvg-cell-render${selectedRowKeySet.has(getRowKey(row, rowIndex)) || selectedColumnKeySet.has(column.key) ? " is-axis-selected" : ""}`,
|
|
4153
4190
|
style: {
|
|
4154
4191
|
left,
|
|
4155
4192
|
top,
|
|
@@ -4168,6 +4205,7 @@ function TableInner({
|
|
|
4168
4205
|
};
|
|
4169
4206
|
const renderHeaderTitle = (columnIndex, left) => {
|
|
4170
4207
|
const column = columns[columnIndex];
|
|
4208
|
+
const isAxisSelected = selectedColumnKeySet.has(column.key);
|
|
4171
4209
|
const isDropTarget = Boolean(columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex);
|
|
4172
4210
|
const currentScrollTop = scrollRef.current.top;
|
|
4173
4211
|
const headerTop = fixedHeader ? 0 : -currentScrollTop;
|
|
@@ -4184,7 +4222,7 @@ function TableInner({
|
|
|
4184
4222
|
);
|
|
4185
4223
|
}
|
|
4186
4224
|
if (column.rowSelection) {
|
|
4187
|
-
if (rowSelectionMode === "single" || column.rowSelectionIndicator === "arrow") return null;
|
|
4225
|
+
if (rowSelectionMode === "single" || column.rowSelectionIndicator === "arrow" || column.rowSelectionIndicator === "none") return null;
|
|
4188
4226
|
const allSelected = rows.length > 0 && selectedRowKeySet.size === rows.length;
|
|
4189
4227
|
const indeterminate = selectedRowKeySet.size > 0 && !allSelected;
|
|
4190
4228
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -4203,7 +4241,7 @@ function TableInner({
|
|
|
4203
4241
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4204
4242
|
"div",
|
|
4205
4243
|
{
|
|
4206
|
-
className: `rvg-header-title is-custom${isDropTarget ? " is-drop-target" : ""}`,
|
|
4244
|
+
className: `rvg-header-title is-custom${isAxisSelected ? " is-axis-selected" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
4207
4245
|
"data-level": headerDepth - 1,
|
|
4208
4246
|
"data-measure-key": column.key,
|
|
4209
4247
|
style: {
|
|
@@ -4246,10 +4284,11 @@ function TableInner({
|
|
|
4246
4284
|
const visibleActions = cell.leaf ? getVisibleHeaderActions(column, startMetric.width, columnDraggable, measureHeaderTitleWidth(cell.startIndex), headerActionSlotWidth) : null;
|
|
4247
4285
|
const actionWidth = visibleActions ? (Number(visibleActions.drag) + Number(visibleActions.filter) + Number(visibleActions.sort)) * headerActionSlotWidth : columnDraggable && !cell.leaf ? headerActionSlotWidth : 0;
|
|
4248
4286
|
const isDropTarget = Boolean(columnDropTarget && cell.endIndex >= columnDropTarget.startIndex && cell.startIndex <= columnDropTarget.endIndex);
|
|
4287
|
+
const isAxisSelected = cell.leaf && selectedColumnKeySet.has(column.key);
|
|
4249
4288
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4250
4289
|
"div",
|
|
4251
4290
|
{
|
|
4252
|
-
className: `rvg-header-title rvg-header-group${column.renderHeader ? " is-custom" : ""}${cell.leaf ? " is-leaf" : ""}${cell.endIndex === columns.length - 1 ? " is-frame-right" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
4291
|
+
className: `rvg-header-title rvg-header-group${column.renderHeader ? " is-custom" : ""}${cell.leaf ? " is-leaf" : ""}${isAxisSelected ? " is-axis-selected" : ""}${cell.endIndex === columns.length - 1 ? " is-frame-right" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
4253
4292
|
"data-level": cell.level,
|
|
4254
4293
|
"data-measure-key": `group:${cell.key}:${cell.level}`,
|
|
4255
4294
|
style: {
|
|
@@ -4513,12 +4552,16 @@ function TableInner({
|
|
|
4513
4552
|
getSelectedRows: () => rows.filter((row, index) => selectedRowKeySet.has(getRowKey(row, index))),
|
|
4514
4553
|
setSelectedRowKeys: (keys) => {
|
|
4515
4554
|
if (!rowSelection) return;
|
|
4555
|
+
setSelectionRange(null);
|
|
4556
|
+
setSelection(null);
|
|
4516
4557
|
const next = [...new Set(keys)];
|
|
4517
4558
|
setRowKeys(rowSelectionMode === "single" ? next.slice(0, 1) : next);
|
|
4518
4559
|
},
|
|
4519
4560
|
getSelectedColumnKeys: () => [...columnKeys],
|
|
4520
4561
|
setSelectedColumnKeys: (keys) => {
|
|
4521
4562
|
if (!columnSelection) return;
|
|
4563
|
+
setSelectionRange(null);
|
|
4564
|
+
setSelection(null);
|
|
4522
4565
|
const next = [...new Set(keys)].filter((key) => columns.some((column) => column.key === key && !column.rowNumber && !column.rowSelection && !column.rowDragHandle));
|
|
4523
4566
|
setColumnKeys(typeof columnSelection === "object" && columnSelection.mode === "single" ? next.slice(0, 1) : next);
|
|
4524
4567
|
},
|
|
@@ -4721,7 +4764,9 @@ function TableInner({
|
|
|
4721
4764
|
}
|
|
4722
4765
|
if (locateHeaderDragHandle(event.clientX, columnIndex)) return;
|
|
4723
4766
|
if (columnIndex >= 0 && columns[columnIndex].rowSelection && rowSelection) {
|
|
4724
|
-
if (columns[columnIndex].rowSelectionIndicator === "arrow") return;
|
|
4767
|
+
if (columns[columnIndex].rowSelectionIndicator === "arrow" || columns[columnIndex].rowSelectionIndicator === "none") return;
|
|
4768
|
+
setSelectionRange(null);
|
|
4769
|
+
setSelection(null);
|
|
4725
4770
|
setRowKeys(rowKeys.length === rows.length ? [] : rows.map(getRowKey));
|
|
4726
4771
|
} else if (columnIndex >= 0 && (columns[columnIndex].rowDragHandle || columns[columnIndex].rowNumber)) {
|
|
4727
4772
|
return;
|
|
@@ -4740,7 +4785,7 @@ function TableInner({
|
|
|
4740
4785
|
const clickedRowSelector = Boolean(columns[cell.columnIndex].rowSelection);
|
|
4741
4786
|
if (clickedRowSelector) {
|
|
4742
4787
|
clickedCellRef.current = null;
|
|
4743
|
-
selectRow(cell.rowIndex, event, columns[cell.columnIndex].rowSelectionIndicator
|
|
4788
|
+
selectRow(cell.rowIndex, event, !["arrow", "none"].includes(columns[cell.columnIndex].rowSelectionIndicator ?? "checkbox"));
|
|
4744
4789
|
return;
|
|
4745
4790
|
}
|
|
4746
4791
|
if (event.detail > 1) return;
|
|
@@ -5039,6 +5084,8 @@ function TableInner({
|
|
|
5039
5084
|
if (item === "select-row") {
|
|
5040
5085
|
if (!rowSelection) return null;
|
|
5041
5086
|
return renderContextMenuButton("cell-select-row", cellContext, selectedRowKeySet.has(cell.rowKey) ? labels.deselectRow : labels.selectRow, () => {
|
|
5087
|
+
setSelectionRange(null);
|
|
5088
|
+
setSelection(null);
|
|
5042
5089
|
if (selectedRowKeySet.has(cell.rowKey)) setRowKeys(rowKeys.filter((key) => key !== cell.rowKey));
|
|
5043
5090
|
else setRowKeys(rowSelectionMode === "single" ? [cell.rowKey] : [...rowKeys, cell.rowKey]);
|
|
5044
5091
|
}, override, { icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ContextMenuIcon, { type: "select-row" }) });
|
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;
|
|
@@ -769,6 +773,10 @@
|
|
|
769
773
|
.rvg-header-title.is-drop-target {
|
|
770
774
|
background: var(--rvg-color-column-drop-target-fill);
|
|
771
775
|
}
|
|
776
|
+
.rvg-header-title.is-axis-selected {
|
|
777
|
+
background: var(--rvg-color-axis-selection-fill);
|
|
778
|
+
color: var(--rvg-color-axis-selection-text);
|
|
779
|
+
}
|
|
772
780
|
.rvg-text-fixed-shadow {
|
|
773
781
|
position: absolute;
|
|
774
782
|
z-index: 4;
|
|
@@ -850,6 +858,11 @@
|
|
|
850
858
|
.rvg-header-icon.is-hovered {
|
|
851
859
|
color: var(--rvg-color-muted);
|
|
852
860
|
}
|
|
861
|
+
.rvg-header-icon.is-axis-selected,
|
|
862
|
+
.rvg-header-icon.is-axis-selected.is-hovered,
|
|
863
|
+
.rvg-header-icon.is-axis-selected.is-active {
|
|
864
|
+
color: var(--rvg-color-axis-selection-text);
|
|
865
|
+
}
|
|
853
866
|
.rvg-root.is-initial-loading .rvg-header-icon {
|
|
854
867
|
color: #d6dbe0;
|
|
855
868
|
animation: rvg-loading-icon-pulse 1.15s ease-in-out infinite alternate;
|
package/dist/index.d.cts
CHANGED
|
@@ -160,7 +160,7 @@ 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
162
|
/** Selection marker style. Arrow stays blank until selected. Defaults to checkbox. */
|
|
163
|
-
indicator?: 'checkbox' | 'arrow';
|
|
163
|
+
indicator?: 'checkbox' | 'arrow' | 'none';
|
|
164
164
|
/** Width of the generated selection column. Defaults to 44. */
|
|
165
165
|
columnWidth?: number;
|
|
166
166
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -160,7 +160,7 @@ 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
162
|
/** Selection marker style. Arrow stays blank until selected. Defaults to checkbox. */
|
|
163
|
-
indicator?: 'checkbox' | 'arrow';
|
|
163
|
+
indicator?: 'checkbox' | 'arrow' | 'none';
|
|
164
164
|
/** Width of the generated selection column. Defaults to 44. */
|
|
165
165
|
columnWidth?: number;
|
|
166
166
|
}
|
package/dist/index.js
CHANGED
|
@@ -890,6 +890,7 @@ var COLORS = {
|
|
|
890
890
|
selection: "#1677ff",
|
|
891
891
|
selectionFill: "#edf4ff",
|
|
892
892
|
axisSelectionFill: "#e8f2ff",
|
|
893
|
+
axisSelectionText: "#202124",
|
|
893
894
|
rowHoverFill: "#f6f9fc",
|
|
894
895
|
editedFill: "#fff1b8",
|
|
895
896
|
insertedFill: "#c8ead4",
|
|
@@ -988,6 +989,7 @@ function paintGrid(options) {
|
|
|
988
989
|
const colSpan = span?.colSpan ?? 1;
|
|
989
990
|
const cellWidth = getCellWidth(columnIndex, colSpan);
|
|
990
991
|
const cellHeight = rowHeight * rowSpan;
|
|
992
|
+
const isAxisSelected = selectedRowKeys.has(rowKey) || selectedColumnKeys.has(column.key);
|
|
991
993
|
const rangeRowStart = selectionRange ? Math.min(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
992
994
|
const rangeRowEnd = selectionRange ? Math.max(selectionRange.anchor.rowIndex, selectionRange.focus.rowIndex) : -1;
|
|
993
995
|
const rangeColumnStart = selectionRange ? Math.min(selectionRange.anchor.columnIndex, selectionRange.focus.columnIndex) : -1;
|
|
@@ -997,7 +999,7 @@ function paintGrid(options) {
|
|
|
997
999
|
ctx.fillStyle = striped && rowIndex % 2 === 1 ? colors.stripe : colors.background;
|
|
998
1000
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
999
1001
|
}
|
|
1000
|
-
if (
|
|
1002
|
+
if (isAxisSelected) {
|
|
1001
1003
|
ctx.fillStyle = colors.axisSelectionFill;
|
|
1002
1004
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
1003
1005
|
}
|
|
@@ -1042,14 +1044,14 @@ function paintGrid(options) {
|
|
|
1042
1044
|
ctx.fillRect(x, y + cellHeight - 1, cellWidth, 1);
|
|
1043
1045
|
}
|
|
1044
1046
|
if (rowSpan > 1) {
|
|
1045
|
-
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);
|
|
1046
1048
|
ctx.fillStyle = mergedFill;
|
|
1047
1049
|
for (let offset = 1; offset < rowSpan; offset += 1) {
|
|
1048
1050
|
ctx.fillRect(x, y + offset * rowHeight - 1, cellWidth, 2);
|
|
1049
1051
|
}
|
|
1050
1052
|
}
|
|
1051
1053
|
if (colSpan > 1 && !verticalBorderless) {
|
|
1052
|
-
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);
|
|
1053
1055
|
ctx.fillStyle = mergedFill;
|
|
1054
1056
|
let offsetLeft = 0;
|
|
1055
1057
|
for (let offset = 1; offset < colSpan; offset += 1) {
|
|
@@ -1083,7 +1085,8 @@ function paintGrid(options) {
|
|
|
1083
1085
|
const checked = selectedRowKeys.has(rowKey);
|
|
1084
1086
|
ctx.save();
|
|
1085
1087
|
ctx.lineWidth = 1;
|
|
1086
|
-
if (column.rowSelectionIndicator === "
|
|
1088
|
+
if (column.rowSelectionIndicator === "none") {
|
|
1089
|
+
} else if (column.rowSelectionIndicator === "arrow") {
|
|
1087
1090
|
if (checked) {
|
|
1088
1091
|
ctx.beginPath();
|
|
1089
1092
|
ctx.moveTo(iconLeft + 3.5, iconTop + 8);
|
|
@@ -1091,7 +1094,7 @@ function paintGrid(options) {
|
|
|
1091
1094
|
ctx.moveTo(iconLeft + 8.5, iconTop + 4);
|
|
1092
1095
|
ctx.lineTo(iconLeft + 12.5, iconTop + 8);
|
|
1093
1096
|
ctx.lineTo(iconLeft + 8.5, iconTop + 12);
|
|
1094
|
-
ctx.strokeStyle = colors.
|
|
1097
|
+
ctx.strokeStyle = colors.axisSelectionText;
|
|
1095
1098
|
ctx.lineWidth = 1.75;
|
|
1096
1099
|
ctx.lineCap = "round";
|
|
1097
1100
|
ctx.lineJoin = "round";
|
|
@@ -1145,7 +1148,7 @@ function paintGrid(options) {
|
|
|
1145
1148
|
ctx.beginPath();
|
|
1146
1149
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1147
1150
|
ctx.clip();
|
|
1148
|
-
ctx.fillStyle =
|
|
1151
|
+
ctx.fillStyle = isAxisSelected && !isSelectedCell && !isRangeCell ? colors.axisSelectionText : cellStyle?.color ?? colors.text;
|
|
1149
1152
|
ctx.font = createCellFont(bodyFontSize);
|
|
1150
1153
|
ctx.textBaseline = "alphabetic";
|
|
1151
1154
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1169,9 +1172,25 @@ function paintGrid(options) {
|
|
|
1169
1172
|
paintBodyColumns("scroll");
|
|
1170
1173
|
paintBodyColumns("left");
|
|
1171
1174
|
paintBodyColumns("right");
|
|
1172
|
-
if (extendVerticalGridLines
|
|
1175
|
+
if (extendVerticalGridLines) {
|
|
1173
1176
|
const extensionTop = Math.max(bodyTop, Math.min(height, bodyTop + rows.length * rowHeight - scrollTop));
|
|
1174
1177
|
const extensionHeight = Math.max(0, height - extensionTop);
|
|
1178
|
+
const paintExtendedColumnSelection = (layer) => {
|
|
1179
|
+
ctx.save();
|
|
1180
|
+
if (layer === "scroll") {
|
|
1181
|
+
ctx.beginPath();
|
|
1182
|
+
ctx.rect(leftFixedWidth, extensionTop, Math.max(0, rightFixedLeft - leftFixedWidth), extensionHeight);
|
|
1183
|
+
ctx.clip();
|
|
1184
|
+
}
|
|
1185
|
+
ctx.fillStyle = colors.axisSelectionFill;
|
|
1186
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex += 1) {
|
|
1187
|
+
if (!selectedColumnKeys.has(columns[columnIndex].key)) continue;
|
|
1188
|
+
if (layer === "scroll" ? columns[columnIndex].fixed !== void 0 : columns[columnIndex].fixed !== layer) continue;
|
|
1189
|
+
if (layer === "scroll" && (columnIndex < range.columnStart || columnIndex >= range.columnEnd)) continue;
|
|
1190
|
+
ctx.fillRect(getColumnX(columnIndex), extensionTop, metrics[columnIndex].width, extensionHeight);
|
|
1191
|
+
}
|
|
1192
|
+
ctx.restore();
|
|
1193
|
+
};
|
|
1175
1194
|
const paintExtendedColumnLines = (layer) => {
|
|
1176
1195
|
ctx.save();
|
|
1177
1196
|
if (layer === "scroll") {
|
|
@@ -1189,9 +1208,14 @@ function paintGrid(options) {
|
|
|
1189
1208
|
}
|
|
1190
1209
|
ctx.restore();
|
|
1191
1210
|
};
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1211
|
+
paintExtendedColumnSelection("scroll");
|
|
1212
|
+
paintExtendedColumnSelection("left");
|
|
1213
|
+
paintExtendedColumnSelection("right");
|
|
1214
|
+
if (!verticalBorderless) {
|
|
1215
|
+
paintExtendedColumnLines("scroll");
|
|
1216
|
+
paintExtendedColumnLines("left");
|
|
1217
|
+
paintExtendedColumnLines("right");
|
|
1218
|
+
}
|
|
1195
1219
|
}
|
|
1196
1220
|
const headerY = fixedHeader ? 0 : -scrollTop;
|
|
1197
1221
|
ctx.fillStyle = colors.header;
|
|
@@ -1207,8 +1231,9 @@ function paintGrid(options) {
|
|
|
1207
1231
|
ctx.fillStyle = colors.header;
|
|
1208
1232
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1209
1233
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1234
|
+
const isAxisSelected = selectedColumnKeys.has(columns[columnIndex].key);
|
|
1235
|
+
if (isAxisSelected) {
|
|
1236
|
+
ctx.fillStyle = colors.axisSelectionFill;
|
|
1212
1237
|
ctx.fillRect(x, headerY, metric.width, headerHeight);
|
|
1213
1238
|
}
|
|
1214
1239
|
if (columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex) {
|
|
@@ -1240,7 +1265,7 @@ function paintGrid(options) {
|
|
|
1240
1265
|
ctx.beginPath();
|
|
1241
1266
|
ctx.rect(x + 2, headerY + headerLeafTop + 1, Math.max(0, clipWidth - 4), headerLeafHeight - 2);
|
|
1242
1267
|
ctx.clip();
|
|
1243
|
-
ctx.fillStyle = colors.muted;
|
|
1268
|
+
ctx.fillStyle = isAxisSelected ? colors.axisSelectionText : colors.muted;
|
|
1244
1269
|
ctx.textAlign = titleAlign === "right" ? "right" : titleAlign === "center" ? "center" : "left";
|
|
1245
1270
|
ctx.fillText(title, textX, headerY + headerLeafTop + headerLeafHeight / 2);
|
|
1246
1271
|
ctx.restore();
|
|
@@ -2246,6 +2271,7 @@ function TableInner({
|
|
|
2246
2271
|
selection: readThemeColor(themeStyles, "--rvg-color-primary", "#1677ff"),
|
|
2247
2272
|
selectionFill: readThemeColor(themeStyles, "--rvg-color-selection-fill", "#edf4ff"),
|
|
2248
2273
|
axisSelectionFill: readThemeColor(themeStyles, "--rvg-color-axis-selection-fill", "#e8f2ff"),
|
|
2274
|
+
axisSelectionText: readThemeColor(themeStyles, "--rvg-color-axis-selection-text", readThemeColor(themeStyles, "--rvg-color-text", "#202124")),
|
|
2249
2275
|
rowHoverFill: readThemeColor(themeStyles, "--rvg-color-row-hover-fill", "#f6f9fc"),
|
|
2250
2276
|
editedFill: editedCellHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-edited-fill", "#fff1b8"),
|
|
2251
2277
|
insertedFill: insertedRowHighlightColor ?? readThemeColor(themeStyles, "--rvg-color-inserted-fill", "#c8ead4"),
|
|
@@ -3345,6 +3371,9 @@ function TableInner({
|
|
|
3345
3371
|
}, [setSelection]);
|
|
3346
3372
|
const selectRow = useCallback2((rowIndex, event, forceToggle = false) => {
|
|
3347
3373
|
if (!rowSelection) return;
|
|
3374
|
+
clickedCellRef.current = null;
|
|
3375
|
+
setSelectionRange(null);
|
|
3376
|
+
setSelection(null);
|
|
3348
3377
|
const mode = typeof rowSelection === "object" ? rowSelection.mode ?? "multiple" : "multiple";
|
|
3349
3378
|
const key = getRowKey(rows[rowIndex], rowIndex);
|
|
3350
3379
|
let next;
|
|
@@ -3359,9 +3388,12 @@ function TableInner({
|
|
|
3359
3388
|
}
|
|
3360
3389
|
rowAnchorRef.current = rowIndex;
|
|
3361
3390
|
setRowKeys(next);
|
|
3362
|
-
}, [getRowKey, rowKeys, rowSelection, rows, selectedRowKeySet, setRowKeys]);
|
|
3391
|
+
}, [getRowKey, rowKeys, rowSelection, rows, selectedRowKeySet, setRowKeys, setSelection]);
|
|
3363
3392
|
const selectColumn = useCallback2((columnIndex, event) => {
|
|
3364
3393
|
if (!columnSelection || columnIndex < 0) return;
|
|
3394
|
+
clickedCellRef.current = null;
|
|
3395
|
+
setSelectionRange(null);
|
|
3396
|
+
setSelection(null);
|
|
3365
3397
|
const mode = typeof columnSelection === "object" ? columnSelection.mode ?? "multiple" : "multiple";
|
|
3366
3398
|
const key = columns[columnIndex].key;
|
|
3367
3399
|
let next;
|
|
@@ -3369,23 +3401,26 @@ function TableInner({
|
|
|
3369
3401
|
const start = Math.min(columnAnchorRef.current, columnIndex);
|
|
3370
3402
|
const end = Math.max(columnAnchorRef.current, columnIndex);
|
|
3371
3403
|
next = columns.slice(start, end + 1).map((column) => column.key);
|
|
3372
|
-
} else if (mode === "multiple") {
|
|
3404
|
+
} else if (mode === "multiple" && (event.ctrlKey || event.metaKey)) {
|
|
3373
3405
|
next = selectedColumnKeySet.has(key) ? columnKeys.filter((item) => item !== key) : [...columnKeys, key];
|
|
3374
3406
|
} else {
|
|
3375
3407
|
next = columnKeys.length === 1 && selectedColumnKeySet.has(key) ? [] : [key];
|
|
3376
3408
|
}
|
|
3377
3409
|
columnAnchorRef.current = columnIndex;
|
|
3378
3410
|
setColumnKeys(next);
|
|
3379
|
-
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys]);
|
|
3411
|
+
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys, setSelection]);
|
|
3380
3412
|
const toggleColumnFromMenu = useCallback2((columnIndex) => {
|
|
3381
3413
|
if (!columnSelection || columnIndex < 0) return;
|
|
3414
|
+
clickedCellRef.current = null;
|
|
3415
|
+
setSelectionRange(null);
|
|
3416
|
+
setSelection(null);
|
|
3382
3417
|
const key = columns[columnIndex].key;
|
|
3383
3418
|
const mode = typeof columnSelection === "object" ? columnSelection.mode ?? "multiple" : "multiple";
|
|
3384
3419
|
const selected = selectedColumnKeySet.has(key);
|
|
3385
3420
|
const next = selected ? columnKeys.filter((value) => value !== key) : mode === "multiple" ? [...columnKeys, key] : [key];
|
|
3386
3421
|
columnAnchorRef.current = columnIndex;
|
|
3387
3422
|
setColumnKeys(next);
|
|
3388
|
-
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys]);
|
|
3423
|
+
}, [columnKeys, columnSelection, columns, selectedColumnKeySet, setColumnKeys, setSelection]);
|
|
3389
3424
|
const revealCell = useCallback2((cell) => {
|
|
3390
3425
|
const scroller = scrollerRef.current;
|
|
3391
3426
|
const metric = metrics[cell.columnIndex];
|
|
@@ -3737,6 +3772,8 @@ function TableInner({
|
|
|
3737
3772
|
const renderHeaderIcons = (columnIndex, left) => {
|
|
3738
3773
|
const column = columns[columnIndex];
|
|
3739
3774
|
if (column.rowSelection || column.rowDragHandle || column.rowNumber) return null;
|
|
3775
|
+
const isAxisSelected = selectedColumnKeySet.has(column.key);
|
|
3776
|
+
const selectedClassName = isAxisSelected ? " is-axis-selected" : "";
|
|
3740
3777
|
const top = headerLeafTop + (headerLeafHeight - headerActionSize) / 2;
|
|
3741
3778
|
const visibleActions = getVisibleHeaderActions(column, metrics[columnIndex].width, columnDraggable, measureHeaderTitleWidth(columnIndex), headerActionSlotWidth);
|
|
3742
3779
|
let right = left + metrics[columnIndex].width - (visibleActions.drag ? headerActionSlotWidth : 2);
|
|
@@ -3744,21 +3781,21 @@ function TableInner({
|
|
|
3744
3781
|
if (visibleActions.drag) {
|
|
3745
3782
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "drag";
|
|
3746
3783
|
icons.push(
|
|
3747
|
-
/* @__PURE__ */ jsx7(HeaderDragIcon, { className: `rvg-header-icon rvg-header-drag-icon${hovered ? " is-hovered" : ""}`, style: { left: left + metrics[columnIndex].width - headerActionSlotWidth, top } }, "drag")
|
|
3784
|
+
/* @__PURE__ */ jsx7(HeaderDragIcon, { className: `rvg-header-icon rvg-header-drag-icon${selectedClassName}${hovered ? " is-hovered" : ""}`, style: { left: left + metrics[columnIndex].width - headerActionSlotWidth, top } }, "drag")
|
|
3748
3785
|
);
|
|
3749
3786
|
}
|
|
3750
3787
|
if (visibleActions.sort) {
|
|
3751
3788
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "sort";
|
|
3752
3789
|
const direction = sortState?.columnKey === column.key ? sortState.direction : null;
|
|
3753
3790
|
icons.push(
|
|
3754
|
-
/* @__PURE__ */ jsx7(HeaderSortIcon, { className: `rvg-header-icon${hovered ? " is-hovered" : ""}`, style: { left: right - headerActionSlotWidth, top }, direction }, "sort")
|
|
3791
|
+
/* @__PURE__ */ jsx7(HeaderSortIcon, { className: `rvg-header-icon${selectedClassName}${hovered ? " is-hovered" : ""}`, style: { left: right - headerActionSlotWidth, top }, direction }, "sort")
|
|
3755
3792
|
);
|
|
3756
3793
|
right -= headerActionSlotWidth;
|
|
3757
3794
|
}
|
|
3758
3795
|
if (visibleActions.filter) {
|
|
3759
3796
|
const hovered = hoveredHeaderAction?.columnIndex === columnIndex && hoveredHeaderAction.action === "filter";
|
|
3760
3797
|
icons.push(
|
|
3761
|
-
/* @__PURE__ */ jsx7(HeaderSearchIcon, { className: `rvg-header-icon rvg-header-search-icon${hovered ? " is-hovered" : ""}${filterValues[column.key] ? " is-active" : ""}`, style: { left: right - headerActionSlotWidth, top: top + 1 } }, "filter")
|
|
3798
|
+
/* @__PURE__ */ jsx7(HeaderSearchIcon, { className: `rvg-header-icon rvg-header-search-icon${selectedClassName}${hovered ? " is-hovered" : ""}${filterValues[column.key] ? " is-active" : ""}`, style: { left: right - headerActionSlotWidth, top: top + 1 } }, "filter")
|
|
3762
3799
|
);
|
|
3763
3800
|
}
|
|
3764
3801
|
return icons;
|
|
@@ -4119,7 +4156,7 @@ function TableInner({
|
|
|
4119
4156
|
return /* @__PURE__ */ jsx7(
|
|
4120
4157
|
"div",
|
|
4121
4158
|
{
|
|
4122
|
-
className:
|
|
4159
|
+
className: `rvg-cell-render${selectedRowKeySet.has(getRowKey(row, rowIndex)) || selectedColumnKeySet.has(column.key) ? " is-axis-selected" : ""}`,
|
|
4123
4160
|
style: {
|
|
4124
4161
|
left,
|
|
4125
4162
|
top,
|
|
@@ -4138,6 +4175,7 @@ function TableInner({
|
|
|
4138
4175
|
};
|
|
4139
4176
|
const renderHeaderTitle = (columnIndex, left) => {
|
|
4140
4177
|
const column = columns[columnIndex];
|
|
4178
|
+
const isAxisSelected = selectedColumnKeySet.has(column.key);
|
|
4141
4179
|
const isDropTarget = Boolean(columnDropTarget && columnIndex >= columnDropTarget.startIndex && columnIndex <= columnDropTarget.endIndex);
|
|
4142
4180
|
const currentScrollTop = scrollRef.current.top;
|
|
4143
4181
|
const headerTop = fixedHeader ? 0 : -currentScrollTop;
|
|
@@ -4154,7 +4192,7 @@ function TableInner({
|
|
|
4154
4192
|
);
|
|
4155
4193
|
}
|
|
4156
4194
|
if (column.rowSelection) {
|
|
4157
|
-
if (rowSelectionMode === "single" || column.rowSelectionIndicator === "arrow") return null;
|
|
4195
|
+
if (rowSelectionMode === "single" || column.rowSelectionIndicator === "arrow" || column.rowSelectionIndicator === "none") return null;
|
|
4158
4196
|
const allSelected = rows.length > 0 && selectedRowKeySet.size === rows.length;
|
|
4159
4197
|
const indeterminate = selectedRowKeySet.size > 0 && !allSelected;
|
|
4160
4198
|
return /* @__PURE__ */ jsx7(
|
|
@@ -4173,7 +4211,7 @@ function TableInner({
|
|
|
4173
4211
|
return /* @__PURE__ */ jsx7(
|
|
4174
4212
|
"div",
|
|
4175
4213
|
{
|
|
4176
|
-
className: `rvg-header-title is-custom${isDropTarget ? " is-drop-target" : ""}`,
|
|
4214
|
+
className: `rvg-header-title is-custom${isAxisSelected ? " is-axis-selected" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
4177
4215
|
"data-level": headerDepth - 1,
|
|
4178
4216
|
"data-measure-key": column.key,
|
|
4179
4217
|
style: {
|
|
@@ -4216,10 +4254,11 @@ function TableInner({
|
|
|
4216
4254
|
const visibleActions = cell.leaf ? getVisibleHeaderActions(column, startMetric.width, columnDraggable, measureHeaderTitleWidth(cell.startIndex), headerActionSlotWidth) : null;
|
|
4217
4255
|
const actionWidth = visibleActions ? (Number(visibleActions.drag) + Number(visibleActions.filter) + Number(visibleActions.sort)) * headerActionSlotWidth : columnDraggable && !cell.leaf ? headerActionSlotWidth : 0;
|
|
4218
4256
|
const isDropTarget = Boolean(columnDropTarget && cell.endIndex >= columnDropTarget.startIndex && cell.startIndex <= columnDropTarget.endIndex);
|
|
4257
|
+
const isAxisSelected = cell.leaf && selectedColumnKeySet.has(column.key);
|
|
4219
4258
|
return /* @__PURE__ */ jsxs7(
|
|
4220
4259
|
"div",
|
|
4221
4260
|
{
|
|
4222
|
-
className: `rvg-header-title rvg-header-group${column.renderHeader ? " is-custom" : ""}${cell.leaf ? " is-leaf" : ""}${cell.endIndex === columns.length - 1 ? " is-frame-right" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
4261
|
+
className: `rvg-header-title rvg-header-group${column.renderHeader ? " is-custom" : ""}${cell.leaf ? " is-leaf" : ""}${isAxisSelected ? " is-axis-selected" : ""}${cell.endIndex === columns.length - 1 ? " is-frame-right" : ""}${isDropTarget ? " is-drop-target" : ""}`,
|
|
4223
4262
|
"data-level": cell.level,
|
|
4224
4263
|
"data-measure-key": `group:${cell.key}:${cell.level}`,
|
|
4225
4264
|
style: {
|
|
@@ -4483,12 +4522,16 @@ function TableInner({
|
|
|
4483
4522
|
getSelectedRows: () => rows.filter((row, index) => selectedRowKeySet.has(getRowKey(row, index))),
|
|
4484
4523
|
setSelectedRowKeys: (keys) => {
|
|
4485
4524
|
if (!rowSelection) return;
|
|
4525
|
+
setSelectionRange(null);
|
|
4526
|
+
setSelection(null);
|
|
4486
4527
|
const next = [...new Set(keys)];
|
|
4487
4528
|
setRowKeys(rowSelectionMode === "single" ? next.slice(0, 1) : next);
|
|
4488
4529
|
},
|
|
4489
4530
|
getSelectedColumnKeys: () => [...columnKeys],
|
|
4490
4531
|
setSelectedColumnKeys: (keys) => {
|
|
4491
4532
|
if (!columnSelection) return;
|
|
4533
|
+
setSelectionRange(null);
|
|
4534
|
+
setSelection(null);
|
|
4492
4535
|
const next = [...new Set(keys)].filter((key) => columns.some((column) => column.key === key && !column.rowNumber && !column.rowSelection && !column.rowDragHandle));
|
|
4493
4536
|
setColumnKeys(typeof columnSelection === "object" && columnSelection.mode === "single" ? next.slice(0, 1) : next);
|
|
4494
4537
|
},
|
|
@@ -4691,7 +4734,9 @@ function TableInner({
|
|
|
4691
4734
|
}
|
|
4692
4735
|
if (locateHeaderDragHandle(event.clientX, columnIndex)) return;
|
|
4693
4736
|
if (columnIndex >= 0 && columns[columnIndex].rowSelection && rowSelection) {
|
|
4694
|
-
if (columns[columnIndex].rowSelectionIndicator === "arrow") return;
|
|
4737
|
+
if (columns[columnIndex].rowSelectionIndicator === "arrow" || columns[columnIndex].rowSelectionIndicator === "none") return;
|
|
4738
|
+
setSelectionRange(null);
|
|
4739
|
+
setSelection(null);
|
|
4695
4740
|
setRowKeys(rowKeys.length === rows.length ? [] : rows.map(getRowKey));
|
|
4696
4741
|
} else if (columnIndex >= 0 && (columns[columnIndex].rowDragHandle || columns[columnIndex].rowNumber)) {
|
|
4697
4742
|
return;
|
|
@@ -4710,7 +4755,7 @@ function TableInner({
|
|
|
4710
4755
|
const clickedRowSelector = Boolean(columns[cell.columnIndex].rowSelection);
|
|
4711
4756
|
if (clickedRowSelector) {
|
|
4712
4757
|
clickedCellRef.current = null;
|
|
4713
|
-
selectRow(cell.rowIndex, event, columns[cell.columnIndex].rowSelectionIndicator
|
|
4758
|
+
selectRow(cell.rowIndex, event, !["arrow", "none"].includes(columns[cell.columnIndex].rowSelectionIndicator ?? "checkbox"));
|
|
4714
4759
|
return;
|
|
4715
4760
|
}
|
|
4716
4761
|
if (event.detail > 1) return;
|
|
@@ -5009,6 +5054,8 @@ function TableInner({
|
|
|
5009
5054
|
if (item === "select-row") {
|
|
5010
5055
|
if (!rowSelection) return null;
|
|
5011
5056
|
return renderContextMenuButton("cell-select-row", cellContext, selectedRowKeySet.has(cell.rowKey) ? labels.deselectRow : labels.selectRow, () => {
|
|
5057
|
+
setSelectionRange(null);
|
|
5058
|
+
setSelection(null);
|
|
5012
5059
|
if (selectedRowKeySet.has(cell.rowKey)) setRowKeys(rowKeys.filter((key) => key !== cell.rowKey));
|
|
5013
5060
|
else setRowKeys(rowSelectionMode === "single" ? [cell.rowKey] : [...rowKeys, cell.rowKey]);
|
|
5014
5061
|
}, override, { icon: /* @__PURE__ */ jsx7(ContextMenuIcon, { type: "select-row" }) });
|