material-react-table 1.7.1 → 1.7.3
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/cjs/index.js +5 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/column.utils.d.ts +1 -0
- package/dist/esm/material-react-table.esm.js +5 -4
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/column.utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/column.utils.ts +11 -10
- package/src/table/MRT_Table.tsx +2 -1
package/package.json
CHANGED
package/src/column.utils.ts
CHANGED
@@ -263,7 +263,7 @@ export const getCommonCellStyles = ({
|
|
263
263
|
display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell',
|
264
264
|
flex:
|
265
265
|
table.options.layoutMode === 'grid'
|
266
|
-
? `var(--col-${column.id
|
266
|
+
? `var(--col-${parseCSSVarId(column.id)}-size) 0 auto`
|
267
267
|
: undefined,
|
268
268
|
left:
|
269
269
|
column.getIsPinned() === 'left'
|
@@ -300,18 +300,16 @@ export const getCommonCellStyles = ({
|
|
300
300
|
column.getIsPinned() === 'right'
|
301
301
|
? `${getTotalRight(table, column)}px`
|
302
302
|
: undefined,
|
303
|
-
transition:
|
304
|
-
|
305
|
-
|
306
|
-
: `padding 150ms ease-in-out`,
|
303
|
+
transition: table.options.enableColumnVirtualization
|
304
|
+
? 'none'
|
305
|
+
: `padding 150ms ease-in-out`,
|
307
306
|
...(tableCellProps?.sx instanceof Function
|
308
307
|
? tableCellProps.sx(theme)
|
309
308
|
: (tableCellProps?.sx as any)),
|
310
|
-
minWidth: `max(calc(var(--col-${column.id
|
311
|
-
|
312
|
-
|
313
|
-
)}-size) * 1px)
|
314
|
-
width: `calc(var(--col-${column.id.replaceAll('.', '_')}-size) * 1px)`,
|
309
|
+
minWidth: `max(calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px), ${
|
310
|
+
column.columnDef.minSize ?? 30
|
311
|
+
}px)`,
|
312
|
+
width: `calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px)`,
|
315
313
|
});
|
316
314
|
|
317
315
|
export const MRT_DefaultColumn = {
|
@@ -335,3 +333,6 @@ export const MRT_DefaultDisplayColumn = {
|
|
335
333
|
enableResizing: false,
|
336
334
|
enableSorting: false,
|
337
335
|
} as const;
|
336
|
+
|
337
|
+
export const parseCSSVarId = (id: string) =>
|
338
|
+
id.replaceAll('.', '_').replaceAll(' ', '_').replaceAll('+', '_');
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -9,6 +9,7 @@ import Table from '@mui/material/Table';
|
|
9
9
|
import { MRT_TableHead } from '../head/MRT_TableHead';
|
10
10
|
import { Memo_MRT_TableBody, MRT_TableBody } from '../body/MRT_TableBody';
|
11
11
|
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
12
|
+
import { parseCSSVarId } from '../column.utils';
|
12
13
|
import type { MRT_TableInstance } from '..';
|
13
14
|
|
14
15
|
interface Props {
|
@@ -58,7 +59,7 @@ export const MRT_Table = ({ table }: Props) => {
|
|
58
59
|
const colSizes: { [key: string]: number } = {};
|
59
60
|
for (let i = 0; i < headers.length; i++) {
|
60
61
|
const h = headers[i];
|
61
|
-
colSizes[`--col-${h.column.id}-size
|
62
|
+
colSizes[`--col-${parseCSSVarId(h.column.id)}-size`] = h.getSize();
|
62
63
|
}
|
63
64
|
return colSizes;
|
64
65
|
}, [columns, columnSizing, columnSizingInfo]);
|