@odoo/o-spreadsheet 18.3.31 → 18.3.33

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.3.31
6
- * @date 2025-12-26T10:18:10.765Z
7
- * @hash 1e143e1
5
+ * @version 18.3.33
6
+ * @date 2026-01-21T11:05:17.933Z
7
+ * @hash b7e5d91
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, App, blockDom, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -32,7 +32,8 @@ function createAction(item) {
32
32
  return children
33
33
  .map((child) => (typeof child === "function" ? child(env) : child))
34
34
  .flat()
35
- .map(createAction);
35
+ .map(createAction)
36
+ .sort((a, b) => a.sequence - b.sequence);
36
37
  }
37
38
  : () => [],
38
39
  isReadonlyAllowed: item.isReadonlyAllowed || false,
@@ -307,6 +308,7 @@ const DEFAULT_STYLE = {
307
308
  fillColor: "",
308
309
  textColor: "",
309
310
  };
311
+ const DEFAULT_NUMBER_STYLE = { ...DEFAULT_STYLE, align: "right" };
310
312
  const DEFAULT_VERTICAL_ALIGN = DEFAULT_STYLE.verticalAlign;
311
313
  const DEFAULT_WRAPPING_MODE = DEFAULT_STYLE.wrapping;
312
314
  // Fonts
@@ -6179,67 +6181,6 @@ function getFullReference(sheetName, xc) {
6179
6181
  return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
6180
6182
  }
6181
6183
 
