@lminii/material-react-table 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.
@@ -1,189 +1,189 @@
1
- ---
2
- name: composable-components
3
- description: >
4
- Compose a custom Material React Table V4 layout from exported MRT_* components that all take the same table prop: MRT_TablePaper, MRT_TableContainer, MRT_Table, MRT_TopToolbar, MRT_TablePagination, MRT_GlobalFilterTextField, MRT_ToolbarInternalButtons, MRT_ShowHideColumnsButton, and MRT_TableBodyCellValue for fully custom markup. Load for tables inside cards or dialogs, toolbars placed outside the table, split layouts, or headless rendering with MRT state.
5
- metadata:
6
- type: framework
7
- library: '@lminii/material-react-table'
8
- library_version: '4.0.0'
9
- framework: react
10
- requires:
11
- - getting-started
12
- sources:
13
- - 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/api/mrt-components.mdx'
14
- - 'lminii/material-react-table:apps/material-react-table-docs/examples/custom-headless/sandbox/src/TS.tsx'
15
- - 'lminii/material-react-table:apps/material-react-table-docs/examples/custom-top-toolbar/sandbox/src/TS.tsx'
16
- - 'lminii/material-react-table:apps/material-react-table-docs/examples/external-toolbar/sandbox/src/TS.tsx'
17
- - 'lminii/material-react-table:packages/material-react-table/src/index.ts'
18
- ---
19
-
20
- This skill builds on `getting-started`. `MaterialReactTable` is a thin composition of exported sub-components. Because every sub-component takes the same `table` instance as a prop, you can render any subset of them anywhere in your tree while MRT keeps managing state.
21
-
22
- ## Setup
23
-
24
- ```tsx
25
- import {
26
- MRT_GlobalFilterTextField,
27
- MRT_TableContainer,
28
- MRT_TablePagination,
29
- MRT_ToggleFiltersButton,
30
- useMaterialReactTable,
31
- } from '@lminii/material-react-table'
32
-
33
- const table = useMaterialReactTable({ columns, data, enableBottomToolbar: false })
34
-
35
- return (
36
- <Card>
37
- <CardHeader
38
- title="People"
39
- action={
40
- <Stack direction="row" gap={1}>
41
- <MRT_GlobalFilterTextField table={table} />
42
- <MRT_ToggleFiltersButton table={table} />
43
- </Stack>
44
- }
45
- />
46
- <MRT_TableContainer table={table} />
47
- <CardActions sx={{ justifyContent: 'flex-end' }}>
48
- <MRT_TablePagination table={table} />
49
- </CardActions>
50
- </Card>
51
- )
52
- ```
53
-
54
- `MRT_TableContainer` renders the scroll container, the table, the loading overlay, the edit row modal, and the cell action menu. Turn off the built-in toolbars with `enableTopToolbar` and `enableBottomToolbar` when you place their pieces elsewhere.
55
-
56
- ## Core Patterns
57
-
58
- ### Layers of the default component
59
-
60
- ```text
61
- MRT_TablePaper
62
- MRT_TopToolbar
63
- MRT_GlobalFilterTextField, MRT_ToolbarInternalButtons, MRT_ToolbarAlertBanner, MRT_TablePagination
64
- MRT_TableContainer
65
- MRT_Table
66
- MRT_TableHead > MRT_TableHeadRow > MRT_TableHeadCell
67
- MRT_TableBody > MRT_TableBodyRow > MRT_TableBodyCell, MRT_TableDetailPanel
68
- MRT_TableFooter > MRT_TableFooterRow > MRT_TableFooterCell
69
- MRT_BottomToolbar
70
- ```
71
-
72
- Start from the layer just above what you need to change. Replacing `MRT_TopToolbar` with your own component is the most common cut; replacing `MRT_TableBodyRow` is rarely worth it because `muiTableBodyRowProps` covers styling and events.
73
-
74
- ### Toolbar buttons are individual exports
75
-
76
- ```tsx
77
- import {
78
- MRT_ShowHideColumnsButton,
79
- MRT_ToggleDensePaddingButton,
80
- MRT_ToggleFullScreenButton,
81
- } from '@lminii/material-react-table'
82
-
83
- <MRT_ShowHideColumnsButton table={table} />
84
- <MRT_ToggleDensePaddingButton table={table} />
85
- <MRT_ToggleFullScreenButton table={table} />
86
- ```
87
-
88
- Each button reads and writes MRT state on the shared instance, so it works from any position in the tree.
89
-
90
- ### Fully custom markup with MRT_TableBodyCellValue
91
-
92
- ```tsx
93
- import { MRT_TableBodyCellValue, flexRender } from '@lminii/material-react-table'
94
-
95
- <Table>
96
- <TableHead>
97
- {table.getHeaderGroups().map((group) => (
98
- <TableRow key={group.id}>
99
- {group.headers.map((header) => (
100
- <TableCell key={header.id}>
101
- {header.isPlaceholder ? null : flexRender(header.column.columnDef.Header ?? header.column.columnDef.header, header.getContext())}
102
- </TableCell>
103
- ))}
104
- </TableRow>
105
- ))}
106
- </TableHead>
107
- <TableBody>
108
- {table.getRowModel().rows.map((row, staticRowIndex) => (
109
- <TableRow key={row.id} selected={row.getIsSelected()}>
110
- {row.getVisibleCells().map((cell) => (
111
- <TableCell key={cell.id}>
112
- <MRT_TableBodyCellValue cell={cell} table={table} staticRowIndex={staticRowIndex} />
113
- </TableCell>
114
- ))}
115
- </TableRow>
116
- ))}
117
- </TableBody>
118
- </Table>
119
- ```
120
-
121
- `MRT_TableBodyCellValue` applies the column's `Cell`, `AggregatedCell`, `GroupedCell`, filter match highlighting, and click to copy, so custom markup keeps MRT cell behaviour. `table.getRowModel()` is the final model after filtering, sorting, grouping, expanding, and pagination.
122
-
123
- ### Row virtualization in custom layouts
124
-
125
- Render `MRT_TableContainer` rather than `MRT_Table` when `enableRowVirtualization` or `enableColumnVirtualization` is on. The container owns the scroll element the virtualizers measure.
126
-
127
- ## Common Mistakes
128
-
129
- ### HIGH Rendering MRT components without the table prop
130
-
131
- Wrong:
132
-
133
- ```tsx
134
- <MRT_TablePagination />
135
- ```
136
-
137
- Correct:
138
-
139
- ```tsx
140
- <MRT_TablePagination table={table} />
141
- ```
142
-
143
- MRT does not use React context. Every component requires the instance explicitly.
144
-
145
- Source: `packages/material-react-table/src/components/toolbar/MRT_TablePagination.tsx`
146
-
147
- ### MEDIUM Duplicating the toolbar
148
-
149
- Wrong:
150
-
151
- ```tsx
152
- const table = useMaterialReactTable({ columns, data })
153
- <MRT_GlobalFilterTextField table={table} />
154
- <MaterialReactTable table={table} />
155
- ```
156
-
157
- Correct:
158
-
159
- ```tsx
160
- const table = useMaterialReactTable({ columns, data, enableTopToolbar: false })
161
- <MRT_GlobalFilterTextField table={table} />
162
- <MaterialReactTable table={table} />
163
- ```
164
-
165
- The default top toolbar already contains the search field, so two inputs fight over `globalFilter`.
166
-
167
- Source: `docs/api/mrt-components.mdx`
168
-
169
- ### MEDIUM Using a v8 header render
170
-
171
- Wrong:
172
-
173
- ```tsx
174
- flexRender(header.column.columnDef.header, header.getContext())
175
- ```
176
-
177
- Correct:
178
-
179
- ```tsx
180
- flexRender(header.column.columnDef.Header ?? header.column.columnDef.header, header.getContext())
181
- ```
182
-
183
- MRT columns carry both `header` (string) and `Header` (custom render). Falling back to the string alone drops custom header markup.
184
-
185
- Source: `apps/material-react-table-docs/examples/custom-headless/sandbox/src/TS.tsx`
186
-
187
- ## API Discovery
188
-
189
- `node_modules/@lminii/material-react-table/dist/index.d.ts` exports every `MRT_*` component with its props interface; all of them include `table: MRT_TableInstance<TData>`. The component tree with links to source is at `/docs/api/mrt-components`.
1
+ ---
2
+ name: composable-components
3
+ description: >
4
+ Compose a custom Material React Table V4 layout from exported MRT_* components that all take the same table prop: MRT_TablePaper, MRT_TableContainer, MRT_Table, MRT_TopToolbar, MRT_TablePagination, MRT_GlobalFilterTextField, MRT_ToolbarInternalButtons, MRT_ShowHideColumnsButton, and MRT_TableBodyCellValue for fully custom markup. Load for tables inside cards or dialogs, toolbars placed outside the table, split layouts, or headless rendering with MRT state.
5
+ metadata:
6
+ type: framework
7
+ library: '@lminii/material-react-table'
8
+ library_version: '4.0.0'
9
+ framework: react
10
+ requires:
11
+ - getting-started
12
+ sources:
13
+ - 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/api/mrt-components.mdx'
14
+ - 'lminii/material-react-table:apps/material-react-table-docs/examples/custom-headless/sandbox/src/TS.tsx'
15
+ - 'lminii/material-react-table:apps/material-react-table-docs/examples/custom-top-toolbar/sandbox/src/TS.tsx'
16
+ - 'lminii/material-react-table:apps/material-react-table-docs/examples/external-toolbar/sandbox/src/TS.tsx'
17
+ - 'lminii/material-react-table:packages/material-react-table/src/index.ts'
18
+ ---
19
+
20
+ This skill builds on `getting-started`. `MaterialReactTable` is a thin composition of exported sub-components. Because every sub-component takes the same `table` instance as a prop, you can render any subset of them anywhere in your tree while MRT keeps managing state.
21
+
22
+ ## Setup
23
+
24
+ ```tsx
25
+ import {
26
+ MRT_GlobalFilterTextField,
27
+ MRT_TableContainer,
28
+ MRT_TablePagination,
29
+ MRT_ToggleFiltersButton,
30
+ useMaterialReactTable,
31
+ } from '@lminii/material-react-table'
32
+
33
+ const table = useMaterialReactTable({ columns, data, enableBottomToolbar: false })
34
+
35
+ return (
36
+ <Card>
37
+ <CardHeader
38
+ title="People"
39
+ action={
40
+ <Stack direction="row" gap={1}>
41
+ <MRT_GlobalFilterTextField table={table} />
42
+ <MRT_ToggleFiltersButton table={table} />
43
+ </Stack>
44
+ }
45
+ />
46
+ <MRT_TableContainer table={table} />
47
+ <CardActions sx={{ justifyContent: 'flex-end' }}>
48
+ <MRT_TablePagination table={table} />
49
+ </CardActions>
50
+ </Card>
51
+ )
52
+ ```
53
+
54
+ `MRT_TableContainer` renders the scroll container, the table, the loading overlay, the edit row modal, and the cell action menu. Turn off the built-in toolbars with `enableTopToolbar` and `enableBottomToolbar` when you place their pieces elsewhere.
55
+
56
+ ## Core Patterns
57
+
58
+ ### Layers of the default component
59
+
60
+ ```text
61
+ MRT_TablePaper
62
+ MRT_TopToolbar
63
+ MRT_GlobalFilterTextField, MRT_ToolbarInternalButtons, MRT_ToolbarAlertBanner, MRT_TablePagination
64
+ MRT_TableContainer
65
+ MRT_Table
66
+ MRT_TableHead > MRT_TableHeadRow > MRT_TableHeadCell
67
+ MRT_TableBody > MRT_TableBodyRow > MRT_TableBodyCell, MRT_TableDetailPanel
68
+ MRT_TableFooter > MRT_TableFooterRow > MRT_TableFooterCell
69
+ MRT_BottomToolbar
70
+ ```
71
+
72
+ Start from the layer just above what you need to change. Replacing `MRT_TopToolbar` with your own component is the most common cut; replacing `MRT_TableBodyRow` is rarely worth it because `muiTableBodyRowProps` covers styling and events.
73
+
74
+ ### Toolbar buttons are individual exports
75
+
76
+ ```tsx
77
+ import {
78
+ MRT_ShowHideColumnsButton,
79
+ MRT_ToggleDensePaddingButton,
80
+ MRT_ToggleFullScreenButton,
81
+ } from '@lminii/material-react-table'
82
+
83
+ <MRT_ShowHideColumnsButton table={table} />
84
+ <MRT_ToggleDensePaddingButton table={table} />
85
+ <MRT_ToggleFullScreenButton table={table} />
86
+ ```
87
+
88
+ Each button reads and writes MRT state on the shared instance, so it works from any position in the tree.
89
+
90
+ ### Fully custom markup with MRT_TableBodyCellValue
91
+
92
+ ```tsx
93
+ import { MRT_TableBodyCellValue, flexRender } from '@lminii/material-react-table'
94
+
95
+ <Table>
96
+ <TableHead>
97
+ {table.getHeaderGroups().map((group) => (
98
+ <TableRow key={group.id}>
99
+ {group.headers.map((header) => (
100
+ <TableCell key={header.id}>
101
+ {header.isPlaceholder ? null : flexRender(header.column.columnDef.Header ?? header.column.columnDef.header, header.getContext())}
102
+ </TableCell>
103
+ ))}
104
+ </TableRow>
105
+ ))}
106
+ </TableHead>
107
+ <TableBody>
108
+ {table.getRowModel().rows.map((row, staticRowIndex) => (
109
+ <TableRow key={row.id} selected={row.getIsSelected()}>
110
+ {row.getVisibleCells().map((cell) => (
111
+ <TableCell key={cell.id}>
112
+ <MRT_TableBodyCellValue cell={cell} table={table} staticRowIndex={staticRowIndex} />
113
+ </TableCell>
114
+ ))}
115
+ </TableRow>
116
+ ))}
117
+ </TableBody>
118
+ </Table>
119
+ ```
120
+
121
+ `MRT_TableBodyCellValue` applies the column's `Cell`, `AggregatedCell`, `GroupedCell`, filter match highlighting, and click to copy, so custom markup keeps MRT cell behaviour. `table.getRowModel()` is the final model after filtering, sorting, grouping, expanding, and pagination.
122
+
123
+ ### Row virtualization in custom layouts
124
+
125
+ Render `MRT_TableContainer` rather than `MRT_Table` when `enableRowVirtualization` or `enableColumnVirtualization` is on. The container owns the scroll element the virtualizers measure.
126
+
127
+ ## Common Mistakes
128
+
129
+ ### HIGH Rendering MRT components without the table prop
130
+
131
+ Wrong:
132
+
133
+ ```tsx
134
+ <MRT_TablePagination />
135
+ ```
136
+
137
+ Correct:
138
+
139
+ ```tsx
140
+ <MRT_TablePagination table={table} />
141
+ ```
142
+
143
+ MRT does not use React context. Every component requires the instance explicitly.
144
+
145
+ Source: `packages/material-react-table/src/components/toolbar/MRT_TablePagination.tsx`
146
+
147
+ ### MEDIUM Duplicating the toolbar
148
+
149
+ Wrong:
150
+
151
+ ```tsx
152
+ const table = useMaterialReactTable({ columns, data })
153
+ <MRT_GlobalFilterTextField table={table} />
154
+ <MaterialReactTable table={table} />
155
+ ```
156
+
157
+ Correct:
158
+
159
+ ```tsx
160
+ const table = useMaterialReactTable({ columns, data, enableTopToolbar: false })
161
+ <MRT_GlobalFilterTextField table={table} />
162
+ <MaterialReactTable table={table} />
163
+ ```
164
+
165
+ The default top toolbar already contains the search field, so two inputs fight over `globalFilter`.
166
+
167
+ Source: `docs/api/mrt-components.mdx`
168
+
169
+ ### MEDIUM Using a v8 header render
170
+
171
+ Wrong:
172
+
173
+ ```tsx
174
+ flexRender(header.column.columnDef.header, header.getContext())
175
+ ```
176
+
177
+ Correct:
178
+
179
+ ```tsx
180
+ flexRender(header.column.columnDef.Header ?? header.column.columnDef.header, header.getContext())
181
+ ```
182
+
183
+ MRT columns carry both `header` (string) and `Header` (custom render). Falling back to the string alone drops custom header markup.
184
+
185
+ Source: `apps/material-react-table-docs/examples/custom-headless/sandbox/src/TS.tsx`
186
+
187
+ ## API Discovery
188
+
189
+ `node_modules/@lminii/material-react-table/dist/index.d.ts` exports every `MRT_*` component with its props interface; all of them include `table: MRT_TableInstance<TData>`. The component tree with links to source is at `/docs/api/mrt-components`.