@particle-academy/fancy-sheets 0.4.2 → 0.4.3

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.js CHANGED
@@ -1235,10 +1235,15 @@ function getRecalculationOrder(graph) {
1235
1235
 
1236
1236
  // src/hooks/use-spreadsheet-store.ts
1237
1237
  function recalculateWorkbook(workbook) {
1238
- return {
1239
- ...workbook,
1240
- sheets: workbook.sheets.map((s) => recalculateSheet(s, workbook.sheets))
1241
- };
1238
+ const recalculated = [];
1239
+ for (const sheet of workbook.sheets) {
1240
+ recalculated.push(recalculateSheet(sheet, recalculated));
1241
+ }
1242
+ const finalSheets = [];
1243
+ for (const sheet of recalculated) {
1244
+ finalSheets.push(recalculateSheet(sheet, recalculated));
1245
+ }
1246
+ return { ...workbook, sheets: finalSheets };
1242
1247
  }
1243
1248
  function createInitialState(data) {
1244
1249
  const workbook = data ?? createEmptyWorkbook();
@@ -1338,10 +1343,11 @@ function reducer(state, action) {
1338
1343
  const sheet = getActiveSheet(state);
1339
1344
  const existing = sheet.cells[action.address];
1340
1345
  if (existing?.format) cellData.format = existing.format;
1341
- const workbook = updateActiveSheet(state, (s) => {
1342
- const updated = { ...s, cells: { ...s.cells, [action.address]: cellData } };
1343
- return recalculateSheet(updated, state.workbook.sheets);
1344
- });
1346
+ const updatedWorkbook = updateActiveSheet(state, (s) => ({
1347
+ ...s,
1348
+ cells: { ...s.cells, [action.address]: cellData }
1349
+ }));
1350
+ const workbook = recalculateWorkbook(updatedWorkbook);
1345
1351
  return { ...state, workbook, ...history };
1346
1352
  }
1347
1353
  case "SET_CELL_FORMAT": {