@dooherceg/material-react-table 3.2.18 → 3.2.20

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 CHANGED
@@ -647,9 +647,13 @@ type MRT_TableInstance<TData extends MRT_RowData> = Omit<Table<TData>, 'getAllCo
647
647
  setNewEntryModal: Dispatch<SetStateAction<MRT_NewEntryModalState>>;
648
648
  setRowReorderingSelection: Dispatch<SetStateAction<MRT_RowReorderingSelectionState>>;
649
649
  addRow: (rows: MRT_RowManipulationInput<TData>) => void;
650
- updateRow: (rows: MRT_RowManipulationInput<TData>) => void;
650
+ updateRow: (rows: MRT_RowManipulationInput<Partial<TData> & {
651
+ id: string;
652
+ }>) => void;
651
653
  setRows: (rows: MRT_RowManipulationInput<TData>) => void;
652
- upsertRow: (rows: MRT_RowManipulationInput<TData>) => void;
654
+ upsertRow: (rows: MRT_RowManipulationInput<Partial<TData> & {
655
+ id: string;
656
+ }>) => void;
653
657
  removeRow: (rows: string | string[]) => void;
654
658
  refetch?: () => void;
655
659
  };
package/dist/index.esm.js CHANGED
@@ -2705,17 +2705,13 @@ const handleUpdateRow = ({ getRowId, setRowsState, }) => {
2705
2705
  if (!rowsToUpdate.length)
2706
2706
  return previousRows;
2707
2707
  const rowById = new Map();
2708
- rowsToUpdate.forEach((row, index) => {
2709
- const rowId = getResolvedRowId(row, index, undefined, getRowId);
2710
- if (rowId !== undefined) {
2711
- rowById.set(rowId, row);
2712
- }
2708
+ rowsToUpdate.forEach((row) => {
2709
+ rowById.set(row.id, row);
2713
2710
  });
2714
2711
  return previousRows.map((row, index) => {
2715
2712
  const rowId = getResolvedRowId(row, index, undefined, getRowId);
2716
- return rowId !== undefined && rowById.has(rowId)
2717
- ? rowById.get(rowId)
2718
- : row;
2713
+ const updatedRow = rowId !== undefined ? rowById.get(rowId) : undefined;
2714
+ return updatedRow !== undefined ? Object.assign(Object.assign({}, row), updatedRow) : row;
2719
2715
  });
2720
2716
  });
2721
2717
  };
@@ -2740,14 +2736,13 @@ const handleUpsertRow = ({ getRowId, pageSize, setRowsState, }) => {
2740
2736
  }
2741
2737
  });
2742
2738
  const rowsToInsert = [];
2743
- rowsToUpsert.forEach((row, index) => {
2744
- const rowId = getResolvedRowId(row, index, undefined, getRowId);
2745
- const existingIndex = rowId !== undefined ? indexByRowId.get(rowId) : undefined;
2739
+ rowsToUpsert.forEach((row) => {
2740
+ const existingIndex = indexByRowId.get(row.id);
2746
2741
  if (existingIndex === undefined) {
2747
2742
  rowsToInsert.push(row);
2748
2743
  return;
2749
2744
  }
2750
- nextRows[existingIndex] = row;
2745
+ nextRows[existingIndex] = Object.assign(Object.assign({}, nextRows[existingIndex]), row);
2751
2746
  });
2752
2747
  return capRowsToPageSize([...rowsToInsert, ...nextRows], pageSize);
2753
2748
  });