@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.
Files changed (284) hide show
  1. package/README.md +68 -0
  2. package/data/MIGRATION.md +136 -0
  3. package/data/api.json +5379 -0
  4. package/data/examples/advanced.js +215 -0
  5. package/data/examples/advanced.tsx +309 -0
  6. package/data/examples/aggregation-and-grouping.js +116 -0
  7. package/data/examples/aggregation-and-grouping.tsx +153 -0
  8. package/data/examples/aggregation-multi.js +89 -0
  9. package/data/examples/aggregation-multi.tsx +105 -0
  10. package/data/examples/alternate-column-filtering.js +38 -0
  11. package/data/examples/alternate-column-filtering.tsx +49 -0
  12. package/data/examples/alternate-detail-panel.js +65 -0
  13. package/data/examples/alternate-detail-panel.tsx +81 -0
  14. package/data/examples/alternate-pagination.js +17 -0
  15. package/data/examples/alternate-pagination.tsx +23 -0
  16. package/data/examples/basic.js +86 -0
  17. package/data/examples/basic.tsx +109 -0
  18. package/data/examples/chart-detail-panel.js +69 -0
  19. package/data/examples/chart-detail-panel.tsx +89 -0
  20. package/data/examples/column-actions-space.js +34 -0
  21. package/data/examples/column-actions-space.tsx +44 -0
  22. package/data/examples/column-alignment.js +58 -0
  23. package/data/examples/column-alignment.tsx +70 -0
  24. package/data/examples/custom-column-actions.js +74 -0
  25. package/data/examples/custom-column-actions.tsx +109 -0
  26. package/data/examples/custom-column-filtering-ui.js +59 -0
  27. package/data/examples/custom-column-filtering-ui.tsx +89 -0
  28. package/data/examples/custom-headless.js +85 -0
  29. package/data/examples/custom-headless.tsx +125 -0
  30. package/data/examples/custom-top-toolbar.js +60 -0
  31. package/data/examples/custom-top-toolbar.tsx +88 -0
  32. package/data/examples/customize-display-columns.js +72 -0
  33. package/data/examples/customize-display-columns.tsx +85 -0
  34. package/data/examples/customize-filter-components.js +78 -0
  35. package/data/examples/customize-filter-components.tsx +101 -0
  36. package/data/examples/customize-filter-modes.js +59 -0
  37. package/data/examples/customize-filter-modes.tsx +73 -0
  38. package/data/examples/customize-filter-variants.js +98 -0
  39. package/data/examples/customize-filter-variants.tsx +116 -0
  40. package/data/examples/customize-global-filter-component.js +37 -0
  41. package/data/examples/customize-global-filter-component.tsx +52 -0
  42. package/data/examples/customize-remove-column-grouping.js +75 -0
  43. package/data/examples/customize-remove-column-grouping.tsx +94 -0
  44. package/data/examples/customize-row-selection.js +43 -0
  45. package/data/examples/customize-row-selection.tsx +54 -0
  46. package/data/examples/customize-table-styles.js +81 -0
  47. package/data/examples/customize-table-styles.tsx +100 -0
  48. package/data/examples/disable-column-actions.js +26 -0
  49. package/data/examples/disable-column-actions.tsx +37 -0
  50. package/data/examples/disable-column-hiding.js +74 -0
  51. package/data/examples/disable-column-hiding.tsx +90 -0
  52. package/data/examples/disable-density-toggle.js +37 -0
  53. package/data/examples/disable-density-toggle.tsx +49 -0
  54. package/data/examples/dynamic-columns.js +124 -0
  55. package/data/examples/dynamic-columns.tsx +189 -0
  56. package/data/examples/editing-crud-cell.js +288 -0
  57. package/data/examples/editing-crud-cell.tsx +377 -0
  58. package/data/examples/editing-crud-modal.js +275 -0
  59. package/data/examples/editing-crud-modal.tsx +370 -0
  60. package/data/examples/editing-crud-row.js +255 -0
  61. package/data/examples/editing-crud-row.tsx +333 -0
  62. package/data/examples/editing-crud-table.js +280 -0
  63. package/data/examples/editing-crud-table.tsx +369 -0
  64. package/data/examples/editing-crud-tree.js +328 -0
  65. package/data/examples/editing-crud-tree.tsx +416 -0
  66. package/data/examples/enable-cell-actions.js +52 -0
  67. package/data/examples/enable-cell-actions.tsx +76 -0
  68. package/data/examples/enable-click-to-copy.js +33 -0
  69. package/data/examples/enable-click-to-copy.tsx +39 -0
  70. package/data/examples/enable-column-grouping.js +69 -0
  71. package/data/examples/enable-column-grouping.tsx +120 -0
  72. package/data/examples/enable-column-ordering.js +37 -0
  73. package/data/examples/enable-column-ordering.tsx +48 -0
  74. package/data/examples/enable-column-pinning.js +58 -0
  75. package/data/examples/enable-column-pinning.tsx +69 -0
  76. package/data/examples/enable-column-resizing.js +45 -0
  77. package/data/examples/enable-column-resizing.tsx +56 -0
  78. package/data/examples/enable-column-virtualization.js +19 -0
  79. package/data/examples/enable-column-virtualization.tsx +27 -0
  80. package/data/examples/enable-detail-panel-conditionally.js +61 -0
  81. package/data/examples/enable-detail-panel-conditionally.tsx +78 -0
  82. package/data/examples/enable-detail-panel-virtualized.js +64 -0
  83. package/data/examples/enable-detail-panel-virtualized.tsx +80 -0
  84. package/data/examples/enable-expanding-tree.js +87 -0
  85. package/data/examples/enable-expanding-tree.tsx +110 -0
  86. package/data/examples/enable-filter-facet-values.js +52 -0
  87. package/data/examples/enable-filter-facet-values.tsx +65 -0
  88. package/data/examples/enable-row-dragging.js +102 -0
  89. package/data/examples/enable-row-dragging.tsx +137 -0
  90. package/data/examples/enable-row-numbers-original.js +37 -0
  91. package/data/examples/enable-row-numbers-original.tsx +48 -0
  92. package/data/examples/enable-row-numbers-static.js +37 -0
  93. package/data/examples/enable-row-numbers-static.tsx +48 -0
  94. package/data/examples/enable-row-ordering.js +40 -0
  95. package/data/examples/enable-row-ordering.tsx +57 -0
  96. package/data/examples/enable-row-pinning-select.js +64 -0
  97. package/data/examples/enable-row-pinning-select.tsx +76 -0
  98. package/data/examples/enable-row-pinning-static.js +39 -0
  99. package/data/examples/enable-row-pinning-static.tsx +50 -0
  100. package/data/examples/enable-row-pinning-sticky.js +57 -0
  101. package/data/examples/enable-row-pinning-sticky.tsx +69 -0
  102. package/data/examples/enable-row-selection.js +71 -0
  103. package/data/examples/enable-row-selection.tsx +96 -0
  104. package/data/examples/enable-row-virtualization.js +85 -0
  105. package/data/examples/enable-row-virtualization.tsx +101 -0
  106. package/data/examples/enable-sticky-header.js +47 -0
  107. package/data/examples/enable-sticky-header.tsx +59 -0
  108. package/data/examples/expanding-tree-expanded.js +98 -0
  109. package/data/examples/expanding-tree-expanded.tsx +121 -0
  110. package/data/examples/expanding-tree-flat-parse.js +102 -0
  111. package/data/examples/expanding-tree-flat-parse.tsx +125 -0
  112. package/data/examples/expanding-tree-root-expanded.js +120 -0
  113. package/data/examples/expanding-tree-root-expanded.tsx +151 -0
  114. package/data/examples/export-to-csv.js +84 -0
  115. package/data/examples/export-to-csv.tsx +114 -0
  116. package/data/examples/export-to-pdf.js +76 -0
  117. package/data/examples/export-to-pdf.tsx +104 -0
  118. package/data/examples/external-toolbar.js +82 -0
  119. package/data/examples/external-toolbar.tsx +108 -0
  120. package/data/examples/font-awesome-icons.js +62 -0
  121. package/data/examples/font-awesome-icons.tsx +106 -0
  122. package/data/examples/infinite-scrolling.js +137 -0
  123. package/data/examples/infinite-scrolling.tsx +208 -0
  124. package/data/examples/lazy-detail-panel.js +164 -0
  125. package/data/examples/lazy-detail-panel.tsx +262 -0
  126. package/data/examples/lazy-sub-rows.js +118 -0
  127. package/data/examples/lazy-sub-rows.tsx +190 -0
  128. package/data/examples/linear-progress.js +48 -0
  129. package/data/examples/linear-progress.tsx +66 -0
  130. package/data/examples/loading.js +34 -0
  131. package/data/examples/loading.tsx +50 -0
  132. package/data/examples/localization-i18n-ar.js +40 -0
  133. package/data/examples/localization-i18n-ar.tsx +65 -0
  134. package/data/examples/localization-i18n-az.js +38 -0
  135. package/data/examples/localization-i18n-az.tsx +60 -0
  136. package/data/examples/localization-i18n-bg.js +38 -0
  137. package/data/examples/localization-i18n-bg.tsx +60 -0
  138. package/data/examples/localization-i18n-cs.js +38 -0
  139. package/data/examples/localization-i18n-cs.tsx +60 -0
  140. package/data/examples/localization-i18n-da.js +38 -0
  141. package/data/examples/localization-i18n-da.tsx +60 -0
  142. package/data/examples/localization-i18n-de.js +38 -0
  143. package/data/examples/localization-i18n-de.tsx +60 -0
  144. package/data/examples/localization-i18n-el.js +38 -0
  145. package/data/examples/localization-i18n-el.tsx +60 -0
  146. package/data/examples/localization-i18n-en.js +38 -0
  147. package/data/examples/localization-i18n-en.tsx +60 -0
  148. package/data/examples/localization-i18n-es.js +38 -0
  149. package/data/examples/localization-i18n-es.tsx +60 -0
  150. package/data/examples/localization-i18n-et.js +38 -0
  151. package/data/examples/localization-i18n-et.tsx +60 -0
  152. package/data/examples/localization-i18n-fa.js +40 -0
  153. package/data/examples/localization-i18n-fa.tsx +66 -0
  154. package/data/examples/localization-i18n-fi.js +38 -0
  155. package/data/examples/localization-i18n-fi.tsx +60 -0
  156. package/data/examples/localization-i18n-fr.js +38 -0
  157. package/data/examples/localization-i18n-fr.tsx +60 -0
  158. package/data/examples/localization-i18n-he.js +40 -0
  159. package/data/examples/localization-i18n-he.tsx +66 -0
  160. package/data/examples/localization-i18n-hr.js +38 -0
  161. package/data/examples/localization-i18n-hr.tsx +60 -0
  162. package/data/examples/localization-i18n-hu.js +38 -0
  163. package/data/examples/localization-i18n-hu.tsx +60 -0
  164. package/data/examples/localization-i18n-hy.js +40 -0
  165. package/data/examples/localization-i18n-hy.tsx +65 -0
  166. package/data/examples/localization-i18n-id.js +38 -0
  167. package/data/examples/localization-i18n-id.tsx +60 -0
  168. package/data/examples/localization-i18n-it.js +38 -0
  169. package/data/examples/localization-i18n-it.tsx +60 -0
  170. package/data/examples/localization-i18n-ja.js +38 -0
  171. package/data/examples/localization-i18n-ja.tsx +60 -0
  172. package/data/examples/localization-i18n-ko.js +38 -0
  173. package/data/examples/localization-i18n-ko.tsx +60 -0
  174. package/data/examples/localization-i18n-nl.js +38 -0
  175. package/data/examples/localization-i18n-nl.tsx +60 -0
  176. package/data/examples/localization-i18n-no.js +38 -0
  177. package/data/examples/localization-i18n-no.tsx +60 -0
  178. package/data/examples/localization-i18n-np.js +38 -0
  179. package/data/examples/localization-i18n-np.tsx +60 -0
  180. package/data/examples/localization-i18n-pl.js +38 -0
  181. package/data/examples/localization-i18n-pl.tsx +60 -0
  182. package/data/examples/localization-i18n-pt-BR.js +38 -0
  183. package/data/examples/localization-i18n-pt-BR.tsx +60 -0
  184. package/data/examples/localization-i18n-pt.js +38 -0
  185. package/data/examples/localization-i18n-pt.tsx +60 -0
  186. package/data/examples/localization-i18n-ro.js +38 -0
  187. package/data/examples/localization-i18n-ro.tsx +60 -0
  188. package/data/examples/localization-i18n-ru.js +38 -0
  189. package/data/examples/localization-i18n-ru.tsx +60 -0
  190. package/data/examples/localization-i18n-sk.js +38 -0
  191. package/data/examples/localization-i18n-sk.tsx +60 -0
  192. package/data/examples/localization-i18n-sr-Cyrl-RS.js +38 -0
  193. package/data/examples/localization-i18n-sr-Cyrl-RS.tsx +60 -0
  194. package/data/examples/localization-i18n-sr-Latn-RS.js +38 -0
  195. package/data/examples/localization-i18n-sr-Latn-RS.tsx +60 -0
  196. package/data/examples/localization-i18n-sv.js +38 -0
  197. package/data/examples/localization-i18n-sv.tsx +60 -0
  198. package/data/examples/localization-i18n-tr.js +38 -0
  199. package/data/examples/localization-i18n-tr.tsx +60 -0
  200. package/data/examples/localization-i18n-uk.js +38 -0
  201. package/data/examples/localization-i18n-uk.tsx +60 -0
  202. package/data/examples/localization-i18n-vi.js +38 -0
  203. package/data/examples/localization-i18n-vi.tsx +60 -0
  204. package/data/examples/localization-i18n-zh-hans.js +38 -0
  205. package/data/examples/localization-i18n-zh-hans.tsx +60 -0
  206. package/data/examples/localization-i18n-zh-hant.js +38 -0
  207. package/data/examples/localization-i18n-zh-hant.tsx +60 -0
  208. package/data/examples/manual-selection.js +81 -0
  209. package/data/examples/manual-selection.tsx +105 -0
  210. package/data/examples/minimal.js +66 -0
  211. package/data/examples/minimal.tsx +78 -0
  212. package/data/examples/mui-theme.js +109 -0
  213. package/data/examples/mui-theme.tsx +136 -0
  214. package/data/examples/multi-sorting.js +48 -0
  215. package/data/examples/multi-sorting.tsx +58 -0
  216. package/data/examples/persistent-state.js +126 -0
  217. package/data/examples/persistent-state.tsx +184 -0
  218. package/data/examples/react-query.js +122 -0
  219. package/data/examples/react-query.tsx +182 -0
  220. package/data/examples/remote.js +113 -0
  221. package/data/examples/remote.tsx +150 -0
  222. package/data/examples/row-actions-buttons.js +54 -0
  223. package/data/examples/row-actions-buttons.tsx +89 -0
  224. package/data/examples/row-actions-menu-items.js +36 -0
  225. package/data/examples/row-actions-menu-items.tsx +64 -0
  226. package/data/examples/single-row-selection.js +74 -0
  227. package/data/examples/single-row-selection.tsx +98 -0
  228. package/data/examples/virtualized.js +122 -0
  229. package/data/examples/virtualized.tsx +138 -0
  230. package/data/guides/accessibility.md +119 -0
  231. package/data/guides/aggregation.md +210 -0
  232. package/data/guides/async-loading.md +132 -0
  233. package/data/guides/best-practices.md +363 -0
  234. package/data/guides/cell-actions.md +139 -0
  235. package/data/guides/click-to-copy.md +67 -0
  236. package/data/guides/column-actions.md +69 -0
  237. package/data/guides/column-filtering.md +366 -0
  238. package/data/guides/column-grouping.md +192 -0
  239. package/data/guides/column-hiding.md +133 -0
  240. package/data/guides/column-ordering-dnd.md +99 -0
  241. package/data/guides/column-pinning.md +72 -0
  242. package/data/guides/column-resizing.md +157 -0
  243. package/data/guides/column-size.md +162 -0
  244. package/data/guides/customize-components.md +395 -0
  245. package/data/guides/customize-icons.md +35 -0
  246. package/data/guides/data-columns.md +292 -0
  247. package/data/guides/density-toggle.md +46 -0
  248. package/data/guides/detail-panel.md +195 -0
  249. package/data/guides/display-columns.md +135 -0
  250. package/data/guides/editing.md +367 -0
  251. package/data/guides/expanding-sub-rows.md +194 -0
  252. package/data/guides/full-screen-toggle.md +63 -0
  253. package/data/guides/global-filtering.md +237 -0
  254. package/data/guides/localization.md +57 -0
  255. package/data/guides/memoization.md +157 -0
  256. package/data/guides/pagination.md +171 -0
  257. package/data/guides/row-actions.md +116 -0
  258. package/data/guides/row-numbers.md +24 -0
  259. package/data/guides/row-ordering-dnd.md +51 -0
  260. package/data/guides/row-pinning.md +96 -0
  261. package/data/guides/row-selection.md +237 -0
  262. package/data/guides/sorting.md +190 -0
  263. package/data/guides/state-management.md +165 -0
  264. package/data/guides/sticky-header.md +41 -0
  265. package/data/guides/table-event-listeners.md +103 -0
  266. package/data/guides/toolbar-customization.md +251 -0
  267. package/data/guides/virtualization.md +183 -0
  268. package/data/index.json +1930 -0
  269. package/data/reference/mrt-components.md +183 -0
  270. package/data/reference/mrt-hooks.md +125 -0
  271. package/data/skills/README.md +81 -0
  272. package/data/skills/composable-components/SKILL.md +189 -0
  273. package/data/skills/customization/SKILL.md +190 -0
  274. package/data/skills/drag-and-drop-ordering/SKILL.md +227 -0
  275. package/data/skills/editing/SKILL.md +243 -0
  276. package/data/skills/filtering/SKILL.md +213 -0
  277. package/data/skills/getting-started/SKILL.md +213 -0
  278. package/data/skills/localization/SKILL.md +182 -0
  279. package/data/skills/migrate-v3-to-v4/SKILL.md +161 -0
  280. package/data/skills/state-and-server-data/SKILL.md +200 -0
  281. package/data/skills/virtualization/SKILL.md +203 -0
  282. package/dist/data.js +159 -0
  283. package/dist/index.js +244 -0
  284. package/package.json +50 -0
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: migrate-v3-to-v4
3
+ description: >
4
+ Migrate an application from material-react-table V3 to @lminii/material-react-table V4: switch the package and imports, upgrade Material UI and X Date Pickers to V9, move text field props to slotProps, and apply every TanStack Table V9 rename and behaviour change (column pinning start/end, columnResizing, sortFn, getPaginatedRowModel, rowSelection true values, removed getCoreRowModel options and onStateChange). Load for migration plans, implementation, or audits of a V3 codebase.
5
+ metadata:
6
+ type: lifecycle
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:MIGRATION.md'
14
+ - 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/getting-started/migrating-to-v4.mdx'
15
+ - 'lminii/material-react-table:packages/material-react-table/src/types.ts'
16
+ - 'lminii/material-react-table:packages/material-react-table/src/hooks/useMRT_TableOptions.ts'
17
+ ---
18
+
19
+ This skill builds on `getting-started`. V4 keeps the V3 API: `useMaterialReactTable`, the `table` prop, every `mui*Props`, `render*`, and `enable*` option. Breaking changes come from three sources only: the package rename, Material UI V9, and TanStack Table V9. Do them in that order.
20
+
21
+ ## Setup
22
+
23
+ ```bash
24
+ npx @mui/codemod@latest v9.0.0/system-props src
25
+ npx @mui/codemod@latest deprecations/all src
26
+ npm uninstall material-react-table
27
+ npm install @lminii/material-react-table @mui/material@^9 @mui/icons-material@^9 @mui/x-date-pickers@^9
28
+ ```
29
+
30
+ Then rewrite imports:
31
+
32
+ ```diff
33
+ -import { MaterialReactTable } from 'material-react-table';
34
+ -import { MRT_Localization_DE } from 'material-react-table/locales/de';
35
+ +import { MaterialReactTable } from '@lminii/material-react-table';
36
+ +import { MRT_Localization_DE } from '@lminii/material-react-table/locales/de';
37
+ ```
38
+
39
+ Peer floors are `@mui/material`, `@mui/icons-material`, and `@mui/x-date-pickers` at 9.0 or newer; React 18 and Emotion 11.13 are unchanged. Node 22.12 or newer is required for the CommonJS build.
40
+
41
+ ## Core Patterns
42
+
43
+ ### Renames from TanStack Table V9
44
+
45
+ Each of these is a find and replace across the codebase:
46
+
47
+ | V3 | V4 |
48
+ | --- | --- |
49
+ | `columnPinning: { left, right }` | `columnPinning: { start, end }` |
50
+ | `column.pin('left')`, `getIsPinned() === 'left'` | `column.pin('start')`, `getIsPinned() === 'start'` |
51
+ | `table.getLeftLeafColumns()`, `getRight*`, `row.getLeftVisibleCells()` | `getStartLeafColumns()`, `getEnd*`, `row.getStartVisibleCells()` |
52
+ | `columnSizingInfo`, `onColumnSizingInfoChange`, `setColumnSizingInfo` | `columnResizing`, `onColumnResizingChange`, `setColumnResizing` |
53
+ | `sortingFn`, `sortingFns`, `column.getSortingFn()` | `sortFn`, `sortFns`, `column.getSortFn()` |
54
+ | `table.getPrePaginationRowModel()`, `getPaginationRowModel()` | `getPrePaginatedRowModel()`, `getPaginatedRowModel()` |
55
+ | `column.getAggregationFn()` | `column.getAggregationFns()` |
56
+ | `MRT_SortingFn`, `MRT_ColumnSizingInfoState` | `MRT_SortFn`, `MRT_ColumnResizingState` (old names remain as deprecated aliases) |
57
+
58
+ ### Behaviour changes to audit
59
+
60
+ - `rowSelection` values are `true`, never `false`. Deselect by deleting the key.
61
+ - `rowPinning` needs both `top` and `bottom`; `columnPinning` needs both `start` and `end` when passed through `initialState` or `state`.
62
+ - `table.getIsSomeRowsSelected()` is `true` when all rows are selected. Indeterminate is `getIsSomeRowsSelected() && !getIsAllRowsSelected()`.
63
+ - A custom `aggregationFn` is `{ aggregate: (context) => value }`, not a callable. Built-in names still work.
64
+ - `getCoreRowModel`, `getFilteredRowModel`, `getSortedRowModel`, `getPaginationRowModel`, `getExpandedRowModel`, `getGroupedRowModel`, and `getFaceted*` options are gone; the models are always registered. Use `manual*` to take over a stage.
65
+ - Rows with `renderDetailPanel` report `row.getCanExpand()` as `true`. Pass `getRowCanExpand` to restrict it.
66
+ - `onStateChange` and `table.setState()` are gone. Control slices individually.
67
+ - `table.getState()` still returns the full state; `table.state` is reactive in render code.
68
+ - Pinned cells use `insetInlineStart` and `insetInlineEnd`, so RTL pins to the logical start and end.
69
+
70
+ ### Material UI V9 changes inside MRT options
71
+
72
+ ```diff
73
+ muiFilterTextFieldProps: {
74
+ - InputProps: { sx: { minWidth: 120 } },
75
+ + slotProps: { input: { sx: { minWidth: 120 } } },
76
+ },
77
+ -const pickerProps: DatePickerProps<Dayjs> = { ... };
78
+ +const pickerProps: DatePickerProps = { ... };
79
+ ```
80
+
81
+ `muiFilterDatePickerProps`, `muiFilterDateTimePickerProps`, and `muiFilterTimePickerProps` are no longer generic, and the filter pickers render `PickersTextField`, so a custom `slots.textField` must accept `PickersTextFieldProps`. Everything else in `mui*Props` passes straight to Material UI, so Material UI's own V7 and V9 notes apply.
82
+
83
+ ### Package entry points
84
+
85
+ The package ships an `exports` map with `.mjs` and `.js` builds. Only `@lminii/material-react-table`, `@lminii/material-react-table/locales/<code>`, and `@lminii/material-react-table/package.json` resolve; deep imports into `dist/` or `src/` fail at build time and must be replaced with root exports.
86
+
87
+ ## Common Mistakes
88
+
89
+ ### HIGH Keeping v8 pinning literals
90
+
91
+ Wrong:
92
+
93
+ ```tsx
94
+ initialState: { columnPinning: { left: ['mrt-row-select'], right: ['mrt-row-actions'] } }
95
+ ```
96
+
97
+ Correct:
98
+
99
+ ```tsx
100
+ initialState: { columnPinning: { start: ['mrt-row-select'], end: ['mrt-row-actions'] } }
101
+ ```
102
+
103
+ `left` and `right` are no longer valid keys, so the pinning state is silently empty.
104
+
105
+ Source: `MIGRATION.md`
106
+
107
+ ### HIGH Passing row model factories
108
+
109
+ Wrong:
110
+
111
+ ```tsx
112
+ useMaterialReactTable({ columns, data, getSortedRowModel: getSortedRowModel() })
113
+ ```
114
+
115
+ Correct:
116
+
117
+ ```tsx
118
+ useMaterialReactTable({ columns, data })
119
+ ```
120
+
121
+ The options no longer exist in `MRT_TableOptions`; MRT registers every row model itself.
122
+
123
+ Source: `packages/material-react-table/src/features/mrtFeatures.ts`
124
+
125
+ ### MEDIUM Treating the migration as a TanStack useTable rewrite
126
+
127
+ Wrong:
128
+
129
+ ```tsx
130
+ const table = useTable({ features: tableFeatures({ rowSortingFeature }), columns, data })
131
+ ```
132
+
133
+ Correct:
134
+
135
+ ```tsx
136
+ const table = useMaterialReactTable({ columns, data })
137
+ ```
138
+
139
+ The `@tanstack/react-table#migrate-v8-to-v9` skill describes migrating a headless table. MRT applications stay on `useMaterialReactTable`; only the renamed instance methods and state shapes from that skill apply.
140
+
141
+ Source: `MIGRATION.md`
142
+
143
+ ### LOW Deep-importing a locale file
144
+
145
+ Wrong:
146
+
147
+ ```tsx
148
+ import { MRT_Localization_FR } from '@lminii/material-react-table/dist/locales/fr'
149
+ ```
150
+
151
+ Correct:
152
+
153
+ ```tsx
154
+ import { MRT_Localization_FR } from '@lminii/material-react-table/locales/fr'
155
+ ```
156
+
157
+ Source: `packages/material-react-table/package.json` exports map
158
+
159
+ ## API Discovery
160
+
161
+ Compare `node_modules/@lminii/material-react-table/dist/index.d.ts` against the V3 declarations for renamed members; the deprecated `MRT_SortingFn` and `MRT_ColumnSizingInfoState` aliases carry JSDoc pointing to the new names. The full guide with tables is at `/docs/getting-started/migrating-to-v4`.
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: state-and-server-data
3
+ description: >
4
+ Control Material React Table V4 state with initialState, the state option plus on*Change callbacks, MRT_Updater handlers, table.getState and table.state, and move filtering, sorting, pagination, grouping, or expanding to the server with manual* options and rowCount. Load for controlled tables, persisted state, side effects on state change, TanStack Query integration, or infinite scrolling.
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
+ - '@tanstack/table-core#client-vs-server'
13
+ sources:
14
+ - 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/state-management.mdx'
15
+ - 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/pagination.mdx'
16
+ - 'lminii/material-react-table:apps/material-react-table-docs/pages/docs/guides/async-loading.mdx'
17
+ - 'lminii/material-react-table:apps/material-react-table-docs/examples/react-query/sandbox/src/TS.tsx'
18
+ - 'lminii/material-react-table:packages/material-react-table/src/types.ts'
19
+ ---
20
+
21
+ This skill builds on `getting-started` and `@tanstack/table-core#client-vs-server`. MRT manages every state slice internally by default. Take over only the slices you need to read or persist, and only through the `state` option paired with the matching `on*Change` callback.
22
+
23
+ ## Setup
24
+
25
+ ```tsx
26
+ const [pagination, setPagination] = useState<MRT_PaginationState>({ pageIndex: 0, pageSize: 25 })
27
+ const [sorting, setSorting] = useState<MRT_SortingState>([])
28
+
29
+ const table = useMaterialReactTable({
30
+ columns,
31
+ data,
32
+ initialState: { density: 'compact', showColumnFilters: true },
33
+ state: { pagination, sorting },
34
+ onPaginationChange: setPagination,
35
+ onSortingChange: setSorting,
36
+ })
37
+ ```
38
+
39
+ `initialState` seeds slices MRT keeps managing. `state` hands a slice over to you; from then on MRT calls `on<Slice>Change` and reads only what you pass back. Do not put the same slice in both.
40
+
41
+ ## Core Patterns
42
+
43
+ ### Handle updaters like React setState
44
+
45
+ ```tsx
46
+ import { type MRT_Updater, type MRT_RowSelectionState } from '@lminii/material-react-table'
47
+
48
+ const handleRowSelectionChange = (updater: MRT_Updater<MRT_RowSelectionState>) => {
49
+ setRowSelection((previous) => {
50
+ const next = updater instanceof Function ? updater(previous) : updater
51
+ onSelectionChanged(Object.keys(next)) // side effect runs once, even in Strict Mode
52
+ return next
53
+ })
54
+ }
55
+ ```
56
+
57
+ Callbacks receive either a value or an updater function, exactly like `useState`. Use `getRowId` so selection keys are stable ids instead of row indexes.
58
+
59
+ ### Server-side data with manual* options
60
+
61
+ ```tsx
62
+ const { data: page, isLoading, isError, isRefetching } = useQuery({
63
+ queryKey: ['people', pagination, sorting, columnFilters, globalFilter],
64
+ queryFn: () => fetchPeople({ pagination, sorting, columnFilters, globalFilter }),
65
+ placeholderData: keepPreviousData,
66
+ })
67
+
68
+ const table = useMaterialReactTable({
69
+ columns,
70
+ data: page?.rows ?? EMPTY,
71
+ rowCount: page?.total ?? 0,
72
+ manualFiltering: true,
73
+ manualPagination: true,
74
+ manualSorting: true,
75
+ state: { pagination, sorting, columnFilters, globalFilter, isLoading, showAlertBanner: isError, showProgressBars: isRefetching },
76
+ onPaginationChange: setPagination,
77
+ onSortingChange: setSorting,
78
+ onColumnFiltersChange: setColumnFilters,
79
+ onGlobalFilterChange: setGlobalFilter,
80
+ muiToolbarAlertBannerProps: isError ? { color: 'error', children: 'Error loading data' } : undefined,
81
+ })
82
+ ```
83
+
84
+ Each `manual*` option tells MRT that stage already happened on the server, so the client row model passes rows through. `rowCount` (or `pageCount`) drives the pagination controls. `isLoading`, `showProgressBars`, `showSkeletons`, and `showLoadingOverlay` are MRT state slices meant to be set from fetch status.
85
+
86
+ ### Read state without controlling it
87
+
88
+ ```tsx
89
+ const table = useMaterialReactTable({ columns, data })
90
+
91
+ <Button onClick={() => save(table.getState().columnVisibility)}>Save layout</Button>
92
+ ```
93
+
94
+ `table.getState()` returns the complete state, including MRT-only slices such as `density`, `isFullScreen`, `showColumnFilters`, `editingRow`, and `creatingRow`. In render code `table.state` is reactive. Setters such as `table.setPagination`, `table.resetSorting`, `table.setShowColumnFilters`, and `table.setDensity` exist for every slice.
95
+
96
+ ### Persist state
97
+
98
+ ```tsx
99
+ const [columnVisibility, setColumnVisibility] = useState<MRT_VisibilityState>(
100
+ () => JSON.parse(localStorage.getItem('people-columns') ?? '{}'),
101
+ )
102
+ useEffect(() => {
103
+ localStorage.setItem('people-columns', JSON.stringify(columnVisibility))
104
+ }, [columnVisibility])
105
+
106
+ const table = useMaterialReactTable({
107
+ columns,
108
+ data,
109
+ state: { columnVisibility },
110
+ onColumnVisibilityChange: setColumnVisibility,
111
+ })
112
+ ```
113
+
114
+ ## Common Mistakes
115
+
116
+ ### HIGH Passing on*Change without state
117
+
118
+ Wrong:
119
+
120
+ ```tsx
121
+ const table = useMaterialReactTable({ columns, data, onSortingChange: setSorting })
122
+ ```
123
+
124
+ Correct:
125
+
126
+ ```tsx
127
+ const table = useMaterialReactTable({
128
+ columns,
129
+ data,
130
+ state: { sorting },
131
+ onSortingChange: setSorting,
132
+ })
133
+ ```
134
+
135
+ Once a callback is supplied, MRT stops updating that slice itself. Without `state`, the table never sorts.
136
+
137
+ Source: `docs/guides/state-management.mdx`
138
+
139
+ ### HIGH Toggling row selection with false
140
+
141
+ Wrong:
142
+
143
+ ```tsx
144
+ setRowSelection((old) => ({ ...old, [id]: false }))
145
+ ```
146
+
147
+ Correct:
148
+
149
+ ```tsx
150
+ setRowSelection(({ [id]: _removed, ...rest }) => rest)
151
+ ```
152
+
153
+ TanStack Table V9 types `rowSelection` as `Record<string, true>`, so a `false` entry is a type error; absence of the key is the only deselected state.
154
+
155
+ Source: `MIGRATION.md`
156
+
157
+ ### MEDIUM Using onStateChange or table.setState
158
+
159
+ Wrong:
160
+
161
+ ```tsx
162
+ onStateChange: (updater) => setTableState(updater)
163
+ ```
164
+
165
+ Correct:
166
+
167
+ ```tsx
168
+ state: { pagination, sorting },
169
+ onPaginationChange: setPagination,
170
+ onSortingChange: setSorting,
171
+ ```
172
+
173
+ `onStateChange` and `table.setState` were removed with TanStack Table V9. Control slices individually.
174
+
175
+ Source: `MIGRATION.md`
176
+
177
+ ### MEDIUM Forgetting rowCount with manualPagination
178
+
179
+ Wrong:
180
+
181
+ ```tsx
182
+ manualPagination: true,
183
+ data: page.rows,
184
+ ```
185
+
186
+ Correct:
187
+
188
+ ```tsx
189
+ manualPagination: true,
190
+ data: page.rows,
191
+ rowCount: page.total,
192
+ ```
193
+
194
+ Without a total, MRT assumes the current page is all the data and disables the next page button.
195
+
196
+ Source: `docs/guides/pagination.mdx`
197
+
198
+ ## API Discovery
199
+
200
+ `MRT_TableState` in `node_modules/@lminii/material-react-table/dist/index.d.ts` lists every slice; each has an `on<Slice>Change` option and `table.set<Slice>` method. The State Options table at `/docs/api/state-options` shows defaults, and the `manual*` and `rowCount` options are in `/docs/api/table-options`.
@@ -0,0 +1,203 @@
1
+ ---
2
+ name: virtualization
3
+ description: >
4
+ Render thousands of rows or hundreds of columns in Material React Table V4 with enableRowVirtualization and enableColumnVirtualization, tune rowVirtualizerOptions and columnVirtualizerOptions (overscan, estimateSize), reach the TanStack Virtual instance through rowVirtualizerInstanceRef for scrollToIndex, and understand the automatic layoutMode grid and sticky header. Load for large unpaginated tables, infinite scroll, scroll-to-row, jumpy scrolling, or headless virtualization with useMRT_RowVirtualizer.
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/virtualization.mdx'
14
+ - 'lminii/material-react-table:apps/material-react-table-docs/examples/enable-row-virtualization/sandbox/src/TS.tsx'
15
+ - 'lminii/material-react-table:packages/material-react-table/src/hooks/useMRT_RowVirtualizer.ts'
16
+ - 'lminii/material-react-table:packages/material-react-table/src/hooks/useMRT_TableOptions.ts'
17
+ - 'lminii/material-react-table:packages/material-react-table/src/types.ts'
18
+ ---
19
+
20
+ This skill builds on `getting-started`. MRT wraps `@tanstack/react-virtual` so only the rows and columns inside the scroll container render. Enable it when a table shows more than about 50 rows without pagination or more than about a dozen columns; below that it adds overhead without benefit.
21
+
22
+ ## Setup
23
+
24
+ ```tsx
25
+ const table = useMaterialReactTable({
26
+ columns,
27
+ data, // 10,000 rows
28
+ enablePagination: false,
29
+ enableRowVirtualization: true,
30
+ enableColumnVirtualization: true, // only with many columns
31
+ muiTableContainerProps: { sx: { maxHeight: '600px' } },
32
+ rowVirtualizerOptions: { overscan: 5 },
33
+ columnVirtualizerOptions: { overscan: 2 },
34
+ })
35
+ ```
36
+
37
+ Row virtualization sets `enableStickyHeader` to true and, unless `layoutMode` was given, switches `layoutMode` to `'grid'`, so the table renders with CSS grid and flexbox instead of semantic table layout. The container needs a bounded height for scrolling; the sticky header default caps it at 100vh, and `muiTableContainerProps.sx.maxHeight` sets a tighter one.
38
+
39
+ ## Core Patterns
40
+
41
+ ### Tune the virtualizer
42
+
43
+ ```tsx
44
+ rowVirtualizerOptions: ({ table }) => ({
45
+ overscan: 10,
46
+ estimateSize: () => (table.getState().density === 'compact' ? 37 : 73),
47
+ }),
48
+ columnVirtualizerOptions: { overscan: 3, estimateSize: () => 200 },
49
+ ```
50
+
51
+ Both options accept an object or a callback receiving `table`, and both are `Partial<VirtualizerOptions>` from TanStack Virtual. MRT already estimates row height from the density (37, 58, or 73 px) and measures rendered rows, sets `overscan: 4`, and keeps a dragging row mounted; anything you pass merges over those defaults. Raise `overscan` if fast scrolling shows blank rows, and set `estimateSize` when rows or columns are far from the defaults so the scrollbar length is accurate.
52
+
53
+ ### Reach the virtualizer instance
54
+
55
+ ```tsx
56
+ const rowVirtualizerInstanceRef = useRef<MRT_RowVirtualizer>(null)
57
+ const [sorting, setSorting] = useState<MRT_SortingState>([])
58
+
59
+ useEffect(() => {
60
+ rowVirtualizerInstanceRef.current?.scrollToIndex?.(0) // back to top when sorting changes
61
+ }, [sorting])
62
+
63
+ const table = useMaterialReactTable({
64
+ columns,
65
+ data,
66
+ enablePagination: false,
67
+ enableRowVirtualization: true,
68
+ rowVirtualizerInstanceRef,
69
+ state: { sorting },
70
+ onSortingChange: setSorting,
71
+ })
72
+ ```
73
+
74
+ `MRT_RowVirtualizer` and `MRT_ColumnVirtualizer` are the TanStack `Virtualizer` plus `virtualRows` or `virtualColumns`, so `scrollToIndex`, `scrollToOffset`, `measure`, and `getVirtualItems` are available. `columnVirtualizerInstanceRef` is the column counterpart.
75
+
76
+ ### Infinite scroll on the container
77
+
78
+ ```tsx
79
+ const tableContainerRef = useRef<HTMLDivElement>(null)
80
+
81
+ const table = useMaterialReactTable({
82
+ columns,
83
+ data: flatRows,
84
+ enablePagination: false,
85
+ enableRowVirtualization: true,
86
+ manualFiltering: true,
87
+ manualSorting: true,
88
+ muiTableContainerProps: {
89
+ ref: tableContainerRef,
90
+ sx: { maxHeight: '600px' },
91
+ onScroll: (event) => {
92
+ const { scrollHeight, scrollTop, clientHeight } = event.currentTarget
93
+ if (scrollHeight - scrollTop - clientHeight < 400 && !isFetching && hasNextPage) fetchNextPage()
94
+ },
95
+ },
96
+ renderBottomToolbarCustomActions: () => <Typography>Fetched {flatRows.length} of {totalRowCount} rows</Typography>,
97
+ state: { isLoading, showProgressBars: isFetching },
98
+ })
99
+ ```
100
+
101
+ Virtualization keeps the DOM small while the fetched array grows. Server-side sorting and filtering options are covered in `state-and-server-data`.
102
+
103
+ ### Headless virtualization
104
+
105
+ ```tsx
106
+ import { useMRT_Rows, useMRT_RowVirtualizer, useMRT_ColumnVirtualizer } from '@lminii/material-react-table'
107
+
108
+ const rows = useMRT_Rows(table)
109
+ const rowVirtualizer = useMRT_RowVirtualizer(table)
110
+ const columnVirtualizer = useMRT_ColumnVirtualizer(table)
111
+
112
+ rowVirtualizer?.virtualRows.map((virtualRow) => {
113
+ const row = rows[virtualRow.index]
114
+ return <MyRow key={row.id} row={row} style={{ transform: `translateY(${virtualRow.start}px)` }} />
115
+ })
116
+ ```
117
+
118
+ The hooks return `undefined` when the matching `enable*Virtualization` option is off. They read the scroll element from `table.refs.tableContainerRef`, so a custom layout must attach that ref to its scroll container.
119
+
120
+ ## Common Mistakes
121
+
122
+ ### HIGH Enabling virtualization conditionally
123
+
124
+ Wrong:
125
+
126
+ ```tsx
127
+ enableRowVirtualization: data.length > 100,
128
+ ```
129
+
130
+ Correct:
131
+
132
+ ```tsx
133
+ enableRowVirtualization: true, // decide once per table, not per render
134
+ ```
135
+
136
+ The virtualizer hooks run only when enabled, so toggling the option at runtime changes the hook order and breaks React's rules of hooks; it also flips `layoutMode`, which re-lays out every cell.
137
+
138
+ Source: `docs/guides/virtualization.mdx`
139
+
140
+ ### HIGH Leaving pagination on
141
+
142
+ Wrong:
143
+
144
+ ```tsx
145
+ enableRowVirtualization: true,
146
+ ```
147
+
148
+ Correct:
149
+
150
+ ```tsx
151
+ enableRowVirtualization: true,
152
+ enablePagination: false,
153
+ ```
154
+
155
+ With pagination on, only one page of rows exists to virtualize, so the table still renders 10 rows and the user pages through 10,000.
156
+
157
+ Source: `docs/guides/virtualization.mdx`
158
+
159
+ ### MEDIUM Expecting semantic table CSS to keep working
160
+
161
+ Wrong:
162
+
163
+ ```tsx
164
+ enableRowVirtualization: true,
165
+ muiTableBodyCellProps: { sx: { width: '20%' } }, // percentage widths ignored in grid layout
166
+ ```
167
+
168
+ Correct:
169
+
170
+ ```tsx
171
+ enableRowVirtualization: true,
172
+ columns: [{ accessorKey: 'email', header: 'Email', size: 300, grow: false }],
173
+ ```
174
+
175
+ Virtualization forces `layoutMode: 'grid'`, where column widths come from `size`, `minSize`, `maxSize`, and `grow`, not from table-layout CSS.
176
+
177
+ Source: `packages/material-react-table/src/hooks/useMRT_TableOptions.ts`
178
+
179
+ ### MEDIUM Detail panels with a fixed row estimate
180
+
181
+ Wrong:
182
+
183
+ ```tsx
184
+ enableRowVirtualization: true,
185
+ renderDetailPanel: ({ row }) => <Details row={row} />,
186
+ rowVirtualizerOptions: { estimateSize: () => 50 },
187
+ ```
188
+
189
+ Correct:
190
+
191
+ ```tsx
192
+ enableRowVirtualization: true,
193
+ renderDetailPanel: ({ row }) => <Details row={row} />,
194
+ // keep MRT's estimate: it counts two virtual items per row and sizes the panel item from the expanded state
195
+ ```
196
+
197
+ With a detail panel MRT virtualizes two items per row (row and panel) and estimates the panel at 0 or 100 px depending on expansion. A flat `estimateSize` breaks the scrollbar and item positions.
198
+
199
+ Source: `packages/material-react-table/src/hooks/useMRT_RowVirtualizer.ts`
200
+
201
+ ## API Discovery
202
+
203
+ Search `node_modules/@lminii/material-react-table/dist/index.d.ts` for `Virtualizer` to find `MRT_RowVirtualizer`, `MRT_ColumnVirtualizer`, `MRT_VirtualizerOptions`, and `MRT_VirtualItem`. The TanStack Virtual docs at `https://tanstack.com/virtual/v3/docs/api/virtualizer` list every option and instance method. The Virtualization guide at `/docs/guides/virtualization` and the examples `/docs/examples/virtualized`, `enable-row-virtualization`, `enable-column-virtualization`, `enable-detail-panel-virtualized`, and `infinite-scrolling` show the patterns above.