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