@dooherceg/material-react-table 4.0.2 → 4.0.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/dist/index.esm.js CHANGED
@@ -2294,7 +2294,39 @@ const MRT_ExpandButton = ({
2294
2294
  const canExpand = row.getCanExpand() && (maxDepth === undefined || row.depth < maxDepth - 1);
2295
2295
  const handleToggleExpand = event => {
2296
2296
  event.stopPropagation();
2297
- row.toggleExpanded();
2297
+ // row.toggleExpanded() is never called here. Its internal read of
2298
+ // row.table.atoms.expanded.get() can go stale relative to the live
2299
+ // table.getState() after repeated toggles on the same row (observed: a row's
2300
+ // second collapse silently no-ops - state and UI both stay exactly as they
2301
+ // were, with no error). table.getState()/table.setExpanded() stayed reliable
2302
+ // through the same repeated-toggle sequence, so the resulting map is always
2303
+ // built from those directly instead.
2304
+ const currentExpanded = table.getState().expanded;
2305
+ const isCurrentlyExpanded = currentExpanded === true || !!currentExpanded[row.id];
2306
+ if (isCurrentlyExpanded) {
2307
+ if (currentExpanded === true) {
2308
+ const next = {};
2309
+ Object.values(table.getRowModel().rowsById).forEach(otherRow => {
2310
+ if (otherRow.id !== row.id && otherRow.getCanExpand()) {
2311
+ next[otherRow.id] = true;
2312
+ }
2313
+ });
2314
+ table.setExpanded(next);
2315
+ } else {
2316
+ const next_0 = {
2317
+ ...currentExpanded
2318
+ };
2319
+ delete next_0[row.id];
2320
+ table.setExpanded(next_0);
2321
+ }
2322
+ } else {
2323
+ // isCurrentlyExpanded is false, so currentExpanded can't be `true` here.
2324
+ const next_1 = {
2325
+ ...currentExpanded
2326
+ };
2327
+ next_1[row.id] = true;
2328
+ table.setExpanded(next_1);
2329
+ }
2298
2330
  iconButtonProps?.onClick?.(event);
2299
2331
  };
2300
2332
  const detailPanel = !!renderDetailPanel?.({
@@ -13619,7 +13651,7 @@ const MRT_CellActionMenu = ({
13619
13651
  };
13620
13652
 
13621
13653
  const MRT_DisplayColumnCellRenderer = t0 => {
13622
- const $ = c(11);
13654
+ const $ = c(12);
13623
13655
  const {
13624
13656
  cell,
13625
13657
  rowRef,
@@ -13634,41 +13666,45 @@ const MRT_DisplayColumnCellRenderer = t0 => {
13634
13666
  const {
13635
13667
  columnDef
13636
13668
  } = column;
13669
+ const CellComponent = columnDef.Cell;
13670
+ if (!CellComponent) {
13671
+ return null;
13672
+ }
13637
13673
  let t1;
13638
- if ($[0] !== cell || $[1] !== column || $[2] !== columnDef || $[3] !== row || $[4] !== rowRef || $[5] !== staticColumnIndex || $[6] !== staticRowIndex || $[7] !== table) {
13639
- t1 = columnDef.Cell?.({
13640
- cell,
13641
- column,
13642
- renderedCellValue: cell.renderValue(),
13643
- row,
13644
- rowRef,
13645
- staticColumnIndex,
13646
- staticRowIndex,
13647
- table
13648
- }) ?? null;
13674
+ if ($[0] !== cell) {
13675
+ t1 = cell.renderValue();
13649
13676
  $[0] = cell;
13650
- $[1] = column;
13651
- $[2] = columnDef;
13652
- $[3] = row;
13653
- $[4] = rowRef;
13654
- $[5] = staticColumnIndex;
13655
- $[6] = staticRowIndex;
13656
- $[7] = table;
13657
- $[8] = t1;
13677
+ $[1] = t1;
13658
13678
  } else {
13659
- t1 = $[8];
13679
+ t1 = $[1];
13660
13680
  }
13661
- let t2;
13662
- if ($[9] !== t1) {
13663
- t2 = /*#__PURE__*/jsx(Fragment, {
13664
- children: t1
13681
+ const t2 = t1;
13682
+ let t3;
13683
+ if ($[2] !== CellComponent || $[3] !== cell || $[4] !== column || $[5] !== row || $[6] !== rowRef || $[7] !== staticColumnIndex || $[8] !== staticRowIndex || $[9] !== t2 || $[10] !== table) {
13684
+ t3 = /*#__PURE__*/jsx(CellComponent, {
13685
+ cell: cell,
13686
+ column: column,
13687
+ renderedCellValue: t2,
13688
+ row: row,
13689
+ rowRef: rowRef,
13690
+ staticColumnIndex: staticColumnIndex,
13691
+ staticRowIndex: staticRowIndex,
13692
+ table: table
13665
13693
  });
13666
- $[9] = t1;
13667
- $[10] = t2;
13694
+ $[2] = CellComponent;
13695
+ $[3] = cell;
13696
+ $[4] = column;
13697
+ $[5] = row;
13698
+ $[6] = rowRef;
13699
+ $[7] = staticColumnIndex;
13700
+ $[8] = staticRowIndex;
13701
+ $[9] = t2;
13702
+ $[10] = table;
13703
+ $[11] = t3;
13668
13704
  } else {
13669
- t2 = $[10];
13705
+ t3 = $[11];
13670
13706
  }
13671
- return t2;
13707
+ return t3;
13672
13708
  };
13673
13709
 
13674
13710
  const MRT_TableBodyCellValue = ({