6182
- function createDefaultRows(rowNumber) {
6183
- const rows = [];
6184
- for (let i = 0; i < rowNumber; i++) {
6185
- const row = {
6186
- cells: {},
6187
- };
6188
- rows.push(row);
6189
- }
6190
- return rows;
6191
- }
6192
- function moveHeaderIndexesOnHeaderAddition(indexHeaderAdded, numberAdded, headers) {
6193
- return headers.map((header) => {
6194
- if (header >= indexHeaderAdded) {
6195
- return header + numberAdded;
6196
- }
6197
- return header;
6198
- });
6199
- }
6200
- function moveHeaderIndexesOnHeaderDeletion(deletedHeaders, headers) {
6201
- deletedHeaders = [...deletedHeaders].sort((a, b) => b - a);
6202
- return headers
6203
- .map((header) => {
6204
- for (const deletedHeader of deletedHeaders) {
6205
- if (header > deletedHeader) {
6206
- header--;
6207
- }
6208
- else if (header === deletedHeader) {
6209
- return undefined;
6210
- }
6211
- }
6212
- return header;
6213
- })
6214
- .filter(isDefined);
6215
- }
6216
- function getNextSheetName(existingNames, baseName = "Sheet") {
6217
- let i = 1;
6218
- let name = `${baseName}${i}`;
6219
- while (existingNames.includes(name)) {
6220
- name = `${baseName}${i}`;
6221
- i++;
6222
- }
6223
- return name;
6224
- }
6225
- function getDuplicateSheetName(nameToDuplicate, existingNames) {
6226
- let i = 1;
6227
- const baseName = _t("Copy of %s", nameToDuplicate);
6228
- let name = baseName.toString();
6229
- while (existingNames.includes(name)) {
6230
- name = `${baseName} (${i})`;
6231
- i++;
6232
- }
6233
- return name;
6234
- }
6235
- function isSheetNameEqual(name1, name2) {
6236
- if (name1 === undefined || name2 === undefined) {
6237
- return false;
6238
- }
6239
- return (getUnquotedSheetName(name1.trim().toUpperCase()) ===
6240
- getUnquotedSheetName(name2.trim().toUpperCase()));
6241
- }
6242
-
6243
6184
  function createRange(args, getSheetSize) {
6244
6185
  const unboundedZone = args.zone;
6245
6186
  const zone = boundUnboundedZone(unboundedZone, getSheetSize(args.sheetId));
@@ -6534,8 +6475,8 @@ function getApplyRangeChangeRemoveColRow(cmd) {
6534
6475
  elements.sort((a, b) => b - a);
6535
6476
  const groups = groupConsecutive(elements);
6536
6477
  return (range) => {
6537
- if (!isSheetNameEqual(range.sheetId, cmd.sheetId)) {
6538
- return { changeType: "NONE" };
6478
+ if (range.sheetId !== cmd.sheetId) {
6479
+ return { changeType: "NONE", range };
6539
6480
  }
6540
6481
  let newRange = range;
6541
6482
  let changeType = "NONE";
@@ -6562,10 +6503,7 @@ function getApplyRangeChangeRemoveColRow(cmd) {
6562
6503
  newRange = createAdaptedRange(newRange, dimension, changeType, -(max - min + 1));
6563
6504
  }
6564
6505
  }
6565
- if (changeType !== "NONE") {
6566
- return { changeType, range: newRange };
6567
- }
6568
- return { changeType: "NONE" };
6506
+ return { changeType, range: newRange };
6569
6507
  };
6570
6508
  }
6571
6509
  function getApplyRangeChangeAddColRow(cmd) {
@@ -6574,7 +6512,7 @@ function getApplyRangeChangeAddColRow(cmd) {
6574
6512
  let dimension = cmd.dimension === "COL" ? "columns" : "rows";
6575
6513
  return (range) => {
6576
6514
  if (range.sheetId !== cmd.sheetId) {
6577
- return { changeType: "NONE" };
6515
+ return { changeType: "NONE", range };
6578
6516
  }
6579
6517
  if (cmd.position === "after") {
6580
6518
  if (range.zone[start] <= cmd.base && cmd.base < range.zone[end]) {
@@ -6604,13 +6542,13 @@ function getApplyRangeChangeAddColRow(cmd) {
6604
6542
  };
6605
6543
  }
6606
6544
  }
6607
- return { changeType: "NONE" };
6545
+ return { changeType: "NONE", range };
6608
6546
  };
6609
6547
  }
6610
6548
  function getApplyRangeChangeDeleteSheet(cmd) {
6611
6549
  return (range) => {
6612
6550
  if (range.sheetId !== cmd.sheetId && range.invalidSheetName !== cmd.sheetName) {
6613
- return { changeType: "NONE" };
6551
+ return { changeType: "NONE", range };
6614
6552
  }
6615
6553
  const invalidSheetName = cmd.sheetName;
6616
6554
  range = {
@@ -6637,14 +6575,14 @@ function getApplyRangeChangeRenameSheet(cmd) {
6637
6575
  const newRange = { ...range, sheetId, invalidSheetName };
6638
6576
  return { changeType: "CHANGE", range: newRange };
6639
6577
  }
6640
- return { changeType: "NONE" };
6578
+ return { changeType: "NONE", range };
6641
6579
  };
6642
6580
  }
6643
6581
  function getApplyRangeChangeMoveRange(cmd) {
6644
6582
  const originZone = cmd.target[0];
6645
6583
  return (range) => {
6646
6584
  if (range.sheetId !== cmd.sheetId || !isZoneInside(range.zone, originZone)) {
6647
- return { changeType: "NONE" };
6585
+ return { changeType: "NONE", range };
6648
6586
  }
6649
6587
  const targetSheetId = cmd.targetSheetId;
6650
6588
  const offsetX = cmd.col - originZone.left;
@@ -6741,17 +6679,87 @@ function fuzzyLookup(pattern, list, fn) {
6741
6679
  return results.map((r) => r.elem);
6742
6680
  }
6743
6681
 
6682
+ function createDefaultRows(rowNumber) {
6683
+ const rows = [];
6684
+ for (let i = 0; i < rowNumber; i++) {
6685
+ const row = {
6686
+ cells: {},
6687
+ };
6688
+ rows.push(row);
6689
+ }
6690
+ return rows;
6691
+ }
6692
+ function moveHeaderIndexesOnHeaderAddition(indexHeaderAdded, numberAdded, headers) {
6693
+ return headers.map((header) => {
6694
+ if (header >= indexHeaderAdded) {
6695
+ return header + numberAdded;
6696
+ }
6697
+ return header;
6698
+ });
6699
+ }
6700
+ function moveHeaderIndexesOnHeaderDeletion(deletedHeaders, headers) {
6701
+ deletedHeaders = [...deletedHeaders].sort((a, b) => b - a);
6702
+ return headers
6703
+ .map((header) => {
6704
+ for (const deletedHeader of deletedHeaders) {
6705
+ if (header > deletedHeader) {
6706
+ header--;
6707
+ }
6708
+ else if (header === deletedHeader) {
6709
+ return undefined;
6710
+ }
6711
+ }
6712
+ return header;
6713
+ })
6714
+ .filter(isDefined);
6715
+ }
6716
+ function getNextSheetName(existingNames, baseName = "Sheet") {
6717
+ let i = 1;
6718
+ let name = `${baseName}${i}`;
6719
+ while (existingNames.includes(name)) {
6720
+ name = `${baseName}${i}`;
6721
+ i++;
6722
+ }
6723
+ return name;
6724
+ }
6725
+ function getDuplicateSheetName(nameToDuplicate, existingNames) {
6726
+ let i = 1;
6727
+ const baseName = _t("Copy of %s", nameToDuplicate);
6728
+ let name = baseName.toString();
6729
+ while (existingNames.includes(name)) {
6730
+ name = `${baseName} (${i})`;
6731
+ i++;
6732
+ }
6733
+ return name;
6734
+ }
6735
+ function isSheetNameEqual(name1, name2) {
6736
+ if (name1 === undefined || name2 === undefined) {
6737
+ return false;
6738
+ }
6739
+ return (getUnquotedSheetName(name1.trim().toUpperCase()) ===
6740
+ getUnquotedSheetName(name2.trim().toUpperCase()));
6741
+ }
6742
+
6744
6743
  function computeTextLinesHeight(textLineHeight, numberOfLines = 1) {
6745
6744
  return numberOfLines * (textLineHeight + MIN_CELL_TEXT_MARGIN) - MIN_CELL_TEXT_MARGIN;
6746
6745
  }
6747
6746
  /**
6748
6747
  * Get the default height of the cell given its style.
6749
6748
  */
6750
- function getDefaultCellHeight(ctx, cell, colSize) {
6749
+ function getDefaultCellHeight(ctx, cell, locale, colSize) {
6751
6750
  if (!cell || (!cell.isFormula && !cell.content)) {
6752
6751
  return DEFAULT_CELL_HEIGHT;
6753
6752
  }
6754
- const content = cell.isFormula ? "" : cell.content;
6753
+ let content = "";
6754
+ try {
6755
+ if (!cell.isFormula) {
6756
+ const localeFormat = { format: cell.format, locale };
6757
+ content = formatValue(parseLiteral(cell.content, locale), localeFormat);
6758
+ }
6759
+ }
6760
+ catch {
6761
+ content = CellErrorType.GenericError;
6762
+ }
6755
6763
  return getCellContentHeight(ctx, content, cell.style, colSize);
6756
6764
  }
6757
6765
  function getCellContentHeight(ctx, content, style, colSize) {
@@ -18413,9 +18421,10 @@ function assertDomainLength(domain) {
18413
18421
  throw new EvaluationError(_t("Function PIVOT takes an even number of arguments."));
18414
18422
  }
18415
18423
  }
18416
- function addPivotDependencies(evalContext, coreDefinition, forMeasures) {
18424
+ function addPivotDependencies(evalContext, pivotId, forMeasures) {
18417
18425
  //TODO This function can be very costly when used with PIVOT.VALUE and PIVOT.HEADER
18418
18426
  const dependencies = [];
18427
+ const coreDefinition = evalContext.getters.getPivotCoreDefinition(pivotId);
18419
18428
  if (coreDefinition.type === "SPREADSHEET" && coreDefinition.dataSet) {
18420
18429
  const { sheetId, zone } = coreDefinition.dataSet;
18421
18430
  const xc = zoneToXc(zone);
@@ -18432,8 +18441,7 @@ function addPivotDependencies(evalContext, coreDefinition, forMeasures) {
18432
18441
  }
18433
18442
  for (const measure of forMeasures) {
18434
18443
  if (measure.computedBy) {
18435
- const formula = evalContext.getters.getMeasureCompiledFormula(measure);
18436
- dependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
18444
+ dependencies.push(...evalContext.getters.getMeasureFullDependencies(pivotId, measure));
18437
18445
  }
18438
18446
  }
18439
18447
  const originPosition = evalContext.__originCellPosition;
@@ -18868,7 +18876,7 @@ const PIVOT_VALUE = {
18868
18876
  assertDomainLength(domainArgs);
18869
18877
  const pivot = this.getters.getPivot(pivotId);
18870
18878
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
18871
- addPivotDependencies(this, coreDefinition, coreDefinition.measures.filter((m) => m.id === _measure));
18879
+ addPivotDependencies(this, pivotId, coreDefinition.measures.filter((m) => m.id === _measure));
18872
18880
  pivot.init({ reload: pivot.needsReevaluation });
18873
18881
  const error = pivot.assertIsValid({ throwOnError: false });
18874
18882
  if (error) {
@@ -18901,8 +18909,7 @@ const PIVOT_HEADER = {
18901
18909
  const _pivotId = getPivotId(_pivotFormulaId, this.getters);
18902
18910
  assertDomainLength(domainArgs);
18903
18911
  const pivot = this.getters.getPivot(_pivotId);
18904
- const coreDefinition = this.getters.getPivotCoreDefinition(_pivotId);
18905
- addPivotDependencies(this, coreDefinition, []);
18912
+ addPivotDependencies(this, _pivotId, []);
18906
18913
  pivot.init({ reload: pivot.needsReevaluation });
18907
18914
  const error = pivot.assertIsValid({ throwOnError: false });
18908
18915
  if (error) {
@@ -18956,7 +18963,7 @@ const PIVOT = {
18956
18963
  const pivotId = getPivotId(_pivotFormulaId, this.getters);
18957
18964
  const pivot = this.getters.getPivot(pivotId);
18958
18965
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
18959
- addPivotDependencies(this, coreDefinition, coreDefinition.measures);
18966
+ addPivotDependencies(this, pivotId, coreDefinition.measures);
18960
18967
  pivot.init({ reload: pivot.needsReevaluation });
18961
18968
  const error = pivot.assertIsValid({ throwOnError: false });
18962
18969
  if (error) {
@@ -20185,7 +20192,16 @@ function createComputeFunction(descr) {
20185
20192
  }
20186
20193
  acceptToVectorize.push(!argDefinition.acceptMatrix);
20187
20194
  }
20188
- return applyVectorization(errorHandlingCompute.bind(this), args, acceptToVectorize);
20195
+ return replaceErrorPlaceholderInResult(applyVectorization(errorHandlingCompute.bind(this), args, acceptToVectorize));
20196
+ }
20197
+ function replaceErrorPlaceholderInResult(result) {
20198
+ if (!isMatrix(result)) {
20199
+ replaceFunctionNamePlaceholder(result, descr.name);
20200
+ }
20201
+ else {
20202
+ matrixForEach(result, (result) => replaceFunctionNamePlaceholder(result, descr.name));
20203
+ }
20204
+ return result;
20189
20205
  }
20190
20206
  function errorHandlingCompute(...args) {
20191
20207
  for (let i = 0; i < args.length; i++) {
@@ -20213,13 +20229,12 @@ function createComputeFunction(descr) {
20213
20229
  const result = descr.compute.apply(this, args);
20214
20230
  if (!isMatrix(result)) {
20215
20231
  if (typeof result === "object" && result !== null && "value" in result) {
20216
- replaceFunctionNamePlaceholder(result, descr.name);
20217
20232
  return result;
20218
20233
  }
20234
+ descr.name;
20219
20235
  return { value: result };
20220
20236
  }
20221
20237
  if (typeof result[0][0] === "object" && result[0][0] !== null && "value" in result[0][0]) {
20222
- matrixForEach(result, (result) => replaceFunctionNamePlaceholder(result, descr.name));
20223
20238
  return result;
20224
20239
  }
20225
20240
  return matrixMap(result, (row) => ({ value: row }));
@@ -20671,7 +20686,7 @@ function adaptFormulaStringRanges(defaultSheetId, formula, applyChange) {
20671
20686
  continue;
20672
20687
  }
20673
20688
  const sheetXC = tokens[tokenIdx].value;
20674
- const newSheetXC = adaptStringRange(defaultSheetId, sheetXC, applyChange);
20689
+ const newSheetXC = adaptStringRange(defaultSheetId, sheetXC, applyChange).range;
20675
20690
  if (sheetXC !== newSheetXC) {
20676
20691
  tokens[tokenIdx] = {
20677
20692
  value: newSheetXC,
@@ -20681,23 +20696,30 @@ function adaptFormulaStringRanges(defaultSheetId, formula, applyChange) {
20681
20696
  }
20682
20697
  return concat(tokens.map((token) => token.value));
20683
20698
  }
20684
- function adaptStringRange(defaultSheetId, sheetXC, applyChange) {
20699
+ function adaptStringRange(defaultSheetId, sheetXC, rangeAdapter) {
20685
20700
  const sheetName = splitReference(sheetXC).sheetName;
20686
20701
  if (sheetName
20687
- ? !isSheetNameEqual(sheetName, applyChange.sheetName.old)
20688
- : defaultSheetId !== applyChange.sheetId) {
20689
- return sheetXC;
20702
+ ? !isSheetNameEqual(sheetName, rangeAdapter.sheetName.old)
20703
+ : defaultSheetId !== rangeAdapter.sheetId) {
20704
+ return { changeType: "NONE", range: sheetXC };
20690
20705
  }
20691
- const sheetId = sheetName ? applyChange.sheetId : defaultSheetId;
20706
+ const sheetId = sheetName ? rangeAdapter.sheetId : defaultSheetId;
20692
20707
  const range = getRange(sheetXC, sheetId);
20693
20708
  if (range.invalidXc) {
20694
- return sheetXC;
20709
+ return { changeType: "NONE", range: sheetXC };
20695
20710
  }
20696
- const change = applyChange.applyChange(range);
20711
+ const change = rangeAdapter.applyChange(range);
20697
20712
  if (change.changeType === "NONE" || change.changeType === "REMOVE") {
20698
- return sheetXC;
20713
+ return { changeType: change.changeType, range: sheetXC };
20699
20714
  }
20700
- return getRangeString(change.range, defaultSheetId, getSheetNameGetter(applyChange));
20715
+ const rangeStr = getRangeString(change.range, defaultSheetId, getSheetNameGetter(rangeAdapter));
20716
+ if (rangeStr === CellErrorType.InvalidReference) {
20717
+ return { changeType: "REMOVE", range: rangeStr };
20718
+ }
20719
+ return {
20720
+ changeType: change.changeType,
20721
+ range: rangeStr,
20722
+ };
20701
20723
  }
20702
20724
  function getSheetNameGetter(applyChange) {
20703
20725
  return (sheetId) => {
@@ -20796,8 +20818,6 @@ function adaptChartRange(range, applyChange) {
20796
20818
  }
20797
20819
  const change = applyChange(range);
20798
20820
  switch (change.changeType) {
20799
- case "NONE":
20800
- return range;
20801
20821
  case "REMOVE":
20802
20822
  return undefined;
20803
20823
  default:
@@ -20935,16 +20955,16 @@ function toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel) {
20935
20955
  function transformChartDefinitionWithDataSetsWithZone(chartSheetId, definition, applyChange) {
20936
20956
  let labelRange;
20937
20957
  if (definition.labelRange) {
20938
- const adaptedRange = adaptStringRange(chartSheetId, definition.labelRange, applyChange);
20939
- if (adaptedRange !== CellErrorType.InvalidReference) {
20958
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.labelRange, applyChange);
20959
+ if (changeType !== "REMOVE") {
20940
20960
  labelRange = adaptedRange;
20941
20961
  }
20942
20962
  }
20943
20963
  const dataSets = [];
20944
20964
  for (const dataSet of definition.dataSets) {
20945
20965
  const newDataSet = { ...dataSet };
20946
- const adaptedRange = adaptStringRange(chartSheetId, dataSet.dataRange, applyChange);
20947
- if (adaptedRange !== CellErrorType.InvalidReference) {
20966
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, dataSet.dataRange, applyChange);
20967
+ if (changeType !== "REMOVE") {
20948
20968
  newDataSet.dataRange = adaptedRange;
20949
20969
  dataSets.push(newDataSet);
20950
20970
  }
@@ -22270,14 +22290,14 @@ let ScorecardChart$1 = class ScorecardChart extends AbstractChart {
22270
22290
  let baseline;
22271
22291
  let keyValue;
22272
22292
  if (definition.baseline) {
22273
- const adaptedRange = adaptStringRange(chartSheetId, definition.baseline, applyChange);
22274
- if (adaptedRange !== CellErrorType.InvalidReference) {
22293
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.baseline, applyChange);
22294
+ if (changeType !== "REMOVE") {
22275
22295
  baseline = adaptedRange;
22276
22296
  }
22277
22297
  }
22278
22298
  if (definition.keyValue) {
22279
- const adaptedRange = adaptStringRange(chartSheetId, definition.keyValue, applyChange);
22280
- if (adaptedRange !== CellErrorType.InvalidReference) {
22299
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.keyValue, applyChange);
22300
+ if (changeType !== "REMOVE") {
22281
22301
  keyValue = adaptedRange;
22282
22302
  }
22283
22303
  }
@@ -22333,7 +22353,7 @@ let ScorecardChart$1 = class ScorecardChart extends AbstractChart {
22333
22353
  // This kind of graph is not exportable in Excel
22334
22354
  return undefined;
22335
22355
  }
22336
- updateRanges(applyChange) {
22356
+ updateRanges({ applyChange }) {
22337
22357
  const baseline = adaptChartRange(this.baseline, applyChange);
22338
22358
  const keyValue = adaptChartRange(this.keyValue, applyChange);
22339
22359
  if (this.baseline === baseline && this.keyValue === keyValue) {
@@ -23228,7 +23248,7 @@ class AbstractComposerStore extends SpreadsheetStore {
23228
23248
  }
23229
23249
  captureSelection(zone, col, row) {
23230
23250
  this.model.selection.capture(this, {
23231
- cell: { col: col ?? zone.left, row: row ?? zone.right },
23251
+ cell: { col: col ?? zone.left, row: row ?? zone.top },
23232
23252
  zone,
23233
23253
  }, {
23234
23254
  handleEvent: this.handleEvent.bind(this),
@@ -27205,7 +27225,7 @@ class BarChart extends AbstractChart {
27205
27225
  verticalAxis: getDefinedAxis(definition),
27206
27226
  };
27207
27227
  }
27208
- updateRanges(applyChange) {
27228
+ updateRanges({ applyChange }) {
27209
27229
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27210
27230
  if (!isStale) {
27211
27231
  return this;
@@ -27326,7 +27346,7 @@ class ComboChart extends AbstractChart {
27326
27346
  verticalAxis: getDefinedAxis(definition),
27327
27347
  };
27328
27348
  }
27329
- updateRanges(applyChange) {
27349
+ updateRanges({ applyChange }) {
27330
27350
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27331
27351
  if (!isStale) {
27332
27352
  return this;
@@ -27497,7 +27517,7 @@ class FunnelChart extends AbstractChart {
27497
27517
  getDefinitionForExcel() {
27498
27518
  return undefined;
27499
27519
  }
27500
- updateRanges(applyChange) {
27520
+ updateRanges({ applyChange }) {
27501
27521
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27502
27522
  if (!isStale) {
27503
27523
  return this;
@@ -27608,8 +27628,8 @@ class GaugeChart extends AbstractChart {
27608
27628
  static transformDefinition(chartSheetId, definition, applyChange) {
27609
27629
  let dataRange;
27610
27630
  if (definition.dataRange) {
27611
- const adaptedRange = adaptStringRange(chartSheetId, definition.dataRange, applyChange);
27612
- if (adaptedRange !== CellErrorType.InvalidReference) {
27631
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.dataRange, applyChange);
27632
+ if (changeType !== "REMOVE") {
27613
27633
  dataRange = adaptedRange;
27614
27634
  }
27615
27635
  }
@@ -27684,13 +27704,9 @@ class GaugeChart extends AbstractChart {
27684
27704
  : undefined,
27685
27705
  };
27686
27706
  }
27687
- updateRanges(applyChange, sheetId, adaptSheetName) {
27707
+ updateRanges({ applyChange, adaptFormulaString }) {
27688
27708
  const dataRange = adaptChartRange(this.dataRange, applyChange);
27689
- const adaptFormula = (formula) => adaptFormulaStringRanges(this.sheetId, formula, {
27690
- applyChange,
27691
- sheetId,
27692
- sheetName: adaptSheetName,
27693
- });
27709
+ const adaptFormula = (formula) => adaptFormulaString(this.sheetId, formula);
27694
27710
  const sectionRule = adaptSectionRuleFormulas(this.sectionRule, adaptFormula);
27695
27711
  const definition = this.getDefinitionWithSpecificRanges(dataRange, sectionRule);
27696
27712
  return new GaugeChart(definition, this.sheetId, this.getters);
@@ -27910,7 +27926,7 @@ class GeoChart extends AbstractChart {
27910
27926
  getDefinitionForExcel() {
27911
27927
  return undefined;
27912
27928
  }
27913
- updateRanges(applyChange) {
27929
+ updateRanges({ applyChange }) {
27914
27930
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27915
27931
  if (!isStale) {
27916
27932
  return this;
@@ -28042,7 +28058,7 @@ class LineChart extends AbstractChart {
28042
28058
  : undefined,
28043
28059
  };
28044
28060
  }
28045
- updateRanges(applyChange) {
28061
+ updateRanges({ applyChange }) {
28046
28062
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28047
28063
  if (!isStale) {
28048
28064
  return this;
@@ -28199,7 +28215,7 @@ class PieChart extends AbstractChart {
28199
28215
  labelRange,
28200
28216
  };
28201
28217
  }
28202
- updateRanges(applyChange) {
28218
+ updateRanges({ applyChange }) {
28203
28219
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28204
28220
  if (!isStale) {
28205
28221
  return this;
@@ -28335,7 +28351,7 @@ class PyramidChart extends AbstractChart {
28335
28351
  getDefinitionForExcel() {
28336
28352
  return undefined;
28337
28353
  }
28338
- updateRanges(applyChange) {
28354
+ updateRanges({ applyChange }) {
28339
28355
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28340
28356
  if (!isStale) {
28341
28357
  return this;
@@ -28482,7 +28498,7 @@ class RadarChart extends AbstractChart {
28482
28498
  labelRange,
28483
28499
  };
28484
28500
  }
28485
- updateRanges(applyChange) {
28501
+ updateRanges({ applyChange }) {
28486
28502
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28487
28503
  if (!isStale) {
28488
28504
  return this;
@@ -28604,7 +28620,7 @@ class ScatterChart extends AbstractChart {
28604
28620
  : undefined,
28605
28621
  };
28606
28622
  }
28607
- updateRanges(applyChange) {
28623
+ updateRanges({ applyChange }) {
28608
28624
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28609
28625
  if (!isStale) {
28610
28626
  return this;
@@ -28766,7 +28782,7 @@ class SunburstChart extends AbstractChart {
28766
28782
  getDefinitionForExcel() {
28767
28783
  return undefined;
28768
28784
  }
28769
- updateRanges(applyChange) {
28785
+ updateRanges({ applyChange }) {
28770
28786
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28771
28787
  if (!isStale) {
28772
28788
  return this;
@@ -28914,7 +28930,7 @@ class TreeMapChart extends AbstractChart {
28914
28930
  getDefinitionForExcel() {
28915
28931
  return undefined;
28916
28932
  }
28917
- updateRanges(applyChange) {
28933
+ updateRanges({ applyChange }) {
28918
28934
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28919
28935
  if (!isStale) {
28920
28936
  return this;
@@ -29069,7 +29085,7 @@ class WaterfallChart extends AbstractChart {
29069
29085
  // TODO: implement export excel
29070
29086
  return undefined;
29071
29087
  }
29072
- updateRanges(applyChange) {
29088
+ updateRanges({ applyChange }) {
29073
29089
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
29074
29090
  if (!isStale) {
29075
29091
  return this;
@@ -31937,6 +31953,7 @@ function extractStyle(data, content, styleId, formatId, borderId) {
31937
31953
  ? V_ALIGNMENT_EXPORT_CONVERSION_MAP[style.verticalAlign]
31938
31954
  : undefined,
31939
31955
  wrapText: style.wrapping === "wrap" || content?.includes(NEWLINE) ? true : undefined,
31956
+ shrinkToFit: style.wrapping === "clip" ? true : undefined,
31940
31957
  },
31941
31958
  };
31942
31959
  styles.font["strike"] = !!style?.strikethrough || undefined;
@@ -31957,6 +31974,7 @@ function normalizeStyle(construct, styles) {
31957
31974
  vertical: styles.alignment.vertical,
31958
31975
  horizontal: styles.alignment.horizontal,
31959
31976
  wrapText: styles.alignment.wrapText,
31977
+ shrinkToFit: styles.alignment.shrinkToFit,
31960
31978
  },
31961
31979
  };
31962
31980
  return pushElement(style, construct.styles);
@@ -42961,7 +42979,7 @@ class GaugeChartConfigPanel extends Component {
42961
42979
  });
42962
42980
  dataRange = this.props.definition.dataRange;
42963
42981
  get configurationErrorMessages() {
42964
- const cancelledReasons = [...(this.state.dataRangeDispatchResult?.reasons || [])];
42982
+ const cancelledReasons = [...(this.state.dataRangeDispatchResult?.reasons || [])].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
42965
42983
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
42966
42984
  }
42967
42985
  get isDataRangeInvalid() {
@@ -44385,7 +44403,7 @@ class GaugeChartDesignPanel extends Component {
44385
44403
  });
44386
44404
  }
44387
44405
  get designErrorMessages() {
44388
- const cancelledReasons = [...(this.state.sectionRuleCancelledReasons || [])];
44406
+ const cancelledReasons = [...(this.state.sectionRuleCancelledReasons || [])].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
44389
44407
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
44390
44408
  }
44391
44409
  get isRangeMinInvalid() {
@@ -44721,7 +44739,7 @@ class ScorecardChartConfigPanel extends Component {
44721
44739
  const cancelledReasons = [
44722
44740
  ...(this.state.keyValueDispatchResult?.reasons || []),
44723
44741
  ...(this.state.baselineDispatchResult?.reasons || []),
44724
- ];
44742
+ ].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
44725
44743
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
44726
44744
  }
44727
44745
  get isKeyValueInvalid() {
@@ -47616,6 +47634,12 @@ class FindAndReplaceStore extends SpreadsheetStore {
47616
47634
  case "ACTIVATE_SHEET":
47617
47635
  this.isSearchDirty = true;
47618
47636
  this.shouldFinalizeUpdateSelection = true;
47637
+ if (this.searchOptions.specificRange) {
47638
+ this.searchOptions.specificRange = {
47639
+ ...this.searchOptions.specificRange,
47640
+ sheetId: this.getters.getActiveSheetId(),
47641
+ };
47642
+ }
47619
47643
  break;
47620
47644
  case "REPLACE_SEARCH":
47621
47645
  for (const match of cmd.matches) {
@@ -48037,9 +48061,20 @@ class FindAndReplacePanel extends Component {
48037
48061
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
48038
48062
  this.store.updateSearchOptions({ specificRange });
48039
48063
  }
48064
+ get specificRange() {
48065
+ const range = this.store.searchOptions.specificRange;
48066
+ return range ? this.env.model.getters.getRangeString(range, "forceSheetReference") : "";
48067
+ }
48040
48068
  get pendingSearch() {
48041
48069
  return this.updateSearchContent.isDebouncePending();
48042
48070
  }
48071
+ get selectionInputKey() {
48072
+ // Selections input are made to work with objects linked to a sheet id. They store the active sheet id at their creation,
48073
+ // and have specific behaviour linked to it (eg. go back to the initial sheet after confirmation).
48074
+ // We don't want all those behaviors here, so we force the recreation of the component when the active sheet changes.
48075
+ // The only drawback is that the input loses focus when changing sheet.
48076
+ return this.env.model.getters.getActiveSheetId();
48077
+ }
48043
48078
  }
48044
48079
 
48045
48080
  css /* scss */ `
@@ -50309,8 +50344,6 @@ function adaptPivotRange(range, applyChange) {
50309
50344
  }
50310
50345
  const change = applyChange(range);
50311
50346
  switch (change.changeType) {
50312
- case "NONE":
50313
- return range;
50314
50347
  case "REMOVE":
50315
50348
  return undefined;
50316
50349
  default:
@@ -57373,7 +57406,7 @@ class CorePlugin extends BasePlugin {
57373
57406
  * @param sheetId an sheetId to adapt either range of that sheet specifically, or ranges pointing to that sheet
57374
57407
  * @param sheetName couple of old and new sheet names to adapt ranges pointing to that sheet
57375
57408
  */
57376
- adaptRanges(applyChange, sheetId, sheetName) { }
57409
+ adaptRanges(rangeAdapterFunctions, sheetId, sheetName) { }
57377
57410
  /**
57378
57411
  * Implement this method to clean unused external resources, such as images
57379
57412
  * stored on a server which have been deleted.
@@ -57969,7 +58002,7 @@ class CellPlugin extends CorePlugin {
57969
58002
  ];
57970
58003
  nextId = 1;
57971
58004
  cells = {};
57972
- adaptRanges(applyChange, sheetId, sheetName) {
58005
+ adaptRanges({ applyChange }, sheetId, sheetName) {
57973
58006
  for (const sheet of Object.keys(this.cells)) {
57974
58007
  for (const cell of Object.values(this.cells[sheet] || {})) {
57975
58008
  if (cell.isFormula) {
@@ -58191,7 +58224,7 @@ class CellPlugin extends CorePlugin {
58191
58224
  for (const position of positions) {
58192
58225
  const cell = this.getters.getCell(position);
58193
58226
  const xc = toXC(position.col, position.row);
58194
- const style = this.removeDefaultStyleValues(cell.style);
58227
+ const style = this.extractCustomStyle(cell);
58195
58228
  if (Object.keys(style).length) {
58196
58229
  const styleId = getItemId(style, styles);
58197
58230
  positionsByStyle[styleId] ??= [];
@@ -58237,10 +58270,14 @@ class CellPlugin extends CorePlugin {
58237
58270
  }
58238
58271
  }
58239
58272
  }
58240
- removeDefaultStyleValues(style) {
58241
- const cleanedStyle = { ...style };
58242
- for (const property in DEFAULT_STYLE) {
58243
- if (cleanedStyle[property] === DEFAULT_STYLE[property]) {
58273
+ extractCustomStyle(cell) {
58274
+ const cleanedStyle = { ...cell.style };
58275
+ const defaultStyle = isNumber(cell.content, DEFAULT_LOCALE)
58276
+ ? DEFAULT_NUMBER_STYLE
58277
+ : DEFAULT_STYLE;
58278
+ for (const property in cleanedStyle) {
58279
+ if ((property !== "align" || !cell.isFormula) &&
58280
+ cleanedStyle[property] === defaultStyle[property]) {
58244
58281
  delete cleanedStyle[property];
58245
58282
  }
58246
58283
  }
@@ -58590,9 +58627,9 @@ class ChartPlugin extends CorePlugin {
58590
58627
  charts = {};
58591
58628
  createChart = chartFactory(this.getters);
58592
58629
  validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
58593
- adaptRanges(applyChange, sheetId, adaptSheetName) {
58630
+ adaptRanges(rangeAdapters) {
58594
58631
  for (const [chartId, chart] of Object.entries(this.charts)) {
58595
- this.history.update("charts", chartId, chart?.updateRanges(applyChange, sheetId, adaptSheetName));
58632
+ this.history.update("charts", chartId, chart?.updateRanges(rangeAdapters));
58596
58633
  }
58597
58634
  }
58598
58635
  // ---------------------------------------------------------------------------
@@ -58782,7 +58819,7 @@ class ConditionalFormatPlugin extends CorePlugin {
58782
58819
  "getAdaptedCfRanges",
58783
58820
  ];
58784
58821
  cfRules = {};
58785
- adaptCFFormulas(applyChange) {
58822
+ adaptCFFormulas({ applyChange, adaptFormulaString }) {
58786
58823
  for (const sheetId in this.cfRules) {
58787
58824
  for (const rule of this.cfRules[sheetId]) {
58788
58825
  if (rule.rule.type === "DataBarRule" && rule.rule.rangeValues) {
@@ -58806,7 +58843,7 @@ class ConditionalFormatPlugin extends CorePlugin {
58806
58843
  for (let i = 0; i < rule.rule.values.length; i++) {
58807
58844
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
58808
58845
  //@ts-expect-error
58809
- "values", i, this.getters.adaptFormulaStringDependencies(sheetId, rule.rule.values[i], applyChange));
58846
+ "values", i, adaptFormulaString(sheetId, rule.rule.values[i]));
58810
58847
  }
58811
58848
  }
58812
58849
  else if (rule.rule.type === "IconSetRule") {
@@ -58814,7 +58851,7 @@ class ConditionalFormatPlugin extends CorePlugin {
58814
58851
  if (rule.rule[inflectionPoint].type === "formula") {
58815
58852
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
58816
58853
  //@ts-expect-error
58817
- inflectionPoint, "value", this.getters.adaptFormulaStringDependencies(sheetId, rule.rule[inflectionPoint].value, applyChange));
58854
+ inflectionPoint, "value", adaptFormulaString(sheetId, rule.rule[inflectionPoint].value));
58818
58855
  }
58819
58856
  }
58820
58857
  }
@@ -58824,14 +58861,14 @@ class ConditionalFormatPlugin extends CorePlugin {
58824
58861
  if (ruleValue?.type === "formula" && ruleValue?.value) {
58825
58862
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
58826
58863
  //@ts-expect-error
58827
- value, "value", this.getters.adaptFormulaStringDependencies(sheetId, ruleValue.value, applyChange));
58864
+ value, "value", adaptFormulaString(sheetId, ruleValue.value));
58828
58865
  }
58829
58866
  }
58830
58867
  }
58831
58868
  }
58832
58869
  }
58833
58870
  }
58834
- adaptCFRanges(sheetId, applyChange) {
58871
+ adaptCFRanges(sheetId, { applyChange }) {
58835
58872
  for (const rule of this.cfRules[sheetId]) {
58836
58873
  for (const range of rule.ranges) {
58837
58874
  const change = applyChange(range);
@@ -58855,12 +58892,12 @@ class ConditionalFormatPlugin extends CorePlugin {
58855
58892
  }
58856
58893
  }
58857
58894
  }
58858
- adaptRanges(applyChange, sheetId) {
58895
+ adaptRanges(rangeAdapters, sheetId) {
58859
58896
  const sheetIds = sheetId ? [sheetId] : Object.keys(this.cfRules);
58860
58897
  for (const sheetId of sheetIds) {
58861
- this.adaptCFRanges(sheetId, applyChange);
58898
+ this.adaptCFRanges(sheetId, rangeAdapters);
58862
58899
  }
58863
- this.adaptCFFormulas(applyChange);
58900
+ this.adaptCFFormulas(rangeAdapters);
58864
58901
  }
58865
58902
  // ---------------------------------------------------------------------------
58866
58903
  // Command Handling
@@ -59251,23 +59288,23 @@ class DataValidationPlugin extends CorePlugin {
59251
59288
  "getValidationRuleForCell",
59252
59289
  ];
59253
59290
  rules = {};
59254
- adaptRanges(applyChange, sheetId) {
59255
- this.adaptDVRanges(sheetId, applyChange);
59256
- this.adaptDVFormulas(applyChange);
59291
+ adaptRanges(rangeAdapters, sheetId) {
59292
+ this.adaptDVRanges(sheetId, rangeAdapters);
59293
+ this.adaptDVFormulas(rangeAdapters);
59257
59294
  }
59258
- adaptDVFormulas(applyChange) {
59295
+ adaptDVFormulas({ adaptFormulaString }) {
59259
59296
  for (const sheetId in this.rules) {
59260
59297
  const rules = this.rules[sheetId];
59261
59298
  for (let ruleIndex = rules.length - 1; ruleIndex >= 0; ruleIndex--) {
59262
59299
  const rule = this.rules[sheetId][ruleIndex];
59263
59300
  for (let valueIndex = 0; valueIndex < rule.criterion.values.length; valueIndex++) {
59264
- const value = this.getters.adaptFormulaStringDependencies(sheetId, rule.criterion.values[valueIndex], applyChange);
59301
+ const value = adaptFormulaString(sheetId, rule.criterion.values[valueIndex]);
59265
59302
  this.history.update("rules", sheetId, ruleIndex, "criterion", "values", valueIndex, value);
59266
59303
  }
59267
59304
  }
59268
59305
  }
59269
59306
  }
59270
- adaptDVRanges(sheetId, applyChange) {
59307
+ adaptDVRanges(sheetId, { applyChange }) {
59271
59308
  const rules = this.rules[sheetId];
59272
59309
  for (let ruleIndex = rules.length - 1; ruleIndex >= 0; ruleIndex--) {
59273
59310
  const rule = this.rules[sheetId][ruleIndex];
@@ -59541,7 +59578,7 @@ class FigurePlugin extends CorePlugin {
59541
59578
  // ---------------------------------------------------------------------------
59542
59579
  // Command Handling
59543
59580
  // ---------------------------------------------------------------------------
59544
- adaptRanges(applyChange, sheetId) {
59581
+ adaptRanges({ applyChange }, sheetId) {
59545
59582
  for (const figure of this.getFigures(sheetId)) {
59546
59583
  const change = applyChange(this.getters.getRangeFromZone(sheetId, {
59547
59584
  left: figure.col,
@@ -60348,8 +60385,8 @@ class MergePlugin extends CorePlugin {
60348
60385
  break;
60349
60386
  }
60350
60387
  }
60351
- adaptRanges(applyChange, sheetId) {
60352
- this.applyRangeChangeOnSheet(sheetId, applyChange);
60388
+ adaptRanges(rangeAdapters, sheetId) {
60389
+ this.applyRangeChangeOnSheet(sheetId, rangeAdapters);
60353
60390
  }
60354
60391
  // ---------------------------------------------------------------------------
60355
60392
  // Getters
@@ -60654,7 +60691,7 @@ class MergePlugin extends CorePlugin {
60654
60691
  /**
60655
60692
  * Apply a range change on merges of a particular sheet.
60656
60693
  */
60657
- applyRangeChangeOnSheet(sheetId, applyChange) {
60694
+ applyRangeChangeOnSheet(sheetId, { applyChange }) {
60658
60695
  const merges = Object.entries(this.merges[sheetId] || {});
60659
60696
  for (const [mergeId, range] of merges) {
60660
60697
  if (range) {
@@ -60728,7 +60765,7 @@ function rangeToMerge(mergeId, range) {
60728
60765
  };
60729
60766
  }
60730
60767
 
60731
- class RangeAdapter {
60768
+ class RangeAdapterPlugin {
60732
60769
  getters;
60733
60770
  providers = [];
60734
60771
  isAdaptingRanges = false;
@@ -60736,7 +60773,6 @@ class RangeAdapter {
60736
60773
  this.getters = getters;
60737
60774
  }
60738
60775
  static getters = [
60739
- "adaptFormulaStringDependencies",
60740
60776
  "copyFormulaStringForSheet",
60741
60777
  "extendRange",
60742
60778
  "getRangeString",
@@ -60767,8 +60803,8 @@ class RangeAdapter {
60767
60803
  throw new Error("Plugins cannot dispatch commands during adaptRanges phase");
60768
60804
  }
60769
60805
  const rangeAdapter = getRangeAdapter(cmd);
60770
- if (rangeAdapter?.applyChange) {
60771
- this.executeOnAllRanges(rangeAdapter.applyChange, rangeAdapter.sheetId, rangeAdapter.sheetName);
60806
+ if (rangeAdapter) {
60807
+ this.executeOnAllRanges(rangeAdapter);
60772
60808
  }
60773
60809
  }
60774
60810
  finalize() { }
@@ -60787,11 +60823,15 @@ class RangeAdapter {
60787
60823
  return result;
60788
60824
  };
60789
60825
  }
60790
- executeOnAllRanges(adaptRange, sheetId, sheetName) {
60826
+ executeOnAllRanges(rangeAdapter) {
60791
60827
  this.isAdaptingRanges = true;
60792
- const func = this.verifyRangeRemoved(adaptRange);
60828
+ const adapterFunctions = {
60829
+ applyChange: this.verifyRangeRemoved(rangeAdapter.applyChange),
60830
+ adaptRangeString: (defaultSheetId, sheetXC) => adaptStringRange(defaultSheetId, sheetXC, rangeAdapter),
60831
+ adaptFormulaString: (defaultSheetId, formula) => adaptFormulaStringRanges(defaultSheetId, formula, rangeAdapter),
60832
+ };
60793
60833
  for (const provider of this.providers) {
60794
- provider(func, sheetId, sheetName);
60834
+ provider(adapterFunctions, rangeAdapter.sheetId, rangeAdapter.sheetName);
60795
60835
  }
60796
60836
  this.isAdaptingRanges = false;
60797
60837
  }
@@ -60959,18 +60999,6 @@ class RangeAdapter {
60959
60999
  const unionOfZones = unionUnboundedZones(...zones);
60960
61000
  return this.getRangeFromZone(ranges[0].sheetId, unionOfZones);
60961
61001
  }
60962
- adaptFormulaStringDependencies(sheetId, formula, applyChange) {
60963
- if (!formula.startsWith("=")) {
60964
- return formula;
60965
- }
60966
- const compiledFormula = compile(formula);
60967
- const updatedDependencies = compiledFormula.dependencies.map((dep) => {
60968
- const range = this.getters.getRangeFromSheetXC(sheetId, dep);
60969
- const changedRange = applyChange(range);
60970
- return changedRange.changeType === "NONE" ? range : changedRange.range;
60971
- });
60972
- return this.getters.getFormulaString(sheetId, compiledFormula.tokens, updatedDependencies);
60973
- }
60974
61002
  /**
60975
61003
  * Copy a formula string to another sheet.
60976
61004
  *
@@ -61863,7 +61891,7 @@ class TablePlugin extends CorePlugin {
61863
61891
  static getters = ["getCoreTable", "getCoreTables", "getCoreTableMatchingTopLeft"];
61864
61892
  tables = {};
61865
61893
  nextTableId = 1;
61866
- adaptRanges(applyChange, sheetId) {
61894
+ adaptRanges({ applyChange }, sheetId) {
61867
61895
  for (const table of this.getCoreTables(sheetId)) {
61868
61896
  this.applyRangeChangeOnTable(sheetId, table, applyChange);
61869
61897
  }
@@ -62741,6 +62769,7 @@ class PivotCorePlugin extends CorePlugin {
62741
62769
  "getMeasureCompiledFormula",
62742
62770
  "getPivotName",
62743
62771
  "isExistingPivot",
62772
+ "getMeasureFullDependencies",
62744
62773
  ];
62745
62774
  nextFormulaId = 1;
62746
62775
  pivots = {};
@@ -62823,12 +62852,12 @@ class PivotCorePlugin extends CorePlugin {
62823
62852
  }
62824
62853
  case "UPDATE_PIVOT": {
62825
62854
  this.history.update("pivots", cmd.pivotId, "definition", this.repairSortedColumn(deepCopy(cmd.pivot)));
62826
- this.compileCalculatedMeasures(cmd.pivot.measures);
62855
+ this.compileCalculatedMeasures(cmd.pivotId, cmd.pivot.measures);
62827
62856
  break;
62828
62857
  }
62829
62858
  }
62830
62859
  }
62831
- adaptRanges(applyChange) {
62860
+ adaptRanges({ applyChange, adaptFormulaString }) {
62832
62861
  for (const pivotId in this.pivots) {
62833
62862
  const definition = deepCopy(this.pivots[pivotId]?.definition);
62834
62863
  if (!definition) {
@@ -62841,22 +62870,22 @@ class PivotCorePlugin extends CorePlugin {
62841
62870
  this.history.update("pivots", pivotId, "definition", newDefinition);
62842
62871
  }
62843
62872
  }
62844
- for (const sheetId in this.compiledMeasureFormulas) {
62845
- for (const formulaString in this.compiledMeasureFormulas[sheetId]) {
62846
- const compiledFormula = this.compiledMeasureFormulas[sheetId][formulaString];
62847
- const newDependencies = [];
62848
- for (const range of compiledFormula.dependencies) {
62849
- const change = applyChange(range);
62850
- if (change.changeType === "NONE") {
62851
- newDependencies.push(range);
62852
- }
62853
- else {
62854
- newDependencies.push(change.range);
62855
- }
62873
+ for (const pivotId in this.compiledMeasureFormulas) {
62874
+ for (const measureId in this.compiledMeasureFormulas[pivotId]) {
62875
+ const measure = this.pivots[pivotId]?.definition.measures.find((m) => m.id === measureId);
62876
+ if (!measure || !measure.computedBy) {
62877
+ continue;
62856
62878
  }
62857
- const newFormulaString = this.getters.getFormulaString(sheetId, compiledFormula.tokens, newDependencies);
62858
- if (newFormulaString !== formulaString) {
62859
- this.replaceMeasureFormula(sheetId, formulaString, newFormulaString);
62879
+ const sheetId = measure.computedBy.sheetId;
62880
+ const { formula: compiledFormula, dependencies: indirectDependencies } = this.compiledMeasureFormulas[pivotId][measureId];
62881
+ // adapt direct dependencies
62882
+ this.history.update("compiledMeasureFormulas", pivotId, measureId, "formula", "dependencies", compiledFormula.dependencies.map((range) => applyChange(range).range));
62883
+ // adapt all dependencies (including indirect)
62884
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", indirectDependencies.map((range) => applyChange(range).range));
62885
+ const oldFormulaString = measure.computedBy.formula;
62886
+ const newFormulaString = adaptFormulaString(sheetId, oldFormulaString);
62887
+ if (newFormulaString !== oldFormulaString) {
62888
+ this.replaceMeasureFormula(pivotId, measure, newFormulaString);
62860
62889
  }
62861
62890
  }
62862
62891
  }
@@ -62894,12 +62923,17 @@ class PivotCorePlugin extends CorePlugin {
62894
62923
  isExistingPivot(pivotId) {
62895
62924
  return pivotId in this.pivots;
62896
62925
  }
62897
- getMeasureCompiledFormula(measure) {
62926
+ getMeasureCompiledFormula(pivotId, measure) {
62927
+ if (!measure.computedBy) {
62928
+ throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
62929
+ }
62930
+ return this.compiledMeasureFormulas[pivotId][measure.id].formula;
62931
+ }
62932
+ getMeasureFullDependencies(pivotId, measure) {
62898
62933
  if (!measure.computedBy) {
62899
62934
  throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
62900
62935
  }
62901
- const sheetId = measure.computedBy.sheetId;
62902
- return this.compiledMeasureFormulas[sheetId][measure.computedBy.formula];
62936
+ return this.compiledMeasureFormulas[pivotId][measure.id].dependencies;
62903
62937
  }
62904
62938
  // -------------------------------------------------------------------------
62905
62939
  // Private
@@ -62909,18 +62943,42 @@ class PivotCorePlugin extends CorePlugin {
62909
62943
  definition: this.repairSortedColumn(deepCopy(pivot)),
62910
62944
  formulaId,
62911
62945
  });
62912
- this.compileCalculatedMeasures(pivot.measures);
62946
+ this.compileCalculatedMeasures(pivotId, pivot.measures);
62913
62947
  this.history.update("formulaIds", formulaId, pivotId);
62914
62948
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
62915
62949
  }
62916
- compileCalculatedMeasures(measures) {
62950
+ compileCalculatedMeasures(pivotId, measures) {
62917
62951
  for (const measure of measures) {
62918
62952
  if (measure.computedBy) {
62919
- const sheetId = measure.computedBy.sheetId;
62920
62953
  const compiledFormula = this.compileMeasureFormula(measure.computedBy.sheetId, measure.computedBy.formula);
62921
- this.history.update("compiledMeasureFormulas", sheetId, measure.computedBy.formula, compiledFormula);
62954
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "formula", compiledFormula);
62922
62955
  }
62923
62956
  }
62957
+ for (const measure of measures) {
62958
+ if (measure.computedBy) {
62959
+ const dependencies = this.computeMeasureFullDependencies(pivotId, measure);
62960
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", dependencies);
62961
+ }
62962
+ }
62963
+ }
62964
+ computeMeasureFullDependencies(pivotId, measure, exploredMeasures = new Set()) {
62965
+ const rangeDependencies = [];
62966
+ const definition = this.getPivotCoreDefinition(pivotId);
62967
+ const formula = this.getMeasureCompiledFormula(pivotId, measure);
62968
+ exploredMeasures.add(measure.id);
62969
+ for (const token of formula.tokens) {
62970
+ if (token.type !== "SYMBOL") {
62971
+ continue;
62972
+ }
62973
+ const otherMeasure = definition.measures.find((measureCandidate) => getCanonicalSymbolName(measureCandidate.id) === token.value &&
62974
+ measure.id !== measureCandidate.id);
62975
+ if (!otherMeasure || exploredMeasures.has(otherMeasure.id) || !otherMeasure.computedBy) {
62976
+ continue;
62977
+ }
62978
+ rangeDependencies.push(...this.computeMeasureFullDependencies(pivotId, otherMeasure, exploredMeasures));
62979
+ }
62980
+ rangeDependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
62981
+ return rangeDependencies;
62924
62982
  }
62925
62983
  insertPivot(position, formulaId, table) {
62926
62984
  this.resizeSheet(position.sheetId, position, table);
@@ -62980,21 +63038,16 @@ class PivotCorePlugin extends CorePlugin {
62980
63038
  dependencies: rangeDependencies,
62981
63039
  };
62982
63040
  }
62983
- replaceMeasureFormula(sheetId, formulaString, newFormulaString) {
62984
- this.history.update("compiledMeasureFormulas", sheetId, formulaString, undefined);
62985
- this.history.update("compiledMeasureFormulas", sheetId, newFormulaString, this.compileMeasureFormula(sheetId, newFormulaString));
62986
- for (const pivotId in this.pivots) {
62987
- const pivot = this.pivots[pivotId];
62988
- if (!pivot) {
62989
- continue;
62990
- }
62991
- for (const measure of pivot.definition.measures) {
62992
- if (measure.computedBy?.formula === formulaString) {
62993
- const measureIndex = pivot.definition.measures.indexOf(measure);
62994
- this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", { formula: newFormulaString, sheetId });
62995
- }
62996
- }
63041
+ replaceMeasureFormula(pivotId, measure, newFormulaString) {
63042
+ const pivot = this.pivots[pivotId];
63043
+ if (!pivot) {
63044
+ return;
62997
63045
  }
63046
+ const measureIndex = pivot.definition.measures.indexOf(measure);
63047
+ this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", {
63048
+ formula: newFormulaString,
63049
+ sheetId: measure.computedBy.sheetId,
63050
+ });
62998
63051
  }
62999
63052
  checkSortedColumnInMeasures(definition) {
63000
63053
  definition = this.repairSortedColumn(definition);
@@ -64399,11 +64452,16 @@ class SpreadingRelation {
64399
64452
  return this.arrayFormulasToResults.get(formulasPosition);
64400
64453
  }
64401
64454
  /**
64402
- * Remove a node, also remove it from other nodes adjacency list
64455
+ * Remove a spreading relation for a given array formula position
64456
+ * and its result zone
64403
64457
  */
64404
64458
  removeNode(position) {
64459
+ const resultZone = this.arrayFormulasToResults.get(position);
64460
+ if (!resultZone) {
64461
+ return;
64462
+ }
64405
64463
  this.resultsToArrayFormulas.remove({
64406
- boundingBox: { sheetId: position.sheetId, zone: positionToZone(position) },
64464
+ boundingBox: { sheetId: position.sheetId, zone: resultZone },
64407
64465
  data: position,
64408
64466
  });
64409
64467
  this.arrayFormulasToResults.delete(position);
@@ -64691,6 +64749,10 @@ class Evaluator {
64691
64749
  // empty matrix
64692
64750
  return createEvaluatedCell({ value: 0 }, this.getters.getLocale(), cellData);
64693
64751
  }
64752
+ if (nbRows === 1 && nbColumns === 1) {
64753
+ // single value matrix
64754
+ return createEvaluatedCell(nullValueToZeroValue(formulaReturn[0][0]), this.getters.getLocale(), cellData);
64755
+ }
64694
64756
  const resultZone = {
64695
64757
  top: formulaPosition.row,
64696
64758
  bottom: formulaPosition.row + nbRows - 1,
@@ -66116,6 +66178,7 @@ class HeaderSizeUIPlugin extends CoreViewPlugin {
66116
66178
  handle(cmd) {
66117
66179
  switch (cmd.type) {
66118
66180
  case "START":
66181
+ case "UPDATE_LOCALE":
66119
66182
  for (const sheetId of this.getters.getSheetIds()) {
66120
66183
  this.initializeSheet(sheetId);
66121
66184
  }
@@ -66237,7 +66300,7 @@ class HeaderSizeUIPlugin extends CoreViewPlugin {
66237
66300
  }
66238
66301
  const cell = this.getters.getCell(position);
66239
66302
  const colSize = this.getters.getColSize(position.sheetId, position.col);
66240
- return getDefaultCellHeight(this.ctx, cell, colSize);
66303
+ return getDefaultCellHeight(this.ctx, cell, this.getters.getLocale(), colSize);
66241
66304
  }
66242
66305
  isInMultiRowMerge(position) {
66243
66306
  const merge = this.getters.getMerge(position);
@@ -66284,14 +66347,16 @@ const PERCENT_FORMAT = "0.00%";
66284
66347
  function withPivotPresentationLayer (PivotClass) {
66285
66348
  class PivotPresentationLayer extends PivotClass {
66286
66349
  getters;
66350
+ pivotId;
66287
66351
  cache = {};
66288
66352
  rankAsc = {};
66289
66353
  rankDesc = {};
66290
66354
  runningTotal = {};
66291
66355
  runningTotalInPercent = {};
66292
- constructor(custom, params) {
66356
+ constructor(pivotId, custom, params) {
66293
66357
  super(custom, params);
66294
66358
  this.getters = params.getters;
66359
+ this.pivotId = pivotId;
66295
66360
  }
66296
66361
  markAsDirtyForEvaluation() {
66297
66362
  this.cache = {};
@@ -66341,7 +66406,7 @@ function withPivotPresentationLayer (PivotClass) {
66341
66406
  return handleError(error, measure.aggregator.toUpperCase());
66342
66407
  }
66343
66408
  }
66344
- const formula = this.getters.getMeasureCompiledFormula(measure);
66409
+ const formula = this.getters.getMeasureCompiledFormula(this.pivotId, measure);
66345
66410
  const getSymbolValue = (symbolName) => {
66346
66411
  const { columns, rows } = this.definition;
66347
66412
  if (columns.find((col) => col.nameWithGranularity === symbolName)) {
@@ -67069,7 +67134,7 @@ class PivotUIPlugin extends CoreViewPlugin {
67069
67134
  const definition = deepCopy(this.getters.getPivotCoreDefinition(pivotId));
67070
67135
  if (!(pivotId in this.pivots)) {
67071
67136
  const Pivot = withPivotPresentationLayer(pivotRegistry.get(definition.type).ui);
67072
- this.pivots[pivotId] = new Pivot(this.custom, { definition, getters: this.getters });
67137
+ this.pivots[pivotId] = new Pivot(pivotId, this.custom, { definition, getters: this.getters });
67073
67138
  }
67074
67139
  else if (recreate) {
67075
67140
  this.pivots[pivotId].onDefinitionChange(definition);
@@ -68124,7 +68189,7 @@ function addConditionalFormatCommandAdaptRange(cmd, applyChange) {
68124
68189
  cmd.cf.rule = {
68125
68190
  ...rule,
68126
68191
  rangeValues: rule.rangeValues
68127
- ? adaptStringRange(cmd.sheetId, rule.rangeValues, applyChange)
68192
+ ? adaptStringRange(cmd.sheetId, rule.rangeValues, applyChange).range
68128
68193
  : undefined,
68129
68194
  };
68130
68195
  }
@@ -79611,6 +79676,9 @@ function addStyles(styles) {
79611
79676
  if (style.alignment && style.alignment.wrapText) {
79612
79677
  alignAttrs.push(["wrapText", "1"]);
79613
79678
  }
79679
+ if (style.alignment && style.alignment.shrinkToFit) {
79680
+ alignAttrs.push(["shrinkToFit", "1"]);
79681
+ }
79614
79682
  if (alignAttrs.length > 0) {
79615
79683
  attributes.push(["applyAlignment", "1"]); // for Libre Office
79616
79684
  styleNodes.push(escapeXml /*xml*/ `<xf ${formatAttributes(attributes)}><alignment ${formatAttributes(alignAttrs)} /></xf> `);
@@ -80381,7 +80449,7 @@ class Model extends EventBus {
80381
80449
  this.config = this.setupConfig(config);
80382
80450
  this.session = this.setupSession(workbookData.revisionId);
80383
80451
  this.coreGetters = {};
80384
- this.range = new RangeAdapter(this.coreGetters);
80452
+ this.range = new RangeAdapterPlugin(this.coreGetters);
80385
80453
  this.coreGetters.getRangeString = this.range.getRangeString.bind(this.range);
80386
80454
  this.coreGetters.getRangeFromSheetXC = this.range.getRangeFromSheetXC.bind(this.range);
80387
80455
  this.coreGetters.createAdaptedRanges = this.range.createAdaptedRanges.bind(this.range);
@@ -80395,8 +80463,6 @@ class Model extends EventBus {
80395
80463
  this.coreGetters.extendRange = this.range.extendRange.bind(this.range);
80396
80464
  this.coreGetters.getRangesUnion = this.range.getRangesUnion.bind(this.range);
80397
80465
  this.coreGetters.removeRangesSheetPrefix = this.range.removeRangesSheetPrefix.bind(this.range);
80398
- this.coreGetters.adaptFormulaStringDependencies =
80399
- this.range.adaptFormulaStringDependencies.bind(this.range);
80400
80466
  this.coreGetters.copyFormulaStringForSheet = this.range.copyFormulaStringForSheet.bind(this.range);
80401
80467
  this.getters = {
80402
80468
  isReadonly: () => this.config.mode === "readonly" || this.config.mode === "dashboard",
@@ -81066,6 +81132,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
81066
81132
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, CoreViewPlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, chartHelpers, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateChartEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
81067
81133
 
81068
81134
 
81069
- __info__.version = "18.3.31";
81070
- __info__.date = "2025-12-26T10:18:10.765Z";
81071
- __info__.hash = "1e143e1";
81135
+ __info__.version = "18.3.33";
81136
+ __info__.date = "2026-01-21T11:05:17.933Z";
81137
+ __info__.hash = "b7e5d91";