@mini_7/material-react-table-mcp 4.0.0

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.
Files changed (170) hide show
  1. package/README.md +68 -0
  2. package/data/MIGRATION.md +136 -0
  3. package/data/api.json +5379 -0
  4. package/data/examples/advanced.tsx +309 -0
  5. package/data/examples/aggregation-and-grouping.tsx +153 -0
  6. package/data/examples/aggregation-multi.tsx +105 -0
  7. package/data/examples/alternate-column-filtering.tsx +49 -0
  8. package/data/examples/alternate-detail-panel.tsx +81 -0
  9. package/data/examples/alternate-pagination.tsx +23 -0
  10. package/data/examples/basic.tsx +109 -0
  11. package/data/examples/chart-detail-panel.tsx +89 -0
  12. package/data/examples/column-actions-space.tsx +44 -0
  13. package/data/examples/column-alignment.tsx +70 -0
  14. package/data/examples/custom-column-actions.tsx +109 -0
  15. package/data/examples/custom-column-filtering-ui.tsx +89 -0
  16. package/data/examples/custom-headless.tsx +125 -0
  17. package/data/examples/custom-top-toolbar.tsx +88 -0
  18. package/data/examples/customize-display-columns.tsx +85 -0
  19. package/data/examples/customize-filter-components.tsx +101 -0
  20. package/data/examples/customize-filter-modes.tsx +73 -0
  21. package/data/examples/customize-filter-variants.tsx +116 -0
  22. package/data/examples/customize-global-filter-component.tsx +52 -0
  23. package/data/examples/customize-remove-column-grouping.tsx +94 -0
  24. package/data/examples/customize-row-selection.tsx +54 -0
  25. package/data/examples/customize-table-styles.tsx +100 -0
  26. package/data/examples/disable-column-actions.tsx +37 -0
  27. package/data/examples/disable-column-hiding.tsx +90 -0
  28. package/data/examples/disable-density-toggle.tsx +49 -0
  29. package/data/examples/dynamic-columns.tsx +189 -0
  30. package/data/examples/editing-crud-cell.tsx +377 -0
  31. package/data/examples/editing-crud-modal.tsx +370 -0
  32. package/data/examples/editing-crud-row.tsx +333 -0
  33. package/data/examples/editing-crud-table.tsx +369 -0
  34. package/data/examples/editing-crud-tree.tsx +416 -0
  35. package/data/examples/enable-cell-actions.tsx +76 -0
  36. package/data/examples/enable-click-to-copy.tsx +39 -0
  37. package/data/examples/enable-column-grouping.tsx +120 -0
  38. package/data/examples/enable-column-ordering.tsx +48 -0
  39. package/data/examples/enable-column-pinning.tsx +69 -0
  40. package/data/examples/enable-column-resizing.tsx +56 -0
  41. package/data/examples/enable-column-virtualization.tsx +27 -0
  42. package/data/examples/enable-detail-panel-conditionally.tsx +78 -0
  43. package/data/examples/enable-detail-panel-virtualized.tsx +80 -0
  44. package/data/examples/enable-expanding-tree.tsx +110 -0
  45. package/data/examples/enable-filter-facet-values.tsx +65 -0
  46. package/data/examples/enable-row-dragging.tsx +137 -0
  47. package/data/examples/enable-row-numbers-original.tsx +48 -0
  48. package/data/examples/enable-row-numbers-static.tsx +48 -0
  49. package/data/examples/enable-row-ordering.tsx +57 -0
  50. package/data/examples/enable-row-pinning-select.tsx +76 -0
  51. package/data/examples/enable-row-pinning-static.tsx +50 -0
  52. package/data/examples/enable-row-pinning-sticky.tsx +69 -0
  53. package/data/examples/enable-row-selection.tsx +96 -0
  54. package/data/examples/enable-row-virtualization.tsx +101 -0
  55. package/data/examples/enable-sticky-header.tsx +59 -0
  56. package/data/examples/expanding-tree-expanded.tsx +121 -0
  57. package/data/examples/expanding-tree-flat-parse.tsx +125 -0
  58. package/data/examples/expanding-tree-root-expanded.tsx +151 -0
  59. package/data/examples/export-to-csv.tsx +114 -0
  60. package/data/examples/export-to-pdf.tsx +104 -0
  61. package/data/examples/external-toolbar.tsx +108 -0
  62. package/data/examples/font-awesome-icons.tsx +106 -0
  63. package/data/examples/infinite-scrolling.tsx +208 -0
  64. package/data/examples/lazy-detail-panel.tsx +262 -0
  65. package/data/examples/lazy-sub-rows.tsx +190 -0
  66. package/data/examples/linear-progress.tsx +66 -0
  67. package/data/examples/loading.tsx +50 -0
  68. package/data/examples/localization-i18n-ar.tsx +65 -0
  69. package/data/examples/localization-i18n-az.tsx +60 -0
  70. package/data/examples/localization-i18n-bg.tsx +60 -0
  71. package/data/examples/localization-i18n-cs.tsx +60 -0
  72. package/data/examples/localization-i18n-da.tsx +60 -0
  73. package/data/examples/localization-i18n-de.tsx +60 -0
  74. package/data/examples/localization-i18n-el.tsx +60 -0
  75. package/data/examples/localization-i18n-en.tsx +60 -0
  76. package/data/examples/localization-i18n-es.tsx +60 -0
  77. package/data/examples/localization-i18n-et.tsx +60 -0
  78. package/data/examples/localization-i18n-fa.tsx +66 -0
  79. package/data/examples/localization-i18n-fi.tsx +60 -0
  80. package/data/examples/localization-i18n-fr.tsx +60 -0
  81. package/data/examples/localization-i18n-he.tsx +66 -0
  82. package/data/examples/localization-i18n-hr.tsx +60 -0
  83. package/data/examples/localization-i18n-hu.tsx +60 -0
  84. package/data/examples/localization-i18n-hy.tsx +65 -0
  85. package/data/examples/localization-i18n-id.tsx +60 -0
  86. package/data/examples/localization-i18n-it.tsx +60 -0
  87. package/data/examples/localization-i18n-ja.tsx +60 -0
  88. package/data/examples/localization-i18n-ko.tsx +60 -0
  89. package/data/examples/localization-i18n-nl.tsx +60 -0
  90. package/data/examples/localization-i18n-no.tsx +60 -0
  91. package/data/examples/localization-i18n-np.tsx +60 -0
  92. package/data/examples/localization-i18n-pl.tsx +60 -0
  93. package/data/examples/localization-i18n-pt-BR.tsx +60 -0
  94. package/data/examples/localization-i18n-pt.tsx +60 -0
  95. package/data/examples/localization-i18n-ro.tsx +60 -0
  96. package/data/examples/localization-i18n-ru.tsx +60 -0
  97. package/data/examples/localization-i18n-sk.tsx +60 -0
  98. package/data/examples/localization-i18n-sr-Cyrl-RS.tsx +60 -0
  99. package/data/examples/localization-i18n-sr-Latn-RS.tsx +60 -0
  100. package/data/examples/localization-i18n-sv.tsx +60 -0
  101. package/data/examples/localization-i18n-tr.tsx +60 -0
  102. package/data/examples/localization-i18n-uk.tsx +60 -0
  103. package/data/examples/localization-i18n-vi.tsx +60 -0
  104. package/data/examples/localization-i18n-zh-hans.tsx +60 -0
  105. package/data/examples/localization-i18n-zh-hant.tsx +60 -0
  106. package/data/examples/manual-selection.tsx +105 -0
  107. package/data/examples/minimal.tsx +78 -0
  108. package/data/examples/mui-theme.tsx +136 -0
  109. package/data/examples/multi-sorting.tsx +58 -0
  110. package/data/examples/persistent-state.tsx +184 -0
  111. package/data/examples/react-query.tsx +182 -0
  112. package/data/examples/remote.tsx +150 -0
  113. package/data/examples/row-actions-buttons.tsx +89 -0
  114. package/data/examples/row-actions-menu-items.tsx +64 -0
  115. package/data/examples/single-row-selection.tsx +98 -0
  116. package/data/examples/virtualized.tsx +138 -0
  117. package/data/guides/accessibility.md +119 -0
  118. package/data/guides/aggregation.md +210 -0
  119. package/data/guides/async-loading.md +132 -0
  120. package/data/guides/best-practices.md +363 -0
  121. package/data/guides/cell-actions.md +139 -0
  122. package/data/guides/click-to-copy.md +67 -0
  123. package/data/guides/column-actions.md +69 -0
  124. package/data/guides/column-filtering.md +366 -0
  125. package/data/guides/column-grouping.md +192 -0
  126. package/data/guides/column-hiding.md +133 -0
  127. package/data/guides/column-ordering-dnd.md +99 -0
  128. package/data/guides/column-pinning.md +72 -0
  129. package/data/guides/column-resizing.md +157 -0
  130. package/data/guides/column-size.md +162 -0
  131. package/data/guides/customize-components.md +395 -0
  132. package/data/guides/customize-icons.md +35 -0
  133. package/data/guides/data-columns.md +292 -0
  134. package/data/guides/density-toggle.md +46 -0
  135. package/data/guides/detail-panel.md +195 -0
  136. package/data/guides/display-columns.md +135 -0
  137. package/data/guides/editing.md +367 -0
  138. package/data/guides/expanding-sub-rows.md +194 -0
  139. package/data/guides/full-screen-toggle.md +63 -0
  140. package/data/guides/global-filtering.md +237 -0
  141. package/data/guides/localization.md +57 -0
  142. package/data/guides/memoization.md +157 -0
  143. package/data/guides/pagination.md +171 -0
  144. package/data/guides/row-actions.md +116 -0
  145. package/data/guides/row-numbers.md +24 -0
  146. package/data/guides/row-ordering-dnd.md +51 -0
  147. package/data/guides/row-pinning.md +96 -0
  148. package/data/guides/row-selection.md +237 -0
  149. package/data/guides/sorting.md +190 -0
  150. package/data/guides/state-management.md +165 -0
  151. package/data/guides/sticky-header.md +41 -0
  152. package/data/guides/table-event-listeners.md +103 -0
  153. package/data/guides/toolbar-customization.md +251 -0
  154. package/data/guides/virtualization.md +183 -0
  155. package/data/index.json +1930 -0
  156. package/data/reference/mrt-components.md +183 -0
  157. package/data/reference/mrt-hooks.md +125 -0
  158. package/data/skills/composable-components/SKILL.md +189 -0
  159. package/data/skills/customization/SKILL.md +190 -0
  160. package/data/skills/drag-and-drop-ordering/SKILL.md +227 -0
  161. package/data/skills/editing/SKILL.md +243 -0
  162. package/data/skills/filtering/SKILL.md +213 -0
  163. package/data/skills/getting-started/SKILL.md +213 -0
  164. package/data/skills/localization/SKILL.md +182 -0
  165. package/data/skills/migrate-v3-to-v4/SKILL.md +161 -0
  166. package/data/skills/state-and-server-data/SKILL.md +200 -0
  167. package/data/skills/virtualization/SKILL.md +203 -0
  168. package/dist/data.js +137 -0
  169. package/dist/index.js +232 -0
  170. package/package.json +50 -0
