material-react-table 0.9.3 → 0.9.4

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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.3",
2
+ "version": "0.9.4",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
@@ -767,6 +767,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
767
767
  IconButtonProps & { tableInstance: MRT_TableInstance<D> }
768
768
  >;
769
769
  }) => ReactNode;
770
+ rowNumberMode?: 'original' | 'static';
770
771
  selectAllMode?: 'all' | 'page';
771
772
  tableId?: string;
772
773
  };
@@ -806,6 +807,7 @@ export default <D extends Record<string, any> = {}>({
806
807
  positionGlobalFilter = 'right',
807
808
  positionToolbarActions = 'top',
808
809
  positionToolbarAlertBanner = 'top',
810
+ rowNumberMode = 'original',
809
811
  selectAllMode = 'all',
810
812
  ...rest
811
813
  }: MaterialReactTableProps<D>) => (
@@ -844,6 +846,7 @@ export default <D extends Record<string, any> = {}>({
844
846
  positionPagination={positionPagination}
845
847
  positionToolbarActions={positionToolbarActions}
846
848
  positionToolbarAlertBanner={positionToolbarAlertBanner}
849
+ rowNumberMode={rowNumberMode}
847
850
  selectAllMode={selectAllMode}
848
851
  {...rest}
849
852
  />
@@ -55,7 +55,7 @@ export const MRT_TableBody: FC<Props> = ({
55
55
  )}
56
56
  {/* @ts-ignore */}
57
57
  {(enableRowVirtualization ? virtualRows : rows).map(
58
- (rowOrVirtualRow: any) => {
58
+ (rowOrVirtualRow: any, rowIndex: number) => {
59
59
  const row = enableRowVirtualization
60
60
  ? (rows[rowOrVirtualRow.index] as MRT_Row)
61
61
  : (rowOrVirtualRow as MRT_Row);
@@ -63,6 +63,9 @@ export const MRT_TableBody: FC<Props> = ({
63
63
  <MRT_TableBodyRow
64
64
  key={row.id}
65
65
  row={row}
66
+ rowIndex={
67
+ enableRowVirtualization ? rowOrVirtualRow.index : rowIndex
68
+ }
66
69
  tableInstance={tableInstance}
67
70
  />
68
71
  );
@@ -9,12 +9,14 @@ import type { MRT_Cell, MRT_Column, MRT_TableInstance } from '..';
9
9
  interface Props {
10
10
  cell: MRT_Cell;
11
11
  enableHover?: boolean;
12
+ rowIndex: number;
12
13
  tableInstance: MRT_TableInstance;
13
14
  }
14
15
 
15
16
  export const MRT_TableBodyCell: FC<Props> = ({
16
17
  cell,
17
18
  enableHover,
19
+ rowIndex,
18
20
  tableInstance,
19
21
  }) => {
20
22
  const {
@@ -25,10 +27,12 @@ export const MRT_TableBodyCell: FC<Props> = ({
25
27
  enableColumnOrdering,
26
28
  enableColumnResizing,
27
29
  enableEditing,
30
+ enableRowNumbers,
28
31
  enableRowVirtualization,
29
32
  muiTableBodyCellProps,
30
33
  muiTableBodyCellSkeletonProps,
31
34
  onMrtCellClick,
35
+ rowNumberMode,
32
36
  tableId,
33
37
  },
34
38
  setColumnOrder,
@@ -206,6 +210,10 @@ export const MRT_TableBodyCell: FC<Props> = ({
206
210
  width={skeletonWidth}
207
211
  {...muiTableBodyCellSkeletonProps}
208
212
  />
213
+ ) : enableRowNumbers &&
214
+ rowNumberMode === 'static' &&
215
+ column.id === 'mrt-row-numbers' ? (
216
+ rowIndex + 1
209
217
  ) : columnDefType === 'display' ? (
210
218
  columnDef.Cell?.({ cell, tableInstance })
211
219
  ) : cell.getIsPlaceholder() ||
@@ -6,10 +6,11 @@ import type { MRT_Row, MRT_TableInstance } from '..';
6
6
 
7
7
  interface Props {
8
8
  row: MRT_Row;
9
+ rowIndex: number;
9
10
  tableInstance: MRT_TableInstance;
10
11
  }
11
12
 
12
- export const MRT_TableBodyRow: FC<Props> = ({ row, tableInstance }) => {
13
+ export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, tableInstance }) => {
13
14
  const {
14
15
  getIsSomeColumnsPinned,
15
16
  options: { muiTableBodyRowProps, onMrtRowClick, renderDetailPanel },
@@ -48,6 +49,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, tableInstance }) => {
48
49
  cell={cell}
49
50
  key={cell.id}
50
51
  enableHover={tableRowProps?.hover !== false}
52
+ rowIndex={rowIndex}
51
53
  tableInstance={tableInstance}
52
54
  />
53
55
  ))}