@lensui/lens-table 0.1.69 → 0.1.70
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 +30 -14
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +30 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -990,8 +990,8 @@ function getVisibleHeaderActions(column, width, columnDraggable = false, titleWi
|
|
|
990
990
|
return { filter: visible.has("filter"), sort: visible.has("sort"), drag: visible.has("drag") };
|
|
991
991
|
}
|
|
992
992
|
function getMinimumColumnWidth(column, columnDraggable = false) {
|
|
993
|
-
if (column.rowDragHandle) return 36;
|
|
994
993
|
if (column.rowSelection) return Math.max(24, column.width ?? 44);
|
|
994
|
+
if (column.rowDragHandle) return 36;
|
|
995
995
|
if (column.rowNumber) return 44;
|
|
996
996
|
return 60;
|
|
997
997
|
}
|
|
@@ -1283,7 +1283,7 @@ function paintGrid(options) {
|
|
|
1283
1283
|
if (columnIndex === rangeColumnStart) ctx.fillRect(x, y, 2, cellHeight);
|
|
1284
1284
|
if (columnIndex === rangeColumnEnd) ctx.fillRect(x + cellWidth - 2, y, 2, cellHeight);
|
|
1285
1285
|
}
|
|
1286
|
-
if (column.rowDragHandle) {
|
|
1286
|
+
if (column.rowDragHandle && !column.rowSelection) {
|
|
1287
1287
|
const iconLeft = x + (cellWidth - 16) / 2;
|
|
1288
1288
|
const iconTop = y + (cellHeight - 16) / 2;
|
|
1289
1289
|
ctx.fillStyle = isAxisSelected ? colors.axisSelectionText : colors.icon;
|
|
@@ -1874,6 +1874,7 @@ function TableInner({
|
|
|
1874
1874
|
onColumnsReorder,
|
|
1875
1875
|
onColumnResize,
|
|
1876
1876
|
rowDraggable = false,
|
|
1877
|
+
combineRowSelectionAndDrag = false,
|
|
1877
1878
|
utilityColumnOrder = ["drag", "selection", "rowNumber"],
|
|
1878
1879
|
onRowsReorder,
|
|
1879
1880
|
onInsertRows,
|
|
@@ -1942,6 +1943,7 @@ function TableInner({
|
|
|
1942
1943
|
const showRowCheckbox = Boolean(rowSelection) && (typeof rowSelection !== "object" || rowSelection.showCheckbox !== false);
|
|
1943
1944
|
const rowSelectionIndicator = typeof rowSelection === "object" ? rowSelection.indicator ?? "checkbox" : "checkbox";
|
|
1944
1945
|
const rowSelectionColumnWidth = typeof rowSelection === "object" ? Math.max(24, rowSelection.columnWidth ?? 44) : 44;
|
|
1946
|
+
const hasCombinedRowUtility = combineRowSelectionAndDrag && rowDraggable && showRowCheckbox;
|
|
1945
1947
|
(0, import_react8.useEffect)(() => {
|
|
1946
1948
|
if (!isProductionRuntime() && hasNestedFixedColumns(sourceColumns)) {
|
|
1947
1949
|
console.warn("[Table] Multi-level headers only support fixed columns on top-level columns. Nested fixed values are ignored.");
|
|
@@ -1949,8 +1951,22 @@ function TableInner({
|
|
|
1949
1951
|
}, [sourceColumns]);
|
|
1950
1952
|
const columns = (0, import_react8.useMemo)(() => {
|
|
1951
1953
|
const utilityColumns = [];
|
|
1954
|
+
let combinedRowUtilityAdded = false;
|
|
1952
1955
|
utilityColumnOrder.forEach((utilityColumn) => {
|
|
1953
|
-
if (utilityColumn === "drag"
|
|
1956
|
+
if (hasCombinedRowUtility && (utilityColumn === "drag" || utilityColumn === "selection")) {
|
|
1957
|
+
if (combinedRowUtilityAdded) return;
|
|
1958
|
+
combinedRowUtilityAdded = true;
|
|
1959
|
+
utilityColumns.push({
|
|
1960
|
+
key: "__rvg_row_selection_drag__",
|
|
1961
|
+
title: "",
|
|
1962
|
+
width: rowSelectionColumnWidth,
|
|
1963
|
+
align: "center",
|
|
1964
|
+
fixed: "left",
|
|
1965
|
+
rowSelection: true,
|
|
1966
|
+
rowSelectionIndicator,
|
|
1967
|
+
rowDragHandle: true
|
|
1968
|
+
});
|
|
1969
|
+
} else if (utilityColumn === "drag" && rowDraggable) {
|
|
1954
1970
|
utilityColumns.push({ key: "__rvg_row_drag__", title: "", width: 36, align: "center", fixed: "left", rowDragHandle: true });
|
|
1955
1971
|
} else if (utilityColumn === "selection" && showRowCheckbox) {
|
|
1956
1972
|
utilityColumns.push({ key: "__rvg_row_selection__", title: "", width: rowSelectionColumnWidth, align: "center", fixed: "left", rowSelection: true, rowSelectionIndicator });
|
|
@@ -1963,8 +1979,8 @@ function TableInner({
|
|
|
1963
1979
|
return resizedWidth === void 0 ? column : { ...column, width: resizedWidth };
|
|
1964
1980
|
});
|
|
1965
1981
|
return [...utilityColumns, ...dataColumns];
|
|
1966
|
-
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length, utilityColumnOrder]);
|
|
1967
|
-
const utilityColumnCount = (rowDraggable ? 1 : 0) + (showRowCheckbox ? 1 : 0) + (rowNumber ? 1 : 0);
|
|
1982
|
+
}, [hasCombinedRowUtility, leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length, utilityColumnOrder]);
|
|
1983
|
+
const utilityColumnCount = (hasCombinedRowUtility ? 1 : (rowDraggable ? 1 : 0) + (showRowCheckbox ? 1 : 0)) + (rowNumber ? 1 : 0);
|
|
1968
1984
|
const headerCells = (0, import_react8.useMemo)(() => buildHeaderCells(sourceColumns, utilityColumnCount, headerDepth), [headerDepth, sourceColumns, utilityColumnCount]);
|
|
1969
1985
|
const activeCustomHeaderLevels = (0, import_react8.useMemo)(() => {
|
|
1970
1986
|
const levels = /* @__PURE__ */ new Map();
|
|
@@ -3320,13 +3336,15 @@ function TableInner({
|
|
|
3320
3336
|
cell.style.left = `${left}px`;
|
|
3321
3337
|
cell.style.width = `${columnWidth}px`;
|
|
3322
3338
|
cell.style.justifyContent = column.align === "right" ? "flex-end" : column.align === "center" ? "center" : "flex-start";
|
|
3323
|
-
if (column.rowDragHandle) {
|
|
3339
|
+
if (column.rowDragHandle && !column.rowSelection) {
|
|
3324
3340
|
cell.appendChild(createRowDragHandleSvg());
|
|
3325
3341
|
} else if (column.rowSelection) {
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3342
|
+
if (column.rowSelectionIndicator !== "none") {
|
|
3343
|
+
const checkbox = document.createElement("span");
|
|
3344
|
+
checkbox.className = selectedRowKeySet.has(rowKey2) ? "rvg-preview-checkbox is-checked" : "rvg-preview-checkbox";
|
|
3345
|
+
checkbox.textContent = selectedRowKeySet.has(rowKey2) ? "\u2713" : "";
|
|
3346
|
+
cell.appendChild(checkbox);
|
|
3347
|
+
}
|
|
3330
3348
|
} else {
|
|
3331
3349
|
cell.textContent = getCellLabel(sourceIndex, columnIndex);
|
|
3332
3350
|
}
|
|
@@ -5011,9 +5029,7 @@ function TableInner({
|
|
|
5011
5029
|
handleColumnPointerDown(event);
|
|
5012
5030
|
if (columnDragRef.current) return;
|
|
5013
5031
|
const headerDragCell = columnDraggable ? locateHeaderCell(event.clientX, event.clientY) : null;
|
|
5014
|
-
|
|
5015
|
-
const rowDragHandle = rowDraggable && columnIndex >= 0 && Boolean(columns[columnIndex].rowDragHandle) && locateRow(event.clientY) >= 0;
|
|
5016
|
-
if (headerDragCell && locateHeaderCellDragHandle(event.clientX, event.clientY, headerDragCell) || rowDragHandle) {
|
|
5032
|
+
if (headerDragCell && locateHeaderCellDragHandle(event.clientX, event.clientY, headerDragCell)) {
|
|
5017
5033
|
hideDragTooltips();
|
|
5018
5034
|
document.documentElement.classList.add("rvg-is-dragging");
|
|
5019
5035
|
event.currentTarget.style.cursor = "move";
|
|
@@ -5087,7 +5103,7 @@ function TableInner({
|
|
|
5087
5103
|
setSelection(null);
|
|
5088
5104
|
return;
|
|
5089
5105
|
}
|
|
5090
|
-
if (columns[cell.columnIndex].rowDragHandle || columns[cell.columnIndex].rowNumber) {
|
|
5106
|
+
if (columns[cell.columnIndex].rowDragHandle && !columns[cell.columnIndex].rowSelection || columns[cell.columnIndex].rowNumber) {
|
|
5091
5107
|
clickedCellRef.current = null;
|
|
5092
5108
|
return;
|
|
5093
5109
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -421,6 +421,8 @@ interface TableProps<Row extends object> {
|
|
|
421
421
|
}) => void;
|
|
422
422
|
onColumnResize?: (columnKey: string, width: number) => void;
|
|
423
423
|
rowDraggable?: boolean;
|
|
424
|
+
/** Merge row selection and row dragging into one utility column. Click selects; press and drag reorders. */
|
|
425
|
+
combineRowSelectionAndDrag?: boolean;
|
|
424
426
|
/** Order of the generated row utility columns. Defaults to drag, selection, then row number. */
|
|
425
427
|
utilityColumnOrder?: Array<'drag' | 'selection' | 'rowNumber'>;
|
|
426
428
|
onRowsReorder?: (rows: Row[], detail: {
|
package/dist/index.d.ts
CHANGED
|
@@ -421,6 +421,8 @@ interface TableProps<Row extends object> {
|
|
|
421
421
|
}) => void;
|
|
422
422
|
onColumnResize?: (columnKey: string, width: number) => void;
|
|
423
423
|
rowDraggable?: boolean;
|
|
424
|
+
/** Merge row selection and row dragging into one utility column. Click selects; press and drag reorders. */
|
|
425
|
+
combineRowSelectionAndDrag?: boolean;
|
|
424
426
|
/** Order of the generated row utility columns. Defaults to drag, selection, then row number. */
|
|
425
427
|
utilityColumnOrder?: Array<'drag' | 'selection' | 'rowNumber'>;
|
|
426
428
|
onRowsReorder?: (rows: Row[], detail: {
|
package/dist/index.js
CHANGED
|
@@ -960,8 +960,8 @@ function getVisibleHeaderActions(column, width, columnDraggable = false, titleWi
|
|
|
960
960
|
return { filter: visible.has("filter"), sort: visible.has("sort"), drag: visible.has("drag") };
|
|
961
961
|
}
|
|
962
962
|
function getMinimumColumnWidth(column, columnDraggable = false) {
|
|
963
|
-
if (column.rowDragHandle) return 36;
|
|
964
963
|
if (column.rowSelection) return Math.max(24, column.width ?? 44);
|
|
964
|
+
if (column.rowDragHandle) return 36;
|
|
965
965
|
if (column.rowNumber) return 44;
|
|
966
966
|
return 60;
|
|
967
967
|
}
|
|
@@ -1253,7 +1253,7 @@ function paintGrid(options) {
|
|
|
1253
1253
|
if (columnIndex === rangeColumnStart) ctx.fillRect(x, y, 2, cellHeight);
|
|
1254
1254
|
if (columnIndex === rangeColumnEnd) ctx.fillRect(x + cellWidth - 2, y, 2, cellHeight);
|
|
1255
1255
|
}
|
|
1256
|
-
if (column.rowDragHandle) {
|
|
1256
|
+
if (column.rowDragHandle && !column.rowSelection) {
|
|
1257
1257
|
const iconLeft = x + (cellWidth - 16) / 2;
|
|
1258
1258
|
const iconTop = y + (cellHeight - 16) / 2;
|
|
1259
1259
|
ctx.fillStyle = isAxisSelected ? colors.axisSelectionText : colors.icon;
|
|
@@ -1844,6 +1844,7 @@ function TableInner({
|
|
|
1844
1844
|
onColumnsReorder,
|
|
1845
1845
|
onColumnResize,
|
|
1846
1846
|
rowDraggable = false,
|
|
1847
|
+
combineRowSelectionAndDrag = false,
|
|
1847
1848
|
utilityColumnOrder = ["drag", "selection", "rowNumber"],
|
|
1848
1849
|
onRowsReorder,
|
|
1849
1850
|
onInsertRows,
|
|
@@ -1912,6 +1913,7 @@ function TableInner({
|
|
|
1912
1913
|
const showRowCheckbox = Boolean(rowSelection) && (typeof rowSelection !== "object" || rowSelection.showCheckbox !== false);
|
|
1913
1914
|
const rowSelectionIndicator = typeof rowSelection === "object" ? rowSelection.indicator ?? "checkbox" : "checkbox";
|
|
1914
1915
|
const rowSelectionColumnWidth = typeof rowSelection === "object" ? Math.max(24, rowSelection.columnWidth ?? 44) : 44;
|
|
1916
|
+
const hasCombinedRowUtility = combineRowSelectionAndDrag && rowDraggable && showRowCheckbox;
|
|
1915
1917
|
useEffect3(() => {
|
|
1916
1918
|
if (!isProductionRuntime() && hasNestedFixedColumns(sourceColumns)) {
|
|
1917
1919
|
console.warn("[Table] Multi-level headers only support fixed columns on top-level columns. Nested fixed values are ignored.");
|
|
@@ -1919,8 +1921,22 @@ function TableInner({
|
|
|
1919
1921
|
}, [sourceColumns]);
|
|
1920
1922
|
const columns = useMemo2(() => {
|
|
1921
1923
|
const utilityColumns = [];
|
|
1924
|
+
let combinedRowUtilityAdded = false;
|
|
1922
1925
|
utilityColumnOrder.forEach((utilityColumn) => {
|
|
1923
|
-
if (utilityColumn === "drag"
|
|
1926
|
+
if (hasCombinedRowUtility && (utilityColumn === "drag" || utilityColumn === "selection")) {
|
|
1927
|
+
if (combinedRowUtilityAdded) return;
|
|
1928
|
+
combinedRowUtilityAdded = true;
|
|
1929
|
+
utilityColumns.push({
|
|
1930
|
+
key: "__rvg_row_selection_drag__",
|
|
1931
|
+
title: "",
|
|
1932
|
+
width: rowSelectionColumnWidth,
|
|
1933
|
+
align: "center",
|
|
1934
|
+
fixed: "left",
|
|
1935
|
+
rowSelection: true,
|
|
1936
|
+
rowSelectionIndicator,
|
|
1937
|
+
rowDragHandle: true
|
|
1938
|
+
});
|
|
1939
|
+
} else if (utilityColumn === "drag" && rowDraggable) {
|
|
1924
1940
|
utilityColumns.push({ key: "__rvg_row_drag__", title: "", width: 36, align: "center", fixed: "left", rowDragHandle: true });
|
|
1925
1941
|
} else if (utilityColumn === "selection" && showRowCheckbox) {
|
|
1926
1942
|
utilityColumns.push({ key: "__rvg_row_selection__", title: "", width: rowSelectionColumnWidth, align: "center", fixed: "left", rowSelection: true, rowSelectionIndicator });
|
|
@@ -1933,8 +1949,8 @@ function TableInner({
|
|
|
1933
1949
|
return resizedWidth === void 0 ? column : { ...column, width: resizedWidth };
|
|
1934
1950
|
});
|
|
1935
1951
|
return [...utilityColumns, ...dataColumns];
|
|
1936
|
-
}, [leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length, utilityColumnOrder]);
|
|
1937
|
-
const utilityColumnCount = (rowDraggable ? 1 : 0) + (showRowCheckbox ? 1 : 0) + (rowNumber ? 1 : 0);
|
|
1952
|
+
}, [hasCombinedRowUtility, leafSourceColumns, resizedColumnWidths, rowDraggable, rowNumber, rowSelectionColumnWidth, rowSelectionIndicator, showRowCheckbox, sourceRows.length, utilityColumnOrder]);
|
|
1953
|
+
const utilityColumnCount = (hasCombinedRowUtility ? 1 : (rowDraggable ? 1 : 0) + (showRowCheckbox ? 1 : 0)) + (rowNumber ? 1 : 0);
|
|
1938
1954
|
const headerCells = useMemo2(() => buildHeaderCells(sourceColumns, utilityColumnCount, headerDepth), [headerDepth, sourceColumns, utilityColumnCount]);
|
|
1939
1955
|
const activeCustomHeaderLevels = useMemo2(() => {
|
|
1940
1956
|
const levels = /* @__PURE__ */ new Map();
|
|
@@ -3290,13 +3306,15 @@ function TableInner({
|
|
|
3290
3306
|
cell.style.left = `${left}px`;
|
|
3291
3307
|
cell.style.width = `${columnWidth}px`;
|
|
3292
3308
|
cell.style.justifyContent = column.align === "right" ? "flex-end" : column.align === "center" ? "center" : "flex-start";
|
|
3293
|
-
if (column.rowDragHandle) {
|
|
3309
|
+
if (column.rowDragHandle && !column.rowSelection) {
|
|
3294
3310
|
cell.appendChild(createRowDragHandleSvg());
|
|
3295
3311
|
} else if (column.rowSelection) {
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3312
|
+
if (column.rowSelectionIndicator !== "none") {
|
|
3313
|
+
const checkbox = document.createElement("span");
|
|
3314
|
+
checkbox.className = selectedRowKeySet.has(rowKey2) ? "rvg-preview-checkbox is-checked" : "rvg-preview-checkbox";
|
|
3315
|
+
checkbox.textContent = selectedRowKeySet.has(rowKey2) ? "\u2713" : "";
|
|
3316
|
+
cell.appendChild(checkbox);
|
|
3317
|
+
}
|
|
3300
3318
|
} else {
|
|
3301
3319
|
cell.textContent = getCellLabel(sourceIndex, columnIndex);
|
|
3302
3320
|
}
|
|
@@ -4981,9 +4999,7 @@ function TableInner({
|
|
|
4981
4999
|
handleColumnPointerDown(event);
|
|
4982
5000
|
if (columnDragRef.current) return;
|
|
4983
5001
|
const headerDragCell = columnDraggable ? locateHeaderCell(event.clientX, event.clientY) : null;
|
|
4984
|
-
|
|
4985
|
-
const rowDragHandle = rowDraggable && columnIndex >= 0 && Boolean(columns[columnIndex].rowDragHandle) && locateRow(event.clientY) >= 0;
|
|
4986
|
-
if (headerDragCell && locateHeaderCellDragHandle(event.clientX, event.clientY, headerDragCell) || rowDragHandle) {
|
|
5002
|
+
if (headerDragCell && locateHeaderCellDragHandle(event.clientX, event.clientY, headerDragCell)) {
|
|
4987
5003
|
hideDragTooltips();
|
|
4988
5004
|
document.documentElement.classList.add("rvg-is-dragging");
|
|
4989
5005
|
event.currentTarget.style.cursor = "move";
|
|
@@ -5057,7 +5073,7 @@ function TableInner({
|
|
|
5057
5073
|
setSelection(null);
|
|
5058
5074
|
return;
|
|
5059
5075
|
}
|
|
5060
|
-
if (columns[cell.columnIndex].rowDragHandle || columns[cell.columnIndex].rowNumber) {
|
|
5076
|
+
if (columns[cell.columnIndex].rowDragHandle && !columns[cell.columnIndex].rowSelection || columns[cell.columnIndex].rowNumber) {
|
|
5061
5077
|
clickedCellRef.current = null;
|
|
5062
5078
|
return;
|
|
5063
5079
|
}
|