@odoo/o-spreadsheet 18.4.40 → 18.4.43

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 18.4.40
6
- * @date 2026-05-15T07:04:46.418Z
7
- * @hash bb1e6d6
5
+ * @version 18.4.43
6
+ * @date 2026-06-17T08:50:35.126Z
7
+ * @hash 5ab697a
8
8
  */
9
9
 
10
10
  (function(exports, _odoo_owl) {
@@ -3402,6 +3402,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3402
3402
  //#endregion
3403
3403
  //#region src/helpers/format/format_tokenizer.ts
3404
3404
  function tokenizeFormat(str) {
3405
+ str = str.replace(/\s/g, " ");
3405
3406
  const chars = new TokenizingChars(str);
3406
3407
  const result = [];
3407
3408
  let currentFormatPart = [];
@@ -5664,8 +5665,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5664
5665
  changeType: "NONE",
5665
5666
  range
5666
5667
  };
5668
+ const isUnboundedAtEnd = range.unboundedZone[end] === void 0;
5669
+ if (isUnboundedAtEnd && !range.unboundedZone.hasHeader) return {
5670
+ changeType: "RESIZE",
5671
+ range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
5672
+ };
5667
5673
  if (cmd.position === "after") {
5668
- if (range.zone[start] <= cmd.base && cmd.base < range.zone[end]) return {
5674
+ if (range.zone[start] <= cmd.base && (cmd.base < range.zone[end] || isUnboundedAtEnd)) return {
5669
5675
  changeType: "RESIZE",
5670
5676
  range: createAdaptedRange(range, dimension, "RESIZE", cmd.quantity)
5671
5677
  };
@@ -9199,6 +9205,10 @@ stores.inject(MyMetaStore, storeInstance);
9199
9205
  ROUNDDOWN: [{
9200
9206
  type: "NUMBER",
9201
9207
  value: 0
9208
+ }],
9209
+ IFERROR: [{
9210
+ type: "NUMBER",
9211
+ value: 0
9202
9212
  }]
9203
9213
  };
9204
9214
  /**
@@ -37052,11 +37062,10 @@ stores.inject(MyMetaStore, storeInstance);
37052
37062
  if (interactiveCreateTable(env, env.model.getters.getActiveSheetId()).isSuccessful) env.openSidePanel("TableSidePanel", {});
37053
37063
  };
37054
37064
  const DELETE_SELECTED_TABLE = (env) => {
37055
- const position = env.model.getters.getActivePosition();
37056
- const table = env.model.getters.getTable(position);
37065
+ const table = env.model.getters.getFirstTableInSelection();
37057
37066
  if (!table) return;
37058
37067
  env.model.dispatch("REMOVE_TABLE", {
37059
- sheetId: position.sheetId,
37068
+ sheetId: env.model.getters.getActiveSheetId(),
37060
37069
  target: [table.range.zone]
37061
37070
  });
37062
37071
  };
@@ -39666,8 +39675,12 @@ stores.inject(MyMetaStore, storeInstance);
39666
39675
  }
39667
39676
  stopEdition(direction) {
39668
39677
  if (this.canStopEdition()) {
39678
+ const { col, row } = this.currentEditedCell;
39669
39679
  this._stopEdition();
39670
- if (direction) this.model.selection.moveAnchorCell(direction, 1);
39680
+ if (direction) {
39681
+ this.model.selection.selectCell(col, row);
39682
+ this.model.selection.moveAnchorCell(direction, 1);
39683
+ }
39671
39684
  return;
39672
39685
  }
39673
39686
  const editedCell = this.currentEditedCell;
@@ -47013,9 +47026,9 @@ stores.inject(MyMetaStore, storeInstance);
47013
47026
  allSheetsMatches = [];
47014
47027
  activeSheetMatches = [];
47015
47028
  specificRangeMatches = [];
47029
+ selectedMatchPosition = null;
47016
47030
  currentSearchRegex = null;
47017
47031
  initialShowFormulaState;
47018
- preserveSelectedMatchIndex = false;
47019
47032
  irreplaceableMatchCount = 0;
47020
47033
  isSearchDirty = false;
47021
47034
  shouldFinalizeUpdateSelection = false;
@@ -47137,7 +47150,10 @@ stores.inject(MyMetaStore, storeInstance);
47137
47150
  */
47138
47151
  _updateSearch(toSearch, searchOptions) {
47139
47152
  this.searchOptions = searchOptions;
47140
- if (toSearch !== this.toSearch) this.selectedMatchIndex = null;
47153
+ if (toSearch !== this.toSearch) {
47154
+ this.selectedMatchIndex = null;
47155
+ this.selectedMatchPosition = null;
47156
+ }
47141
47157
  this.toSearch = toSearch;
47142
47158
  this.currentSearchRegex = getSearchRegex(this.toSearch, this.searchOptions);
47143
47159
  this.refreshSearch({
@@ -47149,8 +47165,14 @@ stores.inject(MyMetaStore, storeInstance);
47149
47165
  * refresh the matches according to the current search options
47150
47166
  */
47151
47167
  refreshSearch(options) {
47152
- if (!this.preserveSelectedMatchIndex) this.selectedMatchIndex = null;
47153
47168
  this.findMatches();
47169
+ if (this.selectedMatchPosition) if (this.selectedMatchPosition.sheetId !== this.getters.getActiveSheetId()) {
47170
+ this.selectedMatchIndex = null;
47171
+ this.selectedMatchPosition = null;
47172
+ } else {
47173
+ const index = this.searchMatches.findIndex((match) => match.sheetId === this.selectedMatchPosition?.sheetId && match.col === this.selectedMatchPosition?.col && match.row === this.selectedMatchPosition?.row);
47174
+ if (index !== -1) this.selectedMatchIndex = index;
47175
+ }
47154
47176
  this.selectNextCell(0, options);
47155
47177
  }
47156
47178
  getSheetsInSearchOrder() {
@@ -47218,6 +47240,7 @@ stores.inject(MyMetaStore, storeInstance);
47218
47240
  const matches = this.searchMatches;
47219
47241
  if (!matches.length) {
47220
47242
  this.selectedMatchIndex = null;
47243
+ this.selectedMatchPosition = null;
47221
47244
  return;
47222
47245
  }
47223
47246
  let nextIndex;
@@ -47231,14 +47254,13 @@ stores.inject(MyMetaStore, storeInstance);
47231
47254
  } else nextIndex = this.selectedMatchIndex + indexChange;
47232
47255
  nextIndex = (nextIndex + matches.length) % matches.length;
47233
47256
  this.selectedMatchIndex = nextIndex;
47257
+ this.selectedMatchPosition = matches[this.selectedMatchIndex];
47234
47258
  const selectedMatch = matches[nextIndex];
47235
47259
  if (options.jumpToMatchSheet && this.getters.getActiveSheetId() !== selectedMatch.sheetId) {
47236
- this.preserveSelectedMatchIndex = true;
47237
47260
  this.model.dispatch("ACTIVATE_SHEET", {
47238
47261
  sheetIdFrom: this.getters.getActiveSheetId(),
47239
47262
  sheetIdTo: selectedMatch.sheetId
47240
47263
  });
47241
- this.preserveSelectedMatchIndex = false;
47242
47264
  this.isSearchDirty = false;
47243
47265
  }
47244
47266
  this.model.selection.getBackToDefault();
@@ -47249,7 +47271,6 @@ stores.inject(MyMetaStore, storeInstance);
47249
47271
  */
47250
47272
  replace() {
47251
47273
  if (this.selectedMatchIndex === null) return;
47252
- this.preserveSelectedMatchIndex = true;
47253
47274
  this.shouldFinalizeUpdateSelection = true;
47254
47275
  this.model.dispatch("REPLACE_SEARCH", {
47255
47276
  searchString: this.toSearch,
@@ -47257,7 +47278,6 @@ stores.inject(MyMetaStore, storeInstance);
47257
47278
  matches: [this.searchMatches[this.selectedMatchIndex]],
47258
47279
  searchOptions: this.searchOptions
47259
47280
  });
47260
- this.preserveSelectedMatchIndex = false;
47261
47281
  }
47262
47282
  /**
47263
47283
  * Apply the replace function to all the matches one time.
@@ -47732,7 +47752,7 @@ stores.inject(MyMetaStore, storeInstance);
47732
47752
  col,
47733
47753
  row
47734
47754
  };
47735
- if (pivotId === getters.getPivotIdFromPosition(position)) positions.push(position);
47755
+ if (getters.getPivotIdsFromPosition(position).includes(pivotId)) positions.push(position);
47736
47756
  }
47737
47757
  return positions;
47738
47758
  }
@@ -48657,6 +48677,9 @@ stores.inject(MyMetaStore, storeInstance);
48657
48677
  function getFirstPivotFunction(tokens) {
48658
48678
  return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS)[0];
48659
48679
  }
48680
+ function getPivotFunctions(tokens) {
48681
+ return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS);
48682
+ }
48660
48683
  /**
48661
48684
  * Parse a spreadsheet formula and detect the number of PIVOT functions that are
48662
48685
  * present in the given formula.
@@ -59332,7 +59355,7 @@ stores.inject(MyMetaStore, storeInstance);
59332
59355
  const definition = getters.getPivotCoreDefinition(pivotId);
59333
59356
  const isDashboard = getters.isDashboard();
59334
59357
  const fields = pivotCell.dimension === "COL" ? definition.columns : definition.rows;
59335
- const hasIcon = !isDashboard && pivotCell.domain.length !== fields.length;
59358
+ const hasIcon = !isDashboard && !getters.shouldShowFormulas() && pivotCell.domain.length !== fields.length;
59336
59359
  const isCollapsed = (definition.collapsedDomains?.[pivotCell.dimension] ?? []).some((domain) => deepEquals(domain, pivotCell.domain));
59337
59360
  const indent = pivotCell.dimension === "ROW" ? (pivotCell.domain.length - 1) * 15 : 0;
59338
59361
  return {
@@ -60241,6 +60264,7 @@ stores.inject(MyMetaStore, storeInstance);
60241
60264
  "getPivot",
60242
60265
  "getFirstPivotFunction",
60243
60266
  "getPivotIdFromPosition",
60267
+ "getPivotIdsFromPosition",
60244
60268
  "getPivotCellFromPosition",
60245
60269
  "generateNewCalculatedMeasureName",
60246
60270
  "isPivotUnused",
@@ -60265,9 +60289,11 @@ stores.inject(MyMetaStore, storeInstance);
60265
60289
  this.refreshPivot(cmd.id);
60266
60290
  break;
60267
60291
  case "ADD_PIVOT":
60292
+ this.unusedPivots?.push(cmd.pivotId);
60268
60293
  this.setupPivot(cmd.pivotId);
60269
60294
  break;
60270
60295
  case "DUPLICATE_PIVOT":
60296
+ this.unusedPivots?.push(cmd.newPivotId);
60271
60297
  this.setupPivot(cmd.newPivotId);
60272
60298
  break;
60273
60299
  case "UPDATE_PIVOT":
@@ -60298,37 +60324,52 @@ stores.inject(MyMetaStore, storeInstance);
60298
60324
  }
60299
60325
  }
60300
60326
  /**
60301
- * Get the id of the pivot at the given position. Returns undefined if there
60327
+ * Get the id of the first pivot in the formula at the given position. Returns undefined if there
60302
60328
  * is no pivot at this position
60303
60329
  */
60304
60330
  getPivotIdFromPosition(position) {
60331
+ return this.getPivotIdsFromPosition(position)[0];
60332
+ }
60333
+ /**
60334
+ * Get all of the ids of the pivot present in the formula at the given position.
60335
+ */
60336
+ getPivotIdsFromPosition(position) {
60305
60337
  const cell = this.getters.getCorrespondingFormulaCell(position);
60306
- if (cell && cell.isFormula) {
60307
- const pivotFunction = this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens);
60308
- if (pivotFunction) {
60309
- const pivotId = pivotFunction.args[0]?.toString();
60310
- return pivotId && this.getters.getPivotId(pivotId);
60311
- }
60312
- }
60338
+ if (cell && cell.isFormula) return this.getPivotIdsFromFormula(position.sheetId, cell.compiledFormula);
60339
+ return [];
60340
+ }
60341
+ getPivotIdsFromFormula(sheetId, formula) {
60342
+ return this.getPivotFunctions(sheetId, formula.tokens).map((pivotFunction) => {
60343
+ const pivotId = pivotFunction.args[0]?.toString();
60344
+ return pivotId && this.getters.getPivotId(pivotId);
60345
+ }).filter(isDefined);
60313
60346
  }
60314
60347
  isSpillPivotFormula(position) {
60315
60348
  const cell = this.getters.getCorrespondingFormulaCell(position);
60316
60349
  if (cell && cell.isFormula) return this.getFirstPivotFunction(position.sheetId, cell.compiledFormula.tokens)?.functionName === "PIVOT";
60317
60350
  return false;
60318
60351
  }
60319
- getFirstPivotFunction(sheetId, tokens) {
60320
- const pivotFunction = getFirstPivotFunction(tokens);
60321
- if (!pivotFunction) return;
60322
- const { functionName, args } = pivotFunction;
60323
- return {
60324
- functionName,
60325
- args: args.map((argAst) => {
60352
+ getPivotFunctions(sheetId, tokens) {
60353
+ const pivotFunctions = getPivotFunctions(tokens);
60354
+ if (!pivotFunctions.length) return [];
60355
+ const evaluatedPivotFunctions = [];
60356
+ for (const pivotFunction of pivotFunctions) {
60357
+ const { functionName, args } = pivotFunction;
60358
+ const evaluatedArgs = args.map((argAst) => {
60326
60359
  if (argAst.type === "EMPTY") return;
60327
60360
  else if (argAst.type === "STRING" || argAst.type === "BOOLEAN" || argAst.type === "NUMBER") return argAst.value;
60328
60361
  const argsString = astToFormula(argAst);
60329
60362
  return this.getters.evaluateFormula(sheetId, argsString);
60330
- })
60331
- };
60363
+ });
60364
+ evaluatedPivotFunctions.push({
60365
+ functionName,
60366
+ args: evaluatedArgs
60367
+ });
60368
+ }
60369
+ return evaluatedPivotFunctions;
60370
+ }
60371
+ getFirstPivotFunction(sheetId, tokens) {
60372
+ return this.getPivotFunctions(sheetId, tokens)[0];
60332
60373
  }
60333
60374
  /**
60334
60375
  * Returns the domain args of a pivot formula from a position.
@@ -60432,8 +60473,8 @@ stores.inject(MyMetaStore, storeInstance);
60432
60473
  const unusedPivots = new Set(this.getters.getPivotIds());
60433
60474
  for (const sheetId of this.getters.getSheetIds()) for (const cellId in this.getters.getCells(sheetId)) {
60434
60475
  const position = this.getters.getCellPosition(cellId);
60435
- const pivotId = this.getPivotIdFromPosition(position);
60436
- if (pivotId) {
60476
+ const pivotIds = this.getPivotIdsFromPosition(position);
60477
+ for (const pivotId of pivotIds) {
60437
60478
  unusedPivots.delete(pivotId);
60438
60479
  if (!unusedPivots.size) {
60439
60480
  this.unusedPivots = [];
@@ -60441,6 +60482,21 @@ stores.inject(MyMetaStore, storeInstance);
60441
60482
  }
60442
60483
  }
60443
60484
  }
60485
+ for (const pivotId of this.getters.getPivotIds()) {
60486
+ const pivot = this.getters.getPivotCoreDefinition(pivotId);
60487
+ for (const measure of pivot.measures) if (measure.computedBy) {
60488
+ const { sheetId } = measure.computedBy;
60489
+ const formula = this.getters.getMeasureCompiledFormula(pivotId, measure);
60490
+ const relatedPivotIds = this.getPivotIdsFromFormula(sheetId, formula);
60491
+ for (const relatedPivotId of relatedPivotIds) {
60492
+ unusedPivots.delete(relatedPivotId);
60493
+ if (!unusedPivots.size) {
60494
+ this.unusedPivots = [];
60495
+ return [];
60496
+ }
60497
+ }
60498
+ }
60499
+ }
60444
60500
  this.unusedPivots = [...unusedPivots];
60445
60501
  return this.unusedPivots;
60446
60502
  }
@@ -75370,8 +75426,8 @@ exports.stores = stores;
75370
75426
  exports.tokenColors = tokenColors;
75371
75427
  exports.tokenize = tokenize;
75372
75428
 
75373
- __info__.version = "18.4.40";
75374
- __info__.date = "2026-05-15T07:04:46.418Z";
75375
- __info__.hash = "bb1e6d6";
75429
+ __info__.version = "18.4.43";
75430
+ __info__.date = "2026-06-17T08:50:35.126Z";
75431
+ __info__.hash = "5ab697a";
75376
75432
 
75377
75433
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);