@odoo/o-spreadsheet 19.1.20 → 19.1.21

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 19.1.20
6
- * @date 2026-05-15T07:06:03.182Z
7
- * @hash b6a68b8
5
+ * @version 19.1.21
6
+ * @date 2026-05-27T05:56:49.891Z
7
+ * @hash 99ebe93
8
8
  */
9
9
 
10
10
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
@@ -6428,8 +6428,13 @@ function getApplyRangeChangeAddColRow(cmd) {
6428
6428
  changeType: "NONE",
6429
6429
  range
6430
6430
  };
6431
+ const isUnboundedAtEnd = range.unboundedZone[end] === void 0;
6432
+ if (isUnboundedAtEnd && !range.unboundedZone.hasHeader) return {
6433
+ changeType: "RESIZE",
6434
+ range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
6435
+ };
6431
6436
  if (cmd.position === "after") {
6432
- if (range.zone[start] <= cmd.base && cmd.base < range.zone[end]) return {
6437
+ if (range.zone[start] <= cmd.base && (cmd.base < range.zone[end] || isUnboundedAtEnd)) return {
6433
6438
  changeType: "RESIZE",
6434
6439
  range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
6435
6440
  };
@@ -7358,6 +7363,10 @@ const FORCE_DEFAULT_ARGS_FUNCTIONS = {
7358
7363
  ROUNDDOWN: [{
7359
7364
  type: "NUMBER",
7360
7365
  value: 0
7366
+ }],
7367
+ IFERROR: [{
7368
+ type: "NUMBER",
7369
+ value: 0
7361
7370
  }]
7362
7371
  };
7363
7372
  /**
@@ -49477,7 +49486,7 @@ function getVisiblePivotCellPositions(getters, pivotId) {
49477
49486
  col,
49478
49487
  row
49479
49488
  };
49480
- if (pivotId === getters.getPivotIdFromPosition(position)) positions.push(position);
49489
+ if (getters.getPivotIdsFromPosition(position).includes(pivotId)) positions.push(position);
49481
49490
  }
49482
49491
  return positions;
49483
49492
  }
@@ -50577,6 +50586,9 @@ const PIVOT_FUNCTIONS = [
50577
50586
  function getFirstPivotFunction(tokens) {
50578
50587
  return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS)[0];
50579
50588
  }
50589
+ function getPivotFunctions(tokens) {
50590
+ return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS);
50591
+ }
50580
50592
  /**
50581
50593
  * Parse a spreadsheet formula and detect the number of PIVOT functions that are
50582
50594
  * present in the given formula.
@@ -61409,6 +61421,7 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61409
61421
  "getFirstPivotFunction",
61410
61422
  "getPivotCellSortDirection",
61411
61423
  "getPivotIdFromPosition",
61424
+ "getPivotIdsFromPosition",
61412
61425
  "getPivotCellFromPosition",
61413
61426
  "generateNewCalculatedMeasureName",
61414
61427
  "isPivotUnused",
@@ -61466,37 +61479,52 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61466
61479
  }
61467
61480
  }
61468
61481
  /**
61469
- * Get the id of the pivot at the given position. Returns undefined if there
61482
+ * Get the id of the first pivot in the formula at the given position. Returns undefined if there
61470
61483
  * is no pivot at this position
61471
61484
  */
61472
61485
  getPivotIdFromPosition(position) {
61486
+ return this.getPivotIdsFromPosition(position)[0];
61487
+ }
61488
+ /**
61489
+ * Get all of the ids of the pivot present in the formula at the given position.
61490
+ */
61491
+ getPivotIdsFromPosition(position) {
61473
61492
  const cell = this.getters.getCorrespondingFormulaCell(position);
61474
- if (cell && cell.isFormula) {
61475
- const pivotFunction = this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
61476
- if (pivotFunction) {
61477
- const pivotId = pivotFunction.args[0]?.toString();
61478
- return pivotId && this.getters.getPivotId(pivotId);
61479
- }
61480
- }
61493
+ if (cell && cell.isFormula) return this.getPivotIdsFromFormula(position.sheetId, cell.compiledFormula);
61494
+ return [];
61495
+ }
61496
+ getPivotIdsFromFormula(sheetId, formula) {
61497
+ return this.getPivotFunctions(sheetId, formula.tokens).map((pivotFunction) => {
61498
+ const pivotId = pivotFunction.args[0]?.toString();
61499
+ return pivotId && this.getters.getPivotId(pivotId);
61500
+ }).filter(isDefined);
61481
61501
  }
61482
61502
  isSpillPivotFormula(position) {
61483
61503
  const cell = this.getters.getCorrespondingFormulaCell(position);
61484
61504
  if (cell && cell.isFormula) return this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens)?.functionName === "PIVOT";
61485
61505
  return false;
61486
61506
  }
61487
- getFirstPivotFunction(sheetId, tokens) {
61488
- const pivotFunction = getFirstPivotFunction(tokens);
61489
- if (!pivotFunction) return;
61490
- const { functionName, args } = pivotFunction;
61491
- return {
61492
- functionName,
61493
- args: args.map((argAst) => {
61507
+ getPivotFunctions(sheetId, tokens) {
61508
+ const pivotFunctions = getPivotFunctions(tokens);
61509
+ if (!pivotFunctions.length) return [];
61510
+ const evaluatedPivotFunctions = [];
61511
+ for (const pivotFunction of pivotFunctions) {
61512
+ const { functionName, args } = pivotFunction;
61513
+ const evaluatedArgs = args.map((argAst) => {
61494
61514
  if (argAst.type === "EMPTY") return;
61495
61515
  else if (argAst.type === "STRING" || argAst.type === "BOOLEAN" || argAst.type === "NUMBER") return argAst.value;
61496
61516
  const argsString = astToFormula(argAst);
61497
61517
  return this.getters.evaluateFormula(sheetId, argsString);
61498
- })
61499
- };
61518
+ });
61519
+ evaluatedPivotFunctions.push({
61520
+ functionName,
61521
+ args: evaluatedArgs
61522
+ });
61523
+ }
61524
+ return evaluatedPivotFunctions;
61525
+ }
61526
+ getFirstPivotFunction(sheetId, tokens) {
61527
+ return this.getPivotFunctions(sheetId, tokens)[0];
61500
61528
  }
61501
61529
  /**
61502
61530
  * Returns the domain args of a pivot formula from a position.
@@ -61602,8 +61630,8 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61602
61630
  const unusedPivots = new Set(this.getters.getPivotIds());
61603
61631
  for (const sheetId of this.getters.getSheetIds()) for (const cellId in this.getters.getCells(sheetId)) {
61604
61632
  const position = this.getters.getCellPosition(cellId);
61605
- const pivotId = this.getPivotIdFromPosition(position);
61606
- if (pivotId) {
61633
+ const pivotIds = this.getPivotIdsFromPosition(position);
61634
+ for (const pivotId of pivotIds) {
61607
61635
  unusedPivots.delete(pivotId);
61608
61636
  if (!unusedPivots.size) {
61609
61637
  this.unusedPivotsInFormulas = [];
@@ -61611,6 +61639,21 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61611
61639
  }
61612
61640
  }
61613
61641
  }
61642
+ for (const pivotId of this.getters.getPivotIds()) {
61643
+ const pivot = this.getters.getPivot(pivotId);
61644
+ for (const measure of pivot.definition.measures) if (measure.computedBy) {
61645
+ const { sheetId } = measure.computedBy;
61646
+ const formula = this.getters.getMeasureCompiledFormula(pivotId, measure);
61647
+ const relatedPivotIds = this.getPivotIdsFromFormula(sheetId, formula);
61648
+ for (const relatedPivotId of relatedPivotIds) {
61649
+ unusedPivots.delete(relatedPivotId);
61650
+ if (!unusedPivots.size) {
61651
+ this.unusedPivotsInFormulas = [];
61652
+ return [];
61653
+ }
61654
+ }
61655
+ }
61656
+ }
61614
61657
  this.unusedPivotsInFormulas = [...unusedPivots];
61615
61658
  return this.unusedPivotsInFormulas;
61616
61659
  }
@@ -79284,6 +79327,6 @@ exports.stores = stores;
79284
79327
  exports.tokenColors = tokenColors;
79285
79328
  exports.tokenize = tokenize;
79286
79329
 
79287
- __info__.version = "19.1.20";
79288
- __info__.date = "2026-05-15T07:06:03.182Z";
79289
- __info__.hash = "b6a68b8";
79330
+ __info__.version = "19.1.21";
79331
+ __info__.date = "2026-05-27T05:56:49.891Z";
79332
+ __info__.hash = "99ebe93";
@@ -2,9 +2,9 @@
2
2
  /*
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 19.1.20
6
- * @date 2026-05-15T07:06:04.872Z
7
- * @hash b6a68b8
5
+ * @version 19.1.21
6
+ * @date 2026-05-27T05:56:51.558Z
7
+ * @hash 99ebe93
8
8
  */
9
9
  :root {
10
10
  --os-gray-100: light-dark(#f9fafb, #1b1d26);
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 19.1.20
6
- * @date 2026-05-15T07:06:03.182Z
7
- * @hash b6a68b8
5
+ * @version 19.1.21
6
+ * @date 2026-05-27T05:56:49.891Z
7
+ * @hash 99ebe93
8
8
  */
9
9
 
10
10
  import { App, Component, blockDom, markRaw, onMounted, onPatched, onWillPatch, onWillStart, onWillUnmount, onWillUpdateProps, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, whenReady, xml } from "@odoo/owl";
@@ -6427,8 +6427,13 @@ function getApplyRangeChangeAddColRow(cmd) {
6427
6427
  changeType: "NONE",
6428
6428
  range
6429
6429
  };
6430
+ const isUnboundedAtEnd = range.unboundedZone[end] === void 0;
6431
+ if (isUnboundedAtEnd && !range.unboundedZone.hasHeader) return {
6432
+ changeType: "RESIZE",
6433
+ range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
6434
+ };
6430
6435
  if (cmd.position === "after") {
6431
- if (range.zone[start] <= cmd.base && cmd.base < range.zone[end]) return {
6436
+ if (range.zone[start] <= cmd.base && (cmd.base < range.zone[end] || isUnboundedAtEnd)) return {
6432
6437
  changeType: "RESIZE",
6433
6438
  range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
6434
6439
  };
@@ -7357,6 +7362,10 @@ const FORCE_DEFAULT_ARGS_FUNCTIONS = {
7357
7362
  ROUNDDOWN: [{
7358
7363
  type: "NUMBER",
7359
7364
  value: 0
7365
+ }],
7366
+ IFERROR: [{
7367
+ type: "NUMBER",
7368
+ value: 0
7360
7369
  }]
7361
7370
  };
7362
7371
  /**
@@ -49476,7 +49485,7 @@ function getVisiblePivotCellPositions(getters, pivotId) {
49476
49485
  col,
49477
49486
  row
49478
49487
  };
49479
- if (pivotId === getters.getPivotIdFromPosition(position)) positions.push(position);
49488
+ if (getters.getPivotIdsFromPosition(position).includes(pivotId)) positions.push(position);
49480
49489
  }
49481
49490
  return positions;
49482
49491
  }
@@ -50576,6 +50585,9 @@ const PIVOT_FUNCTIONS = [
50576
50585
  function getFirstPivotFunction(tokens) {
50577
50586
  return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS)[0];
50578
50587
  }
50588
+ function getPivotFunctions(tokens) {
50589
+ return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS);
50590
+ }
50579
50591
  /**
50580
50592
  * Parse a spreadsheet formula and detect the number of PIVOT functions that are
50581
50593
  * present in the given formula.
@@ -61224,6 +61236,7 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61224
61236
  "getFirstPivotFunction",
61225
61237
  "getPivotCellSortDirection",
61226
61238
  "getPivotIdFromPosition",
61239
+ "getPivotIdsFromPosition",
61227
61240
  "getPivotCellFromPosition",
61228
61241
  "generateNewCalculatedMeasureName",
61229
61242
  "isPivotUnused",
@@ -61281,37 +61294,52 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61281
61294
  }
61282
61295
  }
61283
61296
  /**
61284
- * Get the id of the pivot at the given position. Returns undefined if there
61297
+ * Get the id of the first pivot in the formula at the given position. Returns undefined if there
61285
61298
  * is no pivot at this position
61286
61299
  */
61287
61300
  getPivotIdFromPosition(position) {
61301
+ return this.getPivotIdsFromPosition(position)[0];
61302
+ }
61303
+ /**
61304
+ * Get all of the ids of the pivot present in the formula at the given position.
61305
+ */
61306
+ getPivotIdsFromPosition(position) {
61288
61307
  const cell = this.getters.getCorrespondingFormulaCell(position);
61289
- if (cell && cell.isFormula) {
61290
- const pivotFunction = this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
61291
- if (pivotFunction) {
61292
- const pivotId = pivotFunction.args[0]?.toString();
61293
- return pivotId && this.getters.getPivotId(pivotId);
61294
- }
61295
- }
61308
+ if (cell && cell.isFormula) return this.getPivotIdsFromFormula(position.sheetId, cell.compiledFormula);
61309
+ return [];
61310
+ }
61311
+ getPivotIdsFromFormula(sheetId, formula) {
61312
+ return this.getPivotFunctions(sheetId, formula.tokens).map((pivotFunction) => {
61313
+ const pivotId = pivotFunction.args[0]?.toString();
61314
+ return pivotId && this.getters.getPivotId(pivotId);
61315
+ }).filter(isDefined);
61296
61316
  }
61297
61317
  isSpillPivotFormula(position) {
61298
61318
  const cell = this.getters.getCorrespondingFormulaCell(position);
61299
61319
  if (cell && cell.isFormula) return this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens)?.functionName === "PIVOT";
61300
61320
  return false;
61301
61321
  }
61302
- getFirstPivotFunction(sheetId, tokens) {
61303
- const pivotFunction = getFirstPivotFunction(tokens);
61304
- if (!pivotFunction) return;
61305
- const { functionName, args } = pivotFunction;
61306
- return {
61307
- functionName,
61308
- args: args.map((argAst) => {
61322
+ getPivotFunctions(sheetId, tokens) {
61323
+ const pivotFunctions = getPivotFunctions(tokens);
61324
+ if (!pivotFunctions.length) return [];
61325
+ const evaluatedPivotFunctions = [];
61326
+ for (const pivotFunction of pivotFunctions) {
61327
+ const { functionName, args } = pivotFunction;
61328
+ const evaluatedArgs = args.map((argAst) => {
61309
61329
  if (argAst.type === "EMPTY") return;
61310
61330
  else if (argAst.type === "STRING" || argAst.type === "BOOLEAN" || argAst.type === "NUMBER") return argAst.value;
61311
61331
  const argsString = astToFormula(argAst);
61312
61332
  return this.getters.evaluateFormula(sheetId, argsString);
61313
- })
61314
- };
61333
+ });
61334
+ evaluatedPivotFunctions.push({
61335
+ functionName,
61336
+ args: evaluatedArgs
61337
+ });
61338
+ }
61339
+ return evaluatedPivotFunctions;
61340
+ }
61341
+ getFirstPivotFunction(sheetId, tokens) {
61342
+ return this.getPivotFunctions(sheetId, tokens)[0];
61315
61343
  }
61316
61344
  /**
61317
61345
  * Returns the domain args of a pivot formula from a position.
@@ -61417,8 +61445,8 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61417
61445
  const unusedPivots = new Set(this.getters.getPivotIds());
61418
61446
  for (const sheetId of this.getters.getSheetIds()) for (const cellId in this.getters.getCells(sheetId)) {
61419
61447
  const position = this.getters.getCellPosition(cellId);
61420
- const pivotId = this.getPivotIdFromPosition(position);
61421
- if (pivotId) {
61448
+ const pivotIds = this.getPivotIdsFromPosition(position);
61449
+ for (const pivotId of pivotIds) {
61422
61450
  unusedPivots.delete(pivotId);
61423
61451
  if (!unusedPivots.size) {
61424
61452
  this.unusedPivotsInFormulas = [];
@@ -61426,6 +61454,21 @@ var PivotUIPlugin = class extends CoreViewPlugin {
61426
61454
  }
61427
61455
  }
61428
61456
  }
61457
+ for (const pivotId of this.getters.getPivotIds()) {
61458
+ const pivot = this.getters.getPivot(pivotId);
61459
+ for (const measure of pivot.definition.measures) if (measure.computedBy) {
61460
+ const { sheetId } = measure.computedBy;
61461
+ const formula = this.getters.getMeasureCompiledFormula(pivotId, measure);
61462
+ const relatedPivotIds = this.getPivotIdsFromFormula(sheetId, formula);
61463
+ for (const relatedPivotId of relatedPivotIds) {
61464
+ unusedPivots.delete(relatedPivotId);
61465
+ if (!unusedPivots.size) {
61466
+ this.unusedPivotsInFormulas = [];
61467
+ return [];
61468
+ }
61469
+ }
61470
+ }
61471
+ }
61429
61472
  this.unusedPivotsInFormulas = [...unusedPivots];
61430
61473
  return this.unusedPivotsInFormulas;
61431
61474
  }
@@ -79046,6 +79089,6 @@ const chartHelpers = {
79046
79089
  //#endregion
79047
79090
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, ClientDisconnectedError, CommandResult, CorePlugin, CoreViewPlugin, DEFAULT_LOCALE, DEFAULT_LOCALES, DispatchResult, EvaluationError, LocalTransportService, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, categories, chartHelpers, components, constants, convertAstNodes, coreTypes, createAutocompleteArgumentsProvider, findCellInNewZone, functionCache, getCaretDownSvg, getCaretUpSvg, helpers, hooks, invalidateCFEvaluationCommands, invalidateChartEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
79048
79091
 
79049
- __info__.version = "19.1.20";
79050
- __info__.date = "2026-05-15T07:06:03.182Z";
79051
- __info__.hash = "b6a68b8";
79092
+ __info__.version = "19.1.21";
79093
+ __info__.date = "2026-05-27T05:56:49.891Z";
79094
+ __info__.hash = "99ebe93";
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 19.1.20
6
- * @date 2026-05-15T07:06:03.182Z
7
- * @hash b6a68b8
5
+ * @version 19.1.21
6
+ * @date 2026-05-27T05:56:49.891Z
7
+ * @hash 99ebe93
8
8
  */
9
9
 
10
10
  (function(exports, _odoo_owl) {
@@ -6429,8 +6429,13 @@ stores.inject(MyMetaStore, storeInstance);
6429
6429
  changeType: "NONE",
6430
6430
  range
6431
6431
  };
6432
+ const isUnboundedAtEnd = range.unboundedZone[end] === void 0;
6433
+ if (isUnboundedAtEnd && !range.unboundedZone.hasHeader) return {
6434
+ changeType: "RESIZE",
6435
+ range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
6436
+ };
6432
6437
  if (cmd.position === "after") {
6433
- if (range.zone[start] <= cmd.base && cmd.base < range.zone[end]) return {
6438
+ if (range.zone[start] <= cmd.base && (cmd.base < range.zone[end] || isUnboundedAtEnd)) return {
6434
6439
  changeType: "RESIZE",
6435
6440
  range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
6436
6441
  };
@@ -7359,6 +7364,10 @@ stores.inject(MyMetaStore, storeInstance);
7359
7364
  ROUNDDOWN: [{
7360
7365
  type: "NUMBER",
7361
7366
  value: 0
7367
+ }],
7368
+ IFERROR: [{
7369
+ type: "NUMBER",
7370
+ value: 0
7362
7371
  }]
7363
7372
  };
7364
7373
  /**
@@ -49478,7 +49487,7 @@ stores.inject(MyMetaStore, storeInstance);
49478
49487
  col,
49479
49488
  row
49480
49489
  };
49481
- if (pivotId === getters.getPivotIdFromPosition(position)) positions.push(position);
49490
+ if (getters.getPivotIdsFromPosition(position).includes(pivotId)) positions.push(position);
49482
49491
  }
49483
49492
  return positions;
49484
49493
  }
@@ -50578,6 +50587,9 @@ stores.inject(MyMetaStore, storeInstance);
50578
50587
  function getFirstPivotFunction(tokens) {
50579
50588
  return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS)[0];
50580
50589
  }
50590
+ function getPivotFunctions(tokens) {
50591
+ return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS);
50592
+ }
50581
50593
  /**
50582
50594
  * Parse a spreadsheet formula and detect the number of PIVOT functions that are
50583
50595
  * present in the given formula.
@@ -61226,6 +61238,7 @@ stores.inject(MyMetaStore, storeInstance);
61226
61238
  "getFirstPivotFunction",
61227
61239
  "getPivotCellSortDirection",
61228
61240
  "getPivotIdFromPosition",
61241
+ "getPivotIdsFromPosition",
61229
61242
  "getPivotCellFromPosition",
61230
61243
  "generateNewCalculatedMeasureName",
61231
61244
  "isPivotUnused",
@@ -61283,37 +61296,52 @@ stores.inject(MyMetaStore, storeInstance);
61283
61296
  }
61284
61297
  }
61285
61298
  /**
61286
- * Get the id of the pivot at the given position. Returns undefined if there
61299
+ * Get the id of the first pivot in the formula at the given position. Returns undefined if there
61287
61300
  * is no pivot at this position
61288
61301
  */
61289
61302
  getPivotIdFromPosition(position) {
61303
+ return this.getPivotIdsFromPosition(position)[0];
61304
+ }
61305
+ /**
61306
+ * Get all of the ids of the pivot present in the formula at the given position.
61307
+ */
61308
+ getPivotIdsFromPosition(position) {
61290
61309
  const cell = this.getters.getCorrespondingFormulaCell(position);
61291
- if (cell && cell.isFormula) {
61292
- const pivotFunction = this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
61293
- if (pivotFunction) {
61294
- const pivotId = pivotFunction.args[0]?.toString();
61295
- return pivotId && this.getters.getPivotId(pivotId);
61296
- }
61297
- }
61310
+ if (cell && cell.isFormula) return this.getPivotIdsFromFormula(position.sheetId, cell.compiledFormula);
61311
+ return [];
61312
+ }
61313
+ getPivotIdsFromFormula(sheetId, formula) {
61314
+ return this.getPivotFunctions(sheetId, formula.tokens).map((pivotFunction) => {
61315
+ const pivotId = pivotFunction.args[0]?.toString();
61316
+ return pivotId && this.getters.getPivotId(pivotId);
61317
+ }).filter(isDefined);
61298
61318
  }
61299
61319
  isSpillPivotFormula(position) {
61300
61320
  const cell = this.getters.getCorrespondingFormulaCell(position);
61301
61321
  if (cell && cell.isFormula) return this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens)?.functionName === "PIVOT";
61302
61322
  return false;
61303
61323
  }
61304
- getFirstPivotFunction(sheetId, tokens) {
61305
- const pivotFunction = getFirstPivotFunction(tokens);
61306
- if (!pivotFunction) return;
61307
- const { functionName, args } = pivotFunction;
61308
- return {
61309
- functionName,
61310
- args: args.map((argAst) => {
61324
+ getPivotFunctions(sheetId, tokens) {
61325
+ const pivotFunctions = getPivotFunctions(tokens);
61326
+ if (!pivotFunctions.length) return [];
61327
+ const evaluatedPivotFunctions = [];
61328
+ for (const pivotFunction of pivotFunctions) {
61329
+ const { functionName, args } = pivotFunction;
61330
+ const evaluatedArgs = args.map((argAst) => {
61311
61331
  if (argAst.type === "EMPTY") return;
61312
61332
  else if (argAst.type === "STRING" || argAst.type === "BOOLEAN" || argAst.type === "NUMBER") return argAst.value;
61313
61333
  const argsString = astToFormula(argAst);
61314
61334
  return this.getters.evaluateFormula(sheetId, argsString);
61315
- })
61316
- };
61335
+ });
61336
+ evaluatedPivotFunctions.push({
61337
+ functionName,
61338
+ args: evaluatedArgs
61339
+ });
61340
+ }
61341
+ return evaluatedPivotFunctions;
61342
+ }
61343
+ getFirstPivotFunction(sheetId, tokens) {
61344
+ return this.getPivotFunctions(sheetId, tokens)[0];
61317
61345
  }
61318
61346
  /**
61319
61347
  * Returns the domain args of a pivot formula from a position.
@@ -61419,8 +61447,8 @@ stores.inject(MyMetaStore, storeInstance);
61419
61447
  const unusedPivots = new Set(this.getters.getPivotIds());
61420
61448
  for (const sheetId of this.getters.getSheetIds()) for (const cellId in this.getters.getCells(sheetId)) {
61421
61449
  const position = this.getters.getCellPosition(cellId);
61422
- const pivotId = this.getPivotIdFromPosition(position);
61423
- if (pivotId) {
61450
+ const pivotIds = this.getPivotIdsFromPosition(position);
61451
+ for (const pivotId of pivotIds) {
61424
61452
  unusedPivots.delete(pivotId);
61425
61453
  if (!unusedPivots.size) {
61426
61454
  this.unusedPivotsInFormulas = [];
@@ -61428,6 +61456,21 @@ stores.inject(MyMetaStore, storeInstance);
61428
61456
  }
61429
61457
  }
61430
61458
  }
61459
+ for (const pivotId of this.getters.getPivotIds()) {
61460
+ const pivot = this.getters.getPivot(pivotId);
61461
+ for (const measure of pivot.definition.measures) if (measure.computedBy) {
61462
+ const { sheetId } = measure.computedBy;
61463
+ const formula = this.getters.getMeasureCompiledFormula(pivotId, measure);
61464
+ const relatedPivotIds = this.getPivotIdsFromFormula(sheetId, formula);
61465
+ for (const relatedPivotId of relatedPivotIds) {
61466
+ unusedPivots.delete(relatedPivotId);
61467
+ if (!unusedPivots.size) {
61468
+ this.unusedPivotsInFormulas = [];
61469
+ return [];
61470
+ }
61471
+ }
61472
+ }
61473
+ }
61431
61474
  this.unusedPivotsInFormulas = [...unusedPivots];
61432
61475
  return this.unusedPivotsInFormulas;
61433
61476
  }
@@ -79101,8 +79144,8 @@ exports.stores = stores;
79101
79144
  exports.tokenColors = tokenColors;
79102
79145
  exports.tokenize = tokenize;
79103
79146
 
79104
- __info__.version = "19.1.20";
79105
- __info__.date = "2026-05-15T07:06:03.182Z";
79106
- __info__.hash = "b6a68b8";
79147
+ __info__.version = "19.1.21";
79148
+ __info__.date = "2026-05-27T05:56:49.891Z";
79149
+ __info__.hash = "99ebe93";
79107
79150
 
79108
79151
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);