@mini_7/material-react-table-mcp 4.0.0 → 4.0.1

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 (117) hide show
  1. package/README.md +1 -1
  2. package/data/examples/advanced.js +215 -0
  3. package/data/examples/aggregation-and-grouping.js +116 -0
  4. package/data/examples/aggregation-multi.js +89 -0
  5. package/data/examples/alternate-column-filtering.js +38 -0
  6. package/data/examples/alternate-detail-panel.js +65 -0
  7. package/data/examples/alternate-pagination.js +17 -0
  8. package/data/examples/basic.js +86 -0
  9. package/data/examples/chart-detail-panel.js +69 -0
  10. package/data/examples/column-actions-space.js +34 -0
  11. package/data/examples/column-alignment.js +58 -0
  12. package/data/examples/custom-column-actions.js +74 -0
  13. package/data/examples/custom-column-filtering-ui.js +59 -0
  14. package/data/examples/custom-headless.js +85 -0
  15. package/data/examples/custom-top-toolbar.js +60 -0
  16. package/data/examples/customize-display-columns.js +72 -0
  17. package/data/examples/customize-filter-components.js +78 -0
  18. package/data/examples/customize-filter-modes.js +59 -0
  19. package/data/examples/customize-filter-variants.js +98 -0
  20. package/data/examples/customize-global-filter-component.js +37 -0
  21. package/data/examples/customize-remove-column-grouping.js +75 -0
  22. package/data/examples/customize-row-selection.js +43 -0
  23. package/data/examples/customize-table-styles.js +81 -0
  24. package/data/examples/disable-column-actions.js +26 -0
  25. package/data/examples/disable-column-hiding.js +74 -0
  26. package/data/examples/disable-density-toggle.js +37 -0
  27. package/data/examples/dynamic-columns.js +124 -0
  28. package/data/examples/editing-crud-cell.js +288 -0
  29. package/data/examples/editing-crud-modal.js +275 -0
  30. package/data/examples/editing-crud-row.js +255 -0
  31. package/data/examples/editing-crud-table.js +280 -0
  32. package/data/examples/editing-crud-tree.js +328 -0
  33. package/data/examples/enable-cell-actions.js +52 -0
  34. package/data/examples/enable-click-to-copy.js +33 -0
  35. package/data/examples/enable-column-grouping.js +69 -0
  36. package/data/examples/enable-column-ordering.js +37 -0
  37. package/data/examples/enable-column-pinning.js +58 -0
  38. package/data/examples/enable-column-resizing.js +45 -0
  39. package/data/examples/enable-column-virtualization.js +19 -0
  40. package/data/examples/enable-detail-panel-conditionally.js +61 -0
  41. package/data/examples/enable-detail-panel-virtualized.js +64 -0
  42. package/data/examples/enable-expanding-tree.js +87 -0
  43. package/data/examples/enable-filter-facet-values.js +52 -0
  44. package/data/examples/enable-row-dragging.js +102 -0
  45. package/data/examples/enable-row-numbers-original.js +37 -0
  46. package/data/examples/enable-row-numbers-static.js +37 -0
  47. package/data/examples/enable-row-ordering.js +40 -0
  48. package/data/examples/enable-row-pinning-select.js +64 -0
  49. package/data/examples/enable-row-pinning-static.js +39 -0
  50. package/data/examples/enable-row-pinning-sticky.js +57 -0
  51. package/data/examples/enable-row-selection.js +71 -0
  52. package/data/examples/enable-row-virtualization.js +85 -0
  53. package/data/examples/enable-sticky-header.js +47 -0
  54. package/data/examples/expanding-tree-expanded.js +98 -0
  55. package/data/examples/expanding-tree-flat-parse.js +102 -0
  56. package/data/examples/expanding-tree-root-expanded.js +120 -0
  57. package/data/examples/export-to-csv.js +84 -0
  58. package/data/examples/export-to-pdf.js +76 -0
  59. package/data/examples/external-toolbar.js +82 -0
  60. package/data/examples/font-awesome-icons.js +62 -0
  61. package/data/examples/infinite-scrolling.js +137 -0
  62. package/data/examples/lazy-detail-panel.js +164 -0
  63. package/data/examples/lazy-sub-rows.js +118 -0
  64. package/data/examples/linear-progress.js +48 -0
  65. package/data/examples/loading.js +34 -0
  66. package/data/examples/localization-i18n-ar.js +40 -0
  67. package/data/examples/localization-i18n-az.js +38 -0
  68. package/data/examples/localization-i18n-bg.js +38 -0
  69. package/data/examples/localization-i18n-cs.js +38 -0
  70. package/data/examples/localization-i18n-da.js +38 -0
  71. package/data/examples/localization-i18n-de.js +38 -0
  72. package/data/examples/localization-i18n-el.js +38 -0
  73. package/data/examples/localization-i18n-en.js +38 -0
  74. package/data/examples/localization-i18n-es.js +38 -0
  75. package/data/examples/localization-i18n-et.js +38 -0
  76. package/data/examples/localization-i18n-fa.js +40 -0
  77. package/data/examples/localization-i18n-fi.js +38 -0
  78. package/data/examples/localization-i18n-fr.js +38 -0
  79. package/data/examples/localization-i18n-he.js +40 -0
  80. package/data/examples/localization-i18n-hr.js +38 -0
  81. package/data/examples/localization-i18n-hu.js +38 -0
  82. package/data/examples/localization-i18n-hy.js +40 -0
  83. package/data/examples/localization-i18n-id.js +38 -0
  84. package/data/examples/localization-i18n-it.js +38 -0
  85. package/data/examples/localization-i18n-ja.js +38 -0
  86. package/data/examples/localization-i18n-ko.js +38 -0
  87. package/data/examples/localization-i18n-nl.js +38 -0
  88. package/data/examples/localization-i18n-no.js +38 -0
  89. package/data/examples/localization-i18n-np.js +38 -0
  90. package/data/examples/localization-i18n-pl.js +38 -0
  91. package/data/examples/localization-i18n-pt-BR.js +38 -0
  92. package/data/examples/localization-i18n-pt.js +38 -0
  93. package/data/examples/localization-i18n-ro.js +38 -0
  94. package/data/examples/localization-i18n-ru.js +38 -0
  95. package/data/examples/localization-i18n-sk.js +38 -0
  96. package/data/examples/localization-i18n-sr-Cyrl-RS.js +38 -0
  97. package/data/examples/localization-i18n-sr-Latn-RS.js +38 -0
  98. package/data/examples/localization-i18n-sv.js +38 -0
  99. package/data/examples/localization-i18n-tr.js +38 -0
  100. package/data/examples/localization-i18n-uk.js +38 -0
  101. package/data/examples/localization-i18n-vi.js +38 -0
  102. package/data/examples/localization-i18n-zh-hans.js +38 -0
  103. package/data/examples/localization-i18n-zh-hant.js +38 -0
  104. package/data/examples/manual-selection.js +81 -0
  105. package/data/examples/minimal.js +66 -0
  106. package/data/examples/mui-theme.js +109 -0
  107. package/data/examples/multi-sorting.js +48 -0
  108. package/data/examples/persistent-state.js +126 -0
  109. package/data/examples/react-query.js +122 -0
  110. package/data/examples/remote.js +113 -0
  111. package/data/examples/row-actions-buttons.js +54 -0
  112. package/data/examples/row-actions-menu-items.js +36 -0
  113. package/data/examples/single-row-selection.js +74 -0
  114. package/data/examples/virtualized.js +122 -0
  115. package/dist/data.js +31 -9
  116. package/dist/index.js +18 -6
  117. package/package.json +1 -1
