@lensui/lens-table 0.1.12 → 0.1.14
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/dist/index.cjs +28 -4
- package/dist/index.js +28 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -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, bodyFontSize, headerActionSlotWidth, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, frameBorderless, 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, headerActionSlotWidth, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, frameBorderless, extendVerticalGridLines, 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 };
|
|
@@ -1160,7 +1160,7 @@ function paintGrid(options) {
|
|
|
1160
1160
|
ctx.beginPath();
|
|
1161
1161
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1162
1162
|
ctx.clip();
|
|
1163
|
-
ctx.fillStyle = cellStyle?.color ?? colors.text;
|
|
1163
|
+
ctx.fillStyle = column.rowNumber && selectedRowKeys.has(rowKey) ? colors.selection : cellStyle?.color ?? colors.text;
|
|
1164
1164
|
ctx.font = createCellFont(bodyFontSize);
|
|
1165
1165
|
ctx.textBaseline = "alphabetic";
|
|
1166
1166
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1184,6 +1184,30 @@ function paintGrid(options) {
|
|
|
1184
1184
|
paintBodyColumns("scroll");
|
|
1185
1185
|
paintBodyColumns("left");
|
|
1186
1186
|
paintBodyColumns("right");
|
|
1187
|
+
if (extendVerticalGridLines && !verticalBorderless) {
|
|
1188
|
+
const extensionTop = Math.max(bodyTop, Math.min(height, bodyTop + rows.length * rowHeight - scrollTop));
|
|
1189
|
+
const extensionHeight = Math.max(0, height - extensionTop);
|
|
1190
|
+
const paintExtendedColumnLines = (layer) => {
|
|
1191
|
+
ctx.save();
|
|
1192
|
+
if (layer === "scroll") {
|
|
1193
|
+
ctx.beginPath();
|
|
1194
|
+
ctx.rect(leftFixedWidth, extensionTop, Math.max(0, rightFixedLeft - leftFixedWidth), extensionHeight);
|
|
1195
|
+
ctx.clip();
|
|
1196
|
+
}
|
|
1197
|
+
ctx.fillStyle = colors.grid;
|
|
1198
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex += 1) {
|
|
1199
|
+
if (layer === "scroll" ? columns[columnIndex].fixed !== void 0 : columns[columnIndex].fixed !== layer) continue;
|
|
1200
|
+
if (layer === "scroll" && (columnIndex < range.columnStart || columnIndex >= range.columnEnd)) continue;
|
|
1201
|
+
if (frameBorderless && columnIndex === columns.length - 1) continue;
|
|
1202
|
+
const x = getColumnX(columnIndex) + metrics[columnIndex].width - 1;
|
|
1203
|
+
ctx.fillRect(x, extensionTop, 1, extensionHeight);
|
|
1204
|
+
}
|
|
1205
|
+
ctx.restore();
|
|
1206
|
+
};
|
|
1207
|
+
paintExtendedColumnLines("scroll");
|
|
1208
|
+
paintExtendedColumnLines("left");
|
|
1209
|
+
paintExtendedColumnLines("right");
|
|
1210
|
+
}
|
|
1187
1211
|
const headerY = fixedHeader ? 0 : -scrollTop;
|
|
1188
1212
|
ctx.fillStyle = colors.header;
|
|
1189
1213
|
ctx.fillRect(0, headerY, width, headerHeight);
|
|
@@ -2244,8 +2268,8 @@ function TableInner({
|
|
|
2244
2268
|
const scroll = scrollRef.current;
|
|
2245
2269
|
const rowScrollTop = fixedHeader ? scroll.top : Math.max(0, scroll.top - bodyTop);
|
|
2246
2270
|
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 };
|
|
2247
|
-
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, bodyFontSize, headerActionSlotWidth, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, frameBorderless, 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 });
|
|
2248
|
-
}, [bodyTop, bodyViewportHeight, bottomSummaryHeight, cellAnnotations, cellSpanLookup, columnDraggable, columnDropTarget, columns, editedCellHighlightColor, editedCellKeys, editing, renderHeight, filterValues, fixedHeader, frameBorderless, getRowKey, hasStripedRows, hasVerticalBorders, headerActionSlotWidth, headerDepth, headerHeight, headerLeafHeight, headerLeafTop, horizontalBorderless, highlightsEditedCells, highlightsInsertedRows, insertedRowHighlightColor, insertedRowKeySet, isVirtualized, metrics, rowDragPreview, rowHeight, rowSelectionMode, rows, selectedColumnKeySet, selectedRowKeySet, selection, selectionRange, sortState, stripedColor, viewport.width, virtualOverscan]);
|
|
2271
|
+
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, bodyFontSize, headerActionSlotWidth, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, frameBorderless, extendVerticalGridLines: !autoHeight, 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 });
|
|
2272
|
+
}, [autoHeight, bodyTop, bodyViewportHeight, bottomSummaryHeight, cellAnnotations, cellSpanLookup, columnDraggable, columnDropTarget, columns, editedCellHighlightColor, editedCellKeys, editing, renderHeight, filterValues, fixedHeader, frameBorderless, getRowKey, hasStripedRows, hasVerticalBorders, headerActionSlotWidth, headerDepth, headerHeight, headerLeafHeight, headerLeafTop, horizontalBorderless, highlightsEditedCells, highlightsInsertedRows, insertedRowHighlightColor, insertedRowKeySet, isVirtualized, metrics, rowDragPreview, rowHeight, rowSelectionMode, rows, selectedColumnKeySet, selectedRowKeySet, selection, selectionRange, sortState, stripedColor, viewport.width, virtualOverscan]);
|
|
2249
2273
|
const scheduleDraw = (0, import_react5.useCallback)(() => {
|
|
2250
2274
|
if (frameRef.current === null) frameRef.current = requestAnimationFrame(draw);
|
|
2251
2275
|
}, [draw]);
|
package/dist/index.js
CHANGED
|
@@ -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, bodyFontSize, headerActionSlotWidth, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, frameBorderless, 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, headerActionSlotWidth, headerHeight, fixedHeader, verticalBorderless, horizontalBorderless, frameBorderless, extendVerticalGridLines, 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 };
|
|
@@ -1130,7 +1130,7 @@ function paintGrid(options) {
|
|
|
1130
1130
|
ctx.beginPath();
|
|
1131
1131
|
ctx.rect(x + 2, y + 1, Math.max(0, cellWidth - 4), cellHeight - 2);
|
|
1132
1132
|
ctx.clip();
|
|
1133
|
-
ctx.fillStyle = cellStyle?.color ?? colors.text;
|
|
1133
|
+
ctx.fillStyle = column.rowNumber && selectedRowKeys.has(rowKey) ? colors.selection : cellStyle?.color ?? colors.text;
|
|
1134
1134
|
ctx.font = createCellFont(bodyFontSize);
|
|
1135
1135
|
ctx.textBaseline = "alphabetic";
|
|
1136
1136
|
ctx.textAlign = column.align === "right" ? "right" : column.align === "center" ? "center" : "left";
|
|
@@ -1154,6 +1154,30 @@ function paintGrid(options) {
|
|
|
1154
1154
|
paintBodyColumns("scroll");
|
|
1155
1155
|
paintBodyColumns("left");
|
|
1156
1156
|
paintBodyColumns("right");
|
|
1157
|
+
if (extendVerticalGridLines && !verticalBorderless) {
|
|
1158
|
+
const extensionTop = Math.max(bodyTop, Math.min(height, bodyTop + rows.length * rowHeight - scrollTop));
|
|
1159
|
+
const extensionHeight = Math.max(0, height - extensionTop);
|
|
1160
|
+
const paintExtendedColumnLines = (layer) => {
|
|
1161
|
+
ctx.save();
|
|
1162
|
+
if (layer === "scroll") {
|
|
1163
|
+
ctx.beginPath();
|
|
1164
|
+
ctx.rect(leftFixedWidth, extensionTop, Math.max(0, rightFixedLeft - leftFixedWidth), extensionHeight);
|
|
1165
|
+
ctx.clip();
|
|
1166
|
+
}
|
|
1167
|
+
ctx.fillStyle = colors.grid;
|
|
1168
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex += 1) {
|
|
1169
|
+
if (layer === "scroll" ? columns[columnIndex].fixed !== void 0 : columns[columnIndex].fixed !== layer) continue;
|
|
1170
|
+
if (layer === "scroll" && (columnIndex < range.columnStart || columnIndex >= range.columnEnd)) continue;
|
|
1171
|
+
if (frameBorderless && columnIndex === columns.length - 1) continue;
|
|
1172
|
+
const x = getColumnX(columnIndex) + metrics[columnIndex].width - 1;
|
|
1173
|
+
ctx.fillRect(x, extensionTop, 1, extensionHeight);
|
|
1174
|
+
}
|
|
1175
|
+
ctx.restore();
|
|
1176
|
+
};
|
|
1177
|
+
paintExtendedColumnLines("scroll");
|
|
1178
|
+
paintExtendedColumnLines("left");
|
|
1179
|
+
paintExtendedColumnLines("right");
|
|
1180
|
+
}
|
|
1157
1181
|
const headerY = fixedHeader ? 0 : -scrollTop;
|
|
1158
1182
|
ctx.fillStyle = colors.header;
|
|
1159
1183
|
ctx.fillRect(0, headerY, width, headerHeight);
|
|
@@ -2214,8 +2238,8 @@ function TableInner({
|
|
|
2214
2238
|
const scroll = scrollRef.current;
|
|
2215
2239
|
const rowScrollTop = fixedHeader ? scroll.top : Math.max(0, scroll.top - bodyTop);
|
|
2216
2240
|
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 };
|
|
2217
|
-
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, bodyFontSize, headerActionSlotWidth, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, frameBorderless, 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 });
|
|
2218
|
-
}, [bodyTop, bodyViewportHeight, bottomSummaryHeight, cellAnnotations, cellSpanLookup, columnDraggable, columnDropTarget, columns, editedCellHighlightColor, editedCellKeys, editing, renderHeight, filterValues, fixedHeader, frameBorderless, getRowKey, hasStripedRows, hasVerticalBorders, headerActionSlotWidth, headerDepth, headerHeight, headerLeafHeight, headerLeafTop, horizontalBorderless, highlightsEditedCells, highlightsInsertedRows, insertedRowHighlightColor, insertedRowKeySet, isVirtualized, metrics, rowDragPreview, rowHeight, rowSelectionMode, rows, selectedColumnKeySet, selectedRowKeySet, selection, selectionRange, sortState, stripedColor, viewport.width, virtualOverscan]);
|
|
2241
|
+
paintGrid({ context, width: viewport.width, height: renderHeight, pixelRatio: ratio, scrollLeft: scroll.left, scrollTop: scroll.top, rowHeight, bodyFontSize, headerActionSlotWidth, headerHeight, headerLeafTop, headerLeafHeight, bodyTop, suppressLastRowBottomBorder: bottomSummaryHeight > 0, suppressFrameBottomBorder: bottomSummaryHeight > 0, fixedHeader, verticalBorderless: !hasVerticalBorders, horizontalBorderless, frameBorderless, extendVerticalGridLines: !autoHeight, 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 });
|
|
2242
|
+
}, [autoHeight, bodyTop, bodyViewportHeight, bottomSummaryHeight, cellAnnotations, cellSpanLookup, columnDraggable, columnDropTarget, columns, editedCellHighlightColor, editedCellKeys, editing, renderHeight, filterValues, fixedHeader, frameBorderless, getRowKey, hasStripedRows, hasVerticalBorders, headerActionSlotWidth, headerDepth, headerHeight, headerLeafHeight, headerLeafTop, horizontalBorderless, highlightsEditedCells, highlightsInsertedRows, insertedRowHighlightColor, insertedRowKeySet, isVirtualized, metrics, rowDragPreview, rowHeight, rowSelectionMode, rows, selectedColumnKeySet, selectedRowKeySet, selection, selectionRange, sortState, stripedColor, viewport.width, virtualOverscan]);
|
|
2219
2243
|
const scheduleDraw = useCallback2(() => {
|
|
2220
2244
|
if (frameRef.current === null) frameRef.current = requestAnimationFrame(draw);
|
|
2221
2245
|
}, [draw]);
|