Skip to content

Commit b63bbd0

Browse files
authored
Merge pull request #725 from icflorescu/next
Use ref prop instead of forwardRef, which was deprecated in React 19
2 parents da65561 + 06d1edb commit b63bbd0

File tree

8 files changed

+520
-502
lines changed

8 files changed

+520
-502
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
The following is a list of notable changes to the Mantine DataTable component.
44
Minor versions that are not listed in the changelog are bug fixes and small improvements.
55

6-
## 8.1.0 (2025-03-16)
6+
## 8.1.2 (2025-03-24)
7+
8+
- Use `ref` prop instead of `forwardRef`, which was deprecated in React 19
9+
- Update dev deps
10+
11+
## 8.1.1 (2025-06-16)
712

813
- Update dependencies to ensure compatibility with Mantine 8.1.1
914

10-
## 8.1.0 (2025-03-11)
15+
## 8.1.0 (2025-06-11)
1116

1217
- Update dependencies to ensure compatibility with Mantine 8.1 and Next.js 15.3
1318
- Fix [#698](https://github.com/icflorescu/mantine-datatable/issues/698) - first column header not pinned when using row selection

app/config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { MantineColor } from '@mantine/core';
2-
import type { Icon, IconProps } from '@tabler/icons-react';
2+
import type { Icon } from '@tabler/icons-react';
33
import {
44
IconAdjustments,
55
IconBrandCss3,
@@ -11,7 +11,6 @@ import {
1111
IconThumbUp,
1212
} from '@tabler/icons-react';
1313
import type { Route } from 'next';
14-
import type { ForwardRefExoticComponent, RefAttributes } from 'react';
1514

1615
export const PRODUCT_NAME = 'Mantine DataTable';
1716
export const PRODUCT_DESCRIPTION =
@@ -47,10 +46,7 @@ export type RouteInfo = {
4746
href: Route;
4847
title: string;
4948
description: string;
50-
} & (
51-
| { icon?: never; color?: never }
52-
| { icon: ForwardRefExoticComponent<Omit<IconProps, 'ref'> & RefAttributes<Icon>>; color: MantineColor }
53-
);
49+
} & ({ icon?: never; color?: never } | { icon: Icon; color: MantineColor });
5450

5551
export const EXAMPLES_ROUTE_COLOR: MantineColor = 'green';
5652

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mantine-datatable",
3-
"version": "8.1.1",
3+
"version": "8.1.2",
44
"description": "The lightweight, dependency-free, dark-theme aware table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagination, intuitive Gmail-style additive batch rows selection, column sorting, custom cell data rendering, row expansion, nesting, context menus, and much more",
55
"keywords": [
66
"mantine",
@@ -84,32 +84,32 @@
8484
"@mantine/modals": "^8.1.1",
8585
"@mantine/notifications": "^8.1.1",
8686
"@tabler/icons-react": "^3.34.0",
87-
"@tanstack/react-query": "^5.80.7",
88-
"@types/lodash": "^4.17.17",
87+
"@tanstack/react-query": "^5.81.2",
88+
"@types/lodash": "^4.17.18",
8989
"@types/node": "^24.0.3",
9090
"@types/react": "^19.1.8",
9191
"@types/react-dom": "^19.1.6",
92-
"@typescript-eslint/eslint-plugin": "^8.34.0",
93-
"@typescript-eslint/parser": "^8.34.0",
92+
"@typescript-eslint/eslint-plugin": "^8.35.0",
93+
"@typescript-eslint/parser": "^8.35.0",
9494
"clsx": "^2.1.1",
9595
"cssnano": "^7.0.7",
9696
"dayjs": "^1.11.13",
9797
"eslint": "^9.29.0",
98-
"eslint-config-next": "^15.3.3",
98+
"eslint-config-next": "^15.3.4",
9999
"eslint-config-prettier": "^10.1.5",
100100
"lodash": "^4.17.21",
101101
"mantine-contextmenu": "^8.1.2",
102-
"next": "^15.3.3",
103-
"postcss": "^8.5.5",
102+
"next": "^15.3.4",
103+
"postcss": "^8.5.6",
104104
"postcss-cli": "^11.0.1",
105-
"postcss-import": "^16.1.0",
105+
"postcss-import": "^16.1.1",
106106
"postcss-preset-mantine": "^1.17.0",
107107
"postcss-simple-vars": "^7.0.1",
108-
"prettier": "^3.5.3",
108+
"prettier": "^3.6.0",
109109
"react": "^19.1.0",
110110
"react-dom": "^19.1.0",
111111
"sharp": "^0.34.2",
112-
"shiki": "^3.6.0",
112+
"shiki": "^3.7.0",
113113
"swr": "^2.3.3",
114114
"tsup": "^8.5.0",
115115
"typescript": "^5.8.3"

package/DataTableFooter.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { TableTfoot, TableTr, rem, type MantineStyleProp } from '@mantine/core';
22
import clsx from 'clsx';
3-
import { forwardRef, type JSX } from 'react';
43
import { DataTableFooterCell } from './DataTableFooterCell';
54
import { DataTableFooterSelectorPlaceholderCell } from './DataTableFooterSelectorPlaceholderCell';
65
import type { DataTableColumn, DataTableDefaultColumnProps } from './types';
@@ -13,20 +12,19 @@ type DataTableFooterProps<T> = {
1312
selectionVisible: boolean;
1413
selectorCellShadowVisible: boolean;
1514
scrollDiff: number;
15+
ref: React.Ref<HTMLTableSectionElement>;
1616
};
1717

18-
export const DataTableFooter = forwardRef(function DataTableFooter<T>(
19-
{
20-
className,
21-
style,
22-
columns,
23-
defaultColumnProps,
24-
selectionVisible,
25-
selectorCellShadowVisible,
26-
scrollDiff,
27-
}: DataTableFooterProps<T>,
28-
ref: React.ForwardedRef<HTMLTableSectionElement>
29-
) {
18+
export function DataTableFooter<T>({
19+
className,
20+
style,
21+
columns,
22+
defaultColumnProps,
23+
selectionVisible,
24+
selectorCellShadowVisible,
25+
scrollDiff,
26+
ref,
27+
}: DataTableFooterProps<T>) {
3028
const relative = scrollDiff < 0;
3129
return (
3230
<TableTfoot
@@ -74,4 +72,4 @@ export const DataTableFooter = forwardRef(function DataTableFooter<T>(
7472
</TableTr>
7573
</TableTfoot>
7674
);
77-
}) as <T>(props: DataTableFooterProps<T> & { ref: React.ForwardedRef<HTMLTableSectionElement> }) => JSX.Element;
75+
}

package/DataTableHeader.tsx

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type MantineStyleProp,
1212
} from '@mantine/core';
1313
import clsx from 'clsx';
14-
import { forwardRef, useState, type JSX } from 'react';
14+
import { useState } from 'react';
1515
import { DataTableColumnGroupHeaderCell } from './DataTableColumnGroupHeaderCell';
1616
import { useDataTableColumnsContext } from './DataTableColumns.context';
1717
import { DataTableHeaderCell } from './DataTableHeaderCell';
@@ -39,31 +39,30 @@ type DataTableHeaderProps<T> = {
3939
selectorCellShadowVisible: boolean;
4040
selectionColumnClassName: string | undefined;
4141
selectionColumnStyle: MantineStyleProp;
42+
ref: React.Ref<HTMLTableSectionElement>;
4243
};
4344

44-
export const DataTableHeader = forwardRef(function DataTableHeader<T>(
45-
{
46-
selectionColumnHeaderRef,
47-
className,
48-
style,
49-
sortStatus,
50-
sortIcons,
51-
onSortStatusChange,
52-
columns,
53-
defaultColumnProps,
54-
groups,
55-
selectionTrigger,
56-
selectionVisible,
57-
selectionChecked,
58-
selectionIndeterminate,
59-
onSelectionChange,
60-
selectionCheckboxProps,
61-
selectorCellShadowVisible,
62-
selectionColumnClassName,
63-
selectionColumnStyle,
64-
}: DataTableHeaderProps<T>,
65-
ref: React.ForwardedRef<HTMLTableSectionElement>
66-
) {
45+
export function DataTableHeader<T>({
46+
selectionColumnHeaderRef,
47+
className,
48+
style,
49+
sortStatus,
50+
sortIcons,
51+
onSortStatusChange,
52+
columns,
53+
defaultColumnProps,
54+
groups,
55+
selectionTrigger,
56+
selectionVisible,
57+
selectionChecked,
58+
selectionIndeterminate,
59+
onSelectionChange,
60+
selectionCheckboxProps,
61+
selectorCellShadowVisible,
62+
selectionColumnClassName,
63+
selectionColumnStyle,
64+
ref,
65+
}: DataTableHeaderProps<T>) {
6766
const allRecordsSelectorCell = selectionVisible ? (
6867
<DataTableHeaderSelectorCell
6968
ref={selectionColumnHeaderRef}
@@ -200,4 +199,4 @@ export const DataTableHeader = forwardRef(function DataTableHeader<T>(
200199
) : (
201200
content
202201
);
203-
}) as <T>(props: DataTableHeaderProps<T> & { ref: React.ForwardedRef<HTMLTableSectionElement> }) => JSX.Element;
202+
}

package/DataTableHeaderSelectorCell.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { MantineStyleProp } from '@mantine/core';
22
import { Checkbox, TableTh, type CheckboxProps } from '@mantine/core';
33
import clsx from 'clsx';
4-
import { forwardRef } from 'react';
54
import type { DataTableSelectionTrigger } from './types';
65
import { POINTER_CURSOR } from './utilityClasses';
76

@@ -15,22 +14,21 @@ type DataTableHeaderSelectorCellProps = {
1514
checkboxProps: CheckboxProps;
1615
onChange: (() => void) | undefined;
1716
rowSpan: number | undefined;
17+
ref: React.Ref<HTMLTableCellElement>;
1818
};
1919

20-
export const DataTableHeaderSelectorCell = forwardRef(function DataTableHeaderSelectorCell(
21-
{
22-
className,
23-
style,
24-
trigger,
25-
shadowVisible,
26-
checked,
27-
indeterminate,
28-
checkboxProps,
29-
onChange,
30-
rowSpan,
31-
}: DataTableHeaderSelectorCellProps,
32-
ref: React.ForwardedRef<HTMLTableCellElement>
33-
) {
20+
export function DataTableHeaderSelectorCell({
21+
className,
22+
style,
23+
trigger,
24+
shadowVisible,
25+
checked,
26+
indeterminate,
27+
checkboxProps,
28+
onChange,
29+
rowSpan,
30+
ref,
31+
}: DataTableHeaderSelectorCellProps) {
3432
const enabled = !checkboxProps.disabled;
3533

3634
return (
@@ -56,4 +54,4 @@ export const DataTableHeaderSelectorCell = forwardRef(function DataTableHeaderSe
5654
/>
5755
</TableTh>
5856
);
59-
});
57+
}

package/DataTablePagination.tsx

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box, Pagination, Text, rem, type MantineSpacing, type MantineStyleProp } from '@mantine/core';
22
import clsx from 'clsx';
3-
import { forwardRef, type ForwardedRef, type JSX } from 'react';
3+
import { type ForwardedRef } from 'react';
44
import { DataTablePageSizeSelector } from './DataTablePageSizeSelector';
55
import { getPaginationCssVariables } from './cssVariables';
66
import { useMediaQueryStringOrFunction } from './hooks';
@@ -20,35 +20,34 @@ type DataTablePaginationComponentProps = WithOptionalProperty<
2020
recordsLength: number | undefined;
2121
horizontalSpacing: MantineSpacing | undefined;
2222
noRecordsText: string;
23+
ref: ForwardedRef<HTMLDivElement>;
2324
};
2425

25-
export const DataTablePagination = forwardRef(function DataTablePagination(
26-
{
27-
className,
28-
style,
29-
fetching,
30-
page,
31-
onPageChange,
32-
paginationWithEdges,
33-
paginationWithControls,
34-
paginationActiveTextColor,
35-
paginationActiveBackgroundColor,
36-
paginationSize,
37-
loadingText,
38-
noRecordsText,
39-
paginationText,
40-
totalRecords,
41-
recordsPerPage,
42-
onRecordsPerPageChange,
43-
recordsPerPageLabel,
44-
recordsPerPageOptions,
45-
recordsLength,
46-
horizontalSpacing,
47-
paginationWrapBreakpoint,
48-
getPaginationControlProps,
49-
}: DataTablePaginationComponentProps,
50-
ref: ForwardedRef<HTMLDivElement>
51-
) {
26+
export function DataTablePagination({
27+
className,
28+
style,
29+
fetching,
30+
page,
31+
onPageChange,
32+
paginationWithEdges,
33+
paginationWithControls,
34+
paginationActiveTextColor,
35+
paginationActiveBackgroundColor,
36+
paginationSize,
37+
loadingText,
38+
noRecordsText,
39+
paginationText,
40+
totalRecords,
41+
recordsPerPage,
42+
onRecordsPerPageChange,
43+
recordsPerPageLabel,
44+
recordsPerPageOptions,
45+
recordsLength,
46+
horizontalSpacing,
47+
paginationWrapBreakpoint,
48+
getPaginationControlProps,
49+
ref,
50+
}: DataTablePaginationComponentProps) {
5251
let paginationTextValue: React.ReactNode;
5352
if (totalRecords) {
5453
const from = (page - 1) * recordsPerPage + 1;
@@ -112,4 +111,4 @@ export const DataTablePagination = forwardRef(function DataTablePagination(
112111
/>
113112
</Box>
114113
);
115-
}) as (props: DataTablePaginationComponentProps & { ref: ForwardedRef<HTMLDivElement> }) => JSX.Element;
114+
}

0 commit comments

Comments
 (0)