Skip to content

Commit

Permalink
upgrade to tanstack table v8.13
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Feb 27, 2024
1 parent 20cf3de commit 959e7f7
Show file tree
Hide file tree
Showing 8 changed files with 1,166 additions and 1,102 deletions.
26 changes: 13 additions & 13 deletions apps/material-react-table-docs/package.json
Expand Up @@ -14,24 +14,24 @@
},
"dependencies": {
"@docsearch/js": "3.5.2",
"@emotion/react": "^11.11.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@faker-js/faker": "^8.4.1",
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@mdx-js/loader": "^3.0.1",
"@mdx-js/react": "^3.0.1",
"@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10",
"@mui/x-charts": "^6.19.4",
"@mui/x-date-pickers": "^6.19.4",
"@mui/icons-material": "^5.15.11",
"@mui/material": "^5.15.11",
"@mui/x-charts": "^6.19.5",
"@mui/x-date-pickers": "^6.19.5",
"@next/mdx": "^14.1.0",
"@tanstack/react-query": "^5.21.7",
"@tanstack/react-table-devtools": "^8.12.0",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-table-devtools": "^8.13.0",
"@types/mdx": "^2.0.11",
"dayjs": "^1.11.10",
"export-to-csv": "^1.2.2",
"export-to-csv": "^1.2.3",
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.8.2",
"material-react-table": "workspace:*",
Expand All @@ -44,12 +44,12 @@
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.20.1",
"@types/node": "^20.11.19",
"@types/react": "^18.2.56",
"@types/node": "^20.11.20",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "8.56.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"eslint": "8.57.0",
"eslint-config-next": "14.1.0",
"next-plausible": "^3.12.0",
"raw-loader": "^4.0.2",
Expand Down
8 changes: 4 additions & 4 deletions apps/test-cra/package.json
Expand Up @@ -3,11 +3,11 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10",
"@mui/x-date-pickers": "^6.19.4",
"@mui/icons-material": "^5.15.11",
"@mui/material": "^5.15.11",
"@mui/x-date-pickers": "^6.19.5",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@testing-library/user-event": "^14.5.2",
Expand Down
26 changes: 13 additions & 13 deletions apps/test-remix/package.json
Expand Up @@ -10,26 +10,26 @@
"typecheck": "tsc"
},
"dependencies": {
"@emotion/react": "^11.11.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10",
"@mui/x-date-pickers": "^6.19.4",
"@remix-run/css-bundle": "^2.6.0",
"@remix-run/node": "^2.6.0",
"@remix-run/react": "^2.6.0",
"@remix-run/serve": "^2.6.0",
"isbot": "^5.1.0",
"@mui/icons-material": "^5.15.11",
"@mui/material": "^5.15.11",
"@mui/x-date-pickers": "^6.19.5",
"@remix-run/css-bundle": "^2.7.2",
"@remix-run/node": "^2.7.2",
"@remix-run/react": "^2.7.2",
"@remix-run/serve": "^2.7.2",
"isbot": "^5.1.1",
"material-react-table": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.6.0",
"@remix-run/eslint-config": "^2.6.0",
"@types/react": "^18.2.56",
"@remix-run/dev": "^2.7.2",
"@remix-run/eslint-config": "^2.7.2",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"typescript": "^5.3.3"
},
"engines": {
Expand Down
18 changes: 9 additions & 9 deletions apps/test-vite/package.json
Expand Up @@ -10,25 +10,25 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10",
"@mui/x-date-pickers": "^6.19.4",
"@mui/icons-material": "^5.15.11",
"@mui/material": "^5.15.11",
"@mui/x-date-pickers": "^6.19.5",
"material-react-table": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.56",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.3.3",
"vite": "^5.1.3"
"vite": "^5.1.4"
}
}
42 changes: 21 additions & 21 deletions packages/material-react-table/package.json
Expand Up @@ -63,30 +63,30 @@
"devDependencies": {
"@babel/core": "^7.23.9",
"@babel/preset-react": "^7.23.3",
"@emotion/react": "^11.11.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@faker-js/faker": "^8.4.1",
"@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10",
"@mui/x-date-pickers": "^6.19.4",
"@mui/icons-material": "^5.15.11",
"@mui/material": "^5.15.11",
"@mui/x-date-pickers": "^6.19.5",
"@rollup/plugin-typescript": "^11.1.6",
"@size-limit/preset-small-lib": "^11.0.2",
"@storybook/addon-a11y": "^7.6.16",
"@storybook/addon-essentials": "^7.6.16",
"@storybook/addon-interactions": "^7.6.16",
"@storybook/addon-links": "^7.6.16",
"@storybook/addon-storysource": "^7.6.16",
"@storybook/blocks": "^7.6.16",
"@storybook/react": "^7.6.16",
"@storybook/react-vite": "^7.6.16",
"@storybook/addon-a11y": "^7.6.17",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-interactions": "^7.6.17",
"@storybook/addon-links": "^7.6.17",
"@storybook/addon-storysource": "^7.6.17",
"@storybook/blocks": "^7.6.17",
"@storybook/react": "^7.6.17",
"@storybook/react-vite": "^7.6.17",
"@storybook/testing-library": "^0.2.2",
"@types/node": "^20.11.19",
"@types/react": "^18.2.56",
"@types/node": "^20.11.20",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-plugin-mui-path-imports": "^0.0.15",
"eslint-plugin-perfectionist": "^2.5.0",
"prop-types": "^15.8.1",
Expand All @@ -99,11 +99,11 @@
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"size-limit": "^11.0.2",
"storybook": "^7.6.16",
"storybook": "^7.6.17",
"storybook-dark-mode": "^3.0.3",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^5.1.3"
"vite": "^5.1.4"
},
"peerDependencies": {
"@emotion/react": ">=11.11",
Expand All @@ -116,8 +116,8 @@
},
"dependencies": {
"@tanstack/match-sorter-utils": "8.11.8",
"@tanstack/react-table": "8.12.0",
"@tanstack/react-virtual": "3.1.1",
"@tanstack/react-table": "8.13.0",
"@tanstack/react-virtual": "3.1.3",
"highlight-words": "1.2.2"
}
}
Expand Up @@ -37,18 +37,14 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
const isMobile = useMediaQuery('(max-width: 720px)');

