@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,69 @@
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 { MenuItem } from '@mui/material';
9
+
10
+ const Example = () => {
11
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
12
+ () => [
13
+ {
14
+ accessorKey: 'id',
15
+ enableColumnPinning: false, //disable column pinning for this column
16
+ header: 'ID',
17
+ size: 50,
18
+ },
19
+ //column definitions...
20
+ {
21
+ accessorKey: 'firstName',
22
+ header: 'First Name',
23
+ },
24
+ {
25
+ accessorKey: 'middleName',
26
+ header: 'Middle Name',
27
+ },
28
+ {
29
+ accessorKey: 'lastName',
30
+ header: 'Last Name',
31
+ },
32
+ {
33
+ accessorKey: 'address',
34
+ header: 'Address',
35
+ size: 300,
36
+ },
37
+ //end
38
+ {
39
+ accessorKey: 'city', //this column gets pinned to the right by default because of the initial state,
40
+ header: 'City',
41
+ },
42
+ {
43
+ accessorKey: 'state', //this column gets pinned left by default because of the the initial state,
44
+ header: 'State',
45
+ },
46
+ {
47
+ accessorKey: 'country',
48
+ header: 'Country',
49
+ },
50
+ ],
51
+ [],
52
+ );
53
+
54
+ const table = useMaterialReactTable({
55
+ columns,
56
+ data,
57
+ enableColumnPinning: true,
58
+ enableRowActions: true,
59
+ layoutMode: 'grid-no-grow', //constant column widths
60
+ renderRowActionMenuItems: () => [<MenuItem key="action">Action</MenuItem>],
61
+ initialState: {
62
+ columnPinning: { end: ['city'], start: ['mrt-row-actions', 'state'] },
63
+ },
64
+ });
65
+
66
+ return <MaterialReactTable table={table} />;
67
+ };
68
+
69
+ export default Example;
@@ -0,0 +1,56 @@
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: 'firstName',
14
+ header: 'First Name', //uses the default width from defaultColumn prop
15
+ },
16
+ {
17
+ accessorKey: 'lastName',
18
+ header: 'Last Name',
19
+ },
20
+ {
21
+ accessorKey: 'email',
22
+ header: 'Email Address',
23
+ size: 250, //increase the width of this column
24
+ },
25
+ {
26
+ accessorKey: 'city',
27
+ header: 'City',
28
+ size: 200, //decrease the width of this column
29
+ enableResizing: false, //disable resizing for this column
30
+ },
31
+ {
32
+ accessorKey: 'country',
33
+ header: 'Country',
34
+ size: 140, //decrease the width of this column
35
+ },
36
+ ],
37
+ [],
38
+ );
39
+
40
+ const table = useMaterialReactTable({
41
+ columns,
42
+ data,
43
+ //optionally override the default column widths
44
+ defaultColumn: {
45
+ maxSize: 400,
46
+ minSize: 80,
47
+ size: 160, //default size is usually 180
48
+ },
49
+ enableColumnResizing: true,
50
+ columnResizeMode: 'onChange', //default
51
+ });
52
+
53
+ return <MaterialReactTable table={table} />;
54
+ };
55
+
56
+ export default Example;
@@ -0,0 +1,27 @@
1
+ import { useRef } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnVirtualizer,
6
+ } from 'material-react-table';
7
+ import { fakeColumns, fakeData } from './makeData';
8
+
9
+ const Example = () => {
10
+ //optionally access the underlying virtualizer instance
11
+ const columnVirtualizerInstanceRef = useRef<MRT_ColumnVirtualizer>(null);
12
+
13
+ const table = useMaterialReactTable({
14
+ columnVirtualizerInstanceRef, //optional
15
+ columnVirtualizerOptions: { overscan: 4 }, //optionally customize the virtualizer
16
+ columns: fakeColumns, //500 columns
17
+ data: fakeData,
18
+ enableColumnPinning: true,
19
+ enableColumnResizing: true,
20
+ enableColumnVirtualization: true,
21
+ enableRowNumbers: true,
22
+ });
23
+
24
+ return <MaterialReactTable table={table} />;
25
+ };
26
+
27
+ export default Example;
@@ -0,0 +1,78 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+ import { Box, Typography } from '@mui/material';
8
+ import { data, type Person } from './makeData';
9
+
10
+ const Example = () => {
11
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
12
+ //column definitions...
13
+ () => [
14
+ {
15
+ accessorKey: 'id',
16
+ header: 'ID',
17
+ size: 50,
18
+ },
19
+ {
20
+ accessorKey: 'firstName',
21
+ header: 'First Name',
22
+ },
23
+ {
24
+ accessorKey: 'middleName',
25
+ header: 'Middle Name',
26
+ },
27
+ {
28
+ accessorKey: 'lastName',
29
+ header: 'Last Name',
30
+ },
31
+ ],
32
+ [],
33
+ //end
34
+ );
35
+
36
+ const table = useMaterialReactTable({
37
+ columns,
38
+ data,
39
+ enableExpandAll: false, //disable expand all button
40
+ muiDetailPanelProps: () => ({
41
+ sx: (theme) => ({
42
+ backgroundColor:
43
+ theme.palette.mode === 'dark'
44
+ ? 'rgba(255,210,244,0.1)'
45
+ : 'rgba(0,0,0,0.1)',
46
+ }),
47
+ }),
48
+ //custom expand button rotation
49
+ muiExpandButtonProps: ({ row, table }) => ({
50
+ onClick: () => table.setExpanded({ [row.id]: !row.getIsExpanded() }), //only 1 detail panel open at a time
51
+ sx: {
52
+ transform: row.getIsExpanded() ? 'rotate(180deg)' : 'rotate(-90deg)',
53
+ transition: 'transform 0.2s',
54
+ },
55
+ }),
56
+ //conditionally render detail panel
57
+ renderDetailPanel: ({ row }) =>
58
+ row.original.address ? (
59
+ <Box
60
+ sx={{
61
+ display: 'grid',
62
+ margin: 'auto',
63
+ gridTemplateColumns: '1fr 1fr',
64
+ width: '100%',
65
+ }}
66
+ >
67
+ <Typography>Address: {row.original.address}</Typography>
68
+ <Typography>City: {row.original.city}</Typography>
69
+ <Typography>State: {row.original.state}</Typography>
70
+ <Typography>Country: {row.original.country}</Typography>
71
+ </Box>
72
+ ) : null,
73
+ });
74
+
75
+ return <MaterialReactTable table={table} />;
76
+ };
77
+
78
+ export default Example;
@@ -0,0 +1,80 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+ import { Box, Typography } from '@mui/material';
8
+ import { data, type Person } from './makeData';
9
+
10
+ const Example = () => {
11
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
12
+ //column definitions...
13
+ () => [
14
+ {
15
+ accessorKey: 'firstName',
16
+ header: 'First Name',
17
+ },
18
+ {
19
+ accessorKey: 'lastName',
20
+ header: 'Last Name',
21
+ },
22
+ {
23
+ accessorKey: 'email',
24
+ header: 'Email',
25
+ },
26
+ ],
27
+ [],
28
+ //end
29
+ );
30
+
31
+ const table = useMaterialReactTable({
32
+ columns,
33
+ data,
34
+ enableBottomToolbar: false,
35
+ enablePagination: false,
36
+ enableRowVirtualization: true,
37
+ muiTableContainerProps: {
38
+ sx: {
39
+ maxHeight: '500px',
40
+ },
41
+ },
42
+ renderDetailPanel: ({ row }) => (
43
+ <Box
44
+ sx={{
45
+ display: 'grid',
46
+ margin: 'auto',
47
+ gridTemplateColumns: '1fr 1fr',
48
+ width: '100%',
49
+ }}
50
+ >
51
+ <Typography>Address: {row.original.address}</Typography>
52
+ <Typography>City: {row.original.city}</Typography>
53
+ <Typography>State: {row.original.state}</Typography>
54
+ <Typography>Country: {row.original.country}</Typography>
55
+ </Box>
56
+ ),
57
+ rowVirtualizerOptions: ({ table }) => {
58
+ const { density, expanded } = table.getState();
59
+ return {
60
+ //adjust to your needs
61
+ estimateSize: (index) =>
62
+ index % 2 === 1 //even rows are normal rows, odd rows are detail panels
63
+ ? //Estimate open detail panels as 80px tall, closed detail panels as 0px tall
64
+ expanded === true
65
+ ? 80
66
+ : 0
67
+ : //estimate normal row heights
68
+ density === 'compact'
69
+ ? 37
70
+ : density === 'comfortable'
71
+ ? 58
72
+ : 73,
73
+ };
74
+ },
75
+ });
76
+
77
+ return <MaterialReactTable table={table} />;
78
+ };
79
+
80
+ export default Example;
@@ -0,0 +1,110 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+
8
+ export type Person = {
9
+ firstName: string;
10
+ lastName: string;
11
+ address: string;
12
+ city: string;
13
+ state: string;
14
+ subRows?: Person[]; //Each person can have sub rows of more people
15
+ };
16
+
17
+ export const data = [
18
+ {
19
+ firstName: 'Dylan',
20
+ lastName: 'Murray',
21
+ address: '261 Erdman Ford',
22
+ city: 'East Daphne',
23
+ state: 'Kentucky',
24
+ subRows: [
25
+ {
26
+ firstName: 'Ervin',
27
+ lastName: 'Reinger',
28
+ address: '566 Brakus Inlet',
29
+ city: 'South Linda',
30
+ state: 'West Virginia',
31
+ subRows: [
32
+ {
33
+ firstName: 'Jordane',
34
+ lastName: 'Homenick',
35
+ address: '1234 Brakus Inlet',
36
+ city: 'South Linda',
37
+ state: 'West Virginia',
38
+ },
39
+ ],
40
+ },
41
+ {
42
+ firstName: 'Brittany',
43
+ lastName: 'McCullough',
44
+ address: '722 Emie Stream',
45
+ city: 'Lincoln',
46
+ state: 'Nebraska',
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ firstName: 'Raquel',
52
+ lastName: 'Kohler',
53
+ address: '769 Dominic Grove',
54
+ city: 'Columbus',
55
+ state: 'Ohio',
56
+ subRows: [
57
+ {
58
+ firstName: 'Branson',
59
+ lastName: 'Frami',
60
+ address: '32188 Larkin Turnpike',
61
+ city: 'Charleston',
62
+ state: 'South Carolina',
63
+ },
64
+ ],
65
+ },
66
+ ];
67
+
68
+ const Example = () => {
69
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
70
+ //column definitions...
71
+ () => [
72
+ {
73
+ accessorKey: 'firstName',
74
+ header: 'First Name',
75
+ },
76
+ {
77
+ accessorKey: 'lastName',
78
+ header: 'Last Name',
79
+ },
80
+
81
+ {
82
+ accessorKey: 'address',
83
+ header: 'Address',
84
+ },
85
+ {
86
+ accessorKey: 'city',
87
+ header: 'City',
88
+ },
89
+
90
+ {
91
+ accessorKey: 'state',
92
+ enableColumnOrdering: false,
93
+ header: 'State',
94
+ },
95
+ ],
96
+ [],
97
+ //end
98
+ );
99
+
100
+ const table = useMaterialReactTable({
101
+ columns,
102
+ data,
103
+ enableExpandAll: false, //hide expand all double arrow in column header
104
+ enableExpanding: true,
105
+ });
106
+
107
+ return <MaterialReactTable table={table} />;
108
+ };
109
+
110
+ export default Example;
@@ -0,0 +1,65 @@
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: 'name',
14
+ header: 'Name',
15
+ filterVariant: 'autocomplete', // default
16
+ size: 100,
17
+ },
18
+ {
19
+ accessorKey: 'salary',
20
+ header: 'Salary',
21
+ Cell: ({ cell }) =>
22
+ cell.getValue<number>().toLocaleString('en-US', {
23
+ style: 'currency',
24
+ currency: 'USD',
25
+ }),
26
+ filterVariant: 'range-slider',
27
+ filterFn: 'betweenInclusive', // default (or between)
28
+ muiFilterSliderProps: {
29
+ //no need to specify min/max/step if using faceted values
30
+ marks: true,
31
+ step: 5_000,
32
+ valueLabelFormat: (value) =>
33
+ value.toLocaleString('en-US', {
34
+ style: 'currency',
35
+ currency: 'USD',
36
+ }),
37
+ },
38
+ },
39
+ {
40
+ accessorKey: 'city',
41
+ header: 'City',
42
+ filterVariant: 'select',
43
+ //no need to specify filterSelectOptions if using faceted values
44
+ },
45
+ {
46
+ accessorKey: 'state',
47
+ header: 'State',
48
+ filterVariant: 'multi-select',
49
+ //no need to specify filterSelectOptions if using faceted values
50
+ },
51
+ ],
52
+ [],
53
+ );
54
+
55
+ const table = useMaterialReactTable({
56
+ columns,
57
+ data,
58
+ enableFacetedValues: true,
59
+ initialState: { showColumnFilters: true },
60
+ });
61
+
62
+ return <MaterialReactTable table={table} />;
63
+ };
64
+
65
+ export default Example;
@@ -0,0 +1,137 @@
1
+ import { useMemo, useState } from 'react';
2
+ import {
3
+ type MRT_TableOptions,
4
+ type MRT_ColumnDef,
5
+ type MRT_Row,
6
+ MaterialReactTable,
7
+ useMaterialReactTable,
8
+ } from 'material-react-table';
9
+ import { Box, Typography } from '@mui/material';
10
+ import { data, type Person } from './makeData';
11
+
12
+ const Example = () => {
13
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
14
+ //column definitions...
15
+ () => [
16
+ {
17
+ accessorKey: 'firstName',
18
+ header: 'First Name',
19
+ },
20
+ {
21
+ accessorKey: 'lastName',
22
+ header: 'Last Name',
23
+ },
24
+ {
25
+ accessorKey: 'city',
26
+ header: 'City',
27
+ },
28
+ ],
29
+ [],
30
+ //end
31
+ );
32
+
33
+ const [data1, setData1] = useState<Person[]>(() => data.slice(0, 3));
34
+ const [data2, setData2] = useState<Person[]>(() => data.slice(3, 5));
35
+
36
+ const [draggingRow, setDraggingRow] = useState<MRT_Row<Person> | null>(null);
37
+ const [hoveredTable, setHoveredTable] = useState<string | null>(null);
38
+
39
+ const commonTableProps: Partial<MRT_TableOptions<Person>> & {
40
+ columns: MRT_ColumnDef<Person>[];
41
+ } = {
42
+ columns,
43
+ enableRowDragging: true,
44
+ enableFullScreenToggle: false,
45
+ muiTableContainerProps: {
46
+ sx: {
47
+ minHeight: '320px',
48
+ },
49
+ },
50
+ onDraggingRowChange: setDraggingRow,
51
+ state: { draggingRow },
52
+ };
53
+
54
+ const table1 = useMaterialReactTable({
55
+ ...commonTableProps,
56
+ data: data1,
57
+ getRowId: (originalRow) => `table-1-${originalRow.firstName}`,
58
+ muiRowDragHandleProps: {
59
+ onDragEnd: () => {
60
+ if (hoveredTable === 'table-2') {
61
+ setData2((data2) => [...data2, draggingRow!.original]);
62
+ setData1((data1) => data1.filter((d) => d !== draggingRow!.original));
63
+ }
64
+ setHoveredTable(null);
65
+ },
66
+ },
67
+ muiTablePaperProps: {
68
+ onDragEnter: () => setHoveredTable('table-1'),
69
+ sx: {
70
+ outline: hoveredTable === 'table-1' ? '2px dashed pink' : undefined,
71
+ },
72
+ },
73
+ renderTopToolbarCustomActions: () => (
74
+ <Typography
75
+ component="span"
76
+ variant="h4"
77
+ sx={{
78
+ color: 'success.main',
79
+ }}
80
+ >
81
+ Nice List
82
+ </Typography>
83
+ ),
84
+ });
85
+
86
+ const table2 = useMaterialReactTable({
87
+ ...commonTableProps,
88
+ data: data2,
89
+ defaultColumn: {
90
+ size: 100,
91
+ },
92
+ getRowId: (originalRow) => `table-2-${originalRow.firstName}`,
93
+ muiRowDragHandleProps: {
94
+ onDragEnd: () => {
95
+ if (hoveredTable === 'table-1') {
96
+ setData1((data1) => [...data1, draggingRow!.original]);
97
+ setData2((data2) => data2.filter((d) => d !== draggingRow!.original));
98
+ }
99
+ setHoveredTable(null);
100
+ },
101
+ },
102
+ muiTablePaperProps: {
103
+ onDragEnter: () => setHoveredTable('table-2'),
104
+ sx: {
105
+ outline: hoveredTable === 'table-2' ? '2px dashed pink' : undefined,
106
+ },
107
+ },
108
+ renderTopToolbarCustomActions: () => (
109
+ <Typography
110
+ component="span"
111
+ variant="h4"
112
+ sx={{
113
+ color: 'error.main',
114
+ }}
115
+ >
116
+ Naughty List
117
+ </Typography>
118
+ ),
119
+ });
120
+
121
+ return (
122
+ <Box
123
+ sx={{
124
+ display: 'grid',
125
+ gridTemplateColumns: { xs: 'auto', lg: '1fr 1fr' },
126
+ gap: '1rem',
127
+ overflow: 'auto',
128
+ p: '4px',
129
+ }}
130
+ >
131
+ <MaterialReactTable table={table1} />
132
+ <MaterialReactTable table={table2} />
133
+ </Box>
134
+ );
135
+ };
136
+
137
+ export default Example;
@@ -0,0 +1,48 @@
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
+ //column definitions...
12
+ () => [
13
+ {
14
+ accessorKey: 'firstName',
15
+ header: 'First Name',
16
+ },
17
+ {
18
+ accessorKey: 'lastName',
19
+ header: 'Last Name',
20
+ },
21
+ {
22
+ accessorKey: 'address',
23
+ header: 'Address',
24
+ },
25
+ {
26
+ accessorKey: 'city',
27
+ header: 'City',
28
+ },
29
+ {
30
+ accessorKey: 'state',
31
+ header: 'State',
32
+ },
33
+ ],
34
+ [],
35
+ //end
36
+ );
37
+
38
+ const table = useMaterialReactTable({
39
+ columns,
40
+ data,
41
+ enableRowNumbers: true,
42
+ rowNumberDisplayMode: 'original',
43
+ });
44
+
45
+ return <MaterialReactTable table={table} />;
46
+ };
47
+
48
+ export default Example;