react-glide-table 1.1.8 → 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 +256 -15
- package/dist/compound.d.cts +3 -3
- package/dist/compound.d.ts +3 -3
- package/dist/compound.js +256 -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 +264 -15
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +260 -15
- package/dist/{types-Ce4qepIU.d.cts → types-D031_07N.d.cts} +94 -3
- package/dist/{types-Ce4qepIU.d.ts → types-D031_07N.d.ts} +94 -3
- package/package.json +23 -1
package/dist/compound.cjs
CHANGED
|
@@ -45,6 +45,9 @@ var ROW_HOVERED_BG_CLASS = "row-hovered";
|
|
|
45
45
|
var CELL_SELECTION_FILL_CLASS = "cell-selection-fill";
|
|
46
46
|
var DATA_TABLE_ROW_HEIGHT = 44;
|
|
47
47
|
var DATA_TABLE_VIRTUAL_OVERSCAN = 8;
|
|
48
|
+
var DATA_TABLE_COLUMN_SIZE = 150;
|
|
49
|
+
var DATA_TABLE_COLUMN_MIN_SIZE = 40;
|
|
50
|
+
var DATA_TABLE_COLUMN_MAX_SIZE = 800;
|
|
48
51
|
|
|
49
52
|
// src/components/ui/table/DataTableContext.tsx
|
|
50
53
|
var import_react = require("react");
|
|
@@ -385,6 +388,81 @@ function hasCellSelectionEdges(style) {
|
|
|
385
388
|
);
|
|
386
389
|
}
|
|
387
390
|
|
|
391
|
+
// src/components/ui/table/features/column-freeze/columnFreeze.ts
|
|
392
|
+
var HEADER_Z_BASE = 30;
|
|
393
|
+
var BODY_Z_BASE = 5;
|
|
394
|
+
function resolveColumnFreezeSide(frozen) {
|
|
395
|
+
if (frozen === true || frozen === "left") return "left";
|
|
396
|
+
if (frozen === "right") return "right";
|
|
397
|
+
return void 0;
|
|
398
|
+
}
|
|
399
|
+
function buildColumnFreezeOffsets(columns) {
|
|
400
|
+
const result = /* @__PURE__ */ new Map();
|
|
401
|
+
let leftOffset = 0;
|
|
402
|
+
const leftIds = [];
|
|
403
|
+
for (const column of columns) {
|
|
404
|
+
if (column.side !== "left") continue;
|
|
405
|
+
leftIds.push(column.id);
|
|
406
|
+
result.set(column.id, {
|
|
407
|
+
side: "left",
|
|
408
|
+
offset: leftOffset,
|
|
409
|
+
isEdge: false,
|
|
410
|
+
stack: 0
|
|
411
|
+
});
|
|
412
|
+
leftOffset += column.size;
|
|
413
|
+
}
|
|
414
|
+
leftIds.forEach((id, index) => {
|
|
415
|
+
const entry = result.get(id);
|
|
416
|
+
if (!entry) return;
|
|
417
|
+
entry.isEdge = index === leftIds.length - 1;
|
|
418
|
+
entry.stack = leftIds.length - index;
|
|
419
|
+
});
|
|
420
|
+
let rightOffset = 0;
|
|
421
|
+
const rightIds = [];
|
|
422
|
+
for (let index = columns.length - 1; index >= 0; index -= 1) {
|
|
423
|
+
const column = columns[index];
|
|
424
|
+
if (!column || column.side !== "right") continue;
|
|
425
|
+
rightIds.push(column.id);
|
|
426
|
+
result.set(column.id, {
|
|
427
|
+
side: "right",
|
|
428
|
+
offset: rightOffset,
|
|
429
|
+
isEdge: false,
|
|
430
|
+
stack: 0
|
|
431
|
+
});
|
|
432
|
+
rightOffset += column.size;
|
|
433
|
+
}
|
|
434
|
+
rightIds.forEach((id, index) => {
|
|
435
|
+
const entry = result.get(id);
|
|
436
|
+
if (!entry) return;
|
|
437
|
+
entry.isEdge = index === rightIds.length - 1;
|
|
438
|
+
entry.stack = rightIds.length - index;
|
|
439
|
+
});
|
|
440
|
+
return result;
|
|
441
|
+
}
|
|
442
|
+
function getColumnFreezeStyle(offset, options) {
|
|
443
|
+
if (!offset) return void 0;
|
|
444
|
+
const zBase = options?.isHeader ? HEADER_Z_BASE : BODY_Z_BASE;
|
|
445
|
+
return {
|
|
446
|
+
position: "sticky",
|
|
447
|
+
...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
|
|
448
|
+
zIndex: zBase + offset.stack,
|
|
449
|
+
...options?.isHeader ? { top: 0 } : {}
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// src/components/ui/table/features/column-resize/columnResize.ts
|
|
454
|
+
function getColumnSizeStyle(size, options) {
|
|
455
|
+
const { force = false, lockMax = false } = options ?? {};
|
|
456
|
+
if (!force && size === DATA_TABLE_COLUMN_SIZE) {
|
|
457
|
+
return void 0;
|
|
458
|
+
}
|
|
459
|
+
return {
|
|
460
|
+
width: size,
|
|
461
|
+
minWidth: size,
|
|
462
|
+
...lockMax ? { maxWidth: size } : {}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
|
|
388
466
|
// src/components/ui/table/features/row-expand/row-expand.ts
|
|
389
467
|
var import_react2 = require("react");
|
|
390
468
|
|
|
@@ -789,6 +867,19 @@ function cn(...inputs) {
|
|
|
789
867
|
|
|
790
868
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
791
869
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
870
|
+
function isInteractiveMouseTarget(target) {
|
|
871
|
+
if (!(target instanceof Element)) return false;
|
|
872
|
+
const interactiveSelector = [
|
|
873
|
+
"input",
|
|
874
|
+
"textarea",
|
|
875
|
+
"select",
|
|
876
|
+
"button",
|
|
877
|
+
"a[href]",
|
|
878
|
+
"[contenteditable]:not([contenteditable='false'])",
|
|
879
|
+
"[data-table-disable-cell-selection]"
|
|
880
|
+
].join(",");
|
|
881
|
+
return target.closest(interactiveSelector) !== null;
|
|
882
|
+
}
|
|
792
883
|
function resolveExpandCellIndex(cells, toggleField) {
|
|
793
884
|
if (!toggleField) return 0;
|
|
794
885
|
const matchedIndex = cells.findIndex(
|
|
@@ -809,7 +900,18 @@ function DataTableRow({
|
|
|
809
900
|
virtualIndex,
|
|
810
901
|
measureElement
|
|
811
902
|
}) {
|
|
812
|
-
const {
|
|
903
|
+
const {
|
|
904
|
+
classNames,
|
|
905
|
+
rowSpan,
|
|
906
|
+
selection,
|
|
907
|
+
cellSelection,
|
|
908
|
+
cellEdit,
|
|
909
|
+
expand,
|
|
910
|
+
columnResize,
|
|
911
|
+
columnFreeze
|
|
912
|
+
} = useDataTableRowContext();
|
|
913
|
+
const { enableColumnResize } = columnResize;
|
|
914
|
+
const { enableColumnFreeze, offsets: freezeOffsets } = columnFreeze;
|
|
813
915
|
const {
|
|
814
916
|
enableRowSpan,
|
|
815
917
|
primaryRowSpanColumnId,
|
|
@@ -855,6 +957,33 @@ function DataTableRow({
|
|
|
855
957
|
const isGroupHovered = enableRowSpan && hoveredRowIndex !== null && hoveredRowIndex >= primaryGroupStart && hoveredRowIndex <= primaryGroupStart + primaryGroupSpan - 1;
|
|
856
958
|
const visibleCells = row.getVisibleCells();
|
|
857
959
|
const columnIdsByIndex = visibleCells.map((cell) => cell.column.id);
|
|
960
|
+
row.getIsCellDragSelected = (columnId) => {
|
|
961
|
+
if (!activeSelectionBounds) return false;
|
|
962
|
+
if (columnId) {
|
|
963
|
+
const colIndex = columnIdsByIndex.indexOf(columnId);
|
|
964
|
+
if (colIndex < 0) return false;
|
|
965
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
966
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
967
|
+
rowIndex
|
|
968
|
+
);
|
|
969
|
+
return isCellInSelection(
|
|
970
|
+
startRow,
|
|
971
|
+
colIndex,
|
|
972
|
+
activeSelectionBounds,
|
|
973
|
+
rowSpan2
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
for (let colIndex = 0; colIndex < columnIdsByIndex.length; colIndex += 1) {
|
|
977
|
+
const { startRow, rowSpan: rowSpan2 } = resolveRowSpanAt(
|
|
978
|
+
columnRowSpanMap.get(columnIdsByIndex[colIndex]),
|
|
979
|
+
rowIndex
|
|
980
|
+
);
|
|
981
|
+
if (isCellInSelection(startRow, colIndex, activeSelectionBounds, rowSpan2)) {
|
|
982
|
+
return true;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return false;
|
|
986
|
+
};
|
|
858
987
|
const isVisuallySelectedAt = activeSelectionBounds ? (targetRow, targetCol) => {
|
|
859
988
|
if (targetCol < activeSelectionBounds.startCol || targetCol > activeSelectionBounds.endCol) {
|
|
860
989
|
return false;
|
|
@@ -963,6 +1092,17 @@ function DataTableRow({
|
|
|
963
1092
|
);
|
|
964
1093
|
const resolveCellRowIndex = (clientY, element) => getRowIndexInMergedCell(clientY, element, rowIndex, cellRowSpan);
|
|
965
1094
|
const hasSelectionEdges = hasCellSelectionEdges(selectionEdgeStyle);
|
|
1095
|
+
const sizeStyle = getColumnSizeStyle(cell.column.getSize(), {
|
|
1096
|
+
force: enableColumnResize,
|
|
1097
|
+
lockMax: enableColumnResize
|
|
1098
|
+
});
|
|
1099
|
+
const freezeOffset = enableColumnFreeze ? freezeOffsets.get(columnId) : void 0;
|
|
1100
|
+
const freezeStyle = getColumnFreezeStyle(freezeOffset);
|
|
1101
|
+
const cellStyle = {
|
|
1102
|
+
...sizeStyle,
|
|
1103
|
+
...freezeStyle,
|
|
1104
|
+
...selectionEdgeStyle
|
|
1105
|
+
};
|
|
966
1106
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
967
1107
|
"td",
|
|
968
1108
|
{
|
|
@@ -976,12 +1116,15 @@ function DataTableRow({
|
|
|
976
1116
|
"data-selection-edges": hasSelectionEdges ? "" : void 0,
|
|
977
1117
|
"data-editable": editable ? "" : void 0,
|
|
978
1118
|
"data-editing": isEditing ? "" : void 0,
|
|
1119
|
+
"data-frozen": freezeOffset?.side,
|
|
1120
|
+
"data-freeze-edge": freezeOffset?.isEdge ? "" : void 0,
|
|
979
1121
|
onMouseDown: (event) => {
|
|
980
1122
|
if (isEditing) {
|
|
981
1123
|
event.stopPropagation();
|
|
982
1124
|
return;
|
|
983
1125
|
}
|
|
984
1126
|
if (!enableCellSelection) return;
|
|
1127
|
+
if (isInteractiveMouseTarget(event.target)) return;
|
|
985
1128
|
event.preventDefault();
|
|
986
1129
|
onCellMouseDown(
|
|
987
1130
|
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
@@ -1009,9 +1152,10 @@ function DataTableRow({
|
|
|
1009
1152
|
event.stopPropagation();
|
|
1010
1153
|
onStartEdit(rowIndex, cellIndex);
|
|
1011
1154
|
},
|
|
1012
|
-
style:
|
|
1155
|
+
style: Object.keys(cellStyle).length > 0 ? cellStyle : void 0,
|
|
1013
1156
|
className: cn(
|
|
1014
1157
|
"data-table-cell",
|
|
1158
|
+
freezeOffset && `data-table-cell--frozen-${freezeOffset.side}`,
|
|
1015
1159
|
CELL_ALIGN_CLASS[align],
|
|
1016
1160
|
cellClassName,
|
|
1017
1161
|
isMerged && "is-merged",
|
|
@@ -1762,7 +1906,8 @@ var DEFAULT_DATA_TABLE_LABELS = {
|
|
|
1762
1906
|
loading: "Loading...",
|
|
1763
1907
|
selection: (selectedCount) => selectedCount > 0 ? `\u2713 ${selectedCount} selected` : null,
|
|
1764
1908
|
expandRow: "Expand row",
|
|
1765
|
-
collapseRow: "Collapse row"
|
|
1909
|
+
collapseRow: "Collapse row",
|
|
1910
|
+
resizeColumn: "Resize column"
|
|
1766
1911
|
};
|
|
1767
1912
|
function resolveDataTableLabels(partial) {
|
|
1768
1913
|
return {
|
|
@@ -1772,6 +1917,7 @@ function resolveDataTableLabels(partial) {
|
|
|
1772
1917
|
}
|
|
1773
1918
|
|
|
1774
1919
|
// src/core/useGlideTable.ts
|
|
1920
|
+
var EMPTY_COLUMN_FREEZE_OFFSETS = /* @__PURE__ */ new Map();
|
|
1775
1921
|
function useGlideTable(options) {
|
|
1776
1922
|
const {
|
|
1777
1923
|
data,
|
|
@@ -1807,7 +1953,12 @@ function useGlideTable(options) {
|
|
|
1807
1953
|
enableInsertPaste,
|
|
1808
1954
|
enableVirtualization = true,
|
|
1809
1955
|
estimateRowHeight = DATA_TABLE_ROW_HEIGHT,
|
|
1810
|
-
virtualOverscan = DATA_TABLE_VIRTUAL_OVERSCAN
|
|
1956
|
+
virtualOverscan = DATA_TABLE_VIRTUAL_OVERSCAN,
|
|
1957
|
+
enableColumnResize = false,
|
|
1958
|
+
columnSizing: controlledColumnSizing,
|
|
1959
|
+
onColumnSizingChange,
|
|
1960
|
+
columnResizeMode = "onChange",
|
|
1961
|
+
enableColumnFreeze = false
|
|
1811
1962
|
} = options;
|
|
1812
1963
|
const labels = (0, import_react6.useMemo)(() => {
|
|
1813
1964
|
const resolved = resolveDataTableLabels(labelsProp);
|
|
@@ -1821,6 +1972,7 @@ function useGlideTable(options) {
|
|
|
1821
1972
|
const enableExpand = Boolean(toggleField);
|
|
1822
1973
|
const resolvedEnableSubtreeCopy = enableSubtreeCopy ?? enableExpand;
|
|
1823
1974
|
const [internalRowSelection, setInternalRowSelection] = (0, import_react6.useState)({});
|
|
1975
|
+
const [internalColumnSizing, setInternalColumnSizing] = (0, import_react6.useState)({});
|
|
1824
1976
|
const [internalExpandedRows, setInternalExpandedRows] = (0, import_react6.useState)(
|
|
1825
1977
|
() => /* @__PURE__ */ new Set()
|
|
1826
1978
|
);
|
|
@@ -1839,6 +1991,7 @@ function useGlideTable(options) {
|
|
|
1839
1991
|
controlledRowSelection,
|
|
1840
1992
|
internalRowSelection
|
|
1841
1993
|
);
|
|
1994
|
+
const columnSizing = controlledColumnSizing ?? internalColumnSizing;
|
|
1842
1995
|
const expandedRows = controlledExpandedRows ?? internalExpandedRows;
|
|
1843
1996
|
const handleExpandedRowsChange = (0, import_react6.useCallback)(
|
|
1844
1997
|
(next) => {
|
|
@@ -1864,9 +2017,27 @@ function useGlideTable(options) {
|
|
|
1864
2017
|
const table = (0, import_react_table2.useReactTable)({
|
|
1865
2018
|
data: tableData,
|
|
1866
2019
|
columns,
|
|
2020
|
+
...enableColumnResize ? {
|
|
2021
|
+
defaultColumn: {
|
|
2022
|
+
minSize: DATA_TABLE_COLUMN_MIN_SIZE,
|
|
2023
|
+
maxSize: DATA_TABLE_COLUMN_MAX_SIZE
|
|
2024
|
+
}
|
|
2025
|
+
} : {},
|
|
2026
|
+
enableColumnResizing: enableColumnResize,
|
|
2027
|
+
columnResizeMode,
|
|
1867
2028
|
state: {
|
|
1868
|
-
rowSelection: rowSelectionMode === "none" ? {} : rowSelection
|
|
2029
|
+
rowSelection: rowSelectionMode === "none" ? {} : rowSelection,
|
|
2030
|
+
...enableColumnResize ? { columnSizing } : {}
|
|
1869
2031
|
},
|
|
2032
|
+
onColumnSizingChange: enableColumnResize ? (updater) => {
|
|
2033
|
+
if (onColumnSizingChange) {
|
|
2034
|
+
onColumnSizingChange(updater);
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
setInternalColumnSizing(
|
|
2038
|
+
(previous) => typeof updater === "function" ? updater(previous) : updater
|
|
2039
|
+
);
|
|
2040
|
+
} : void 0,
|
|
1870
2041
|
enableRowSelection: rowSelectionMode === "none" ? false : getRowCanSelect ? (row) => getRowCanSelect(row.original, row.index) : true,
|
|
1871
2042
|
enableMultiRowSelection: rowSelectionMode === "multi",
|
|
1872
2043
|
onRowSelectionChange: (updater) => {
|
|
@@ -1897,6 +2068,17 @@ function useGlideTable(options) {
|
|
|
1897
2068
|
const selectedCount = selectedRows.length;
|
|
1898
2069
|
const rows = table.getRowModel().rows;
|
|
1899
2070
|
const columnCount = table.getAllLeafColumns().length || 1;
|
|
2071
|
+
const visibleLeafColumns = table.getVisibleLeafColumns();
|
|
2072
|
+
const columnFreezeOffsets = (0, import_react6.useMemo)(() => {
|
|
2073
|
+
if (!enableColumnFreeze) return EMPTY_COLUMN_FREEZE_OFFSETS;
|
|
2074
|
+
return buildColumnFreezeOffsets(
|
|
2075
|
+
visibleLeafColumns.map((column) => ({
|
|
2076
|
+
id: column.id,
|
|
2077
|
+
size: column.getSize(),
|
|
2078
|
+
side: resolveColumnFreezeSide(column.columnDef.meta?.frozen)
|
|
2079
|
+
}))
|
|
2080
|
+
);
|
|
2081
|
+
}, [enableColumnFreeze, visibleLeafColumns, columnSizing]);
|
|
1900
2082
|
const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
1901
2083
|
count: shouldVirtualize ? rows.length : 0,
|
|
1902
2084
|
getScrollElement: () => scrollRef.current,
|
|
@@ -2013,6 +2195,13 @@ function useGlideTable(options) {
|
|
|
2013
2195
|
onToggleExpand: handleToggleExpand,
|
|
2014
2196
|
expandRowLabel: labels.expandRow,
|
|
2015
2197
|
collapseRowLabel: labels.collapseRow
|
|
2198
|
+
},
|
|
2199
|
+
columnResize: {
|
|
2200
|
+
enableColumnResize
|
|
2201
|
+
},
|
|
2202
|
+
columnFreeze: {
|
|
2203
|
+
enableColumnFreeze,
|
|
2204
|
+
offsets: columnFreezeOffsets
|
|
2016
2205
|
}
|
|
2017
2206
|
};
|
|
2018
2207
|
}, [
|
|
@@ -2045,7 +2234,10 @@ function useGlideTable(options) {
|
|
|
2045
2234
|
preventExpand,
|
|
2046
2235
|
handleToggleExpand,
|
|
2047
2236
|
labels.expandRow,
|
|
2048
|
-
labels.collapseRow
|
|
2237
|
+
labels.collapseRow,
|
|
2238
|
+
enableColumnResize,
|
|
2239
|
+
enableColumnFreeze,
|
|
2240
|
+
columnFreezeOffsets
|
|
2049
2241
|
]);
|
|
2050
2242
|
const copySelectionRef = (0, import_react6.useRef)(copySelection);
|
|
2051
2243
|
(0, import_react6.useEffect)(() => {
|
|
@@ -2066,6 +2258,8 @@ function useGlideTable(options) {
|
|
|
2066
2258
|
loadingText: labels.loading,
|
|
2067
2259
|
selectionLabel: labels.selection,
|
|
2068
2260
|
enableCellSelection,
|
|
2261
|
+
enableColumnResize,
|
|
2262
|
+
enableColumnFreeze,
|
|
2069
2263
|
shouldVirtualize,
|
|
2070
2264
|
scrollRef,
|
|
2071
2265
|
rowVirtualizer,
|
|
@@ -2131,10 +2325,13 @@ function DataTable({
|
|
|
2131
2325
|
rows,
|
|
2132
2326
|
columnCount,
|
|
2133
2327
|
selectedCount,
|
|
2328
|
+
labels,
|
|
2134
2329
|
emptyText,
|
|
2135
2330
|
loadingText,
|
|
2136
2331
|
selectionLabel,
|
|
2137
2332
|
enableCellSelection,
|
|
2333
|
+
enableColumnResize,
|
|
2334
|
+
enableColumnFreeze,
|
|
2138
2335
|
shouldVirtualize,
|
|
2139
2336
|
scrollRef,
|
|
2140
2337
|
rowVirtualizer,
|
|
@@ -2149,6 +2346,7 @@ function DataTable({
|
|
|
2149
2346
|
const RowSlot = slots?.Row ?? DataTableRow;
|
|
2150
2347
|
const PendingSlot = slots?.Pending ?? DefaultPending;
|
|
2151
2348
|
const EmptySlot = slots?.Empty ?? DefaultEmpty;
|
|
2349
|
+
const freezeOffsets = rowContextValue.columnFreeze.offsets;
|
|
2152
2350
|
const contextValue = (0, import_react7.useMemo)(
|
|
2153
2351
|
() => ({ ...rowContextValue, classNames }),
|
|
2154
2352
|
[rowContextValue, classNames]
|
|
@@ -2169,6 +2367,8 @@ function DataTable({
|
|
|
2169
2367
|
className: cn(
|
|
2170
2368
|
"DataTableJSX",
|
|
2171
2369
|
!enableCellSelection && "DataTableJSX--no-cell-selection",
|
|
2370
|
+
enableColumnResize && "DataTableJSX--column-resize",
|
|
2371
|
+
enableColumnFreeze && "DataTableJSX--column-freeze",
|
|
2172
2372
|
classNames?.root,
|
|
2173
2373
|
className
|
|
2174
2374
|
),
|
|
@@ -2189,6 +2389,7 @@ function DataTable({
|
|
|
2189
2389
|
"table",
|
|
2190
2390
|
{
|
|
2191
2391
|
className: cn("data-table", classNames?.table),
|
|
2392
|
+
style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
|
|
2192
2393
|
onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
|
|
2193
2394
|
children: [
|
|
2194
2395
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: cn("data-table-head", classNames?.head), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -2198,22 +2399,54 @@ function DataTable({
|
|
|
2198
2399
|
children: headerGroup.headers.map((header) => {
|
|
2199
2400
|
const align = header.column.columnDef.meta?.align ?? "center";
|
|
2200
2401
|
const headerClassName = header.column.columnDef.meta?.headerClassName;
|
|
2201
|
-
|
|
2402
|
+
const canResize = enableColumnResize && header.column.getCanResize();
|
|
2403
|
+
const sizeStyle = getColumnSizeStyle(header.getSize(), {
|
|
2404
|
+
force: enableColumnResize,
|
|
2405
|
+
lockMax: enableColumnResize
|
|
2406
|
+
});
|
|
2407
|
+
const freezeOffset = enableColumnFreeze ? freezeOffsets.get(header.column.id) : void 0;
|
|
2408
|
+
const freezeStyle = getColumnFreezeStyle(freezeOffset, {
|
|
2409
|
+
isHeader: true
|
|
2410
|
+
});
|
|
2411
|
+
const headerStyle = {
|
|
2412
|
+
...sizeStyle,
|
|
2413
|
+
...freezeStyle
|
|
2414
|
+
};
|
|
2415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2202
2416
|
"th",
|
|
2203
2417
|
{
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
minWidth: header.getSize() !== 150 ? header.getSize() : void 0
|
|
2209
|
-
},
|
|
2418
|
+
"data-resizing": header.column.getIsResizing() ? "" : void 0,
|
|
2419
|
+
"data-frozen": freezeOffset?.side,
|
|
2420
|
+
"data-freeze-edge": freezeOffset?.isEdge ? "" : void 0,
|
|
2421
|
+
style: Object.keys(headerStyle).length > 0 ? headerStyle : void 0,
|
|
2210
2422
|
className: cn(
|
|
2211
2423
|
"data-table-head-cell",
|
|
2424
|
+
freezeOffset && `data-table-head-cell--frozen-${freezeOffset.side}`,
|
|
2212
2425
|
CELL_ALIGN_CLASS[align],
|
|
2213
2426
|
classNames?.headCell,
|
|
2214
2427
|
headerClassName
|
|
2215
2428
|
),
|
|
2216
|
-
children:
|
|
2429
|
+
children: [
|
|
2430
|
+
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
2431
|
+
canResize ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2432
|
+
"div",
|
|
2433
|
+
{
|
|
2434
|
+
role: "separator",
|
|
2435
|
+
"aria-orientation": "vertical",
|
|
2436
|
+
"aria-label": labels.resizeColumn,
|
|
2437
|
+
"data-table-disable-cell-selection": "",
|
|
2438
|
+
className: cn(
|
|
2439
|
+
"data-table-resize-handle",
|
|
2440
|
+
classNames?.resizeHandle
|
|
2441
|
+
),
|
|
2442
|
+
onMouseDown: header.getResizeHandler(),
|
|
2443
|
+
onTouchStart: header.getResizeHandler(),
|
|
2444
|
+
onDoubleClick: () => {
|
|
2445
|
+
header.column.resetSize();
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
) : null
|
|
2449
|
+
]
|
|
2217
2450
|
},
|
|
2218
2451
|
header.id
|
|
2219
2452
|
);
|
|
@@ -2341,6 +2574,10 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2341
2574
|
children,
|
|
2342
2575
|
sortable = false,
|
|
2343
2576
|
width,
|
|
2577
|
+
minWidth,
|
|
2578
|
+
maxWidth,
|
|
2579
|
+
resizable,
|
|
2580
|
+
frozen,
|
|
2344
2581
|
align,
|
|
2345
2582
|
rowSpan,
|
|
2346
2583
|
rowSpanKey,
|
|
@@ -2354,7 +2591,10 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2354
2591
|
return {
|
|
2355
2592
|
id: field,
|
|
2356
2593
|
...!virtual ? { accessorKey: field } : {},
|
|
2357
|
-
size: width ??
|
|
2594
|
+
size: width ?? DATA_TABLE_COLUMN_SIZE,
|
|
2595
|
+
...minWidth != null ? { minSize: minWidth } : {},
|
|
2596
|
+
...maxWidth != null ? { maxSize: maxWidth } : {},
|
|
2597
|
+
...resizable === false ? { enableResizing: false } : {},
|
|
2358
2598
|
header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SortableHeader, { label: children, field, sort, onSort }) : (
|
|
2359
2599
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
2360
2600
|
() => children
|
|
@@ -2374,6 +2614,7 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
2374
2614
|
editable,
|
|
2375
2615
|
editType,
|
|
2376
2616
|
editInputProps,
|
|
2617
|
+
frozen,
|
|
2377
2618
|
className,
|
|
2378
2619
|
headerClassName
|
|
2379
2620
|
}
|
package/dist/compound.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { a as
|
|
5
|
-
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
3
|
+
import { g as DataTableProps, T as TableColumnProps, j as TableProps } from './types-D031_07N.cjs';
|
|
4
|
+
export { a as ColumnFreezeMeta, c as ColumnFreezeSide, d as DataTableClassNames, f as DataTableLabels, h as DataTableSlots, P as PasteMode, R as RowSelectionMode, i as RowsPastePayload } from './types-D031_07N.cjs';
|
|
5
|
+
export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Unstyled DataTable shell: semantic HTML + interaction behavior.
|
package/dist/compound.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { a as
|
|
5
|
-
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
3
|
+
import { g as DataTableProps, T as TableColumnProps, j as TableProps } from './types-D031_07N.js';
|
|
4
|
+
export { a as ColumnFreezeMeta, c as ColumnFreezeSide, d as DataTableClassNames, f as DataTableLabels, h as DataTableSlots, P as PasteMode, R as RowSelectionMode, i as RowsPastePayload } from './types-D031_07N.js';
|
|
5
|
+
export { ColumnDef, ColumnResizeMode, ColumnSizingState, RowSelectionState } from '@tanstack/react-table';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Unstyled DataTable shell: semantic HTML + interaction behavior.
|