@lminii/material-react-table-mcp 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.
- package/README.md +68 -0
- package/data/MIGRATION.md +136 -0
- package/data/api.json +5379 -0
- package/data/examples/advanced.js +215 -0
- package/data/examples/advanced.tsx +309 -0
- package/data/examples/aggregation-and-grouping.js +116 -0
- package/data/examples/aggregation-and-grouping.tsx +153 -0
- package/data/examples/aggregation-multi.js +89 -0
- package/data/examples/aggregation-multi.tsx +105 -0
- package/data/examples/alternate-column-filtering.js +38 -0
- package/data/examples/alternate-column-filtering.tsx +49 -0
- package/data/examples/alternate-detail-panel.js +65 -0
- package/data/examples/alternate-detail-panel.tsx +81 -0
- package/data/examples/alternate-pagination.js +17 -0
- package/data/examples/alternate-pagination.tsx +23 -0
- package/data/examples/basic.js +86 -0
- package/data/examples/basic.tsx +109 -0
- package/data/examples/chart-detail-panel.js +69 -0
- package/data/examples/chart-detail-panel.tsx +89 -0
- package/data/examples/column-actions-space.js +34 -0
- package/data/examples/column-actions-space.tsx +44 -0
- package/data/examples/column-alignment.js +58 -0
- package/data/examples/column-alignment.tsx +70 -0
- package/data/examples/custom-column-actions.js +74 -0
- package/data/examples/custom-column-actions.tsx +109 -0
- package/data/examples/custom-column-filtering-ui.js +59 -0
- package/data/examples/custom-column-filtering-ui.tsx +89 -0
- package/data/examples/custom-headless.js +85 -0
- package/data/examples/custom-headless.tsx +125 -0
- package/data/examples/custom-top-toolbar.js +60 -0
- package/data/examples/custom-top-toolbar.tsx +88 -0
- package/data/examples/customize-display-columns.js +72 -0
- package/data/examples/customize-display-columns.tsx +85 -0
- package/data/examples/customize-filter-components.js +78 -0
- package/data/examples/customize-filter-components.tsx +101 -0
- package/data/examples/customize-filter-modes.js +59 -0
- package/data/examples/customize-filter-modes.tsx +73 -0
- package/data/examples/customize-filter-variants.js +98 -0
- package/data/examples/customize-filter-variants.tsx +116 -0
- package/data/examples/customize-global-filter-component.js +37 -0
- package/data/examples/customize-global-filter-component.tsx +52 -0
- package/data/examples/customize-remove-column-grouping.js +75 -0
- package/data/examples/customize-remove-column-grouping.tsx +94 -0
- package/data/examples/customize-row-selection.js +43 -0
- package/data/examples/customize-row-selection.tsx +54 -0
- package/data/examples/customize-table-styles.js +81 -0
- package/data/examples/customize-table-styles.tsx +100 -0
- package/data/examples/disable-column-actions.js +26 -0
- package/data/examples/disable-column-actions.tsx +37 -0
- package/data/examples/disable-column-hiding.js +74 -0
- package/data/examples/disable-column-hiding.tsx +90 -0
- package/data/examples/disable-density-toggle.js +37 -0
- package/data/examples/disable-density-toggle.tsx +49 -0
- package/data/examples/dynamic-columns.js +124 -0
- package/data/examples/dynamic-columns.tsx +189 -0
- package/data/examples/editing-crud-cell.js +288 -0
- package/data/examples/editing-crud-cell.tsx +377 -0
- package/data/examples/editing-crud-modal.js +275 -0
- package/data/examples/editing-crud-modal.tsx +370 -0
- package/data/examples/editing-crud-row.js +255 -0
- package/data/examples/editing-crud-row.tsx +333 -0
- package/data/examples/editing-crud-table.js +280 -0
- package/data/examples/editing-crud-table.tsx +369 -0
- package/data/examples/editing-crud-tree.js +328 -0
- package/data/examples/editing-crud-tree.tsx +416 -0
- package/data/examples/enable-cell-actions.js +52 -0
- package/data/examples/enable-cell-actions.tsx +76 -0
- package/data/examples/enable-click-to-copy.js +33 -0
- package/data/examples/enable-click-to-copy.tsx +39 -0
- package/data/examples/enable-column-grouping.js +69 -0
- package/data/examples/enable-column-grouping.tsx +120 -0
- package/data/examples/enable-column-ordering.js +37 -0
- package/data/examples/enable-column-ordering.tsx +48 -0
- package/data/examples/enable-column-pinning.js +58 -0
- package/data/examples/enable-column-pinning.tsx +69 -0
- package/data/examples/enable-column-resizing.js +45 -0
- package/data/examples/enable-column-resizing.tsx +56 -0
- package/data/examples/enable-column-virtualization.js +19 -0
- package/data/examples/enable-column-virtualization.tsx +27 -0
- package/data/examples/enable-detail-panel-conditionally.js +61 -0
- package/data/examples/enable-detail-panel-conditionally.tsx +78 -0
- package/data/examples/enable-detail-panel-virtualized.js +64 -0
- package/data/examples/enable-detail-panel-virtualized.tsx +80 -0
- package/data/examples/enable-expanding-tree.js +87 -0
- package/data/examples/enable-expanding-tree.tsx +110 -0
- package/data/examples/enable-filter-facet-values.js +52 -0
- package/data/examples/enable-filter-facet-values.tsx +65 -0
- package/data/examples/enable-row-dragging.js +102 -0
- package/data/examples/enable-row-dragging.tsx +137 -0
- package/data/examples/enable-row-numbers-original.js +37 -0
- package/data/examples/enable-row-numbers-original.tsx +48 -0
- package/data/examples/enable-row-numbers-static.js +37 -0
- package/data/examples/enable-row-numbers-static.tsx +48 -0
- package/data/examples/enable-row-ordering.js +40 -0
- package/data/examples/enable-row-ordering.tsx +57 -0
- package/data/examples/enable-row-pinning-select.js +64 -0
- package/data/examples/enable-row-pinning-select.tsx +76 -0
- package/data/examples/enable-row-pinning-static.js +39 -0
- package/data/examples/enable-row-pinning-static.tsx +50 -0
- package/data/examples/enable-row-pinning-sticky.js +57 -0
- package/data/examples/enable-row-pinning-sticky.tsx +69 -0
- package/data/examples/enable-row-selection.js +71 -0
- package/data/examples/enable-row-selection.tsx +96 -0
- package/data/examples/enable-row-virtualization.js +85 -0
- package/data/examples/enable-row-virtualization.tsx +101 -0
- package/data/examples/enable-sticky-header.js +47 -0
- package/data/examples/enable-sticky-header.tsx +59 -0
- package/data/examples/expanding-tree-expanded.js +98 -0
- package/data/examples/expanding-tree-expanded.tsx +121 -0
- package/data/examples/expanding-tree-flat-parse.js +102 -0
- package/data/examples/expanding-tree-flat-parse.tsx +125 -0
- package/data/examples/expanding-tree-root-expanded.js +120 -0
- package/data/examples/expanding-tree-root-expanded.tsx +151 -0
- package/data/examples/export-to-csv.js +84 -0
- package/data/examples/export-to-csv.tsx +114 -0
- package/data/examples/export-to-pdf.js +76 -0
- package/data/examples/export-to-pdf.tsx +104 -0
- package/data/examples/external-toolbar.js +82 -0
- package/data/examples/external-toolbar.tsx +108 -0
- package/data/examples/font-awesome-icons.js +62 -0
- package/data/examples/font-awesome-icons.tsx +106 -0
- package/data/examples/infinite-scrolling.js +137 -0
- package/data/examples/infinite-scrolling.tsx +208 -0
- package/data/examples/lazy-detail-panel.js +164 -0
- package/data/examples/lazy-detail-panel.tsx +262 -0
- package/data/examples/lazy-sub-rows.js +118 -0
- package/data/examples/lazy-sub-rows.tsx +190 -0
- package/data/examples/linear-progress.js +48 -0
- package/data/examples/linear-progress.tsx +66 -0
- package/data/examples/loading.js +34 -0
- package/data/examples/loading.tsx +50 -0
- package/data/examples/localization-i18n-ar.js +40 -0
- package/data/examples/localization-i18n-ar.tsx +65 -0
- package/data/examples/localization-i18n-az.js +38 -0
- package/data/examples/localization-i18n-az.tsx +60 -0
- package/data/examples/localization-i18n-bg.js +38 -0
- package/data/examples/localization-i18n-bg.tsx +60 -0
- package/data/examples/localization-i18n-cs.js +38 -0
- package/data/examples/localization-i18n-cs.tsx +60 -0
- package/data/examples/localization-i18n-da.js +38 -0
- package/data/examples/localization-i18n-da.tsx +60 -0
- package/data/examples/localization-i18n-de.js +38 -0
- package/data/examples/localization-i18n-de.tsx +60 -0
- package/data/examples/localization-i18n-el.js +38 -0
- package/data/examples/localization-i18n-el.tsx +60 -0
- package/data/examples/localization-i18n-en.js +38 -0
- package/data/examples/localization-i18n-en.tsx +60 -0
- package/data/examples/localization-i18n-es.js +38 -0
- package/data/examples/localization-i18n-es.tsx +60 -0
- package/data/examples/localization-i18n-et.js +38 -0
- package/data/examples/localization-i18n-et.tsx +60 -0
- package/data/examples/localization-i18n-fa.js +40 -0
- package/data/examples/localization-i18n-fa.tsx +66 -0
- package/data/examples/localization-i18n-fi.js +38 -0
- package/data/examples/localization-i18n-fi.tsx +60 -0
- package/data/examples/localization-i18n-fr.js +38 -0
- package/data/examples/localization-i18n-fr.tsx +60 -0
- package/data/examples/localization-i18n-he.js +40 -0
- package/data/examples/localization-i18n-he.tsx +66 -0
- package/data/examples/localization-i18n-hr.js +38 -0
- package/data/examples/localization-i18n-hr.tsx +60 -0
- package/data/examples/localization-i18n-hu.js +38 -0
- package/data/examples/localization-i18n-hu.tsx +60 -0
- package/data/examples/localization-i18n-hy.js +40 -0
- package/data/examples/localization-i18n-hy.tsx +65 -0
- package/data/examples/localization-i18n-id.js +38 -0
- package/data/examples/localization-i18n-id.tsx +60 -0
- package/data/examples/localization-i18n-it.js +38 -0
- package/data/examples/localization-i18n-it.tsx +60 -0
- package/data/examples/localization-i18n-ja.js +38 -0
- package/data/examples/localization-i18n-ja.tsx +60 -0
- package/data/examples/localization-i18n-ko.js +38 -0
- package/data/examples/localization-i18n-ko.tsx +60 -0
- package/data/examples/localization-i18n-nl.js +38 -0
- package/data/examples/localization-i18n-nl.tsx +60 -0
- package/data/examples/localization-i18n-no.js +38 -0
- package/data/examples/localization-i18n-no.tsx +60 -0
- package/data/examples/localization-i18n-np.js +38 -0
- package/data/examples/localization-i18n-np.tsx +60 -0
- package/data/examples/localization-i18n-pl.js +38 -0
- package/data/examples/localization-i18n-pl.tsx +60 -0
- package/data/examples/localization-i18n-pt-BR.js +38 -0
- package/data/examples/localization-i18n-pt-BR.tsx +60 -0
- package/data/examples/localization-i18n-pt.js +38 -0
- package/data/examples/localization-i18n-pt.tsx +60 -0
- package/data/examples/localization-i18n-ro.js +38 -0
- package/data/examples/localization-i18n-ro.tsx +60 -0
- package/data/examples/localization-i18n-ru.js +38 -0
- package/data/examples/localization-i18n-ru.tsx +60 -0
- package/data/examples/localization-i18n-sk.js +38 -0
- package/data/examples/localization-i18n-sk.tsx +60 -0
- package/data/examples/localization-i18n-sr-Cyrl-RS.js +38 -0
- package/data/examples/localization-i18n-sr-Cyrl-RS.tsx +60 -0
- package/data/examples/localization-i18n-sr-Latn-RS.js +38 -0
- package/data/examples/localization-i18n-sr-Latn-RS.tsx +60 -0
- package/data/examples/localization-i18n-sv.js +38 -0
- package/data/examples/localization-i18n-sv.tsx +60 -0
- package/data/examples/localization-i18n-tr.js +38 -0
- package/data/examples/localization-i18n-tr.tsx +60 -0
- package/data/examples/localization-i18n-uk.js +38 -0
- package/data/examples/localization-i18n-uk.tsx +60 -0
- package/data/examples/localization-i18n-vi.js +38 -0
- package/data/examples/localization-i18n-vi.tsx +60 -0
- package/data/examples/localization-i18n-zh-hans.js +38 -0
- package/data/examples/localization-i18n-zh-hans.tsx +60 -0
- package/data/examples/localization-i18n-zh-hant.js +38 -0
- package/data/examples/localization-i18n-zh-hant.tsx +60 -0
- package/data/examples/manual-selection.js +81 -0
- package/data/examples/manual-selection.tsx +105 -0
- package/data/examples/minimal.js +66 -0
- package/data/examples/minimal.tsx +78 -0
- package/data/examples/mui-theme.js +109 -0
- package/data/examples/mui-theme.tsx +136 -0
- package/data/examples/multi-sorting.js +48 -0
- package/data/examples/multi-sorting.tsx +58 -0
- package/data/examples/persistent-state.js +126 -0
- package/data/examples/persistent-state.tsx +184 -0
- package/data/examples/react-query.js +122 -0
- package/data/examples/react-query.tsx +182 -0
- package/data/examples/remote.js +113 -0
- package/data/examples/remote.tsx +150 -0
- package/data/examples/row-actions-buttons.js +54 -0
- package/data/examples/row-actions-buttons.tsx +89 -0
- package/data/examples/row-actions-menu-items.js +36 -0
- package/data/examples/row-actions-menu-items.tsx +64 -0
- package/data/examples/single-row-selection.js +74 -0
- package/data/examples/single-row-selection.tsx +98 -0
- package/data/examples/virtualized.js +122 -0
- package/data/examples/virtualized.tsx +138 -0
- package/data/guides/accessibility.md +119 -0
- package/data/guides/aggregation.md +210 -0
- package/data/guides/async-loading.md +132 -0
- package/data/guides/best-practices.md +363 -0
- package/data/guides/cell-actions.md +139 -0
- package/data/guides/click-to-copy.md +67 -0
- package/data/guides/column-actions.md +69 -0
- package/data/guides/column-filtering.md +366 -0
- package/data/guides/column-grouping.md +192 -0
- package/data/guides/column-hiding.md +133 -0
- package/data/guides/column-ordering-dnd.md +99 -0
- package/data/guides/column-pinning.md +72 -0
- package/data/guides/column-resizing.md +157 -0
- package/data/guides/column-size.md +162 -0
- package/data/guides/customize-components.md +395 -0
- package/data/guides/customize-icons.md +35 -0
- package/data/guides/data-columns.md +292 -0
- package/data/guides/density-toggle.md +46 -0
- package/data/guides/detail-panel.md +195 -0
- package/data/guides/display-columns.md +135 -0
- package/data/guides/editing.md +367 -0
- package/data/guides/expanding-sub-rows.md +194 -0
- package/data/guides/full-screen-toggle.md +63 -0
- package/data/guides/global-filtering.md +237 -0
- package/data/guides/localization.md +57 -0
- package/data/guides/memoization.md +157 -0
- package/data/guides/pagination.md +171 -0
- package/data/guides/row-actions.md +116 -0
- package/data/guides/row-numbers.md +24 -0
- package/data/guides/row-ordering-dnd.md +51 -0
- package/data/guides/row-pinning.md +96 -0
- package/data/guides/row-selection.md +237 -0
- package/data/guides/sorting.md +190 -0
- package/data/guides/state-management.md +165 -0
- package/data/guides/sticky-header.md +41 -0
- package/data/guides/table-event-listeners.md +103 -0
- package/data/guides/toolbar-customization.md +251 -0
- package/data/guides/virtualization.md +183 -0
- package/data/index.json +1930 -0
- package/data/reference/mrt-components.md +183 -0
- package/data/reference/mrt-hooks.md +125 -0
- package/data/skills/README.md +81 -0
- package/data/skills/composable-components/SKILL.md +189 -0
- package/data/skills/customization/SKILL.md +190 -0
- package/data/skills/drag-and-drop-ordering/SKILL.md +227 -0
- package/data/skills/editing/SKILL.md +243 -0
- package/data/skills/filtering/SKILL.md +213 -0
- package/data/skills/getting-started/SKILL.md +213 -0
- package/data/skills/localization/SKILL.md +182 -0
- package/data/skills/migrate-v3-to-v4/SKILL.md +161 -0
- package/data/skills/state-and-server-data/SKILL.md +200 -0
- package/data/skills/virtualization/SKILL.md +203 -0
- package/dist/data.js +159 -0
- package/dist/index.js +244 -0
- package/package.json +50 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { MaterialReactTable, type MRT_ColumnDef } from 'material-react-table';
|
|
3
|
+
import { data, type Person } from './makeData';
|
|
4
|
+
|
|
5
|
+
const Example = () => {
|
|
6
|
+
const columns = useMemo<MRT_ColumnDef<Person>[]>(
|
|
7
|
+
//column definitions...
|
|
8
|
+
() => [
|
|
9
|
+
{
|
|
10
|
+
accessorKey: 'id',
|
|
11
|
+
header: 'ID',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
accessorKey: 'firstName',
|
|
15
|
+
header: 'First Name',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
accessorKey: 'middleName',
|
|
19
|
+
header: 'Middle Name',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
accessorKey: 'lastName',
|
|
23
|
+
header: 'Last Name',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
accessorKey: 'age',
|
|
27
|
+
header: 'Age',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
[],
|
|
31
|
+
//end
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<MaterialReactTable
|
|
36
|
+
columns={columns}
|
|
37
|
+
data={data}
|
|
38
|
+
enableGlobalFilterModes
|
|
39
|
+
initialState={{
|
|
40
|
+
showGlobalFilter: true,
|
|
41
|
+
}}
|
|
42
|
+
positionGlobalFilter="left"
|
|
43
|
+
muiSearchTextFieldProps={{
|
|
44
|
+
placeholder: `Search ${data.length} rows`,
|
|
45
|
+
sx: { minWidth: '300px' },
|
|
46
|
+
variant: 'outlined',
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default Example;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { MaterialReactTable, useMaterialReactTable, MRT_ExpandAllButton, } from 'material-react-table';
|
|
3
|
+
import { data } from './makeData';
|
|
4
|
+
import { Box, Stack } from '@mui/material';
|
|
5
|
+
const Example = () => {
|
|
6
|
+
const columns = useMemo(
|
|
7
|
+
//column definitions...
|
|
8
|
+
() => [
|
|
9
|
+
{
|
|
10
|
+
header: 'First Name',
|
|
11
|
+
accessorKey: 'firstName',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
header: 'Last Name',
|
|
15
|
+
accessorKey: 'lastName',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
header: 'Age',
|
|
19
|
+
accessorKey: 'age',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
header: 'Gender',
|
|
23
|
+
accessorKey: 'gender',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
header: 'State',
|
|
27
|
+
accessorKey: 'state',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
header: 'Salary',
|
|
31
|
+
accessorKey: 'salary',
|
|
32
|
+
},
|
|
33
|
+
], []);
|
|
34
|
+
const table = useMaterialReactTable({
|
|
35
|
+
columns,
|
|
36
|
+
data,
|
|
37
|
+
displayColumnDefOptions: {
|
|
38
|
+
'mrt-row-expand': {
|
|
39
|
+
Header: () => (<Stack direction="row" sx={{
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
}}>
|
|
42
|
+
<MRT_ExpandAllButton table={table}/>
|
|
43
|
+
<Box>Groups</Box>
|
|
44
|
+
</Stack>),
|
|
45
|
+
GroupedCell: ({ row, table }) => {
|
|
46
|
+
const { grouping } = table.getState();
|
|
47
|
+
return row.getValue(grouping[grouping.length - 1]);
|
|
48
|
+
},
|
|
49
|
+
enableResizing: true,
|
|
50
|
+
muiTableBodyCellProps: ({ row }) => ({
|
|
51
|
+
sx: (theme) => ({
|
|
52
|
+
color: row.depth === 0
|
|
53
|
+
? theme.palette.primary.main
|
|
54
|
+
: row.depth === 1
|
|
55
|
+
? theme.palette.secondary.main
|
|
56
|
+
: undefined,
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
size: 200,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
enableGrouping: true,
|
|
63
|
+
enableColumnResizing: true,
|
|
64
|
+
groupedColumnMode: 'remove',
|
|
65
|
+
initialState: {
|
|
66
|
+
density: 'compact',
|
|
67
|
+
expanded: true, //expand all groups by default
|
|
68
|
+
grouping: ['state', 'gender'], //an array of columns to group by by default (can be multiple)
|
|
69
|
+
pagination: { pageIndex: 0, pageSize: 20 },
|
|
70
|
+
sorting: [{ id: 'state', desc: false }],
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return <MaterialReactTable table={table}/>;
|
|
74
|
+
};
|
|
75
|
+
export default Example;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
MaterialReactTable,
|
|
4
|
+
useMaterialReactTable,
|
|
5
|
+
type MRT_ColumnDef,
|
|
6
|
+
type MRT_Row,
|
|
7
|
+
MRT_ExpandAllButton,
|
|
8
|
+
} from 'material-react-table';
|
|
9
|
+
import { data, type Person } from './makeData';
|
|
10
|
+
import { Box, Stack } from '@mui/material';
|
|
11
|
+
|
|
12
|
+
const Example = () => {
|
|
13
|
+
const columns = useMemo<MRT_ColumnDef<Person>[]>(
|
|
14
|
+
//column definitions...
|
|
15
|
+
() => [
|
|
16
|
+
{
|
|
17
|
+
header: 'First Name',
|
|
18
|
+
accessorKey: 'firstName',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
header: 'Last Name',
|
|
22
|
+
accessorKey: 'lastName',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
header: 'Age',
|
|
26
|
+
accessorKey: 'age',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
header: 'Gender',
|
|
30
|
+
accessorKey: 'gender',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
header: 'State',
|
|
34
|
+
accessorKey: 'state',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
header: 'Salary',
|
|
38
|
+
accessorKey: 'salary',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
[],
|
|
42
|
+
//end
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const table = useMaterialReactTable({
|
|
46
|
+
columns,
|
|
47
|
+
data,
|
|
48
|
+
displayColumnDefOptions: {
|
|
49
|
+
'mrt-row-expand': {
|
|
50
|
+
Header: () => (
|
|
51
|
+
<Stack
|
|
52
|
+
direction="row"
|
|
53
|
+
sx={{
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<MRT_ExpandAllButton table={table} />
|
|
58
|
+
<Box>Groups</Box>
|
|
59
|
+
</Stack>
|
|
60
|
+
),
|
|
61
|
+
GroupedCell: ({ row, table }) => {
|
|
62
|
+
const { grouping } = table.getState();
|
|
63
|
+
return row.getValue(grouping[grouping.length - 1]);
|
|
64
|
+
},
|
|
65
|
+
enableResizing: true,
|
|
66
|
+
muiTableBodyCellProps: ({ row }) => ({
|
|
67
|
+
sx: (theme) => ({
|
|
68
|
+
color:
|
|
69
|
+
row.depth === 0
|
|
70
|
+
? theme.palette.primary.main
|
|
71
|
+
: row.depth === 1
|
|
72
|
+
? theme.palette.secondary.main
|
|
73
|
+
: undefined,
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
size: 200,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
enableGrouping: true,
|
|
80
|
+
enableColumnResizing: true,
|
|
81
|
+
groupedColumnMode: 'remove',
|
|
82
|
+
initialState: {
|
|
83
|
+
density: 'compact',
|
|
84
|
+
expanded: true, //expand all groups by default
|
|
85
|
+
grouping: ['state', 'gender'], //an array of columns to group by by default (can be multiple)
|
|
86
|
+
pagination: { pageIndex: 0, pageSize: 20 },
|
|
87
|
+
sorting: [{ id: 'state', desc: false }],
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return <MaterialReactTable table={table} />;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default Example;
|
|
@@ -0,0 +1,43 @@
|
|
|
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: 'age',
|
|
18
|
+
header: 'Age',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
accessorKey: 'address',
|
|
22
|
+
header: 'Address',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
accessorKey: 'city',
|
|
26
|
+
header: 'City',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
accessorKey: 'state',
|
|
30
|
+
header: 'State',
|
|
31
|
+
},
|
|
32
|
+
], []);
|
|
33
|
+
const table = useMaterialReactTable({
|
|
34
|
+
columns,
|
|
35
|
+
data,
|
|
36
|
+
enableSelectAll: false,
|
|
37
|
+
enableRowSelection: (row) => row.original.age >= 21, //enable row selection conditionally per row
|
|
38
|
+
muiSelectCheckboxProps: { color: 'secondary' },
|
|
39
|
+
positionToolbarAlertBanner: 'head-overlay',
|
|
40
|
+
});
|
|
41
|
+
return <MaterialReactTable table={table}/>;
|
|
42
|
+
};
|
|
43
|
+
export default Example;
|
|
@@ -0,0 +1,54 @@
|
|
|
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: 'age',
|
|
23
|
+
header: 'Age',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
accessorKey: 'address',
|
|
27
|
+
header: 'Address',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
accessorKey: 'city',
|
|
31
|
+
header: 'City',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
accessorKey: 'state',
|
|
35
|
+
header: 'State',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
[],
|
|
39
|
+
//end
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const table = useMaterialReactTable({
|
|
43
|
+
columns,
|
|
44
|
+
data,
|
|
45
|
+
enableSelectAll: false,
|
|
46
|
+
enableRowSelection: (row) => row.original.age >= 21, //enable row selection conditionally per row
|
|
47
|
+
muiSelectCheckboxProps: { color: 'secondary' },
|
|
48
|
+
positionToolbarAlertBanner: 'head-overlay',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return <MaterialReactTable table={table} />;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default Example;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
|
|
3
|
+
import { data } from './makeData';
|
|
4
|
+
import { darken, lighten, useTheme } from '@mui/material';
|
|
5
|
+
const Example = () => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
//light or dark green
|
|
8
|
+
const baseBackgroundColor = theme.palette.mode === 'dark'
|
|
9
|
+
? 'rgba(3, 44, 43, 1)'
|
|
10
|
+
: 'rgba(244, 255, 233, 1)';
|
|
11
|
+
const columns = useMemo(
|
|
12
|
+
//column definitions...
|
|
13
|
+
() => [
|
|
14
|
+
{
|
|
15
|
+
accessorKey: 'id',
|
|
16
|
+
header: 'ID',
|
|
17
|
+
size: 100,
|
|
18
|
+
enableColumnFilter: false,
|
|
19
|
+
},
|
|
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
|
+
{
|
|
38
|
+
accessorKey: 'city',
|
|
39
|
+
header: 'City',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
accessorKey: 'state',
|
|
43
|
+
header: 'State',
|
|
44
|
+
},
|
|
45
|
+
], []);
|
|
46
|
+
const table = useMaterialReactTable({
|
|
47
|
+
columns,
|
|
48
|
+
data,
|
|
49
|
+
enableColumnResizing: true,
|
|
50
|
+
enableRowPinning: true,
|
|
51
|
+
enableRowSelection: true,
|
|
52
|
+
muiTablePaperProps: {
|
|
53
|
+
elevation: 0,
|
|
54
|
+
sx: {
|
|
55
|
+
borderRadius: '0',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
muiTableBodyProps: {
|
|
59
|
+
sx: (theme) => ({
|
|
60
|
+
'& tr:nth-of-type(odd):not([data-selected="true"]):not([data-pinned="true"]) > td': {
|
|
61
|
+
backgroundColor: darken(baseBackgroundColor, 0.1),
|
|
62
|
+
},
|
|
63
|
+
'& tr:nth-of-type(odd):not([data-selected="true"]):not([data-pinned="true"]):hover > td': {
|
|
64
|
+
backgroundColor: darken(baseBackgroundColor, 0.2),
|
|
65
|
+
},
|
|
66
|
+
'& tr:nth-of-type(even):not([data-selected="true"]):not([data-pinned="true"]) > td': {
|
|
67
|
+
backgroundColor: lighten(baseBackgroundColor, 0.1),
|
|
68
|
+
},
|
|
69
|
+
'& tr:nth-of-type(even):not([data-selected="true"]):not([data-pinned="true"]):hover > td': {
|
|
70
|
+
backgroundColor: darken(baseBackgroundColor, 0.2),
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
mrtTheme: (theme) => ({
|
|
75
|
+
baseBackgroundColor: baseBackgroundColor,
|
|
76
|
+
draggingBorderColor: theme.palette.secondary.main,
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
return <MaterialReactTable table={table}/>;
|
|
80
|
+
};
|
|
81
|
+
export default Example;
|
|
@@ -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,26 @@
|
|
|
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: 'id',
|
|
8
|
+
enableColumnActions: false,
|
|
9
|
+
header: 'ID',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
accessorKey: 'firstName',
|
|
13
|
+
header: 'First Name',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
accessorKey: 'lastName',
|
|
17
|
+
header: 'Last Name',
|
|
18
|
+
},
|
|
19
|
+
], []);
|
|
20
|
+
const table = useMaterialReactTable({
|
|
21
|
+
columns,
|
|
22
|
+
data,
|
|
23
|
+
});
|
|
24
|
+
return <MaterialReactTable table={table}/>;
|
|
25
|
+
};
|
|
26
|
+
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,74 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
|
|
3
|
+
const Example = () => {
|
|
4
|
+
const columns = useMemo(() => [
|
|
5
|
+
{
|
|
6
|
+
accessorKey: 'firstName',
|
|
7
|
+
enableHiding: false,
|
|
8
|
+
header: 'First Name',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
accessorKey: 'lastName',
|
|
12
|
+
enableHiding: false,
|
|
13
|
+
header: 'Last Name',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
accessorKey: 'address',
|
|
17
|
+
header: 'Address',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
accessorKey: 'city',
|
|
21
|
+
header: 'City',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
accessorKey: 'state',
|
|
25
|
+
header: 'State',
|
|
26
|
+
},
|
|
27
|
+
], []);
|
|
28
|
+
const data = useMemo(() => [
|
|
29
|
+
//data definitions...
|
|
30
|
+
{
|
|
31
|
+
firstName: 'Dylan',
|
|
32
|
+
lastName: 'Murray',
|
|
33
|
+
address: '261 Erdman Ford',
|
|
34
|
+
city: 'East Daphne',
|
|
35
|
+
state: 'Kentucky',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
firstName: 'Raquel',
|
|
39
|
+
lastName: 'Kohler',
|
|
40
|
+
address: '769 Dominic Grove',
|
|
41
|
+
city: 'Columbus',
|
|
42
|
+
state: 'Ohio',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
firstName: 'Ervin',
|
|
46
|
+
lastName: 'Reinger',
|
|
47
|
+
address: '566 Brakus Inlet',
|
|
48
|
+
city: 'South Linda',
|
|
49
|
+
state: 'West Virginia',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
firstName: 'Brittany',
|
|
53
|
+
lastName: 'McCullough',
|
|
54
|
+
address: '722 Emie Stream',
|
|
55
|
+
city: 'Lincoln',
|
|
56
|
+
state: 'Nebraska',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
firstName: 'Branson',
|
|
60
|
+
lastName: 'Frami',
|
|
61
|
+
address: '32188 Larkin Turnpike',
|
|
62
|
+
city: 'Charleston',
|
|
63
|
+
state: 'South Carolina',
|
|
64
|
+
},
|
|
65
|
+
//end
|
|
66
|
+
], []);
|
|
67
|
+
const table = useMaterialReactTable({
|
|
68
|
+
columns,
|
|
69
|
+
data,
|
|
70
|
+
initialState: { columnVisibility: { address: false } },
|
|
71
|
+
});
|
|
72
|
+
return <MaterialReactTable table={table}/>;
|
|
73
|
+
};
|
|
74
|
+
export default Example;
|