react-glide-table 1.1.9 → 1.2.0
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 +111 -47
- package/dist/compound.cjs +215 -15
- package/dist/compound.d.cts +3 -3
- package/dist/compound.d.ts +3 -3
- package/dist/compound.js +215 -15
- package/dist/core.cjs +140 -4
- package/dist/core.d.cts +20 -5
- package/dist/core.d.ts +20 -5
- package/dist/core.js +136 -4
- package/dist/index.cjs +223 -15
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +219 -15
- package/dist/{types-xxzMLUwM.d.cts → types-D031_07N.d.cts} +85 -3
- package/dist/{types-xxzMLUwM.d.ts → types-D031_07N.d.ts} +85 -3
- package/package.json +23 -1
package/dist/core.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-
|
|
1
|
+
import { n as CellEditType, d as DataTableClassNames, R as RowSelectionMode, b as ColumnFreezeOffset, g as DataTableProps, f as DataTableLabels, e as DataTableCopyActions, P as PasteMode, i as RowsPastePayload } from './types-D031_07N.cjs';
|
|
2
|
+
export { C as ColumnFreezeColumnInput, a as ColumnFreezeMeta, c as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, k as buildColumnFreezeOffsets, l as getColumnFreezeStyle, r as resolveColumnFreezeSide, m as resolveDataTableLabels } from './types-D031_07N.cjs';
|
|
3
3
|
import { Row, ColumnDef, Table, Updater, RowSelectionState } from '@tanstack/react-table';
|
|
4
|
-
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
4
|
+
export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
|
|
5
5
|
import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
|
|
6
6
|
import * as react from 'react';
|
|
7
|
-
import { RefObject } from 'react';
|
|
7
|
+
import { RefObject, CSSProperties } from 'react';
|
|
8
8
|
|
|
9
9
|
/** Neutral default field names for tree conversion */
|
|
10
10
|
declare const DEFAULT_TREE_ID_FIELD = "id";
|
|
@@ -170,6 +170,13 @@ type DataTableRowContextValue = {
|
|
|
170
170
|
expandRowLabel: string;
|
|
171
171
|
collapseRowLabel: string;
|
|
172
172
|
};
|
|
173
|
+
columnResize: {
|
|
174
|
+
enableColumnResize: boolean;
|
|
175
|
+
};
|
|
176
|
+
columnFreeze: {
|
|
177
|
+
enableColumnFreeze: boolean;
|
|
178
|
+
offsets: Map<string, ColumnFreezeOffset>;
|
|
179
|
+
};
|
|
173
180
|
};
|
|
174
181
|
|
|
175
182
|
type UseGlideTableOptions<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "className" | "classNames" | "slots" | "summary" | "toolbar" | "isPending" | "totalCount" | "filteredCount">;
|
|
@@ -184,6 +191,8 @@ type UseGlideTableResult<T extends Record<string, unknown>> = {
|
|
|
184
191
|
loadingText: string;
|
|
185
192
|
selectionLabel: DataTableLabels["selection"];
|
|
186
193
|
enableCellSelection: boolean;
|
|
194
|
+
enableColumnResize: boolean;
|
|
195
|
+
enableColumnFreeze: boolean;
|
|
187
196
|
shouldVirtualize: boolean;
|
|
188
197
|
scrollRef: RefObject<HTMLDivElement | null>;
|
|
189
198
|
rowVirtualizer: Virtualizer<HTMLDivElement, Element>;
|
|
@@ -212,6 +221,12 @@ declare function useCellEdit<T extends Record<string, unknown>>({ data, rows, on
|
|
|
212
221
|
cancelEdit: () => void;
|
|
213
222
|
};
|
|
214
223
|
|
|
224
|
+
/** Width styles for header/body cells when column sizing is active. */
|
|
225
|
+
declare function getColumnSizeStyle(size: number, options?: {
|
|
226
|
+
force?: boolean;
|
|
227
|
+
lockMax?: boolean;
|
|
228
|
+
}): CSSProperties | undefined;
|
|
229
|
+
|
|
215
230
|
type ParsedClipboardTSV = {
|
|
216
231
|
values: string[][];
|
|
217
232
|
/**
|
|
@@ -327,4 +342,4 @@ declare const useConvertTreeData: <T extends Record<string, unknown>>({ data, en
|
|
|
327
342
|
declare function resolveRowSelection(mode: RowSelectionMode, controlledSelection: RowSelectionState | undefined, internalSelection: RowSelectionState): RowSelectionState;
|
|
328
343
|
declare function applySelectionUpdater(mode: RowSelectionMode, updater: Updater<RowSelectionState>, previous: RowSelectionState): RowSelectionState;
|
|
329
344
|
|
|
330
|
-
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, RowSelectionMode, type RowSpanInfo, RowsPastePayload, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard };
|
|
345
|
+
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, ColumnFreezeOffset, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, RowSelectionMode, type RowSpanInfo, RowsPastePayload, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-
|
|
1
|
+
import { n as CellEditType, d as DataTableClassNames, R as RowSelectionMode, b as ColumnFreezeOffset, g as DataTableProps, f as DataTableLabels, e as DataTableCopyActions, P as PasteMode, i as RowsPastePayload } from './types-D031_07N.js';
|
|
2
|
+
export { C as ColumnFreezeColumnInput, a as ColumnFreezeMeta, c as ColumnFreezeSide, D as DEFAULT_DATA_TABLE_LABELS, k as buildColumnFreezeOffsets, l as getColumnFreezeStyle, r as resolveColumnFreezeSide, m as resolveDataTableLabels } from './types-D031_07N.js';
|
|
3
3
|
import { Row, ColumnDef, Table, Updater, RowSelectionState } from '@tanstack/react-table';
|
|
4
|
-
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
4
|
+
export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
|
|
5
5
|
import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
|
|
6
6
|
import * as react from 'react';
|
|
7
|
-
import { RefObject } from 'react';
|
|
7
|
+
import { RefObject, CSSProperties } from 'react';
|
|
8
8
|
|
|
9
9
|
/** Neutral default field names for tree conversion */
|
|
10
10
|
declare const DEFAULT_TREE_ID_FIELD = "id";
|
|
@@ -170,6 +170,13 @@ type DataTableRowContextValue = {
|
|
|
170
170
|
expandRowLabel: string;
|
|
171
171
|
collapseRowLabel: string;
|
|
172
172
|
};
|
|
173
|
+
columnResize: {
|
|
174
|
+
enableColumnResize: boolean;
|
|
175
|
+
};
|
|
176
|
+
columnFreeze: {
|
|
177
|
+
enableColumnFreeze: boolean;
|
|
178
|
+
offsets: Map<string, ColumnFreezeOffset>;
|
|
179
|
+
};
|
|
173
180
|
};
|
|
174
181
|
|
|
175
182
|
type UseGlideTableOptions<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "className" | "classNames" | "slots" | "summary" | "toolbar" | "isPending" | "totalCount" | "filteredCount">;
|
|
@@ -184,6 +191,8 @@ type UseGlideTableResult<T extends Record<string, unknown>> = {
|
|
|
184
191
|
loadingText: string;
|
|
185
192
|
selectionLabel: DataTableLabels["selection"];
|
|
186
193
|
enableCellSelection: boolean;
|
|
194
|
+
enableColumnResize: boolean;
|
|
195
|
+
enableColumnFreeze: boolean;
|
|
187
196
|
shouldVirtualize: boolean;
|
|
188
197
|
scrollRef: RefObject<HTMLDivElement | null>;
|
|
189
198
|
rowVirtualizer: Virtualizer<HTMLDivElement, Element>;
|
|
@@ -212,6 +221,12 @@ declare function useCellEdit<T extends Record<string, unknown>>({ data, rows, on
|
|
|
212
221
|
cancelEdit: () => void;
|
|
213
222
|
};
|
|
214
223
|
|
|
224
|
+
/** Width styles for header/body cells when column sizing is active. */
|
|
225
|
+
declare function getColumnSizeStyle(size: number, options?: {
|
|
226
|
+
force?: boolean;
|
|
227
|
+
lockMax?: boolean;
|
|
228
|
+
}): CSSProperties | undefined;
|
|
229
|
+
|
|
215
230
|
type ParsedClipboardTSV = {
|
|
216
231
|
values: string[][];
|
|
217
232
|
/**
|
|
@@ -327,4 +342,4 @@ declare const useConvertTreeData: <T extends Record<string, unknown>>({ data, en
|
|
|
327
342
|
declare function resolveRowSelection(mode: RowSelectionMode, controlledSelection: RowSelectionState | undefined, internalSelection: RowSelectionState): RowSelectionState;
|
|
328
343
|
declare function applySelectionUpdater(mode: RowSelectionMode, updater: Updater<RowSelectionState>, previous: RowSelectionState): RowSelectionState;
|
|
329
344
|
|
|
330
|
-
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, RowSelectionMode, type RowSpanInfo, RowsPastePayload, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard };
|
|
345
|
+
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, ColumnFreezeOffset, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, RowSelectionMode, type RowSpanInfo, RowsPastePayload, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getColumnSizeStyle, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard };
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,8 @@ var DEFAULT_DATA_TABLE_LABELS = {
|
|
|
4
4
|
loading: "Loading...",
|
|
5
5
|
selection: (selectedCount) => selectedCount > 0 ? `\u2713 ${selectedCount} selected` : null,
|
|
6
6
|
expandRow: "Expand row",
|
|
7
|
-
collapseRow: "Collapse row"
|
|
7
|
+
collapseRow: "Collapse row",
|
|
8
|
+
resizeColumn: "Resize column"
|
|
8
9
|
};
|
|
9
10
|
function resolveDataTableLabels(partial) {
|
|
10
11
|
return {
|
|
@@ -38,6 +39,9 @@ import {
|
|
|
38
39
|
// src/components/ui/table/constants.ts
|
|
39
40
|
var DATA_TABLE_ROW_HEIGHT = 44;
|
|
40
41
|
var DATA_TABLE_VIRTUAL_OVERSCAN = 8;
|
|
42
|
+
var DATA_TABLE_COLUMN_SIZE = 150;
|
|
43
|
+
var DATA_TABLE_COLUMN_MIN_SIZE = 40;
|
|
44
|
+
var DATA_TABLE_COLUMN_MAX_SIZE = 800;
|
|
41
45
|
|
|
42
46
|
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
43
47
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -928,6 +932,68 @@ function useCellSelection({
|
|
|
928
932
|
};
|
|
929
933
|
}
|
|
930
934
|
|
|
935
|
+
// src/components/ui/table/features/column-freeze/columnFreeze.ts
|
|
936
|
+
var HEADER_Z_BASE = 30;
|
|
937
|
+
var BODY_Z_BASE = 5;
|
|
938
|
+
function resolveColumnFreezeSide(frozen) {
|
|
939
|
+
if (frozen === true || frozen === "left") return "left";
|
|
940
|
+
if (frozen === "right") return "right";
|
|
941
|
+
return void 0;
|
|
942
|
+
}
|
|
943
|
+
function buildColumnFreezeOffsets(columns) {
|
|
944
|
+
const result = /* @__PURE__ */ new Map();
|
|
945
|
+
let leftOffset = 0;
|
|
946
|
+
const leftIds = [];
|
|
947
|
+
for (const column of columns) {
|
|
948
|
+
if (column.side !== "left") continue;
|
|
949
|
+
leftIds.push(column.id);
|
|
950
|
+
result.set(column.id, {
|
|
951
|
+
side: "left",
|
|
952
|
+
offset: leftOffset,
|
|
953
|
+
isEdge: false,
|
|
954
|
+
stack: 0
|
|
955
|
+
});
|
|
956
|
+
leftOffset += column.size;
|
|
957
|
+
}
|
|
958
|
+
leftIds.forEach((id, index) => {
|
|
959
|
+
const entry = result.get(id);
|
|
960
|
+
if (!entry) return;
|
|
961
|
+
entry.isEdge = index === leftIds.length - 1;
|
|
962
|
+
entry.stack = leftIds.length - index;
|
|
963
|
+
});
|
|
964
|
+
let rightOffset = 0;
|
|
965
|
+
const rightIds = [];
|
|
966
|
+
for (let index = columns.length - 1; index >= 0; index -= 1) {
|
|
967
|
+
const column = columns[index];
|
|
968
|
+
if (!column || column.side !== "right") continue;
|
|
969
|
+
rightIds.push(column.id);
|
|
970
|
+
result.set(column.id, {
|
|
971
|
+
side: "right",
|
|
972
|
+
offset: rightOffset,
|
|
973
|
+
isEdge: false,
|
|
974
|
+
stack: 0
|
|
975
|
+
});
|
|
976
|
+
rightOffset += column.size;
|
|
977
|
+
}
|
|
978
|
+
rightIds.forEach((id, index) => {
|
|
979
|
+
const entry = result.get(id);
|
|
980
|
+
if (!entry) return;
|
|
981
|
+
entry.isEdge = index === rightIds.length - 1;
|
|
982
|
+
entry.stack = rightIds.length - index;
|
|
983
|
+
});
|
|
984
|
+
return result;
|
|
985
|
+
}
|
|
986
|
+
function getColumnFreezeStyle(offset, options) {
|
|
987
|
+
if (!offset) return void 0;
|
|
988
|
+
const zBase = options?.isHeader ? HEADER_Z_BASE : BODY_Z_BASE;
|
|
989
|
+
return {
|
|
990
|
+
position: "sticky",
|
|
991
|
+
...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
|
|
992
|
+
zIndex: zBase + offset.stack,
|
|
993
|
+
...options?.isHeader ? { top: 0 } : {}
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
|
|
931
997
|
// src/components/ui/table/features/row-expand/row-expand.ts
|
|
932
998
|
import { useEffect as useEffect3, useMemo, useRef as useRef3 } from "react";
|
|
933
999
|
function getFieldValue(row, key) {
|
|
@@ -1193,6 +1259,7 @@ function collectRowSpanColumns(columns) {
|
|
|
1193
1259
|
}
|
|
1194
1260
|
|
|
1195
1261
|
// src/core/useGlideTable.ts
|
|
1262
|
+
var EMPTY_COLUMN_FREEZE_OFFSETS = /* @__PURE__ */ new Map();
|
|
1196
1263
|
function useGlideTable(options) {
|
|
1197
1264
|
const {
|
|
1198
1265
|
data,
|
|
@@ -1228,7 +1295,12 @@ function useGlideTable(options) {
|
|
|
1228
1295
|
enableInsertPaste,
|
|
1229
1296
|
enableVirtualization = true,
|
|
1230
1297
|
estimateRowHeight = DATA_TABLE_ROW_HEIGHT,
|
|
1231
|
-
virtualOverscan = DATA_TABLE_VIRTUAL_OVERSCAN
|
|
1298
|
+
virtualOverscan = DATA_TABLE_VIRTUAL_OVERSCAN,
|
|
1299
|
+
enableColumnResize = false,
|
|
1300
|
+
columnSizing: controlledColumnSizing,
|
|
1301
|
+
onColumnSizingChange,
|
|
1302
|
+
columnResizeMode = "onChange",
|
|
1303
|
+
enableColumnFreeze = false
|
|
1232
1304
|
} = options;
|
|
1233
1305
|
const labels = useMemo2(() => {
|
|
1234
1306
|
const resolved = resolveDataTableLabels(labelsProp);
|
|
@@ -1242,6 +1314,7 @@ function useGlideTable(options) {
|
|
|
1242
1314
|
const enableExpand = Boolean(toggleField);
|
|
1243
1315
|
const resolvedEnableSubtreeCopy = enableSubtreeCopy ?? enableExpand;
|
|
1244
1316
|
const [internalRowSelection, setInternalRowSelection] = useState3({});
|
|
1317
|
+
const [internalColumnSizing, setInternalColumnSizing] = useState3({});
|
|
1245
1318
|
const [internalExpandedRows, setInternalExpandedRows] = useState3(
|
|
1246
1319
|
() => /* @__PURE__ */ new Set()
|
|
1247
1320
|
);
|
|
@@ -1260,6 +1333,7 @@ function useGlideTable(options) {
|
|
|
1260
1333
|
controlledRowSelection,
|
|
1261
1334
|
internalRowSelection
|
|
1262
1335
|
);
|
|
1336
|
+
const columnSizing = controlledColumnSizing ?? internalColumnSizing;
|
|
1263
1337
|
const expandedRows = controlledExpandedRows ?? internalExpandedRows;
|
|
1264
1338
|
const handleExpandedRowsChange = useCallback3(
|
|
1265
1339
|
(next) => {
|
|
@@ -1285,9 +1359,27 @@ function useGlideTable(options) {
|
|
|
1285
1359
|
const table = useReactTable({
|
|
1286
1360
|
data: tableData,
|
|
1287
1361
|
columns,
|
|
1362
|
+
...enableColumnResize ? {
|
|
1363
|
+
defaultColumn: {
|
|
1364
|
+
minSize: DATA_TABLE_COLUMN_MIN_SIZE,
|
|
1365
|
+
maxSize: DATA_TABLE_COLUMN_MAX_SIZE
|
|
1366
|
+
}
|
|
1367
|
+
} : {},
|
|
1368
|
+
enableColumnResizing: enableColumnResize,
|
|
1369
|
+
columnResizeMode,
|
|
1288
1370
|
state: {
|
|
1289
|
-
rowSelection: rowSelectionMode === "none" ? {} : rowSelection
|
|
1371
|
+
rowSelection: rowSelectionMode === "none" ? {} : rowSelection,
|
|
1372
|
+
...enableColumnResize ? { columnSizing } : {}
|
|
1290
1373
|
},
|
|
1374
|
+
onColumnSizingChange: enableColumnResize ? (updater) => {
|
|
1375
|
+
if (onColumnSizingChange) {
|
|
1376
|
+
onColumnSizingChange(updater);
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
setInternalColumnSizing(
|
|
1380
|
+
(previous) => typeof updater === "function" ? updater(previous) : updater
|
|
1381
|
+
);
|
|
1382
|
+
} : void 0,
|
|
1291
1383
|
enableRowSelection: rowSelectionMode === "none" ? false : getRowCanSelect ? (row) => getRowCanSelect(row.original, row.index) : true,
|
|
1292
1384
|
enableMultiRowSelection: rowSelectionMode === "multi",
|
|
1293
1385
|
onRowSelectionChange: (updater) => {
|
|
@@ -1318,6 +1410,17 @@ function useGlideTable(options) {
|
|
|
1318
1410
|
const selectedCount = selectedRows.length;
|
|
1319
1411
|
const rows = table.getRowModel().rows;
|
|
1320
1412
|
const columnCount = table.getAllLeafColumns().length || 1;
|
|
1413
|
+
const visibleLeafColumns = table.getVisibleLeafColumns();
|
|
1414
|
+
const columnFreezeOffsets = useMemo2(() => {
|
|
1415
|
+
if (!enableColumnFreeze) return EMPTY_COLUMN_FREEZE_OFFSETS;
|
|
1416
|
+
return buildColumnFreezeOffsets(
|
|
1417
|
+
visibleLeafColumns.map((column) => ({
|
|
1418
|
+
id: column.id,
|
|
1419
|
+
size: column.getSize(),
|
|
1420
|
+
side: resolveColumnFreezeSide(column.columnDef.meta?.frozen)
|
|
1421
|
+
}))
|
|
1422
|
+
);
|
|
1423
|
+
}, [enableColumnFreeze, visibleLeafColumns, columnSizing]);
|
|
1321
1424
|
const rowVirtualizer = useVirtualizer({
|
|
1322
1425
|
count: shouldVirtualize ? rows.length : 0,
|
|
1323
1426
|
getScrollElement: () => scrollRef.current,
|
|
@@ -1434,6 +1537,13 @@ function useGlideTable(options) {
|
|
|
1434
1537
|
onToggleExpand: handleToggleExpand,
|
|
1435
1538
|
expandRowLabel: labels.expandRow,
|
|
1436
1539
|
collapseRowLabel: labels.collapseRow
|
|
1540
|
+
},
|
|
1541
|
+
columnResize: {
|
|
1542
|
+
enableColumnResize
|
|
1543
|
+
},
|
|
1544
|
+
columnFreeze: {
|
|
1545
|
+
enableColumnFreeze,
|
|
1546
|
+
offsets: columnFreezeOffsets
|
|
1437
1547
|
}
|
|
1438
1548
|
};
|
|
1439
1549
|
}, [
|
|
@@ -1466,7 +1576,10 @@ function useGlideTable(options) {
|
|
|
1466
1576
|
preventExpand,
|
|
1467
1577
|
handleToggleExpand,
|
|
1468
1578
|
labels.expandRow,
|
|
1469
|
-
labels.collapseRow
|
|
1579
|
+
labels.collapseRow,
|
|
1580
|
+
enableColumnResize,
|
|
1581
|
+
enableColumnFreeze,
|
|
1582
|
+
columnFreezeOffsets
|
|
1470
1583
|
]);
|
|
1471
1584
|
const copySelectionRef = useRef4(copySelection);
|
|
1472
1585
|
useEffect4(() => {
|
|
@@ -1487,6 +1600,8 @@ function useGlideTable(options) {
|
|
|
1487
1600
|
loadingText: labels.loading,
|
|
1488
1601
|
selectionLabel: labels.selection,
|
|
1489
1602
|
enableCellSelection,
|
|
1603
|
+
enableColumnResize,
|
|
1604
|
+
enableColumnFreeze,
|
|
1490
1605
|
shouldVirtualize,
|
|
1491
1606
|
scrollRef,
|
|
1492
1607
|
rowVirtualizer,
|
|
@@ -1499,6 +1614,19 @@ function useGlideTable(options) {
|
|
|
1499
1614
|
copySelection: stableCopySelection
|
|
1500
1615
|
};
|
|
1501
1616
|
}
|
|
1617
|
+
|
|
1618
|
+
// src/components/ui/table/features/column-resize/columnResize.ts
|
|
1619
|
+
function getColumnSizeStyle(size, options) {
|
|
1620
|
+
const { force = false, lockMax = false } = options ?? {};
|
|
1621
|
+
if (!force && size === DATA_TABLE_COLUMN_SIZE) {
|
|
1622
|
+
return void 0;
|
|
1623
|
+
}
|
|
1624
|
+
return {
|
|
1625
|
+
width: size,
|
|
1626
|
+
minWidth: size,
|
|
1627
|
+
...lockMax ? { maxWidth: size } : {}
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1502
1630
|
export {
|
|
1503
1631
|
CELL_SELECTION_EDGES_CLASS,
|
|
1504
1632
|
DEFAULT_DATA_TABLE_LABELS,
|
|
@@ -1509,6 +1637,7 @@ export {
|
|
|
1509
1637
|
applyCellEdit,
|
|
1510
1638
|
applyFillData,
|
|
1511
1639
|
applySelectionUpdater,
|
|
1640
|
+
buildColumnFreezeOffsets,
|
|
1512
1641
|
buildColumnRowSpanMap,
|
|
1513
1642
|
buildRowsPastePayload,
|
|
1514
1643
|
canExpandRow,
|
|
@@ -1520,6 +1649,8 @@ export {
|
|
|
1520
1649
|
getCellEditDraftValue,
|
|
1521
1650
|
getCellSelectionEdgeStyle,
|
|
1522
1651
|
getColumnEditType,
|
|
1652
|
+
getColumnFreezeStyle,
|
|
1653
|
+
getColumnSizeStyle,
|
|
1523
1654
|
getRowIndexInMergedCell,
|
|
1524
1655
|
hasCellSelectionEdges,
|
|
1525
1656
|
isCellInSelection,
|
|
@@ -1529,6 +1660,7 @@ export {
|
|
|
1529
1660
|
parseCellEditValue,
|
|
1530
1661
|
parseClipboardTSV,
|
|
1531
1662
|
parseClipboardTSVWithDepths,
|
|
1663
|
+
resolveColumnFreezeSide,
|
|
1532
1664
|
resolveDataTableLabels,
|
|
1533
1665
|
resolvePasteColumnIds,
|
|
1534
1666
|
resolveRowSelection,
|