@dooherceg/material-react-table 4.1.2 → 4.1.4
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 +359 -182
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +35 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18114,6 +18114,9 @@ const MaterialReactServerTableInstanceComponent = ({
|
|
|
18114
18114
|
availableExports: hasAvailableExports ? allowedExports : undefined,
|
|
18115
18115
|
loadExport: hasAvailableExports ? loadExport : undefined,
|
|
18116
18116
|
enableNewEntryButton,
|
|
18117
|
+
muiPaginationProps: {
|
|
18118
|
+
rowsPerPageOptions: config.rowsPerPageOptions
|
|
18119
|
+
},
|
|
18117
18120
|
...tableOptionsOverrides,
|
|
18118
18121
|
...handlers
|
|
18119
18122
|
});
|
|
@@ -18121,6 +18124,38 @@ const MaterialReactServerTableInstanceComponent = ({
|
|
|
18121
18124
|
// Lets any code that already has `table` (row actions, deleteRowsFn/editRowFn,
|
|
18122
18125
|
// custom cell renderers, etc.) trigger a manual reload without needing a ref.
|
|
18123
18126
|
table.refetch = refetch;
|
|
18127
|
+
|
|
18128
|
+
// addRow() only inserts the row into the local, page-capped `rows` state
|
|
18129
|
+
// (tableCrudFns.ts) — it never touches the server-driven `rowCount` this
|
|
18130
|
+
// component owns. Without this, pagination controls (Next button, page
|
|
18131
|
+
// count) stay stuck on the pre-add total until the next real fetch. Bump
|
|
18132
|
+
// rowCount here instead of forcing an immediate refetch: the consumer may
|
|
18133
|
+
// never navigate to the next page, so paying for a network round trip up
|
|
18134
|
+
// front isn't worth it — the real page 2 data still comes from an actual
|
|
18135
|
+
// fetch (triggered by fetchTrigger.pagination) once the user clicks Next.
|
|
18136
|
+
const baseAddRow = table.addRow;
|
|
18137
|
+
table.addRow = rowInput => {
|
|
18138
|
+
baseAddRow(rowInput);
|
|
18139
|
+
const addedCount = Array.isArray(rowInput) ? rowInput.length : 1;
|
|
18140
|
+
setRowCount(prev => prev + addedCount);
|
|
18141
|
+
};
|
|
18142
|
+
|
|
18143
|
+
// upsertRow() is the other row-creation entry point consumers actually use
|
|
18144
|
+
// (e.g. a "save" handler shared by both create and edit forms) — it needs
|
|
18145
|
+
// the same rowCount bump as addRow(), but only for rows that are genuinely
|
|
18146
|
+
// new. An upsert whose id already exists locally is an edit, not a growth
|
|
18147
|
+
// of the total row count, so only count ids NOT in the current row model
|
|
18148
|
+
// before delegating to the base handler (which does the real insert/merge).
|
|
18149
|
+
const baseUpsertRow = table.upsertRow;
|
|
18150
|
+
table.upsertRow = rowInput_0 => {
|
|
18151
|
+
const rowsToUpsert = Array.isArray(rowInput_0) ? rowInput_0 : [rowInput_0];
|
|
18152
|
+
const existingRowsById = table.getRowModel().rowsById;
|
|
18153
|
+
const insertedCount = rowsToUpsert.filter(row => !(row.id in existingRowsById)).length;
|
|
18154
|
+
baseUpsertRow(rowInput_0);
|
|
18155
|
+
if (insertedCount > 0) {
|
|
18156
|
+
setRowCount(prev_0 => prev_0 + insertedCount);
|
|
18157
|
+
}
|
|
18158
|
+
};
|
|
18124
18159
|
const fetchData = react.useCallback(async tableInstance => {
|
|
18125
18160
|
setIsLoading(true);
|
|
18126
18161
|
try {
|