material-react-table 1.5.0-beta.1 → 1.5.0-beta.2
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/package.json
CHANGED
package/src/column.utils.ts
CHANGED
@@ -221,7 +221,7 @@ export const getIsFirstRightPinnedColumn = (column: MRT_Column) => {
|
|
221
221
|
|
222
222
|
export const getTotalRight = (table: MRT_TableInstance, column: MRT_Column) => {
|
223
223
|
return (
|
224
|
-
(table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) *
|
224
|
+
(table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 200
|
225
225
|
);
|
226
226
|
};
|
227
227
|
|
@@ -253,6 +253,26 @@ export const getCommonCellStyles = ({
|
|
253
253
|
column.getIsPinned() === 'left'
|
254
254
|
? `${column.getStart('left')}px`
|
255
255
|
: undefined,
|
256
|
+
ml:
|
257
|
+
table.options.enableColumnVirtualization &&
|
258
|
+
column.getIsPinned() === 'left' &&
|
259
|
+
column.getPinnedIndex() === 0
|
260
|
+
? `-${
|
261
|
+
column.getSize() *
|
262
|
+
(table.getState().columnPinning.left?.length ?? 1) *
|
263
|
+
1.2
|
264
|
+
}px`
|
265
|
+
: undefined,
|
266
|
+
mr:
|
267
|
+
table.options.enableColumnVirtualization &&
|
268
|
+
column.getIsPinned() === 'right' &&
|
269
|
+
column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
|
270
|
+
? `-${
|
271
|
+
column.getSize() *
|
272
|
+
(table.getState().columnPinning.right?.length ?? 1) *
|
273
|
+
1.2
|
274
|
+
}px`
|
275
|
+
: undefined,
|
256
276
|
opacity:
|
257
277
|
table.getState().draggingColumn?.id === column.id ||
|
258
278
|
table.getState().hoveredColumn?.id === column.id
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -52,25 +52,23 @@ export const MRT_Table: FC<Props> = ({ table }) => {
|
|
52
52
|
.getRowModel()
|
53
53
|
.rows[0]?.getCenterVisibleCells()
|
54
54
|
?.slice(0, 16)
|
55
|
-
?.map((cell) => cell.column.getSize() * 1.
|
55
|
+
?.map((cell) => cell.column.getSize() * 1.2) ?? [];
|
56
56
|
return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
|
57
57
|
}, [table.getRowModel().rows, columnPinning, columnVisibility]);
|
58
58
|
|
59
|
-
const
|
59
|
+
const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(
|
60
60
|
() =>
|
61
61
|
enableColumnVirtualization && enablePinning
|
62
62
|
? [
|
63
|
-
|
64
|
-
|
65
|
-
.
|
63
|
+
table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
|
64
|
+
table
|
65
|
+
.getRightLeafColumns()
|
66
66
|
.map(
|
67
|
-
(
|
68
|
-
table.
|
69
|
-
h.column.getPinnedIndex() -
|
70
|
-
1,
|
67
|
+
(c) =>
|
68
|
+
table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1,
|
71
69
|
),
|
72
70
|
]
|
73
|
-
: [],
|
71
|
+
: [[], []],
|
74
72
|
[columnPinning, enableColumnVirtualization, enablePinning],
|
75
73
|
);
|
76
74
|
|
@@ -78,21 +76,20 @@ export const MRT_Table: FC<Props> = ({ table }) => {
|
|
78
76
|
| Virtualizer<HTMLDivElement, HTMLTableCellElement>
|
79
77
|
| undefined = enableColumnVirtualization
|
80
78
|
? useVirtualizer({
|
81
|
-
count: table.
|
79
|
+
count: table.getVisibleLeafColumns().length,
|
82
80
|
estimateSize: () => averageColumnWidth,
|
83
81
|
getScrollElement: () => tableContainerRef.current,
|
84
82
|
horizontal: true,
|
85
|
-
measureElement: (element) => element?.getBoundingClientRect().width,
|
86
83
|
overscan: 3,
|
87
84
|
rangeExtractor: useCallback(
|
88
|
-
(range: Range) =>
|
89
|
-
[
|
90
|
-
...
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
[
|
85
|
+
(range: Range) => [
|
86
|
+
...new Set([
|
87
|
+
...leftPinnedIndexes,
|
88
|
+
...defaultRangeExtractor(range),
|
89
|
+
...rightPinnedIndexes,
|
90
|
+
]),
|
91
|
+
],
|
92
|
+
[leftPinnedIndexes, rightPinnedIndexes],
|
96
93
|
),
|
97
94
|
...vProps,
|
98
95
|
})
|
@@ -110,13 +107,11 @@ export const MRT_Table: FC<Props> = ({ table }) => {
|
|
110
107
|
let virtualPaddingRight: number | undefined;
|
111
108
|
|
112
109
|
if (columnVirtualizer && virtualColumns?.length) {
|
113
|
-
virtualPaddingLeft = virtualColumns?.
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
(virtualColumns[virtualColumns.length - 1]?.end || 0)
|
119
|
-
: 0;
|
110
|
+
virtualPaddingLeft = virtualColumns[leftPinnedIndexes.length]?.start ?? 0;
|
111
|
+
virtualPaddingRight =
|
112
|
+
columnVirtualizer.getTotalSize() -
|
113
|
+
(virtualColumns[virtualColumns.length - 1 - rightPinnedIndexes.length]
|
114
|
+
?.end ?? 0);
|
120
115
|
}
|
121
116
|
|
122
117
|
const props = {
|