@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.
- package/README.md +234 -234
- package/locales/ja/index.d.mts +0 -3
- package/locales/ja/index.d.ts +0 -3
- package/locales/ja/package.json +0 -6
- package/package.json +147 -147
- package/skills/README.md +81 -81
- package/skills/composable-components/SKILL.md +189 -189
- package/skills/customization/SKILL.md +190 -190
- package/skills/drag-and-drop-ordering/SKILL.md +227 -227
- package/skills/editing/SKILL.md +243 -243
- package/skills/filtering/SKILL.md +213 -213
- package/skills/getting-started/SKILL.md +213 -213
- package/skills/localization/SKILL.md +182 -182
- package/skills/migrate-v3-to-v4/SKILL.md +161 -161
- package/skills/state-and-server-data/SKILL.md +200 -200
- package/skills/virtualization/SKILL.md +203 -203
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: customization
|
|
3
|
-
description: >
|
|
4
|
-
Style and extend Material React Table V4 through mui*Props objects and callbacks, the sx prop, Material UI V9 slotProps on text fields, render* slots for toolbars, row actions, detail panels and empty states, displayColumnDefOptions, icons, and localization. Load for theming, conditional row or cell styling, custom toolbar buttons, or replacing built-in display columns.
|
|
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/guides/customize-components.mdx'
|
|
14
|
-
- 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/display-columns.mdx'
|
|
15
|
-
- 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/toolbar-customization.mdx'
|
|
16
|
-
- 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/row-actions.mdx'
|
|
17
|
-
- 'lminii/material-react-table:MIGRATION.md'
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
This skill builds on `getting-started`. MRT renders Material UI components and forwards props to each of them through a matching `mui<Component>Props` option, so customization means passing Material UI props, not overriding MRT internals.
|
|
21
|
-
|
|
22
|
-
## Setup
|
|
23
|
-
|
|
24
|
-
```tsx
|
|
25
|
-
const table = useMaterialReactTable({
|
|
26
|
-
columns,
|
|
27
|
-
data,
|
|
28
|
-
muiTablePaperProps: { elevation: 0, sx: { borderRadius: 0 } },
|
|
29
|
-
muiTableBodyRowProps: ({ row }) => ({
|
|
30
|
-
sx: { backgroundColor: row.getIsSelected() ? 'action.selected' : undefined },
|
|
31
|
-
}),
|
|
32
|
-
muiTableBodyCellProps: ({ column }) => ({
|
|
33
|
-
align: column.id === 'amount' ? 'right' : 'left',
|
|
34
|
-
}),
|
|
35
|
-
})
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Every `mui*Props` option accepts a static object or a callback. The callback receives `table` plus whatever is in scope for that component: `row`, `cell`, `column`, `staticRowIndex`, `isDetailPanel`, and similar. Static objects are cheaper; use a callback only when the props depend on data.
|
|
39
|
-
|
|
40
|
-
## Core Patterns
|
|
41
|
-
|
|
42
|
-
### Text field options use Material UI V9 slotProps
|
|
43
|
-
|
|
44
|
-
```tsx
|
|
45
|
-
muiSearchTextFieldProps: {
|
|
46
|
-
placeholder: 'Search people',
|
|
47
|
-
slotProps: {
|
|
48
|
-
input: { startAdornment: <SearchIcon /> },
|
|
49
|
-
htmlInput: { 'aria-label': 'Search people' },
|
|
50
|
-
inputLabel: { shrink: true },
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
`muiEditTextFieldProps`, `muiFilterTextFieldProps`, and `muiSearchTextFieldProps` take `slotProps.input`, `slotProps.htmlInput`, `slotProps.select`, and `slotProps.inputLabel`. MRT merges the object form of each slot after its own defaults and composes `sx`. The function form `(ownerState) => props` is ignored.
|
|
56
|
-
|
|
57
|
-
### Column-level props override table-level props
|
|
58
|
-
|
|
59
|
-
```tsx
|
|
60
|
-
const columns: MRT_ColumnDef<Person>[] = [
|
|
61
|
-
{
|
|
62
|
-
accessorKey: 'salary',
|
|
63
|
-
header: 'Salary',
|
|
64
|
-
muiTableHeadCellProps: { align: 'right' },
|
|
65
|
-
muiTableBodyCellProps: { align: 'right' },
|
|
66
|
-
Cell: ({ cell }) => cell.getValue<number>().toLocaleString('en-US', { style: 'currency', currency: 'USD' }),
|
|
67
|
-
},
|
|
68
|
-
]
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
`muiTableHeadCellProps`, `muiTableBodyCellProps`, `muiTableFooterCellProps`, `muiFilter*Props`, `muiEditTextFieldProps`, `muiCopyButtonProps`, and `muiColumnActionsButtonProps` exist on both the table options and the column definition. The column value wins.
|
|
72
|
-
|
|
73
|
-
### render* slots add UI without replacing MRT components
|
|
74
|
-
|
|
75
|
-
```tsx
|
|
76
|
-
const table = useMaterialReactTable({
|
|
77
|
-
columns,
|
|
78
|
-
data,
|
|
79
|
-
enableRowActions: true,
|
|
80
|
-
positionActionsColumn: 'last',
|
|
81
|
-
renderRowActionMenuItems: ({ row, closeMenu }) => [
|
|
82
|
-
<MenuItem key="edit" onClick={() => { edit(row.original); closeMenu() }}>Edit</MenuItem>,
|
|
83
|
-
],
|
|
84
|
-
renderTopToolbarCustomActions: ({ table }) => (
|
|
85
|
-
<Button onClick={() => exportRows(table.getPrePaginatedRowModel().rows)}>Export</Button>
|
|
86
|
-
),
|
|
87
|
-
renderDetailPanel: ({ row }) => <Address address={row.original.address} />,
|
|
88
|
-
renderEmptyRowsFallback: () => <Typography>No people match these filters</Typography>,
|
|
89
|
-
})
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
`renderTopToolbar` and `renderBottomToolbar` replace the whole toolbar; `renderTopToolbarCustomActions`, `renderBottomToolbarCustomActions`, and `renderToolbarInternalActions` add to it. `renderRowActions` renders inline buttons; `renderRowActionMenuItems` fills the kebab menu. `renderDetailPanel` also makes every row expandable.
|
|
93
|
-
|
|
94
|
-
### Adjust built-in display columns
|
|
95
|
-
|
|
96
|
-
```tsx
|
|
97
|
-
displayColumnDefOptions: {
|
|
98
|
-
'mrt-row-actions': { header: '', size: 80, muiTableHeadCellProps: { align: 'center' } },
|
|
99
|
-
'mrt-row-select': { enableColumnActions: false },
|
|
100
|
-
'mrt-row-expand': { size: 40 },
|
|
101
|
-
},
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Display column ids are `mrt-row-actions`, `mrt-row-drag`, `mrt-row-expand`, `mrt-row-numbers`, `mrt-row-pin`, `mrt-row-select`, and `mrt-row-spacer`. They exist only when the matching feature is enabled.
|
|
105
|
-
|
|
106
|
-
### Icons and localization
|
|
107
|
-
|
|
108
|
-
```tsx
|
|
109
|
-
import { MRT_Localization_DE } from '@lminii/material-react-table/locales/de'
|
|
110
|
-
|
|
111
|
-
const table = useMaterialReactTable({
|
|
112
|
-
columns,
|
|
113
|
-
data,
|
|
114
|
-
localization: MRT_Localization_DE,
|
|
115
|
-
icons: { SearchIcon: (props) => <TravelExploreIcon {...props} /> },
|
|
116
|
-
})
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
`icons` accepts a partial `MRT_Icons` map; `localization` accepts a partial `MRT_Localization`, so overriding a few strings is fine.
|
|
120
|
-
|
|
121
|
-
## Common Mistakes
|
|
122
|
-
|
|
123
|
-
### HIGH Passing removed Material UI text field props
|
|
124
|
-
|
|
125
|
-
Wrong:
|
|
126
|
-
|
|
127
|
-
```tsx
|
|
128
|
-
muiSearchTextFieldProps: {
|
|
129
|
-
InputProps: { startAdornment: <SearchIcon /> },
|
|
130
|
-
inputProps: { 'aria-label': 'Search' },
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
Correct:
|
|
135
|
-
|
|
136
|
-
```tsx
|
|
137
|
-
muiSearchTextFieldProps: {
|
|
138
|
-
slotProps: {
|
|
139
|
-
input: { startAdornment: <SearchIcon /> },
|
|
140
|
-
htmlInput: { 'aria-label': 'Search' },
|
|
141
|
-
},
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Material UI V9 removed `InputProps`, `inputProps`, `SelectProps`, `InputLabelProps`, and `FormHelperTextProps` from `TextField`, so the old keys are type errors and are never applied.
|
|
146
|
-
|
|
147
|
-
Source: `MIGRATION.md`
|
|
148
|
-
|
|
149
|
-
### MEDIUM Styling with a class selector instead of the sx prop
|
|
150
|
-
|
|
151
|
-
Wrong:
|
|
152
|
-
|
|
153
|
-
```tsx
|
|
154
|
-
muiTableBodyCellProps: { className: 'my-cell' }
|
|
155
|
-
// plus a global .my-cell rule fighting Material UI specificity
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Correct:
|
|
159
|
-
|
|
160
|
-
```tsx
|
|
161
|
-
muiTableBodyCellProps: {
|
|
162
|
-
sx: (theme) => ({ borderRight: `1px solid ${theme.palette.divider}` }),
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
`sx` receives the Material UI theme and wins the specificity contest with Emotion styles that MRT already applies.
|
|
167
|
-
|
|
168
|
-
Source: `docs/guides/customize-components.mdx`
|
|
169
|
-
|
|
170
|
-
### MEDIUM Replacing the toolbar when only a button was needed
|
|
171
|
-
|
|
172
|
-
Wrong:
|
|
173
|
-
|
|
174
|
-
```tsx
|
|
175
|
-
renderTopToolbar: ({ table }) => <Button onClick={add}>Add</Button>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Correct:
|
|
179
|
-
|
|
180
|
-
```tsx
|
|
181
|
-
renderTopToolbarCustomActions: ({ table }) => <Button onClick={add}>Add</Button>
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
`renderTopToolbar` removes the search box, filter toggle, density and full screen buttons, and the alert banner. The `*CustomActions` slot keeps them.
|
|
185
|
-
|
|
186
|
-
Source: `docs/guides/toolbar-customization.mdx`
|
|
187
|
-
|
|
188
|
-
## API Discovery
|
|
189
|
-
|
|
190
|
-
Search `node_modules/@lminii/material-react-table/dist/index.d.ts` for `mui` to see every prop option and its callback arguments, and for `render` to see every render slot. The Customize Components guide at `/docs/guides/customize-components` lists the options per component, and `/docs/api/column-options` marks which options also exist on columns.
|
|
1
|
+
---
|
|
2
|
+
name: customization
|
|
3
|
+
description: >
|
|
4
|
+
Style and extend Material React Table V4 through mui*Props objects and callbacks, the sx prop, Material UI V9 slotProps on text fields, render* slots for toolbars, row actions, detail panels and empty states, displayColumnDefOptions, icons, and localization. Load for theming, conditional row or cell styling, custom toolbar buttons, or replacing built-in display columns.
|
|
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/guides/customize-components.mdx'
|
|
14
|
+
- 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/display-columns.mdx'
|
|
15
|
+
- 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/toolbar-customization.mdx'
|
|
16
|
+
- 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/row-actions.mdx'
|
|
17
|
+
- 'lminii/material-react-table:MIGRATION.md'
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
This skill builds on `getting-started`. MRT renders Material UI components and forwards props to each of them through a matching `mui<Component>Props` option, so customization means passing Material UI props, not overriding MRT internals.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
const table = useMaterialReactTable({
|
|
26
|
+
columns,
|
|
27
|
+
data,
|
|
28
|
+
muiTablePaperProps: { elevation: 0, sx: { borderRadius: 0 } },
|
|
29
|
+
muiTableBodyRowProps: ({ row }) => ({
|
|
30
|
+
sx: { backgroundColor: row.getIsSelected() ? 'action.selected' : undefined },
|
|
31
|
+
}),
|
|
32
|
+
muiTableBodyCellProps: ({ column }) => ({
|
|
33
|
+
align: column.id === 'amount' ? 'right' : 'left',
|
|
34
|
+
}),
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Every `mui*Props` option accepts a static object or a callback. The callback receives `table` plus whatever is in scope for that component: `row`, `cell`, `column`, `staticRowIndex`, `isDetailPanel`, and similar. Static objects are cheaper; use a callback only when the props depend on data.
|
|
39
|
+
|
|
40
|
+
## Core Patterns
|
|
41
|
+
|
|
42
|
+
### Text field options use Material UI V9 slotProps
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
muiSearchTextFieldProps: {
|
|
46
|
+
placeholder: 'Search people',
|
|
47
|
+
slotProps: {
|
|
48
|
+
input: { startAdornment: <SearchIcon /> },
|
|
49
|
+
htmlInput: { 'aria-label': 'Search people' },
|
|
50
|
+
inputLabel: { shrink: true },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`muiEditTextFieldProps`, `muiFilterTextFieldProps`, and `muiSearchTextFieldProps` take `slotProps.input`, `slotProps.htmlInput`, `slotProps.select`, and `slotProps.inputLabel`. MRT merges the object form of each slot after its own defaults and composes `sx`. The function form `(ownerState) => props` is ignored.
|
|
56
|
+
|
|
57
|
+
### Column-level props override table-level props
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
const columns: MRT_ColumnDef<Person>[] = [
|
|
61
|
+
{
|
|
62
|
+
accessorKey: 'salary',
|
|
63
|
+
header: 'Salary',
|
|
64
|
+
muiTableHeadCellProps: { align: 'right' },
|
|
65
|
+
muiTableBodyCellProps: { align: 'right' },
|
|
66
|
+
Cell: ({ cell }) => cell.getValue<number>().toLocaleString('en-US', { style: 'currency', currency: 'USD' }),
|
|
67
|
+
},
|
|
68
|
+
]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`muiTableHeadCellProps`, `muiTableBodyCellProps`, `muiTableFooterCellProps`, `muiFilter*Props`, `muiEditTextFieldProps`, `muiCopyButtonProps`, and `muiColumnActionsButtonProps` exist on both the table options and the column definition. The column value wins.
|
|
72
|
+
|
|
73
|
+
### render* slots add UI without replacing MRT components
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
const table = useMaterialReactTable({
|
|
77
|
+
columns,
|
|
78
|
+
data,
|
|
79
|
+
enableRowActions: true,
|
|
80
|
+
positionActionsColumn: 'last',
|
|
81
|
+
renderRowActionMenuItems: ({ row, closeMenu }) => [
|
|
82
|
+
<MenuItem key="edit" onClick={() => { edit(row.original); closeMenu() }}>Edit</MenuItem>,
|
|
83
|
+
],
|
|
84
|
+
renderTopToolbarCustomActions: ({ table }) => (
|
|
85
|
+
<Button onClick={() => exportRows(table.getPrePaginatedRowModel().rows)}>Export</Button>
|
|
86
|
+
),
|
|
87
|
+
renderDetailPanel: ({ row }) => <Address address={row.original.address} />,
|
|
88
|
+
renderEmptyRowsFallback: () => <Typography>No people match these filters</Typography>,
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`renderTopToolbar` and `renderBottomToolbar` replace the whole toolbar; `renderTopToolbarCustomActions`, `renderBottomToolbarCustomActions`, and `renderToolbarInternalActions` add to it. `renderRowActions` renders inline buttons; `renderRowActionMenuItems` fills the kebab menu. `renderDetailPanel` also makes every row expandable.
|
|
93
|
+
|
|
94
|
+
### Adjust built-in display columns
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
displayColumnDefOptions: {
|
|
98
|
+
'mrt-row-actions': { header: '', size: 80, muiTableHeadCellProps: { align: 'center' } },
|
|
99
|
+
'mrt-row-select': { enableColumnActions: false },
|
|
100
|
+
'mrt-row-expand': { size: 40 },
|
|
101
|
+
},
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Display column ids are `mrt-row-actions`, `mrt-row-drag`, `mrt-row-expand`, `mrt-row-numbers`, `mrt-row-pin`, `mrt-row-select`, and `mrt-row-spacer`. They exist only when the matching feature is enabled.
|
|
105
|
+
|
|
106
|
+
### Icons and localization
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { MRT_Localization_DE } from '@lminii/material-react-table/locales/de'
|
|
110
|
+
|
|
111
|
+
const table = useMaterialReactTable({
|
|
112
|
+
columns,
|
|
113
|
+
data,
|
|
114
|
+
localization: MRT_Localization_DE,
|
|
115
|
+
icons: { SearchIcon: (props) => <TravelExploreIcon {...props} /> },
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`icons` accepts a partial `MRT_Icons` map; `localization` accepts a partial `MRT_Localization`, so overriding a few strings is fine.
|
|
120
|
+
|
|
121
|
+
## Common Mistakes
|
|
122
|
+
|
|
123
|
+
### HIGH Passing removed Material UI text field props
|
|
124
|
+
|
|
125
|
+
Wrong:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
muiSearchTextFieldProps: {
|
|
129
|
+
InputProps: { startAdornment: <SearchIcon /> },
|
|
130
|
+
inputProps: { 'aria-label': 'Search' },
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Correct:
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
muiSearchTextFieldProps: {
|
|
138
|
+
slotProps: {
|
|
139
|
+
input: { startAdornment: <SearchIcon /> },
|
|
140
|
+
htmlInput: { 'aria-label': 'Search' },
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Material UI V9 removed `InputProps`, `inputProps`, `SelectProps`, `InputLabelProps`, and `FormHelperTextProps` from `TextField`, so the old keys are type errors and are never applied.
|
|
146
|
+
|
|
147
|
+
Source: `MIGRATION.md`
|
|
148
|
+
|
|
149
|
+
### MEDIUM Styling with a class selector instead of the sx prop
|
|
150
|
+
|
|
151
|
+
Wrong:
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
muiTableBodyCellProps: { className: 'my-cell' }
|
|
155
|
+
// plus a global .my-cell rule fighting Material UI specificity
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Correct:
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
muiTableBodyCellProps: {
|
|
162
|
+
sx: (theme) => ({ borderRight: `1px solid ${theme.palette.divider}` }),
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`sx` receives the Material UI theme and wins the specificity contest with Emotion styles that MRT already applies.
|
|
167
|
+
|
|
168
|
+
Source: `docs/guides/customize-components.mdx`
|
|
169
|
+
|
|
170
|
+
### MEDIUM Replacing the toolbar when only a button was needed
|
|
171
|
+
|
|
172
|
+
Wrong:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
renderTopToolbar: ({ table }) => <Button onClick={add}>Add</Button>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Correct:
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
renderTopToolbarCustomActions: ({ table }) => <Button onClick={add}>Add</Button>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`renderTopToolbar` removes the search box, filter toggle, density and full screen buttons, and the alert banner. The `*CustomActions` slot keeps them.
|
|
185
|
+
|
|
186
|
+
Source: `docs/guides/toolbar-customization.mdx`
|
|
187
|
+
|
|
188
|
+
## API Discovery
|
|
189
|
+
|
|
190
|
+
Search `node_modules/@lminii/material-react-table/dist/index.d.ts` for `mui` to see every prop option and its callback arguments, and for `render` to see every render slot. The Customize Components guide at `/docs/guides/customize-components` lists the options per component, and `/docs/api/column-options` marks which options also exist on columns.
|