@economic/taco 2.58.0 → 2.58.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.
package/dist/taco.js CHANGED
@@ -53129,6 +53129,27 @@ function reducer(state, action) {
53129
53129
  temporaryRows: state.temporaryRows.filter((row) => row[rowIdentityAccessor] !== rowId)
53130
53130
  };
53131
53131
  }
53132
+ case "complete": {
53133
+ const { changes, handleDiscard } = payload;
53134
+ if (JSON.stringify(changes) !== JSON.stringify(state.changes.rows[rowId])) {
53135
+ return {
53136
+ ...state,
53137
+ changes: {
53138
+ ...state.changes,
53139
+ originals: setWith(
53140
+ state.changes.originals,
53141
+ rowId,
53142
+ { ...state.changes.originals[rowId], ...changes },
53143
+ Object
53144
+ )
53145
+ }
53146
+ };
53147
+ }
53148
+ if (typeof handleDiscard === "function") {
53149
+ handleDiscard();
53150
+ }
53151
+ return state;
53152
+ }
53132
53153
  case "setRowStatus": {
53133
53154
  const { status } = payload;
53134
53155
  return {
@@ -53346,7 +53367,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
53346
53367
  for (const rowId2 of Object.keys(changes)) {
53347
53368
  const status = getRowStatus(rowId2);
53348
53369
  try {
53349
- const rowChanges = changes[rowId2] ?? {};
53370
+ const rowChanges = JSON.parse(JSON.stringify(changes[rowId2] ?? {}));
53350
53371
  if (!Object.keys(rowChanges).length || status === "saving" || status === "errored") {
53351
53372
  continue;
53352
53373
  }
@@ -53362,7 +53383,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
53362
53383
  }
53363
53384
  }
53364
53385
  await handleSave(changeSet);
53365
- await discardChanges(rowId2, table);
53386
+ await complete(rowId2, table, rowChanges);
53366
53387
  setRowStatus(rowId2, "saved");
53367
53388
  setTimeout(() => {
53368
53389
  setRowStatus(rowId2, void 0);
@@ -53411,6 +53432,16 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
53411
53432
  await handleDiscard();
53412
53433
  }
53413
53434
  }
53435
+ async function complete(rowId, table, changes) {
53436
+ const handleDiscard2 = async () => {
53437
+ await discardChanges(rowId, table);
53438
+ };
53439
+ dispatch({
53440
+ type: "complete",
53441
+ rowId,
53442
+ payload: { rowIdentityAccessor, changes, handleDiscard: handleDiscard2 }
53443
+ });
53444
+ }
53414
53445
  return {
53415
53446
  // row
53416
53447
  getRowValue,