@@ -0,0 +1,100 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+ import { data, type Person } from './makeData';
8
+ import { darken, lighten, useTheme } from '@mui/material';
9
+
10
+ const Example = () => {
11
+ const theme = useTheme();
12
+
13
+ //light or dark green
14
+ const baseBackgroundColor =
15
+ theme.palette.mode === 'dark'
16
+ ? 'rgba(3, 44, 43, 1)'
17
+ : 'rgba(244, 255, 233, 1)';
18
+
19
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
20
+ //column definitions...
21
+ () => [
22
+ {
23
+ accessorKey: 'id',
24
+ header: 'ID',
25
+ size: 100,
26
+ enableColumnFilter: false,
27
+ },
28
+ {
29
+ accessorKey: 'firstName',
30
+ header: 'First Name',
31
+ },
32
+ {
33
+ accessorKey: 'middleName',
34
+ header: 'Middle Name',
35
+ },
36
+ {
37
+ accessorKey: 'lastName',
38
+ header: 'Last Name',
39
+ },
40
+ {
41
+ accessorKey: 'address',
42
+ header: 'Address',
43
+ size: 300,
44
+ },
45
+ {
46
+ accessorKey: 'city',
47
+ header: 'City',
48
+ },
49
+
50
+ {
51
+ accessorKey: 'state',
52
+ header: 'State',
53
+ },
54
+ ],
55
+ [],
56
+ //end
57
+ );
58
+
59
+ const table = useMaterialReactTable({
60
+ columns,
61
+ data,
62
+ enableColumnResizing: true,
63
+ enableRowPinning: true,
64
+ enableRowSelection: true,
65
+ muiTablePaperProps: {
66
+ elevation: 0,
67
+ sx: {
68
+ borderRadius: '0',
69
+ },
70
+ },
71
+ muiTableBodyProps: {
72
+ sx: (theme) => ({
73
+ '& tr:nth-of-type(odd):not([data-selected="true"]):not([data-pinned="true"]) > td':
74
+ {
75
+ backgroundColor: darken(baseBackgroundColor, 0.1),
76
+ },
77
+ '& tr:nth-of-type(odd):not([data-selected="true"]):not([data-pinned="true"]):hover > td':
78
+ {
79
+ backgroundColor: darken(baseBackgroundColor, 0.2),
80
+ },
81
+ '& tr:nth-of-type(even):not([data-selected="true"]):not([data-pinned="true"]) > td':
82
+ {
83
+ backgroundColor: lighten(baseBackgroundColor, 0.1),
84
+ },
85
+ '& tr:nth-of-type(even):not([data-selected="true"]):not([data-pinned="true"]):hover > td':
86
+ {
87
+ backgroundColor: darken(baseBackgroundColor, 0.2),
88
+ },
89
+ }),
90
+ },
91
+ mrtTheme: (theme) => ({
92
+ baseBackgroundColor: baseBackgroundColor,
93
+ draggingBorderColor: theme.palette.secondary.main,
94
+ }),
95
+ });
96
+
97
+ return <MaterialReactTable table={table} />;
98
+ };
99
+
100
+ export default Example;
@@ -0,0 +1,37 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+ import { data, type Person } from './makeData';
8
+
9
+ const Example = () => {
10
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
11
+ () => [
12
+ {
13
+ accessorKey: 'id',
14
+ enableColumnActions: false,
15
+ header: 'ID',
16
+ },
17
+ {
18
+ accessorKey: 'firstName',
19
+ header: 'First Name',
20
+ },
21
+ {
22
+ accessorKey: 'lastName',
23
+ header: 'Last Name',
24
+ },
25
+ ],
26
+ [],
27
+ );
28
+
29
+ const table = useMaterialReactTable({
30
+ columns,
31
+ data,
32
+ });
33
+
34
+ return <MaterialReactTable table={table} />;
35
+ };
36
+
37
+ export default Example;
@@ -0,0 +1,90 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+
8
+ const Example = () => {
9
+ const columns = useMemo(
10
+ () =>
11
+ [
12
+ {
13
+ accessorKey: 'firstName',
14
+ enableHiding: false,
15
+ header: 'First Name',
16
+ },
17
+ {
18
+ accessorKey: 'lastName',
19
+ enableHiding: false,
20
+ header: 'Last Name',
21
+ },
22
+ {
23
+ accessorKey: 'address',
24
+ header: 'Address',
25
+ },
26
+ {
27
+ accessorKey: 'city',
28
+ header: 'City',
29
+ },
30
+ {
31
+ accessorKey: 'state',
32
+ header: 'State',
33
+ },
34
+ ] as MRT_ColumnDef<(typeof data)[0]>[],
35
+ [],
36
+ );
37
+
38
+ const data = useMemo(
39
+ () => [
40
+ //data definitions...
41
+ {
42
+ firstName: 'Dylan',
43
+ lastName: 'Murray',
44
+ address: '261 Erdman Ford',
45
+ city: 'East Daphne',
46
+ state: 'Kentucky',
47
+ },
48
+ {
49
+ firstName: 'Raquel',
50
+ lastName: 'Kohler',
51
+ address: '769 Dominic Grove',
52
+ city: 'Columbus',
53
+ state: 'Ohio',
54
+ },
55
+ {
56
+ firstName: 'Ervin',
57
+ lastName: 'Reinger',
58
+ address: '566 Brakus Inlet',
59
+ city: 'South Linda',
60
+ state: 'West Virginia',
61
+ },
62
+ {
63
+ firstName: 'Brittany',
64
+ lastName: 'McCullough',
65
+ address: '722 Emie Stream',
66
+ city: 'Lincoln',
67
+ state: 'Nebraska',
68
+ },
69
+ {
70
+ firstName: 'Branson',
71
+ lastName: 'Frami',
72
+ address: '32188 Larkin Turnpike',
73
+ city: 'Charleston',
74
+ state: 'South Carolina',
75
+ },
76
+ //end
77
+ ],
78
+ [],
79
+ );
80
+
81
+ const table = useMaterialReactTable({
82
+ columns,
83
+ data,
84
+ initialState: { columnVisibility: { address: false } },
85
+ });
86
+
87
+ return <MaterialReactTable table={table} />;
88
+ };
89
+
90
+ export default Example;
@@ -0,0 +1,49 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+ import { data, type Person } from './makeData';
8
+
9
+ const Example = () => {
10
+ const columns = useMemo(
11
+ //column definitions...
12
+ () =>
13
+ [
14
+ {
15
+ accessorKey: 'firstName',
16
+ header: 'First Name',
17
+ },
18
+ {
19
+ accessorKey: 'lastName',
20
+ header: 'Last Name',
21
+ },
22
+ {
23
+ accessorKey: 'address',
24
+ header: 'Address',
25
+ },
26
+ {
27
+ accessorKey: 'city',
28
+ header: 'City',
29
+ },
30
+ {
31
+ accessorKey: 'state',
32
+ header: 'State',
33
+ },
34
+ ] as MRT_ColumnDef<Person>[],
35
+ [],
36
+ //end
37
+ );
38
+
39
+ const table = useMaterialReactTable({
40
+ columns,
41
+ data,
42
+ enableDensityToggle: false,
43
+ initialState: { density: 'compact' },
44
+ });
45
+
46
+ return <MaterialReactTable table={table} />;
47
+ };
48
+
49
+ export default Example;
@@ -0,0 +1,189 @@
1
+ import { lazy, Suspense, useMemo, useState } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ type MRT_ColumnFiltersState,
7
+ type MRT_PaginationState,
8
+ type MRT_SortingState,
9
+ // type MRT_ColumnOrderState,
10
+ } from 'material-react-table';
11
+ import { IconButton, Tooltip } from '@mui/material';
12
+ import RefreshIcon from '@mui/icons-material/Refresh';
13
+ import {
14
+ keepPreviousData,
15
+ QueryClient,
16
+ QueryClientProvider,
17
+ useQuery,
18
+ } from '@tanstack/react-query'; //note: this is TanStack React Query V5
19
+
20
+ //Your API response shape will probably be different. Knowing a total row count is important though.
21
+ type UserApiResponse = {
22
+ data: Array<User>;
23
+ meta: {
24
+ totalRowCount: number;
25
+ };
26
+ };
27
+
28
+ type User = {
29
+ firstName: string;
30
+ lastName: string;
31
+ address: string;
32
+ state: string;
33
+ phoneNumber: string;
34
+ lastLogin: Date;
35
+ };
36
+
37
+ const columnNames = {
38
+ firstName: 'First Name',
39
+ lastName: 'Last Name',
40
+ address: 'Address',
41
+ state: 'State',
42
+ phoneNumber: 'Phone Number',
43
+ lastLogin: 'Last Login',
44
+ } as const;
45
+
46
+ const Example = () => {
47
+ //manage our own state for stuff we want to pass to the API
48
+ const [columnFilters, setColumnFilters] = useState<MRT_ColumnFiltersState>(
49
+ [],
50
+ );
51
+ const [globalFilter, setGlobalFilter] = useState('');
52
+ const [sorting, setSorting] = useState<MRT_SortingState>([]);
53
+ const [pagination, setPagination] = useState<MRT_PaginationState>({
54
+ pageIndex: 0,
55
+ pageSize: 10,
56
+ });
57
+
58
+ //if using dynamic columns that are loaded after table instance creation, we will need to manage the column order state ourselves
59
+ //UPDATE: No longer needed as of v2.10.0
60
+ // const [columnOrder, setColumnOrder] = useState<MRT_ColumnOrderState>([]);
61
+
62
+ //consider storing this code in a custom hook (i.e useFetchUsers)
63
+ const {
64
+ data: { data = [], meta } = {}, //your data and api response will probably be different
65
+ isError,
66
+ isRefetching,
67
+ isLoading,
68
+ refetch,
69
+ } = useQuery<UserApiResponse>({
70
+ queryKey: [
71
+ 'users-list',
72
+ {
73
+ columnFilters, //refetch when columnFilters changes
74
+ globalFilter, //refetch when globalFilter changes
75
+ pagination, //refetch when pagination changes
76
+ sorting, //refetch when sorting changes
77
+ },
78
+ ],
79
+ queryFn: async () => {
80
+ const fetchURL = new URL('/api/data', location.origin); // nextjs api route
81
+
82
+ //read our state and pass it to the API as query params
83
+ fetchURL.searchParams.set(
84
+ 'start',
85
+ `${pagination.pageIndex * pagination.pageSize}`,
86
+ );
87
+ fetchURL.searchParams.set('size', `${pagination.pageSize}`);
88
+ fetchURL.searchParams.set('filters', JSON.stringify(columnFilters ?? []));
89
+ fetchURL.searchParams.set('globalFilter', globalFilter ?? '');
90
+ fetchURL.searchParams.set('sorting', JSON.stringify(sorting ?? []));
91
+
92
+ //use whatever fetch library you want, fetch, axios, etc
93
+ const response = await fetch(fetchURL.href);
94
+ const json = (await response.json()) as UserApiResponse;
95
+ return json;
96
+ },
97
+ placeholderData: keepPreviousData, //don't go to 0 rows when refetching or paginating to next page
98
+ });
99
+
100
+ //create columns from data
101
+ const columns = useMemo<MRT_ColumnDef<User>[]>(
102
+ () =>
103
+ data.length
104
+ ? Object.keys(data[0]).map((columnId) => ({
105
+ header: columnNames[columnId as keyof User] ?? columnId,
106
+ accessorKey: columnId,
107
+ id: columnId,
108
+ }))
109
+ : [],
110
+ [data],
111
+ );
112
+
113
+ //UPDATE: No longer needed as of v2.10.0
114
+ // useEffect(() => {
115
+ // //if using dynamic columns that are loaded after table instance creation, we will need to set the column order state ourselves
116
+ // setColumnOrder(columns.map((column) => column.id!));
117
+ // }, [columns]);
118
+
119
+ const table = useMaterialReactTable({
120
+ columns,
121
+ data,
122
+ enableRowSelection: true,
123
+ initialState: { showColumnFilters: true },
124
+ manualFiltering: true, //turn off built-in client-side filtering
125
+ manualPagination: true, //turn off built-in client-side pagination
126
+ manualSorting: true, //turn off built-in client-side sorting
127
+ //give loading spinner somewhere to go while loading
128
+ muiTableBodyProps: {
129
+ children: isLoading ? (
130
+ <tr style={{ height: '200px' }}>
131
+ <td />
132
+ </tr>
133
+ ) : undefined,
134
+ },
135
+ muiToolbarAlertBannerProps: isError
136
+ ? {
137
+ color: 'error',
138
+ children: 'Error loading data',
139
+ }
140
+ : undefined,
141
+ onColumnFiltersChange: setColumnFilters,
142
+ // onColumnOrderChange: setColumnOrder,
143
+ onGlobalFilterChange: setGlobalFilter,
144
+ onPaginationChange: setPagination,
145
+ onSortingChange: setSorting,
146
+ renderTopToolbarCustomActions: () => (
147
+ <Tooltip arrow title="Refresh Data">
148
+ <IconButton onClick={() => refetch()}>
149
+ <RefreshIcon />
150
+ </IconButton>
151
+ </Tooltip>
152
+ ),
153
+ rowCount: meta?.totalRowCount ?? 0,
154
+ state: {
155
+ columnFilters,
156
+ // columnOrder,
157
+ globalFilter,
158
+ isLoading,
159
+ pagination,
160
+ showAlertBanner: isError,
161
+ showProgressBars: isRefetching,
162
+ sorting,
163
+ },
164
+ });
165
+
166
+ return <MaterialReactTable table={table} />;
167
+ };
168
+
169
+ //react query setup in App.tsx
170
+ const ReactQueryDevtoolsProduction = lazy(() =>
171
+ import('@tanstack/react-query-devtools/build/modern/production.js').then(
172
+ (d) => ({
173
+ default: d.ReactQueryDevtools,
174
+ }),
175
+ ),
176
+ );
177
+
178
+ const queryClient = new QueryClient();
179
+
180
+ export default function App() {
181
+ return (
182
+ <QueryClientProvider client={queryClient}>
183
+ <Example />
184
+ <Suspense fallback={null}>
185
+ <ReactQueryDevtoolsProduction />
186
+ </Suspense>
187
+ </QueryClientProvider>
188
+ );
189
+ }