@@ -0,0 +1,61 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { Box, Typography } from '@mui/material';
4
+ import { data } from './makeData';
5
+ const Example = () => {
6
+ const columns = useMemo(
7
+ //column definitions...
8
+ () => [
9
+ {
10
+ accessorKey: 'id',
11
+ header: 'ID',
12
+ size: 50,
13
+ },
14
+ {
15
+ accessorKey: 'firstName',
16
+ header: 'First Name',
17
+ },
18
+ {
19
+ accessorKey: 'middleName',
20
+ header: 'Middle Name',
21
+ },
22
+ {
23
+ accessorKey: 'lastName',
24
+ header: 'Last Name',
25
+ },
26
+ ], []);
27
+ const table = useMaterialReactTable({
28
+ columns,
29
+ data,
30
+ enableExpandAll: false, //disable expand all button
31
+ muiDetailPanelProps: () => ({
32
+ sx: (theme) => ({
33
+ backgroundColor: theme.palette.mode === 'dark'
34
+ ? 'rgba(255,210,244,0.1)'
35
+ : 'rgba(0,0,0,0.1)',
36
+ }),
37
+ }),
38
+ //custom expand button rotation
39
+ muiExpandButtonProps: ({ row, table }) => ({
40
+ onClick: () => table.setExpanded({ [row.id]: !row.getIsExpanded() }), //only 1 detail panel open at a time
41
+ sx: {
42
+ transform: row.getIsExpanded() ? 'rotate(180deg)' : 'rotate(-90deg)',
43
+ transition: 'transform 0.2s',
44
+ },
45
+ }),
46
+ //conditionally render detail panel
47
+ renderDetailPanel: ({ row }) => row.original.address ? (<Box sx={{
48
+ display: 'grid',
49
+ margin: 'auto',
50
+ gridTemplateColumns: '1fr 1fr',
51
+ width: '100%',
52
+ }}>
53
+ <Typography>Address: {row.original.address}</Typography>
54
+ <Typography>City: {row.original.city}</Typography>
55
+ <Typography>State: {row.original.state}</Typography>
56
+ <Typography>Country: {row.original.country}</Typography>
57
+ </Box>) : null,
58
+ });
59
+ return <MaterialReactTable table={table}/>;
60
+ };
61
+ export default Example;
@@ -0,0 +1,64 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { Box, Typography } from '@mui/material';
4
+ import { data } from './makeData';
5
+ const Example = () => {
6
+ const columns = useMemo(
7
+ //column definitions...
8
+ () => [
9
+ {
10
+ accessorKey: 'firstName',
11
+ header: 'First Name',
12
+ },
13
+ {
14
+ accessorKey: 'lastName',
15
+ header: 'Last Name',
16
+ },
17
+ {
18
+ accessorKey: 'email',
19
+ header: 'Email',
20
+ },
21
+ ], []);
22
+ const table = useMaterialReactTable({
23
+ columns,
24
+ data,
25
+ enableBottomToolbar: false,
26
+ enablePagination: false,
27
+ enableRowVirtualization: true,
28
+ muiTableContainerProps: {
29
+ sx: {
30
+ maxHeight: '500px',
31
+ },
32
+ },
33
+ renderDetailPanel: ({ row }) => (<Box sx={{
34
+ display: 'grid',
35
+ margin: 'auto',
36
+ gridTemplateColumns: '1fr 1fr',
37
+ width: '100%',
38
+ }}>
39
+ <Typography>Address: {row.original.address}</Typography>
40
+ <Typography>City: {row.original.city}</Typography>
41
+ <Typography>State: {row.original.state}</Typography>
42
+ <Typography>Country: {row.original.country}</Typography>
43
+ </Box>),
44
+ rowVirtualizerOptions: ({ table }) => {
45
+ const { density, expanded } = table.getState();
46
+ return {
47
+ //adjust to your needs
48
+ estimateSize: (index) => index % 2 === 1 //even rows are normal rows, odd rows are detail panels
49
+ ? //Estimate open detail panels as 80px tall, closed detail panels as 0px tall
50
+ expanded === true
51
+ ? 80
52
+ : 0
53
+ : //estimate normal row heights
54
+ density === 'compact'
55
+ ? 37
56
+ : density === 'comfortable'
57
+ ? 58
58
+ : 73,
59
+ };
60
+ },
61
+ });
62
+ return <MaterialReactTable table={table}/>;
63
+ };
64
+ export default Example;
@@ -0,0 +1,87 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ export const data = [
4
+ {
5
+ firstName: 'Dylan',
6
+ lastName: 'Murray',
7
+ address: '261 Erdman Ford',
8
+ city: 'East Daphne',
9
+ state: 'Kentucky',
10
+ subRows: [
11
+ {
12
+ firstName: 'Ervin',
13
+ lastName: 'Reinger',
14
+ address: '566 Brakus Inlet',
15
+ city: 'South Linda',
16
+ state: 'West Virginia',
17
+ subRows: [
18
+ {
19
+ firstName: 'Jordane',
20
+ lastName: 'Homenick',
21
+ address: '1234 Brakus Inlet',
22
+ city: 'South Linda',
23
+ state: 'West Virginia',
24
+ },
25
+ ],
26
+ },
27
+ {
28
+ firstName: 'Brittany',
29
+ lastName: 'McCullough',
30
+ address: '722 Emie Stream',
31
+ city: 'Lincoln',
32
+ state: 'Nebraska',
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ firstName: 'Raquel',
38
+ lastName: 'Kohler',
39
+ address: '769 Dominic Grove',
40
+ city: 'Columbus',
41
+ state: 'Ohio',
42
+ subRows: [
43
+ {
44
+ firstName: 'Branson',
45
+ lastName: 'Frami',
46
+ address: '32188 Larkin Turnpike',
47
+ city: 'Charleston',
48
+ state: 'South Carolina',
49
+ },
50
+ ],
51
+ },
52
+ ];
53
+ const Example = () => {
54
+ const columns = useMemo(
55
+ //column definitions...
56
+ () => [
57
+ {
58
+ accessorKey: 'firstName',
59
+ header: 'First Name',
60
+ },
61
+ {
62
+ accessorKey: 'lastName',
63
+ header: 'Last Name',
64
+ },
65
+ {
66
+ accessorKey: 'address',
67
+ header: 'Address',
68
+ },
69
+ {
70
+ accessorKey: 'city',
71
+ header: 'City',
72
+ },
73
+ {
74
+ accessorKey: 'state',
75
+ enableColumnOrdering: false,
76
+ header: 'State',
77
+ },
78
+ ], []);
79
+ const table = useMaterialReactTable({
80
+ columns,
81
+ data,
82
+ enableExpandAll: false, //hide expand all double arrow in column header
83
+ enableExpanding: true,
84
+ });
85
+ return <MaterialReactTable table={table}/>;
86
+ };
87
+ export default Example;
@@ -0,0 +1,52 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { data } from './makeData';
4
+ const Example = () => {
5
+ const columns = useMemo(() => [
6
+ {
7
+ accessorKey: 'name',
8
+ header: 'Name',
9
+ filterVariant: 'autocomplete', // default
10
+ size: 100,
11
+ },
12
+ {
13
+ accessorKey: 'salary',
14
+ header: 'Salary',
15
+ Cell: ({ cell }) => cell.getValue().toLocaleString('en-US', {
16
+ style: 'currency',
17
+ currency: 'USD',
18
+ }),
19
+ filterVariant: 'range-slider',
20
+ filterFn: 'betweenInclusive', // default (or between)
21
+ muiFilterSliderProps: {
22
+ //no need to specify min/max/step if using faceted values
23
+ marks: true,
24
+ step: 5000,
25
+ valueLabelFormat: (value) => value.toLocaleString('en-US', {
26
+ style: 'currency',
27
+ currency: 'USD',
28
+ }),
29
+ },
30
+ },
31
+ {
32
+ accessorKey: 'city',
33
+ header: 'City',
34
+ filterVariant: 'select',
35
+ //no need to specify filterSelectOptions if using faceted values
36
+ },
37
+ {
38
+ accessorKey: 'state',
39
+ header: 'State',
40
+ filterVariant: 'multi-select',
41
+ //no need to specify filterSelectOptions if using faceted values
42
+ },
43
+ ], []);
44
+ const table = useMaterialReactTable({
45
+ columns,
46
+ data,
47
+ enableFacetedValues: true,
48
+ initialState: { showColumnFilters: true },
49
+ });
50
+ return <MaterialReactTable table={table}/>;
51
+ };
52
+ export default Example;
@@ -0,0 +1,102 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { Box, Typography } from '@mui/material';
4
+ import { data } from './makeData';
5
+ const Example = () => {
6
+ const columns = useMemo(
7
+ //column definitions...
8
+ () => [
9
+ {
10
+ accessorKey: 'firstName',
11
+ header: 'First Name',
12
+ },
13
+ {
14
+ accessorKey: 'lastName',
15
+ header: 'Last Name',
16
+ },
17
+ {
18
+ accessorKey: 'city',
19
+ header: 'City',
20
+ },
21
+ ], []);
22
+ const [data1, setData1] = useState(() => data.slice(0, 3));
23
+ const [data2, setData2] = useState(() => data.slice(3, 5));
24
+ const [draggingRow, setDraggingRow] = useState(null);
25
+ const [hoveredTable, setHoveredTable] = useState(null);
26
+ const commonTableProps = {
27
+ columns,
28
+ enableRowDragging: true,
29
+ enableFullScreenToggle: false,
30
+ muiTableContainerProps: {
31
+ sx: {
32
+ minHeight: '320px',
33
+ },
34
+ },
35
+ onDraggingRowChange: setDraggingRow,
36
+ state: { draggingRow },
37
+ };
38
+ const table1 = useMaterialReactTable({
39
+ ...commonTableProps,
40
+ data: data1,
41
+ getRowId: (originalRow) => `table-1-${originalRow.firstName}`,
42
+ muiRowDragHandleProps: {
43
+ onDragEnd: () => {
44
+ if (hoveredTable === 'table-2') {
45
+ setData2((data2) => [...data2, draggingRow.original]);
46
+ setData1((data1) => data1.filter((d) => d !== draggingRow.original));
47
+ }
48
+ setHoveredTable(null);
49
+ },
50
+ },
51
+ muiTablePaperProps: {
52
+ onDragEnter: () => setHoveredTable('table-1'),
53
+ sx: {
54
+ outline: hoveredTable === 'table-1' ? '2px dashed pink' : undefined,
55
+ },
56
+ },
57
+ renderTopToolbarCustomActions: () => (<Typography component="span" variant="h4" sx={{
58
+ color: 'success.main',
59
+ }}>
60
+ Nice List
61
+ </Typography>),
62
+ });
63
+ const table2 = useMaterialReactTable({
64
+ ...commonTableProps,
65
+ data: data2,
66
+ defaultColumn: {
67
+ size: 100,
68
+ },
69
+ getRowId: (originalRow) => `table-2-${originalRow.firstName}`,
70
+ muiRowDragHandleProps: {
71
+ onDragEnd: () => {
72
+ if (hoveredTable === 'table-1') {
73
+ setData1((data1) => [...data1, draggingRow.original]);
74
+ setData2((data2) => data2.filter((d) => d !== draggingRow.original));
75
+ }
76
+ setHoveredTable(null);
77
+ },
78
+ },
79
+ muiTablePaperProps: {
80
+ onDragEnter: () => setHoveredTable('table-2'),
81
+ sx: {
82
+ outline: hoveredTable === 'table-2' ? '2px dashed pink' : undefined,
83
+ },
84
+ },
85
+ renderTopToolbarCustomActions: () => (<Typography component="span" variant="h4" sx={{
86
+ color: 'error.main',
87
+ }}>
88
+ Naughty List
89
+ </Typography>),
90
+ });
91
+ return (<Box sx={{
92
+ display: 'grid',
93
+ gridTemplateColumns: { xs: 'auto', lg: '1fr 1fr' },
94
+ gap: '1rem',
95
+ overflow: 'auto',
96
+ p: '4px',
97
+ }}>
98
+ <MaterialReactTable table={table1}/>
99
+ <MaterialReactTable table={table2}/>
100
+ </Box>);
101
+ };
102
+ export default Example;
@@ -0,0 +1,37 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { data } from './makeData';
4
+ const Example = () => {
5
+ const columns = useMemo(
6
+ //column definitions...
7
+ () => [
8
+ {
9
+ accessorKey: 'firstName',
10
+ header: 'First Name',
11
+ },
12
+ {
13
+ accessorKey: 'lastName',
14
+ header: 'Last Name',
15
+ },
16
+ {
17
+ accessorKey: 'address',
18
+ header: 'Address',
19
+ },
20
+ {
21
+ accessorKey: 'city',
22
+ header: 'City',
23
+ },
24
+ {
25
+ accessorKey: 'state',
26
+ header: 'State',
27
+ },
28
+ ], []);
29
+ const table = useMaterialReactTable({
30
+ columns,
31
+ data,
32
+ enableRowNumbers: true,
33
+ rowNumberDisplayMode: 'original',
34
+ });
35
+ return <MaterialReactTable table={table}/>;
36
+ };
37
+ export default Example;
@@ -0,0 +1,37 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { data } from './makeData';
4
+ const Example = () => {
5
+ const columns = useMemo(
6
+ //column definitions...
7
+ () => [
8
+ {
9
+ accessorKey: 'firstName',
10
+ header: 'First Name',
11
+ },
12
+ {
13
+ accessorKey: 'lastName',
14
+ header: 'Last Name',
15
+ },
16
+ {
17
+ accessorKey: 'address',
18
+ header: 'Address',
19
+ },
20
+ {
21
+ accessorKey: 'city',
22
+ header: 'City',
23
+ },
24
+ {
25
+ accessorKey: 'state',
26
+ header: 'State',
27
+ },
28
+ ], []);
29
+ const table = useMaterialReactTable({
30
+ columns,
31
+ data,
32
+ enableRowNumbers: true,
33
+ rowNumberDisplayMode: 'static', // default
34
+ });
35
+ return <MaterialReactTable table={table}/>;
36
+ };
37
+ export default Example;
@@ -0,0 +1,40 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { useMaterialReactTable, MRT_TableContainer, } from 'material-react-table';
3
+ import { data as initData } from './makeData';
4
+ const Example = () => {
5
+ const columns = useMemo(
6
+ //column definitions...
7
+ () => [
8
+ {
9
+ accessorKey: 'firstName',
10
+ header: 'First Name',
11
+ },
12
+ {
13
+ accessorKey: 'lastName',
14
+ header: 'Last Name',
15
+ },
16
+ {
17
+ accessorKey: 'city',
18
+ header: 'City',
19
+ },
20
+ ], []);
21
+ const [data, setData] = useState(() => initData);
22
+ const table = useMaterialReactTable({
23
+ autoResetPageIndex: false,
24
+ columns,
25
+ data,
26
+ enableRowOrdering: true,
27
+ enableSorting: false,
28
+ muiRowDragHandleProps: ({ table }) => ({
29
+ onDragEnd: () => {
30
+ const { draggingRow, hoveredRow } = table.getState();
31
+ if (hoveredRow && draggingRow) {
32
+ data.splice(hoveredRow.index, 0, data.splice(draggingRow.index, 1)[0]);
33
+ setData([...data]);
34
+ }
35
+ },
36
+ }),
37
+ });
38
+ return <MRT_TableContainer table={table}/>;
39
+ };
40
+ export default Example;
@@ -0,0 +1,64 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { data } from './makeData';
4
+ const Example = () => {
5
+ const columns = useMemo(
6
+ //column definitions...
7
+ () => [
8
+ {
9
+ accessorKey: 'firstName',
10
+ header: 'First Name',
11
+ },
12
+ {
13
+ accessorKey: 'lastName',
14
+ header: 'Last Name',
15
+ },
16
+ {
17
+ accessorKey: 'email',
18
+ header: 'Email',
19
+ },
20
+ {
21
+ accessorKey: 'city',
22
+ header: 'City',
23
+ },
24
+ ], []);
25
+ const table = useMaterialReactTable({
26
+ columns,
27
+ data,
28
+ enablePagination: false,
29
+ enableRowPinning: true,
30
+ enableRowSelection: true,
31
+ enableStickyHeader: true,
32
+ rowPinningDisplayMode: 'select-sticky',
33
+ getRowId: (row) => row.email,
34
+ initialState: {
35
+ rowPinning: {
36
+ bottom: [],
37
+ top: ['ereinger@mailinator.com'],
38
+ },
39
+ rowSelection: {
40
+ 'ereinger@mailinator.com': true,
41
+ },
42
+ },
43
+ muiTableContainerProps: {
44
+ sx: {
45
+ maxHeight: '400px',
46
+ },
47
+ },
48
+ muiTableBodyRowProps: ({ row, table }) => {
49
+ const { density } = table.getState();
50
+ return {
51
+ sx: {
52
+ //Set a fixed height for pinned rows
53
+ height: row.getIsPinned()
54
+ ? `${
55
+ //Default mrt row height estimates. Adjust as needed.
56
+ density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69}px`
57
+ : undefined,
58
+ },
59
+ };
60
+ },
61
+ });
62
+ return <MaterialReactTable table={table}/>;
63
+ };
64
+ export default Example;
@@ -0,0 +1,39 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { data } from './makeData';
4
+ const Example = () => {
5
+ const columns = useMemo(() => [
6
+ {
7
+ accessorKey: 'firstName',
8
+ header: 'First Name',
9
+ },
10
+ {
11
+ accessorKey: 'lastName',
12
+ header: 'Last Name',
13
+ },
14
+ {
15
+ accessorKey: 'email',
16
+ header: 'Email',
17
+ },
18
+ {
19
+ accessorKey: 'city',
20
+ header: 'City',
21
+ },
22
+ ], []);
23
+ const table = useMaterialReactTable({
24
+ columns,
25
+ data,
26
+ enableRowPinning: true,
27
+ enablePagination: false,
28
+ enableStickyHeader: true,
29
+ rowPinningDisplayMode: 'top-and-bottom',
30
+ getRowId: (row) => row.email,
31
+ muiTableContainerProps: {
32
+ sx: {
33
+ maxHeight: '400px',
34
+ },
35
+ },
36
+ });
37
+ return <MaterialReactTable table={table}/>;
38
+ };
39
+ export default Example;
@@ -0,0 +1,57 @@
1
+ import { useMemo } from 'react';
2
+ import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
3
+ import { data } from './makeData';
4
+ const Example = () => {
5
+ const columns = useMemo(() => [
6
+ {
7
+ accessorKey: 'firstName',
8
+ header: 'First Name',
9
+ },
10
+ {
11
+ accessorKey: 'lastName',
12
+ header: 'Last Name',
13
+ },
14
+ {
15
+ accessorKey: 'email',
16
+ header: 'Email',
17
+ },
18
+ {
19
+ accessorKey: 'city',
20
+ header: 'City',
21
+ },
22
+ ], []);
23
+ const table = useMaterialReactTable({
24
+ columns,
25
+ data,
26
+ enableRowPinning: true,
27
+ enablePagination: false,
28
+ enableStickyHeader: true,
29
+ getRowId: (row) => row.email,
30
+ initialState: {
31
+ rowPinning: {
32
+ top: ['rkholer33@yopmail.com', 'egarcia@yopmail.com'],
33
+ bottom: [],
34
+ },
35
+ },
36
+ muiTableContainerProps: {
37
+ sx: {
38
+ maxHeight: '400px',
39
+ },
40
+ },
41
+ muiTableBodyRowProps: ({ row, table }) => {
42
+ const { density } = table.getState();
43
+ return {
44
+ sx: {
45
+ //Set a fixed height for pinned rows
46
+ height: row.getIsPinned()
47
+ ? `${
48
+ //Default mrt row height estimates. Adjust as needed.
49
+ density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69}px`
50
+ : undefined,
51
+ },
52
+ };
53
+ },
54
+ });
55
+ return <MaterialReactTable table={table}/>;
56
+ };
57
+ export default Example;