@dooherceg/material-react-table 4.1.1 → 4.1.2
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/dist/index.d.ts +8 -1
- package/dist/index.esm.js +25 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -278,6 +278,21 @@ const getDefaultColumnPinningState = (tableOptions, existingColumnPinning = {})
|
|
|
278
278
|
end: existingEnd
|
|
279
279
|
};
|
|
280
280
|
};
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Forces mrt-row-expand to a fixed slot in columnOrder: right after the
|
|
284
|
+
* checkbox column when row selection is enabled, otherwise the very first
|
|
285
|
+
* column. Not configurable — mirrors how getDefaultColumnPinningState
|
|
286
|
+
* forces the checkbox column itself to the front of columnPinning.start.
|
|
287
|
+
*/
|
|
288
|
+
const normalizeRowExpandColumnOrder = (tableOptions, columnOrder) => {
|
|
289
|
+
if (!showRowExpandColumn(tableOptions)) {
|
|
290
|
+
return columnOrder;
|
|
291
|
+
}
|
|
292
|
+
const withoutExpand = columnOrder.filter(id => id !== 'mrt-row-expand');
|
|
293
|
+
const expandIndex = showRowSelectionColumn(tableOptions) ? 1 : 0;
|
|
294
|
+
return [...withoutExpand.slice(0, expandIndex), 'mrt-row-expand', ...withoutExpand.slice(expandIndex)];
|
|
295
|
+
};
|
|
281
296
|
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
|
282
297
|
const {
|
|
283
298
|
state: {
|
|
@@ -4468,7 +4483,7 @@ const useMRT_TableInstance = definedTableOptions => {
|
|
|
4468
4483
|
...definedTableOptions.state
|
|
4469
4484
|
}
|
|
4470
4485
|
};
|
|
4471
|
-
initState.columnOrder = initState.columnOrder ?? getDefaultColumnOrderIds(mergedOptionsSnapshot);
|
|
4486
|
+
initState.columnOrder = normalizeRowExpandColumnOrder(mergedOptionsSnapshot, initState.columnOrder ?? getDefaultColumnOrderIds(mergedOptionsSnapshot));
|
|
4472
4487
|
|
|
4473
4488
|
// Ensure the checkbox column is always the leftmost sticky column when
|
|
4474
4489
|
// row selection is enabled, regardless of what the user pinned initially.
|
|
@@ -4533,6 +4548,14 @@ const useMRT_TableInstance = definedTableOptions => {
|
|
|
4533
4548
|
|
|
4534
4549
|
//The table options now include all state needed to help determine column visibility and order logic
|
|
4535
4550
|
const statefulTableOptions = definedTableOptions;
|
|
4551
|
+
|
|
4552
|
+
// Keep mrt-row-expand locked to its slot (right after the checkbox, or
|
|
4553
|
+
// first if there's no checkbox) regardless of what columnOrder the
|
|
4554
|
+
// consumer passes in — same enforcement model as columnPinning above.
|
|
4555
|
+
statefulTableOptions.state = {
|
|
4556
|
+
...statefulTableOptions.state,
|
|
4557
|
+
columnOrder: normalizeRowExpandColumnOrder(statefulTableOptions, statefulTableOptions.state.columnOrder)
|
|
4558
|
+
};
|
|
4536
4559
|
const resolveRowId = statefulTableOptions.getRowId ?? ((_originalRow, index, _parentRow) => String(index));
|
|
4537
4560
|
|
|
4538
4561
|
//keep the prepared column tree referentially stable so TanStack's
|
|
@@ -20190,6 +20213,7 @@ exports.getMRT_Rows = getMRT_Rows;
|
|
|
20190
20213
|
exports.getMRT_SelectAllHandler = getMRT_SelectAllHandler;
|
|
20191
20214
|
exports.getTrailingDisplayColumnIds = getTrailingDisplayColumnIds;
|
|
20192
20215
|
exports.groupFieldsBySection = groupFieldsBySection;
|
|
20216
|
+
exports.normalizeRowExpandColumnOrder = normalizeRowExpandColumnOrder;
|
|
20193
20217
|
exports.prepareColumns = prepareColumns;
|
|
20194
20218
|
exports.reorderColumn = reorderColumn;
|
|
20195
20219
|
exports.resolveFormFields = resolveFormFields;
|