const {
getPrePaginationRowModel,
getState,
options: {
enableToolbarInternalActions,
icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon },
localization,
muiPaginationProps,
paginationDisplayMode,
rowCount,
},
setPageIndex,
setPageSize,
} = table;
const {
pagination: { pageIndex = 0, pageSize = 10 },
Expand All @@ -62,8 +58,8 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
...rest,
};

const totalRowCount = rowCount ?? getPrePaginationRowModel().rows.length;
const numberOfPages = Math.ceil(totalRowCount / pageSize);
const totalRowCount = table.getRowCount();
const numberOfPages = table.getPageCount();
const showFirstLastPageButtons = numberOfPages > 2;
const firstRowIndex = pageIndex * pageSize;
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
Expand Down Expand Up @@ -123,7 +119,9 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
id: 'mrt-rows-per-page',
}}
label={localization.rowsPerPage}
onChange={(event) => setPageSize(+(event.target.value as any))}
onChange={(event) =>
table.setPageSize(+(event.target.value as any))
}
sx={{ mb: 0 }}
value={pageSize}
variant="standard"
Expand Down Expand Up @@ -153,7 +151,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
<Pagination
count={numberOfPages}
disabled={disabled}
onChange={(_e, newPageIndex) => setPageIndex(newPageIndex - 1)}
onChange={(_e, newPageIndex) => table.setPageIndex(newPageIndex - 1)}
page={pageIndex + 1}
renderItem={(item) => (
<PaginationItem
Expand Down Expand Up @@ -189,7 +187,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
<IconButton
aria-label={localization.goToFirstPage}
disabled={disableBack}
onClick={() => setPageIndex(0)}
onClick={() => table.firstPage()}
size="small"
>
<FirstPageIcon {...flipIconStyles(theme)} />
Expand All @@ -202,7 +200,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
<IconButton
aria-label={localization.goToPreviousPage}
disabled={disableBack}
onClick={() => setPageIndex(pageIndex - 1)}
onClick={() => table.previousPage()}
size="small"
>
<ChevronLeftIcon {...flipIconStyles(theme)} />
Expand All @@ -214,7 +212,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
<IconButton
aria-label={localization.goToNextPage}
disabled={disableNext}
onClick={() => setPageIndex(pageIndex + 1)}
onClick={() => table.nextPage()}
size="small"
>
<ChevronRightIcon {...flipIconStyles(theme)} />
Expand All @@ -227,7 +225,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
<IconButton
aria-label={localization.goToLastPage}
disabled={disableNext}
onClick={() => setPageIndex(numberOfPages - 1)}
onClick={() => table.lastPage()}
size="small"
>
<LastPageIcon {...flipIconStyles(theme)} />
Expand Down
1 change: 0 additions & 1 deletion packages/material-react-table/src/types.ts
Expand Up @@ -1267,7 +1267,6 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
renderTopToolbarCustomActions?: (props: {
table: MRT_TableInstance<TData>;
}) => ReactNode;
rowCount?: number;
rowNumberDisplayMode?: 'original' | 'static';
rowPinningDisplayMode?:
| 'bottom'
Expand Down

0 comments on commit 959e7f7

Please sign in to comment.