@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,120 @@
|
|
|
1
|
+
import { useMemo, useState } 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 {
|
|
9
|
+
FormControl,
|
|
10
|
+
FormControlLabel,
|
|
11
|
+
FormLabel,
|
|
12
|
+
Radio,
|
|
13
|
+
RadioGroup,
|
|
14
|
+
Stack,
|
|
15
|
+
} from '@mui/material';
|
|
16
|
+
|
|
17
|
+
const Example = () => {
|
|
18
|
+
const columns = useMemo<MRT_ColumnDef<Person>[]>(
|
|
19
|
+
//column definitions...
|
|
20
|
+
() => [
|
|
21
|
+
{
|
|
22
|
+
header: 'First Name',
|
|
23
|
+
accessorKey: 'firstName',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
header: 'Last Name',
|
|
27
|
+
accessorKey: 'lastName',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
header: 'Age',
|
|
31
|
+
accessorKey: 'age',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
header: 'Gender',
|
|
35
|
+
accessorKey: 'gender',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
header: 'State',
|
|
39
|
+
accessorKey: 'state',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
header: 'Salary',
|
|
43
|
+
accessorKey: 'salary',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
[],
|
|
47
|
+
//end
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
//demo state
|
|
51
|
+
const [groupedColumnMode, setGroupedColumnMode] = useState<
|
|
52
|
+
false | 'remove' | 'reorder'
|
|
53
|
+
>('reorder'); //default is 'reorder
|
|
54
|
+
|
|
55
|
+
const table = useMaterialReactTable({
|
|
56
|
+
columns,
|
|
57
|
+
data,
|
|
58
|
+
enableGrouping: true,
|
|
59
|
+
groupedColumnMode,
|
|
60
|
+
initialState: {
|
|
61
|
+
expanded: true, //expand all groups by default
|
|
62
|
+
grouping: ['state', 'gender'], //an array of columns to group by by default (can be multiple)
|
|
63
|
+
pagination: { pageIndex: 0, pageSize: 20 },
|
|
64
|
+
},
|
|
65
|
+
muiTableContainerProps: { sx: { maxHeight: '800px' } },
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Stack
|
|
70
|
+
sx={{
|
|
71
|
+
gap: '1rem',
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<DemoRadioGroup
|
|
75
|
+
groupedColumnMode={groupedColumnMode}
|
|
76
|
+
setGroupedColumnMode={setGroupedColumnMode}
|
|
77
|
+
/>
|
|
78
|
+
<MaterialReactTable table={table} />
|
|
79
|
+
</Stack>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default Example;
|
|
84
|
+
|
|
85
|
+
//demo...
|
|
86
|
+
const DemoRadioGroup = ({
|
|
87
|
+
groupedColumnMode,
|
|
88
|
+
setGroupedColumnMode,
|
|
89
|
+
}: {
|
|
90
|
+
groupedColumnMode: false | 'remove' | 'reorder';
|
|
91
|
+
setGroupedColumnMode: (
|
|
92
|
+
groupedColumnMode: false | 'remove' | 'reorder',
|
|
93
|
+
) => void;
|
|
94
|
+
}) => {
|
|
95
|
+
return (
|
|
96
|
+
<FormControl sx={{ margin: 'auto', textAlign: 'center' }}>
|
|
97
|
+
<FormLabel>Grouped Column Mode</FormLabel>
|
|
98
|
+
<RadioGroup
|
|
99
|
+
row
|
|
100
|
+
value={groupedColumnMode}
|
|
101
|
+
onChange={(event) =>
|
|
102
|
+
setGroupedColumnMode(
|
|
103
|
+
event.target.value === 'false'
|
|
104
|
+
? false
|
|
105
|
+
: (event.target.value as any),
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
>
|
|
109
|
+
<FormControlLabel
|
|
110
|
+
control={<Radio />}
|
|
111
|
+
label='"reorder" (default)'
|
|
112
|
+
value="reorder"
|
|
113
|
+
/>
|
|
114
|
+
<FormControlLabel control={<Radio />} label='"remove"' value="remove" />
|
|
115
|
+
<FormControlLabel value={false} control={<Radio />} label="false" />
|
|
116
|
+
</RadioGroup>
|
|
117
|
+
</FormControl>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
//end
|
|
@@ -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
|
+
{
|
|
7
|
+
accessorKey: 'firstName',
|
|
8
|
+
header: 'First Name',
|
|
9
|
+
},
|
|
10
|
+
//column definitions...
|
|
11
|
+
{
|
|
12
|
+
accessorKey: 'lastName',
|
|
13
|
+
header: 'Last Name',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
accessorKey: 'address',
|
|
17
|
+
header: 'Address',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
accessorKey: 'city',
|
|
21
|
+
header: 'City',
|
|
22
|
+
},
|
|
23
|
+
//end
|
|
24
|
+
{
|
|
25
|
+
accessorKey: 'state',
|
|
26
|
+
enableColumnOrdering: false, //disable column ordering for this column,
|
|
27
|
+
header: 'State',
|
|
28
|
+
},
|
|
29
|
+
], []);
|
|
30
|
+
const table = useMaterialReactTable({
|
|
31
|
+
columns,
|
|
32
|
+
data,
|
|
33
|
+
enableColumnOrdering: true,
|
|
34
|
+
});
|
|
35
|
+
return <MaterialReactTable table={table}/>;
|
|
36
|
+
};
|
|
37
|
+
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
|
+
() => [
|
|
12
|
+
{
|
|
13
|
+
accessorKey: 'firstName',
|
|
14
|
+
header: 'First Name',
|
|
15
|
+
},
|
|
16
|
+
//column definitions...
|
|
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
|
+
//end
|
|
30
|
+
{
|
|
31
|
+
accessorKey: 'state',
|
|
32
|
+
enableColumnOrdering: false, //disable column ordering for this column,
|
|
33
|
+
header: 'State',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
[],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const table = useMaterialReactTable({
|
|
40
|
+
columns,
|
|
41
|
+
data,
|
|
42
|
+
enableColumnOrdering: true,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return <MaterialReactTable table={table} />;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default Example;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
|
|
3
|
+
import { data } from './makeData';
|
|
4
|
+
import { MenuItem } from '@mui/material';
|
|
5
|
+
const Example = () => {
|
|
6
|
+
const columns = useMemo(() => [
|
|
7
|
+
{
|
|
8
|
+
accessorKey: 'id',
|
|
9
|
+
enableColumnPinning: false, //disable column pinning for this column
|
|
10
|
+
header: 'ID',
|
|
11
|
+
size: 50,
|
|
12
|
+
},
|
|
13
|
+
//column definitions...
|
|
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
|
+
accessorKey: 'address',
|
|
28
|
+
header: 'Address',
|
|
29
|
+
size: 300,
|
|
30
|
+
},
|
|
31
|
+
//end
|
|
32
|
+
{
|
|
33
|
+
accessorKey: 'city', //this column gets pinned to the right by default because of the initial state,
|
|
34
|
+
header: 'City',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
accessorKey: 'state', //this column gets pinned left by default because of the the initial state,
|
|
38
|
+
header: 'State',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
accessorKey: 'country',
|
|
42
|
+
header: 'Country',
|
|
43
|
+
},
|
|
44
|
+
], []);
|
|
45
|
+
const table = useMaterialReactTable({
|
|
46
|
+
columns,
|
|
47
|
+
data,
|
|
48
|
+
enableColumnPinning: true,
|
|
49
|
+
enableRowActions: true,
|
|
50
|
+
layoutMode: 'grid-no-grow', //constant column widths
|
|
51
|
+
renderRowActionMenuItems: () => [<MenuItem key="action">Action</MenuItem>],
|
|
52
|
+
initialState: {
|
|
53
|
+
columnPinning: { end: ['city'], start: ['mrt-row-actions', 'state'] },
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return <MaterialReactTable table={table}/>;
|
|
57
|
+
};
|
|
58
|
+
export default Example;
|
|
@@ -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,45 @@
|
|
|
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', //uses the default width from defaultColumn prop
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
accessorKey: 'lastName',
|
|
12
|
+
header: 'Last Name',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
accessorKey: 'email',
|
|
16
|
+
header: 'Email Address',
|
|
17
|
+
size: 250, //increase the width of this column
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
accessorKey: 'city',
|
|
21
|
+
header: 'City',
|
|
22
|
+
size: 200, //decrease the width of this column
|
|
23
|
+
enableResizing: false, //disable resizing for this column
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
accessorKey: 'country',
|
|
27
|
+
header: 'Country',
|
|
28
|
+
size: 140, //decrease the width of this column
|
|
29
|
+
},
|
|
30
|
+
], []);
|
|
31
|
+
const table = useMaterialReactTable({
|
|
32
|
+
columns,
|
|
33
|
+
data,
|
|
34
|
+
//optionally override the default column widths
|
|
35
|
+
defaultColumn: {
|
|
36
|
+
maxSize: 400,
|
|
37
|
+
minSize: 80,
|
|
38
|
+
size: 160, //default size is usually 180
|
|
39
|
+
},
|
|
40
|
+
enableColumnResizing: true,
|
|
41
|
+
columnResizeMode: 'onChange', //default
|
|
42
|
+
});
|
|
43
|
+
return <MaterialReactTable table={table}/>;
|
|
44
|
+
};
|
|
45
|
+
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,19 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { MaterialReactTable, useMaterialReactTable, } from 'material-react-table';
|
|
3
|
+
import { fakeColumns, fakeData } from './makeData';
|
|
4
|
+
const Example = () => {
|
|
5
|
+
//optionally access the underlying virtualizer instance
|
|
6
|
+
const columnVirtualizerInstanceRef = useRef(null);
|
|
7
|
+
const table = useMaterialReactTable({
|
|
8
|
+
columnVirtualizerInstanceRef, //optional
|
|
9
|
+
columnVirtualizerOptions: { overscan: 4 }, //optionally customize the virtualizer
|
|
10
|
+
columns: fakeColumns, //500 columns
|
|
11
|
+
data: fakeData,
|
|
12
|
+
enableColumnPinning: true,
|
|
13
|
+
enableColumnResizing: true,
|
|
14
|
+
enableColumnVirtualization: true,
|
|
15
|
+
enableRowNumbers: true,
|
|
16
|
+
});
|
|
17
|
+
return <MaterialReactTable table={table}/>;
|
|
18
|
+
};
|
|
19
|
+
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,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,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,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;
|